Add SoupSession:proxy-resolver
[platform/upstream/libsoup.git] / libsoup / soup-misc.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2000-2003, Ximian, Inc.
4  */
5
6 #ifndef SOUP_MISC_H
7 #define SOUP_MISC_H 1
8
9 #include <libsoup/soup-types.h>
10
11 G_BEGIN_DECLS
12
13 /* Non-default-GMainContext operations */
14 GSource           *soup_add_io_watch         (GMainContext *async_context,
15                                               GIOChannel   *chan,
16                                               GIOCondition  condition,
17                                               GIOFunc       function,
18                                               gpointer      data);
19 GSource           *soup_add_idle             (GMainContext *async_context,
20                                               GSourceFunc   function,
21                                               gpointer      data);
22 SOUP_AVAILABLE_IN_2_24
23 GSource           *soup_add_completion       (GMainContext *async_context,
24                                               GSourceFunc   function,
25                                               gpointer      data);
26 GSource           *soup_add_timeout          (GMainContext *async_context,
27                                               guint         interval,
28                                               GSourceFunc   function,
29                                               gpointer      data);
30
31 /* Misc utils */
32
33 guint              soup_str_case_hash        (gconstpointer key);
34 gboolean           soup_str_case_equal       (gconstpointer v1,
35                                               gconstpointer v2);
36
37 #define _SOUP_ATOMIC_INTERN_STRING(variable, value) ((const char *)(g_atomic_pointer_get (&(variable)) ? (variable) : (g_atomic_pointer_set (&(variable), (gpointer)g_intern_static_string (value)), (variable))))
38
39 /* character classes */
40
41 extern const char soup_char_attributes[];
42 #define SOUP_CHAR_URI_PERCENT_ENCODED 0x01
43 #define SOUP_CHAR_URI_GEN_DELIMS      0x02
44 #define SOUP_CHAR_URI_SUB_DELIMS      0x04
45 #define SOUP_CHAR_HTTP_SEPARATOR      0x08
46 #define SOUP_CHAR_HTTP_CTL            0x10
47
48 #define soup_char_is_uri_percent_encoded(ch) (soup_char_attributes[(guchar)ch] & SOUP_CHAR_URI_PERCENT_ENCODED)
49 #define soup_char_is_uri_gen_delims(ch)      (soup_char_attributes[(guchar)ch] & SOUP_CHAR_URI_GEN_DELIMS)
50 #define soup_char_is_uri_sub_delims(ch)      (soup_char_attributes[(guchar)ch] & SOUP_CHAR_URI_SUB_DELIMS)
51 #define soup_char_is_uri_unreserved(ch)      (!(soup_char_attributes[(guchar)ch] & (SOUP_CHAR_URI_PERCENT_ENCODED | SOUP_CHAR_URI_GEN_DELIMS | SOUP_CHAR_URI_SUB_DELIMS)))
52 #define soup_char_is_token(ch)               (!(soup_char_attributes[(guchar)ch] & (SOUP_CHAR_HTTP_SEPARATOR | SOUP_CHAR_HTTP_CTL)))
53
54 /* SSL stuff */
55
56 extern const gboolean soup_ssl_supported;
57
58 /* Part of a debugging API */
59
60 typedef enum {
61         SOUP_CONNECTION_NEW,
62         SOUP_CONNECTION_CONNECTING,
63         SOUP_CONNECTION_IDLE,
64         SOUP_CONNECTION_IN_USE,
65         SOUP_CONNECTION_REMOTE_DISCONNECTED,
66         SOUP_CONNECTION_DISCONNECTED
67 } SoupConnectionState;
68
69 G_END_DECLS
70
71 #endif /* SOUP_MISC_H */