- memset(&ri, 0, sizeof(struct rss_item));
- ri.roomlist = rooms;
- XML_SetElementHandler(xp, rss_xml_start, rss_xml_end);
- XML_SetCharacterDataHandler(xp, rss_xml_chardata);
- XML_SetUserData(xp, &ri);
-
-retry: lprintf(CTDL_NOTICE, "Connecting to <%s>\n", rsshost);
- sprintf(buf, "%d", rssport);
- sock = sock_connect(rsshost, buf, "tcp");
- if (sock >= 0) {
- lprintf(CTDL_DEBUG, "Connected!\n");
-
- snprintf(buf, sizeof buf, "GET %s HTTP/1.0", rssurl);
- lprintf(CTDL_DEBUG, "<%s\n", buf);
- sock_puts(sock, buf);
-
- snprintf(buf, sizeof buf, "Host: %s", rsshost);
- lprintf(CTDL_DEBUG, "<%s\n", buf);
- sock_puts(sock, buf);
-
- snprintf(buf, sizeof buf, "User-Agent: %s", CITADEL);
- lprintf(CTDL_DEBUG, "<%s\n", buf);
- sock_puts(sock, buf);
-
- snprintf(buf, sizeof buf, "Accept: */*");
- lprintf(CTDL_DEBUG, "<%s\n", buf);
- sock_puts(sock, buf);
-
- sock_puts(sock, "");
-
- if (sock_getln(sock, buf, sizeof buf) >= 0) {
- lprintf(CTDL_DEBUG, ">%s\n", buf);
- remove_token(buf, 0, ' ');
-
- /* 200 OK */
- if (buf[0] == '2') {
-
- while (got_bytes = sock_getln(sock, buf, sizeof buf),
- (got_bytes >= 0 && (strcmp(buf, "")) && (strcmp(buf, "\r"))) ) {
- /* discard headers */
- }
-
- while (got_bytes = sock_read(sock, buf, sizeof buf, 0),
- ((got_bytes>=0) && (ri.done_parsing == 0)) ) {
- XML_Parse(xp, buf, got_bytes, 0);
- }
- if (ri.done_parsing == 0) XML_Parse(xp, "", 0, 1);
- }