Impl. Use instead of custom header free funcs throughout.
[platform/upstream/libsoup.git] / libsoup / soup-socket.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * soup-socket.c: ronous Callback-based SOAP Request Queue.
4  *
5  * Authors:
6  *      David Helder  (dhelder@umich.edu)
7  *      Alex Graveley (alex@helixcode.com)
8  * 
9  * Original code compliments of David Helder's GNET Networking Library.
10  *
11  * Copyright (C) 2000, Helix Code, Inc.
12  */
13
14 #ifndef SOUP_SOCKET_H
15 #define SOUP_SOCKET_H 1
16
17 #include <glib.h>
18
19 typedef struct _SoupAddress SoupAddress;
20
21 typedef gpointer SoupAddressNewId;
22
23 typedef enum {
24         SOUP_ADDRESS_STATUS_OK,
25         SOUP_ADDRESS_STATUS_ERROR
26 } SoupAddressStatus;
27
28 typedef void (*SoupAddressNewFn) (SoupAddress       *inetaddr, 
29                                   SoupAddressStatus  status, 
30                                   gpointer           user_data);
31
32 SoupAddressNewId     soup_address_new                (const gchar*       name, 
33                                                       const gint         port, 
34                                                       SoupAddressNewFn   func, 
35                                                       gpointer           data);
36
37 void                 soup_address_new_cancel         (SoupAddressNewId   id);
38
39 SoupAddress         *soup_address_new_sync           (const gchar *name, 
40                                                       const gint port);
41
42 void                 soup_address_ref                (SoupAddress*       ia);
43
44 void                 soup_address_unref              (SoupAddress*       ia);
45
46 SoupAddress *        soup_address_copy               (SoupAddress*       ia);
47
48
49 typedef gpointer SoupAddressGetNameId;
50
51 typedef void (*SoupAddressGetNameFn) (SoupAddress       *inetaddr, 
52                                       SoupAddressStatus  status, 
53                                       const gchar       *name,
54                                       gpointer           user_data);
55
56 SoupAddressGetNameId soup_address_get_name           (SoupAddress*         ia, 
57                                                       SoupAddressGetNameFn func,
58                                                       gpointer             data);
59
60 void                 soup_address_get_name_cancel    (SoupAddressGetNameId id);
61
62 const gchar         *soup_address_get_name_sync      (SoupAddress *addr);
63
64 gchar*               soup_address_get_canonical_name (SoupAddress*         ia);
65
66 gint                 soup_address_get_port           (const SoupAddress*   ia);
67
68 void                 soup_address_set_port           (const SoupAddress*   ia, 
69                                                       guint                port);
70
71 guint                soup_address_hash               (const gpointer       p);
72
73 gint                 soup_address_equal              (const gpointer       p1, 
74                                                       const gpointer       p2);
75
76 gint                 soup_address_noport_equal       (const gpointer       p1, 
77                                                       const gpointer       p2);
78
79 gchar*               soup_address_gethostname        (void);
80
81 SoupAddress*         soup_address_gethostaddr        (void);
82
83
84 typedef struct _SoupSocket SoupSocket;
85
86 typedef gpointer SoupSocketConnectId;
87
88 typedef enum {
89         SOUP_SOCKET_CONNECT_ERROR_NONE,
90         SOUP_SOCKET_CONNECT_ERROR_ADDR_RESOLVE,
91         SOUP_SOCKET_CONNECT_ERROR_NETWORK
92 } SoupSocketConnectStatus;
93
94 typedef void (*SoupSocketConnectFn) (SoupSocket              *socket, 
95                                      SoupSocketConnectStatus  status, 
96                                      gpointer                 data);
97
98 SoupSocketConnectId  soup_socket_connect        (const gchar*        hostname,
99                                                  const gint          port, 
100                                                  SoupSocketConnectFn func, 
101                                                  gpointer            data);
102
103 void                 soup_socket_connect_cancel (SoupSocketConnectId id);
104
105 SoupSocket          *soup_socket_connect_sync   (const gchar        *hostname, 
106                                                  const gint          port);
107
108
109 typedef gpointer SoupSocketNewId;
110
111 typedef enum {
112         SOUP_SOCKET_NEW_STATUS_OK,
113         SOUP_SOCKET_NEW_STATUS_ERROR
114 } SoupSocketNewStatus;
115
116 typedef void (*SoupSocketNewFn) (SoupSocket*         socket, 
117                                  SoupSocketNewStatus status, 
118                                  gpointer            data);
119
120 SoupSocketNewId     soup_socket_new             (SoupAddress        *addr, 
121                                                  SoupSocketNewFn     func,
122                                                  gpointer            data);
123
124 void                soup_socket_new_cancel      (SoupSocketNewId     id);
125
126 SoupSocket         *soup_socket_new_sync        (SoupAddress        *addr);
127
128
129 void                soup_socket_ref             (SoupSocket*         s);
130
131 void                soup_socket_unref           (SoupSocket*         s);
132
133 GIOChannel         *soup_socket_get_iochannel   (SoupSocket*         socket);
134
135 SoupAddress        *soup_socket_get_address     (const SoupSocket*   socket);
136
137 gint                soup_socket_get_port        (const SoupSocket*   socket);
138
139
140 #define SOUP_SERVER_ANY_PORT 0
141
142 SoupSocket         *soup_socket_server_new        (const gint          port);
143
144 SoupSocket         *soup_socket_server_accept     (SoupSocket         *socket);
145
146 SoupSocket         *soup_socket_server_try_accept (SoupSocket         *socket);
147
148 #endif /* SOUP_SOCKET_H */