From 1b7ec24a2f702ffcc3409eb74ef0399ae6206bbe Mon Sep 17 00:00:00 2001 From: vms Date: Tue, 20 Aug 2019 14:36:14 +0200 Subject: [PATCH] get rid of imports --- backend-c/src/main.c | 20 +++++++++++++++++--- backend-c/src/model.c | 6 +++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/backend-c/src/main.c b/backend-c/src/main.c index 914eb4d..3dca45d 100644 --- a/backend-c/src/main.c +++ b/backend-c/src/main.c @@ -3,7 +3,21 @@ #include "model.h" #include "../libs/tiny-json/tiny-json.h" -//#include +#include +#include +#include + +size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) { + return 1; +} + +int __stdio_close(FILE *f) { + return 1; +} + +off_t __stdio_seek(FILE *_f, off_t _offset, int _value) { + return 0; +} char *prepare_response(const char *response, int response_length) { const int RESPONSE_SIZE_BYTES = 4; @@ -21,7 +35,7 @@ char *prepare_response(const char *response, int response_length) { const char *add_post_request(const json_t *json); const char *fetch_posts_request(const json_t *json); -char *invoke(char *str, int length) { +const char *invoke(char *str, int length) { wasm_log(str, length); json_t pool[10]; @@ -53,7 +67,7 @@ char *invoke(char *str, int length) { result = fetch_posts_request(json); } else { char *error = (char *)malloc(1024); - const int error_size = snprintf(error, 1024, "%s given as the action field, but only `Post` and `Fetch` are supported"); + const int error_size = snprintf(error, 1024, "%s given as the action field, but only `Post` and `Fetch` are supported", action); result = prepare_response(error, error_size); } diff --git a/backend-c/src/model.c b/backend-c/src/model.c index 1795635..5709d25 100644 --- a/backend-c/src/model.c +++ b/backend-c/src/model.c @@ -1,9 +1,9 @@ #include "../sdk/side_module_api.h" -//#include -//#include + +#include +#include __MODULE_IMPORT(sqlite) -int snprintf ( char * s, int n, const char * format, ... ); // TODO: introduce error codes and security checks