Copyright clean-up (part 1):
[AROS.git] / test / dos / getenv.c
blobfc3fdf43a36cd1e0d7eb62f976103bd596dcf608
1 /*
2 Copyright © 1995-2014, 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", argv[1], (long)len);
32 len = GetVar(argv[1], buf, len+1, GVF_BINARY_VAR);
34 printf("GetVar() says the len of the value of the var '%s' is: %ld - its value is '%s'\n",
35 argv[1], (long)len, buf);
37 free(buf);
39 return 0;
42 PrintFault(IoErr(), argv[1]);
44 return 20;