GNUnet debian-0.24.3-23-g589b01d60
gnunet-pils.c File Reference

Print information about the peer identity. More...

#include "platform.h"
#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_pils_service.h"
Include dependency graph for gnunet-pils.c:

Go to the source code of this file.

Functions

static void shutdown_task (void *cls)
 Task run in monitor mode when the user presses CTRL-C to abort. More...
 
void pid_change_cb (void *cls, const struct GNUNET_HELLO_Parser *hparser, const struct GNUNET_HashCode *addr_hash)
 
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 obtain peer information from PILS. More...
 

Variables

static int ret
 Return code. More...
 
static int once
 Option -i. More...
 
static struct GNUNET_PILS_Handlepils
 Handle to PILS. More...
 

Detailed Description

Print information about the peer identity.

Author
Martin Schanzenbach

Definition in file gnunet-pils.c.

Function Documentation

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run in monitor mode when the user presses CTRL-C to abort.

Stops monitoring activity.

Parameters
clsNULL

Definition at line 53 of file gnunet-pils.c.

54{
55 (void) cls;
56 if (NULL != pils)
57 {
59 pils = NULL;
60 }
61}
static struct GNUNET_PILS_Handle * pils
Handle to PILS.
Definition: gnunet-pils.c:44
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition: pils_api.c:390

References GNUNET_PILS_disconnect(), and pils.

Referenced by run().

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

◆ pid_change_cb()

void pid_change_cb ( void *  cls,
const struct GNUNET_HELLO_Parser hparser,
const struct GNUNET_HashCode addr_hash 
)

Definition at line 64 of file gnunet-pils.c.

67{
68 printf ("%s\n",
70 if (once)
72}
static int once
Option -i.
Definition: gnunet-pils.c:39
const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_get_id(const struct GNUNET_HELLO_Parser *parser)
Get the PeerIdentity for this builder.
Definition: hello-uri.c:353
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567

References GNUNET_HELLO_parser_get_id(), GNUNET_i2s(), GNUNET_SCHEDULER_shutdown(), and once.

Referenced by GNUNET_PILS_connect(), and 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 83 of file gnunet-pils.c.

87{
88 (void) cls;
89 (void) cfgfile;
90
91 if (NULL != args[0])
92 {
93 fprintf (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
94 return;
95 }
98 if (NULL == pils)
99 {
100 fprintf (stderr, "%s", _ ("Unable to connect to service.\n"));
101 ret = 1;
103 return;
104 }
105}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static void shutdown_task(void *cls)
Task run in monitor mode when the user presses CTRL-C to abort.
Definition: gnunet-pils.c:53
static int ret
Return code.
Definition: gnunet-pils.c:34
void pid_change_cb(void *cls, const struct GNUNET_HELLO_Parser *hparser, const struct GNUNET_HashCode *addr_hash)
Definition: gnunet-pils.c:64
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
Definition: pils_api.c:367
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:1339
#define _(String)
GNU gettext support macro.
Definition: platform.h:179

References _, warningfilter::args, cfg, GNUNET_PILS_connect(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), pid_change_cb(), pils, 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 obtain peer information from PILS.

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

Definition at line 116 of file gnunet-pils.c.

117{
118 int res;
120 {
122 '1',
123 "once",
125 "Show our current peer identity and exit"
126 ),
127 &once),
129
131 argc,
132 argv,
133 "gnunet-pils",
135 "Print information about our peer identity."),
136 options,
137 &run,
138 NULL);
139
140 if (GNUNET_OK == res)
141 return ret;
142 return 1;
143}
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:74
static char * res
Currently read line or NULL on EOF.
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.
Definition: gnunet-pils.c:83
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
@ GNUNET_OK
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, 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:407
Definition of a command line option.

References gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), once, options, res, ret, and run().

Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Return code.

Definition at line 34 of file gnunet-pils.c.

Referenced by main(), and run().

◆ once

int once
static

◆ pils

struct GNUNET_PILS_Handle* pils
static

Handle to PILS.

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

Referenced by run(), and shutdown_task().