35#define LOG(kind, ...) GNUNET_log_from (kind, "util-program", __VA_ARGS__)
37#define LOG_STRERROR_FILE(kind, syscall, filename) \
38 GNUNET_log_from_strerror_file (kind, "util-program", syscall, filename)
117 if (toupper ((
unsigned char) c1->
shortName) >
120 if (toupper ((
unsigned char) c1->
shortName) <
134 const char *binaryName,
135 const char *binaryHelp,
139 int run_without_scheduler)
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));
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,
" ")))
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;
368 else if (NULL != cfg_fn)
376 cc.
args = &argv[iret];
377 if ((NULL == cc.
cfgfile) && (NULL != cfg_fn))
402 const char *binaryName,
403 const char *binaryHelp,
425 char *opt_cfg_filename;
437 "do daemonize (detach from terminal)"),
446 xdg =
getenv (
"XDG_CONFIG_HOME");
458 opt_cfg_filename = NULL;
483 if (NULL != opt_cfg_filename)
492 _ (
"Malformed configuration file `%s', exit ...\n"),
507 _ (
"Malformed configuration file `%s', exit ...\n"),
520 _ (
"Malformed configuration, exit ...\n"));
609 hll->
d (NULL, NULL, NULL, hll->
cfg);
623 "Launching daemon %s\n",
639 "Entering GNUNET_DAEMON_main\n");
656 const char *daemon_help,
662 "registering daemon %s\n",
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
#define textdomain(Domainname)
#define bindtextdomain(Domainname, Dirname)
static int ret
Final status code.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static char * cfg_filename
Name of the configuration file.
static void cleanup(void *cls)
Disconnect and shutdown.
static char * name
Name (label) of the records to list.
Functions related to doing DNS lookups.
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.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
char * GNUNET_CONFIGURATION_default_filename(void)
Return the filename of the default configuration filename that is used when no explicit configuration...
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load 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).
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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_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_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.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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.
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,...
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
@ GNUNET_OS_IPK_LOCALEDIR
Return the directory where translations are installed (share/locale/)
enum GNUNET_GenericReturnValue GNUNET_DAEMON_register(const char *daemon_name, const char *daemon_help, GNUNET_PROGRAM_Main task)
void GNUNET_DAEMON_main(int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_GenericReturnValue with_scheduler)
Run the mainloop in a monolithic libgnunet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run2(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls, int run_without_scheduler)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void(* GNUNET_PROGRAM_Main)(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
void GNUNET_PROGRAM_monolith_main(int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg)
Start all services and daemons in a single process.
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,...
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_conf_and_options(int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg)
Create configuration handle from options and configuration file.
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.
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,...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
void GNUNET_SERVICE_main(int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_GenericReturnValue with_scheduler)
Run the mainloop in a monolithic libgnunet.
void GNUNET_TIME_set_offset(long long offset)
Set the timestamp offset for this instance.
static void launch_daemon(void *cls)
static struct DaemonHandleList * hll_tail
static void monolith_main(void *cls)
static struct DaemonHandleList * hll_head
static void shutdown_task(void *cls)
task run when the scheduler shuts down
static void launch_daemons(void *cls)
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.
int GNUNET_SPEEDUP_start_(const struct GNUNET_CONFIGURATION_Handle *cfg)
Start task that may speed up our system clock artificially.
void GNUNET_SPEEDUP_stop_()
Stop tasks that modify clock behavior.
void * task_cls
Closure for task.
char *const * args
Argv argument.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
GNUNET_PROGRAM_Main task
Main function to run.
char * cfgfile
Name of the configuration file used, can be NULL!
const struct GNUNET_CONFIGURATION_Handle * cfg
struct DaemonHandleList * next
struct DaemonHandleList * prev
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.
const char * gettext_path
Gettext directory, e.g.
const char * gettext_domain
Gettext domain for localisation, 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.
const char * version
String identifying the current project version.