WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
static void
delete_files ()
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Will attempt to remove configuration file %s and service directory %s\n",
- config_file,
- dir);
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_DEBUG,
+ "Will attempt to remove configuration file %s and service directory %s\n",
+ config_file,
+ dir);
if (0 != UNLINK (config_file))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to remove configuration file %s\n"),
+ _ ("Failed to remove configuration file %s\n"),
config_file);
}
if (GNUNET_OK != GNUNET_DISK_directory_remove (dir))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to remove servicehome directory %s\n"),
+ _ ("Failed to remove servicehome directory %s\n"),
dir);
}
}
/**
- * Returns a string interpretation of 'rs'
+ * Returns a string interpretation of @a rs
*
* @param rs the request status from ARM
* @return a string interpretation of the request status
switch (rs)
{
case GNUNET_ARM_REQUEST_SENT_OK:
- return _("Message was sent successfully");
+ return _ ("Message was sent successfully");
case GNUNET_ARM_REQUEST_DISCONNECTED:
- return _("We disconnected from ARM before we could send a request");
+ return _ ("We disconnected from ARM before we could send a request");
}
- return _("Unknown request status");
+ return _ ("Unknown request status");
}
/**
- * Returns a string interpretation of the 'result'
+ * Returns a string interpretation of the @a result
*
* @param result the arm result
* @return a string interpretation
switch (result)
{
case GNUNET_ARM_RESULT_STOPPED:
- return _("is stopped");
+ return _ ("is stopped");
case GNUNET_ARM_RESULT_STARTING:
- return _("is starting");
+ return _ ("is starting");
case GNUNET_ARM_RESULT_STOPPING:
- return _("is stopping");
+ return _ ("is stopping");
case GNUNET_ARM_RESULT_IS_STARTING_ALREADY:
- return _("is starting already");
+ return _ ("is starting already");
case GNUNET_ARM_RESULT_IS_STOPPING_ALREADY:
- return _("is stopping already");
+ return _ ("is stopping already");
case GNUNET_ARM_RESULT_IS_STARTED_ALREADY:
- return _("is started already");
+ return _ ("is started already");
case GNUNET_ARM_RESULT_IS_STOPPED_ALREADY:
- return _("is stopped already");
+ return _ ("is stopped already");
case GNUNET_ARM_RESULT_IS_NOT_KNOWN:
- return _("service is not known to ARM");
+ return _ ("service is not known to ARM");
case GNUNET_ARM_RESULT_START_FAILED:
- return _("service failed to start");
+ return _ ("service failed to start");
case GNUNET_ARM_RESULT_IN_SHUTDOWN:
- return _("service cannot be manipulated because ARM is shutting down");
+ return _ ("service cannot be manipulated because ARM is shutting down");
}
- return _("Unknown result code.");
+ return _ ("Unknown result code.");
}
* #GNUNET_SYSERR on error.
*/
static void
-conn_status (void *cls,
- int connected)
+conn_status (void *cls, int connected)
{
static int once;
(void) cls;
- if ( (GNUNET_SYSERR == connected) &&
- (0 == once) )
+ if ((GNUNET_SYSERR == connected) && (0 == once))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Fatal error initializing ARM API.\n"));
+ _ ("Fatal error initializing ARM API.\n"));
GNUNET_SCHEDULER_shutdown ();
return;
}
*/
static void
start_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- enum GNUNET_ARM_Result result)
+ enum GNUNET_ARM_RequestStatus rs,
+ enum GNUNET_ARM_Result result)
{
(void) cls;
op = NULL;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
{
FPRINTF (stdout,
- _("Failed to start the ARM service: %s\n"),
+ _ ("Failed to start the ARM service: %s\n"),
req_string (rs));
GNUNET_SCHEDULER_shutdown ();
return;
}
- if ( (GNUNET_ARM_RESULT_STARTING != result) &&
- (GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result) )
+ if ((GNUNET_ARM_RESULT_STARTING != result) &&
+ (GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result))
{
FPRINTF (stdout,
- _("Failed to start the ARM service: %s\n"),
+ _ ("Failed to start the ARM service: %s\n"),
ret_string (result));
GNUNET_SCHEDULER_shutdown ();
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM service [re]start successful\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM service [re]start successful\n");
start = 0;
al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
}
*/
static void
stop_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- enum GNUNET_ARM_Result result)
+ enum GNUNET_ARM_RequestStatus rs,
+ enum GNUNET_ARM_Result result)
{
char *msg;
op = NULL;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
{
- GNUNET_asprintf (&msg, "%s",
- _("Failed to send a stop request to the ARM service: %s\n"));
+ GNUNET_asprintf (&msg,
+ "%s",
+ _ (
+ "Failed to send a stop request to the ARM service: %s\n"));
FPRINTF (stdout, msg, req_string (rs));
GNUNET_free (msg);
GNUNET_SCHEDULER_shutdown ();
(GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
{
FPRINTF (stdout,
- _("Failed to stop the ARM service: %s\n"),
+ _ ("Failed to stop the ARM service: %s\n"),
ret_string (result));
GNUNET_SCHEDULER_shutdown ();
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM service shutdown successful\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM service shutdown successful\n");
end = 0;
if (restart)
{
restart = 0;
start = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Initiating an ARM restart\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initiating an ARM restart\n");
}
al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
}
*/
static void
init_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- enum GNUNET_ARM_Result result)
+ enum GNUNET_ARM_RequestStatus rs,
+ enum GNUNET_ARM_Result result)
{
(void) cls;
op = NULL;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
{
FPRINTF (stdout,
- _("Failed to send a request to start the `%s' service: %s\n"),
+ _ ("Failed to send a request to start the `%s' service: %s\n"),
init,
req_string (rs));
GNUNET_SCHEDULER_shutdown ();
(GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result))
{
FPRINTF (stdout,
- _("Failed to start the `%s' service: %s\n"),
+ _ ("Failed to start the `%s' service: %s\n"),
init,
ret_string (result));
GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Service %s [re]started successfully\n",
- init);
+ "Service %s [re]started successfully\n",
+ init);
GNUNET_free (init);
init = NULL;
al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
*/
static void
term_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- enum GNUNET_ARM_Result result)
+ enum GNUNET_ARM_RequestStatus rs,
+ enum GNUNET_ARM_Result result)
{
char *msg;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
{
GNUNET_asprintf (&msg,
- _("Failed to send a request to kill the `%s' service: %%s\n"),
+ _ (
+ "Failed to send a request to kill the `%s' service: %%s\n"),
term);
FPRINTF (stdout, msg, req_string (rs));
GNUNET_free (msg);
(GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
{
FPRINTF (stdout,
- _("Failed to kill the `%s' service: %s\n"),
+ _ ("Failed to kill the `%s' service: %s\n"),
term,
ret_string (result));
GNUNET_SCHEDULER_shutdown ();
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Service %s stopped successfully\n",
+ "Service %s stopped successfully\n",
term);
GNUNET_free (term);
term = NULL;
*/
static void
list_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- unsigned int count,
- const char *const*list)
+ enum GNUNET_ARM_RequestStatus rs,
+ unsigned int count,
+ const char *const *list)
{
- unsigned int i;
-
(void) cls;
op = NULL;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
{
char *msg;
- GNUNET_asprintf (&msg, "%s",
- _("Failed to request a list of services: %s\n"));
+ GNUNET_asprintf (&msg,
+ "%s",
+ _ ("Failed to request a list of services: %s\n"));
FPRINTF (stdout, msg, req_string (rs));
GNUNET_free (msg);
ret = 3;
}
if (NULL == list)
{
- FPRINTF (stderr, "%s",
- _("Error communicating with ARM. ARM not running?\n"));
+ FPRINTF (stderr,
+ "%s",
+ _ ("Error communicating with ARM. ARM not running?\n"));
GNUNET_SCHEDULER_shutdown ();
ret = 3;
return;
}
if (! quiet)
- FPRINTF (stdout, "%s", _("Running services:\n"));
- for (i = 0; i < count; i++)
+ FPRINTF (stdout, "%s", _ ("Running services:\n"));
+ for (unsigned int i = 0; i < count; i++)
FPRINTF (stdout, "%s\n", list[i]);
al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
}
{
(void) cls;
al_task = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Running requested actions\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running requested actions\n");
while (1)
{
switch (phase++)
case 0:
if (NULL != term)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Termination action\n");
- op = GNUNET_ARM_request_service_stop (h,
- term,
- &term_callback,
- NULL);
- return;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Termination action\n");
+ op = GNUNET_ARM_request_service_stop (h, term, &term_callback, NULL);
+ return;
}
break;
case 1:
if (end || restart)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "End action\n");
- op = GNUNET_ARM_request_service_stop (h,
- "arm",
- &stop_callback,
- NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "End action\n");
+ op = GNUNET_ARM_request_service_stop (h, "arm", &stop_callback, NULL);
return;
}
break;
case 2:
if (start)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Start action\n");
- op = GNUNET_ARM_request_service_start (h, "arm",
- (no_stdout ? 0 : GNUNET_OS_INHERIT_STD_OUT) |
- (no_stderr ? 0 : GNUNET_OS_INHERIT_STD_ERR),
- &start_callback,
- NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start action\n");
+ op =
+ GNUNET_ARM_request_service_start (h,
+ "arm",
+ (no_stdout
+ ? 0
+ : GNUNET_OS_INHERIT_STD_OUT) |
+ (no_stderr
+ ? 0
+ : GNUNET_OS_INHERIT_STD_ERR),
+ &start_callback,
+ NULL);
return;
}
break;
case 3:
if (NULL != init)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Initialization action\n");
- op = GNUNET_ARM_request_service_start (h, init,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initialization action\n");
+ op = GNUNET_ARM_request_service_start (h,
+ init,
GNUNET_OS_INHERIT_STD_NONE,
&init_callback,
NULL);
case 4:
if (list)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Going to list all running services controlled by ARM.\n");
- op = GNUNET_ARM_request_service_list (h,
- &list_callback,
- &list);
- return;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Going to list all running services controlled by ARM.\n");
+ op = GNUNET_ARM_request_service_list (h, &list_callback, &list);
+ return;
}
break;
case 5:
if (monitor)
- {
- if (! quiet)
- fprintf (stderr,
- _("Now only monitoring, press CTRL-C to stop.\n"));
- quiet = 0; /* does not make sense to stay quiet in monitor mode at this time */
- return; /* done with tasks, just monitor */
- }
+ {
+ if (! quiet)
+ fprintf (stderr, _ ("Now only monitoring, press CTRL-C to stop.\n"));
+ quiet =
+ 0; /* does not make sense to stay quiet in monitor mode at this time */
+ return; /* done with tasks, just monitor */
+ }
break;
- default: /* last phase */
+ default: /* last phase */
GNUNET_SCHEDULER_shutdown ();
return;
}
*/
static void
srv_status (void *cls,
- const char *service,
- enum GNUNET_ARM_ServiceStatus status)
+ const char *service,
+ enum GNUNET_ARM_ServiceStatus status)
{
const char *msg;
case GNUNET_ARM_SERVICE_MONITORING_STARTED:
return; /* this should be done silently */
case GNUNET_ARM_SERVICE_STOPPED:
- msg = _("Stopped %s.\n");
+ msg = _ ("Stopped %s.\n");
break;
case GNUNET_ARM_SERVICE_STARTING:
- msg = _("Starting %s...\n");
+ msg = _ ("Starting %s...\n");
break;
case GNUNET_ARM_SERVICE_STOPPING:
- msg = _("Stopping %s...\n");
+ msg = _ ("Stopping %s...\n");
break;
default:
msg = NULL;
if (! quiet)
{
if (NULL != msg)
- FPRINTF (stderr,
- msg,
- service);
+ FPRINTF (stderr, msg, service);
else
FPRINTF (stderr,
- _("Unknown status %u for service %s.\n"),
+ _ ("Unknown status %u for service %s.\n"),
status,
service);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got service %s status %d\n",
- service, (int)
- status);
+ service,
+ (int) status);
}
(void) cfgfile;
cfg = GNUNET_CONFIGURATION_dup (c);
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "PATHS",
- "GNUNET_HOME",
- &dir))
+ GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "GNUNET_HOME", &dir))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "PATHS",
- "GNUNET_HOME");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "PATHS", "GNUNET_HOME");
return;
}
(void) GNUNET_CONFIGURATION_get_value_filename (cfg,
- "arm",
- "CONFIG",
- &config_file);
- if (NULL == (h = GNUNET_ARM_connect (cfg,
- &conn_status,
- NULL)))
+ "arm",
+ "CONFIG",
+ &config_file);
+ if (NULL == (h = GNUNET_ARM_connect (cfg, &conn_status, NULL)))
return;
if (monitor)
- m = GNUNET_ARM_monitor_start (cfg,
- &srv_status,
- NULL);
- al_task = GNUNET_SCHEDULER_add_now (&action_loop,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
- NULL);
+ m = GNUNET_ARM_monitor_start (cfg, &srv_status, NULL);
+ al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
if (0 != timeout.rel_value_us)
- timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
- &timeout_task_cb,
- NULL);
+ timeout_task =
+ GNUNET_SCHEDULER_add_delayed (timeout, &timeout_task_cb, NULL);
}
* @return 0 ok, 1 on error, 2 on timeout
*/
int
-main (int argc,
- char *const *argv)
+main (int argc, char *const *argv)
{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_flag ('e',
- "end",
- gettext_noop ("stop all GNUnet services"),
- &end),
- GNUNET_GETOPT_option_string ('i',
- "init",
- "SERVICE",
- gettext_noop ("start a particular service"),
- &init),
- GNUNET_GETOPT_option_string ('k',
- "kill",
- "SERVICE",
- gettext_noop ("stop a particular service"),
- &term),
- GNUNET_GETOPT_option_flag ('s',
- "start",
- gettext_noop ("start all GNUnet default services"),
- &start),
- GNUNET_GETOPT_option_flag ('r',
- "restart",
- gettext_noop ("stop and start all GNUnet default services"),
- &restart),
- GNUNET_GETOPT_option_flag ('d',
- "delete",
- gettext_noop ("delete config file and directory on exit"),
- &delete),
- GNUNET_GETOPT_option_flag ('m',
- "monitor",
- gettext_noop ("monitor ARM activities"),
- &monitor),
- GNUNET_GETOPT_option_flag ('q',
- "quiet",
- gettext_noop ("don't print status messages"),
- &quiet),
- GNUNET_GETOPT_option_relative_time ('T',
- "timeout",
- "DELAY",
- gettext_noop ("exit with error status if operation does not finish after DELAY"),
- &timeout),
- GNUNET_GETOPT_option_flag ('I',
- "info",
- gettext_noop ("list currently running services"),
- &list),
- GNUNET_GETOPT_option_flag ('O',
- "no-stdout",
- gettext_noop ("don't let gnunet-service-arm inherit standard output"),
- &no_stdout),
- GNUNET_GETOPT_option_flag ('E',
- "no-stderr",
- gettext_noop ("don't let gnunet-service-arm inherit standard error"),
- &no_stderr),
- GNUNET_GETOPT_OPTION_END
- };
-
- if (GNUNET_OK !=
- GNUNET_STRINGS_get_utf8_args (argc, argv,
- &argc, &argv))
+ struct GNUNET_GETOPT_CommandLineOption options[] =
+ {GNUNET_GETOPT_option_flag ('e',
+ "end",
+ gettext_noop ("stop all GNUnet services"),
+ &end),
+ GNUNET_GETOPT_option_string ('i',
+ "init",
+ "SERVICE",
+ gettext_noop ("start a particular service"),
+ &init),
+ GNUNET_GETOPT_option_string ('k',
+ "kill",
+ "SERVICE",
+ gettext_noop ("stop a particular service"),
+ &term),
+ GNUNET_GETOPT_option_flag ('s',
+ "start",
+ gettext_noop (
+ "start all GNUnet default services"),
+ &start),
+ GNUNET_GETOPT_option_flag ('r',
+ "restart",
+ gettext_noop (
+ "stop and start all GNUnet default services"),
+ &restart),
+ GNUNET_GETOPT_option_flag ('d',
+ "delete",
+ gettext_noop (
+ "delete config file and directory on exit"),
+ &delete),
+ GNUNET_GETOPT_option_flag ('m',
+ "monitor",
+ gettext_noop ("monitor ARM activities"),
+ &monitor),
+ GNUNET_GETOPT_option_flag ('q',
+ "quiet",
+ gettext_noop ("don't print status messages"),
+ &quiet),
+ GNUNET_GETOPT_option_relative_time (
+ 'T',
+ "timeout",
+ "DELAY",
+ gettext_noop (
+ "exit with error status if operation does not finish after DELAY"),
+ &timeout),
+ GNUNET_GETOPT_option_flag ('I',
+ "info",
+ gettext_noop (
+ "list currently running services"),
+ &list),
+ GNUNET_GETOPT_option_flag (
+ 'O',
+ "no-stdout",
+ gettext_noop ("don't let gnunet-service-arm inherit standard output"),
+ &no_stdout),
+ GNUNET_GETOPT_option_flag (
+ 'E',
+ "no-stderr",
+ gettext_noop ("don't let gnunet-service-arm inherit standard error"),
+ &no_stderr),
+ GNUNET_GETOPT_OPTION_END};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
-
if (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-arm",
- gettext_noop
- ("Control services and the Automated Restart Manager (ARM)"),
- options,
- &run, NULL))
+ GNUNET_PROGRAM_run (
+ argc,
+ argv,
+ "gnunet-arm",
+ gettext_noop (
+ "Control services and the Automated Restart Manager (ARM)"),
+ options,
+ &run,
+ NULL))
{
GNUNET_free ((void *) argv);
return ret;
}
- GNUNET_free ((void*) argv);
+ GNUNET_free ((void *) argv);
return 1;
}
#include "speedup.h"
#include <gcrypt.h>
-#define LOG(kind,...) GNUNET_log_from (kind, "util-program", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-program", __VA_ARGS__)
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util-program", syscall, filename)
+#define LOG_STRERROR_FILE(kind, syscall, filename) \
+ GNUNET_log_from_strerror_file (kind, "util-program", syscall, filename)
/**
* Context for the command.
* Configuration to use.
*/
const struct GNUNET_CONFIGURATION_Handle *cfg;
-
};
{
struct CommandContext *cc = cls;
- GNUNET_SPEEDUP_start_(cc->cfg);
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
- NULL);
+ GNUNET_SPEEDUP_start_ (cc->cfg);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
GNUNET_RESOLVER_connect (cc->cfg);
- cc->task (cc->task_cls,
- cc->args,
- cc->cfgfile,
- cc->cfg);
+ cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg);
}
* @param a2 second command line option
*/
static int
-cmd_sorter (const void *a1,
- const void *a2)
+cmd_sorter (const void *a1, const void *a2)
{
const struct GNUNET_GETOPT_CommandLineOption *c1 = a1;
const struct GNUNET_GETOPT_CommandLineOption *c2 = a2;
*/
int
GNUNET_PROGRAM_run2 (int argc,
- char *const *argv,
- const char *binaryName,
+ char *const *argv,
+ const char *binaryName,
const char *binaryHelp,
const struct GNUNET_GETOPT_CommandLineOption *options,
GNUNET_PROGRAM_Main task,
- void *task_cls,
+ void *task_cls,
int run_without_scheduler)
{
struct CommandContext cc;
unsigned long long skew_variance;
long long clock_offset;
struct GNUNET_CONFIGURATION_Handle *cfg;
- struct GNUNET_GETOPT_CommandLineOption defoptions[] = {
- GNUNET_GETOPT_option_cfgfile (&cc.cfgfile),
- GNUNET_GETOPT_option_help (binaryHelp),
- GNUNET_GETOPT_option_loglevel (&loglev),
- GNUNET_GETOPT_option_logfile (&logfile),
- GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION)
- };
+ struct GNUNET_GETOPT_CommandLineOption defoptions[] =
+ {GNUNET_GETOPT_option_cfgfile (&cc.cfgfile),
+ GNUNET_GETOPT_option_help (binaryHelp),
+ GNUNET_GETOPT_option_loglevel (&loglev),
+ GNUNET_GETOPT_option_logfile (&logfile),
+ GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION)};
struct GNUNET_GETOPT_CommandLineOption *allopts;
const char *gargs;
char *lpfx;
gargv = NULL;
gargc = 0;
for (int i = 0; i < argc; i++)
- GNUNET_array_append (gargv,
- gargc,
- GNUNET_strdup (argv[i]));
+ GNUNET_array_append (gargv, gargc, GNUNET_strdup (argv[i]));
cargs = GNUNET_strdup (gargs);
- for (char *tok = strtok (cargs, " ");
- NULL != tok;
- tok = strtok (NULL, " "))
- GNUNET_array_append (gargv,
- gargc,
- GNUNET_strdup (tok));
+ for (char *tok = strtok (cargs, " "); NULL != tok; tok = strtok (NULL, " "))
+ GNUNET_array_append (gargv, gargc, GNUNET_strdup (tok));
GNUNET_free (cargs);
- GNUNET_array_append (gargv,
- gargc,
- NULL);
+ GNUNET_array_append (gargv, gargc, NULL);
argv = (char *const *) gargv;
argc = gargc - 1;
}
- memset (&cc,
- 0,
- sizeof (cc));
+ memset (&cc, 0, sizeof (cc));
loglev = NULL;
cc.task = task;
cc.task_cls = task_cls;
path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
if (NULL != path)
{
- BINDTEXTDOMAIN ("GNUnet",
- path);
+ BINDTEXTDOMAIN ("GNUnet", path);
GNUNET_free (path);
}
textdomain ("GNUnet");
while (NULL != options[cnt].name)
cnt++;
allopts =
- GNUNET_malloc ((cnt +
- 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption) +
- sizeof (defoptions));
- GNUNET_memcpy (allopts,
- defoptions,
- sizeof (defoptions));
- GNUNET_memcpy (&allopts
- [sizeof (defoptions) /
- sizeof (struct GNUNET_GETOPT_CommandLineOption)], options,
- (cnt + 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption));
+ GNUNET_malloc ((cnt + 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption) +
+ sizeof (defoptions));
+ GNUNET_memcpy (allopts, defoptions, sizeof (defoptions));
+ GNUNET_memcpy (&allopts[sizeof (defoptions) /
+ sizeof (struct GNUNET_GETOPT_CommandLineOption)],
+ options,
+ (cnt + 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption));
cnt += sizeof (defoptions) / sizeof (struct GNUNET_GETOPT_CommandLineOption);
qsort (allopts,
- cnt,
- sizeof (struct GNUNET_GETOPT_CommandLineOption),
+ cnt,
+ sizeof (struct GNUNET_GETOPT_CommandLineOption),
&cmd_sorter);
loglev = NULL;
xdg = getenv ("XDG_CONFIG_HOME");
lpfx = GNUNET_strdup (binaryName);
if (NULL != (spc = strstr (lpfx, " ")))
*spc = '\0';
- ret = GNUNET_GETOPT_run (binaryName,
- allopts,
- (unsigned int) argc,
- argv);
+ ret = GNUNET_GETOPT_run (binaryName, allopts, (unsigned int) argc, argv);
if ((GNUNET_OK > ret) ||
- (GNUNET_OK !=
- GNUNET_log_setup (lpfx,
- loglev,
- logfile)))
+ (GNUNET_OK != GNUNET_log_setup (lpfx, loglev, logfile)))
{
GNUNET_free (allopts);
GNUNET_free (lpfx);
}
if (NULL != cc.cfgfile)
{
- if ( (GNUNET_YES !=
- GNUNET_DISK_file_test (cc.cfgfile)) ||
- (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_load (cfg,
- cc.cfgfile)) )
+ if ((GNUNET_YES != GNUNET_DISK_file_test (cc.cfgfile)) ||
+ (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cc.cfgfile)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Unreadable or malformed configuration file `%s', exit ...\n"),
- cc.cfgfile);
+ _ (
+ "Unreadable or malformed configuration file `%s', exit ...\n"),
+ cc.cfgfile);
ret = GNUNET_SYSERR;
GNUNET_free (allopts);
GNUNET_free (lpfx);
}
else
{
- if (GNUNET_YES ==
- GNUNET_DISK_file_test (cfg_fn))
+ if (GNUNET_YES == GNUNET_DISK_file_test (cfg_fn))
{
- if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_load (cfg,
- cfg_fn))
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfg_fn))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Unreadable or malformed default configuration file `%s', exit ...\n"),
- cfg_fn);
- ret = GNUNET_SYSERR;
- GNUNET_free (allopts);
- GNUNET_free (lpfx);
- goto cleanup;
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_ERROR,
+ _ (
+ "Unreadable or malformed default configuration file `%s', exit ...\n"),
+ cfg_fn);
+ ret = GNUNET_SYSERR;
+ GNUNET_free (allopts);
+ GNUNET_free (lpfx);
+ goto cleanup;
}
}
else
{
GNUNET_free (cfg_fn);
cfg_fn = NULL;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_load (cfg,
- NULL))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, NULL))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Unreadable or malformed configuration, exit ...\n"));
- ret = GNUNET_SYSERR;
- GNUNET_free (allopts);
- GNUNET_free (lpfx);
- goto cleanup;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Unreadable or malformed configuration, exit ...\n"));
+ ret = GNUNET_SYSERR;
+ GNUNET_free (allopts);
+ GNUNET_free (lpfx);
+ goto cleanup;
}
}
}
GNUNET_free (allopts);
GNUNET_free (lpfx);
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number (cc.cfg,
- "testing",
- "skew_offset",
- &skew_offset) &&
- (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number (cc.cfg,
- "testing",
- "skew_variance",
- &skew_variance)))
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cc.cfg,
+ "testing",
+ "skew_offset",
+ &skew_offset) &&
+ (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cc.cfg,
+ "testing",
+ "skew_variance",
+ &skew_variance)))
{
clock_offset = skew_offset - skew_variance;
GNUNET_TIME_set_offset (clock_offset);
in "cfg". This is typically really only having an effect if we
are running code in src/arm/, as obviously the rest of the code
has little business with ARM-specific options. */
- if (GNUNET_YES !=
- GNUNET_CONFIGURATION_have_value (cfg,
- "arm",
- "CONFIG"))
+ if (GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, "arm", "CONFIG"))
{
if (NULL != cc.cfgfile)
- GNUNET_CONFIGURATION_set_value_string (cfg,
- "arm",
- "CONFIG",
- cc.cfgfile);
+ GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", cc.cfgfile);
else if (NULL != cfg_fn)
- GNUNET_CONFIGURATION_set_value_string (cfg,
- "arm",
- "CONFIG",
- cfg_fn);
+ GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", cfg_fn);
}
/* run */
cc.args = &argv[ret];
- if ( (NULL == cc.cfgfile) &&
- (NULL != cfg_fn) )
+ if ((NULL == cc.cfgfile) && (NULL != cfg_fn))
cc.cfgfile = GNUNET_strdup (cfg_fn);
if (GNUNET_NO == run_without_scheduler)
{
- GNUNET_SCHEDULER_run (&program_main,
- &cc);
+ GNUNET_SCHEDULER_run (&program_main, &cc);
}
else
{
GNUNET_RESOLVER_connect (cc.cfg);
- cc.task (cc.task_cls,
- cc.args,
- cc.cfgfile,
- cc.cfg);
+ cc.task (cc.task_cls, cc.args, cc.cfgfile, cc.cfg);
}
ret = GNUNET_OK;
- cleanup:
+cleanup:
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free_non_null (cc.cfgfile);
GNUNET_free_non_null (cfg_fn);
* @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/
int
-GNUNET_PROGRAM_run (int argc, char *const *argv,
+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)
{
- return GNUNET_PROGRAM_run2 (argc, argv,
- binaryName, binaryHelp,
+ return GNUNET_PROGRAM_run2 (argc,
+ argv,
+ binaryName,
+ binaryHelp,
options,
- task, task_cls,
+ task,
+ task_cls,
GNUNET_NO);
}