revert wrong commit
[AROS.git] / test / scanvarstest.c
blobf83f2fad9b9471424db2c1df04cb428403771e59
1 /*
2 Copyright © 1995-2008, 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
21 printf("Hook called with userdata: %s\n", (char*) userdata);
22 printf("%s=%.*s\n", message->sv_Name, (int)message->sv_VarLen, message->sv_Var);
23 return 0;
24 AROS_USERFUNC_EXIT
27 AROS_UFH3(LONG, print_var_break,
28 AROS_UFHA(struct Hook *, hook, A0),
29 AROS_UFHA(APTR, userdata, A2),
30 AROS_UFHA(struct ScanVarsMsg *, message, A1))
32 AROS_USERFUNC_INIT
33 printf("Hook called with userdata: %s\n", (char*) userdata);
34 printf("%s=%.*s\n", message->sv_Name, (int)message->sv_VarLen, message->sv_Var);
35 if(!strncmp("var2", message->sv_Name, 4))
37 printf("Scanned var2 variable!\n");
38 return 1;
40 return 0;
41 AROS_USERFUNC_EXIT
44 int main(void)
46 struct Hook hook;
47 char userdata[] = "Some user data...";
48 LONG ret;
50 memset(&hook, 0, sizeof(struct Hook));
51 hook.h_Entry = (HOOKFUNC)print_var;
53 printf("Scanning local variables:\n");
54 ret = ScanVars(&hook, GVF_LOCAL_ONLY, userdata);
55 printf("ScanVars returned %d\n", (int)ret);
57 printf("Adding some new local variables:\n");
58 SetVar("var1","Value of variable 1", -1, GVF_LOCAL_ONLY);
59 SetVar("var2","Value of variable 2", -1, GVF_LOCAL_ONLY);
60 SetVar("var3","Value of variable 3", -1, GVF_LOCAL_ONLY);
61 printf("Scanning local variables again:\n");
62 ret = ScanVars(&hook, GVF_LOCAL_ONLY, userdata);
63 printf("ScanVars returned %d\n", (int)ret);
65 printf("Trying to print all variables up to var2:\n");
66 hook.h_Entry = (HOOKFUNC)print_var_break;
67 ret = ScanVars(&hook, GVF_LOCAL_ONLY, userdata);
68 printf("ScanVars returned %d\n", (int)ret);
70 return 0;