LCOV - code coverage report
Current view: top level - sync - sync-httpd_mhd.c (source / functions) Hit Total Coverage
Test: GNU Taler sync coverage report Lines: 5 7 71.4 %
Date: 2021-05-09 06:21:04 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify it under the
       6             :   terms of the GNU Affero General Public License as published by the Free Software
       7             :   Foundation; either version 3, or (at your option) any later version.
       8             : 
       9             :   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10             :   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11             :   A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
      12             : 
      13             :   You should have received a copy of the GNU Affero General Public License along with
      14             :   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15             : */
      16             : /**
      17             :  * @file sync-httpd_mhd.c
      18             :  * @brief helpers for MHD interaction; these are TALER_EXCHANGE_handler_ functions
      19             :  *        that generate simple MHD replies that do not require any real operations
      20             :  *        to be performed (error handling, static pages, etc.)
      21             :  * @author Florian Dold
      22             :  * @author Benedikt Mueller
      23             :  * @author Christian Grothoff
      24             :  */
      25             : #include "platform.h"
      26             : #include <jansson.h>
      27             : #include "sync-httpd_mhd.h"
      28             : 
      29             : 
      30             : /**
      31             :  * Function to call to handle the request by sending
      32             :  * back static data from the @a rh.
      33             :  *
      34             :  * @param rh context of the handler
      35             :  * @param connection the MHD connection to handle
      36             :  * @param[in,out] connection_cls the connection's closure (can be updated)
      37             :  * @param upload_data upload data
      38             :  * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
      39             :  * @return MHD result code
      40             :  */
      41             : MHD_RESULT
      42           1 : SH_MHD_handler_static_response (struct SH_RequestHandler *rh,
      43             :                                 struct MHD_Connection *connection,
      44             :                                 void **connection_cls,
      45             :                                 const char *upload_data,
      46             :                                 size_t *upload_data_size)
      47             : {
      48             :   (void) connection_cls;
      49             :   (void) upload_data;
      50             :   (void) upload_data_size;
      51           1 :   if (0 == rh->data_size)
      52           1 :     rh->data_size = strlen ((const char *) rh->data);
      53           2 :   return TALER_MHD_reply_static (connection,
      54             :                                  rh->response_code,
      55             :                                  rh->mime_type,
      56           1 :                                  (void *) rh->data,
      57             :                                  rh->data_size);
      58             : }
      59             : 
      60             : 
      61             : /**
      62             :  * Function to call to handle the request by sending
      63             :  * back a redirect to the AGPL source code.
      64             :  *
      65             :  * @param rh context of the handler
      66             :  * @param connection the MHD connection to handle
      67             :  * @param[in,out] connection_cls the connection's closure (can be updated)
      68             :  * @param upload_data upload data
      69             :  * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
      70             :  * @return MHD result code
      71             :  */
      72             : MHD_RESULT
      73           0 : SH_MHD_handler_agpl_redirect (struct SH_RequestHandler *rh,
      74             :                               struct MHD_Connection *connection,
      75             :                               void **connection_cls,
      76             :                               const char *upload_data,
      77             :                               size_t *upload_data_size)
      78             : {
      79             :   (void) rh;
      80             :   (void) connection_cls;
      81             :   (void) upload_data;
      82             :   (void) upload_data_size;
      83           0 :   return TALER_MHD_reply_agpl (connection,
      84             :                                "http://www.git.taler.net/sync.git");
      85             : }
      86             : 
      87             : 
      88             : /* end of sync-httpd_mhd.c */

Generated by: LCOV version 1.14