Detabbed
[AROS.git] / rom / dos / scanvars.c
blob4e4dbec9e143f90830e5119efea94b3f26e92e8a
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
11 #include "dos_intern.h"
12 #include <proto/utility.h>
13 #include <exec/lists.h>
14 #include <dos/var.h>
16 /*****************************************************************************
18 NAME */
19 #include <proto/dos.h>
21 AROS_LH3(LONG, ScanVars,
23 /* SYNOPSIS */
24 AROS_LHA(struct Hook *, hook, D1),
25 AROS_LHA(ULONG, flags, D2),
26 AROS_LHA(APTR, userdata, D3),
28 /* LOCATION */
29 struct DosLibrary *, DOSBase, 169, Dos)
31 /* FUNCTION
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.
37 INPUTS
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
43 variable.
45 RESULT
46 !=0 returned by hook function if scan process was aborted, 0 otherwise.
48 NOTES
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.
54 EXAMPLE
56 BUGS
57 Currently only local variables scanning is implemented.
59 SEE ALSO
60 DeleteVar(), FindVar(), GetVar(), SetVar(), <dos/var.h>
62 INTERNALS
64 *****************************************************************************/
66 AROS_LIBFUNC_INIT
68 /* We scan through the process->pr_LocalVars list */
69 struct Process *pr;
70 struct LocalVar *var;
71 struct ScanVarsMsg msg;
72 LONG res;
74 msg.sv_SVMSize = sizeof(struct ScanVarsMsg);
75 msg.sv_Flags = flags;
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;
92 msg.sv_GDir = "";
93 res = CallHookPkt(hook, userdata, &msg);
94 if(res != 0)
95 return(res);
99 return 0;
101 AROS_LIBFUNC_EXIT