about summary refs log tree commit diff stats
path: root/src/teliva.c
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-05 18:04:35 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-03-05 18:04:35 -0800
commit52ae23784b5474298c6ada6252f5a785fc5e8c19 (patch)
tree519e3b3812f4543161b5c4ed9674a7e2b59bb785 /src/teliva.c
parent2d6b88204bca1787cbcc08bbff4383e1980cd196 (diff)
downloadteliva-52ae23784b5474298c6ada6252f5a785fc5e8c19.tar.gz
new API for file operations
File operations now always return a channel (or nil on error or
permission denied).

When start_reading() from a filename, you can repeatedly :recv() from
the channel it returns.
When :recv() returns nil, you're at the end of the file. Stop.

When you start_writing() to a filename, you can repeatedly :send() to
the channel it returns.
When you're done writing, :close() the channel. Writes to the file won't
be externally visible until you do.

To make this work I'm now always starting up the scheduler, so I need to
fix sieve.tlv.

Transparently running the scheduler is an abstraction, and whenever I
create an abstraction I always worry about how it might fail. There's
a hopefully-clear error when you read past end of a file.
Diffstat (limited to 'src/teliva.c')
-rw-r--r--src/teliva.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/teliva.c b/src/teliva.c
index 90da6f1..2e9c9d9 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -1794,7 +1794,7 @@ int handle_image(lua_State* L, char** argv, int n) {
   /* initialize permissions */
   load_permissions_from_user_configuration(L);
   /* call main() */
-  lua_getglobal(L, "main");
+  lua_getglobal(L, "spawn_main");
   status = docall(L, 0, 1);
   if (status != 0) return report_in_developer_mode(L, status);
   return 0;