diff options
author | Steven Barth <steven@midlink.org> | 2009-03-03 22:44:26 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-03-03 22:44:26 +0000 |
commit | e38c438771d10231e7ce1b74c027b4914acd6c78 (patch) | |
tree | 91ca365e48919d9af60e11ec7564f47538208289 /libs/nixio/src/splice.c | |
parent | a3079828b4e0c0fabd96dfca87b99a5b5d9529e5 (diff) |
nixio:
Use POSIX file functions
introduce dup()
introduce fork() wait() kill()
more signal interrupt wrappers
more POSIX / UNIX standard compliance
Diffstat (limited to 'libs/nixio/src/splice.c')
-rw-r--r-- | libs/nixio/src/splice.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/libs/nixio/src/splice.c b/libs/nixio/src/splice.c index cbfc67499..0f715c2bb 100644 --- a/libs/nixio/src/splice.c +++ b/libs/nixio/src/splice.c @@ -16,8 +16,6 @@ * limitations under the License. */ -#define _GNU_SOURCE - #include "nixio.h" #include <fcntl.h> #include <string.h> @@ -25,6 +23,8 @@ #include <unistd.h> #include <sys/sendfile.h> +#ifdef _GNU_SOURCE + /* guess what sucks... */ #ifdef __UCLIBC__ #include <unistd.h> @@ -47,30 +47,6 @@ ssize_t splice(int __fdin, __off64_t *__offin, int __fdout, #endif /* __UCLIBC__ */ /** - * Translate splice flags to integer - */ -static int nixio_splice_flags(lua_State *L) { - const int j = lua_gettop(L); - int flags = 0; - for (int i=1; i<=j; i++) { - const char *flag = luaL_checkstring(L, i); - if (!strcmp(flag, "move")) { - flags |= SPLICE_F_MOVE; - } else if (!strcmp(flag, "nonblock")) { - flags |= SPLICE_F_NONBLOCK; - } else if (!strcmp(flag, "more")) { - flags |= SPLICE_F_MORE; - } else { - return luaL_argerror(L, i, "supported values: " - "move, nonblock, more"); - } - } - lua_pushinteger(L, flags); - - return 1; -} - -/** * splice(fd_in, fd_out, length, flags) */ static int nixio_splice(lua_State *L) { @@ -92,12 +68,32 @@ static int nixio_splice(lua_State *L) { return 1; } -static int nixio_splice_avail(lua_State *L) { - splice(-1, 0, -1, 0, 0, 0); - lua_pushboolean(L, errno != ENOSYS); +/** + * Translate splice flags to integer + */ +static int nixio_splice_flags(lua_State *L) { + const int j = lua_gettop(L); + int flags = 0; + for (int i=1; i<=j; i++) { + const char *flag = luaL_checkstring(L, i); + if (!strcmp(flag, "move")) { + flags |= SPLICE_F_MOVE; + } else if (!strcmp(flag, "nonblock")) { + flags |= SPLICE_F_NONBLOCK; + } else if (!strcmp(flag, "more")) { + flags |= SPLICE_F_MORE; + } else { + return luaL_argerror(L, i, "supported values: " + "move, nonblock, more"); + } + } + lua_pushinteger(L, flags); + return 1; } +#endif /* _GNU_SOURCE */ + /** * sendfile(outfd, infd, length) */ @@ -118,9 +114,10 @@ static int nixio_sendfile(lua_State *L) { /* module table */ static const luaL_reg R[] = { +#ifdef _GNU_SOURCE {"splice", nixio_splice}, {"splice_flags", nixio_splice_flags}, - {"splice_avail", nixio_splice_avail}, +#endif {"sendfile", nixio_sendfile}, {NULL, NULL} }; |