Forgotten changes that should have been part of the r45368 64-bit fix.
[AROS.git] / test / dos / getenv.c
blob2ee1dde1f68ed109de7ef42c5c2aba43df6c5e94
1 #include <proto/dos.h>
2 #include <stdio.h>
3 #include <stdlib.h>
5 int main(int argc, char *argv[])
7 char c;
8 if (argc < 2)
10 fprintf(stderr, "usage: %s <varname>\n", argv[0]);
11 return 20;
14 if (GetVar(argv[1], &c, 1, GVF_BINARY_VAR) == 0)
16 LONG len = IoErr();
17 char *buf = malloc(len + 1);
18 if (!buf)
20 PrintFault(ERROR_NO_FREE_STORE, argv[0]);
21 return 20;
24 printf("IoErr() says the len of the value of the var '%s' is: %ld\n", argv[1], (long)len);
27 len = GetVar(argv[1], buf, len+1, GVF_BINARY_VAR);
29 printf("GetVar() says the len of the value of the var '%s' is: %ld - its value is '%s'\n",
30 argv[1], (long)len, buf);
32 free(buf);
34 return 0;
37 PrintFault(IoErr(), argv[1]);
39 return 20;