GNUnet 0.26.2-114-g7c6b613e3
 
Loading...
Searching...
No Matches
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.
 
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.
 
int main (int argc, char *const *argv)
 The main function to obtain peer information from PILS.
 

Variables

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

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:488

References GNUNET_PILS_disconnect(), and pils.

Here is the call 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 65 of file gnunet-pils.c.

68{
69 printf ("%s\n",
71 if (once)
73}
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:354
const char * GNUNET_i2s_full(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:572

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

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 85 of file gnunet-pils.c.

89{
90 (void) cls;
91 (void) cfgfile;
92
93 if (NULL != args[0])
94 {
95 fprintf (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
96 return;
97 }
100 if (NULL == pils)
101 {
102 fprintf (stderr, "%s", _ ("Unable to connect to service.\n"));
103 ret = 1;
105 return;
106 }
107}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
struct GNUNET_SCHEDULER_Task * shutdown_task
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:65
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:465
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:1345
#define _(String)
GNU gettext support macro.
Definition platform.h:179

References _, 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 118 of file gnunet-pils.c.

119{
120 int res;
123 '1',
124 "once",
126 "Show our current peer identity and exit"
127 ),
128 &once),
130 };
131
133 argc,
134 argv,
135 "gnunet-pils",
137 "Print information about our peer identity."),
138 options,
139 &run,
140 NULL);
141
142 if (GNUNET_OK == res)
143 return ret;
144 return 1;
145}
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:85
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
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