libuev
2.4.1
src
io.c
Go to the documentation of this file.
1
/* libuEv - Micro event loop library
2
*
3
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
4
* Copyright (c) 2013-2024 Joachim Wiberg <troglobit()gmail!com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to deal
8
* in the Software without restriction, including without limitation the rights
9
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
* copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
* THE SOFTWARE.
23
*/
24
25
#include <errno.h>
26
#include "
uev.h
"
27
32
44
int
uev_io_init
(
uev_ctx_t
*ctx,
uev_t
*w,
uev_cb_t
*cb,
void
*arg,
int
fd,
int
events)
45
{
46
if
(fd < 0) {
47
errno = EINVAL;
48
return
-1;
49
}
50
51
if
(_uev_watcher_init(ctx, w, UEV_IO_TYPE, cb, arg, fd, events))
52
return
-1;
53
54
return
_uev_watcher_start(w);
55
}
56
65
int
uev_io_set
(
uev_t
*w,
int
fd,
int
events)
66
{
67
if
((events &
UEV_ONESHOT
) && _uev_watcher_active(w))
68
return
_uev_watcher_rearm(w);
69
70
/* Ignore any errors, only to clean up anything lingering ... */
71
uev_io_stop
(w);
72
73
return
uev_io_init
(w->
ctx
, w, (
uev_cb_t
*)w->cb, w->arg, fd, events);
74
}
75
82
int
uev_io_start
(
uev_t
*w)
83
{
84
return
uev_io_set
(w, w->
fd
, w->events);
85
}
86
93
int
uev_io_stop
(
uev_t
*w)
94
{
95
return
_uev_watcher_stop(w);
96
}
97
uev_io_stop
int uev_io_stop(uev_t *w)
Definition
io.c:93
uev_io_init
int uev_io_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int fd, int events)
Definition
io.c:44
uev_io_start
int uev_io_start(uev_t *w)
Definition
io.c:82
uev_io_set
int uev_io_set(uev_t *w, int fd, int events)
Definition
io.c:65
uev::fd
int fd
Definition
uev.h:79
uev::ctx
uev_ctx_t * ctx
Definition
uev.h:80
uev.h
uev_ctx_t
struct uev_ctx uev_ctx_t
Definition
uev.h:70
uev_cb_t
void uev_cb_t(uev_t *w, void *arg, int events)
Definition
uev.h:97
UEV_ONESHOT
#define UEV_ONESHOT
Definition
uev.h:52
uev_t
struct uev uev_t
Generated by
1.13.2