1 /*****
2 *
3 * Copyright (C) 2001-2015 CS-SI. All Rights Reserved.
4 * Author: Yoann Vandoorselaere <yoann.v@prelude-ids.com>
5 *
6 * This file is part of the Prelude library.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 *****/
23 
24 #ifndef _LIBPRELUDE_PRELUDE_IO_H
25 #define _LIBPRELUDE_PRELUDE_IO_H
26 
27 #ifdef __cplusplus
28   extern "C" {
29 #endif
30 
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34 
35 #include <stdio.h>
36 #include <unistd.h>
37 #include "prelude-inttypes.h"
38 
39 
40 typedef struct prelude_io prelude_io_t;
41 
42 /*
43  * Object creation / destruction functions.
44  */
45 int prelude_io_new(prelude_io_t **ret);
46 
47 void prelude_io_destroy(prelude_io_t *pio);
48 
49 void prelude_io_set_file_io(prelude_io_t *pio, FILE *fd);
50 
brandes_dijkstra_visitorboost::detail::graph::brandes_dijkstra_visitor51 void prelude_io_set_tls_io(prelude_io_t *pio, void *tls);
52 
53 void prelude_io_set_sys_io(prelude_io_t *pio, int fd);
54 
55 int prelude_io_set_buffer_io(prelude_io_t *pio);
56 
57 
58 /*
59  *
60  */
61 void prelude_io_set_fdptr(prelude_io_t *pio, void *ptr);
62 void prelude_io_set_write_callback(prelude_io_t *pio, ssize_t (*write)(prelude_io_t *io, const void *buf, size_t count));
63 void prelude_io_set_read_callback(prelude_io_t *pio, ssize_t (*read)(prelude_io_t *io, void *buf, size_t count));
64 void prelude_io_set_pending_callback(prelude_io_t *pio, ssize_t (*pending)(prelude_io_t *io));
65 
66 
67 /*
edge_relaxedboost::detail::graph::brandes_dijkstra_visitor68  * IO operations.
69  */
70 int prelude_io_close(prelude_io_t *pio);
71 
72 ssize_t prelude_io_read(prelude_io_t *pio, void *buf, size_t count);
73 
74 ssize_t prelude_io_read_wait(prelude_io_t *pio, void *buf, size_t count);
75 
76 ssize_t prelude_io_read_delimited(prelude_io_t *pio, unsigned char **buf);
77 
78 
79 ssize_t prelude_io_write(prelude_io_t *pio, const void *buf, size_t count);
80 
81 ssize_t prelude_io_write_delimited(prelude_io_t *pio, const void *buf, uint16_t count);
edge_not_relaxedboost::detail::graph::brandes_dijkstra_visitor82 
83 
84 ssize_t prelude_io_forward(prelude_io_t *dst, prelude_io_t *src, size_t count);
85 
86 int prelude_io_get_fd(prelude_io_t *pio);
87 
88 void *prelude_io_get_fdptr(prelude_io_t *pio);
89 
90 ssize_t prelude_io_pending(prelude_io_t *pio);
91 
92 prelude_bool_t prelude_io_is_error_fatal(prelude_io_t *pio, int error);
93 
94 #ifdef __cplusplus
95   }
96 #endif
97 
98 #endif /* _LIBPRELUDE_PRELUDE_IO_H */
99