-fix records
[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
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file fs/gnunet-service-fs_indexing.h
23  * @brief indexing for the file-sharing service
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_SERVICE_FS_INDEXING_H
27 #define GNUNET_SERVICE_FS_INDEXING_H
28
29 #include "gnunet_block_lib.h"
30 #include "gnunet_core_service.h"
31 #include "gnunet_datastore_service.h"
32 #include "gnunet_peer_lib.h"
33 #include "gnunet_protocols.h"
34 #include "gnunet_signatures.h"
35 #include "gnunet_util_lib.h"
36
37
38 /**
39  * We've received an on-demand encoded block from the datastore.
40  * Attempt to do on-demand encoding and (if successful), call the
41  * continuation with the resulting block.  On error, clean up and ask
42  * the datastore for more results.
43  *
44  * @param key key for the content
45  * @param size number of bytes in data
46  * @param data content stored
47  * @param type type of the content
48  * @param priority priority of the content
49  * @param anonymity anonymity-level for the content
50  * @param replication replication-level for the content
51  * @param expiration expiration time for the content
52  * @param uid unique identifier for the datum;
53  *        maybe 0 if no unique identifier is available
54  * @param cont function to call with the actual block (at most once, on success)
55  * @param cont_cls closure for @a cont
56  * @return #GNUNET_OK on success
57  */
58 int
59 GNUNET_FS_handle_on_demand_block (const struct GNUNET_HashCode *key,
60                                   uint32_t size,
61                                   const void *data,
62                                   enum GNUNET_BLOCK_Type type,
63                                   uint32_t priority,
64                                   uint32_t anonymity,
65                                   uint32_t replication,
66                                   struct GNUNET_TIME_Absolute expiration,
67                                   uint64_t uid,
68                                   GNUNET_DATASTORE_DatumProcessor cont,
69                                   void *cont_cls);
70
71
72 /**
73  * Transmit information about indexed files to @a mq.
74  *
75  * @param mq message queue to send information to
76  */
77 void
78 GNUNET_FS_indexing_send_list (struct GNUNET_MQ_Handle *mq);
79
80
81 /**
82  * Remove a file from the index.
83  *
84  * @param fid identifier of the file to remove
85  * @return #GNUNET_YES if the @a fid was found
86  */
87 int
88 GNUNET_FS_indexing_do_unindex (const struct GNUNET_HashCode *fid);
89
90
91 /**
92  * Add the given file to the list of indexed files.
93  *
94  * @param filename name of the file
95  * @param file_id hash identifier for @a filename
96  */
97 void
98 GNUNET_FS_add_to_index (const char *filename,
99                         const struct GNUNET_HashCode *file_id);
100
101
102 /**
103  * Initialize the indexing submodule.
104  *
105  * @param c configuration to use
106  * @param d datastore to use
107  * @return GNUNET_OK on success
108  */
109 int
110 GNUNET_FS_indexing_init (const struct GNUNET_CONFIGURATION_Handle *c,
111                          struct GNUNET_DATASTORE_Handle *d);
112
113
114 /**
115  * Shutdown the module.
116  */
117 void
118 GNUNET_FS_indexing_done (void);
119
120
121 #endif