Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / dos / findvar.c
blob53a273c9dd316769df489497366bd1b332e1a08a
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Find a local variable.
6 Lang: English
7 */
8 #include "dos_intern.h"
9 #include <proto/exec.h>
10 #include <proto/utility.h>
11 #include <string.h>
13 /*****************************************************************************
15 NAME */
17 #include <proto/dos.h>
18 #include <dos/var.h>
20 AROS_LH2(struct LocalVar *, FindVar,
22 /* SYNOPSIS */
23 AROS_LHA(CONST_STRPTR, name, D1),
24 AROS_LHA(ULONG , type, D2),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 153, Dos)
29 /* FUNCTION
30 Finds a local variable structure.
32 INPUTS
33 name -- the name of the variable you wish to find. Note that
34 variable names follow the same syntax and semantics
35 as filesystem names.
36 type -- The type of variable to be found (see <dos/var.h>).
37 Actually, only the lower 8 bits of "type" are used
38 by FindVar().
40 RESULT
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.
45 NOTES
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 DeleteVar(), GetVar(), SetVar()
54 INTERNALS
55 For every local variable, a structure of type LocalVar exists:
56 struct LocalVar {
57 struct Node lv_Node;
58 UWORD lv_Flags;
59 UBYTE *lv_Value;
60 ULONG lv_Len;
63 lv_Node.ln_Type
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)
68 lv_Node.ln_Name
69 holds the variable name (NUL terminated string)
71 lv_Flags
72 stores GVF_BINARY_VAR and GVF_DONT_NULL_TERM if given as flags to
73 SetVar(). It is only used by GetVar().
75 lv_Value
76 holds the variable's value
78 lv_Len
79 is the length of lv_Value
81 *****************************************************************************/
83 AROS_LIBFUNC_INIT
84 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
86 /* Only the lowest 8 bits are valid here */
87 type &= 0xFF;
89 if (name != NULL)
91 /* We scan through the process->pr_LocalVars list */
92 struct Process *pr;
93 struct LocalVar *var;
95 pr = (struct Process *)FindTask(NULL);
96 var = (struct LocalVar *)pr->pr_LocalVars.mlh_Head;
98 ForeachNode(&pr->pr_LocalVars, var)
100 LONG res;
102 if (var->lv_Node.ln_Type == type)
104 /* The list is alphabetically sorted. */
105 res = Stricmp(name, var->lv_Node.ln_Name);
107 /* Found it */
108 if (res == 0)
110 return var;
113 /* We have gone too far through the sorted list. */
114 else if (res < 0)
116 break;
122 return NULL;
124 AROS_LIBFUNC_EXIT
125 } /* FindVar */