GNUnet  0.20.0
gnunet-peerstore.c File Reference

peerstore tool More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_peerstore_service.h"
Include dependency graph for gnunet-peerstore.c:

Go to the source code of this file.

Functions

static void shutdown_task (void *cls)
 Run on shutdown. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 The main function to peerstore. More...
 

Variables

static int ret
 
static struct GNUNET_PEERSTORE_Handlepeerstore_handle
 

Detailed Description

peerstore tool

Author
Omar Tarabai

Definition in file gnunet-peerstore.c.

Function Documentation

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Run on shutdown.

Parameters
clsunused

Definition at line 44 of file gnunet-peerstore.c.

45 {
46  if (NULL != peerstore_handle)
47  {
49  peerstore_handle = NULL;
50  }
51 }
static struct GNUNET_PEERSTORE_Handle * peerstore_handle
@ GNUNET_YES
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.

References GNUNET_PEERSTORE_disconnect(), GNUNET_YES, and peerstore_handle.

Referenced by run().

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

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 63 of file gnunet-peerstore.c.

67 {
69  NULL);
72  ret = 0;
73 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static void shutdown_task(void *cls)
Run on shutdown.
static int ret
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1334

References cfg, GNUNET_assert, GNUNET_PEERSTORE_connect(), GNUNET_SCHEDULER_add_shutdown(), peerstore_handle, ret, and shutdown_task().

Referenced by main().

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

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function to peerstore.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 84 of file gnunet-peerstore.c.

85 {
86  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
88  };
89 
90  return (GNUNET_OK ==
91  GNUNET_PROGRAM_run (argc, argv, "gnunet-peerstore [options [value]]",
92  gettext_noop ("peerstore"), options, &run,
93  NULL)) ? ret : 1;
94 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:70
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
@ GNUNET_OK
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:400
Definition of a command line option.

References gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_OK, GNUNET_PROGRAM_run(), options, ret, and run().

Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Definition at line 30 of file gnunet-peerstore.c.

Referenced by main(), and run().

◆ peerstore_handle

struct GNUNET_PEERSTORE_Handle* peerstore_handle
static

Definition at line 35 of file gnunet-peerstore.c.

Referenced by run(), and shutdown_task().