d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina Pavel Březina <pbrezina@redhat.com>
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina Copyright (C) 2016 Red Hat
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina This program is free software; you can redistribute it and/or modify
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina it under the terms of the GNU General Public License as published by
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina the Free Software Foundation; either version 3 of the License, or
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina (at your option) any later version.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina This program is distributed in the hope that it will be useful,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina GNU General Public License for more details.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina You should have received a copy of the GNU General Public License
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#include "providers/data_provider/dp_request.h"
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#include "providers/data_provider/dp_custom_data.h"
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Module constructor.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * It is possible to create a module data that is passed into all
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * target initialization functions.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinatypedef errno_t (*dp_module_init_fn)(TALLOC_CTX *mem_ctx,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Target initialization function.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Pointer to dp_method is unique for all targets. Make sure that
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * dp_set_method is called in all targets even if you are reusing
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * some existing context or initialization function.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinatypedef errno_t (*dp_target_init_fn)(TALLOC_CTX *mem_ctx,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* Method handler. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinatypedef struct tevent_req *
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina(*dp_req_send_fn)(TALLOC_CTX *mem_ctx, void *method_data, void *request_data,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina(*dp_req_recv_fn)(TALLOC_CTX *mem_ctx, struct tevent_req *req, void *data);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* Data provider initialization. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinabool _dp_target_enabled(struct data_provider *provider,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#define dp_target_enabled(provider, module_name, ...) \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina _dp_target_enabled(provider, module_name, ##__VA_ARGS__, DP_TARGET_SENTINEL)
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinastruct dp_module *dp_target_module(struct data_provider *provider,
35fa5a83ce8badf6bc868937047f44c3f32b7c28Sumit Bosevoid *dp_get_module_data(struct dp_module *dp_module);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* We check function headers on compile time and data types on run time. This
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * check requires that both method and request private data are talloc-created
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * with talloc name set to data type name (which is done by talloc unless
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * you use _size variations of talloc functions.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * This way we ensure that we always pass correct data and we can access them
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * directly in request handler without the need to cast them explicitly
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * from void pointer. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#define dp_set_method(methods, method, send_fn, recv_fn, method_data, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Check _send function parameter types. */ \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina struct tevent_req *(*__send_fn)(TALLOC_CTX *, method_dtype *, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina req_dtype *, struct dp_req_params *params) = (send_fn); \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Check _recv function parameter types. */ \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina errno_t (*__recv_fn)(TALLOC_CTX *, struct tevent_req *, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina _dp_set_method(methods, method, (dp_req_send_fn)__send_fn, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinabool dp_method_enabled(struct data_provider *provider,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinavoid dp_terminate_domain_requests(struct data_provider *provider,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *domain);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#endif /* _DP_H_ */