diff options
author | Andrew Clayton <a.clayton@nginx.com> | 2023-08-02 17:03:48 +0100 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2023-08-21 23:24:12 +0100 |
commit | d6ed6a219b31a58526721f96195c80061d41ce54 (patch) | |
tree | 17a1fd6ecf72a327916ff0f8bc7aaf85b981ceff /examples/c/unit-wasm-raw.h | |
download | unit-wasm-d6ed6a219b31a58526721f96195c80061d41ce54.tar.gz unit-wasm-d6ed6a219b31a58526721f96195c80061d41ce54.tar.bz2 |
Initial commitv0.1.0
libunit-wasm and example C and Rust WebAssembly modules for NGINX Unit.
Co-developed-by: Timo Stark <t.stark@nginx.com>
Co-developed-by: Liam Crilly <liam@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'examples/c/unit-wasm-raw.h')
-rw-r--r-- | examples/c/unit-wasm-raw.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/examples/c/unit-wasm-raw.h b/examples/c/unit-wasm-raw.h new file mode 100644 index 0000000..6fd9d35 --- /dev/null +++ b/examples/c/unit-wasm-raw.h @@ -0,0 +1,87 @@ +#ifndef _UNIT_WASM_H_ +#define _UNIT_WASM_H_ + +#include <stddef.h> +#include <stdint.h> + +typedef uint64_t u64; +typedef int64_t s64; +typedef uint32_t u32; +typedef int32_t s32; +typedef uint16_t u16; +typedef int16_t s16; +typedef uint8_t u8; +typedef int8_t s8; + +#ifndef __unused +#define __unused __attribute__((unused)) +#endif +#ifndef __maybe_unused +#define __maybe_unused __unused +#endif +#ifndef __always_unused +#define __always_unused __unused +#endif + +struct hdr_field { + u32 name_offs; + u32 name_len; + u32 value_offs; + u32 value_len; +}; + +struct req { + u32 method_offs; + u32 method_len; + u32 version_offs; + u32 version_len; + u32 path_offs; + u32 path_len; + u32 query_offs; + u32 query_len; + u32 remote_offs; + u32 remote_len; + u32 local_addr_offs; + u32 local_addr_len; + u32 local_port_offs; + u32 local_port_len; + u32 server_name_offs; + u32 server_name_len; + + u32 content_offs; + u32 content_len; + u32 content_sent; + u32 total_content_sent; + + u32 request_size; + + u32 nr_fields; + + u32 tls; + + struct hdr_field fields[]; +}; + +struct resp { + u32 size; + + u8 data[]; +}; + +struct resp_hdr { + u32 nr_fields; + + struct hdr_field fields[]; +}; + +extern void wasm_module_end_handler(void); +extern void wasm_module_init_handler(void); +extern void wasm_response_end_handler(void); +extern void wasm_request_end_handler(void); +extern void wasm_free_handler(u32 addr); +extern u32 wasm_malloc_handler(size_t size); +extern int wasm_request_handler(u8 *addr); + +extern void send_headers(u8 *addr, const char *ct, size_t len); + +#endif /* _UNIT_WASM_H_ */ |