libc_extra/android_linux/stdio/
cookie_io_functions_t.rs

1// This file is part of libc-extra. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/libc-extra/master/COPYRIGHT. No part of libc-extra, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2016-2018 The developers of libc-extra. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/libc-extra/master/COPYRIGHT.
3
4
5//noinspection SpellCheckingInspection
6/// Used by `fopencookie`.
7#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
8#[repr(C)]
9pub struct cookie_io_functions_t
10{
11	/// Read function pointer.
12	pub read: cookie_read_function_t,
13	
14	/// Write function pointer.
15	pub write: cookie_write_function_t,
16	
17	/// Seek function pointer.
18	pub seek: cookie_seek_function_t,
19	
20	/// Close function pointer.
21	pub close: cookie_close_function_t,
22}
23
24impl Default for cookie_io_functions_t
25{
26	#[inline(always)]
27	fn default() -> Self
28	{
29		Self
30		{
31			read: Self::default_read,
32			write: Self::default_write,
33			seek: Self::default_seek,
34			close: Self::default_close,
35		}
36	}
37}
38
39impl cookie_io_functions_t
40{
41	/// No-op cookie read function.
42	pub unsafe extern "C" fn default_read(_cookier: *mut c_void, _buf: *mut c_char, _size: size_t) -> ssize_t
43	{
44		0
45	}
46	
47	/// No-op cookie write function.
48	pub unsafe extern "C" fn default_write(_cookier: *mut c_void, _buf: *const c_char, _size: size_t) -> ssize_t
49	{
50		0
51	}
52	
53	/// No-op cookie seek function.
54	pub unsafe extern "C" fn default_seek(_cookier: *mut c_void, _offset: *mut off_t, _whence: c_int) -> c_int
55	{
56		0
57	}
58	
59	/// No-op cookie close function.
60	pub unsafe extern "C" fn default_close(_cookier: *mut c_void) -> c_int
61	{
62		0
63	}
64}