+/*
+ * Wrapper for curl_easy_init() that includes the options common to all calls
+ * used in this module.
+ */
+CURL *ctdl_openid_curl_easy_init(char *errmsg) {
+ CURL *curl;
+
+ curl = curl_easy_init();
+ if (!curl) {
+ return(curl);
+ }
+
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
+
+ if (errmsg) {
+ curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errmsg);
+ }
+ curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
+#ifdef CURLOPT_HTTP_CONTENT_DECODING
+ curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 1);
+ curl_easy_setopt(curl, CURLOPT_ENCODING, "");
+#endif
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, CITADEL);
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30); /* die after 30 seconds */
+
+ if (
+ (!IsEmptyStr(config.c_ip_addr))
+ && (strcmp(config.c_ip_addr, "*"))
+ && (strcmp(config.c_ip_addr, "::"))
+ && (strcmp(config.c_ip_addr, "0.0.0.0"))
+ ) {
+ curl_easy_setopt(curl, CURLOPT_INTERFACE, config.c_ip_addr);
+ }
+
+ return(curl);
+}
+
+
+struct xrds {
+ StrBuf *CharData;
+ int nesting_level;
+ int in_xrd;
+ int current_service_priority;
+ int selected_service_priority;
+ StrBuf *current_service_uri;
+ StrBuf *selected_service_uri;
+ int current_service_is_oid2auth;
+};
+
+
+void xrds_xml_start(void *data, const char *supplied_el, const char **attr) {
+ struct xrds *xrds = (struct xrds *) data;
+ int i;
+
+ ++xrds->nesting_level;
+
+ if (!strcasecmp(supplied_el, "XRD")) {
+ ++xrds->in_xrd;
+ }
+
+ else if (!strcasecmp(supplied_el, "service")) {
+ xrds->current_service_priority = 0;
+ xrds->current_service_is_oid2auth = 0;
+ for (i=0; attr[i] != NULL; i+=2) {
+ if (!strcasecmp(attr[i], "priority")) {
+ xrds->current_service_priority = atoi(attr[i+1]);