diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-06 09:49:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-06 09:49:55 +0000 |
commit | e44303b164ebb3640288c0054bbee9829baeff25 (patch) | |
tree | d9d761c540eff4274617a873fcceed2f25560868 /src | |
download | gnunet-ext-e44303b164ebb3640288c0054bbee9829baeff25.tar.gz gnunet-ext-e44303b164ebb3640288c0054bbee9829baeff25.zip |
ext
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/ext/Makefile.am | 47 | ||||
-rw-r--r-- | src/ext/ext_api.c | 32 | ||||
-rw-r--r-- | src/ext/gnunet-ext.c | 71 | ||||
-rw-r--r-- | src/ext/gnunet-service-ext.c | 126 | ||||
-rw-r--r-- | src/ext/test_ext_api.c | 75 | ||||
-rw-r--r-- | src/include/Makefile.am | 7 | ||||
-rw-r--r-- | src/include/gnunet_ext_service.h | 50 | ||||
-rw-r--r-- | src/include/gnunet_protocols_ext.h | 56 |
9 files changed, 466 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..a53c604 --- /dev/null +++ b/src/Makefile.am | |||
@@ -0,0 +1,2 @@ | |||
1 | SUBDIRS = include ext . | ||
2 | |||
diff --git a/src/ext/Makefile.am b/src/ext/Makefile.am new file mode 100644 index 0000000..fdcca0b --- /dev/null +++ b/src/ext/Makefile.am | |||
@@ -0,0 +1,47 @@ | |||
1 | SUBDIRS = . | ||
2 | |||
3 | INCLUDES = \ | ||
4 | -I$(top_srcdir)/src/include \ | ||
5 | -I$(top_srcdir) | ||
6 | |||
7 | lib_LTLIBRARIES = libgnunetext.la | ||
8 | |||
9 | libgnunetext_la_SOURCES = \ | ||
10 | ext_api.c | ||
11 | libgnunetext_la_LIBADD = \ | ||
12 | -lgnunetutil | ||
13 | libgnunetext_la_LDFLAGS = \ | ||
14 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ | ||
15 | -version-info 0:0:0 | ||
16 | |||
17 | |||
18 | bin_PROGRAMS = gnunet-service-ext gnunet-ext | ||
19 | |||
20 | gnunet_service_ext_SOURCES = \ | ||
21 | gnunet-service-ext.c | ||
22 | gnunet_service_ext_LDADD = \ | ||
23 | -lgnunetutil -lgnunetcore\ | ||
24 | $(INTLLIBS) | ||
25 | gnunet_service_ext_LDFLAGS = \ | ||
26 | -export-dynamic | ||
27 | |||
28 | gnunet_ext_SOURCES = \ | ||
29 | gnunet-ext.c | ||
30 | gnunet_ext_LDADD = \ | ||
31 | -lgnunetutil \ | ||
32 | $(INTLLIBS) | ||
33 | gnunet_ext_LDFLAGS = \ | ||
34 | -export-dynamic | ||
35 | |||
36 | |||
37 | check_PROGRAMS = \ | ||
38 | test_ext_api | ||
39 | |||
40 | TESTS = $(check_PROGRAMS) | ||
41 | |||
42 | test_ext_api_SOURCES = \ | ||
43 | test_ext_api.c | ||
44 | test_ext_api_LDADD = \ | ||
45 | $(top_builddir)/src/ext/libgnunetext.la \ | ||
46 | -lgnunetutil | ||
47 | |||
diff --git a/src/ext/ext_api.c b/src/ext/ext_api.c new file mode 100644 index 0000000..ea9c97f --- /dev/null +++ b/src/ext/ext_api.c | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) | ||
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 ext/ext_api.c | ||
23 | * @brief API for ext | ||
24 | * @author | ||
25 | */ | ||
26 | #include <gnunet/platform.h> | ||
27 | #include <gnunet/gnunet_util_lib.h> | ||
28 | #include "gnunet_ext_service.h" | ||
29 | |||
30 | |||
31 | |||
32 | /* end of ext_api.c */ | ||
diff --git a/src/ext/gnunet-ext.c b/src/ext/gnunet-ext.c new file mode 100644 index 0000000..4cf0188 --- /dev/null +++ b/src/ext/gnunet-ext.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) | ||
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., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file ext/gnunet-ext.c | ||
23 | * @brief ext tool | ||
24 | * @author | ||
25 | */ | ||
26 | #include <gnunet/platform.h> | ||
27 | #include <gnunet/gnunet_util_lib.h> | ||
28 | #include "gnunet_ext_service.h" | ||
29 | |||
30 | static int ret; | ||
31 | |||
32 | /** | ||
33 | * Main function that will be run by the scheduler. | ||
34 | * | ||
35 | * @param cls closure | ||
36 | * @param args remaining command-line arguments | ||
37 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
38 | * @param cfg configuration | ||
39 | */ | ||
40 | static void | ||
41 | run (void *cls, | ||
42 | char *const *args, | ||
43 | const char *cfgfile, | ||
44 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
45 | { | ||
46 | ret = 0; | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * The main function to ext. | ||
51 | * | ||
52 | * @param argc number of arguments from the command line | ||
53 | * @param argv command line arguments | ||
54 | * @return 0 ok, 1 on error | ||
55 | */ | ||
56 | int | ||
57 | main (int argc, char *const *argv) | ||
58 | { | ||
59 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
60 | GNUNET_GETOPT_OPTION_END | ||
61 | }; | ||
62 | return (GNUNET_OK == | ||
63 | GNUNET_PROGRAM_run (argc, | ||
64 | argv, | ||
65 | "gnunet-ext [options [value]]", | ||
66 | gettext_noop | ||
67 | ("ext"), | ||
68 | options, &run, NULL)) ? ret : 1; | ||
69 | } | ||
70 | |||
71 | /* end of gnunet-ext.c */ | ||
diff --git a/src/ext/gnunet-service-ext.c b/src/ext/gnunet-service-ext.c new file mode 100644 index 0000000..733b99b --- /dev/null +++ b/src/ext/gnunet-service-ext.c | |||
@@ -0,0 +1,126 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) | ||
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., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file ext/gnunet-service-ext.c | ||
23 | * @brief ext service implementation | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include <gnunet/platform.h> | ||
27 | #include <gnunet/gnunet_util_lib.h> | ||
28 | #include "gnunet_protocols_ext.h" | ||
29 | |||
30 | /** | ||
31 | * Our configuration. | ||
32 | */ | ||
33 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
34 | |||
35 | /** | ||
36 | * Handle EXT-message. | ||
37 | * | ||
38 | * @param cls closure | ||
39 | * @param client identification of the client | ||
40 | * @param message the actual message | ||
41 | * @return GNUNET_OK to keep the connection open, | ||
42 | * GNUNET_SYSERR to close it (signal serious error) | ||
43 | */ | ||
44 | static void | ||
45 | handle_ext (void *cls, | ||
46 | struct GNUNET_SERVER_Client *client, | ||
47 | const struct GNUNET_MessageHeader *message) | ||
48 | { | ||
49 | GNUNET_SERVER_receive_done (client, | ||
50 | GNUNET_OK); | ||
51 | } | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Task run during shutdown. | ||
56 | * | ||
57 | * @param cls unused | ||
58 | * @param tc unused | ||
59 | */ | ||
60 | static void | ||
61 | shutdown_task (void *cls, | ||
62 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
63 | { | ||
64 | } | ||
65 | |||
66 | |||
67 | /** | ||
68 | * A client disconnected. Remove all of its data structure entries. | ||
69 | * | ||
70 | * @param cls closure, NULL | ||
71 | * @param client identification of the client | ||
72 | */ | ||
73 | static void | ||
74 | handle_client_disconnect (void *cls, | ||
75 | struct GNUNET_SERVER_Client | ||
76 | * client) | ||
77 | { | ||
78 | } | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Process statistics requests. | ||
83 | * | ||
84 | * @param cls closure | ||
85 | * @param server the initialized server | ||
86 | * @param c configuration to use | ||
87 | */ | ||
88 | static void | ||
89 | run (void *cls, | ||
90 | struct GNUNET_SERVER_Handle *server, | ||
91 | const struct GNUNET_CONFIGURATION_Handle *c) | ||
92 | { | ||
93 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | ||
94 | {&handle_ext, NULL, GNUNET_MESSAGE_TYPE_EXT, 0}, | ||
95 | {NULL, NULL, 0, 0} | ||
96 | }; | ||
97 | cfg = c; | ||
98 | GNUNET_SERVER_add_handlers (server, handlers); | ||
99 | GNUNET_SERVER_disconnect_notify (server, | ||
100 | &handle_client_disconnect, | ||
101 | NULL); | ||
102 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
103 | &shutdown_task, | ||
104 | NULL); | ||
105 | } | ||
106 | |||
107 | |||
108 | /** | ||
109 | * The main function for the ext service. | ||
110 | * | ||
111 | * @param argc number of arguments from the command line | ||
112 | * @param argv command line arguments | ||
113 | * @return 0 ok, 1 on error | ||
114 | */ | ||
115 | int | ||
116 | main (int argc, char *const *argv) | ||
117 | { | ||
118 | return (GNUNET_OK == | ||
119 | GNUNET_SERVICE_run (argc, | ||
120 | argv, | ||
121 | "ext", | ||
122 | GNUNET_SERVICE_OPTION_NONE, | ||
123 | &run, NULL)) ? 0 : 1; | ||
124 | } | ||
125 | |||
126 | /* end of gnunet-service-ext.c */ | ||
diff --git a/src/ext/test_ext_api.c b/src/ext/test_ext_api.c new file mode 100644 index 0000000..70f137a --- /dev/null +++ b/src/ext/test_ext_api.c | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) | ||
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., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file ext/test_ext_api.c | ||
22 | * @brief testcase for ext_api.c | ||
23 | */ | ||
24 | #include <gnunet/platform.h> | ||
25 | #include <gnunet/gnunet_util_lib.h> | ||
26 | #include "gnunet_ext_service.h" | ||
27 | |||
28 | |||
29 | static void | ||
30 | run (void *cls, | ||
31 | char *const *args, | ||
32 | const char *cfgfile, | ||
33 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
34 | { | ||
35 | } | ||
36 | |||
37 | |||
38 | static int | ||
39 | check () | ||
40 | { | ||
41 | int ok = 1; | ||
42 | char *const argv[] = { "test-ext-api", NULL }; | ||
43 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
44 | GNUNET_GETOPT_OPTION_END | ||
45 | }; | ||
46 | struct GNUNET_OS_Process *proc; | ||
47 | |||
48 | proc = GNUNET_OS_start_process (NULL, NULL, | ||
49 | "gnunet-service-ext", | ||
50 | "gnunet-service-ext", | ||
51 | NULL); | ||
52 | GNUNET_assert (NULL != proc); | ||
53 | GNUNET_PROGRAM_run (1, argv, "test-ext-api", "nohelp", | ||
54 | options, &run, &ok); | ||
55 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | ||
56 | { | ||
57 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
58 | ok = 1; | ||
59 | } | ||
60 | GNUNET_OS_process_wait (proc); | ||
61 | GNUNET_OS_process_close (proc); | ||
62 | return ok; | ||
63 | } | ||
64 | |||
65 | |||
66 | int | ||
67 | main (int argc, char *argv[]) | ||
68 | { | ||
69 | GNUNET_log_setup ("test_statistics_api", | ||
70 | "WARNING", | ||
71 | NULL); | ||
72 | return check (); | ||
73 | } | ||
74 | |||
75 | /* end of test_ext_api.c */ | ||
diff --git a/src/include/Makefile.am b/src/include/Makefile.am new file mode 100644 index 0000000..784e039 --- /dev/null +++ b/src/include/Makefile.am | |||
@@ -0,0 +1,7 @@ | |||
1 | SUBDIRS = . | ||
2 | |||
3 | gnunetincludedir = $(includedir)/gnunet | ||
4 | |||
5 | gnunetinclude_HEADERS = \ | ||
6 | gnunet_ext_service.h \ | ||
7 | gnunet_protocols_ext.h | ||
diff --git a/src/include/gnunet_ext_service.h b/src/include/gnunet_ext_service.h new file mode 100644 index 0000000..c573608 --- /dev/null +++ b/src/include/gnunet_ext_service.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) | ||
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_ext_service.h | ||
23 | * @brief API to the ext service | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_EXT_SERVICE_H | ||
27 | #define GNUNET_EXT_SERVICE_H | ||
28 | |||
29 | #ifdef __cplusplus | ||
30 | extern "C" | ||
31 | { | ||
32 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
33 | } | ||
34 | #endif | ||
35 | #endif | ||
36 | |||
37 | /** | ||
38 | * Version of the ext API. | ||
39 | */ | ||
40 | #define GNUNET_EXT_VERSION 0x00000000 | ||
41 | |||
42 | |||
43 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
44 | { | ||
45 | #endif | ||
46 | #ifdef __cplusplus | ||
47 | } | ||
48 | #endif | ||
49 | |||
50 | #endif | ||
diff --git a/src/include/gnunet_protocols_ext.h b/src/include/gnunet_protocols_ext.h new file mode 100644 index 0000000..1dbe2d4 --- /dev/null +++ b/src/include/gnunet_protocols_ext.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) | ||
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_protocols_ext.h | ||
23 | * @brief constants for network protocols | ||
24 | * @author | ||
25 | */ | ||
26 | |||
27 | #ifndef GNUNET_PROTOCOLS_EXT_H | ||
28 | #define GNUNET_PROTOCOLS_EXT_H | ||
29 | |||
30 | #ifdef __cplusplus | ||
31 | extern "C" | ||
32 | { | ||
33 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
34 | } | ||
35 | #endif | ||
36 | #endif | ||
37 | |||
38 | |||
39 | |||
40 | /** | ||
41 | * EXT message | ||
42 | */ | ||
43 | #define GNUNET_MESSAGE_TYPE_EXT 32000 | ||
44 | |||
45 | |||
46 | |||
47 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
48 | { | ||
49 | #endif | ||
50 | #ifdef __cplusplus | ||
51 | } | ||
52 | #endif | ||
53 | |||
54 | /* ifndef GNUNET_PROTOCOLS_H */ | ||
55 | #endif | ||
56 | /* end of gnunet_protocols.h */ | ||