summaryrefslogtreecommitdiff
path: root/libsoup/soup-address.h
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2003-08-18 15:59:05 +0000
committerDan Winship <danw@src.gnome.org>2003-08-18 15:59:05 +0000
commit80b7b8f1d619d626fbb9a3fb2b5beda8d3cb1890 (patch)
treed272ae881d08efe5f255ee7e74c1fb6744bbadeb /libsoup/soup-address.h
parent3601be883b932a7b3167ad39cc786a16fd68b834 (diff)
downloadlibsoup-80b7b8f1d619d626fbb9a3fb2b5beda8d3cb1890.tar.gz
Make this more like a struct sockaddr again (like it used to be). In
* libsoup/soup-address.c (SoupAddressPrivate): Make this more like a struct sockaddr again (like it used to be). In particular, add back the "port" field. Add a bunch of macros to try (and fail) to simplify some of the code. (soup_address_new): Now returns a SoupAddress directly rather than a random handle, and the caller can just use g_object_unref to cancel the lookup. Also, the callback now uses a SoupKnownErrorCode rather than a special-purpose address-lookup error code. (soup_address_new_cancel): No longer needed. (soup_address_new_sync): Removed (soup_address_new_any): Replaces soup_address_ipv4_any and soup_address_ipv6_any. (soup_address_get_name, etc): Gone. Use soup_address_resolve() now. (soup_address_get_physical): Renamed from soup_address_get_canonical_name. (soup_address_get_sockaddr): Replaces soup_address_make_sockaddr() * libsoup/soup-socket.c: Update for SoupAddress changes and make similar changes here. (soup_socket_new): Just creates a generic SoupSocket now. (soup_socket_connect): Client setup (soup_socket_listen): Server setup. Now also sets up an iochannel listening for connects and emits a "new_connection" signal as they come in. (soup_socket_start_ssl): Turns on SSL. (soup_socket_client_new, soup_socket_server_new): Utility functions that wrap the above. (soup_socket_new_cancel, soup_socket_new_sync): Gone (soup_socket_server_accept, soup_socket_server_try_accept): No longer needed. (soup_socket_get_iochannel): No longer adds a ref when returning the iochannel. Also, we set it to "close_on_unref" so that if a caller adds a ref to it, the connection will actually remain open even after the SoupSocket is destroyed. (soup_socket_get_local_address, soup_socket_get_remote_address): Let the caller get both of these. * libsoup/soup-connection.c: Don't keep a private copy of the socket's iochannel. (soup_connection_new): Don't need to set socket options here. SoupSocket does it. (soup_connection_start_ssl): Just call soup_socket_start_ssl. (soup_connection_get_iochannel): Just return the socket's iochannel (and don't ref it) * libsoup/soup-error.c: add SOUP_ERROR_CANT_RESOLVE and SOUP_ERROR_CANT_RESOLVE_PROXY * libsoup/soup-dns.c (soup_ntop): Make the address arg const. Remove the "FIXME add a CANT_RESOLVE error" and return SOUP_ERROR_CANT_RESOLVE instead. * libsoup/soup-server.c: Update for socket/address changes. Don't poke into SoupSocket's private fields. (soup_server_run_async): Just connect to the socket's "new_connection" signal. * libsoup/soup-context.c (try_create_connection, soup_context_connect_cb): Update for socket changes. Replace SOUP_CONNECT_ERROR codes with plain SOUP_ERROR codes. * libsoup/soup-misc.c (soup_signal_connect_once): Utility function to connect to a signal handler and connect another function to clean up the first signal handler after its first invocation. (Lets us use signals to replace one-off callbacks.) * libsoup/soup-private.h: Remove SoupSocketPrivate since it is actually private now. (struct _SoupServer): Remove accept_tag. * libsoup/soup-queue.c (soup_queue_read_done_cb, start_request): Don't unref the iochannel. (soup_queue_connect_cb): Takes a SoupKnownErrorCode now. * libsoup/soup-socks.c: Update for socket/address changes * tests/simple-httpd.c (main): s/SOUP_SERVER_ANY_PORT/SOUP_ADDRESS_ANY_PORT/ * tests/simple-proxy.c (main): Likewise * tests/timeserver.c: Update for SoupSocket's "new_connection" signal, and for SoupAddress changes.
Diffstat (limited to 'libsoup/soup-address.h')
-rw-r--r--libsoup/soup-address.h85
1 files changed, 32 insertions, 53 deletions
diff --git a/libsoup/soup-address.h b/libsoup/soup-address.h
index 1c2b9f85..5de2b091 100644
--- a/libsoup/soup-address.h
+++ b/libsoup/soup-address.h
@@ -10,6 +10,8 @@
#include <sys/types.h>
#include <sys/socket.h>
+#include <libsoup/soup-error.h>
+
#define SOUP_TYPE_ADDRESS (soup_address_get_type ())
#define SOUP_ADDRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_ADDRESS, SoupAddress))
#define SOUP_ADDRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_ADDRESS, SoupAddressClass))
@@ -28,64 +30,41 @@ typedef struct {
typedef struct {
GObjectClass parent_class;
+ /* signals */
+ void (*dns_result) (SoupAddress *addr, SoupKnownErrorCode);
} SoupAddressClass;
-GType soup_address_get_type (void);
-
-
-typedef gpointer SoupAddressNewId;
-
typedef enum {
- SOUP_ADDRESS_STATUS_OK,
- SOUP_ADDRESS_STATUS_ERROR
-} SoupAddressStatus;
-
-typedef void (*SoupAddressNewFn) (SoupAddress *inetaddr,
- SoupAddressStatus status,
- gpointer user_data);
-
-SoupAddressNewId soup_address_new (const char *name,
- SoupAddressNewFn func,
- gpointer data);
-
-void soup_address_new_cancel (SoupAddressNewId id);
-
-SoupAddress *soup_address_new_sync (const char *name);
-
-SoupAddress *soup_address_ipv4_any (void);
-SoupAddress *soup_address_ipv6_any (void);
+ SOUP_ADDRESS_FAMILY_IPV4 = AF_INET,
+#ifdef AF_INET6
+ SOUP_ADDRESS_FAMILY_IPV6 = AF_INET6
+#else
+ SOUP_ADDRESS_FAMILY_IPV6 = -1
+#endif
+} SoupAddressFamily;
+#define SOUP_ADDRESS_ANY_PORT 0
-typedef gpointer SoupAddressGetNameId;
-
-typedef void (*SoupAddressGetNameFn) (SoupAddress *inetaddr,
- SoupAddressStatus status,
- const char *name,
- gpointer user_data);
-
-SoupAddressGetNameId
- soup_address_get_name (SoupAddress *addr,
- SoupAddressGetNameFn func,
- gpointer data);
-
-void soup_address_get_name_cancel (SoupAddressGetNameId id);
-
-const char *soup_address_get_name_sync (SoupAddress *addr);
-
-char *soup_address_get_canonical_name (SoupAddress *addr);
-
-
-SoupAddress *soup_address_new_from_sockaddr (struct sockaddr *sa,
- guint *port);
-
-void soup_address_make_sockaddr (SoupAddress *addr,
- guint port,
- struct sockaddr **sa,
- int *len);
-
-guint soup_address_hash (const gpointer p);
+GType soup_address_get_type (void);
-gint soup_address_equal (const gpointer p1,
- const gpointer p2);
+SoupAddress *soup_address_new (const char *name,
+ guint port);
+SoupAddress *soup_address_new_from_sockaddr (struct sockaddr *sa,
+ int len);
+SoupAddress *soup_address_new_any (SoupAddressFamily family,
+ guint port);
+
+typedef void (*SoupAddressCallback) (SoupAddress *addr,
+ SoupKnownErrorCode status,
+ gpointer data);
+void soup_address_resolve (SoupAddress *addr,
+ SoupAddressCallback cb,
+ gpointer data);
+
+const char *soup_address_get_name (SoupAddress *addr);
+struct sockaddr *soup_address_get_sockaddr (SoupAddress *addr,
+ int *len);
+const char *soup_address_get_physical (SoupAddress *addr);
+guint soup_address_get_port (SoupAddress *addr);
#endif /* SOUP_ADDRESS_H */