| 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright 1999-2002 Ximian, Inc. |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | #ifndef __SOUP_URI_H__ |
| 9 | #define __SOUP_URI_H__ 1 |
| 10 | |
| 11 | #include <libsoup/soup-types.h> |
| 12 | #include <libsoup/soup-misc.h> |
| 13 | |
| 14 | G_BEGIN_DECLS |
| 15 | |
| 16 | struct _SoupURI { |
| 17 | const char *scheme; |
| 18 | |
| 19 | char *user; |
| 20 | char *password; |
| 21 | |
| 22 | char *host; |
| 23 | guint port; |
| 24 | |
| 25 | char *path; |
| 26 | char *query; |
| 27 | |
| 28 | char *fragment; |
| 29 | }; |
| 30 | |
| 31 | SOUP_AVAILABLE_IN_2_4 |
| 32 | GType soup_uri_get_type (void); |
| 33 | #define SOUP_TYPE_URI (soup_uri_get_type ()) |
| 34 | |
| 35 | #define SOUP_URI_SCHEME_HTTP _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTP, "http") |
| 36 | #define SOUP_URI_SCHEME_HTTPS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTPS, "https") |
| 37 | #define SOUP_URI_SCHEME_FTP _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_FTP, "ftp") |
| 38 | #define SOUP_URI_SCHEME_FILE _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_FILE, "file") |
| 39 | #define SOUP_URI_SCHEME_DATA _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_DATA, "data") |
| 40 | #define SOUP_URI_SCHEME_RESOURCE _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_RESOURCE, "resource") |
| 41 | #define SOUP_URI_SCHEME_WS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_WS, "ws") |
| 42 | #define SOUP_URI_SCHEME_WSS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_WSS, "wss") |
| 43 | |
| 44 | SOUP_VAR gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS; |
| 45 | SOUP_VAR gpointer _SOUP_URI_SCHEME_FTP; |
| 46 | SOUP_VAR gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA, _SOUP_URI_SCHEME_RESOURCE; |
| 47 | SOUP_VAR gpointer _SOUP_URI_SCHEME_WS, _SOUP_URI_SCHEME_WSS; |
| 48 | |
| 49 | SOUP_AVAILABLE_IN_2_4 |
| 50 | SoupURI *soup_uri_new_with_base (SoupURI *base, |
| 51 | const char *uri_string); |
| 52 | SOUP_AVAILABLE_IN_2_4 |
| 53 | SoupURI *soup_uri_new (const char *uri_string); |
| 54 | |
| 55 | SOUP_AVAILABLE_IN_2_4 |
| 56 | char *soup_uri_to_string (SoupURI *uri, |
| 57 | gboolean just_path_and_query); |
| 58 | |
| 59 | SOUP_AVAILABLE_IN_2_4 |
| 60 | SoupURI *soup_uri_copy (SoupURI *uri); |
| 61 | |
| 62 | SOUP_AVAILABLE_IN_2_4 |
| 63 | gboolean soup_uri_equal (SoupURI *uri1, |
| 64 | SoupURI *uri2); |
| 65 | |
| 66 | SOUP_AVAILABLE_IN_2_4 |
| 67 | void soup_uri_free (SoupURI *uri); |
| 68 | |
| 69 | SOUP_AVAILABLE_IN_2_4 |
| 70 | char *soup_uri_encode (const char *part, |
| 71 | const char *); |
| 72 | SOUP_AVAILABLE_IN_2_4 |
| 73 | char *soup_uri_decode (const char *part); |
| 74 | SOUP_AVAILABLE_IN_2_4 |
| 75 | char *soup_uri_normalize (const char *part, |
| 76 | const char *); |
| 77 | |
| 78 | SOUP_AVAILABLE_IN_2_4 |
| 79 | gboolean soup_uri_uses_default_port (SoupURI *uri); |
| 80 | |
| 81 | SOUP_AVAILABLE_IN_2_32 |
| 82 | const char *soup_uri_get_scheme (SoupURI *uri); |
| 83 | SOUP_AVAILABLE_IN_2_4 |
| 84 | void soup_uri_set_scheme (SoupURI *uri, |
| 85 | const char *scheme); |
| 86 | SOUP_AVAILABLE_IN_2_32 |
| 87 | const char *soup_uri_get_user (SoupURI *uri); |
| 88 | SOUP_AVAILABLE_IN_2_4 |
| 89 | void soup_uri_set_user (SoupURI *uri, |
| 90 | const char *user); |
| 91 | SOUP_AVAILABLE_IN_2_32 |
| 92 | const char *soup_uri_get_password (SoupURI *uri); |
| 93 | SOUP_AVAILABLE_IN_2_4 |
| 94 | void soup_uri_set_password (SoupURI *uri, |
| 95 | const char *password); |
| 96 | SOUP_AVAILABLE_IN_2_32 |
| 97 | const char *soup_uri_get_host (SoupURI *uri); |
| 98 | SOUP_AVAILABLE_IN_2_4 |
| 99 | void soup_uri_set_host (SoupURI *uri, |
| 100 | const char *host); |
| 101 | SOUP_AVAILABLE_IN_2_32 |
| 102 | guint soup_uri_get_port (SoupURI *uri); |
| 103 | SOUP_AVAILABLE_IN_2_4 |
| 104 | void soup_uri_set_port (SoupURI *uri, |
| 105 | guint port); |
| 106 | SOUP_AVAILABLE_IN_2_32 |
| 107 | const char *soup_uri_get_path (SoupURI *uri); |
| 108 | SOUP_AVAILABLE_IN_2_4 |
| 109 | void soup_uri_set_path (SoupURI *uri, |
| 110 | const char *path); |
| 111 | SOUP_AVAILABLE_IN_2_32 |
| 112 | const char *soup_uri_get_query (SoupURI *uri); |
| 113 | SOUP_AVAILABLE_IN_2_4 |
| 114 | void soup_uri_set_query (SoupURI *uri, |
| 115 | const char *query); |
| 116 | SOUP_AVAILABLE_IN_2_4 |
| 117 | void soup_uri_set_query_from_form (SoupURI *uri, |
| 118 | GHashTable *form); |
| 119 | SOUP_AVAILABLE_IN_2_4 |
| 120 | void soup_uri_set_query_from_fields (SoupURI *uri, |
| 121 | const char *first_field, |
| 122 | ...) G_GNUC_NULL_TERMINATED; |
| 123 | SOUP_AVAILABLE_IN_2_32 |
| 124 | const char *soup_uri_get_fragment (SoupURI *uri); |
| 125 | SOUP_AVAILABLE_IN_2_4 |
| 126 | void soup_uri_set_fragment (SoupURI *uri, |
| 127 | const char *fragment); |
| 128 | |
| 129 | SOUP_AVAILABLE_IN_2_28 |
| 130 | SoupURI *soup_uri_copy_host (SoupURI *uri); |
| 131 | SOUP_AVAILABLE_IN_2_28 |
| 132 | guint soup_uri_host_hash (gconstpointer key); |
| 133 | SOUP_AVAILABLE_IN_2_28 |
| 134 | gboolean soup_uri_host_equal (gconstpointer v1, |
| 135 | gconstpointer v2); |
| 136 | |
| 137 | #define SOUP_URI_IS_VALID(uri) ((uri) && (uri)->scheme && (uri)->path) |
| 138 | #define SOUP_URI_VALID_FOR_HTTP(uri) ((uri) && ((uri)->scheme == SOUP_URI_SCHEME_HTTP || (uri)->scheme == SOUP_URI_SCHEME_HTTPS) && (uri)->host && (uri)->path) |
| 139 | |
| 140 | G_END_DECLS |
| 141 | |
| 142 | #endif /* __SOUP_URI_H__ */ |
| 143 | |