2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Desc: Find a local variable.
9 #include <aros/debug.h>
10 #include "dos_intern.h"
11 #include <proto/exec.h>
12 #include <proto/utility.h>
15 /*****************************************************************************
19 #include <proto/dos.h>
22 AROS_LH2(struct LocalVar
*, FindVar
,
25 AROS_LHA(CONST_STRPTR
, name
, D1
),
26 AROS_LHA(ULONG
, type
, D2
),
29 struct DosLibrary
*, DOSBase
, 153, Dos
)
32 Finds a local variable structure.
35 name - the name of the variable you wish to find. Note that
36 variable names follow the same syntax and semantics
38 type - The type of variable to be found (see <dos/var.h>).
39 Actually, only the lower 8 bits of "type" are used
43 A pointer to the LocalVar structure for that variable if it was
44 found. If the variable wasn't found, or was of the wrong type,
45 NULL will be returned.
54 DeleteVar(), GetVar(), SetVar()
57 For every local variable, a structure of type LocalVar exists:
66 holds the variable type, either LV_VAR for regular local environment
67 variables or LV_ALIAS for shell aliases. dos/var.h also defines
68 LVF_IGNORE (for private usage by the shell)
71 holds the variable name (NUL terminated string)
74 stores GVF_BINARY_VAR and GVF_DONT_NULL_TERM if given as flags to
75 SetVar(). It is only used by GetVar().
78 holds the variable's value
81 is the length of lv_Value
83 *****************************************************************************/
87 /* Only the lowest 8 bits are valid here */
92 /* We scan through the process->pr_LocalVars list */
96 pr
= (struct Process
*)FindTask(NULL
);
97 ASSERT_VALID_PROCESS(pr
);
98 var
= (struct LocalVar
*)pr
->pr_LocalVars
.mlh_Head
;
100 ForeachNode(&pr
->pr_LocalVars
, var
)
104 if (var
->lv_Node
.ln_Type
== type
)
106 /* The list is alphabetically sorted. */
107 res
= Stricmp(name
, var
->lv_Node
.ln_Name
);
115 /* We have gone too far through the sorted list. */