2 Copyright © 1995-2015, 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 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
))
22 printf("Hook called with userdata: %s\n", (char *)userdata
);
23 printf("%s=%.*s\n", message
->sv_Name
, (int)message
->sv_VarLen
,
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
))
37 printf("Hook called with userdata: %s\n", (char *)userdata
);
38 printf("%s=%.*s\n", message
->sv_Name
, (int)message
->sv_VarLen
,
40 if (!strncmp("var2", message
->sv_Name
, 4))
42 printf("Scanned var2 variable!\n");
53 char userdata
[] = "Some user data...";
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
);