mhd_dcc_action.h (4810B)
1 /* SPDX-License-Identifier: LGPL-2.1-or-later OR (GPL-2.0-or-later WITH eCos-exception-2.0) */ 2 /* 3 This file is part of GNU libmicrohttpd. 4 Copyright (C) 2024 Evgeny Grin (Karlson2k) 5 6 GNU libmicrohttpd is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) any later version. 10 11 GNU libmicrohttpd is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 Alternatively, you can redistribute GNU libmicrohttpd and/or 17 modify it under the terms of the GNU General Public License as 18 published by the Free Software Foundation; either version 2 of 19 the License, or (at your option) any later version, together 20 with the eCos exception, as follows: 21 22 As a special exception, if other files instantiate templates or 23 use macros or inline functions from this file, or you compile this 24 file and link it with other works to produce a work based on this 25 file, this file does not by itself cause the resulting work to be 26 covered by the GNU General Public License. However the source code 27 for this file must still be made available in accordance with 28 section (3) of the GNU General Public License v2. 29 30 This exception does not invalidate any other reasons why a work 31 based on this file might be covered by the GNU General Public 32 License. 33 34 You should have received copies of the GNU Lesser General Public 35 License and the GNU General Public License along with this library; 36 if not, see <https://www.gnu.org/licenses/>. 37 */ 38 39 /** 40 * @file src/mhd2/mhd_dcc_action.h 41 * @brief The definition of the MHD_Action and MHD_UploadAction structures 42 * @author Karlson2k (Evgeny Grin) 43 */ 44 45 #ifndef MHD_DCC_ACTION_H 46 #define MHD_DCC_ACTION_H 1 47 48 #include "mhd_sys_options.h" 49 50 #include "sys_base_types.h" 51 52 struct MHD_Connection; /* forward declaration */ 53 54 /** 55 * The context used for Dynamic Content Creator callback 56 */ 57 struct MHD_DynamicContentCreatorContext 58 { 59 struct MHD_Connection *connection; 60 }; 61 62 /** 63 * The type of the dynamic content creator action requested by application 64 */ 65 enum mhd_DccActionType 66 { 67 /** 68 * Action has not been set yet. 69 */ 70 mhd_DCC_ACTION_NO_ACTION = 0 71 , 72 /** 73 * Send new portion of data, provided by application 74 */ 75 mhd_DCC_ACTION_CONTINUE 76 , 77 /** 78 * Signal the end of the data stream. 79 */ 80 mhd_DCC_ACTION_FINISH 81 , 82 /** 83 * Suspend requests (connection) 84 */ 85 mhd_DCC_ACTION_SUSPEND 86 , 87 /** 88 * Hard close request with no or partial response 89 */ 90 mhd_DCC_ACTION_ABORT 91 }; 92 93 /** 94 * Check whether provided mhd_ActionType value is valid 95 */ 96 #define mhd_DCC_ACTION_IS_VALID(act) \ 97 ((mhd_DCC_ACTION_CONTINUE <= (act)) && (mhd_DCC_ACTION_ABORT >= (act))) 98 99 100 #ifndef MHD_FREECALLBACK_DEFINED 101 102 /** 103 * This method is called by libmicrohttpd when response with dynamic content 104 * is being destroyed. It should be used to free resources associated 105 * with the dynamic content. 106 * 107 * @param[in] free_cls closure 108 * @ingroup response 109 */ 110 typedef void 111 (*MHD_FreeCallback) (void *free_cls); 112 113 #define MHD_FREECALLBACK_DEFINED 1 114 #endif /* ! MHD_FREECALLBACK_DEFINED */ 115 #ifndef MHD_DYNCONTENTZCIOVEC_DEFINED 116 117 118 /** 119 * Structure for iov type of the response. 120 * Used for zero-copy response content data. 121 */ 122 struct MHD_DynContentZCIoVec 123 { 124 /** 125 * The number of elements in @a iov 126 */ 127 unsigned int iov_count; 128 /** 129 * The pointer to the array with @a iov_count elements. 130 */ 131 const struct MHD_IoVec *iov; 132 /** 133 * The callback to free resources. 134 * It is called once the full array of iov elements is sent. 135 * No callback is called if NULL. 136 */ 137 MHD_FreeCallback iov_fcb; 138 /** 139 * The parameter for @a iov_fcb 140 */ 141 void *iov_fcb_cls; 142 }; 143 144 #define MHD_DYNCONTENTZCIOVEC_DEFINED 1 145 #endif /* ! MHD_DYNCONTENTZCIOVEC_DEFINED */ 146 147 /** 148 * The data for DCC "continue" action 149 */ 150 struct mhd_DccActionContinueData 151 { 152 /** 153 * The size of the content data in the buffer 154 */ 155 size_t buf_data_size; 156 /** 157 * Zero-copy content data data 158 */ 159 const struct MHD_DynContentZCIoVec *iov_data; 160 }; 161 162 163 /** 164 * The data for the DCC application action 165 */ 166 union mhd_DccActionData 167 { 168 /** 169 * The data for the action #mhd_DCC_ACTION_CONTINUE 170 */ 171 struct mhd_DccActionContinueData cntnue; 172 }; 173 174 175 /** 176 * The action type returned by Dynamic Content Creator callback 177 */ 178 struct MHD_DynamicContentCreatorAction 179 { 180 /** 181 * The action 182 */ 183 enum mhd_DccActionType act; 184 185 /** 186 * The data for the @a act action 187 */ 188 union mhd_DccActionData data; 189 }; 190 191 #endif /* ! MHD_DCC_ACTION_H */