-rw-r--r-- | lib/discovery.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc index 3b90977..d1989ec 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -1,77 +1,78 @@ | |||
1 | #include <list> | 1 | #include <list> |
2 | #include <opkele/curl.h> | 2 | #include <opkele/curl.h> |
3 | #include <opkele/expat.h> | 3 | #include <opkele/expat.h> |
4 | #include <opkele/uris.h> | 4 | #include <opkele/uris.h> |
5 | #include <opkele/discovery.h> | 5 | #include <opkele/discovery.h> |
6 | #include <opkele/exception.h> | 6 | #include <opkele/exception.h> |
7 | #include <opkele/util.h> | 7 | #include <opkele/util.h> |
8 | #include <opkele/tidy.h> | ||
9 | #include <opkele/data.h> | 8 | #include <opkele/data.h> |
10 | #include <opkele/debug.h> | 9 | #include <opkele/debug.h> |
11 | 10 | ||
12 | #include "config.h" | 11 | #include "config.h" |
13 | 12 | ||
13 | #include <opkele/tidy.h> | ||
14 | |||
14 | #define XRDS_HEADER "X-XRDS-Location" | 15 | #define XRDS_HEADER "X-XRDS-Location" |
15 | #define CT_HEADER "Content-Type" | 16 | #define CT_HEADER "Content-Type" |
16 | 17 | ||
17 | namespace opkele { | 18 | namespace opkele { |
18 | using std::list; | 19 | using std::list; |
19 | using xrd::XRD_t; | 20 | using xrd::XRD_t; |
20 | using xrd::service_t; | 21 | using xrd::service_t; |
21 | 22 | ||
22 | /* TODO: the whole discovery thing needs cleanup and optimization due to | 23 | /* TODO: the whole discovery thing needs cleanup and optimization due to |
23 | * many changes of concept. */ | 24 | * many changes of concept. */ |
24 | 25 | ||
25 | static const size_t max_html = 16384; | 26 | static const size_t max_html = 16384; |
26 | 27 | ||
27 | static const struct service_type_t { | 28 | static const struct service_type_t { |
28 | const char *uri; | 29 | const char *uri; |
29 | const char *forceid; | 30 | const char *forceid; |
30 | } op_service_types[] = { | 31 | } op_service_types[] = { |
31 | { STURI_OPENID20_OP, IDURI_SELECT20 }, | 32 | { STURI_OPENID20_OP, IDURI_SELECT20 }, |
32 | { STURI_OPENID20, 0 }, | 33 | { STURI_OPENID20, 0 }, |
33 | { STURI_OPENID11, 0 }, | 34 | { STURI_OPENID11, 0 }, |
34 | { STURI_OPENID10, 0 } | 35 | { STURI_OPENID10, 0 } |
35 | }; | 36 | }; |
36 | enum { | 37 | enum { |
37 | st_index_1 = 2, st_index_2 = 1 | 38 | st_index_1 = 2, st_index_2 = 1 |
38 | }; | 39 | }; |
39 | 40 | ||
40 | 41 | ||
41 | static inline bool is_qelement(const XML_Char *n,const char *qen) { | 42 | static inline bool is_qelement(const XML_Char *n,const char *qen) { |
42 | return !strcasecmp(n,qen); | 43 | return !strcasecmp(n,qen); |
43 | } | 44 | } |
44 | static inline bool is_element(const XML_Char *n,const char *en) { | 45 | static inline bool is_element(const XML_Char *n,const char *en) { |
45 | if(!strcasecmp(n,en)) return true; | 46 | if(!strcasecmp(n,en)) return true; |
46 | int nl = strlen(n), enl = strlen(en); | 47 | int nl = strlen(n), enl = strlen(en); |
47 | if( (nl>=(enl+1)) && n[nl-enl-1]=='\t' | 48 | if( (nl>=(enl+1)) && n[nl-enl-1]=='\t' |
48 | && !strcasecmp(&n[nl-enl],en) ) | 49 | && !strcasecmp(&n[nl-enl],en) ) |
49 | return true; | 50 | return true; |
50 | return false; | 51 | return false; |
51 | } | 52 | } |
52 | 53 | ||
53 | static long element_priority(const XML_Char **a) { | 54 | static long element_priority(const XML_Char **a) { |
54 | for(;*a;++a) | 55 | for(;*a;++a) |
55 | if(!strcasecmp(*(a++),"priority")) { | 56 | if(!strcasecmp(*(a++),"priority")) { |
56 | long rv; | 57 | long rv; |
57 | return (sscanf(*a,"%ld",&rv)==1)?rv:-1; | 58 | return (sscanf(*a,"%ld",&rv)==1)?rv:-1; |
58 | } | 59 | } |
59 | return -1; | 60 | return -1; |
60 | } | 61 | } |
61 | /* TODO: ideally all attributes should be | 62 | /* TODO: ideally all attributes should be |
62 | * retrieved in one run */ | 63 | * retrieved in one run */ |
63 | static const char *element_attr(const XML_Char **a, const char *at) { | 64 | static const char *element_attr(const XML_Char **a, const char *at) { |
64 | for(;*a;++a) | 65 | for(;*a;++a) |
65 | if(!strcasecmp(*(a++),at)) { | 66 | if(!strcasecmp(*(a++),at)) { |
66 | return *a; | 67 | return *a; |
67 | } | 68 | } |
68 | return 0; | 69 | return 0; |
69 | } | 70 | } |
70 | 71 | ||
71 | class idigger_t : public util::curl_t, public util::expat_t { | 72 | class idigger_t : public util::curl_t, public util::expat_t { |
72 | public: | 73 | public: |
73 | string xri_proxy; | 74 | string xri_proxy; |
74 | 75 | ||
75 | enum { | 76 | enum { |
76 | xmode_html = 1, xmode_xrd = 2, xmode_cid = 4, | 77 | xmode_html = 1, xmode_xrd = 2, xmode_cid = 4, |
77 | xmode_noredirs = 8 | 78 | xmode_noredirs = 8 |