#define PARSE_OPTIONS 0
#endif
+PRSS* prss_parse_doc(xmlDocPtr doc);
+
PRSS* prss_parse_data(const char* xml_data)
{
xmlDocPtr doc = xmlReadMemory(xml_data, strlen(xml_data), "", NULL, PARSE_OPTIONS);
PRSS* prss_parse_doc(xmlDocPtr doc)
{
+ // FIXME: doc shouldn't be freed after failure when called explicitly from program!
+
xmlNodePtr root = xmlDocGetRootElement(doc);
PRSS* result = malloc(sizeof(PRSS));
prss_null(result);
// RSS 1.0 document
if (!parse_rss_1_0(result, root)) {
free(result);
+ xmlFreeDoc(doc);
return NULL;
}
return result;
// RSS 2.0 or <1.0 document
if (!parse_rss_2_0(result, root)) {
free(result);
+ xmlFreeDoc(doc);
return NULL;
}
return result;
/* Functions for parsing RSS-data */
PRSS* prss_parse_data(const char *xml_data);
PRSS* prss_parse_file(const char *xml_file);
-PRSS* prss_parse_doc(xmlDocPtr doc);
+
+// Works wrong currently when called from application!
+//PRSS* prss_parse_doc(xmlDocPtr doc);
/* Frees the PRSS-stucture returned by prss_parse_*.
* The memory area pointed by data becomes invalid
if(!rss_delay(last_update, delay))
return curdata; // wait for delay to pass
- if(curdata != NULL)
+ if(curdata != NULL) {
prss_free(curdata); // clean up old data
+ curdata = NULL;
+ }
curl = curl_easy_init();
if(curl) {
} else
ERR("No data from server");
- curfeed->data = curdata;
-
curl_easy_cleanup(curl);
}
+ curfeed->data = curdata;
+
return curdata;
}