GNUnet 0.21.1
fs_list_indexed.c File Reference

provide a list of all indexed files More...

#include "platform.h"
#include "gnunet_constants.h"
#include "gnunet_fs_service.h"
#include "gnunet_protocols.h"
#include "fs_api.h"
Include dependency graph for fs_list_indexed.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_FS_GetIndexedContext
 Context for GNUNET_FS_get_indexed_files(). More...
 

Functions

static void handle_index_info_end (void *cls, const struct GNUNET_MessageHeader *msg)
 Function called on each response from the FS service with information about indexed files. More...
 
static int check_index_info (void *cls, const struct IndexInfoMessage *iim)
 Check validity of response from the FS service with information about indexed files. More...
 
static void handle_index_info (void *cls, const struct IndexInfoMessage *iim)
 Function called on each response from the FS service with information about indexed files. More...
 
static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
struct GNUNET_FS_GetIndexedContextGNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, GNUNET_FS_IndexedFileProcessor iterator, void *iterator_cls)
 Iterate over all indexed files. More...
 
void GNUNET_FS_get_indexed_files_cancel (struct GNUNET_FS_GetIndexedContext *gic)
 Cancel iteration over all indexed files. More...
 

Detailed Description

provide a list of all indexed files

Author
Christian Grothoff

Definition in file fs_list_indexed.c.

Function Documentation

◆ handle_index_info_end()

static void handle_index_info_end ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Function called on each response from the FS service with information about indexed files.

Parameters
clsclosure (of type struct GNUNET_FS_GetIndexedContext *)
msgmessage with indexing information

Definition at line 75 of file fs_list_indexed.c.

77{
78 struct GNUNET_FS_GetIndexedContext *gic = cls;
79
80 (void) gic->iterator (gic->iterator_cls,
81 NULL,
82 NULL);
84}
static struct GNUNET_FS_GetIndexedContext * gic
Handle for the index listing operation.
Definition: gnunet-fs.c:42
void GNUNET_FS_get_indexed_files_cancel(struct GNUNET_FS_GetIndexedContext *gic)
Cancel iteration over all indexed files.
Context for GNUNET_FS_get_indexed_files().
void * iterator_cls
Closure for iterator.
GNUNET_FS_IndexedFileProcessor iterator
Function to call for each indexed file.

References gic, GNUNET_FS_get_indexed_files_cancel(), GNUNET_FS_GetIndexedContext::iterator, and GNUNET_FS_GetIndexedContext::iterator_cls.

Here is the call graph for this function:

◆ check_index_info()

static int check_index_info ( void *  cls,
const struct IndexInfoMessage iim 
)
static

Check validity of response from the FS service with information about indexed files.

Parameters
clsclosure (of type struct GNUNET_FS_GetIndexedContext *)
iimmessage with indexing information

Definition at line 95 of file fs_list_indexed.c.

97{
98 uint16_t msize = ntohs (iim->header.size) - sizeof(*iim);
99 const char *filename;
100
101 filename = (const char *) &iim[1];
102 if (filename[msize - 1] != '\0')
103 {
104 GNUNET_break (0);
105 return GNUNET_SYSERR;
106 }
107 return GNUNET_OK;
108}
static char * filename
@ GNUNET_OK
@ GNUNET_SYSERR
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
struct GNUNET_MessageHeader header
Message type will be GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
Definition: fs.h:202

References filename, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, IndexInfoMessage::header, and GNUNET_MessageHeader::size.

◆ handle_index_info()

static void handle_index_info ( void *  cls,
const struct IndexInfoMessage iim 
)
static

Function called on each response from the FS service with information about indexed files.

Parameters
clsclosure (of type struct GNUNET_FS_GetIndexedContext *)
iimmessage with indexing information

Definition at line 119 of file fs_list_indexed.c.

121{
122 struct GNUNET_FS_GetIndexedContext *gic = cls;
123 const char *filename;
124
125 filename = (const char *) &iim[1];
126 if (GNUNET_OK !=
128 filename,
129 &iim->file_id))
130 {
132 return;
133 }
134}
struct GNUNET_HashCode file_id
Hash of the indexed file.
Definition: fs.h:212

References IndexInfoMessage::file_id, filename, gic, GNUNET_FS_get_indexed_files_cancel(), GNUNET_OK, GNUNET_FS_GetIndexedContext::iterator, and GNUNET_FS_GetIndexedContext::iterator_cls.

Here is the call graph for this function:

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_FS_GetIndexedContent *
errorerror code

Definition at line 146 of file fs_list_indexed.c.

148{
149 struct GNUNET_FS_GetIndexedContext *gic = cls;
150
152 "Failed to receive response from `%s' service (error code is %d).\n",
153 "fs",
154 error);
155 (void) gic->iterator (gic->iterator_cls,
156 NULL,
157 NULL);
159}
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_WARNING

References gic, GNUNET_ERROR_TYPE_WARNING, GNUNET_FS_get_indexed_files_cancel(), GNUNET_log, GNUNET_FS_GetIndexedContext::iterator, and GNUNET_FS_GetIndexedContext::iterator_cls.

Referenced by GNUNET_FS_get_indexed_files().

Here is the call graph for this function:
Here is the caller graph for this function: