diff options
Diffstat (limited to 'src/testing/testing_api_cmd_hello_world.c')
-rw-r--r-- | src/testing/testing_api_cmd_hello_world.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/src/testing/testing_api_cmd_hello_world.c b/src/testing/testing_api_cmd_hello_world.c index 4347ac818..73dcd6dff 100644 --- a/src/testing/testing_api_cmd_hello_world.c +++ b/src/testing/testing_api_cmd_hello_world.c | |||
@@ -32,50 +32,51 @@ struct HelloWorldState | |||
32 | const char *birthLabel; | 32 | const char *birthLabel; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | |||
35 | /** | 36 | /** |
36 | * | 37 | * |
37 | * | 38 | * |
38 | * @param cls closure | 39 | * @param cls closure |
39 | * @param cmd current CMD being cleaned up. | 40 | */ |
40 | */ | ||
41 | static void | 41 | static void |
42 | hello_world_cleanup (void *cls, | 42 | hello_world_cleanup (void *cls) |
43 | const struct GNUNET_TESTING_Command *cmd) | ||
44 | { | 43 | { |
45 | struct HelloWorldState *hs = cls; | 44 | struct HelloWorldState *hs = cls; |
45 | |||
46 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 46 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
47 | "Cleaning up message %s\n", | 47 | "Cleaning up message %s\n", |
48 | hs->message); | 48 | hs->message); |
49 | GNUNET_free (hs); | ||
49 | } | 50 | } |
50 | 51 | ||
52 | |||
51 | /** | 53 | /** |
52 | * | 54 | * |
53 | * | 55 | * |
54 | * @param cls closure. | 56 | * @param cls closure. |
55 | * @param[out] ret result | 57 | * @param[out] ret result |
56 | * @param trait name of the trait. | 58 | * @param trait name of the trait. |
57 | * @param index index number of the object to offer. | 59 | * @param index index number of the object to offer. |
58 | * @return #GNUNET_OK on success. | 60 | * @return #GNUNET_OK on success. |
59 | */ | 61 | */ |
60 | static int | 62 | static enum GNUNET_GenericReturnValue |
61 | hello_world_traits (void *cls, | 63 | hello_world_traits (void *cls, |
62 | const void **ret, | 64 | const void **ret, |
63 | const char *trait, | 65 | const char *trait, |
64 | unsigned int index) | 66 | unsigned int index) |
65 | { | 67 | { |
66 | return GNUNET_OK; | 68 | return GNUNET_NO; |
67 | } | 69 | } |
68 | 70 | ||
71 | |||
69 | /** | 72 | /** |
70 | * Run the "hello world" CMD. | 73 | * Run the "hello world" CMD. |
71 | * | 74 | * |
72 | * @param cls closure. | 75 | * @param cls closure. |
73 | * @param cmd CMD being run. | ||
74 | * @param is interpreter state. | 76 | * @param is interpreter state. |
75 | */ | 77 | */ |
76 | static void | 78 | static void |
77 | hello_world_run (void *cls, | 79 | hello_world_run (void *cls, |
78 | const struct GNUNET_TESTING_Command *cmd, | ||
79 | struct GNUNET_TESTING_Interpreter *is) | 80 | struct GNUNET_TESTING_Interpreter *is) |
80 | { | 81 | { |
81 | struct HelloWorldState *hs = cls; | 82 | struct HelloWorldState *hs = cls; |
@@ -84,13 +85,16 @@ hello_world_run (void *cls, | |||
84 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 85 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
85 | "%s\n", | 86 | "%s\n", |
86 | hs->message); | 87 | hs->message); |
87 | birth_cmd = GNUNET_TESTING_interpreter_lookup_command (hs->birthLabel); | 88 | birth_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
88 | GNUNET_TESTING_get_trait_what_am_i (birth_cmd, &hs->message); | 89 | hs->birthLabel); |
90 | GNUNET_TESTING_get_trait_what_am_i (birth_cmd, | ||
91 | &hs->message); | ||
89 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 92 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
90 | "Now I am a %s\n", | 93 | "Now I am a %s\n", |
91 | hs->message); | 94 | hs->message); |
92 | } | 95 | } |
93 | 96 | ||
97 | |||
94 | /** | 98 | /** |
95 | * Create command. | 99 | * Create command. |
96 | * | 100 | * |
@@ -108,14 +112,15 @@ GNUNET_TESTING_cmd_hello_world (const char *label, | |||
108 | hs = GNUNET_new (struct HelloWorldState); | 112 | hs = GNUNET_new (struct HelloWorldState); |
109 | hs->message = "Hello World, I was nobody!"; | 113 | hs->message = "Hello World, I was nobody!"; |
110 | hs->birthLabel = birthLabel; | 114 | hs->birthLabel = birthLabel; |
115 | { | ||
116 | struct GNUNET_TESTING_Command cmd = { | ||
117 | .cls = hs, | ||
118 | .label = label, | ||
119 | .run = &hello_world_run, | ||
120 | .cleanup = &hello_world_cleanup, | ||
121 | .traits = &hello_world_traits | ||
122 | }; | ||
111 | 123 | ||
112 | struct GNUNET_TESTING_Command cmd = { | 124 | return cmd; |
113 | .cls = hs, | 125 | } |
114 | .label = label, | ||
115 | .run = &hello_world_run, | ||
116 | .cleanup = &hello_world_cleanup, | ||
117 | .traits = &hello_world_traits | ||
118 | }; | ||
119 | |||
120 | return cmd; | ||
121 | } | 126 | } |