Fix defines of SOUP_URI_SCHEME_FTP etc
[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 #define SOUP_URI_SCHEME_FTP   _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_FTP, "ftp")
37 #define SOUP_URI_SCHEME_FILE  _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_FILE, "file")
38 #define SOUP_URI_SCHEME_DATA  _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_DATA, "data")
39 extern gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
40 extern gpointer _SOUP_URI_SCHEME_FTP;
41 extern gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA;
42
43 SoupURI  *soup_uri_new_with_base         (SoupURI    *base,
44                                           const char *uri_string);
45 SoupURI  *soup_uri_new                   (const char *uri_string);
46
47 char     *soup_uri_to_string             (SoupURI    *uri, 
48                                           gboolean    just_path_and_query);
49
50 SoupURI  *soup_uri_copy                  (SoupURI    *uri);
51
52 gboolean  soup_uri_equal                 (SoupURI    *uri1, 
53                                           SoupURI    *uri2);
54
55 void      soup_uri_free                  (SoupURI    *uri);
56
57 char     *soup_uri_encode                (const char *part,
58                                           const char *escape_extra);
59 char     *soup_uri_decode                (const char *part);
60 char     *soup_uri_normalize             (const char *part,
61                                           const char *unescape_extra);
62
63 gboolean  soup_uri_uses_default_port     (SoupURI    *uri);
64
65 void      soup_uri_set_scheme            (SoupURI    *uri,
66                                           const char *scheme);
67 void      soup_uri_set_user              (SoupURI    *uri,
68                                           const char *user);
69 void      soup_uri_set_password          (SoupURI    *uri,
70                                           const char *password);
71 void      soup_uri_set_host              (SoupURI    *uri,
72                                           const char *host);
73 void      soup_uri_set_port              (SoupURI    *uri,
74                                           guint       port);
75 void      soup_uri_set_path              (SoupURI    *uri,
76                                           const char *path);
77 void      soup_uri_set_query             (SoupURI    *uri,
78                                           const char *query);
79 void      soup_uri_set_query_from_form   (SoupURI    *uri,
80                                           GHashTable *form);
81 void      soup_uri_set_query_from_fields (SoupURI    *uri,
82                                           const char *first_field,
83                                           ...) G_GNUC_NULL_TERMINATED;
84 void      soup_uri_set_fragment          (SoupURI    *uri,
85                                           const char *fragment);
86
87 SoupURI  *soup_uri_copy_host             (SoupURI    *uri);
88 guint     soup_uri_host_hash             (gconstpointer key);
89 gboolean  soup_uri_host_equal            (gconstpointer v1,
90                                           gconstpointer v2);
91
92 #define   SOUP_URI_VALID_FOR_HTTP(uri) ((uri) && ((uri)->scheme == SOUP_URI_SCHEME_HTTP || (uri)->scheme == SOUP_URI_SCHEME_HTTPS) && (uri)->host && (uri)->path)
93
94 G_END_DECLS
95
96 #endif /*SOUP_URI_H*/