summaryrefslogtreecommitdiff
path: root/luxio.c
diff options
context:
space:
mode:
authorRob Kendrick (humdrum) <rjek@rjek.com>2012-05-08 16:07:00 +0100
committerRob Kendrick (humdrum) <rjek@rjek.com>2012-05-08 16:07:00 +0100
commit5e4df334cc4c64ce97a326d04c67c90a2f8e993c (patch)
tree70b6cda5af40cd8a8064c0f57d277b7d3698cc6e /luxio.c
parent108d5e7bbb2c34a723a4fb353f205c13436fcec5 (diff)
downloadluxio-5e4df334cc4c64ce97a326d04c67c90a2f8e993c.tar.gz
A couple of terminal process group functions, tidy sources a little!
Diffstat (limited to 'luxio.c')
-rw-r--r--luxio.c102
1 files changed, 64 insertions, 38 deletions
diff --git a/luxio.c b/luxio.c
index 70a8dc5..4a5e285 100644
--- a/luxio.c
+++ b/luxio.c
@@ -170,7 +170,7 @@ luxio__exit(lua_State *L) /* 3.2.2 */
return 0;
}
-/* 3.3: Signals */
+/* 3.3: Signals **************************************************************/
static int
luxio_kill(lua_State *L) /* 3.3.2 */
@@ -193,7 +193,7 @@ luxio_kill(lua_State *L) /* 3.3.2 */
/* TODO: sigqueue() 3.3.9 */
/* TODO: pthread_kill() 3.3.10 */
-/* 3.4 Timer operations */
+/* 3.4 Timer operations ******************************************************/
static int
luxio_alarm(lua_State *L) /* 3.4.1 */
@@ -1264,7 +1264,30 @@ luxio_fdatasync(lua_State *L) /* 6.6.2 */
/* 7.1 General Terminal Interface ********************************************/
-/* TODO: all of this. */
+/* TODO: cfgetispeed(), cfgetospeed(), cfsetispeed(), cfsetospeed() 7.1.3 */
+/* TODO: tcgetattr(), tcsetattr() 7.2.1 */
+/* TODO: tcsendbreak(), tcdrain(), tcflush(), tcflow() 7.2.2 */
+
+static int
+luxio_tcgetpgrp(lua_State *L) /* 7.2.3 */
+{
+ lua_pushinteger(L, tcgetpgrp(luaL_checkinteger(L, 1)));
+ lua_pushinteger(L, errno);
+
+ return 2;
+}
+
+static int
+luxio_tcsetpgrp(lua_State *L) /* 7.2.4 */
+{
+ int fildes = luaL_checkinteger(L, 1);
+ pid_t pgrp_id = luaL_checkinteger(L, 2);
+
+ lua_pushinteger(L, tcsetpgrp(fildes, pgrp_id));
+ lua_pushinteger(L, errno);
+
+ return 2;
+}
/* 8.1 Referenced C Language Routines ****************************************/
@@ -2186,39 +2209,39 @@ luxio_strerror(lua_State *L)
static const struct luaL_Reg
luxio_functions[] = {
- { "open", luxio_open },
- { "close", luxio_close },
- { "read", luxio_read },
- { "write", luxio_write },
- { "writev", luxio_writev },
- { "lseek", luxio_lseek },
+ { "open", luxio_open },
+ { "close", luxio_close },
+ { "read", luxio_read },
+ { "write", luxio_write },
+ { "writev", luxio_writev },
+ { "lseek", luxio_lseek },
{ "ftruncate", luxio_ftruncate },
- { "fsync", luxio_fsync },
+ { "fsync", luxio_fsync },
{ "fdatasync", luxio_fdatasync },
- { "rename", luxio_rename },
- { "link", luxio_link },
- { "unlink", luxio_unlink },
+ { "rename", luxio_rename },
+ { "link", luxio_link },
+ { "unlink", luxio_unlink },
#ifdef HAVE_SENDFILE
- { "sendfile", luxio_sendfile },
+ { "sendfile", luxio_sendfile },
#endif
- { "dup", luxio_dup },
- { "dup2", luxio_dup2 },
+ { "dup", luxio_dup },
+ { "dup2", luxio_dup2 },
#ifdef _GNU_SOURCE
- { "dup3", luxio_dup3 },
+ { "dup3", luxio_dup3 },
#endif
- { "pipe", luxio_pipe },
+ { "pipe", luxio_pipe },
#ifdef _GNU_SOURCE
- { "pipe2", luxio_pipe2 },
+ { "pipe2", luxio_pipe2 },
#endif
{ "socketpair", luxio_socketpair },
- { "fcntl", luxio_fcntl },
- { "umask", luxio_umask },
- { "chmod", luxio_chmod },
- { "fchmod", luxio_fchmod },
- { "chown", luxio_chown },
- { "mkfifo", luxio_mkfifo },
- { "mkdir", luxio_mkdir },
- { "rmdir", luxio_rmdir },
+ { "fcntl", luxio_fcntl },
+ { "umask", luxio_umask },
+ { "chmod", luxio_chmod },
+ { "fchmod", luxio_fchmod },
+ { "chown", luxio_chown },
+ { "mkfifo", luxio_mkfifo },
+ { "mkdir", luxio_mkdir },
+ { "rmdir", luxio_rmdir },
#define STAT_IS_ENTRY(x) { "S_IS" #x, luxio_S_IS##x }
STAT_IS_ENTRY(REG),
@@ -2234,16 +2257,16 @@ luxio_functions[] = {
#endif
#undef STAT_IS_ENTRY
- { "stat", luxio_stat },
- { "lstat", luxio_lstat },
- { "fstat", luxio_fstat },
+ { "stat", luxio_stat },
+ { "lstat", luxio_lstat },
+ { "fstat", luxio_fstat },
- { "socket", luxio_socket },
- { "listen", luxio_listen },
- { "shutdown", luxio_shutdown },
- { "connect", luxio_connect },
- { "bind", luxio_bind },
- { "accept", luxio_accept },
+ { "socket", luxio_socket },
+ { "listen", luxio_listen },
+ { "shutdown", luxio_shutdown },
+ { "connect", luxio_connect },
+ { "bind", luxio_bind },
+ { "accept", luxio_accept },
{ "getsockopt", luxio_getsockopt },
{ "setsockopt", luxio_setsockopt },
@@ -2256,7 +2279,7 @@ luxio_functions[] = {
{ "pollfds_resize", luxio_pollfds_resize },
{ "pollfds_setslot", luxio_pollfds_set_slot },
{ "pollfds_getslot", luxio_pollfds_get_slot },
- { "poll", luxio_poll },
+ { "poll", luxio_poll },
{ "zero_timeval", luxio_timeval_zero },
{ "gettimeofday", luxio_gettimeofday },
@@ -2319,10 +2342,13 @@ luxio_functions[] = {
{ "time", luxio_time },
{ "times", luxio_times },
+ { "tcgetpgrp", luxio_tcgetpgrp},
+ { "tcsetpgrp", luxio_tcsetpgrp},
+
LUXIO_MQ_FUNCS
LUXIO_MQ_FUNCS_2001
- { NULL, NULL }
+ { NULL, NULL }
};
static const struct luaL_Reg