aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_hello_world.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_hello_world.c')
-rw-r--r--src/testing/testing_api_cmd_hello_world.c126
1 files changed, 0 insertions, 126 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 73dcd6dff..000000000
--- a/src/testing/testing_api_cmd_hello_world.c
+++ /dev/null
@@ -1,126 +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
29struct HelloWorldState
30{
31 char *message;
32 const char *birthLabel;
33};
34
35
36/**
37 *
38 *
39 * @param cls closure
40 */
41static void
42hello_world_cleanup (void *cls)
43{
44 struct HelloWorldState *hs = cls;
45
46 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
47 "Cleaning up message %s\n",
48 hs->message);
49 GNUNET_free (hs);
50}
51
52
53/**
54 *
55 *
56 * @param cls closure.
57 * @param[out] ret result
58 * @param trait name of the trait.
59 * @param index index number of the object to offer.
60 * @return #GNUNET_OK on success.
61 */
62static enum GNUNET_GenericReturnValue
63hello_world_traits (void *cls,
64 const void **ret,
65 const char *trait,
66 unsigned int index)
67{
68 return GNUNET_NO;
69}
70
71
72/**
73* Run the "hello world" CMD.
74*
75* @param cls closure.
76* @param is interpreter state.
77*/
78static void
79hello_world_run (void *cls,
80 struct GNUNET_TESTING_Interpreter *is)
81{
82 struct HelloWorldState *hs = cls;
83 const struct GNUNET_TESTING_Command *birth_cmd;
84
85 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
86 "%s\n",
87 hs->message);
88 birth_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
89 hs->birthLabel);
90 GNUNET_TESTING_get_trait_what_am_i (birth_cmd,
91 &hs->message);
92 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
93 "Now I am a %s\n",
94 hs->message);
95}
96
97
98/**
99 * Create command.
100 *
101 * @param label name for command.
102 * @param message initial message.
103 * @return command.
104 */
105struct GNUNET_TESTING_Command
106GNUNET_TESTING_cmd_hello_world (const char *label,
107 const char *birthLabel,
108 char *message)
109{
110 struct HelloWorldState *hs;
111
112 hs = GNUNET_new (struct HelloWorldState);
113 hs->message = "Hello World, I was nobody!";
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 };
123
124 return cmd;
125 }
126}