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 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
))
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
);
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
))
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");
47 char userdata
[] = "Some user data...";
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
);