Next: , Previous: , Up: Developing Applications   [Contents]

4.3 Writing a Client Application

When writing any client application (for example, a command-line tool), the basic structure is to start with the GNUNET\_PROGRAM\_run function. This function will parse command-line options, setup the scheduler and then invoke the run function (with the remaining non-option arguments) and a handle to the parsed configuration (and the configuration file name that was used, which is typically not needed):

#include <gnunet/platform.h>
#include <gnunet/gnunet_util_lib.h>

static int ret;

static void
run (void *cls,
     char *const *args,
     const char *cfgfile,
     const struct GNUNET_CONFIGURATION_Handle *cfg)
  // main code here
  ret = 0;

main (int argc, char *const *argv)
  struct GNUNET_GETOPT_CommandLineOption options[] = {
  return (GNUNET_OK ==
          GNUNET_PROGRAM_run (argc,
                              gettext_noop ("binary description text"),
                              options, &run, NULL)) ? ret : 1;