quickjs-libc.h (2951B)
1 /* 2 * QuickJS C library 3 * 4 * Copyright (c) 2017-2018 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 #ifndef QUICKJS_LIBC_H 25 #define QUICKJS_LIBC_H 26 27 #include <stdio.h> 28 #include <stdlib.h> 29 30 #include "quickjs.h" 31 32 #ifndef NO_HTTP 33 #include "quickjs-http.h" 34 #endif 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 typedef void (*JSHostMessageHandlerFn)(void *cls, const char *msg); 41 42 JSModuleDef *js_init_module_std(JSContext *ctx, const char *module_name); 43 JSModuleDef *js_init_module_os(JSContext *ctx, const char *module_name); 44 void js_std_add_helpers(JSContext *ctx, int argc, char **argv); 45 void js_std_loop(JSContext *ctx); 46 JSValue js_std_await(JSContext *ctx, JSValue obj); 47 void js_std_init_handlers(JSRuntime *rt); 48 void js_std_free_handlers(JSRuntime *rt); 49 void js_std_dump_error(JSContext *ctx); 50 uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename); 51 int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val, 52 JS_BOOL use_realpath, JS_BOOL is_main); 53 JSModuleDef *js_module_loader(JSContext *ctx, 54 const char *module_name, void *opaque); 55 void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len, 56 int flags); 57 void js_std_promise_rejection_tracker(JSContext *ctx, JSValueConst promise, 58 JSValueConst reason, 59 JS_BOOL is_handled, void *opaque); 60 void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt)); 61 void js_os_set_host_message_handler(JSContext *ctx, JSHostMessageHandlerFn f, void *cls); 62 int js_os_post_message_from_host(JSContext *ctx, const char *msg_str); 63 64 #ifndef NO_HTTP 65 void js_os_set_http_impl(JSRuntime *rt, struct JSHttpClientImplementation *impl); 66 #endif 67 68 #ifdef __cplusplus 69 } /* extern "C" { */ 70 #endif 71 72 #endif /* QUICKJS_LIBC_H */