/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2003 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __SOCKET_H__
#endif
#include <glib.h>
-#include <netdb.h>
+#if HAVE_NETDB_H
+# include <netdb.h>
+#endif
typedef struct _SockInfo SockInfo;
CONN_ESTABLISHED,
CONN_LOOKUPFAILED,
CONN_FAILED,
- CONN_DISCONNECTED,
+ CONN_DISCONNECTED
} ConnectionState;
typedef gint (*SockConnectFunc) (SockInfo *sock,
gpointer data);
+typedef gboolean (*SockFunc) (SockInfo *sock,
+ GIOCondition condition,
+ gpointer data);
struct _SockInfo
{
-#if USE_GIO
- GIOChannel *channel;
- gchar *buf;
- gint buflen;
-#else
gint sock;
+#if USE_OPENSSL
+ SSL *ssl;
+ guint g_source;
#endif
+ GIOChannel *sock_ch;
+
gchar *hostname;
gushort port;
ConnectionState state;
gpointer data;
-#if USE_OPENSSL
- SSL *ssl;
-#endif
+
+ SockFunc callback;
+ GIOCondition condition;
};
+void refresh_resolvers (void);
+gint sock_init (void);
+gint sock_cleanup (void);
+
gint sock_set_io_timeout (guint sec);
gint sock_set_nonblocking_mode (SockInfo *sock, gboolean nonblock);
gboolean sock_is_nonblocking_mode (SockInfo *sock);
+guint sock_add_watch (SockInfo *sock, GIOCondition condition,
+ SockFunc func, gpointer data);
+
struct hostent *my_gethostbyname (const gchar *hostname);
SockInfo *sock_connect (const gchar *hostname, gushort port);
SockConnectFunc func, gpointer data);
gint sock_connect_async_cancel (gint id);
+/* Basic I/O functions */
gint sock_printf (SockInfo *sock, const gchar *format, ...)
G_GNUC_PRINTF(2, 3);
gint sock_read (SockInfo *sock, gchar *buf, gint len);