diff --git a/Makefile b/Makefile index e1ccceb..16d9f65 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ endif %.$(LIBSUFFIX): %.c $(CC) -shared -fPIC $(CFLAGS) $< -o $@ -all: native/fopen.$(LIBSUFFIX) native/fgetc.$(LIBSUFFIX) native/feof.$(LIBSUFFIX) +all: native/fopen.$(LIBSUFFIX) native/fgetc.$(LIBSUFFIX) native/feof.$(LIBSUFFIX) native/fputc.$(LIBSUFFIX) native/fclose.$(LIBSUFFIX) clean: rm native/*.$(LIBSUFFIX) diff --git a/native/fputc.c b/native/fputc.c new file mode 100644 index 0000000..e14b154 --- /dev/null +++ b/native/fputc.c @@ -0,0 +1,14 @@ +#include +#include + +void labashka(unsigned short (*pop)(void), void (*push)(unsigned short), size_t (*len)(void), size_t max_size ) { + unsigned short symbol = pop(); + + FILE *file = NULL; + file = (void*)((size_t)(pop()) << (16*0) | (size_t)file); + file = (void*)((size_t)(pop()) << (16*1) | (size_t)file); + file = (void*)((size_t)(pop()) << (16*2) | (size_t)file); + file = (void*)((size_t)(pop()) << (16*3) | (size_t)file); + + push(fputc(symbol, file)); +} diff --git a/putc_file.lb b/putc_file.lb new file mode 100644 index 0000000..d6fbb1e --- /dev/null +++ b/putc_file.lb @@ -0,0 +1,5 @@ +@ 0 + args 5 + size + #exec std/rev.lb + #native liblabafile/native/fputc diff --git a/puttest.lb b/puttest.lb new file mode 100644 index 0000000..5330044 --- /dev/null +++ b/puttest.lb @@ -0,0 +1,9 @@ +@ 0 + $string somefile.txt + #string w + #exec liblabafile/open_file.lb + #exec std/dup4.lb + push 70 + #exec liblabafile/putc_file.lb + pop + #exec liblabafile/close_file.lb