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