1 /* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 23 #ifndef XCOM_INPUT_REQUEST_H 24 #define XCOM_INPUT_REQUEST_H 25 26 #include "xcom/pax_msg.h" 27 28 /** 29 * A request directed to XCom through the input channel. 30 */ 31 struct xcom_input_request; 32 typedef struct xcom_input_request *xcom_input_request_ptr; 33 34 /** 35 * The function type that XCom will use to reply to a request. 36 */ 37 typedef void (*xcom_input_reply_function_ptr)(void *reply_arg, 38 pax_msg *payload); 39 40 /** 41 * Creates a new XCom request. 42 * 43 * Takes ownership of @c a. 44 * 45 * @param a the request's app_data payload 46 * @param reply_function the function used to reply to the request 47 * @param reply_arg opaque argument to the reply_function 48 * @retval xcom_input_request_ptr if successful 49 * @retval NULL if unsuccessful 50 */ 51 xcom_input_request_ptr xcom_input_request_new( 52 app_data_ptr a, xcom_input_reply_function_ptr reply_function, 53 void *reply_arg); 54 55 /** 56 * Frees the given request and its payload. 57 * 58 * @param request the request to free 59 */ 60 void xcom_input_request_free(xcom_input_request_ptr request); 61 62 /** 63 * Links @c request to the list of requests @c next. 64 * 65 * @param request the request to link 66 * @param next the list to be linked to 67 */ 68 void xcom_input_request_set_next(xcom_input_request_ptr request, 69 xcom_input_request_ptr next); 70 71 /** 72 * Unlinks @c request from its list. 73 * 74 * @param request the request to unlink 75 * @returns the tail of the list the request was unlinked from 76 */ 77 xcom_input_request_ptr xcom_input_request_extract_next( 78 xcom_input_request_ptr request); 79 80 /** 81 * Extract the given request's payload. 82 * 83 * Transfers ownership of the result to the caller. 84 * 85 * @param request the request from which to extract the payload 86 * @returns the request's app_data payload 87 */ 88 app_data_ptr xcom_input_request_extract_app_data( 89 xcom_input_request_ptr request); 90 91 /** 92 * Replies to the request using the strategy chosen by the request's origin. 93 * 94 * @param request the request to reply to 95 * @param payload the payload of the reply 96 */ 97 void xcom_input_request_reply(xcom_input_request_ptr request, pax_msg *payload); 98 99 #endif /* XCOM_INPUT_REQUEST_H */ 100