GNUnet  0.10.x
Functions | Variables
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.

References GNUNET_PEERSTORE_disconnect(), and GNUNET_YES.

Referenced by run().

45 {
46  if (NULL != peerstore_handle)
47  {
49  peerstore_handle = NULL;
50  }
51 }
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.
static struct GNUNET_PEERSTORE_Handle * peerstore_handle
#define GNUNET_YES
Definition: gnunet_common.h:80
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.

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

Referenced by main().

67 {
69  NULL);
72  ret = 0;
73 }
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_PEERSTORE_Handle * peerstore_handle
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
static int ret
static void shutdown_task(void *cls)
Run on shutdown.
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.

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

85 {
86  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
88  };
89  return (GNUNET_OK ==
90  GNUNET_PROGRAM_run (argc, argv, "gnunet-peerstore [options [value]]",
91  gettext_noop ("peerstore"), options, &run,
92  NULL)) ? ret : 1;
93 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Definition of a command line option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
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.
int 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, parse options).
Definition: program.c:361
static int ret
#define gettext_noop(String)
Definition: gettext.h:69
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.