Wasmtime
wasi.h
Go to the documentation of this file.
1
7#ifndef WASI_H
8#define WASI_H
9
10#include "wasm.h"
11#include <stdint.h>
12
13#ifndef WASI_API_EXTERN
14#ifdef _WIN32
15#define WASI_API_EXTERN __declspec(dllimport)
16#else
17#define WASI_API_EXTERN
18#endif
19#endif
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#define own
26
27#define WASI_DECLARE_OWN(name) \
28 typedef struct wasi_##name##_t wasi_##name##_t; \
29 WASI_API_EXTERN void wasi_##name##_delete(own wasi_##name##_t *);
30
41WASI_DECLARE_OWN(config)
42
43
48WASI_API_EXTERN own wasi_config_t *wasi_config_new();
49
59WASI_API_EXTERN void wasi_config_set_argv(wasi_config_t *config, int argc,
60 const char *argv[]);
61
66WASI_API_EXTERN void wasi_config_inherit_argv(wasi_config_t *config);
67
80WASI_API_EXTERN void wasi_config_set_env(wasi_config_t *config, int envc,
81 const char *names[],
82 const char *values[]);
83
88WASI_API_EXTERN void wasi_config_inherit_env(wasi_config_t *config);
89
99WASI_API_EXTERN bool wasi_config_set_stdin_file(wasi_config_t *config,
100 const char *path);
101
111WASI_API_EXTERN void wasi_config_set_stdin_bytes(wasi_config_t *config,
112 wasm_byte_vec_t *binary);
113
118WASI_API_EXTERN void wasi_config_inherit_stdin(wasi_config_t *config);
119
129WASI_API_EXTERN bool wasi_config_set_stdout_file(wasi_config_t *config,
130 const char *path);
131
136WASI_API_EXTERN void wasi_config_inherit_stdout(wasi_config_t *config);
137
147WASI_API_EXTERN bool wasi_config_set_stderr_file(wasi_config_t *config,
148 const char *path);
149
154WASI_API_EXTERN void wasi_config_inherit_stderr(wasi_config_t *config);
155
167WASI_API_EXTERN bool wasi_config_preopen_dir(wasi_config_t *config,
168 const char *path,
169 const char *guest_path);
170
182WASI_API_EXTERN bool wasi_config_preopen_socket(wasi_config_t *config,
183 uint32_t fd_num,
184 const char *host_port);
185
186#undef own
187
188#ifdef __cplusplus
189} // extern "C"
190#endif
191
192#endif // #ifdef WASI_H
A list of bytes.
Definition: wasm.h:102
void wasi_config_inherit_env(wasi_config_t *config)
Indicates that the entire environment of the calling process should be inherited by this WASI configu...
void wasi_config_inherit_argv(wasi_config_t *config)
Indicates that the argv list should be inherited from this process's argv list.
void wasi_config_inherit_stderr(wasi_config_t *config)
Configures this process's own stderr stream to be used as stderr for this WASI configuration.
bool wasi_config_preopen_socket(wasi_config_t *config, uint32_t fd_num, const char *host_port)
Configures a "preopened" listen socket to be available to WASI APIs.
bool wasi_config_set_stdout_file(wasi_config_t *config, const char *path)
Configures standard output to be written to the specified file.
void wasi_config_set_stdin_bytes(wasi_config_t *config, wasm_byte_vec_t *binary)
Configures standard input to be taken from the specified wasm_byte_vec_t.
bool wasi_config_preopen_dir(wasi_config_t *config, const char *path, const char *guest_path)
Configures a "preopened directory" to be available to WASI APIs.
void wasi_config_set_argv(wasi_config_t *config, int argc, const char *argv[])
Sets the argv list for this configuration object.
void wasi_config_inherit_stdout(wasi_config_t *config)
Configures this process's own stdout stream to be used as stdout for this WASI configuration.
bool wasi_config_set_stderr_file(wasi_config_t *config, const char *path)
Configures standard output to be written to the specified file.
void wasi_config_set_env(wasi_config_t *config, int envc, const char *names[], const char *values[])
Sets the list of environment variables available to the WASI instance.
void wasi_config_inherit_stdin(wasi_config_t *config)
Configures this process's own stdin stream to be used as stdin for this WASI configuration.
bool wasi_config_set_stdin_file(wasi_config_t *config, const char *path)
Configures standard input to be taken from the specified file.
wasi_config_t * wasi_config_new()
Creates a new empty configuration object.