Use GNU printf format
[oweals/gnunet.git] / src / include / gnunet_program_lib.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2001-2013 GNUnet e.V.
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  * @author Christian Grothoff
23  *
24  * @file
25  * Functions related to starting programs
26  *
27  * @defgroup program  Program library
28  * Start command-line programs.
29  * @{
30  */
31
32 #ifndef GNUNET_PROGRAM_LIB_H
33 #define GNUNET_PROGRAM_LIB_H
34
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #if 0                           /* keep Emacsens' auto-indent happy */
39 }
40 #endif
41 #endif
42
43 #include "gnunet_configuration_lib.h"
44 #include "gnunet_getopt_lib.h"
45 #include "gnunet_scheduler_lib.h"
46
47 /**
48  * Main function that will be run.
49  *
50  * @param cls closure
51  * @param args remaining command-line arguments
52  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
53  * @param cfg configuration
54  */
55 typedef void
56 (*GNUNET_PROGRAM_Main) (void *cls,
57                         char *const *args,
58                         const char *cfgfile,
59                         const struct GNUNET_CONFIGURATION_Handle *cfg);
60
61
62 /**
63  * Run a standard GNUnet command startup sequence (initialize loggers
64  * and configuration, parse options).
65  *
66  * @param argc number of command line arguments in @a argv
67  * @param argv command line arguments
68  * @param binaryName our expected name
69  * @param binaryHelp help text for the program
70  * @param options command line options
71  * @param task main function to run
72  * @param task_cls closure for @a task
73  * @param run_without_scheduler #GNUNET_NO start the scheduler,
74  *        #GNUNET_YES do not start the scheduler just run the main task
75  * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
76  */
77 int
78 GNUNET_PROGRAM_run2 (int argc,
79                      char *const *argv,
80                      const char *binaryName,
81                      const char *binaryHelp,
82                      const struct GNUNET_GETOPT_CommandLineOption *options,
83                      GNUNET_PROGRAM_Main task,
84                      void *task_cls,
85                      int run_without_scheduler);
86
87 /**
88  * Run a standard GNUnet command startup sequence (initialize loggers
89  * and configuration, parse options).
90  *
91  * @param argc number of command line arguments
92  * @param argv command line arguments
93  * @param binaryName our expected name
94  * @param binaryHelp helptext for "-h" option (about the app)
95  * @param options command line options
96  * @param task main function to run
97  * @param task_cls closure for @a task
98  * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
99  */
100 int
101 GNUNET_PROGRAM_run (int argc,
102                     char *const *argv,
103                     const char *binaryName,
104                     const char *binaryHelp,
105                     const struct GNUNET_GETOPT_CommandLineOption *options,
106                     GNUNET_PROGRAM_Main task, void *task_cls);
107
108
109 #if 0                           /* keep Emacsens' auto-indent happy */
110 {
111 #endif
112 #ifdef __cplusplus
113 }
114 #endif
115
116 /* ifndef GNUNET_PROGRAM_LIB_H */
117 #endif
118
119 /** @} */  /* end of group program */
120
121 /* end of gnunet_program_lib.h */