Rename eof to at_end.

This is more fitting as end of file is not really true for a socket.
This commit is contained in:
Jonathan Schleifer 2012-09-30 03:34:46 +02:00
parent 3e038e2ba3
commit 377cdc9fa2
4 changed files with 20 additions and 20 deletions

View file

@ -57,7 +57,7 @@
struct CFWFile { struct CFWFile {
CFWStream stream; CFWStream stream;
int fd; int fd;
bool eof; bool at_end;
}; };
static int static int
@ -98,7 +98,7 @@ file_read(void *ptr, void *buf, size_t len)
ssize_t ret; ssize_t ret;
if ((ret = read(file->fd, buf, len)) == 0) if ((ret = read(file->fd, buf, len)) == 0)
file->eof = true; file->at_end = true;
return ret; return ret;
} }
@ -116,11 +116,11 @@ file_write(void *ptr, const void *buf, size_t len)
} }
static bool static bool
file_eof(void *ptr) file_at_end(void *ptr)
{ {
CFWFile *file = ptr; CFWFile *file = ptr;
return file->eof; return file->at_end;
} }
static void static void
@ -134,7 +134,7 @@ file_close(void *ptr)
static struct cfw_stream_ops stream_ops = { static struct cfw_stream_ops stream_ops = {
.read = file_read, .read = file_read,
.write = file_write, .write = file_write,
.eof = file_eof, .at_end = file_at_end,
.close = file_close .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 */ /* Make sure we have a valid file in case we error out */
cfw_stream->ctor(ptr, args); cfw_stream->ctor(ptr, args);
file->eof = false; file->at_end = false;
if ((flags = parse_mode(mode)) == -1) if ((flags = parse_mode(mode)) == -1)
return false; return false;
@ -184,7 +184,7 @@ static CFWFile cfw_stdin_ = {
.ops = &stream_ops .ops = &stream_ops
}, },
.fd = 0, .fd = 0,
.eof = false .at_end = false
}; };
static CFWFile cfw_stdout_ = { static CFWFile cfw_stdout_ = {
.stream = { .stream = {
@ -195,7 +195,7 @@ static CFWFile cfw_stdout_ = {
.ops = &stream_ops .ops = &stream_ops
}, },
.fd = 1, .fd = 1,
.eof = false .at_end = false
}; };
static CFWFile cfw_stderr_ = { static CFWFile cfw_stderr_ = {
.stream = { .stream = {
@ -206,7 +206,7 @@ static CFWFile cfw_stderr_ = {
.ops = &stream_ops .ops = &stream_ops
}, },
.fd = 2, .fd = 2,
.eof = false .at_end = false
}; };
CFWFile *cfw_stdin = &cfw_stdin_; CFWFile *cfw_stdin = &cfw_stdin_;
CFWFile *cfw_stdout = &cfw_stdout_; CFWFile *cfw_stdout = &cfw_stdout_;

View file

@ -141,7 +141,7 @@ cfw_stream_read_line(void *ptr)
return NULL; return NULL;
for (;;) { for (;;) {
if (stream->ops->eof(stream)) { if (stream->ops->at_end(stream)) {
free(buf); free(buf);
if (stream->cache == NULL) if (stream->cache == NULL)
@ -274,7 +274,7 @@ cfw_stream_write_line(void *ptr, const char *str)
} }
bool bool
cfw_stream_eof(void *ptr) cfw_stream_at_end(void *ptr)
{ {
CFWStream *stream = ptr; CFWStream *stream = ptr;
@ -284,7 +284,7 @@ cfw_stream_eof(void *ptr)
if (stream->cache != NULL) if (stream->cache != NULL)
return false; return false;
return stream->ops->eof(stream); return stream->ops->at_end(stream);
} }
void void

View file

@ -36,7 +36,7 @@
struct cfw_stream_ops { struct cfw_stream_ops {
ssize_t (*read)(void*, void*, size_t); ssize_t (*read)(void*, void*, size_t);
bool (*write)(void*, const void*, size_t); bool (*write)(void*, const void*, size_t);
bool (*eof)(void*); bool (*at_end)(void*);
void (*close)(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(void*, const void*, size_t);
extern bool cfw_stream_write_string(void*, const char*); extern bool cfw_stream_write_string(void*, const char*);
extern bool cfw_stream_write_line(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*); extern void cfw_stream_close(void*);
#endif #endif

View file

@ -42,7 +42,7 @@
struct CFWTCPSocket { struct CFWTCPSocket {
CFWStream stream; CFWStream stream;
int fd; int fd;
bool eof; bool at_end;
}; };
static ssize_t static ssize_t
@ -52,7 +52,7 @@ sock_read(void *ptr, void *buf, size_t len)
ssize_t ret; ssize_t ret;
if ((ret = recv(sock->fd, buf, len, 0)) == 0) if ((ret = recv(sock->fd, buf, len, 0)) == 0)
sock->eof = true; sock->at_end = true;
return ret; return ret;
} }
@ -70,11 +70,11 @@ sock_write(void *ptr, const void *buf, size_t len)
} }
static bool static bool
sock_eof(void *ptr) sock_at_end(void *ptr)
{ {
CFWTCPSocket *sock = ptr; CFWTCPSocket *sock = ptr;
return sock->eof; return sock->at_end;
} }
static void static void
@ -89,7 +89,7 @@ sock_close(void *ptr)
static struct cfw_stream_ops stream_ops = { static struct cfw_stream_ops stream_ops = {
.read = sock_read, .read = sock_read,
.write = sock_write, .write = sock_write,
.eof = sock_eof, .at_end = sock_at_end,
.close = sock_close .close = sock_close
}; };
@ -102,7 +102,7 @@ ctor(void *ptr, va_list args)
sock->fd = -1; sock->fd = -1;
sock->stream.ops = &stream_ops; sock->stream.ops = &stream_ops;
sock->eof = false; sock->at_end = false;
return true; return true;
} }