147
|
1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
|
2 |
/* |
|
3 |
* Copyright (C) 2006 Imendio AB |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU Lesser General Public License as |
|
7 |
* published by the Free Software Foundation; either version 2 of the |
|
8 |
* License, or (at your option) any later version. |
|
9 |
* |
|
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 GNU |
|
13 |
* Lesser General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU Lesser General Public |
|
16 |
* License along with this program; if not, write to the |
|
17 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
18 |
* Boston, MA 02111-1307, USA. |
|
19 |
*/ |
|
20 |
|
|
21 |
#include <glib.h> |
|
22 |
|
|
23 |
#ifndef __LM_SOCKET_H__ |
|
24 |
#define __LM_SOCKET_H__ |
|
25 |
|
149
|
26 |
typedef struct _LmSocket LmSocket; |
147
|
27 |
|
|
28 |
typedef struct { |
|
29 |
/* ConnectCB */ |
|
30 |
/* InCB */ |
|
31 |
/* HupCB */ |
149
|
32 |
} LmSocketFuncs; |
147
|
33 |
|
|
34 |
typedef enum { |
149
|
35 |
LM_SOCKET_STATE_CLOSED, |
|
36 |
LM_SOCKET_STATE_DNS_LOOKUP, |
|
37 |
LM_SOCKET_STATE_OPENING, |
|
38 |
LM_SOCKET_STATE_OPEN |
|
39 |
} LmSocketState; |
147
|
40 |
|
149
|
41 |
LmSocket * lm_socket_new (LmSocketFuncs funcs, |
|
42 |
const gchar *host, |
|
43 |
guint port); |
|
44 |
void lm_socket_open (LmSocket *socket); |
|
45 |
int lm_socket_get_fd (LmSocket *socket); |
|
46 |
gboolean lm_socket_get_is_blocking (LmSocket *socket); |
|
47 |
void lm_socket_set_is_blocking (LmSocket *socket, |
|
48 |
gboolean is_block); |
|
49 |
int lm_socket_write (LmSocket *socket, |
|
50 |
gsize size, |
|
51 |
gchar *buf, |
|
52 |
GError **error); |
|
53 |
int lm_socket_read (LmSocket *socket, |
|
54 |
gsize size, |
|
55 |
gchar *buf, |
|
56 |
GError **error); |
|
57 |
gboolean lm_socket_close (LmSocket *socket, |
|
58 |
GError **error); |
|
59 |
LmSock * lm_socket_ref (LmSocket *socket); |
|
60 |
void lm_socket_unref (LmSocket *socket); |
147
|
61 |
|
148
|
62 |
#endif /* __LM_SOCKET_H__ */ |
149
|
63 |
|