grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / c / shellcommands / Getenv.c
blob6dadfc781202ebf1eb5362141b64823497271a50
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Getenv CLI command
6 Lang: English
7 */
9 /*****************************************************************************
11 NAME
13 Getenv
15 SYNOPSIS
17 NAME/A
19 LOCATION
23 FUNCTION
25 Retrieves the information stored in the given global variable.
27 INPUTS
29 NAME - The name of the global variable.
31 RESULT
33 Standard DOS error codes.
35 NOTES
37 EXAMPLE
39 Getenv Kickstart
41 This will retrieve the version of the Kickstart ROM.
43 BUGS
45 SEE ALSO
47 Setenv, Unsetenv
49 INTERNALS
51 HISTORY
53 30-Jul-1997 laguest Corrected a few things in the source
54 27-Jul-1997 laguest Initial inclusion into the AROS tree
56 ******************************************************************************/
58 #include <proto/dos.h>
60 #include <dos/dos.h>
61 #include <dos/rdargs.h>
62 #include <dos/var.h>
63 #include <exec/types.h>
65 #include <aros/shcommands.h>
67 #define BUFFER_SIZE 256
69 AROS_SH1(Getenv, 41.1,
70 AROS_SHA(STRPTR, ,NAME,/A,NULL))
72 AROS_SHCOMMAND_INIT
74 LONG Var_Length;
75 char Var_Value[BUFFER_SIZE];
77 Var_Length = GetVar(SHArg(NAME),
78 &Var_Value[0],
79 BUFFER_SIZE,
80 GVF_GLOBAL_ONLY | LV_VAR
83 if (Var_Length != -1)
85 Printf("%s\n", Var_Value);
87 return RETURN_OK;
90 SetIoErr(ERROR_OBJECT_NOT_FOUND);
91 PrintFault(IoErr(), "Getenv");
93 return RETURN_WARN;
95 AROS_SHCOMMAND_EXIT
96 } /* main */