aboutsummaryrefslogtreecommitdiff
path: root/doc/tutorial/examples
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-08-02 17:25:41 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2022-08-02 17:25:41 +0200
commit4fe567d9d94b9159254a2f2cce64855a794d9699 (patch)
treeb286f5a454472ec92ff88376b297e411e64c5843 /doc/tutorial/examples
parente8b7707f833739851227d4865e6c6064865f19ec (diff)
downloadgnunet-4fe567d9d94b9159254a2f2cce64855a794d9699.tar.gz
gnunet-4fe567d9d94b9159254a2f2cce64855a794d9699.zip
DOC: Move from texinfo to sphinx
Diffstat (limited to 'doc/tutorial/examples')
-rw-r--r--doc/tutorial/examples/001.c29
-rw-r--r--doc/tutorial/examples/002.c17
-rw-r--r--doc/tutorial/examples/003.c11
-rw-r--r--doc/tutorial/examples/004.c5
-rw-r--r--doc/tutorial/examples/005.c9
-rw-r--r--doc/tutorial/examples/006.c31
-rw-r--r--doc/tutorial/examples/007.c10
-rw-r--r--doc/tutorial/examples/008.c22
-rw-r--r--doc/tutorial/examples/009.c9
-rw-r--r--doc/tutorial/examples/010.c8
-rw-r--r--doc/tutorial/examples/011.c8
-rw-r--r--doc/tutorial/examples/012.c4
-rw-r--r--doc/tutorial/examples/013.1.c3
-rw-r--r--doc/tutorial/examples/013.c12
-rw-r--r--doc/tutorial/examples/014.c8
-rw-r--r--doc/tutorial/examples/015.c8
-rw-r--r--doc/tutorial/examples/016.c4
-rw-r--r--doc/tutorial/examples/017.c4
-rw-r--r--doc/tutorial/examples/018.c2
-rw-r--r--doc/tutorial/examples/019.c18
-rw-r--r--doc/tutorial/examples/020.c25
-rw-r--r--doc/tutorial/examples/021.c13
-rw-r--r--doc/tutorial/examples/022.c8
-rw-r--r--doc/tutorial/examples/023.c17
-rw-r--r--doc/tutorial/examples/024.c9
-rw-r--r--doc/tutorial/examples/025.Makefile.am15
-rw-r--r--doc/tutorial/examples/026.c52
-rw-r--r--doc/tutorial/examples/testbed_test.c99
28 files changed, 0 insertions, 460 deletions
diff --git a/doc/tutorial/examples/001.c b/doc/tutorial/examples/001.c
deleted file mode 100644
index 7f6699dd2..000000000
--- a/doc/tutorial/examples/001.c
+++ /dev/null
@@ -1,29 +0,0 @@
1#include <gnunet/platform.h>
2#include <gnunet/gnunet_util_lib.h>
3
4static int ret;
5
6static void
7run (void *cls,
8 char *const *args,
9 const char *cfgfile,
10 const struct GNUNET_CONFIGURATION_Handle *cfg)
11{
12 // main code here
13 ret = 0;
14}
15
16int
17main (int argc, char *const *argv)
18{
19 struct GNUNET_GETOPT_CommandLineOption options[] = {
20 GNUNET_GETOPT_OPTION_END
21 };
22 return (GNUNET_OK ==
23 GNUNET_PROGRAM_run (argc,
24 argv,
25 "binary-name",
26 gettext_noop ("binary description text"),
27 options, &run, NULL)) ? ret : 1;
28}
29
diff --git a/doc/tutorial/examples/002.c b/doc/tutorial/examples/002.c
deleted file mode 100644
index 02233fd61..000000000
--- a/doc/tutorial/examples/002.c
+++ /dev/null
@@ -1,17 +0,0 @@
1static char *string_option;
2static int a_flag;
3
4// ...
5 struct GNUNET_GETOPT_CommandLineOption options[] = {
6 GNUNET_GETOPT_option_string ('s', "name", "SOMESTRING",
7 gettext_noop ("text describing the string_option NAME"),
8 &string_option},
9 GNUNET_GETOPT_option_flag ('f', "flag",
10 gettext_noop ("text describing the flag option"),
11 &a_flag),
12 GNUNET_GETOPT_OPTION_END
13 };
14 string_option = NULL;
15 a_flag = GNUNET_SYSERR;
16// ...
17
diff --git a/doc/tutorial/examples/003.c b/doc/tutorial/examples/003.c
deleted file mode 100644
index d158d7e75..000000000
--- a/doc/tutorial/examples/003.c
+++ /dev/null
@@ -1,11 +0,0 @@
1struct GNUNET_MQ_MessageHandlers handlers[] = {
2 // ...
3 GNUNET_MQ_handler_end ()
4};
5struct GNUNET_MQ_Handle *mq;
6
7mq = GNUNET_CLIENT_connect (cfg,
8 "service-name",
9 handlers,
10 &error_cb,
11 NULL);
diff --git a/doc/tutorial/examples/004.c b/doc/tutorial/examples/004.c
deleted file mode 100644
index 0ef007907..000000000
--- a/doc/tutorial/examples/004.c
+++ /dev/null
@@ -1,5 +0,0 @@
1struct GNUNET_MessageHeader
2{
3 uint16_t size GNUNET_PACKED;
4 uint16_t type GNUNET_PACKED;
5};
diff --git a/doc/tutorial/examples/005.c b/doc/tutorial/examples/005.c
deleted file mode 100644
index 1b59f85a6..000000000
--- a/doc/tutorial/examples/005.c
+++ /dev/null
@@ -1,9 +0,0 @@
1struct GNUNET_MQ_Envelope *env;
2struct GNUNET_MessageHeader *msg;
3
4env = GNUNET_MQ_msg_extra (msg, payload_size, GNUNET_MY_MESSAGE_TYPE);
5GNUNET_memcpy (&msg[1],
6 &payload,
7 payload_size);
8// Send message via message queue 'mq'
9GNUNET_mq_send (mq, env);
diff --git a/doc/tutorial/examples/006.c b/doc/tutorial/examples/006.c
deleted file mode 100644
index 944d2b18c..000000000
--- a/doc/tutorial/examples/006.c
+++ /dev/null
@@ -1,31 +0,0 @@
1static void
2handle_fix (void *cls, const struct MyMessage *msg)
3{
4 // process 'msg'
5}
6
7static int
8check_var (void *cls, const struct MyVarMessage *msg)
9{
10 // check 'msg' is well-formed
11 return GNUNET_OK;
12}
13
14static void
15handle_var (void *cls, const struct MyVarMessage *msg)
16{
17 // process 'msg'
18}
19
20struct GNUNET_MQ_MessageHandler handlers[] = {
21 GNUNET_MQ_hd_fixed_size (fix,
22 GNUNET_MESSAGE_TYPE_MY_FIX,
23 struct MyMessage,
24 NULL),
25 GNUNET_MQ_hd_fixed_size (var,
26 GNUNET_MESSAGE_TYPE_MY_VAR,
27 struct MyVarMessage,
28 NULL),
29
30 GNUNET_MQ_handler_end ()
31};
diff --git a/doc/tutorial/examples/007.c b/doc/tutorial/examples/007.c
deleted file mode 100644
index 096539e43..000000000
--- a/doc/tutorial/examples/007.c
+++ /dev/null
@@ -1,10 +0,0 @@
1GNUNET_SERVICE_MAIN
2("service-name",
3 GNUNET_SERVICE_OPTION_NONE,
4 &run,
5 &client_connect_cb,
6 &client_disconnect_cb,
7 NULL,
8 GNUNET_MQ_hd_fixed_size (...),
9 GNUNET_MQ_hd_var_size (...),
10 GNUNET_MQ_handler_end ());
diff --git a/doc/tutorial/examples/008.c b/doc/tutorial/examples/008.c
deleted file mode 100644
index 2dffe2cf9..000000000
--- a/doc/tutorial/examples/008.c
+++ /dev/null
@@ -1,22 +0,0 @@
1static void
2run (void *cls,
3 const struct GNUNET_CONFIGURATION_Handle *c,
4 struct GNUNET_SERVICE_Handle *service)
5{
6}
7
8static void *
9client_connect_cb (void *cls,
10 struct GNUNET_SERVICE_Client *c,
11 struct GNUNET_MQ_Handle *mq)
12{
13 return c;
14}
15
16static void
17client_disconnect_cb (void *cls,
18 struct GNUNET_SERVICE_Client *c,
19 void *internal_cls)
20{
21 GNUNET_assert (c == internal_cls);
22}
diff --git a/doc/tutorial/examples/009.c b/doc/tutorial/examples/009.c
deleted file mode 100644
index 26d918fb0..000000000
--- a/doc/tutorial/examples/009.c
+++ /dev/null
@@ -1,9 +0,0 @@
1#include <gnunet/gnunet_core_service.h>
2
3struct GNUNET_CORE_Handle *
4GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
5 void *cls,
6 GNUNET_CORE_StartupCallback init,
7 GNUNET_CORE_ConnectEventHandler connects,
8 GNUNET_CORE_DisconnectEventHandler disconnects,
9 const struct GNUNET_MQ_MessageHandler *handlers);
diff --git a/doc/tutorial/examples/010.c b/doc/tutorial/examples/010.c
deleted file mode 100644
index 33494490d..000000000
--- a/doc/tutorial/examples/010.c
+++ /dev/null
@@ -1,8 +0,0 @@
1void *
2connects (void *cls,
3 const struct GNUNET_PeerIdentity *peer,
4 struct GNUNET_MQ_Handle *mq)
5{
6 return mq;
7}
8
diff --git a/doc/tutorial/examples/011.c b/doc/tutorial/examples/011.c
deleted file mode 100644
index 23bc051de..000000000
--- a/doc/tutorial/examples/011.c
+++ /dev/null
@@ -1,8 +0,0 @@
1void
2disconnects (void *cls,
3 const struct GNUNET_PeerIdentity * peer)
4{
5 /* Remove peer's identity from known peers */
6 /* Make sure no messages are sent to peer from now on */
7}
8
diff --git a/doc/tutorial/examples/012.c b/doc/tutorial/examples/012.c
deleted file mode 100644
index cb21d78ab..000000000
--- a/doc/tutorial/examples/012.c
+++ /dev/null
@@ -1,4 +0,0 @@
1#include "gnunet_peerstore_service.h"
2
3peerstore_handle = GNUNET_PEERSTORE_connect (cfg);
4
diff --git a/doc/tutorial/examples/013.1.c b/doc/tutorial/examples/013.1.c
deleted file mode 100644
index fa5212868..000000000
--- a/doc/tutorial/examples/013.1.c
+++ /dev/null
@@ -1,3 +0,0 @@
1void
2GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext
3 *sc);
diff --git a/doc/tutorial/examples/013.c b/doc/tutorial/examples/013.c
deleted file mode 100644
index 6792417e1..000000000
--- a/doc/tutorial/examples/013.c
+++ /dev/null
@@ -1,12 +0,0 @@
1struct GNUNET_PEERSTORE_StoreContext *
2GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h,
3 const char *sub_system,
4 const struct GNUNET_PeerIdentity *peer,
5 const char *key,
6 const void *value,
7 size_t size,
8 struct GNUNET_TIME_Absolute expiry,
9 enum GNUNET_PEERSTORE_StoreOption options,
10 GNUNET_PEERSTORE_Continuation cont,
11 void *cont_cls);
12
diff --git a/doc/tutorial/examples/014.c b/doc/tutorial/examples/014.c
deleted file mode 100644
index db2ed1165..000000000
--- a/doc/tutorial/examples/014.c
+++ /dev/null
@@ -1,8 +0,0 @@
1struct GNUNET_PEERSTORE_IterateContext *
2GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h,
3 const char *sub_system,
4 const struct GNUNET_PeerIdentity *peer,
5 const char *key,
6 GNUNET_PEERSTORE_Processor callback,
7 void *callback_cls);
8
diff --git a/doc/tutorial/examples/015.c b/doc/tutorial/examples/015.c
deleted file mode 100644
index 0dd267e8e..000000000
--- a/doc/tutorial/examples/015.c
+++ /dev/null
@@ -1,8 +0,0 @@
1struct GNUNET_PEERSTORE_WatchContext *
2GNUNET_PEERSTORE_watch (struct GNUNET_PEERSTORE_Handle *h,
3 const char *sub_system,
4 const struct GNUNET_PeerIdentity *peer,
5 const char *key,
6 GNUNET_PEERSTORE_Processor callback,
7 void *callback_cls);
8
diff --git a/doc/tutorial/examples/016.c b/doc/tutorial/examples/016.c
deleted file mode 100644
index d169da16d..000000000
--- a/doc/tutorial/examples/016.c
+++ /dev/null
@@ -1,4 +0,0 @@
1void
2GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext
3 *wc);
4
diff --git a/doc/tutorial/examples/017.c b/doc/tutorial/examples/017.c
deleted file mode 100644
index c86fbcd1f..000000000
--- a/doc/tutorial/examples/017.c
+++ /dev/null
@@ -1,4 +0,0 @@
1void
2GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h,
3 int sync_first);
4
diff --git a/doc/tutorial/examples/018.c b/doc/tutorial/examples/018.c
deleted file mode 100644
index 3fc22584c..000000000
--- a/doc/tutorial/examples/018.c
+++ /dev/null
@@ -1,2 +0,0 @@
1dht_handle = GNUNET_DHT_connect (cfg, parallel_requests);
2
diff --git a/doc/tutorial/examples/019.c b/doc/tutorial/examples/019.c
deleted file mode 100644
index aaf001516..000000000
--- a/doc/tutorial/examples/019.c
+++ /dev/null
@@ -1,18 +0,0 @@
1message_sent_cont (void *cls,
2 const struct GNUNET_SCHEDULER_TaskContext *tc)
3{
4 // Request has left local node
5}
6
7struct GNUNET_DHT_PutHandle *
8GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
9 const struct GNUNET_HashCode *key,
10 uint32_t desired_replication_level,
11 enum GNUNET_DHT_RouteOption options,
12 enum GNUNET_BLOCK_Type type,
13 size_t size,
14 const void *data,
15 struct GNUNET_TIME_Absolute exp,
16 struct GNUNET_TIME_Relative timeout,
17 GNUNET_DHT_PutContinuation cont, void *cont_cls)
18
diff --git a/doc/tutorial/examples/020.c b/doc/tutorial/examples/020.c
deleted file mode 100644
index 596db3069..000000000
--- a/doc/tutorial/examples/020.c
+++ /dev/null
@@ -1,25 +0,0 @@
1static void
2get_result_iterator (void *cls, struct GNUNET_TIME_Absolute expiration,
3 const struct GNUNET_HashCode *key,
4 const struct GNUNET_PeerIdentity *get_path,
5 unsigned int get_path_length,
6 const struct GNUNET_PeerIdentity *put_path,
7 unsigned int put_path_length,
8 enum GNUNET_BLOCK_Type type, size_t size,
9 const void *data)
10{
11 // Optionally:
12 GNUNET_DHT_get_stop (get_handle);
13}
14
15get_handle =
16 GNUNET_DHT_get_start (dht_handle,
17 block_type,
18 &key,
19 replication,
20 GNUNET_DHT_RO_NONE,
21 NULL,
22 0,
23 &get_result_iterator,
24 cls)
25
diff --git a/doc/tutorial/examples/021.c b/doc/tutorial/examples/021.c
deleted file mode 100644
index 688a31fe0..000000000
--- a/doc/tutorial/examples/021.c
+++ /dev/null
@@ -1,13 +0,0 @@
1static enum GNUNET_BLOCK_EvaluationResult
2block_plugin_SERVICE_evaluate (void *cls,
3 enum GNUNET_BLOCK_Type type,
4 struct GNUNET_BlockGroup *bg,
5 const GNUNET_HashCode *query,
6 const void *xquery,
7 size_t xquery_size,
8 const void *reply_block,
9 size_t reply_block_size)
10{
11 // Verify type, block and bg
12}
13
diff --git a/doc/tutorial/examples/022.c b/doc/tutorial/examples/022.c
deleted file mode 100644
index a373619bd..000000000
--- a/doc/tutorial/examples/022.c
+++ /dev/null
@@ -1,8 +0,0 @@
1static int
2block_plugin_SERVICE_get_key (void *cls, enum GNUNET_BLOCK_Type type,
3 const void *block, size_t block_size,
4 struct GNUNET_HashCode *key)
5{
6 // Store the key in the key argument, return GNUNET_OK on success.
7}
8
diff --git a/doc/tutorial/examples/023.c b/doc/tutorial/examples/023.c
deleted file mode 100644
index 820c38b10..000000000
--- a/doc/tutorial/examples/023.c
+++ /dev/null
@@ -1,17 +0,0 @@
1void *
2libgnunet_plugin_block_SERVICE_init (void *cls)
3{
4 static enum GNUNET_BLOCK_Type types[] =
5 {
6 GNUNET_BLOCK_TYPE_SERVICE_BLOCKYPE,
7 GNUNET_BLOCK_TYPE_ANY
8 };
9 struct GNUNET_BLOCK_PluginFunctions *api;
10
11 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
12 api->evaluate = &block_plugin_SERICE_evaluate;
13 api->get_key = &block_plugin_SERVICE_get_key;
14 api->types = types;
15 return api;
16}
17
diff --git a/doc/tutorial/examples/024.c b/doc/tutorial/examples/024.c
deleted file mode 100644
index 2e84b5905..000000000
--- a/doc/tutorial/examples/024.c
+++ /dev/null
@@ -1,9 +0,0 @@
1void *
2libgnunet_plugin_block_SERVICE_done (void *cls)
3{
4 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
5
6 GNUNET_free (api);
7 return NULL;
8}
9
diff --git a/doc/tutorial/examples/025.Makefile.am b/doc/tutorial/examples/025.Makefile.am
deleted file mode 100644
index 66d4f80ec..000000000
--- a/doc/tutorial/examples/025.Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
1 plugindir = $(libdir)/gnunet
2
3 plugin_LTLIBRARIES = \
4 libgnunet_plugin_block_ext.la
5 libgnunet_plugin_block_ext_la_SOURCES = \
6 plugin_block_ext.c
7 libgnunet_plugin_block_ext_la_LIBADD = \
8 $(prefix)/lib/libgnunethello.la \
9 $(prefix)/lib/libgnunetblock.la \
10 $(prefix)/lib/libgnunetutil.la
11 libgnunet_plugin_block_ext_la_LDFLAGS = \
12 $(GN_PLUGIN_LDFLAGS)
13 libgnunet_plugin_block_ext_la_DEPENDENCIES = \
14 $(prefix)/lib/libgnunetblock.la
15
diff --git a/doc/tutorial/examples/026.c b/doc/tutorial/examples/026.c
deleted file mode 100644
index 264e0b6b9..000000000
--- a/doc/tutorial/examples/026.c
+++ /dev/null
@@ -1,52 +0,0 @@
1static void
2get_callback (void *cls,
3 enum GNUNET_DHT_RouteOption options,
4 enum GNUNET_BLOCK_Type type,
5 uint32_t hop_count,
6 uint32_t desired_replication_level,
7 unsigned int path_length,
8 const struct GNUNET_PeerIdentity *path,
9 const struct GNUNET_HashCode * key)
10{
11}
12
13
14static void
15get_resp_callback (void *cls,
16 enum GNUNET_BLOCK_Type type,
17 const struct GNUNET_PeerIdentity *get_path,
18 unsigned int get_path_length,
19 const struct GNUNET_PeerIdentity *put_path,
20 unsigned int put_path_length,
21 struct GNUNET_TIME_Absolute exp,
22 const struct GNUNET_HashCode * key,
23 const void *data,
24 size_t size)
25{
26}
27
28
29static void
30put_callback (void *cls,
31 enum GNUNET_DHT_RouteOption options,
32 enum GNUNET_BLOCK_Type type,
33 uint32_t hop_count,
34 uint32_t desired_replication_level,
35 unsigned int path_length,
36 const struct GNUNET_PeerIdentity *path,
37 struct GNUNET_TIME_Absolute exp,
38 const struct GNUNET_HashCode * key,
39 const void *data,
40 size_t size)
41{
42}
43
44
45monitor_handle = GNUNET_DHT_monitor_start (dht_handle,
46 block_type,
47 key,
48 &get_callback,
49 &get_resp_callback,
50 &put_callback,
51 cls);
52
diff --git a/doc/tutorial/examples/testbed_test.c b/doc/tutorial/examples/testbed_test.c
deleted file mode 100644
index 1696234b0..000000000
--- a/doc/tutorial/examples/testbed_test.c
+++ /dev/null
@@ -1,99 +0,0 @@
1#include <unistd.h>
2#include <gnunet/platform.h>
3#include <gnunet/gnunet_util_lib.h>
4#include <gnunet/gnunet_testbed_service.h>
5#include <gnunet/gnunet_dht_service.h>
6
7#define NUM_PEERS 20
8
9static struct GNUNET_TESTBED_Operation *dht_op;
10
11static struct GNUNET_DHT_Handle *dht_handle;
12
13
14struct MyContext
15{
16 int ht_len;
17} ctxt;
18
19
20static int result;
21
22
23static void
24shutdown_task (void *cls)
25{
26 if (NULL != dht_op)
27 {
28 GNUNET_TESTBED_operation_done (dht_op);
29 dht_op = NULL;
30 dht_handle = NULL;
31 }
32 result = GNUNET_OK;
33}
34
35
36static void
37service_connect_comp (void *cls,
38 struct GNUNET_TESTBED_Operation *op,
39 void *ca_result,
40 const char *emsg)
41{
42 GNUNET_assert (op == dht_op);
43 dht_handle = ca_result;
44 // Do work here...
45 GNUNET_SCHEDULER_shutdown ();
46}
47
48
49static void *
50dht_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
51{
52 struct MyContext *ctxt = cls;
53
54 dht_handle = GNUNET_DHT_connect (cfg, ctxt->ht_len);
55 return dht_handle;
56}
57
58
59static void
60dht_da (void *cls, void *op_result)
61{
62 struct MyContext *ctxt = cls;
63
64 GNUNET_DHT_disconnect ((struct GNUNET_DHT_Handle *) op_result);
65 dht_handle = NULL;
66}
67
68
69static void
70test_master (void *cls,
71 struct GNUNET_TESTBED_RunHandle *h,
72 unsigned int num_peers,
73 struct GNUNET_TESTBED_Peer **peers,
74 unsigned int links_succeeded,
75 unsigned int links_failed)
76{
77 ctxt.ht_len = 10;
78 dht_op = GNUNET_TESTBED_service_connect
79 (NULL, peers[0], "dht",
80 &service_connect_comp, NULL,
81 &dht_ca, &dht_da, &ctxt);
82 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
83}
84
85
86int
87main (int argc, char **argv)
88{
89 int ret;
90
91 result = GNUNET_SYSERR;
92 ret = GNUNET_TESTBED_test_run
93 ("awesome-test", "template.conf",
94 NUM_PEERS, 0LL,
95 NULL, NULL, &test_master, NULL);
96 if ( (GNUNET_OK != ret) || (GNUNET_OK != result) )
97 return 1;
98 return 0;
99}