aboutsummaryrefslogtreecommitdiff
path: root/src/template
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-05-29 00:46:26 +0000
committerChristian Grothoff <christian@grothoff.org>2009-05-29 00:46:26 +0000
commit0a217a8df1657b4334b55b0e4a6c7837a8dbcfd9 (patch)
tree6b552f40eb089db96409a312a98d9b12bd669102 /src/template
downloadgnunet-0a217a8df1657b4334b55b0e4a6c7837a8dbcfd9.tar.gz
gnunet-0a217a8df1657b4334b55b0e4a6c7837a8dbcfd9.zip
ng
Diffstat (limited to 'src/template')
-rw-r--r--src/template/Makefile.am37
-rw-r--r--src/template/gnunet-service-template.c87
-rw-r--r--src/template/gnunet-template.c81
-rw-r--r--src/template/test_template_api.c45
4 files changed, 250 insertions, 0 deletions
diff --git a/src/template/Makefile.am b/src/template/Makefile.am
new file mode 100644
index 000000000..47d6b4165
--- /dev/null
+++ b/src/template/Makefile.am
@@ -0,0 +1,37 @@
1INCLUDES = -I$(top_srcdir)/src/include
2
3if MINGW
4 WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
5endif
6
7if USE_COVERAGE
8 AM_CFLAGS = -fprofile-arcs -ftest-coverage
9endif
10
11bin_PROGRAMS = \
12 gnunet-template \
13 gnunet-service-template
14
15gnunet_template_SOURCES = \
16 gnunet-template.c
17gnunet_template_LDADD = \
18 $(top_builddir)/src/util/libgnunetutil.la \
19 $(GN_LIBINTL)
20
21gnunet_service_template_SOURCES = \
22 gnunet-service-template.c
23gnunet_service_template_LDADD = \
24 $(top_builddir)/src/util/libgnunetutil.la \
25 $(GN_LIBINTL)
26
27
28check_PROGRAMS = \
29 test_template_api
30
31TESTS = $(check_PROGRAMS)
32
33test_template_api_SOURCES = \
34 test_template_api.c
35test_template_api_LDADD = \
36 $(top_builddir)/src/util/libgnunetutil.la
37
diff --git a/src/template/gnunet-service-template.c b/src/template/gnunet-service-template.c
new file mode 100644
index 000000000..c43d681d7
--- /dev/null
+++ b/src/template/gnunet-service-template.c
@@ -0,0 +1,87 @@
1/*
2 This file is part of GNUnet.
3 (C) 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 template/gnunet-service-template.c
23 * @brief program that tracks template
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_getopt_lib.h"
28#include "gnunet_service_lib.h"
29
30/**
31 * Do cleanup here.
32 *
33 * @param cls closure
34 * @param cfg configuration to use
35 */
36static void
37finish (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg)
38{
39 /* FIXME */
40}
41
42
43/**
44 * List of handlers for the messages understood by this
45 * service.
46 */
47static struct GNUNET_SERVER_MessageHandler handlers[] = {
48 /* FIXME: add handlers here! */
49 {NULL, NULL, 0, 0}
50};
51
52/**
53 * Process template requests.
54 *
55 * @param cls closure
56 * @param sched scheduler to use
57 * @param server the initialized server
58 * @param cfg configuration to use
59 */
60static void
61run (void *cls,
62 struct GNUNET_SCHEDULER_Handle *sched,
63 struct GNUNET_SERVER_Handle *server,
64 struct GNUNET_CONFIGURATION_Handle *cfg)
65{
66 /* FIXME: do setup here */
67 GNUNET_SERVER_add_handlers (server, handlers);
68}
69
70
71/**
72 * The main function for the template service.
73 *
74 * @param argc number of arguments from the command line
75 * @param argv command line arguments
76 * @return 0 ok, 1 on error
77 */
78int
79main (int argc, char *const *argv)
80{
81 return (GNUNET_OK ==
82 GNUNET_SERVICE_run (argc,
83 argv,
84 "template", &run, NULL, &finish, NULL)) ? 0 : 1;
85}
86
87/* end of gnunet-service-template.c */
diff --git a/src/template/gnunet-template.c b/src/template/gnunet-template.c
new file mode 100644
index 000000000..ea47c7f45
--- /dev/null
+++ b/src/template/gnunet-template.c
@@ -0,0 +1,81 @@
1/*
2 This file is part of GNUnet.
3 (C) 2001, 2002, 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 template/gnunet-template.c
23 * @brief template for writing a tool
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_getopt_lib.h"
28#include "gnunet_program_lib.h"
29/* #include "gnunet_template_service.h" */
30
31/**
32 * Final status code.
33 */
34static int ret;
35
36/**
37 * Main function that will be run by the scheduler.
38 *
39 * @param cls closure
40 * @param sched the scheduler to use
41 * @param args remaining command-line arguments
42 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
43 * @param cfg configuration
44 */
45static void
46run (void *cls,
47 struct GNUNET_SCHEDULER_Handle *sched,
48 char *const *args,
49 const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg)
50{
51 /* main code here */
52}
53
54/**
55 * gnunet-template command line options
56 */
57static struct GNUNET_GETOPT_CommandLineOption options[] = {
58 /* FIMXE: add options here */
59 GNUNET_GETOPT_OPTION_END
60};
61
62
63/**
64 * The main function to obtain template from gnunetd.
65 *
66 * @param argc number of arguments from the command line
67 * @param argv command line arguments
68 * @return 0 ok, 1 on error
69 */
70int
71main (int argc, char *const *argv)
72{
73 return (GNUNET_OK ==
74 GNUNET_PROGRAM_run (argc,
75 argv,
76 "gnunet-template",
77 gettext_noop ("help text"),
78 options, &run, NULL)) ? ret : 1;
79}
80
81/* end of gnunet-template.c */
diff --git a/src/template/test_template_api.c b/src/template/test_template_api.c
new file mode 100644
index 000000000..8d53a15da
--- /dev/null
+++ b/src/template/test_template_api.c
@@ -0,0 +1,45 @@
1/*
2 This file is part of GNUnet.
3 (C) 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 * @file template/test_template.c
22 * @brief testcase for template.c
23 */
24#include "platform.h"
25#include "gnunet_common.h"
26
27#define VERBOSE GNUNET_NO
28
29static int
30check ()
31{
32 return 0;
33}
34
35int
36main (int argc, char *argv[])
37{
38 int ret;
39
40 ret = check ();
41
42 return ret;
43}
44
45/* end of test_template.c */