aboutsummaryrefslogtreecommitdiff
path: root/src/util/service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/service.c')
-rw-r--r--src/util/service.c58
1 files changed, 44 insertions, 14 deletions
diff --git a/src/util/service.c b/src/util/service.c
index 1156093f4..20cc1036d 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V. 3 Copyright (C) 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
@@ -1572,6 +1570,36 @@ teardown_service (struct GNUNET_SERVICE_Handle *sh)
1572 1570
1573 1571
1574/** 1572/**
1573 * Function to return link to AGPL source upon request.
1574 *
1575 * @param cls closure with the identification of the client
1576 * @param msg AGPL request
1577 */
1578static void
1579return_agpl (void *cls,
1580 const struct GNUNET_MessageHeader *msg)
1581{
1582 struct GNUNET_SERVICE_Client *client = cls;
1583 struct GNUNET_MQ_Handle *mq;
1584 struct GNUNET_MQ_Envelope *env;
1585 struct GNUNET_MessageHeader *res;
1586 size_t slen;
1587
1588 slen = strlen (GNUNET_AGPL_URL) + 1;
1589 env = GNUNET_MQ_msg_extra (res,
1590 GNUNET_MESSAGE_TYPE_RESPONSE_AGPL,
1591 slen);
1592 memcpy (&res[1],
1593 GNUNET_AGPL_URL,
1594 slen);
1595 mq = GNUNET_SERVICE_client_get_mq (client);
1596 GNUNET_MQ_send (mq,
1597 env);
1598 GNUNET_SERVICE_client_continue (client);
1599}
1600
1601
1602/**
1575 * Low-level function to start a service if the scheduler 1603 * Low-level function to start a service if the scheduler
1576 * is already running. Should only be used directly in 1604 * is already running. Should only be used directly in
1577 * special cases. 1605 * special cases.
@@ -1623,7 +1651,9 @@ GNUNET_SERVICE_start (const char *service_name,
1623 sh->connect_cb = connect_cb; 1651 sh->connect_cb = connect_cb;
1624 sh->disconnect_cb = disconnect_cb; 1652 sh->disconnect_cb = disconnect_cb;
1625 sh->cb_cls = cls; 1653 sh->cb_cls = cls;
1626 sh->handlers = GNUNET_MQ_copy_handlers (handlers); 1654 sh->handlers = GNUNET_MQ_copy_handlers2 (handlers,
1655 &return_agpl,
1656 NULL);
1627 if (GNUNET_OK != setup_service (sh)) 1657 if (GNUNET_OK != setup_service (sh))
1628 { 1658 {
1629 GNUNET_free_non_null (sh->handlers); 1659 GNUNET_free_non_null (sh->handlers);
@@ -1723,9 +1753,9 @@ GNUNET_SERVICE_run_ (int argc,
1723 struct GNUNET_GETOPT_CommandLineOption service_options[] = { 1753 struct GNUNET_GETOPT_CommandLineOption service_options[] = {
1724 GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename), 1754 GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename),
1725 GNUNET_GETOPT_option_flag ('d', 1755 GNUNET_GETOPT_option_flag ('d',
1726 "daemonize", 1756 "daemonize",
1727 gettext_noop ("do daemonize (detach from terminal)"), 1757 gettext_noop ("do daemonize (detach from terminal)"),
1728 &do_daemonize), 1758 &do_daemonize),
1729 GNUNET_GETOPT_option_help (NULL), 1759 GNUNET_GETOPT_option_help (NULL),
1730 GNUNET_GETOPT_option_loglevel (&loglev), 1760 GNUNET_GETOPT_option_loglevel (&loglev),
1731 GNUNET_GETOPT_option_logfile (&logfile), 1761 GNUNET_GETOPT_option_logfile (&logfile),