1 /* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright (C) 2010 Christian Kellner
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: Christian Kellner <gicmo@gnome.org>
19 */
20
21 #include "config.h"
22 #include "gfiledescriptorbased.h"
23 #include "glibintl.h"
24
25
26 /**
27 * SECTION:gfiledescriptorbased
28 * @short_description: Interface for file descriptor based IO
29 * @include: gio/gfiledescriptorbased.h
30 * @see_also: #GInputStream, #GOutputStream
31 *
32 * #GFileDescriptorBased is implemented by streams (implementations of
33 * #GInputStream or #GOutputStream) that are based on file descriptors.
34 *
35 * Note that `<gio/gfiledescriptorbased.h>` belongs to the UNIX-specific
36 * GIO interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
37 * file when using it.
38 *
39 * Since: 2.24
40 *
41 **/
42
43 typedef GFileDescriptorBasedIface GFileDescriptorBasedInterface;
G_DEFINE_INTERFACE(GFileDescriptorBased,g_file_descriptor_based,G_TYPE_OBJECT)44 G_DEFINE_INTERFACE (GFileDescriptorBased, g_file_descriptor_based, G_TYPE_OBJECT)
45
46 static void
47 g_file_descriptor_based_default_init (GFileDescriptorBasedInterface *iface)
48 {
49 }
50
51 /**
52 * g_file_descriptor_based_get_fd:
53 * @fd_based: a #GFileDescriptorBased.
54 *
55 * Gets the underlying file descriptor.
56 *
57 * Returns: The file descriptor
58 *
59 * Since: 2.24
60 **/
61 int
g_file_descriptor_based_get_fd(GFileDescriptorBased * fd_based)62 g_file_descriptor_based_get_fd (GFileDescriptorBased *fd_based)
63 {
64 GFileDescriptorBasedIface *iface;
65
66 g_return_val_if_fail (G_IS_FILE_DESCRIPTOR_BASED (fd_based), 0);
67
68 iface = G_FILE_DESCRIPTOR_BASED_GET_IFACE (fd_based);
69
70 return (* iface->get_fd) (fd_based);
71 }
72