LIBMAWK_I...IZE_STAGE(3libmawk)
π LIBMAWK_INITIALIZE_STAGE* π
okay bestie, welcome to the libmawk manual, section 3libmawk β this one's all about spinning up a brand new libmawk context in three β¨stagesβ¨ instead of one big gulp. it's giving controlled chaos, and we're obsessed. π¦
πΈ NAME πΈ
libmawk_initialize_stage* β create a new libmawk context in 3 stages
π SYNOPSIS π
#include <libmawk.h>
mawk_state_t *libmawk_initialize_stage1(void);
mawk_state_t *libmawk_initialize_stage2(mawk_state_t * m,int s ,char*"argv[]);
mawk_state_t *libmawk_initialize_stage3(mawk_state_t * m);
(yes, that char*"argv[] is literally what it says, we do not touch the sacred text π
)
β¨ DESCRIPTION β¨
so the libmawk_initialize_stage*() functions, when you put all three together, do exactly the same thing as libmawk_initialize() β but they let your application slide in and do stuff between the stages. main character energy, honestly. π
libmawk_initialize_stage1() hands you back a pointer to a freshly created libmawk context. and no cap, you can have any number of libmawk contexts living in parallel inside one application. it's a whole friend group. π«Ά
libmawk_initialize_stage2() is what you call after a successful stage1 call. Stage2 is the one responsible for processing the command line arguments and loading any script. π
the arguments are the same as for a command line mawk session, periodt. scripts get loaded (either straight from the command line or from files using -f), variables get set (with -v), special options get set (with -W), etc. but here's the slay: unlike with libmawk_initialize(), your application is allowed to just... not provide any script at this stage. all command line arguments are processed regardless. π
the most common case, fr fr, is that the application calls stage1 with no script, and then β because it already has a context β does some manipulations on it. for example, registering some C functions that would already get called in the BEGIN part of the script that's gonna be loaded later. iconic behavior. π
optionally, before calling stage2, the application loads the actual script(s) using mawk_append_input_file().
libmawk_initialize_stage3() is the grand finale of the three-stage initialization process. Stage3 is responsible for running all the BEGIN parts of all scripts loaded at stage1 or stage2. π₯
and the reason it's a separate call? so your application can manipulate the context right before initializing the scripts. it's giving "let me fix my hair before the photo". πΈ
Stage2 gets the pointer that stage1 returned, and stage3 gets the pointer that stage2 returned. subsequent calls to libmawk functions should get the pointer that stage3 returned. chain of custody, bestie. π
β RETURN VALUE β
- at stage 1: a pointer to a new libmawk context, or
NULLon error. π - subsequent stages: they return that same pointer, or
NULLon error.
ngl if you get NULL back, something went wrong β that's your vibe check failing. π
π SEE ALSO π
libmawk_initialize_stage(3libmawk)libmawk_uninitialize(3libmawk)mawk_append_input_file(3libmawk)
and that's the whole page, bestie β go forth and initialize responsibly. this was the libmawk manual, section 3libmawk, dated 2009-08-10, and honestly it ate. πβ¨π bye!! π¦πΈ
π¦ 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 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