34 #define LOG(kind, ...) GNUNET_log_from (kind, "util-program", __VA_ARGS__) 36 #define LOG_STRERROR_FILE(kind, syscall, filename) \ 37 GNUNET_log_from_strerror_file (kind, "util-program", syscall, filename) 111 if (toupper ((
unsigned char) c1->
shortName) >
114 if (toupper ((
unsigned char) c1->
shortName) <
128 const char *binaryName,
129 const char *binaryHelp,
133 int run_without_scheduler)
147 unsigned long long skew_offset;
148 unsigned long long skew_variance;
149 long long clock_offset;
164 gargs =
getenv (
"GNUNET_ARGS");
173 for (
int i = 0; i < argc; i++)
176 for (
char *tok = strtok (cargs,
" "); NULL != tok; tok = strtok (NULL,
" "))
180 argv = (
char *
const *) gargv;
183 memset (&cc, 0,
sizeof(cc));
192 setlocale (LC_ALL,
"");
205 while (NULL != options[cnt].
name)
209 +
sizeof(defoptions));
223 xdg =
getenv (
"XDG_CONFIG_HOME");
236 if (NULL != (spc = strstr (lpfx,
" ")))
259 "Unreadable or malformed configuration file `%s', exit ...\n"),
276 "Unreadable or malformed default configuration file `%s', exit ...\n"),
284 else if (NULL != cfg_fn)
291 _ (
"Unreadable or malformed configuration, exit ...\n"));
312 clock_offset = skew_offset - skew_variance;
331 else if (NULL != cfg_fn)
339 cc.
args = &argv[iret];
340 if ((NULL == cc.
cfgfile) && (NULL != cfg_fn))
365 const char *binaryName,
366 const char *binaryHelp,
Return the directory where translations are installed (share/locale/)
const char * config_file
Configuration file name (in $XDG_CONFIG_HOME) to use.
char * gettext_domain
Gettext domain for localisation, e.g.
Project-specific data used to help the OS subsystem find installation paths.
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, parse options).
void(* GNUNET_PROGRAM_Main)(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
char * gettext_path
Gettext directory, e.g.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
struct GNUNET_GETOPT_CommandLineOption options[]
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_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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
static void program_main(void *cls)
Initial task called by the scheduler for each program.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
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.
GNUNET_GenericReturnValue
Named constants for return values.
const char * user_config_file
Configuration file name to use (if $XDG_CONFIG_HOME is not set).
#define bindtextdomain(Domainname, Dirname)
Definition of a command line option.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
void GNUNET_TIME_set_offset(long long offset)
Set the timestamp offset for this instance.
const char shortName
Short name of the option.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_logfile(char **logfn)
Allow user to specify log file name (-l option)
char *const * args
Argv argument.
const char * version
String identifying the current project version.
#define textdomain(Domainname)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_version(const char *version)
Define the option to print the version of the application (-v option)
static void shutdown_task(void *cls)
task run when the scheduler shuts down
static int cmd_sorter(const void *a1, const void *a2)
Compare function for 'qsort' to sort command-line arguments by the short option.
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, the current running apps installation directory.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_loglevel(char **level)
Define the '-L' log level option.
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.
char * cfgfile
Name of the configuration file used, can be NULL!
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
int GNUNET_GETOPT_run(const char *binaryOptions, const struct GNUNET_GETOPT_CommandLineOption *allOptions, unsigned int argc, char *const *argv)
Parse the command line.
void * task_cls
Closure for task.
GNUNET_PROGRAM_Main task
Main function to run.
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.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_cfgfile(char **fn)
Allow user to specify configuration file name (-c option)
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, parse options).
int GNUNET_SPEEDUP_start_(const struct GNUNET_CONFIGURATION_Handle *cfg)
Start task that may speed up our system clock artificially.
#define GNUNET_log(kind,...)
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
void GNUNET_RESOLVER_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create the connection to the resolver service.
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_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_SPEEDUP_stop_()
Stop tasks that modify clock behavior.