diff options
Diffstat (limited to 'doc/tutorial-examples')
-rw-r--r-- | doc/tutorial-examples/007.c | 10 | ||||
-rw-r--r-- | doc/tutorial-examples/008.c | 22 | ||||
-rw-r--r-- | doc/tutorial-examples/009.c | 9 | ||||
-rw-r--r-- | doc/tutorial-examples/010.c | 8 | ||||
-rw-r--r-- | doc/tutorial-examples/011.c | 8 | ||||
-rw-r--r-- | doc/tutorial-examples/012.c | 4 | ||||
-rw-r--r-- | doc/tutorial-examples/013.c | 12 | ||||
-rw-r--r-- | doc/tutorial-examples/014.c | 9 | ||||
-rw-r--r-- | doc/tutorial-examples/015.c | 8 | ||||
-rw-r--r-- | doc/tutorial-examples/016.c | 3 | ||||
-rw-r--r-- | doc/tutorial-examples/017.c | 3 | ||||
-rw-r--r-- | doc/tutorial-examples/018.c | 2 | ||||
-rw-r--r-- | doc/tutorial-examples/019.c | 15 | ||||
-rw-r--r-- | doc/tutorial-examples/020.c | 24 | ||||
-rw-r--r-- | doc/tutorial-examples/021.c | 13 | ||||
-rw-r--r-- | doc/tutorial-examples/022.c | 8 | ||||
-rw-r--r-- | doc/tutorial-examples/023.c | 17 | ||||
-rw-r--r-- | doc/tutorial-examples/024.c | 9 | ||||
-rw-r--r-- | doc/tutorial-examples/025.c | 15 | ||||
-rw-r--r-- | doc/tutorial-examples/026.c | 52 |
20 files changed, 251 insertions, 0 deletions
diff --git a/doc/tutorial-examples/007.c b/doc/tutorial-examples/007.c new file mode 100644 index 000000000..096539e43 --- /dev/null +++ b/doc/tutorial-examples/007.c | |||
@@ -0,0 +1,10 @@ | |||
1 | GNUNET_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 new file mode 100644 index 000000000..2dffe2cf9 --- /dev/null +++ b/doc/tutorial-examples/008.c | |||
@@ -0,0 +1,22 @@ | |||
1 | static void | ||
2 | run (void *cls, | ||
3 | const struct GNUNET_CONFIGURATION_Handle *c, | ||
4 | struct GNUNET_SERVICE_Handle *service) | ||
5 | { | ||
6 | } | ||
7 | |||
8 | static void * | ||
9 | client_connect_cb (void *cls, | ||
10 | struct GNUNET_SERVICE_Client *c, | ||
11 | struct GNUNET_MQ_Handle *mq) | ||
12 | { | ||
13 | return c; | ||
14 | } | ||
15 | |||
16 | static void | ||
17 | client_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 new file mode 100644 index 000000000..26d918fb0 --- /dev/null +++ b/doc/tutorial-examples/009.c | |||
@@ -0,0 +1,9 @@ | |||
1 | #include <gnunet/gnunet_core_service.h> | ||
2 | |||
3 | struct GNUNET_CORE_Handle * | ||
4 | GNUNET_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 new file mode 100644 index 000000000..33494490d --- /dev/null +++ b/doc/tutorial-examples/010.c | |||
@@ -0,0 +1,8 @@ | |||
1 | void * | ||
2 | connects (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 new file mode 100644 index 000000000..23bc051de --- /dev/null +++ b/doc/tutorial-examples/011.c | |||
@@ -0,0 +1,8 @@ | |||
1 | void | ||
2 | disconnects (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 new file mode 100644 index 000000000..cb21d78ab --- /dev/null +++ b/doc/tutorial-examples/012.c | |||
@@ -0,0 +1,4 @@ | |||
1 | #include "gnunet_peerstore_service.h" | ||
2 | |||
3 | peerstore_handle = GNUNET_PEERSTORE_connect (cfg); | ||
4 | |||
diff --git a/doc/tutorial-examples/013.c b/doc/tutorial-examples/013.c new file mode 100644 index 000000000..6792417e1 --- /dev/null +++ b/doc/tutorial-examples/013.c | |||
@@ -0,0 +1,12 @@ | |||
1 | struct GNUNET_PEERSTORE_StoreContext * | ||
2 | GNUNET_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 new file mode 100644 index 000000000..ce204f795 --- /dev/null +++ b/doc/tutorial-examples/014.c | |||
@@ -0,0 +1,9 @@ | |||
1 | struct GNUNET_PEERSTORE_IterateContext * | ||
2 | GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h, | ||
3 | const char *sub_system, | ||
4 | const struct GNUNET_PeerIdentity *peer, | ||
5 | const char *key, | ||
6 | struct GNUNET_TIME_Relative timeout, | ||
7 | GNUNET_PEERSTORE_Processor callback, | ||
8 | void *callback_cls); | ||
9 | |||
diff --git a/doc/tutorial-examples/015.c b/doc/tutorial-examples/015.c new file mode 100644 index 000000000..0dd267e8e --- /dev/null +++ b/doc/tutorial-examples/015.c | |||
@@ -0,0 +1,8 @@ | |||
1 | struct GNUNET_PEERSTORE_WatchContext * | ||
2 | GNUNET_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 new file mode 100644 index 000000000..d8db4b3b8 --- /dev/null +++ b/doc/tutorial-examples/016.c | |||
@@ -0,0 +1,3 @@ | |||
1 | void | ||
2 | GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc); | ||
3 | |||
diff --git a/doc/tutorial-examples/017.c b/doc/tutorial-examples/017.c new file mode 100644 index 000000000..c4acbc088 --- /dev/null +++ b/doc/tutorial-examples/017.c | |||
@@ -0,0 +1,3 @@ | |||
1 | void | ||
2 | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first); | ||
3 | |||
diff --git a/doc/tutorial-examples/018.c b/doc/tutorial-examples/018.c new file mode 100644 index 000000000..3fc22584c --- /dev/null +++ b/doc/tutorial-examples/018.c | |||
@@ -0,0 +1,2 @@ | |||
1 | dht_handle = GNUNET_DHT_connect (cfg, parallel_requests); | ||
2 | |||
diff --git a/doc/tutorial-examples/019.c b/doc/tutorial-examples/019.c new file mode 100644 index 000000000..d016d381b --- /dev/null +++ b/doc/tutorial-examples/019.c | |||
@@ -0,0 +1,15 @@ | |||
1 | message_sent_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
2 | { | ||
3 | // Request has left local node | ||
4 | } | ||
5 | |||
6 | struct GNUNET_DHT_PutHandle * | ||
7 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | ||
8 | const struct GNUNET_HashCode *key, | ||
9 | uint32_t desired_replication_level, | ||
10 | enum GNUNET_DHT_RouteOption options, | ||
11 | enum GNUNET_BLOCK_Type type, size_t size, const void *data, | ||
12 | struct GNUNET_TIME_Absolute exp, | ||
13 | struct GNUNET_TIME_Relative timeout, | ||
14 | GNUNET_DHT_PutContinuation cont, void *cont_cls) | ||
15 | |||
diff --git a/doc/tutorial-examples/020.c b/doc/tutorial-examples/020.c new file mode 100644 index 000000000..5ecba1c16 --- /dev/null +++ b/doc/tutorial-examples/020.c | |||
@@ -0,0 +1,24 @@ | |||
1 | static void | ||
2 | get_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, const void *data) | ||
9 | { | ||
10 | // Optionally: | ||
11 | GNUNET_DHT_get_stop (get_handle); | ||
12 | } | ||
13 | |||
14 | get_handle = | ||
15 | GNUNET_DHT_get_start (dht_handle, | ||
16 | block_type, | ||
17 | &key, | ||
18 | replication, | ||
19 | GNUNET_DHT_RO_NONE, | ||
20 | NULL, | ||
21 | 0, | ||
22 | &get_result_iterator, | ||
23 | cls) | ||
24 | |||
diff --git a/doc/tutorial-examples/021.c b/doc/tutorial-examples/021.c new file mode 100644 index 000000000..688a31fe0 --- /dev/null +++ b/doc/tutorial-examples/021.c | |||
@@ -0,0 +1,13 @@ | |||
1 | static enum GNUNET_BLOCK_EvaluationResult | ||
2 | block_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 new file mode 100644 index 000000000..a373619bd --- /dev/null +++ b/doc/tutorial-examples/022.c | |||
@@ -0,0 +1,8 @@ | |||
1 | static int | ||
2 | block_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 new file mode 100644 index 000000000..820c38b10 --- /dev/null +++ b/doc/tutorial-examples/023.c | |||
@@ -0,0 +1,17 @@ | |||
1 | void * | ||
2 | libgnunet_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 new file mode 100644 index 000000000..2e84b5905 --- /dev/null +++ b/doc/tutorial-examples/024.c | |||
@@ -0,0 +1,9 @@ | |||
1 | void * | ||
2 | libgnunet_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.c b/doc/tutorial-examples/025.c new file mode 100644 index 000000000..66d4f80ec --- /dev/null +++ b/doc/tutorial-examples/025.c | |||
@@ -0,0 +1,15 @@ | |||
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 new file mode 100644 index 000000000..264e0b6b9 --- /dev/null +++ b/doc/tutorial-examples/026.c | |||
@@ -0,0 +1,52 @@ | |||
1 | static void | ||
2 | get_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 | |||
14 | static void | ||
15 | get_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 | |||
29 | static void | ||
30 | put_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 | |||
45 | monitor_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 | |||