Line data Source code
1 : /* 2 : This file is part of TALER 3 : Copyright (C) 2014-2020 Taler Systems SA 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 : /** 18 : * @file taler-auditor-httpd_mhd.c 19 : * @brief helpers for MHD interaction; these are TALER_MHD_handler_ functions 20 : * that generate simple MHD replies that do not require any real operations 21 : * to be performed (error handling, static pages, etc.) 22 : * @author Florian Dold 23 : * @author Benedikt Mueller 24 : * @author Christian Grothoff 25 : */ 26 : #include "platform.h" 27 : #include <gnunet/gnunet_util_lib.h> 28 : #include <jansson.h> 29 : #include <microhttpd.h> 30 : #include <pthread.h> 31 : #include "taler_mhd_lib.h" 32 : #include "taler-auditor-httpd.h" 33 : #include "taler-auditor-httpd_mhd.h" 34 : 35 : /** 36 : * Function to call to handle the request by sending 37 : * back static data from the @a rh. 38 : * 39 : * @param rh context of the handler 40 : * @param connection the MHD connection to handle 41 : * @param[in,out] connection_cls the connection's closure (can be updated) 42 : * @param upload_data upload data 43 : * @param[in,out] upload_data_size number of bytes (left) in @a upload_data 44 : * @return MHD result code 45 : */ 46 : MHD_RESULT 47 0 : TAH_MHD_handler_static_response (struct TAH_RequestHandler *rh, 48 : struct MHD_Connection *connection, 49 : void **connection_cls, 50 : const char *upload_data, 51 : size_t *upload_data_size) 52 : { 53 : size_t dlen; 54 : 55 : (void) connection_cls; 56 : (void) upload_data; 57 : (void) upload_data_size; 58 0 : dlen = (0 == rh->data_size) 59 0 : ? strlen ((const char *) rh->data) 60 0 : : rh->data_size; 61 0 : return TALER_MHD_reply_static (connection, 62 : rh->response_code, 63 : rh->mime_type, 64 0 : rh->data, 65 : dlen); 66 : } 67 : 68 : 69 : /** 70 : * Function to call to handle the request by sending 71 : * back a redirect to the AGPL source code. 72 : * 73 : * @param rh context of the handler 74 : * @param connection the MHD connection to handle 75 : * @param[in,out] connection_cls the connection's closure (can be updated) 76 : * @param upload_data upload data 77 : * @param[in,out] upload_data_size number of bytes (left) in @a upload_data 78 : * @return MHD result code 79 : */ 80 : MHD_RESULT 81 0 : TAH_MHD_handler_agpl_redirect (struct TAH_RequestHandler *rh, 82 : struct MHD_Connection *connection, 83 : void **connection_cls, 84 : const char *upload_data, 85 : size_t *upload_data_size) 86 : { 87 : (void) rh; 88 : (void) connection_cls; 89 : (void) upload_data; 90 : (void) upload_data_size; 91 0 : return TALER_MHD_reply_agpl (connection, 92 : "http://www.git.taler.net/?p=exchange.git"); 93 : } 94 : 95 : 96 : /* end of taler-auditor-httpd_mhd.c */