Synopsis
#include <midori/midori.h>
SockInfo;
enum ConnectionState;
gint (*SockConnectFunc) (SockInfo *sock
,
gpointer data
);
gboolean (*SockFunc) (SockInfo *sock
,
GIOCondition condition
,
gpointer data
);
void send_open_command (gint sock
,
const gchar *command
,
gchar **args
);
gint socket_init (const gchar *instance_name
,
const gchar *config_dir
,
gboolean *exists
);
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
);
gboolean sock_has_read_data (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
);
gint sock_connect_async (const gchar *hostname
,
gushort port
,
SockConnectFunc func
,
gpointer data
);
gint sock_connect_async_cancel (gint id
);
gint sock_printf (SockInfo *sock
,
const gchar *format
,
...
);
gint sock_read (SockInfo *sock
,
gchar *buf
,
gint len
);
gint sock_write (SockInfo *sock
,
const gchar *buf
,
gint len
);
gint sock_write_all (SockInfo *sock
,
const gchar *buf
,
gint len
);
gint sock_gets (SockInfo *sock
,
gchar *buf
,
gint len
);
gint sock_getline (SockInfo *sock
,
gchar **line
);
gint sock_puts (SockInfo *sock
,
const gchar *buf
);
gint sock_peek (SockInfo *sock
,
gchar *buf
,
gint len
);
gint sock_close (SockInfo *sock
);
gint fd_connect_inet (gushort port
);
gint fd_open_inet (gushort port
);
gint fd_connect_unix (const gchar *path
);
gint fd_open_unix (const gchar *path
);
gint fd_accept (gint sock
);
gint fd_read (gint sock
,
gchar *buf
,
gint len
);
gint fd_write (gint sock
,
const gchar *buf
,
gint len
);
gint fd_write_all (gint sock
,
const gchar *buf
,
gint len
);
gint fd_gets (gint sock
,
gchar *buf
,
gint len
);
gint fd_getline (gint sock
,
gchar **line
);
gint fd_close (gint sock
);
gint ssl_read (SSL *ssl
,
gchar *buf
,
gint len
);
gint ssl_write (SSL *ssl
,
const gchar *buf
,
gint len
);
gint ssl_write_all (SSL *ssl
,
const gchar *buf
,
gint len
);
gint ssl_gets (SSL *ssl
,
gchar *buf
,
gint len
);
gint ssl_getline (SSL *ssl
,
gchar **line
);
gint ssl_peek (SSL *ssl
,
gchar *buf
,
gint len
);
void ssl_done_socket (SockInfo *sockinfo
);
Details
SockInfo
typedef struct {
gint sock;
#if USE_SSL
SSL *ssl;
#else
gpointer ssl;
#endif
GIOChannel *sock_ch;
gchar *hostname;
gushort port;
ConnectionState state;
gboolean nonblock;
gpointer data;
SockFunc callback;
GIOCondition condition;
} SockInfo;
enum ConnectionState
typedef enum
{
CONN_READY,
CONN_LOOKUPSUCCESS,
CONN_ESTABLISHED,
CONN_LOOKUPFAILED,
CONN_FAILED
} ConnectionState;
SockConnectFunc ()
gint (*SockConnectFunc) (SockInfo *sock
,
gpointer data
);
SockFunc ()
gboolean (*SockFunc) (SockInfo *sock
,
GIOCondition condition
,
gpointer data
);
send_open_command ()
void send_open_command (gint sock
,
const gchar *command
,
gchar **args
);
socket_init ()
gint socket_init (const gchar *instance_name
,
const gchar *config_dir
,
gboolean *exists
);
sock_cleanup ()
gint sock_cleanup (void
);
sock_set_io_timeout ()
gint sock_set_io_timeout (guint sec
);
sock_set_nonblocking_mode ()
gint sock_set_nonblocking_mode (SockInfo *sock
,
gboolean nonblock
);
sock_is_nonblocking_mode ()
gboolean sock_is_nonblocking_mode (SockInfo *sock
);
sock_has_read_data ()
gboolean sock_has_read_data (SockInfo *sock
);
sock_add_watch ()
guint sock_add_watch (SockInfo *sock
,
GIOCondition condition
,
SockFunc func
,
gpointer data
);
my_gethostbyname ()
struct hostent * my_gethostbyname (const gchar *hostname
);
sock_connect ()
SockInfo * sock_connect (const gchar *hostname
,
gushort port
);
sock_connect_async ()
gint sock_connect_async (const gchar *hostname
,
gushort port
,
SockConnectFunc func
,
gpointer data
);
sock_connect_async_cancel ()
gint sock_connect_async_cancel (gint id
);
sock_printf ()
gint sock_printf (SockInfo *sock
,
const gchar *format
,
...
);
sock_read ()
gint sock_read (SockInfo *sock
,
gchar *buf
,
gint len
);
sock_write ()
gint sock_write (SockInfo *sock
,
const gchar *buf
,
gint len
);
sock_write_all ()
gint sock_write_all (SockInfo *sock
,
const gchar *buf
,
gint len
);
sock_gets ()
gint sock_gets (SockInfo *sock
,
gchar *buf
,
gint len
);
sock_getline ()
gint sock_getline (SockInfo *sock
,
gchar **line
);
sock_puts ()
gint sock_puts (SockInfo *sock
,
const gchar *buf
);
sock_peek ()
gint sock_peek (SockInfo *sock
,
gchar *buf
,
gint len
);
sock_close ()
gint sock_close (SockInfo *sock
);
fd_connect_inet ()
gint fd_connect_inet (gushort port
);
fd_open_inet ()
gint fd_open_inet (gushort port
);
fd_connect_unix ()
gint fd_connect_unix (const gchar *path
);
fd_open_unix ()
gint fd_open_unix (const gchar *path
);
fd_accept ()
gint fd_accept (gint sock
);
fd_read ()
gint fd_read (gint sock
,
gchar *buf
,
gint len
);
fd_write ()
gint fd_write (gint sock
,
const gchar *buf
,
gint len
);
fd_write_all ()
gint fd_write_all (gint sock
,
const gchar *buf
,
gint len
);
fd_gets ()
gint fd_gets (gint sock
,
gchar *buf
,
gint len
);
fd_getline ()
gint fd_getline (gint sock
,
gchar **line
);
fd_close ()
gint fd_close (gint sock
);
ssl_read ()
gint ssl_read (SSL *ssl
,
gchar *buf
,
gint len
);
ssl_write ()
gint ssl_write (SSL *ssl
,
const gchar *buf
,
gint len
);
ssl_write_all ()
gint ssl_write_all (SSL *ssl
,
const gchar *buf
,
gint len
);
ssl_gets ()
gint ssl_gets (SSL *ssl
,
gchar *buf
,
gint len
);
ssl_getline ()
gint ssl_getline (SSL *ssl
,
gchar **line
);
ssl_peek ()
gint ssl_peek (SSL *ssl
,
gchar *buf
,
gint len
);
ssl_done_socket ()
void ssl_done_socket (SockInfo *sockinfo
);