summaryrefslogtreecommitdiffabout
path: root/lib/discovery.cc
Unidiff
Diffstat (limited to 'lib/discovery.cc') (more/less context) (show whitespace changes)
-rw-r--r--lib/discovery.cc3
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,61 +1,62 @@
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
17namespace opkele { 18namespace 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