1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2010 Christian Kellner
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 * Author: Christian Kellner <gicmo@gnome.org>
24 #include "gfiledescriptorbased.h"
29 * GFileDescriptorBased:
31 * `GFileDescriptorBased` is an interface for file descriptor based IO.
33 * It is implemented by streams (implementations of [class@Gio.InputStream] or
34 * [class@Gio.OutputStream]) that are based on file descriptors.
36 * Note that `<gio/gfiledescriptorbased.h>` belongs to the UNIX-specific
37 * GIO interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
38 * file or the `GioUnix-2.0` GIR namespace when using it.
43 typedef GFileDescriptorBasedIface GFileDescriptorBasedInterface;
44 G_DEFINE_INTERFACE (GFileDescriptorBased, g_file_descriptor_based, G_TYPE_OBJECT)
47 g_file_descriptor_based_default_init (GFileDescriptorBasedInterface *iface)
52 * g_file_descriptor_based_get_fd:
53 * @fd_based: a #GFileDescriptorBased.
55 * Gets the underlying file descriptor.
57 * Returns: The file descriptor
62 g_file_descriptor_based_get_fd (GFileDescriptorBased *fd_based)
64 GFileDescriptorBasedIface *iface;
66 g_return_val_if_fail (G_IS_FILE_DESCRIPTOR_BASED (fd_based), -1);
68 iface = G_FILE_DESCRIPTOR_BASED_GET_IFACE (fd_based);
70 return (* iface->get_fd) (fd_based);