diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-10-02 01:27:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-10-02 01:27:55 +0900 |
| commit | 7e9c65507f2ba51ff7c13cfc18cf29722b89c973 (patch) | |
| tree | ad4a566a5bf9e225b212c033608188b31735d6fb /php-wasm.c | |
| parent | fcf36b3c9e42ab9fa0ed0e037c6492d0d496f954 (diff) | |
| download | tiny-php.wasm-7e9c65507f2ba51ff7c13cfc18cf29722b89c973.tar.gz tiny-php.wasm-7e9c65507f2ba51ff7c13cfc18cf29722b89c973.tar.zst tiny-php.wasm-7e9c65507f2ba51ff7c13cfc18cf29722b89c973.zip | |
commit files
Diffstat (limited to 'php-wasm.c')
| -rw-r--r-- | php-wasm.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/php-wasm.c b/php-wasm.c new file mode 100644 index 0000000..cef661f --- /dev/null +++ b/php-wasm.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <emscripten.h> +#include <Zend/zend_execute.h> +#include <sapi/embed/php_embed.h> + +int EMSCRIPTEN_KEEPALIVE php_wasm_run(const char* code) { + zend_result result; + + int argc = 1; + char* argv[] = { "php.wasm", NULL }; + + PHP_EMBED_START_BLOCK(argc, argv); + + result = zend_eval_string_ex(code, NULL, "php.wasm code", 1); + + PHP_EMBED_END_BLOCK(); + + fprintf(stdout, "\n"); + fflush(stdout); + fprintf(stderr, "\n"); + fflush(stderr); + + return result == SUCCESS ? 0 : 1; +} |
