Improve documentation

This commit is contained in:
dogeystamp 2021-09-22 18:50:42 -04:00
parent 9f36c4c9c6
commit ac57c3dcca
No known key found for this signature in database
GPG Key ID: 4C53B0126F579F36
3 changed files with 22 additions and 1 deletions

View File

@ -11,6 +11,8 @@
void
itemAction(itemStruct *item, const char *folder)
{
// Receives a link list of articles to process.
itemStruct *cur = item;
unsigned long long int newItems = 0;
@ -71,6 +73,8 @@ itemAction(itemStruct *item, const char *folder)
void
finish(char *url, long responseCode)
{
// Executed after a download finishes
if (responseCode == 200)
logMsg(4, "Finished downloading %s\n", url);
else if (!responseCode)

11
net.c
View File

@ -12,6 +12,8 @@ static CURLM *multiHandle;
int
initCurl()
{
// Initialise the curl handle.
curl_global_init(CURL_GLOBAL_ALL);
multiHandle = curl_multi_init();
@ -21,6 +23,8 @@ initCurl()
static size_t
writeCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
// Write blocks of data to the output.
size_t realsize = size * nmemb;
outputStruct *mem = (outputStruct*) data;
@ -40,6 +44,8 @@ writeCallback(void *ptr, size_t size, size_t nmemb, void *data)
int
createRequest(const char* url, outputStruct *output)
{
// Create the curl request for an URL.
CURL *requestHandle = curl_easy_init();
if (!requestHandle)
@ -75,6 +81,8 @@ createRequest(const char* url, outputStruct *output)
int
performRequests(void callback(char *, long))
{
// Perform all the curl requests.
int runningRequests;
do {
@ -101,7 +109,8 @@ performRequests(void callback(char *, long))
curl_easy_cleanup(requestHandle);
}
}
// > 0 because curl puts negative numbers when there's broken requests
// > 0 because curl puts negative numbers when there's broken requests
} while (runningRequests > 0);
curl_multi_cleanup(multiHandle);

8
xml.c
View File

@ -14,6 +14,8 @@
void
freeItem(itemStruct *item)
{
// Free the memory used by an article.
char **mems[] = {
&item->title,
&item->link,
@ -42,6 +44,8 @@ parseXml(xmlDocPtr doc,
const char *feedName,
void itemAction(itemStruct *, const char *))
{
// Parse the XML in a single document.
if (!feedName || !feedName[0]) {
logMsg(1, "Missing feed name, please set one.\n");
return 1;
@ -73,6 +77,7 @@ parseXml(xmlDocPtr doc,
logMsg(1, "Invalid RSS syntax. Skipping...\n");
}
// Pointer to an article xml tag
xmlNodePtr cur = channel->children;
itemStruct *prev = NULL;
@ -84,6 +89,7 @@ parseXml(xmlDocPtr doc,
if (TAGIS(cur, "item")) {
itemStruct *item = ecalloc(1, sizeof(itemStruct));
// Build a linked list of item structs to pass to itemAction()
item->next = prev;
prev = item;
@ -183,6 +189,8 @@ readDoc(char *content,
const char *feedName,
void itemAction(itemStruct *, const char *))
{
// Initialize the XML document, read it, then free it
xmlDocPtr doc;
doc = xmlReadMemory(content, strlen(content), "noname.xml", NULL, 0);