summaryrefslogtreecommitdiff
path: root/common/elapi/elapi_async.c
blob: 0c404c04a83ff0a493eeed413eee533c989b11d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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;
}