+/*
+ * Attempt to perform YADIS discovery.
+ * If successful, returns nonzero and fills the session's claimed ID blah FIXME this comment
+ * If YADIS fails, returns 0 and does nothing else.
+ */
+int perform_yadis_discovery(StrBuf *YadisURL) {
+ int docbytes = (-1);
+ StrBuf *ReplyBuf = NULL;
+
+ docbytes = fetch_http(YadisURL, &ReplyBuf);
+ if (docbytes < 0) {
+ return(0);
+ }
+ if (docbytes == 0) {
+ FreeStrBuf(&ReplyBuf);
+ return(0);
+ }
+
+ /* If we get to this point, something was retrieved.
+ * Feed it to the XML parser to see if it's an XRDS document.
+ */
+ XML_Parser xp = XML_ParserCreateNS(NULL, ':');
+ if (xp) {
+ XML_Parse(xp, ChrPtr(ReplyBuf), docbytes, 0);
+ XML_Parse(xp, "", 0, 1);
+ XML_ParserFree(xp);
+ }
+ else {
+ syslog(LOG_ALERT, "Cannot create XML parser");
+ }
+
+ FreeStrBuf(&ReplyBuf);
+ return(0);
+}
+
+