LIBMAWK_GET_VAR(3libmawk)
π LIBMAWK_GET_VAR(3libmawk) π
okay bestie, welcome to the libmawk manual β yes we're doing C library lore today and honestly? it's giving iconic. sit down, grab a strawberry, we're getting a pointer to a mawk variable πΈ
β¨ NAME β¨
libmawk_get_var β returns a pointer to a mawk variable π«Ά
π SYNOPSIS π
#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);
like yes, two functions, one header, we love a duo π
π¦ DESCRIPTION π¦
so. libmawk_get_var() hands you back a pointer to a mawk cell that represents the global variable whose name you dropped in vname, inside the context you passed in. that's it, that's the whole vibe.
β οΈ okay this part is IMPORTANT bestie β theCELLyou get back should never befree'd, destroyed, or modified. not even a little. hands off. it's not yours, it's the library's π
and if you're like "ok but how do i even look at it", the function libmawk_print_cell may be used for converting the cell to a string β¨
π libmawk_get_array_at() β the array girlie π
libmawk_get_array_at() does the exact same operation, but for an element of an array instead of a plain global.
- it returns
-1ifarr_nameis not an array, or if anything goes wrong (error city π) - if
idxis not an existing index in the array, it gets allocated β but only ifallocis non-zero. so like,alloc= "go ahead, make it exist" - if
resis notNULL, it gets destroyed β regardless of the return value, no takebacks β and then, if the index exists (or was just created by this very call), it's loaded with the value - the caller needs to destroy
resafter use. that's on you, not on the library - and because
resgets destroyed whenever it's non-NULL, it must be a valid cell with a valid type. no half-baked cells, periodt π
π about that m argument
argument m is a libmawk context that was previously returned by libmawk_initialize() or libmawk_initialize_stage3(). so don't just make one up, get it from those first, iykyk π§
β SEE ALSO β
libmawk_initialize_stage(3libmawk)libmawk_initialize(3libmawk)libmawk_call_function(3libmawk)libmawk_print_cell(3libmawk)
and that's the whole page, bestie, you ate π
this was libmawk, dated 2009-08-12, from the LIBMAWK_GET_VAR(3libmawk) era β vintage but still slaying ππ
π¦ where this page comes from
- debian bookworm: libmawk1 1.0.2-3
- debian trixie: libmawk1t64 1.0.4-4
- fedora 43: libmawk-devel 1.0.3-8.fc41 Β· GPLv2
- fedora 43: libmawk-devel 1.0.3-8.fc41 Β· GPLv2
- fedora 44: libmawk-devel 1.0.5-1.fc44 Β· GPL-2.0-only
- fedora 44: libmawk-devel 1.0.5-1.fc44 Β· GPL-2.0-only
- ubuntu jammy: libmawk1 1.0.2-3
- ubuntu noble: libmawk1t64 1.0.4-3build1
- ubuntu questing: libmawk1t64 1.0.4-5
- ubuntu resolute: libmawk1t64 1.0.5-1
- ubuntu stonking: libmawk1t64 1.0.5-1
- Copyright 2009..2014 Tibor Palinkas (mawk@inno.bme.hu)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms