2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program 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
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 typedef struct _SockInfo SockInfo;
46 typedef gint (*SockConnectFunc) (SockInfo *sock,
48 typedef gboolean (*SockFunc) (SockInfo *sock,
49 GIOCondition condition,
63 ConnectionState state;
67 GIOCondition condition;
70 gint sock_set_io_timeout (guint sec);
72 gint sock_set_nonblocking_mode (SockInfo *sock, gboolean nonblock);
73 gboolean sock_is_nonblocking_mode (SockInfo *sock);
75 guint sock_add_watch (SockInfo *sock, GIOCondition condition,
76 SockFunc func, gpointer data);
78 struct hostent *my_gethostbyname (const gchar *hostname);
80 SockInfo *sock_connect (const gchar *hostname, gushort port);
81 SockInfo *sock_connect_cmd (const gchar *hostname, const gchar *tunnelcmd);
82 gint sock_connect_async (const gchar *hostname, gushort port,
83 SockConnectFunc func, gpointer data);
84 gint sock_connect_async_cancel (gint id);
86 /* Basic I/O functions */
87 gint sock_printf (SockInfo *sock, const gchar *format, ...)
89 gint sock_read (SockInfo *sock, gchar *buf, gint len);
90 gint sock_write (SockInfo *sock, const gchar *buf, gint len);
91 gint sock_write_all (SockInfo *sock, const gchar *buf, gint len);
92 gint sock_gets (SockInfo *sock, gchar *buf, gint len);
93 gchar *sock_getline (SockInfo *sock);
94 gint sock_puts (SockInfo *sock, const gchar *buf);
95 gint sock_peek (SockInfo *sock, gchar *buf, gint len);
96 gint sock_close (SockInfo *sock);
98 /* Functions to directly work on FD. They are needed for pipes */
99 gint fd_connect_unix (const gchar *path);
100 gint fd_open_unix (const gchar *path);
101 gint fd_accept (gint sock);
103 gint fd_read (gint sock, gchar *buf, gint len);
104 gint fd_write (gint sock, const gchar *buf, gint len);
105 gint fd_write_all (gint sock, const gchar *buf, gint len);
106 gint fd_gets (gint sock, gchar *buf, gint len);
107 gint fd_getline (gint sock, gchar **str);
108 gint fd_close (gint sock);
110 /* Functions for SSL */
112 gint ssl_read (SSL *ssl, gchar *buf, gint len);
113 gint ssl_write (SSL *ssl, const gchar *buf, gint len);
114 gint ssl_write_all (SSL *ssl, const gchar *buf, gint len);
115 gint ssl_gets (SSL *ssl, gchar *buf, gint len);
116 gint ssl_getline (SSL *ssl, gchar **str);
117 gint ssl_peek (SSL *ssl, gchar *buf, gint len);
120 #endif /* __SOCKET_H__ */