lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

>Embedded systems don't generally have file (or even console) I/O. Often
>there's just a serial port. You can often get a crippled "libc.lib" for
>these systems that provides do-nothing stubs for the I/O functions.
>You could eliminate iolib and tell your users they cannot use readfrom() etc.
>You could also provide basic console I/O via your serial line, and define
>an 'error' fallback that wrote the string to it but you would still need:
>>>> A function lua_dochunk(void *) that executed a down-loaded copy of
>    luac.out, held somewhere in memory.
>As far as I can see this is *all* you would need, provided you are prepared
>to fiddle with the linker and maybe write a few missing stubs yourself; a
>cost I, at least, would be prepared to accept.

I suggest you write a simple stdio replacement that reads from strings.
Something like:

typedef struct {
	char* buffer; /* original string */
	char* current;
	int size;

int getc(FILE* f)
	if (current<(buffer+size)) return *current++


With this replacement, you should be able to use undump.c as is.
Also, you can arrange so that stdin, stdout and stderr act as /dev/null/.
This should be compatible with the rest of the stdio code in Lua.
Now, someone in the world probably has already written such a replacement for
stdio, although it's pretty easy to write too. If you do write it, I'd be