2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
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 3 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, see <http://www.gnu.org/licenses/>.
27 #if (defined (_XOPEN_SOURCE) && !defined (_BSD_SOURCE))
36 typedef struct _SockInfo SockInfo;
52 typedef gint (*SockConnectFunc) (SockInfo *sock,
54 typedef gboolean (*SockFunc) (SockInfo *sock,
55 GIOCondition condition,
63 gnutls_certificate_credentials_t xcred;
64 gnutls_x509_crt client_crt;
65 gnutls_x509_privkey client_key;
72 ConnectionState state;
76 GIOCondition condition;
77 gchar *canonical_name;
83 void refresh_resolvers (void);
84 gint sock_init (void);
85 gint sock_cleanup (void);
87 gint sock_set_io_timeout (guint sec);
89 gint sock_set_nonblocking_mode (SockInfo *sock, gboolean nonblock);
90 gboolean sock_is_nonblocking_mode (SockInfo *sock);
92 guint sock_add_watch (SockInfo *sock, GIOCondition condition,
93 SockFunc func, gpointer data);
95 struct hostent *my_gethostbyname (const gchar *hostname);
97 SockInfo *sock_connect (const gchar *hostname, gushort port);
98 gint sock_connect_async (const gchar *hostname, gushort port,
99 SockConnectFunc func, gpointer data);
100 gint sock_connect_async_cancel (gint id);
102 /* Basic I/O functions */
103 gint sock_read (SockInfo *sock, gchar *buf, gint len);
104 gint sock_write (SockInfo *sock, const gchar *buf, gint len);
105 gint sock_write_all (SockInfo *sock, const gchar *buf, gint len);
106 gint sock_close (SockInfo *sock);
108 /* Functions to directly work on FD. They are needed for pipes */
109 gint fd_connect_unix (const gchar *path);
110 gint fd_open_unix (const gchar *path);
111 gint fd_accept (gint sock);
113 gint fd_connect_inet(gushort port);
114 gint fd_open_inet(gushort port);
116 gint fd_write (gint sock, const gchar *buf, gint len);
117 gint fd_write_all (gint sock, const gchar *buf, gint len);
118 gint fd_gets (gint sock, gchar *buf, gint len);
119 gint fd_close (gint sock);
121 #endif /* __SOCKET_H__ */