Fixed and unified debug output.
[AROS.git] / test / scanvarstest.c
blobd3cdbe504e3262752abcbfce5049a57ba489c16e
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 LONG print_var(struct Hook *hook, APTR userdata, struct ScanVarsMsg *message)
17 printf("Hook called with userdata: %s\n", (char*) userdata);
18 printf("%s=%.*s\n", message->sv_Name, message->sv_VarLen, message->sv_Var);
19 return 0;
22 LONG print_var_break(struct Hook *hook, APTR userdata, struct ScanVarsMsg *message)
24 printf("Hook called with userdata: %s\n", (char*) userdata);
25 printf("%s=%.*s\n", message->sv_Name, message->sv_VarLen, message->sv_Var);
26 if(!strncmp("var2", message->sv_Name, 4))
28 printf("Scanned var2 variable!\n");
29 return 1;
31 return 0;
34 int main(void)
36 struct Hook hook;
37 char userdata[] = "Some user data...";
38 LONG ret;
40 memset(&hook, 0, sizeof(struct Hook));
41 hook.h_Entry = print_var;
43 printf("Scanning local variables:\n");
44 ret = ScanVars(&hook, GVF_LOCAL_ONLY, userdata);
45 printf("ScanVars returned %d\n", ret);
47 printf("Adding some new local variables:\n");
48 SetVar("var1","Value of variable 1", -1, GVF_LOCAL_ONLY);
49 SetVar("var2","Value of variable 2", -1, GVF_LOCAL_ONLY);
50 SetVar("var3","Value of variable 3", -1, GVF_LOCAL_ONLY);
51 printf("Scanning local variables again:\n");
52 ret = ScanVars(&hook, GVF_LOCAL_ONLY, userdata);
53 printf("ScanVars returned %d\n", ret);
55 printf("Trying to print all variables up to var2:\n");
56 hook.h_Entry = print_var_break;
57 ret = ScanVars(&hook, GVF_LOCAL_ONLY, userdata);
58 printf("ScanVars returned %d\n", ret);