Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
152 unsigned long long skew_offset;
153 unsigned long long skew_variance;
154 long long clock_offset;
164 unsigned int deflen =
sizeof(defoptions) /
sizeof(defoptions[0]);
171 gargs =
getenv (
"GNUNET_ARGS");
180 for (
int i = 0; i < argc; i++)
185 for (
char *tok = strtok (cargs,
" ");
187 tok = strtok (NULL,
" "))
191 argv = (
char *
const *) gargv;
194 memset (&cc, 0,
sizeof(cc));
197 cc.task_cls = task_cls;
203 setlocale (LC_ALL,
"");
224 unsigned int xtra = 0;
226 for (
unsigned int i = 0;
232 for (
unsigned int j = 0; j<cnt; j++)
237 (NULL != defoptions[i].
name) &&
239 defoptions[i].
name)) );
262 if (NULL != (spc = strstr (lpfx,
" ")))
278 if (NULL != cc.cfgfile)
281 "Loading configuration from entry point specified as option (%s)\n",
287 _ (
"Unreadable configuration file `%s', exiting ...\n"),
299 _ (
"Malformed configuration file `%s', exiting ...\n"),
309 if ( (NULL != cfg_fn) &&
314 _ (
"Unreadable configuration file `%s'. Exiting ...\n"),
322 "Loading configuration from entry point `%s'\n",
329 _ (
"Malformed configuration. Exiting ...\n"));
349 clock_offset = skew_offset - skew_variance;
363 if (NULL != cc.cfgfile)
368 else if (NULL != cfg_fn)
376 cc.args = &argv[iret];
377 if ((NULL == cc.cfgfile) && (NULL != cfg_fn))
386 cc.task (cc.task_cls, cc.args, cc.cfgfile, cc.cfg);
struct GNUNET_GETOPT_CommandLineOption options[]
#define textdomain(Domainname)
#define bindtextdomain(Domainname, Dirname)
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int ret
Return value of the commandline.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
char * GNUNET_CONFIGURATION_default_filename(void)
Return the filename of the default configuration filename that is used when no explicit configuration...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_cfgfile(char **fn)
Allow user to specify configuration file name (-c option)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_logfile(char **logfn)
Allow user to specify log file name (-l option)
int GNUNET_GETOPT_run(const char *binaryOptions, const struct GNUNET_GETOPT_CommandLineOption *allOptions, unsigned int argc, char *const *argv)
Parse the command line.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_help(const char *about)
Defining the option to print the command line help text (-h option).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_loglevel(char **level)
Define the '-L' log level option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_version(const char *version)
Define the option to print the version of the application (-v option)
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
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_LOCALEDIR
Return the directory where translations are installed (share/locale/)
void GNUNET_RESOLVER_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create the connection to the resolver service.
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
void GNUNET_TIME_set_offset(long long offset)
Set the timestamp offset for this instance.
static void program_main(void *cls)
Initial task called by the scheduler for each program.
static int cmd_sorter(const void *a1, const void *a2)
Compare function for 'qsort' to sort command-line arguments by the short option.
Definition of a command line option.
const char * name
Long name of the option (may not be NULL)
const char shortName
Short name of the option.
Project-specific data used to help the OS subsystem find installation paths.
char * gettext_path
Gettext directory, e.g.
const char * user_config_file
Configuration file name to use (if $XDG_CONFIG_HOME is not set).
const char * config_file
Configuration file name (in $XDG_CONFIG_HOME) to use.
char * gettext_domain
Gettext domain for localisation, e.g.
const char * version
String identifying the current project version.