summaryrefslogtreecommitdiffabout
path: root/lib/discovery.cc
authorMichael Krelin <hacker@klever.net>2008-06-25 21:24:53 (UTC)
committer Michael Krelin <hacker@klever.net>2008-06-25 21:24:53 (UTC)
commit2744ea9808c3a6c50f8be78a9a71f6d3b2ba7e00 (patch) (side-by-side diff)
treea9c124efee2b4edbeaeb646f1b94928bdc4e8c4c /lib/discovery.cc
parent04aac0e097992df01e17fbbb62a5a7d9682bcea9 (diff)
downloadlibopkele-2744ea9808c3a6c50f8be78a9a71f6d3b2ba7e00.zip
libopkele-2744ea9808c3a6c50f8be78a9a71f6d3b2ba7e00.tar.gz
libopkele-2744ea9808c3a6c50f8be78a9a71f6d3b2ba7e00.tar.bz2
improved detection of htmltidy for debian and co.
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'lib/discovery.cc') (more/less context) (ignore 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,109 +1,110 @@
#include <list>
#include <opkele/curl.h>
#include <opkele/expat.h>
#include <opkele/uris.h>
#include <opkele/discovery.h>
#include <opkele/exception.h>
#include <opkele/util.h>
-#include <opkele/tidy.h>
#include <opkele/data.h>
#include <opkele/debug.h>
#include "config.h"
+#include <opkele/tidy.h>
+
#define XRDS_HEADER "X-XRDS-Location"
#define CT_HEADER "Content-Type"
namespace opkele {
using std::list;
using xrd::XRD_t;
using xrd::service_t;
/* TODO: the whole discovery thing needs cleanup and optimization due to
* many changes of concept. */
static const size_t max_html = 16384;
static const struct service_type_t {
const char *uri;
const char *forceid;
} op_service_types[] = {
{ STURI_OPENID20_OP, IDURI_SELECT20 },
{ STURI_OPENID20, 0 },
{ STURI_OPENID11, 0 },
{ STURI_OPENID10, 0 }
};
enum {
st_index_1 = 2, st_index_2 = 1
};
static inline bool is_qelement(const XML_Char *n,const char *qen) {
return !strcasecmp(n,qen);
}
static inline bool is_element(const XML_Char *n,const char *en) {
if(!strcasecmp(n,en)) return true;
int nl = strlen(n), enl = strlen(en);
if( (nl>=(enl+1)) && n[nl-enl-1]=='\t'
&& !strcasecmp(&n[nl-enl],en) )
return true;
return false;
}
static long element_priority(const XML_Char **a) {
for(;*a;++a)
if(!strcasecmp(*(a++),"priority")) {
long rv;
return (sscanf(*a,"%ld",&rv)==1)?rv:-1;
}
return -1;
}
/* TODO: ideally all attributes should be
* retrieved in one run */
static const char *element_attr(const XML_Char **a, const char *at) {
for(;*a;++a)
if(!strcasecmp(*(a++),at)) {
return *a;
}
return 0;
}
class idigger_t : public util::curl_t, public util::expat_t {
public:
string xri_proxy;
enum {
xmode_html = 1, xmode_xrd = 2, xmode_cid = 4,
xmode_noredirs = 8
};
int xmode;
string xrds_location;
string http_content_type;
service_t html_openid1;
service_t html_openid2;
string cdata_buf;
long status_code;
string status_string;
typedef list<string> pt_stack_t;
pt_stack_t pt_stack;
int skipping;
bool parser_choked;
string save_html;
XRD_t *xrd;
service_t *xrd_service;
string* cdata;
idigger_t()
: util::curl_t(easy_init()),
util::expat_t(0),
xri_proxy(XRI_PROXY_URL) {
CURLcode r;
(r=misc_sets())
|| (r=set_write())
|| (r=set_header())
;
if(r)
throw exception_curl(OPKELE_CP_ "failed to set curly options",r);