Documentation
WASI
environ_get

environ_get()

Read environment variable data.

Description

The environ_get() function is used to read the environment variable data. It writes the environment variable pointers and string data to the specified buffers. The sizes of the buffers should match the values returned by the environ_sizes_get() function.

Syntax

  ;;; Key/value pairs are expected to be joined with `=`s, and terminated with `\0`s.
  ;;; The sizes of the buffers should match that returned by `environ_sizes_get`.
  ;;; Read environment variable data.
  (@interface func (export "environ_get")
    (param $environ (@witx pointer (@witx pointer u8)))
    (param $environ_buf (@witx pointer u8))
    (result $error (expected (error $errno)))
  )

Parameters

  • ctx: A mutable reference to the function environment.
  • environ: A WebAssembly pointer to a buffer where the environment variable pointers will be written.
  • environ_buf: A WebAssembly pointer to a buffer where the environment variable string data will be written.

Return Value

The function returns an Errno value indicating the success or failure of the operation.

Logging

This function has been instrumented with debug-level logging.

Note

The environ_get() function reads the environment variable data and writes the environment variable pointers and string data to the specified buffers. The actual data is retrieved from the WebAssembly module's state.