-check return value
[oweals/gnunet.git] / src / util / program.c
index 597bd7584cc3375f84ea28e93d64b452878fd1c8..9e1a83d0bcc071252214e5eac03b973f2d98d5ec 100644 (file)
@@ -72,6 +72,11 @@ struct CommandContext
 
 };
 
+int
+GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+int
+GNUNET_SPEEDUP_stop_ (void);
 
 /**
  * Initial task called by the scheduler for each
@@ -81,6 +86,7 @@ static void
 program_main (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct CommandContext *cc = cls;
+  GNUNET_SPEEDUP_start_(cc->cfg);
 
   GNUNET_RESOLVER_connect (cc->cfg);
   cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg);
@@ -95,10 +101,10 @@ program_main (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * @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;
+  const struct GNUNET_GETOPT_CommandLineOption *c1 = a1;
+  const struct GNUNET_GETOPT_CommandLineOption *c2 = a2;
 
   if (toupper ((unsigned char) c1->shortName) >
       toupper ((unsigned char) c2->shortName))
@@ -125,7 +131,7 @@ cmd_sorter (__const void *a1, __const void *a2)
  * @param options command line options
  * @param task main function to run
  * @param task_cls closure for task
- * @param run_with_schedule GNUNET_NO start the scheduler, GNUNET_YES do not
+ * @param run_without_scheduler GNUNET_NO start the scheduler, GNUNET_YES do not
  *        start the scheduler just run the main task
  * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
@@ -134,7 +140,7 @@ 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_with_schedule)
+                    int run_without_scheduler)
 {
   struct CommandContext cc;
   char *path;
@@ -250,7 +256,7 @@ GNUNET_PROGRAM_run2 (int argc, char *const *argv, const char *binaryName,
   }
   /* run */
   cc.args = &argv[ret];
-  if (GNUNET_NO == run_with_schedule)
+  if (GNUNET_NO == run_without_scheduler)
   {
           GNUNET_SCHEDULER_run (&program_main, &cc);
   }
@@ -260,6 +266,7 @@ GNUNET_PROGRAM_run2 (int argc, char *const *argv, const char *binaryName,
           cc.task (cc.task_cls, cc.args, cc.cfgfile, cc.cfg);
   }
   /* clean up */
+  GNUNET_SPEEDUP_stop_ ();
   GNUNET_CONFIGURATION_destroy (cfg);
   GNUNET_free_non_null (cc.cfgfile);
   GNUNET_free_non_null (loglev);