force CC/CXX to the passed in compiler to use.
[AROS.git] / workbench / c / shellcommands / Unset.c
blob29f6520aab59e7b1736694c16521a2ecf545e659
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 $Id$
5 Unset CLI command.
6 */
8 /*****************************************************************************
10 NAME
12 Unset
14 SYNOPSIS
16 NAME
18 LOCATION
22 FUNCTION
24 Deletes local variable.
26 INPUTS
28 NAME - The name of the local variable to unset.
30 RESULT
32 Standard DOS error codes.
34 NOTES
36 EXAMPLE
38 BUGS
40 SEE ALSO
42 INTERNALS
44 ******************************************************************************/
47 #include <proto/dos.h>
48 #include <proto/exec.h>
50 #include <dos/dos.h>
51 #include <dos/dosextens.h>
52 #include <dos/rdargs.h>
53 #include <dos/var.h>
54 #include <exec/lists.h>
55 #include <exec/nodes.h>
56 #include <exec/types.h>
57 #include <aros/shcommands.h>
59 #define BUFFER_SIZE 160
61 static void GetNewString(STRPTR, STRPTR, LONG);
63 AROS_SH1(Unset, 41.0,
64 AROS_SHA(STRPTR, ,NAME, ,NULL))
66 AROS_SHCOMMAND_INIT
68 struct Process * UnsetProc;
69 struct LocalVar * UnsetNode;
70 LONG VarLength;
71 char Buffer1[BUFFER_SIZE];
72 char Buffer2[BUFFER_SIZE];
75 if (SHArg(NAME) != NULL)
77 /* Delete the local Var from the list.
80 if (!DeleteVar(SHArg(NAME), GVF_LOCAL_ONLY))
82 return RETURN_FAIL;
86 else
88 /* Display a list of local variables.
90 UnsetProc = (struct Process *)FindTask(NULL);
92 ForeachNode(&(UnsetProc->pr_LocalVars), UnsetNode)
94 if (UnsetNode->lv_Node.ln_Type == LV_VAR)
96 /* Get a clean variable with no excess
97 * characters.
99 VarLength = -1;
100 VarLength = GetVar(UnsetNode->lv_Node.ln_Name,
101 &Buffer1[0],
102 BUFFER_SIZE,
103 GVF_LOCAL_ONLY);
105 if (VarLength != -1)
107 GetNewString(&Buffer1[0], &Buffer2[0], VarLength);
109 Buffer2[VarLength] = 0;
111 Printf("%-20s\t%-20s\n", UnsetNode->lv_Node.ln_Name, Buffer2);
117 return RETURN_OK;
119 AROS_SHCOMMAND_EXIT
120 } /* main */
123 static void GetNewString(STRPTR s, STRPTR d, LONG l)
125 int i;
126 int j;
128 i = j = 0;
130 while (i < l)
132 if (s[i] == '*' || s[i] == '\e')
134 d[j] = '*';
136 i++;
137 j++;
139 else
141 d[j] = s[i];
143 i++;
144 j++;
147 } /* GetNewString */