1LIBMAWK_INITIALIZE_STAGE(3libmawkl)ibmawk manuaLlIBMAWK_INITIALIZE_STAGE(3libmawk)
2
3
4

NAME

6       libmawk_initialize_stage* - create a new libmawk context in 3 stages
7

SYNOPSIS

9       #include <libmawk.h>
10
11       mawk_state_t *libmawk_initialize_stage1(void);
12
13       mawk_state_t *libmawk_initialize_stage2(mawk_state_t * m,int s ,char*"argv[]);
14
15       mawk_state_t *libmawk_initialize_stage3(mawk_state_t * m);
16
17

DESCRIPTION

19       The  libmawk_initialize_stage*() functions together do the same as lib‐
20       mawk_initialize() but allows the application to  take  actions  between
21       different  stages.   libmawk_initialize_stage1() returns a pointer to a
22       newly created libmawk context. Any amount of libmawk contexts can  live
23       in parallel in an application.
24
25       libmawk_initialize_stage2()  can  be  called  after  a succesful stage1
26       call.
27        Stage2 is responsible for processing the command  line  arguments  and
28       loading any script.
29
30       Arguments  are the same as for a command line mawk session. Scripts are
31       loaded (either from command line or from files using -f), variables are
32       set (with -v), special options are set (with -W), etc. Unlike with lib‐
33       mawk_initialize(), the application may decide not to provide any script
34       at this stage. All command line arguments are processed.
35
36       The  most  common  case  is  that  the application calls stage1 with no
37       script, then already having a context makes some  manipulations  on  it
38       (for example registers some C functions that would be already called in
39       the BEGIN part of the script that will  be  later  loaded).  Optionally
40       before  calling stage2 the application loads the actual script(s) using
41       mawk_append_input_file().
42
43       libmawk_initialize_stage3() is called as a final  step  of  the  three-
44       stage initialization process. Stage3 is responsible for running all the
45       BEGIN parts of all scripts loaded at stage1 or stage2. It is useful  to
46       have  stage3 in a separate call to allow applications to manipulate the
47       context right before initializing the scripts.
48
49       Stage2 gets the pointer returned by stage1 and stage3 gets the  pointer
50       returned  by  stage2.  Subsequent calls to libmawk functions should get
51       the pointer returned by stage3.
52
53

RETURN VALUE

55       At stage 1 a pointer to a new libmawk context or NULL on error.  Subse‐
56       quent stages will return the same pointer or NULL on error.
57

SEE ALSO

59       libmawk_initialize_stage(3libmawk),     libmawk_uninitialize(3libmawk),
60       mawk_append_input_file(3libmawk).
61
62
63
64libmawk                           2009-08-10LIBMAWK_INITIALIZE_STAGE(3libmawk)
Impressum