tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / test / dos / scanvarstest.c
blob90bc29042ea3be9cf25f7941e105049c7d23b578
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: dos.library ScanVars() function test.
6 */
8 #include <string.h>
9 #include <stdio.h>
11 #include <proto/dos.h>
12 #include <proto/utility.h>
13 #include <dos/var.h>
15 AROS_UFH3(LONG, print_var,
16 AROS_UFHA(struct Hook *, hook, A0),
17 AROS_UFHA(APTR, userdata, A2),
18 AROS_UFHA(struct ScanVarsMsg *, message, A1))
20 AROS_USERFUNC_INIT
22 printf("Hook called with userdata: %s\n", (char *)userdata);
23 printf("%s=%.*s\n", message->sv_Name, (int)message->sv_VarLen,
24 message->sv_Var);
25 return 0;
27 AROS_USERFUNC_EXIT
30 AROS_UFH3(LONG, print_var_break,
31 AROS_UFHA(struct Hook *, hook, A0),
32 AROS_UFHA(APTR, userdata, A2),
33 AROS_UFHA(struct ScanVarsMsg *, message, A1))
35 AROS_USERFUNC_INIT
37 printf("Hook called with userdata: %s\n", (char *)userdata);
38 printf("%s=%.*s\n", message->sv_Name, (int)message->sv_VarLen,
39 message->sv_Var);
40 if (!strncmp("var2", message->sv_Name, 4))
42 printf("Scanned var2 variable!\n");
43 return 1;
45 return 0;
47 AROS_USERFUNC_EXIT
50 int main(void)
52 struct Hook hook;
53 char userdata[] = "Some user data...";
54 LONG ret;
56 memset(&hook, 0, sizeof(struct Hook));
57 hook.h_Entry = (HOOKFUNC) print_var;
59 printf("Scanning local variables:\n");
60 ret = ScanVars(&hook, GVF_LOCAL_ONLY, userdata);
61 printf("ScanVars returned %d\n", (int)ret);
63 printf("Adding some new local variables:\n");
64 SetVar("var1", "Value of variable 1", -1, GVF_LOCAL_ONLY);
65 SetVar("var2", "Value of variable 2", -1, GVF_LOCAL_ONLY);
66 SetVar("var3", "Value of variable 3", -1, GVF_LOCAL_ONLY);
67 printf("Scanning local variables again:\n");
68 ret = ScanVars(&hook, GVF_LOCAL_ONLY, userdata);
69 printf("ScanVars returned %d\n", (int)ret);
71 printf("Trying to print all variables up to var2:\n");
72 hook.h_Entry = (HOOKFUNC) print_var_break;
73 ret = ScanVars(&hook, GVF_LOCAL_ONLY, userdata);
74 printf("ScanVars returned %d\n", (int)ret);
76 return 0;