dos.library LVO mismatch fixes
[AROS.git] / rom / dos / scanvars.c
blob97b2268d39276b86b10a594502da6ce4b183591b
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include "dos_intern.h"
10 #include <proto/utility.h>
11 #include <exec/lists.h>
12 #include <dos/var.h>
14 /*****************************************************************************
16 NAME */
17 #include <proto/dos.h>
19 AROS_LH3(LONG, ScanVars,
21 /* SYNOPSIS */
22 AROS_LHA(struct Hook *, hook, D1),
23 AROS_LHA(ULONG, flags, D2),
24 AROS_LHA(APTR, userdata, D3),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 169, Dos)
29 /* FUNCTION
30 Scan local and/or global variables accordingly to specified flags. For
31 each scanned variable hook function is called. Scanning process will
32 continue as long as hook returns 0. If hook returns a non-zero value,
33 scanning will be aborted and ScanVars will return this value.
35 INPUTS
36 userdata - Any user-specific data passed to hook function.
37 flags - Same as in GetVar().
38 hook - Hook function that will be called for each scanned variable as:
39 result = hook_function(hook,userdata,message) with ScanVarsMsg
40 structure as message parameter containing information about given
41 variable.
43 RESULT
44 !=0 returned by hook function if scan process was aborted, 0 otherwise.
46 NOTES
47 ScanVarsMsg structure content is valid only during hook call.
48 See <dos/var.h> for description of ScanVarsMsg structure.
50 This function is compatible with AmigaOS v4.
52 EXAMPLE
54 BUGS
55 Currently only local variables scanning is implemented.
57 SEE ALSO
58 DeleteVar(), FindVar(), GetVar(), SetVar(), <dos/var.h>
60 INTERNALS
62 *****************************************************************************/
64 AROS_LIBFUNC_INIT
66 /* We scan through the process->pr_LocalVars list */
67 struct Process *pr;
68 struct LocalVar *var;
69 struct ScanVarsMsg msg;
70 LONG res;
72 msg.sv_SVMSize = sizeof(struct ScanVarsMsg);
73 msg.sv_Flags = flags;
74 pr = (struct Process *)FindTask(NULL);
76 /* not global only? */
77 if(0 == (flags & GVF_GLOBAL_ONLY))
79 var = (struct LocalVar *)pr->pr_LocalVars.mlh_Head;
81 ForeachNode(&pr->pr_LocalVars, var)
83 if (var->lv_Node.ln_Type == LV_VAR)
85 msg.sv_Name = var->lv_Node.ln_Name;
86 msg.sv_Var = var->lv_Value;
87 msg.sv_VarLen = var->lv_Len;
88 msg.sv_GDir = "";
89 res = CallHookPkt(hook, userdata, &msg);
90 if(res != 0)
91 return(res);
95 return 0;
97 AROS_LIBFUNC_EXIT