aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2025-01-04 04:29:39 +0100
committerPřemysl Eric Janouch <p@janouch.name>2025-01-04 04:29:39 +0100
commite612d80cc3c3ef139bfcf8b5acee57262b41be13 (patch)
treeec50a34f713b7a363bb4085a8142fcb54a42ef86
parentbd264787c167368e11c4397aac3e84440b7f1f17 (diff)
downloadliberty-e612d80cc3c3ef139bfcf8b5acee57262b41be13.tar.gz
liberty-e612d80cc3c3ef139bfcf8b5acee57262b41be13.tar.xz
liberty-e612d80cc3c3ef139bfcf8b5acee57262b41be13.zip
WIP
-rw-r--r--tools/wdye/wdye.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/wdye/wdye.c b/tools/wdye/wdye.c
index 3985abf..6ab903f 100644
--- a/tools/wdye/wdye.c
+++ b/tools/wdye/wdye.c
@@ -235,8 +235,23 @@ static int
xlua_process_send (lua_State *L)
{
struct process *self = luaL_checkudata (L, 1, XLUA_PROCESS_METATABLE);
- // TODO(p)
- return 0;
+ int nargs = lua_gettop (L);
+ for (int i = 2; i <= nargs; i++)
+ if (!lua_isstring (L, i))
+ return luaL_error (L, "need string arguments");
+
+ for (int i = 2; i <= nargs; i++)
+ {
+ size_t len = 0;
+ const char *arg = lua_tolstring (L, i, &len);
+ ssize_t written = write (self->terminal_fd, arg, len);
+ if (written == -1)
+ return luaL_error (L, "write failed: %s", strerror (errno));
+ else if (written != len)
+ return luaL_error (L, "write failed: %s", "short write");
+ }
+ lua_pushvalue (L, 1);
+ return 1;
}
static luaL_Reg xlua_process_table[] =