gnunet_program_lib.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2001-2013 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your 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. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @author Christian Grothoff
  18. *
  19. * @file
  20. * Functions related to starting programs
  21. *
  22. * @defgroup program Program library
  23. * Start command-line programs.
  24. * @{
  25. */
  26. #ifndef GNUNET_PROGRAM_LIB_H
  27. #define GNUNET_PROGRAM_LIB_H
  28. #ifdef __cplusplus
  29. extern "C"
  30. {
  31. #if 0 /* keep Emacsens' auto-indent happy */
  32. }
  33. #endif
  34. #endif
  35. #include "gnunet_configuration_lib.h"
  36. #include "gnunet_getopt_lib.h"
  37. #include "gnunet_scheduler_lib.h"
  38. /**
  39. * Main function that will be run.
  40. *
  41. * @param cls closure
  42. * @param args remaining command-line arguments
  43. * @param cfgfile name of the configuration file used (for saving, can be NULL!)
  44. * @param cfg configuration
  45. */
  46. typedef void
  47. (*GNUNET_PROGRAM_Main) (void *cls,
  48. char *const *args,
  49. const char *cfgfile,
  50. const struct GNUNET_CONFIGURATION_Handle *cfg);
  51. /**
  52. * Run a standard GNUnet command startup sequence (initialize loggers
  53. * and configuration, parse options).
  54. *
  55. * @param argc number of command line arguments in @a argv
  56. * @param argv command line arguments
  57. * @param binaryName our expected name
  58. * @param binaryHelp help text for the program
  59. * @param options command line options
  60. * @param task main function to run
  61. * @param task_cls closure for @a task
  62. * @param run_without_scheduler #GNUNET_NO start the scheduler,
  63. * #GNUNET_YES do not start the scheduler just run the main task
  64. * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
  65. */
  66. int
  67. GNUNET_PROGRAM_run2 (int argc,
  68. char *const *argv,
  69. const char *binaryName,
  70. const char *binaryHelp,
  71. const struct GNUNET_GETOPT_CommandLineOption *options,
  72. GNUNET_PROGRAM_Main task,
  73. void *task_cls,
  74. int run_without_scheduler);
  75. /**
  76. * Run a standard GNUnet command startup sequence (initialize loggers
  77. * and configuration, parse options).
  78. *
  79. * @param argc number of command line arguments
  80. * @param argv command line arguments
  81. * @param binaryName our expected name
  82. * @param binaryHelp helptext for "-h" option (about the app)
  83. * @param options command line options
  84. * @param task main function to run
  85. * @param task_cls closure for @a task
  86. * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
  87. */
  88. int
  89. GNUNET_PROGRAM_run (int argc,
  90. char *const *argv,
  91. const char *binaryName,
  92. const char *binaryHelp,
  93. const struct GNUNET_GETOPT_CommandLineOption *options,
  94. GNUNET_PROGRAM_Main task,
  95. 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 */