Map menu key to right amiga to allow clipboard operations on keyboards without right...
[AROS.git] / rom / dos / scanvars.c
blobec46bde9f818ee3002cc4fa067da334f55a5d808
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, 167, 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 EXAMPLE
52 BUGS
53 Currently only local variables scanning is implemented.
55 SEE ALSO
56 DeleteVar(), FindVar(), GetVar(), SetVar(), <dos/var.h>
58 INTERNALS
60 *****************************************************************************/
62 AROS_LIBFUNC_INIT
64 /* We scan through the process->pr_LocalVars list */
65 struct Process *pr;
66 struct LocalVar *var;
67 struct ScanVarsMsg msg;
68 LONG res;
70 msg.sv_SVMSize = sizeof(struct ScanVarsMsg);
71 msg.sv_Flags = flags;
72 pr = (struct Process *)FindTask(NULL);
74 /* not global only? */
75 if(0 == (flags & GVF_GLOBAL_ONLY))
77 var = (struct LocalVar *)pr->pr_LocalVars.mlh_Head;
79 ForeachNode(&pr->pr_LocalVars, var)
81 if (var->lv_Node.ln_Type == LV_VAR)
83 msg.sv_Name = var->lv_Node.ln_Name;
84 msg.sv_Var = var->lv_Value;
85 msg.sv_VarLen = var->lv_Len;
86 msg.sv_GDir = "";
87 res = CallHookPkt(hook, userdata, &msg);
88 if(res != 0)
89 return(res);
93 return 0;
95 AROS_LIBFUNC_EXIT