gnunet_program_lib.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2001-2013 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. /**
  18. * @author Christian Grothoff
  19. *
  20. * @file
  21. * Functions related to starting programs
  22. *
  23. * @defgroup program Program library
  24. * Start command-line programs.
  25. * @{
  26. */
  27. #ifndef GNUNET_PROGRAM_LIB_H
  28. #define GNUNET_PROGRAM_LIB_H
  29. #ifdef __cplusplus
  30. extern "C"
  31. {
  32. #if 0 /* keep Emacsens' auto-indent happy */
  33. }
  34. #endif
  35. #endif
  36. #include "gnunet_configuration_lib.h"
  37. #include "gnunet_getopt_lib.h"
  38. #include "gnunet_scheduler_lib.h"
  39. /**
  40. * Main function that will be run.
  41. *
  42. * @param cls closure
  43. * @param args remaining command-line arguments
  44. * @param cfgfile name of the configuration file used (for saving, can be NULL!)
  45. * @param cfg configuration
  46. */
  47. typedef void
  48. (*GNUNET_PROGRAM_Main) (void *cls,
  49. char *const *args,
  50. const char *cfgfile,
  51. const struct GNUNET_CONFIGURATION_Handle *cfg);
  52. /**
  53. * Run a standard GNUnet command startup sequence (initialize loggers
  54. * and configuration, parse options).
  55. *
  56. * @param argc number of command line arguments in @a argv
  57. * @param argv command line arguments
  58. * @param binaryName our expected name
  59. * @param binaryHelp help text for the program
  60. * @param options command line options
  61. * @param task main function to run
  62. * @param task_cls closure for @a task
  63. * @param run_without_scheduler #GNUNET_NO start the scheduler,
  64. * #GNUNET_YES do not start the scheduler just run the main task
  65. * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
  66. */
  67. int
  68. GNUNET_PROGRAM_run2 (int argc,
  69. char *const *argv,
  70. const char *binaryName,
  71. const char *binaryHelp,
  72. const struct GNUNET_GETOPT_CommandLineOption *options,
  73. GNUNET_PROGRAM_Main task,
  74. void *task_cls,
  75. int run_without_scheduler);
  76. /**
  77. * Run a standard GNUnet command startup sequence (initialize loggers
  78. * and configuration, parse options).
  79. *
  80. * @param argc number of command line arguments
  81. * @param argv command line arguments
  82. * @param binaryName our expected name
  83. * @param binaryHelp helptext for "-h" option (about the app)
  84. * @param options command line options
  85. * @param task main function to run
  86. * @param task_cls closure for @a task
  87. * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
  88. */
  89. int
  90. GNUNET_PROGRAM_run (int argc,
  91. char *const *argv,
  92. const char *binaryName,
  93. const char *binaryHelp,
  94. const struct GNUNET_GETOPT_CommandLineOption *options,
  95. GNUNET_PROGRAM_Main task, void *task_cls);
  96. #if 0 /* keep Emacsens' auto-indent happy */
  97. {
  98. #endif
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. /* ifndef GNUNET_PROGRAM_LIB_H */
  103. #endif
  104. /** @} */ /* end of group program */
  105. /* end of gnunet_program_lib.h */