Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / c / shellcommands / Unsetenv.c
blob024a758c9c85bd347a0ff069786c4dda0449a370
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Unsetenv CLI command
6 Lang: English
7 */
9 /*****************************************************************************
11 NAME
13 Unsetenv
15 SYNOPSIS
17 NAME
19 LOCATION
21 Sys:c
23 FUNCTION
25 INPUTS
27 NAME - The name of the global variable to unset.
29 RESULT
31 Standard DOS error codes.
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
41 INTERNALS
43 HISTORY
45 ******************************************************************************/
47 #include <proto/dos.h>
48 #include <proto/exec.h>
50 #include <dos/dos.h>
51 #include <dos/exall.h>
52 #include <dos/rdargs.h>
53 #include <dos/var.h>
54 #include <exec/memory.h>
55 #include <exec/types.h>
56 #include <utility/tagitem.h>
57 #include <aros/shcommands.h>
59 AROS_SH1(Unsetenv, 41.0,
60 AROS_SHA(STRPTR, ,NAME, ,NULL))
62 AROS_SHCOMMAND_INIT
65 if (SHArg(NAME) != NULL)
67 /* Delete the global variable from the list.
69 if (!DeleteVar(SHArg(NAME), GVF_GLOBAL_ONLY))
70 return RETURN_FAIL;
72 else
74 /* Display a list of global variables.
76 BPTR lock = NULL;
77 struct FileInfoBlock *FIB = NULL;
81 !(lock = Lock("ENV:", ACCESS_READ)) ||
82 !(FIB = AllocDosObject(DOS_FIB, NULL)) ||
83 (Examine(lock, FIB) == DOSFALSE)
86 if (FIB) FreeDosObject(DOS_FIB, FIB);
87 if (lock) UnLock(lock);
89 return RETURN_FAIL;
92 while (ExNext(lock, FIB))
94 /* don't show dirs */
95 if (FIB->fib_DirEntryType < 0)
97 FPuts(Output(),FIB->fib_FileName);
98 FPuts(Output(),"\n");
102 FreeDosObject(DOS_FIB, FIB);
103 UnLock(lock);
106 return RETURN_OK;
108 AROS_SHCOMMAND_EXIT
109 } /* main */