-Merge branch 'master' of ssh://gnunet.org/gnunet into gsoc2018/rest_api
[oweals/gnunet.git] / src / fs / fs_publish_ublock.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009, 2010, 2012, 2013 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
19 /**
20  * @file fs/fs_publish_ublock.h
21  * @brief publish a UBLOCK in GNUnet
22  * @see https://gnunet.org/encoding and #2564
23  * @author Krista Bennett
24  * @author Christian Grothoff
25  */
26 #ifndef FS_PUBLISH_UBLOCK_H
27 #define FS_PUBLISH_UBLOCK_H
28
29 #include "gnunet_util_lib.h"
30 #include "gnunet_datastore_service.h"
31 #include "gnunet_fs_service.h"
32 #include "gnunet_identity_service.h"
33
34
35 /**
36  * Decrypt the given UBlock, storing the result in output.
37  *
38  * @param input input data
39  * @param input_len number of bytes in input
40  * @param ns public key under which the UBlock was stored
41  * @param label label under which the UBlock was stored
42  * @param output where to write the result, has input_len bytes
43  */
44 void
45 GNUNET_FS_ublock_decrypt_ (const void *input,
46                            size_t input_len,
47                            const struct GNUNET_CRYPTO_EcdsaPublicKey *ns,
48                            const char *label,
49                            void *output);
50
51
52 /**
53  * Context for 'ublock_put_cont'.
54  */
55 struct GNUNET_FS_PublishUblockContext;
56
57
58 /**
59  * Signature of a function called as the continuation of a UBlock
60  * publication.
61  *
62  * @param cls closure
63  * @param emsg error message, NULL on success
64  */
65 typedef void (*GNUNET_FS_UBlockContinuation) (void *cls,
66                                               const char *emsg);
67
68
69 /**
70  * Publish a UBlock.
71  *
72  * @param h handle to the file sharing subsystem
73  * @param dsh datastore handle to use for storage operation
74  * @param label identifier to use
75  * @param ulabel update label to use, may be an empty string for none
76  * @param ns namespace to publish in
77  * @param meta metadata to use
78  * @param uri URI to refer to in the UBlock
79  * @param bo per-block options
80  * @param options publication options
81  * @param cont continuation
82  * @param cont_cls closure for cont
83  * @return NULL on error ('cont' will still be called)
84  */
85 struct GNUNET_FS_PublishUblockContext *
86 GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
87                            struct GNUNET_DATASTORE_Handle *dsh,
88                            const char *label,
89                            const char *ulabel,
90                            const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
91                            const struct GNUNET_CONTAINER_MetaData *meta,
92                            const struct GNUNET_FS_Uri *uri,
93                            const struct GNUNET_FS_BlockOptions *bo,
94                            enum GNUNET_FS_PublishOptions options,
95                            GNUNET_FS_UBlockContinuation cont, void *cont_cls);
96
97
98 /**
99  * Abort UBlock publishing operation.
100  *
101  * @param uc operation to abort.
102  */
103 void
104 GNUNET_FS_publish_ublock_cancel_ (struct GNUNET_FS_PublishUblockContext *uc);
105
106 #endif