-fix double free, linker issue
[oweals/gnunet.git] / src / include / gnunet_program_lib.h
1 /*
2      This file is part of GNUnet.
3      (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 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 2, 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., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file include/gnunet_program_lib.h
23  * @brief functions related to starting programs
24  * @author Christian Grothoff
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 (*GNUNET_PROGRAM_Main) (void *cls, char *const *args,
51                                      const char *cfgfile,
52                                      const struct GNUNET_CONFIGURATION_Handle *
53                                      cfg);
54
55
56 /**
57  * Run a standard GNUnet command startup sequence (initialize loggers
58  * and configuration, parse options).
59  *
60  * @param argc number of command line arguments
61  * @param argv command line arguments
62  * @param binaryName our expected name
63  * @param binaryHelp help text for the program
64  * @param options command line options
65  * @param task main function to run
66  * @param task_cls closure for task
67  * @param run_without_scheduler GNUNET_NO start the scheduler, GNUNET_YES do not
68  *        start the scheduler just run the main task
69  * @return GNUNET_SYSERR on error, GNUNET_OK on success
70  */
71 int
72 GNUNET_PROGRAM_run2 (int argc, char *const *argv, const char *binaryName,
73                     const char *binaryHelp,
74                     const struct GNUNET_GETOPT_CommandLineOption *options,
75                     GNUNET_PROGRAM_Main task, void *task_cls,
76                     int run_without_scheduler);
77
78 /**
79  * Run a standard GNUnet command startup sequence (initialize loggers
80  * and configuration, parse options).
81  *
82  * @param argc number of command line arguments
83  * @param argv command line arguments
84  * @param binaryName our expected name
85  * @param binaryHelp helptext for "-h" option (about the app)
86  * @param options command line options
87  * @param task main function to run
88  * @param task_cls closure for task
89  * @return GNUNET_SYSERR on error, GNUNET_OK on success
90  */
91 int
92 GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName,
93                     const char *binaryHelp,
94                     const struct GNUNET_GETOPT_CommandLineOption *options,
95                     GNUNET_PROGRAM_Main task, void *task_cls);
96
97
98
99 #if 0                           /* keep Emacsens' auto-indent happy */
100 {
101 #endif
102 #ifdef __cplusplus
103 }
104 #endif
105
106 /* ifndef GNUNET_PROGRAM_LIB_H */
107 #endif
108 /* end of gnunet_program_lib.h */