2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Find a local variable.
8 #include "dos_intern.h"
9 #include <proto/exec.h>
10 #include <proto/utility.h>
13 /*****************************************************************************
17 #include <proto/dos.h>
20 AROS_LH2(struct LocalVar
*, FindVar
,
23 AROS_LHA(CONST_STRPTR
, name
, D1
),
24 AROS_LHA(ULONG
, type
, D2
),
27 struct DosLibrary
*, DOSBase
, 153, Dos
)
30 Finds a local variable structure.
33 name -- the name of the variable you wish to find. Note that
34 variable names follow the same syntax and semantics
36 type -- The type of variable to be found (see <dos/var.h>).
37 Actually, only the lower 8 bits of "type" are used
41 A pointer to the LocalVar structure for that variable if it was
42 found. If the variable wasn't found, or was of the wrong type,
43 NULL will be returned.
52 DeleteVar(), GetVar(), SetVar()
55 For every local variable, a structure of type LocalVar exists:
64 holds the variable type, either LV_VAR for regular local environment
65 variables or LV_ALIAS for shell aliases. dos/var.h also defines
66 LVF_IGNORE (for private usage by the shell)
69 holds the variable name (NUL terminated string)
72 stores GVF_BINARY_VAR and GVF_DONT_NULL_TERM if given as flags to
73 SetVar(). It is only used by GetVar().
76 holds the variable's value
79 is the length of lv_Value
81 *****************************************************************************/
85 /* Only the lowest 8 bits are valid here */
90 /* We scan through the process->pr_LocalVars list */
94 pr
= (struct Process
*)FindTask(NULL
);
95 var
= (struct LocalVar
*)pr
->pr_LocalVars
.mlh_Head
;
97 ForeachNode(&pr
->pr_LocalVars
, var
)
101 if (var
->lv_Node
.ln_Type
== type
)
103 /* The list is alphabetically sorted. */
104 res
= Stricmp(name
, var
->lv_Node
.ln_Name
);
112 /* We have gone too far through the sorted list. */