Merge branch 'master' of gnunet.org:gnunet
[oweals/gnunet.git] / src / fs / gnunet-service-fs_indexing.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009, 2010, 2011 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/gnunet-service-fs_indexing.h
21  * @brief indexing for the file-sharing service
22  * @author Christian Grothoff
23  */
24 #ifndef GNUNET_SERVICE_FS_INDEXING_H
25 #define GNUNET_SERVICE_FS_INDEXING_H
26
27 #include "gnunet_block_lib.h"
28 #include "gnunet_core_service.h"
29 #include "gnunet_datastore_service.h"
30 #include "gnunet_peer_lib.h"
31 #include "gnunet_protocols.h"
32 #include "gnunet_signatures.h"
33 #include "gnunet_util_lib.h"
34
35
36 /**
37  * We've received an on-demand encoded block from the datastore.
38  * Attempt to do on-demand encoding and (if successful), call the
39  * continuation with the resulting block.  On error, clean up and ask
40  * the datastore for more results.
41  *
42  * @param key key for the content
43  * @param size number of bytes in data
44  * @param data content stored
45  * @param type type of the content
46  * @param priority priority of the content
47  * @param anonymity anonymity-level for the content
48  * @param replication replication-level for the content
49  * @param expiration expiration time for the content
50  * @param uid unique identifier for the datum;
51  *        maybe 0 if no unique identifier is available
52  * @param cont function to call with the actual block (at most once, on success)
53  * @param cont_cls closure for @a cont
54  * @return #GNUNET_OK on success
55  */
56 int
57 GNUNET_FS_handle_on_demand_block (const struct GNUNET_HashCode *key,
58                                   uint32_t size,
59                                   const void *data,
60                                   enum GNUNET_BLOCK_Type type,
61                                   uint32_t priority,
62                                   uint32_t anonymity,
63                                   uint32_t replication,
64                                   struct GNUNET_TIME_Absolute expiration,
65                                   uint64_t uid,
66                                   GNUNET_DATASTORE_DatumProcessor cont,
67                                   void *cont_cls);
68
69
70 /**
71  * Transmit information about indexed files to @a mq.
72  *
73  * @param mq message queue to send information to
74  */
75 void
76 GNUNET_FS_indexing_send_list (struct GNUNET_MQ_Handle *mq);
77
78
79 /**
80  * Remove a file from the index.
81  *
82  * @param fid identifier of the file to remove
83  * @return #GNUNET_YES if the @a fid was found
84  */
85 int
86 GNUNET_FS_indexing_do_unindex (const struct GNUNET_HashCode *fid);
87
88
89 /**
90  * Add the given file to the list of indexed files.
91  *
92  * @param filename name of the file
93  * @param file_id hash identifier for @a filename
94  */
95 void
96 GNUNET_FS_add_to_index (const char *filename,
97                         const struct GNUNET_HashCode *file_id);
98
99
100 /**
101  * Initialize the indexing submodule.
102  *
103  * @param c configuration to use
104  * @param d datastore to use
105  * @return GNUNET_OK on success
106  */
107 int
108 GNUNET_FS_indexing_init (const struct GNUNET_CONFIGURATION_Handle *c,
109                          struct GNUNET_DATASTORE_Handle *d);
110
111
112 /**
113  * Shutdown the module.
114  */
115 void
116 GNUNET_FS_indexing_done (void);
117
118
119 #endif