1LIBMAWK_GET_VAR(3libmawk) libmawk manual LIBMAWK_GET_VAR(3libmawk)
2
3
4
6 libmawk_get_var - returns a pointer to a mawk variable
7
9 #include <libmawk.h>
10
11 const CELL *libmawk_get_var(mawk_state_t *m, const char *vname);
12 int libmawk_get_array_at(mawk_state_t *m, const char *arr_name,
13 const char *idx, const char *res, int alloc);
14
15
17 The libmawk_get_var() function returns a pointer to a mawk cell that
18 represents the global variable with name passed in vname in the given
19 context. The returned CELL should never be free'd or destroyed or modi‐
20 fied. Function libmawk_print_cell may be used for converting the cell
21 to string.
22
23 Function libmawk_get_array_at() performs the same operation for an ele‐
24 ment of an array. -1 is returned if arr_name is not an array or upon an
25 error. If idx is not an existing index in the array it is allocated if
26 alloc is non-zero. If res is not NULL, it is destroyed (regardless of
27 the return value) and if the index exists (or is created by the call),
28 is loaded with the value. The caller needs to destroy res after use.
29 Since res is destroyed when non-NULL, it must be a valid cell with
30 valid type.
31
32 Argument m is a libmawk context previously returned by libmawk_initial‐
33 ize() or libmawk_initialize_stage3().
34
35
37 libmawk_initialize_stage(3libmawk), libmawk_initialize(3libmawk), lib‐
38 mawk_call_function(3libmawk), libmawk_print_cell(3libmawk).
39
40
41
42
43
44libmawk 2009-08-12 LIBMAWK_GET_VAR(3libmawk)