GNUnet  0.11.x
Data Structures | Functions
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 74 of file fs_list_indexed.c.

76 {
77  struct GNUNET_FS_GetIndexedContext *gic = cls;
78 
79  (void) gic->iterator (gic->iterator_cls,
80  NULL,
81  NULL);
83 }
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 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 94 of file fs_list_indexed.c.

96 {
97  uint16_t msize = ntohs (iim->header.size) - sizeof(*iim);
98  const char *filename;
99 
100  filename = (const char *) &iim[1];
101  if (filename[msize - 1] != '\0')
102  {
103  GNUNET_break (0);
104  return GNUNET_SYSERR;
105  }
106  return GNUNET_OK;
107 }
static char * filename
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#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:201

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 118 of file fs_list_indexed.c.

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

References IndexInfoMessage::file_id, filename, 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 145 of file fs_list_indexed.c.

147 {
148  struct GNUNET_FS_GetIndexedContext *gic = cls;
149 
151  _ ("Failed to receive response from `%s' service.\n"),
152  "fs");
153  (void) gic->iterator (gic->iterator_cls, NULL, NULL);
155 }
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_WARNING
#define _(String)
GNU gettext support macro.
Definition: platform.h:177

References _, 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: