Remove redundant alloca define.
[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 \r
17 #ifdef HAVE_SYS_SOCKET_H\r
18 #include <sys/socket.h>\r
19 #endif\r
20 \r
21 #ifdef SOUP_WIN32\r
22 #include <winsock.h>\r
23 #endif\r
24 \r
25 #include <glib.h>
26
27 gboolean  soup_gethostbyname (const gchar         *hostname,
28                               struct sockaddr_in  *sa,
29                               gchar              **nicename);
30
31 gchar    *soup_gethostbyaddr (const gchar         *addr, 
32                               size_t               length, 
33                               int                  type);
34
35 typedef struct _SoupAddress SoupAddress;
36
37 typedef gpointer SoupAddressNewId;
38
39 typedef enum {
40         SOUP_ADDRESS_STATUS_OK,
41         SOUP_ADDRESS_STATUS_ERROR
42 } SoupAddressStatus;
43
44 typedef void (*SoupAddressNewFn) (SoupAddress       *inetaddr, 
45                                   SoupAddressStatus  status, 
46                                   gpointer           user_data);
47
48 SoupAddressNewId     soup_address_new                (const gchar*       name, 
49                                                       const gint         port, 
50                                                       SoupAddressNewFn   func, 
51                                                       gpointer           data);
52
53 void                 soup_address_new_cancel         (SoupAddressNewId   id);
54
55 SoupAddress         *soup_address_new_sync           (const gchar *name, 
56                                                       const gint port);
57
58 void                 soup_address_ref                (SoupAddress*       ia);
59
60 void                 soup_address_unref              (SoupAddress*       ia);
61
62 SoupAddress *        soup_address_copy               (SoupAddress*       ia);
63
64
65 typedef gpointer SoupAddressGetNameId;
66
67 typedef void (*SoupAddressGetNameFn) (SoupAddress       *inetaddr, 
68                                       SoupAddressStatus  status, 
69                                       const gchar       *name,
70                                       gpointer           user_data);
71
72 SoupAddressGetNameId soup_address_get_name           (SoupAddress*         ia, 
73                                                       SoupAddressGetNameFn func,
74                                                       gpointer             data);
75
76 void                 soup_address_get_name_cancel    (SoupAddressGetNameId id);
77
78 const gchar         *soup_address_get_name_sync      (SoupAddress *addr);
79
80 gchar*               soup_address_get_canonical_name (SoupAddress*         ia);
81
82 gint                 soup_address_get_port           (const SoupAddress*   ia);
83
84 void                 soup_address_set_port           (const SoupAddress*   ia, 
85                                                       guint                port);
86
87 guint                soup_address_hash               (const gpointer       p);
88
89 gint                 soup_address_equal              (const gpointer       p1, 
90                                                       const gpointer       p2);
91
92 gint                 soup_address_noport_equal       (const gpointer       p1, 
93                                                       const gpointer       p2);
94
95 gchar*               soup_address_gethostname        (void);
96
97 SoupAddress*         soup_address_gethostaddr        (void);
98
99
100 typedef struct _SoupSocket SoupSocket;
101
102 typedef gpointer SoupSocketConnectId;
103
104 typedef enum {
105         SOUP_SOCKET_CONNECT_ERROR_NONE,
106         SOUP_SOCKET_CONNECT_ERROR_ADDR_RESOLVE,
107         SOUP_SOCKET_CONNECT_ERROR_NETWORK
108 } SoupSocketConnectStatus;
109
110 typedef void (*SoupSocketConnectFn) (SoupSocket              *socket, 
111                                      SoupSocketConnectStatus  status, 
112                                      gpointer                 data);
113
114 SoupSocketConnectId  soup_socket_connect        (const gchar*        hostname,
115                                                  const gint          port, 
116                                                  SoupSocketConnectFn func, 
117                                                  gpointer            data);
118
119 void                 soup_socket_connect_cancel (SoupSocketConnectId id);
120
121 SoupSocket          *soup_socket_connect_sync   (const gchar        *hostname, 
122                                                  const gint          port);
123
124
125
126 typedef gpointer SoupSocketNewId;
127
128 typedef enum {
129         SOUP_SOCKET_NEW_STATUS_OK,
130         SOUP_SOCKET_NEW_STATUS_ERROR
131 } SoupSocketNewStatus;
132
133 typedef void (*SoupSocketNewFn) (SoupSocket*         socket, 
134                                  SoupSocketNewStatus status, 
135                                  gpointer            data);
136
137 SoupSocketNewId     soup_socket_new             (SoupAddress        *addr, 
138                                                  SoupSocketNewFn     func,
139                                                  gpointer            data);
140
141 void                soup_socket_new_cancel      (SoupSocketNewId     id);
142
143 SoupSocket         *soup_socket_new_sync        (SoupAddress        *addr);
144
145
146 void                soup_socket_ref             (SoupSocket*         s);
147
148 void                soup_socket_unref           (SoupSocket*         s);
149
150 GIOChannel         *soup_socket_get_iochannel   (SoupSocket*         socket);
151
152 SoupAddress        *soup_socket_get_address     (const SoupSocket*   socket);
153
154 gint                soup_socket_get_port        (const SoupSocket*   socket);
155
156
157 #define SOUP_SERVER_ANY_PORT 0
158
159 SoupSocket         *soup_socket_server_new        (const gint          port);
160
161 SoupSocket         *soup_socket_server_accept     (SoupSocket         *socket);
162
163 SoupSocket         *soup_socket_server_try_accept (SoupSocket         *socket);
164
165 #endif /* SOUP_SOCKET_H */