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) <
135 const char *binaryName,
136 const char *binaryHelp,
140 int run_without_scheduler)
153 unsigned long long skew_offset;
154 unsigned long long skew_variance;
155 long long clock_offset;
165 unsigned int deflen =
sizeof(defoptions) /
sizeof(defoptions[0]);
172 gargs =
getenv (
"GNUNET_ARGS");
181 for (
int i = 0; i < argc; i++)
186 for (
char *tok = strtok (cargs,
" ");
188 tok = strtok (NULL,
" "))
196 argv = (
char *
const *) gargv;
199 memset (&cc, 0,
sizeof(cc));
208 setlocale (LC_ALL,
"");
231 unsigned int xtra = 0;
233 for (
unsigned int i = 0;
239 for (
unsigned int j = 0; j<cnt; j++)
244 (NULL != defoptions[i].
name) &&
246 defoptions[i].
name)) );
269 if (NULL != (spc = strstr (lpfx,
" ")))
288 "Loading configuration from entry point specified as option (%s)\n",
294 _ (
"Unreadable configuration file `%s', exiting ...\n"),
306 _ (
"Malformed configuration file `%s', exiting ...\n"),
316 if ( (NULL != cfg_fn) &&
321 _ (
"Unreadable configuration file `%s'. Exiting ...\n"),
329 "Loading configuration from entry point `%s'\n",
336 _ (
"Malformed configuration. Exiting ...\n"));
356 clock_offset = skew_offset - skew_variance;
375 else if (NULL != cfg_fn)
383 cc.
args = &argv[iret];
384 if ((NULL == cc.
cfgfile) && (NULL != cfg_fn))
410 const char *binaryName,
411 const char *binaryHelp,
435 char *opt_cfg_filename;
446 "do daemonize (detach from terminal)"),
456 xdg =
getenv (
"XDG_CONFIG_HOME");
468 opt_cfg_filename = NULL;
493 if (NULL != opt_cfg_filename)
502 _ (
"Malformed configuration file `%s', exit ...\n"),
517 _ (
"Malformed configuration file `%s', exit ...\n"),
530 _ (
"Malformed configuration, exit ...\n"));
634 hll->
d (NULL, NULL, NULL, hll->
cfg);
648 "Launching daemon %s\n",
665 "Entering GNUNET_DAEMON_main\n");
684 const char *daemon_help,
690 "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.
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
Functions related to doing DNS lookups.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
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(const struct GNUNET_OS_ProjectData *pd)
Return the filename of the default configuration filename that is used when no explicit configuration...
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 struct GNUNET_OS_ProjectData *pd, 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(const struct GNUNET_OS_ProjectData *pd, 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/)
enum GNUNET_GenericReturnValue GNUNET_DAEMON_register(const char *daemon_name, const char *daemon_help, GNUNET_PROGRAM_Main task)
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run2(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, int run_without_scheduler)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_PROGRAM_monolith_main(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg)
Start all services and daemons in a single process.
void(* GNUNET_PROGRAM_Main)(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
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,...
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_conf_and_options(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg)
Create configuration handle from options and configuration file.
void GNUNET_DAEMON_main(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_GenericReturnValue with_scheduler)
Run the mainloop in a monolithic libgnunet.
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(const struct GNUNET_OS_ProjectData *pd, 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
const struct GNUNET_OS_ProjectData * pd
Project data for this configuration object.
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.
const struct GNUNET_OS_ProjectData * pd
struct GNUNET_CONFIGURATION_Handle * cfg