GNUnet  0.17.6
Functions | Variables
gnunet-config.c File Reference

tool to access and manipulate GNUnet configuration files More...

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

Go to the source code of this file.

Functions

static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Print each option in a given section. More...
 
int main (int argc, char *const *argv)
 Program to manipulate configuration files. More...
 

Variables

static char * backend_check
 Backend to check if the respective plugin is loadable. More...
 
static int cflags
 If printing the value of CFLAGS has been requested. More...
 
static int is_experimental
 Check if this is an experimental build. More...
 
static int libs
 If printing the value of LIBS has been requested. More...
 
static int prefix
 If printing the value of PREFIX has been requested. More...
 

Detailed Description

tool to access and manipulate GNUnet configuration files

Author
Christian Grothoff

Definition in file gnunet-config.c.

Function Documentation

◆ run()

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

Print each option in a given section.

Main task to run to perform operations typical for gnunet-config as per the configuration settings given in cls.

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

Definition at line 74 of file gnunet-config.c.

78 {
79  struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls;
80 
81  if (1 == is_experimental)
82  {
83 #ifdef GNUNET_EXPERIMENTAL
84  cs->global_ret = 0;
85 #else
86  cs->global_ret = 1;
87 #endif
88  return;
89  }
90  if (1 == cflags || 1 == libs || 1 == prefix)
91  {
94 
95  if (1 == cflags)
96  {
97  fprintf (stdout, "-I%sinclude\n", prefixdir);
98  }
99  if (1 == libs)
100  {
101  fprintf (stdout, "-L%s -lgnunetutil\n", libdir);
102  }
103  if (1 == prefix)
104  {
105  fprintf (stdout, "%s\n", prefixdir);
106  }
107  cs->global_ret = 0;
108  GNUNET_free (prefixdir);
109  GNUNET_free (libdir);
110  return;
111  }
112  if (NULL != backend_check)
113  {
114  char *name;
115 
117  "libgnunet_plugin_%s",
118  backend_check);
119  cs->global_ret = (GNUNET_OK ==
120  GNUNET_PLUGIN_test (name)) ? 0 : 77;
121  GNUNET_free (name);
122  return;
123  }
125  args,
126  cfgfile,
127  cfg);
128 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int libs
If printing the value of LIBS has been requested.
Definition: gnunet-config.c:52
static char * backend_check
Backend to check if the respective plugin is loadable.
Definition: gnunet-config.c:35
static int cflags
If printing the value of CFLAGS has been requested.
Definition: gnunet-config.c:41
static int is_experimental
Check if this is an experimental build.
Definition: gnunet-config.c:46
static int prefix
If printing the value of PREFIX has been requested.
Definition: gnunet-config.c:58
void GNUNET_CONFIGURATION_config_tool_run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main task to run to perform operations typical for gnunet-config as per the configuration settings gi...
@ GNUNET_OK
Definition: gnunet_common.h:99
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
@ GNUNET_OS_IPK_LIBDIR
Return the directory where libraries are installed.
@ GNUNET_OS_IPK_PREFIX
Return the "PREFIX" directory given to configure.
int GNUNET_PLUGIN_test(const char *library_name)
Test if a plugin exists.
Definition: plugin.c:167
const char * name
Closure for GNUNET_CONFIGURATION_config_tool_run() with settings for what should be done with the con...
int global_ret
Return value from the operation, to be returned from 'main'.

References consensus-simulation::args, backend_check, cfg, cflags, GNUNET_CONFIGURATION_ConfigSettings::global_ret, GNUNET_asprintf(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_free, GNUNET_OK, GNUNET_OS_installation_get_path(), GNUNET_OS_IPK_LIBDIR, GNUNET_OS_IPK_PREFIX, GNUNET_PLUGIN_test(), is_experimental, libs, name, and prefix.

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 
)

Program to manipulate configuration files.

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

Definition at line 139 of file gnunet-config.c.

141 {
144  .global_ret = EXIT_SUCCESS
145  };
149  'b',
150  "supported-backend",
151  "BACKEND",
152  gettext_noop (
153  "test if the current installation supports the specified BACKEND"),
154  &backend_check)),
156  'C',
157  "cflags",
158  gettext_noop (
159  "Provide an appropriate value for CFLAGS to applications building on top of GNUnet"),
160  &cflags),
162  'E',
163  "is-experimental",
164  gettext_noop ("Is this an experimental build of GNUnet"),
165  &is_experimental),
167  'j',
168  "libs",
169  gettext_noop (
170  "Provide an appropriate value for LIBS to applications building on top of GNUnet"),
171  &libs),
173  'p',
174  "prefix",
175  gettext_noop (
176  "Provide the path under which GNUnet was installed"),
177  &prefix),
180  };
182 
183  if (GNUNET_OK !=
184  GNUNET_STRINGS_get_utf8_args (argc, argv,
185  &argc, &argv))
186  return EXIT_FAILURE;
187  ret =
188  GNUNET_PROGRAM_run (argc,
189  argv,
190  "gnunet-config [OPTIONS]",
191  gettext_noop ("Manipulate GNUnet configuration files"),
192  options,
193  &run,
194  &cs);
195  GNUNET_free_nz ((void *) argv);
197  if (GNUNET_NO == ret)
198  return 0;
199  if (GNUNET_SYSERR == ret)
200  return EXIT_INVALIDARGUMENT;
201  return cs.global_ret;
202 }
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:69
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Print each option in a given section.
Definition: gnunet-config.c:74
#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs)
Macro that expands to a set of GNUNET-getopt directives to initialize a struct GNUNET_CONFIGURATION_C...
void GNUNET_CONFIGURATION_config_settings_free(struct GNUNET_CONFIGURATION_ConfigSettings *cs)
Free resources associated with cs.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_exclusive(struct GNUNET_GETOPT_CommandLineOption opt)
Make the given option mutually exclusive with other 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.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
#define GNUNET_UTIL_VERSION
Version of the API (for entire gnunetutil.so library).
Definition: gnunet_common.h:86
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_free_nz(ptr)
Wrapper around free.
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:399
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1223
#define EXIT_INVALIDARGUMENT
Definition: platform.h:252
unsigned int api_version
Must be set to the API version, i.e.
Definition of a command line option.

References GNUNET_CONFIGURATION_ConfigSettings::api_version, backend_check, cflags, EXIT_INVALIDARGUMENT, gettext_noop, GNUNET_CONFIGURATION_ConfigSettings::global_ret, GNUNET_CONFIGURATION_CONFIG_OPTIONS, GNUNET_CONFIGURATION_config_settings_free(), GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_exclusive(), GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_NO, GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), GNUNET_SYSERR, GNUNET_UTIL_VERSION, is_experimental, libs, options, prefix, ret, and run().

Here is the call graph for this function:

Variable Documentation

◆ backend_check

char* backend_check
static

Backend to check if the respective plugin is loadable.

NULL if no check is to be performed. The value is the "basename" of the plugin to load.

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

Referenced by main(), and run().

◆ cflags

int cflags
static

If printing the value of CFLAGS has been requested.

Definition at line 41 of file gnunet-config.c.

Referenced by main(), and run().

◆ is_experimental

int is_experimental
static

Check if this is an experimental build.

Definition at line 46 of file gnunet-config.c.

Referenced by main(), and run().

◆ libs

int libs
static

If printing the value of LIBS has been requested.

Definition at line 52 of file gnunet-config.c.

Referenced by main(), and run().

◆ prefix

int prefix
static