GNUnet 0.27.0
 
Loading...
Searching...
No Matches
gnunet-pils.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2025--2026 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
26#include "platform.h"
27#include "gnunet_time_lib.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_pils_service.h"
30
34static int ret;
35
39static int once;
40
44static struct GNUNET_PILS_Handle *pils;
45
52static void
53shutdown_task (void *cls)
54{
55 (void) cls;
56 if (NULL != pils)
57 {
59 pils = NULL;
60 }
61}
62
63
64void
65pid_change_cb (void *cls,
66 const struct GNUNET_HELLO_Parser *hparser,
67 const struct GNUNET_HashCode *addr_hash)
68{
69 printf ("%s\n",
71 if (once)
73}
74
75
84static void
85run (void *cls,
86 char *const *args,
87 const char *cfgfile,
88 const struct GNUNET_CONFIGURATION_Handle *cfg)
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}
108
109
117int
118main (int argc, char *const *argv)
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}
146
147
148/* end of gnunet-core.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
int main()
Program to simulate results from GCP_get_desirability_of_path() for various plausible inputs.
#define gettext_noop(String)
Definition gettext.h:74
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
struct GNUNET_SCHEDULER_Task * shutdown_task
static char * res
Currently read line or NULL on EOF.
static int ret
Return code.
Definition gnunet-pils.c:34
static int once
Option -i.
Definition gnunet-pils.c:39
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
void pid_change_cb(void *cls, const struct GNUNET_HELLO_Parser *hparser, const struct GNUNET_HashCode *addr_hash)
Definition gnunet-pils.c:65
static struct GNUNET_PILS_Handle * pils
Handle to PILS.
Definition gnunet-pils.c:44
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
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:488
Functions related to time.
#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.
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
@ GNUNET_OK
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:572
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
Definition of a command line option.
Context for parsing HELLOs.
Definition hello-uri.c:233
A 512-bit hashcode.
A handle for the PILS service.
Definition pils_api.c:82