glitch in the license text detected by hyazinthe, thank you!
[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 it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14 */
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
27 #ifndef GNUNET_PROGRAM_LIB_H
28 #define GNUNET_PROGRAM_LIB_H
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #if 0                           /* keep Emacsens' auto-indent happy */
34 }
35 #endif
36 #endif
37
38 #include "gnunet_configuration_lib.h"
39 #include "gnunet_getopt_lib.h"
40 #include "gnunet_scheduler_lib.h"
41
42 /**
43  * Main function that will be run.
44  *
45  * @param cls closure
46  * @param args remaining command-line arguments
47  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
48  * @param cfg configuration
49  */
50 typedef void
51 (*GNUNET_PROGRAM_Main) (void *cls,
52                         char *const *args,
53                         const char *cfgfile,
54                         const struct GNUNET_CONFIGURATION_Handle *cfg);
55
56
57 /**
58  * Run a standard GNUnet command startup sequence (initialize loggers
59  * and configuration, parse options).
60  *
61  * @param argc number of command line arguments in @a argv
62  * @param argv command line arguments
63  * @param binaryName our expected name
64  * @param binaryHelp help text for the program
65  * @param options command line options
66  * @param task main function to run
67  * @param task_cls closure for @a task
68  * @param run_without_scheduler #GNUNET_NO start the scheduler,
69  *        #GNUNET_YES do not start the scheduler just run the main task
70  * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
71  */
72 int
73 GNUNET_PROGRAM_run2 (int argc,
74                      char *const *argv,
75                      const char *binaryName,
76                      const char *binaryHelp,
77                      const struct GNUNET_GETOPT_CommandLineOption *options,
78                      GNUNET_PROGRAM_Main task,
79                      void *task_cls,
80                      int run_without_scheduler);
81
82
83 /**
84  * Run a standard GNUnet command startup sequence (initialize loggers
85  * and configuration, parse options).
86  *
87  * @param argc number of command line arguments
88  * @param argv command line arguments
89  * @param binaryName our expected name
90  * @param binaryHelp helptext for "-h" option (about the app)
91  * @param options command line options
92  * @param task main function to run
93  * @param task_cls closure for @a task
94  * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
95  */
96 int
97 GNUNET_PROGRAM_run (int argc,
98                     char *const *argv,
99                     const char *binaryName,
100                     const char *binaryHelp,
101                     const struct GNUNET_GETOPT_CommandLineOption *options,
102                     GNUNET_PROGRAM_Main task,
103                     void *task_cls);
104
105
106 #if 0                           /* keep Emacsens' auto-indent happy */
107 {
108 #endif
109 #ifdef __cplusplus
110 }
111 #endif
112
113 /* ifndef GNUNET_PROGRAM_LIB_H */
114 #endif
115
116 /** @} */  /* end of group program */
117
118 /* end of gnunet_program_lib.h */