1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; 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 "soup-types.h"
10 #include "soup-message.h"
11 #include "soup-message-headers.h"
12 
13 G_BEGIN_DECLS
14 
15 /* Non-default-GMainContext operations */
16 void               soup_add_completion	     (GMainContext *async_context,
17 					      GSourceFunc   function,
18 					      gpointer      data);
19 GSource           *soup_add_completion_reffed (GMainContext   *async_context,
20                                                GSourceFunc     function,
21                                                gpointer        data,
22                                                GDestroyNotify  dnotify);
23 GSource           *soup_add_timeout          (GMainContext *async_context,
24 					      guint         interval,
25 					      GSourceFunc   function,
26 					      gpointer      data);
27 
28 /* Misc utils */
29 
30 guint              soup_str_case_hash        (gconstpointer key);
31 gboolean           soup_str_case_equal       (gconstpointer v1,
32 					      gconstpointer v2);
33 
34 /* character classes */
35 
36 extern const char soup_char_attributes[];
37 #define SOUP_CHAR_URI_PERCENT_ENCODED 0x01
38 #define SOUP_CHAR_URI_GEN_DELIMS      0x02
39 #define SOUP_CHAR_URI_SUB_DELIMS      0x04
40 #define SOUP_CHAR_HTTP_SEPARATOR      0x08
41 #define SOUP_CHAR_HTTP_CTL            0x10
42 
43 #define soup_char_is_uri_percent_encoded(ch) (soup_char_attributes[(guchar)ch] & SOUP_CHAR_URI_PERCENT_ENCODED)
44 #define soup_char_is_uri_gen_delims(ch)      (soup_char_attributes[(guchar)ch] & SOUP_CHAR_URI_GEN_DELIMS)
45 #define soup_char_is_uri_sub_delims(ch)      (soup_char_attributes[(guchar)ch] & SOUP_CHAR_URI_SUB_DELIMS)
46 #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)))
47 #define soup_char_is_token(ch)               (!(soup_char_attributes[(guchar)ch] & (SOUP_CHAR_HTTP_SEPARATOR | SOUP_CHAR_HTTP_CTL)))
48 
49 /* At some point it might be possible to mark additional methods
50  * safe or idempotent...
51  */
52 #define SOUP_METHOD_IS_SAFE(method) (method == SOUP_METHOD_GET || \
53 				     method == SOUP_METHOD_HEAD || \
54 				     method == SOUP_METHOD_OPTIONS || \
55 				     method == SOUP_METHOD_PROPFIND || \
56 				     method == SOUP_METHOD_TRACE)
57 
58 #define SOUP_METHOD_IS_IDEMPOTENT(method) (method == SOUP_METHOD_GET || \
59 					   method == SOUP_METHOD_HEAD || \
60 					   method == SOUP_METHOD_OPTIONS || \
61 					   method == SOUP_METHOD_PROPFIND || \
62 					   method == SOUP_METHOD_TRACE || \
63 					   method == SOUP_METHOD_PUT || \
64 					   method == SOUP_METHOD_DELETE)
65 
66 guint soup_message_headers_get_ranges_internal (SoupMessageHeaders  *hdrs,
67 						goffset              total_length,
68 						gboolean             check_satisfiable,
69 						SoupRange          **ranges,
70 						int                 *length);
71 
72 gboolean           soup_host_matches_host    (const gchar *host,
73 					      const gchar *compare_with);
74 
75 gchar *soup_get_accept_languages_from_system (void);
76 
77 const char *soup_http_version_to_string (SoupHTTPVersion version);
78 
79 G_END_DECLS
80 
81 #endif /* __SOUP_MISC_H__ */
82