else {
MD5Init(&md5context);
if (ri->title != NULL) {
- MD5Update(&md5context, ri->title, strlen(ri->title));
+ MD5Update(&md5context, (unsigned char*)ri->title, strlen(ri->title));
}
if (ri->link != NULL) {
- MD5Update(&md5context, ri->link, strlen(ri->link));
+ MD5Update(&md5context, (unsigned char*)ri->link, strlen(ri->link));
}
MD5Final(rawdigest, &md5context);
for (i=0; i<MD5_DIGEST_LEN; i++) {
cdbut = cdb_fetch(CDB_USETABLE, utmsgid, strlen(utmsgid));
if (cdbut != NULL) {
/* Item has already been seen */
- lprintf(CTDL_DEBUG, "%s has already been seen\n", utmsgid);
+ CtdlLogPrintf(CTDL_DEBUG, "%s has already been seen\n", utmsgid);
cdb_free(cdbut);
/* rewrite the record anyway, to update the timestamp */
}
if ( (!strcasecmp(el, "rss")) || (!strcasecmp(el, "rdf")) ) {
- lprintf(CTDL_DEBUG, "End of feed detected. Closing parser.\n");
+ CtdlLogPrintf(CTDL_DEBUG, "End of feed detected. Closing parser.\n");
ri->done_parsing = 1;
}
-/*
- * Parse a URL into host, port number, and resource identifier.
- */
-int parse_url(char *url, char *hostname, int *port, char *identifier)
-{
- char protocol[1024];
- char scratch[1024];
- char *ptr = NULL;
- char *nptr = NULL;
-
- strcpy(scratch, url);
- ptr = (char *)strchr(scratch, ':');
- if (!ptr) {
- return(1); /* no protocol specified */
- }
-
- strcpy(ptr, "");
- strcpy(protocol, scratch);
- if (strcmp(protocol, "http")) {
- return(2); /* not HTTP */
- }
-
- strcpy(scratch, url);
- ptr = (char *) strstr(scratch, "//");
- if (!ptr) {
- return(3); /* no server specified */
- }
- ptr += 2;
-
- strcpy(hostname, ptr);
- nptr = (char *)strchr(ptr, ':');
- if (!nptr) {
- *port = 80; /* default */
- nptr = (char *)strchr(hostname, '/');
- }
- else {
- sscanf(nptr, ":%d", port);
- nptr = (char *)strchr(hostname, ':');
- }
-
- if (nptr) {
- *nptr = '\0';
- }
-
- nptr = (char *)strchr(ptr, '/');
-
- if (!nptr) {
- return(4); /* no url specified */
- }
-
- strcpy(identifier, nptr);
- return(0);
-}
-
-
/*
* Begin a feed parse
*/
/* Parse the URL */
if (parse_url(url, rsshost, &rssport, rssurl) != 0) {
- lprintf(CTDL_ALERT, "Invalid URL: %s\n", url);
+ CtdlLogPrintf(CTDL_ALERT, "Invalid URL: %s\n", url);
}
if (CtdlThreadCheckStop())
xp = XML_ParserCreateNS("UTF-8", ':');
if (!xp) {
- lprintf(CTDL_ALERT, "Cannot create XML parser!\n");
+ CtdlLogPrintf(CTDL_ALERT, "Cannot create XML parser!\n");
return;
}
return;
}
-retry: lprintf(CTDL_NOTICE, "Connecting to <%s>\n", rsshost);
+retry: CtdlLogPrintf(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");
+ CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
if (CtdlThreadCheckStop())
goto shutdown ;
snprintf(buf, sizeof buf, "GET %s HTTP/1.0", rssurl);
- lprintf(CTDL_DEBUG, "<%s\n", buf);
+ CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
sock_puts(sock, buf);
if (CtdlThreadCheckStop())
goto shutdown ;
snprintf(buf, sizeof buf, "Host: %s", rsshost);
- lprintf(CTDL_DEBUG, "<%s\n", buf);
+ CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
sock_puts(sock, buf);
if (CtdlThreadCheckStop())
goto shutdown ;
snprintf(buf, sizeof buf, "User-Agent: %s", CITADEL);
- lprintf(CTDL_DEBUG, "<%s\n", buf);
+ CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
sock_puts(sock, buf);
if (CtdlThreadCheckStop())
goto shutdown ;
snprintf(buf, sizeof buf, "Accept: */*");
- lprintf(CTDL_DEBUG, "<%s\n", buf);
+ CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
sock_puts(sock, buf);
if (CtdlThreadCheckStop())
goto shutdown ;
if (sock_getln(sock, buf, sizeof buf) >= 0) {
- lprintf(CTDL_DEBUG, ">%s\n", buf);
+ CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
remove_token(buf, 0, ' ');
/* 200 OK */
goto retry;
}
else {
- lprintf(CTDL_ALERT, "Invalid URL: %s\n", buf);
+ CtdlLogPrintf(CTDL_ALERT, "Invalid URL: %s\n", buf);
}
}
}
sock_close(sock);
}
else {
- lprintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno));
+ CtdlLogPrintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno));
}
XML_ParserFree(xp);
if (doing_rssclient) return NULL;
doing_rssclient = 1;
- lprintf(CTDL_DEBUG, "rssclient started\n");
+ CtdlLogPrintf(CTDL_DEBUG, "rssclient started\n");
ForEachRoom(rssclient_scan_room, NULL);
while (rnclist != NULL && !CtdlThreadCheckStop()) {
free(rptr);
}
- lprintf(CTDL_DEBUG, "rssclient ended\n");
+ CtdlLogPrintf(CTDL_DEBUG, "rssclient ended\n");
last_run = time(NULL);
doing_rssclient = 0;
if (!CtdlThreadCheckStop())