-void rss_do_fetching(char *url, char *rooms) {
- char buf[1024];
- char rsshost[1024];
- int rssport = 80;
- char rssurl[1024];
- struct rss_item ri;
- XML_Parser xp;
- int sock = (-1);
- int got_bytes = (-1);
- int redirect_count = 0;
-
- /* Parse the URL */
- if (parse_url(url, rsshost, &rssport, rssurl) != 0) {
- lprintf(CTDL_ALERT, "Invalid URL: %s\n", url);
- }
-
- xp = XML_ParserCreateNS("UTF-8", ':');
- if (!xp) {
- lprintf(CTDL_ALERT, "Cannot create XML parser!\n");
- return;
- }
-
- 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);