SOUP_URI_VALID_FOR_HTTP: update to check uri->path too
[platform/upstream/libsoup.git] / libsoup / soup-uri.h
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 GType     soup_uri_get_type          (void);
32 #define SOUP_TYPE_URI (soup_uri_get_type ())
33
34 #define SOUP_URI_SCHEME_HTTP  _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTP, "http")
35 #define SOUP_URI_SCHEME_HTTPS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTPS, "https")
36 extern gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
37
38 SoupURI  *soup_uri_new_with_base         (SoupURI    *base,
39                                           const char *uri_string);
40 SoupURI  *soup_uri_new                   (const char *uri_string);
41
42 char     *soup_uri_to_string             (SoupURI    *uri, 
43                                           gboolean    just_path_and_query);
44
45 SoupURI  *soup_uri_copy                  (SoupURI    *uri);
46
47 gboolean  soup_uri_equal                 (SoupURI    *uri1, 
48                                           SoupURI    *uri2);
49
50 void      soup_uri_free                  (SoupURI    *uri);
51
52 char     *soup_uri_encode                (const char *part,
53                                           const char *escape_extra);
54 char     *soup_uri_decode                (const char *part);
55 char     *soup_uri_normalize             (const char *part,
56                                           const char *unescape_extra);
57
58 gboolean  soup_uri_uses_default_port     (SoupURI    *uri);
59
60 void      soup_uri_set_scheme            (SoupURI    *uri,
61                                           const char *scheme);
62 void      soup_uri_set_user              (SoupURI    *uri,
63                                           const char *user);
64 void      soup_uri_set_password          (SoupURI    *uri,
65                                           const char *password);
66 void      soup_uri_set_host              (SoupURI    *uri,
67                                           const char *host);
68 void      soup_uri_set_port              (SoupURI    *uri,
69                                           guint       port);
70 void      soup_uri_set_path              (SoupURI    *uri,
71                                           const char *path);
72 void      soup_uri_set_query             (SoupURI    *uri,
73                                           const char *query);
74 void      soup_uri_set_query_from_form   (SoupURI    *uri,
75                                           GHashTable *form);
76 void      soup_uri_set_query_from_fields (SoupURI    *uri,
77                                           const char *first_field,
78                                           ...) G_GNUC_NULL_TERMINATED;
79 void      soup_uri_set_fragment          (SoupURI    *uri,
80                                           const char *fragment);
81
82 SoupURI  *soup_uri_copy_host             (SoupURI    *uri);
83 guint     soup_uri_host_hash             (gconstpointer key);
84 gboolean  soup_uri_host_equal            (gconstpointer v1,
85                                           gconstpointer v2);
86
87 #define   SOUP_URI_VALID_FOR_HTTP(uri) ((uri) && ((uri)->scheme == SOUP_URI_SCHEME_HTTP || (uri)->scheme == SOUP_URI_SCHEME_HTTPS) && (uri)->host && (uri)->path)
88
89 G_END_DECLS
90
91 #endif /*SOUP_URI_H*/