summaryrefslogtreecommitdiff
path: root/luxio.c
diff options
context:
space:
mode:
authorRichard Ipsum <richardipsum@fastmail.co.uk>2018-10-12 18:10:53 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2018-10-21 13:39:52 +0100
commit301de4c825ae109cc3a7c780d662863ada62753b (patch)
tree6ec32101bff5b6b36603a4aa2b3a7cbcd26f1995 /luxio.c
parent4e95fbccfbbec3c1ebc10dc156a154a2953200dd (diff)
downloadluxio-301de4c825ae109cc3a7c780d662863ada62753b.tar.bz2
Bind sysconf(3)
Diffstat (limited to 'luxio.c')
-rw-r--r--luxio.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/luxio.c b/luxio.c
index 6507a00..97323f1 100644
--- a/luxio.c
+++ b/luxio.c
@@ -1011,7 +1011,17 @@ luxio_isatty(lua_State *L)
/* 4.8 Configurable system variables *****************************************/
-/* TODO: sysconf() 4.8.1 */
+static int
+luxio_sysconf(lua_State *L)
+{
+ int name = luaL_checkinteger(L, 1);
+ long result = sysconf(name);
+
+ lua_pushinteger(L, result);
+ lua_pushinteger(L, result == -1 ? errno : 0);
+
+ return 2;
+}
/*** Directories.
@section dir
@@ -4592,6 +4602,8 @@ luxio_functions[] = {
{ "ttyname", luxio_ttyname },
{ "isatty", luxio_isatty },
+ { "sysconf", luxio_sysconf },
+
{ NULL, NULL }
};