summaryrefslogtreecommitdiffstats
path: root/common/elapi/elapi_async.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-09-17 00:01:09 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-10-05 10:32:08 -0400
commit8140cea7b4e3d3c9c6003eb6ae30e5e0fdd7c1ae (patch)
tree3f6ec4cf35410fa2c19c2dc448d311d4bd0ef4b3 /common/elapi/elapi_async.c
parentea7d823fa584b36e9a34a43c32dc476beede5ea2 (diff)
downloadsssd_unused-8140cea7b4e3d3c9c6003eb6ae30e5e0fdd7c1ae.tar.gz
sssd_unused-8140cea7b4e3d3c9c6003eb6ae30e5e0fdd7c1ae.tar.xz
sssd_unused-8140cea7b4e3d3c9c6003eb6ae30e5e0fdd7c1ae.zip
ELAPI Event resolver
Started working on the async processing and realised that I need to have a good copy of the event with all the fields resolved so this patch has some foundation for the async functions (module elapi_async.c) but they are mostly stubbed out. The actual code will be added down the road. Instead the patch focuses on the code introduced in elapi_resolve.c module and the use of the functions from it. It also adds the implementation of the high level calls that initialize ELAPI with the external callbacks to be used during async processing (elapi_log.c).
Diffstat (limited to 'common/elapi/elapi_async.c')
-rw-r--r--common/elapi/elapi_async.c153
1 files changed, 153 insertions, 0 deletions
diff --git a/common/elapi/elapi_async.c b/common/elapi/elapi_async.c
new file mode 100644
index 00000000..0c404c04
--- /dev/null
+++ b/common/elapi/elapi_async.c
@@ -0,0 +1,153 @@
+/*
+ ELAPI
+
+ Implementation for the ELAPI async processing interface.
+
+ Copyright (C) Dmitri Pal <dpal@redhat.com> 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#define _GNU_SOURCE
+#include <errno.h> /* for errors */
+
+#include "elapi_async.h"
+/* Private headers that deal with fd and tm structure definitions */
+#include "elapi_fd.h"
+#include "elapi_tm.h"
+#include "trace.h"
+#include "config.h"
+
+/* Functions to set and get data from file descriptor data. */
+/* Functions return EINVAL if passed in argument is invalid. */
+int elapi_set_fd_priv(struct elapi_fd_data *fd_data,
+ void *priv_data_to_set)
+{
+ int error = EOK;
+
+ TRACE_FLOW_STRING("elapi_set_fd_priv", "Entry");
+
+ /* Check arguments */
+ if (fd_data == NULL) {
+ TRACE_ERROR_NUMBER("Invalid argument. Error", EINVAL);
+ return EINVAL;
+ }
+
+ fd_data->ext_data = priv_data_to_set;
+
+ TRACE_FLOW_STRING("elapi_set_fd_priv", "Exit");
+ return error;
+}
+
+int elapi_get_fd_priv(struct elapi_fd_data *fd_data,
+ void **priv_data_to_get)
+{
+ int error = EOK;
+
+ TRACE_FLOW_STRING("elapi_get_fd_priv", "Entry");
+
+ /* Check arguments */
+ if ((fd_data == NULL) || (priv_data_to_get == NULL)) {
+ TRACE_ERROR_NUMBER("Invalid argument. Error", EINVAL);
+ return EINVAL;
+ }
+
+ *priv_data_to_get = fd_data->ext_data;
+
+ TRACE_FLOW_STRING("elapi_get_fd_priv", "Exit");
+ return error;
+}
+
+/* Cleanup function */
+void elapi_destroy_fd_data(struct elapi_fd_data *fd_data)
+{
+ TRACE_FLOW_STRING("elapi_destroy_fd_data", "Entry");
+
+
+ TRACE_FLOW_STRING("elapi_destroy_fd_data", "Exit");
+}
+
+
+/* Functions to set and get custom data from timer data. */
+/* Functions return EINVAL if passed in argument is invalid. */
+int elapi_set_tm_priv(struct elapi_tm_data *tm_data,
+ void *priv_data_to_set)
+{
+ int error = EOK;
+
+ TRACE_FLOW_STRING("elapi_set_tm_priv", "Entry");
+
+ /* Check arguments */
+ if (tm_data == NULL) {
+ TRACE_ERROR_NUMBER("Invalid argument. Error", EINVAL);
+ return EINVAL;
+ }
+
+ tm_data->ext_data = priv_data_to_set;
+
+ TRACE_FLOW_STRING("elapi_set_tm_priv", "Exit");
+ return error;
+}
+
+int elapi_get_tm_priv(struct elapi_tm_data *tm_data,
+ void **priv_data_to_get)
+{
+ int error = EOK;
+
+ TRACE_FLOW_STRING("elapi_get_tm_priv", "Entry");
+
+ /* Check arguments */
+ if ((tm_data == NULL) || (priv_data_to_get == NULL)) {
+ TRACE_ERROR_NUMBER("Invalid argument. Error", EINVAL);
+ return EINVAL;
+ }
+
+ *priv_data_to_get = tm_data->ext_data;
+
+ TRACE_FLOW_STRING("elapi_get_tm_priv", "Exit");
+ return error;
+}
+
+/* Cleanup function */
+void elapi_destroy_tm_data(struct elapi_tm_data *tm_data)
+{
+ TRACE_FLOW_STRING("elapi_destroy_tm_data", "Entry");
+
+
+ TRACE_FLOW_STRING("elapi_destroy_tm_data", "Exit");
+}
+
+
+/* Public interfaces ELAPI exposes to handle fd or timer
+ * events (do not confuse with log events).
+ */
+int elapi_process_fd(struct elapi_fd_data *fd_data)
+{
+ int error = EOK;
+
+ TRACE_FLOW_STRING("elapi_process_fd", "Entry");
+
+
+ TRACE_FLOW_STRING("elapi_process_fd", "Exit");
+ return error;
+}
+
+int elapi_process_tm(struct elapi_tm_data *tm_data)
+{
+ int error = EOK;
+
+ TRACE_FLOW_STRING("elapi_process_tm", "Entry");
+
+
+ TRACE_FLOW_STRING("elapi_process_tm", "Exit");
+ return error;
+}