DOKK / manpages / debian 10 / libmawk1 / libmawk_get_var.3libmawk.en
LIBMAWK_GET_VAR(3libmawk) libmawk manual LIBMAWK_GET_VAR(3libmawk)

libmawk_get_var - returns a pointer to a mawk variable

#include <libmawk.h>

const CELL *libmawk_get_var(mawk_state_t *m, const char *vname);
int libmawk_get_array_at(mawk_state_t *m, const char *arr_name,
            const char *idx, const char *res, int alloc);

The libmawk_get_var() function returns a pointer to a mawk cell that represents the global variable with name passed in vname in the given context. The returned CELL should never be free'd or destroyed or modified. Function libmawk_print_cell may be used for converting the cell to string.

Function libmawk_get_array_at() performs the same operation for an element of an array. -1 is returned if arr_name is not an array or upon an error. If idx is not an existing index in the array it is allocated if alloc is non-zero. If res is not NULL, it is destroyed (regardless of the return value) and if the index exists (or is created by the call), is loaded with the value. The caller needs to destroy res after use. Since res is destroyed when non-NULL, it must be a valid cell with valid type.

Argument m is a libmawk context previously returned by libmawk_initialize() or libmawk_initialize_stage3().

libmawk_initialize_stage(3libmawk), libmawk_initialize(3libmawk), libmawk_call_function(3libmawk), libmawk_print_cell(3libmawk).

2009-08-12 libmawk