2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
5 Desc: dos.library ScanVars() function test.
11 #include <proto/dos.h>
12 #include <proto/utility.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
);
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");
37 char userdata
[] = "Some user data...";
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
);