1 /*
2 NETWIB
3 Network library
4 Copyright(c) 1999-2010 Laurent Constantin
5 -----
6
7 Main server : http://www.laurentconstantin.com/
8 Backup server : http://laurentconstantin.free.fr/
9 [my current email address is on the web servers]
10
11 -----
12 This file is part of Netwib.
13
14 Netwib is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License version 3
16 as published by the Free Software Foundation.
17
18 Netwib is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details (http://www.gnu.org/).
22
23 ------------------------------------------------------------------------
24 */
25
26 #include <netwib/inc/maininc.h>
27
28 /*-------------------------------------------------------------*/
netwib_io_init(netwib_bool readsupported,netwib_bool writesupported,netwib_ptr pcommon,netwib_io_read_pf pfread,netwib_io_write_pf pfwrite,netwib_io_wait_pf pfwait,netwib_io_unread_pf pfunread,netwib_io_ctl_set_pf pfctl_set,netwib_io_ctl_get_pf pfctl_get,netwib_io_close_pf pfclose,netwib_io ** ppio)29 netwib_err netwib_io_init(netwib_bool readsupported,
30 netwib_bool writesupported,
31 netwib_ptr pcommon,
32 netwib_io_read_pf pfread,
33 netwib_io_write_pf pfwrite,
34 netwib_io_wait_pf pfwait,
35 netwib_io_unread_pf pfunread,
36 netwib_io_ctl_set_pf pfctl_set,
37 netwib_io_ctl_get_pf pfctl_get,
38 netwib_io_close_pf pfclose,
39 netwib_io **ppio)
40 {
41 netwib_io *pio;
42
43 /* parameter verification */
44 if (ppio == NULL) {
45 return(NETWIB_ERR_PANULLPTR);
46 }
47
48 /* allocate needed memory to store pio */
49 netwib_er(netwib_ptr_malloc(sizeof(netwib_io), (netwib_ptr*)&pio));
50 *ppio = pio;
51
52 /* set parameters */
53 pio->rd.pnext = NULL;
54 pio->rd.supported = readsupported;
55 pio->rd.numusers = 0;
56 pio->wr.pnext = NULL;
57 pio->wr.supported = writesupported;
58 pio->wr.numusers = 0;
59
60 pio->pcommon = pcommon;
61
62 pio->pfread = pfread;
63 pio->pfwrite = pfwrite;
64 pio->pfwait = pfwait;
65 pio->pfunread = pfunread;
66 pio->pfctl_set = pfctl_set;
67 pio->pfctl_get = pfctl_get;
68 pio->pfclose = pfclose;
69
70 #if NETWIB_DEBUG_LEAK==1
71 netwib_er(netwib_debug_leak_add_io(pio));
72 #endif
73
74 return(NETWIB_ERR_OK);
75 }
76
77