Moved tests into appropriate subdirs.
[AROS.git] / test / dos / getenv.c
blobb2d4c8872b32af49f1710fcab57a335515c1af6c
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/dos.h>
7 #include <stdio.h>
8 #include <stdlib.h>
10 int main(int argc, char *argv[])
12 char c;
13 if (argc < 2)
15 fprintf(stderr, "usage: %s <varname>\n", argv[0]);
16 return 20;
19 if (GetVar(argv[1], &c, 1, GVF_BINARY_VAR) == 0)
21 LONG len = IoErr();
22 char *buf = malloc(len + 1);
23 if (!buf)
25 PrintFault(ERROR_NO_FREE_STORE, argv[0]);
26 return 20;
29 printf("IoErr() says the len of the value of the var '%s' is: %ld\n",
30 argv[1], (long)len);
33 len = GetVar(argv[1], buf, len + 1, GVF_BINARY_VAR);
35 printf("GetVar() says the len of the value of the var '%s' is:"
36 " %ld - its value is '%s'\n", argv[1], (long)len, buf);
38 free(buf);
40 return 0;
43 PrintFault(IoErr(), argv[1]);
45 return 20;