diff options
Diffstat (limited to 'src/testing/testing_api_cmd_hello_world.c')
-rw-r--r-- | src/testing/testing_api_cmd_hello_world.c | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/src/testing/testing_api_cmd_hello_world.c b/src/testing/testing_api_cmd_hello_world.c deleted file mode 100644 index 4347ac818..000000000 --- a/src/testing/testing_api_cmd_hello_world.c +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing/testing_api_cmd_hello_world.c | ||
23 | * @brief implementation of a hello world command. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | |||
29 | struct HelloWorldState | ||
30 | { | ||
31 | char *message; | ||
32 | const char *birthLabel; | ||
33 | }; | ||
34 | |||
35 | /** | ||
36 | * | ||
37 | * | ||
38 | * @param cls closure | ||
39 | * @param cmd current CMD being cleaned up. | ||
40 | */ | ||
41 | static void | ||
42 | hello_world_cleanup (void *cls, | ||
43 | const struct GNUNET_TESTING_Command *cmd) | ||
44 | { | ||
45 | struct HelloWorldState *hs = cls; | ||
46 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
47 | "Cleaning up message %s\n", | ||
48 | hs->message); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * | ||
53 | * | ||
54 | * @param cls closure. | ||
55 | * @param[out] ret result | ||
56 | * @param trait name of the trait. | ||
57 | * @param index index number of the object to offer. | ||
58 | * @return #GNUNET_OK on success. | ||
59 | */ | ||
60 | static int | ||
61 | hello_world_traits (void *cls, | ||
62 | const void **ret, | ||
63 | const char *trait, | ||
64 | unsigned int index) | ||
65 | { | ||
66 | return GNUNET_OK; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * Run the "hello world" CMD. | ||
71 | * | ||
72 | * @param cls closure. | ||
73 | * @param cmd CMD being run. | ||
74 | * @param is interpreter state. | ||
75 | */ | ||
76 | static void | ||
77 | hello_world_run (void *cls, | ||
78 | const struct GNUNET_TESTING_Command *cmd, | ||
79 | struct GNUNET_TESTING_Interpreter *is) | ||
80 | { | ||
81 | struct HelloWorldState *hs = cls; | ||
82 | const struct GNUNET_TESTING_Command *birth_cmd; | ||
83 | |||
84 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
85 | "%s\n", | ||
86 | hs->message); | ||
87 | birth_cmd = GNUNET_TESTING_interpreter_lookup_command (hs->birthLabel); | ||
88 | GNUNET_TESTING_get_trait_what_am_i (birth_cmd, &hs->message); | ||
89 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
90 | "Now I am a %s\n", | ||
91 | hs->message); | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * Create command. | ||
96 | * | ||
97 | * @param label name for command. | ||
98 | * @param message initial message. | ||
99 | * @return command. | ||
100 | */ | ||
101 | struct GNUNET_TESTING_Command | ||
102 | GNUNET_TESTING_cmd_hello_world (const char *label, | ||
103 | const char *birthLabel, | ||
104 | char *message) | ||
105 | { | ||
106 | struct HelloWorldState *hs; | ||
107 | |||
108 | hs = GNUNET_new (struct HelloWorldState); | ||
109 | hs->message = "Hello World, I was nobody!"; | ||
110 | hs->birthLabel = birthLabel; | ||
111 | |||
112 | struct GNUNET_TESTING_Command cmd = { | ||
113 | .cls = hs, | ||
114 | .label = label, | ||
115 | .run = &hello_world_run, | ||
116 | .cleanup = &hello_world_cleanup, | ||
117 | .traits = &hello_world_traits | ||
118 | }; | ||
119 | |||
120 | return cmd; | ||
121 | } | ||