projects
/
project
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nixio:
[project/luci.git]
/
libs
/
nixio
/
src
/
nixio.c
diff --git
a/libs/nixio/src/nixio.c
b/libs/nixio/src/nixio.c
index
0c8ee6e
..
e44f5fd
100644
(file)
--- a/
libs/nixio/src/nixio.c
+++ b/
libs/nixio/src/nixio.c
@@
-20,6
+20,7
@@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <signal.h>
#define VERSION 0.1
#define VERSION 0.1
@@
-53,12
+54,6
@@
nixio_sock* nixio__checksock(lua_State *L) {
return sock;
}
return sock;
}
-FILE* nixio__checkfile(lua_State *L) {
- FILE **fpp = (FILE**)luaL_checkudata(L, 1, NIXIO_FILE_META);
- luaL_argcheck(L, *fpp, 1, "invalid file object");
- return *fpp;
-}
-
/* read fd from nixio_sock object */
int nixio__checksockfd(lua_State *L) {
return nixio__checksock(L)->fd;
/* read fd from nixio_sock object */
int nixio__checksockfd(lua_State *L) {
return nixio__checksock(L)->fd;
@@
-80,7
+75,9
@@
int nixio__tofd(lua_State *L, int ud) {
luaL_getmetatable(L, LUA_FILEHANDLE);
if (lua_rawequal(L, -3, -4)) {
fd = ((nixio_sock*)udata)->fd;
luaL_getmetatable(L, LUA_FILEHANDLE);
if (lua_rawequal(L, -3, -4)) {
fd = ((nixio_sock*)udata)->fd;
- } else if (lua_rawequal(L, -2, -4) || lua_rawequal(L, -1, -4)) {
+ } else if (lua_rawequal(L, -2, -4)) {
+ fd = *((int*)udata);
+ } else if (lua_rawequal(L, -1, -4)) {
fd = (*((FILE **)udata)) ? fileno(*((FILE **)udata)) : -1;
}
lua_pop(L, 4);
fd = (*((FILE **)udata)) ? fileno(*((FILE **)udata)) : -1;
}
lua_pop(L, 4);
@@
-88,8
+85,14
@@
int nixio__tofd(lua_State *L, int ud) {
return fd;
}
return fd;
}
+static int nixio_strerror(lua_State *L) {
+ lua_pushstring(L, strerror(luaL_checkinteger(L, 1)));
+ return 1;
+}
+
/* object table */
static const luaL_reg R[] = {
/* object table */
static const luaL_reg R[] = {
+ {"strerror", nixio_strerror},
{NULL, NULL}
};
{NULL, NULL}
};
@@
-107,7
+110,7
@@
LUALIB_API int luaopen_nixio(lua_State *L) {
/* register metatable as socket_meta */
lua_pushvalue(L, -2);
/* register metatable as socket_meta */
lua_pushvalue(L, -2);
- lua_setfield(L, -2, "
socket_meta
");
+ lua_setfield(L, -2, "
meta_socket
");
/* register methods */
nixio_open_file(L);
/* register methods */
nixio_open_file(L);
@@
-118,6
+121,7
@@
LUALIB_API int luaopen_nixio(lua_State *L) {
nixio_open_poll(L);
nixio_open_io(L);
nixio_open_splice(L);
nixio_open_poll(L);
nixio_open_io(L);
nixio_open_splice(L);
+ nixio_open_process(L);
nixio_open_tls_context(L);
nixio_open_tls_socket(L);
nixio_open_tls_context(L);
nixio_open_tls_socket(L);
@@
-126,7
+130,7
@@
LUALIB_API int luaopen_nixio(lua_State *L) {
lua_setfield(L, -2, "version");
/* some constants */
lua_setfield(L, -2, "version");
/* some constants */
- lua_createtable(L, 0, 1);
+ lua_createtable(L, 0, 1
1
);
NIXIO_PUSH_CONSTANT(EACCES);
NIXIO_PUSH_CONSTANT(ENOSYS);
NIXIO_PUSH_CONSTANT(EACCES);
NIXIO_PUSH_CONSTANT(ENOSYS);
@@
-134,6
+138,11
@@
LUALIB_API int luaopen_nixio(lua_State *L) {
NIXIO_PUSH_CONSTANT(EWOULDBLOCK);
NIXIO_PUSH_CONSTANT(EAGAIN);
NIXIO_PUSH_CONSTANT(ENOMEM);
NIXIO_PUSH_CONSTANT(EWOULDBLOCK);
NIXIO_PUSH_CONSTANT(EAGAIN);
NIXIO_PUSH_CONSTANT(ENOMEM);
+ NIXIO_PUSH_CONSTANT(ENOENT);
+ NIXIO_PUSH_CONSTANT(SIGALRM);
+ NIXIO_PUSH_CONSTANT(SIGINT);
+ NIXIO_PUSH_CONSTANT(SIGTERM);
+ NIXIO_PUSH_CONSTANT(SIGKILL);
lua_setfield(L, -2, "const");
lua_setfield(L, -2, "const");