1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ |
---|
2 | /* gnome-vfs-socket.c |
---|
3 | * |
---|
4 | * Copyright (C) 2001 Seth Nickell |
---|
5 | * Copyright (C) 2001 Maciej Stachowiak |
---|
6 | * |
---|
7 | * The Gnome Library is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU Library General Public License as |
---|
9 | * published by the Free Software Foundation; either version 2 of the |
---|
10 | * License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * The Gnome 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 | * Library General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU Library General Public |
---|
18 | * License along with the Gnome Library; see the file COPYING.LIB. If not, |
---|
19 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
20 | * Boston, MA 02111-1307, USA. |
---|
21 | * |
---|
22 | */ |
---|
23 | /* |
---|
24 | * Authors: Seth Nickell <snickell@stanford.edu> |
---|
25 | * Maciej Stachowiak <mjs@noisehavoc.org> |
---|
26 | * (reverse-engineered from code by Ian McKellar <yakk@yakk.net>) |
---|
27 | */ |
---|
28 | |
---|
29 | #include <config.h> |
---|
30 | #include "gnome-vfs-socket.h" |
---|
31 | |
---|
32 | struct GnomeVFSSocket { |
---|
33 | GnomeVFSSocketImpl *impl; |
---|
34 | gpointer connection; |
---|
35 | }; |
---|
36 | |
---|
37 | |
---|
38 | GnomeVFSSocket* gnome_vfs_socket_new (GnomeVFSSocketImpl *impl, |
---|
39 | void *connection) |
---|
40 | { |
---|
41 | GnomeVFSSocket *socket; |
---|
42 | |
---|
43 | socket = g_new0 (GnomeVFSSocket, 1); |
---|
44 | socket->impl = impl; |
---|
45 | socket->connection = connection; |
---|
46 | |
---|
47 | return socket; |
---|
48 | } |
---|
49 | |
---|
50 | GnomeVFSResult |
---|
51 | gnome_vfs_socket_write (GnomeVFSSocket *socket, |
---|
52 | gconstpointer buffer, |
---|
53 | int bytes, |
---|
54 | GnomeVFSFileSize *bytes_written) |
---|
55 | { |
---|
56 | return socket->impl->write (socket->connection, |
---|
57 | buffer, bytes, bytes_written); |
---|
58 | } |
---|
59 | |
---|
60 | GnomeVFSResult |
---|
61 | gnome_vfs_socket_close (GnomeVFSSocket *socket) |
---|
62 | { |
---|
63 | socket->impl->close (socket->connection); |
---|
64 | return GNOME_VFS_OK; |
---|
65 | } |
---|
66 | |
---|
67 | GnomeVFSResult |
---|
68 | gnome_vfs_socket_read (GnomeVFSSocket *socket, |
---|
69 | gpointer buffer, |
---|
70 | GnomeVFSFileSize bytes, |
---|
71 | GnomeVFSFileSize *bytes_read) |
---|
72 | { |
---|
73 | return socket->impl->read (socket->connection, |
---|
74 | buffer, bytes, bytes_read); |
---|
75 | } |
---|