Git init
[profile/ivi/libsoup2.4.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 <glib-object.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 GSource           *soup_add_completion       (GMainContext *async_context,
23                                               GSourceFunc   function,
24                                               gpointer      data);
25 GSource           *soup_add_timeout          (GMainContext *async_context,
26                                               guint         interval,
27                                               GSourceFunc   function,
28                                               gpointer      data);
29
30 /* Misc utils */
31
32 guint              soup_str_case_hash        (gconstpointer key);
33 gboolean           soup_str_case_equal       (gconstpointer v1,
34                                               gconstpointer v2);
35
36 #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))))
37
38 /* character classes */
39
40 extern const char soup_char_attributes[];
41 #define SOUP_CHAR_URI_PERCENT_ENCODED 0x01
42 #define SOUP_CHAR_URI_GEN_DELIMS      0x02
43 #define SOUP_CHAR_URI_SUB_DELIMS      0x04
44 #define SOUP_CHAR_HTTP_SEPARATOR      0x08
45 #define SOUP_CHAR_HTTP_CTL            0x10
46
47 #define soup_char_is_uri_percent_encoded(ch) (soup_char_attributes[(guchar)ch] & SOUP_CHAR_URI_PERCENT_ENCODED)
48 #define soup_char_is_uri_gen_delims(ch)      (soup_char_attributes[(guchar)ch] & SOUP_CHAR_URI_GEN_DELIMS)
49 #define soup_char_is_uri_sub_delims(ch)      (soup_char_attributes[(guchar)ch] & SOUP_CHAR_URI_SUB_DELIMS)
50 #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)))
51 #define soup_char_is_token(ch)               (!(soup_char_attributes[(guchar)ch] & (SOUP_CHAR_HTTP_SEPARATOR | SOUP_CHAR_HTTP_CTL)))
52
53 /* SSL stuff */
54
55 extern const gboolean soup_ssl_supported;
56
57 #define SOUP_SSL_ERROR soup_ssl_error_quark()
58
59 GQuark soup_ssl_error_quark (void);
60
61 typedef enum {
62         SOUP_SSL_ERROR_HANDSHAKE_NEEDS_READ,
63         SOUP_SSL_ERROR_HANDSHAKE_NEEDS_WRITE,
64         SOUP_SSL_ERROR_CERTIFICATE,
65         SOUP_SSL_ERROR_HANDSHAKE_FAILED
66 } SoupSSLError;
67
68 typedef enum {
69         SOUP_CONNECTION_NEW,
70         SOUP_CONNECTION_CONNECTING,
71         SOUP_CONNECTION_IDLE,
72         SOUP_CONNECTION_IN_USE,
73         SOUP_CONNECTION_REMOTE_DISCONNECTED,
74         SOUP_CONNECTION_DISCONNECTED
75 } SoupConnectionState;
76
77 G_END_DECLS
78
79 #endif /* SOUP_MISC_H */