2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
9 #include <aros/debug.h>
11 #include "dos_intern.h"
12 #include <proto/utility.h>
13 #include <exec/lists.h>
16 /*****************************************************************************
19 #include <proto/dos.h>
21 AROS_LH3(LONG
, ScanVars
,
24 AROS_LHA(struct Hook
*, hook
, D1
),
25 AROS_LHA(ULONG
, flags
, D2
),
26 AROS_LHA(APTR
, userdata
, D3
),
29 struct DosLibrary
*, DOSBase
, 169, Dos
)
32 Scan local and/or global variables accordingly to specified flags. For
33 each scanned variable hook function is called. Scanning process will
34 continue as long as hook returns 0. If hook returns a non-zero value,
35 scanning will be aborted and ScanVars will return this value.
38 userdata - Any user-specific data passed to hook function.
39 flags - Same as in GetVar().
40 hook - Hook function that will be called for each scanned variable as:
41 result = hook_function(hook,userdata,message) with ScanVarsMsg
42 structure as message parameter containing information about given
46 !=0 returned by hook function if scan process was aborted, 0 otherwise.
49 ScanVarsMsg structure content is valid only during hook call.
50 See <dos/var.h> for description of ScanVarsMsg structure.
52 This function is compatible with AmigaOS v4.
57 Currently only local variables scanning is implemented.
60 DeleteVar(), FindVar(), GetVar(), SetVar(), <dos/var.h>
64 *****************************************************************************/
68 /* We scan through the process->pr_LocalVars list */
71 struct ScanVarsMsg msg
;
74 msg
.sv_SVMSize
= sizeof(struct ScanVarsMsg
);
76 pr
= (struct Process
*)FindTask(NULL
);
78 ASSERT_VALID_PROCESS(pr
);
80 /* not global only? */
81 if(0 == (flags
& GVF_GLOBAL_ONLY
))
83 var
= (struct LocalVar
*)pr
->pr_LocalVars
.mlh_Head
;
85 ForeachNode(&pr
->pr_LocalVars
, var
)
87 if (var
->lv_Node
.ln_Type
== LV_VAR
)
89 msg
.sv_Name
= var
->lv_Node
.ln_Name
;
90 msg
.sv_Var
= var
->lv_Value
;
91 msg
.sv_VarLen
= var
->lv_Len
;
93 res
= CallHookPkt(hook
, userdata
, &msg
);