From f9e6a53cb76ce2ecc2010a98b2ebb85a21861593 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Wed, 8 Jul 2020 03:20:03 -0500 Subject: [PATCH] Rename Channel => Feed and Item => Entry --- Makefile | 4 +- src/Channel.cpp | 72 ------------------ src/{Item.cpp => Entry.cpp} | 46 ++++++------ src/{Item.h => Entry.h} | 18 ++--- src/Feed.cpp | 70 ++++++++++++++++++ src/{Channel.h => Feed.h} | 25 +++---- src/Pogger.cpp | 26 +++---- src/parsing.cpp | 143 ++++++++++++++++++------------------ src/parsing.h | 20 ++--- 9 files changed, 210 insertions(+), 214 deletions(-) delete mode 100644 src/Channel.cpp rename src/{Item.cpp => Entry.cpp} (63%) rename src/{Item.h => Entry.h} (72%) create mode 100644 src/Feed.cpp rename src/{Channel.h => Feed.h} (58%) diff --git a/Makefile b/Makefile index 33c27cc..95407db 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,8 @@ APP_MIME_SIG = application/x-vnd.Pogger # same name (source.c or source.cpp) are included from different directories. # Also note that spaces in folder names do not work well with this Makefile. SRCS = \ - src/Channel.cpp, \ - src/Item.cpp, \ + src/Feed.cpp, \ + src/Entry.cpp, \ src/ProtocolListener.cpp, \ src/Config.cpp, \ src/Util.cpp, \ diff --git a/src/Channel.cpp b/src/Channel.cpp deleted file mode 100644 index d0f9c78..0000000 --- a/src/Channel.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include "Util.h" -#include "Channel.h" -#include "Item.h" -#include "Config.h" -#include "parsing.h" - -Channel::Channel ( BString path, BString outputPath ) -{ - title = BString("Untitled Feed"); - description = BString("Nondescript, N/A."); - homePage = BString(""); - xmlUrl = BString(""); - filePath = path; -// lastDate = NULL; - topLevelSubject = ""; - lastSubject = ""; - outputDir = outputPath; -} - -void -Channel::Parse ( Config* cfg ) -{ - items = BList(); - Channel* chan = this; - feedParser(&chan, cfg); -} - -bool Channel::SetTitle ( const char* titleStr ) { - if ( titleStr != NULL ) title = BString( titleStr ); - else return false; - return true; -} -bool Channel::SetTitle ( tinyxml2::XMLElement* elem ) { - if ( elem != NULL ) return SetTitle( elem->GetText() ); - else return false; -} - -bool Channel::SetDesc ( const char* descStr ) { - if ( descStr != NULL ) description = BString( descStr ); - else return false; - return true; -} -bool Channel::SetDesc ( tinyxml2::XMLElement* elem ) { - if ( elem != NULL ) return SetDesc( elem->GetText() ); - else return false; -} - -bool Channel::SetHomePage ( const char* homepageStr ) { - if ( homepageStr != NULL ) homePage = BString( homepageStr ); - else return false; - return true; -} -bool Channel::SetHomePage ( tinyxml2::XMLElement* elem ) { - if ( elem != NULL ) return SetHomePage( elem->GetText() ); - else return false; -} - -bool Channel::SetLastDate ( const char* dateCStr ) { - if ( dateCStr == NULL ) - return false; - BDateTime date = feedDateToBDate( dateCStr ); - if ( date == NULL ) - return false; - lastDate = date; - return true; -} -bool Channel::SetLastDate ( tinyxml2::XMLElement* elem ) { - if ( elem != NULL ) return SetLastDate( elem->GetText() ); - - else return false; -} diff --git a/src/Item.cpp b/src/Entry.cpp similarity index 63% rename from src/Item.cpp rename to src/Entry.cpp index 29bf805..8db85f2 100644 --- a/src/Item.cpp +++ b/src/Entry.cpp @@ -3,22 +3,20 @@ #include #include #include "Config.h" -#include "Item.h" +#include "Entry.h" #include "Util.h" -Item::Item ( BString outputPath ) +Entry::Entry ( BString outputPath ) { title = BString(""); description = BString(""); - homePage = BString(""); postUrl = BString(""); content = BString(""); -// pubDate = NULL; outputDir = outputPath; } bool -Item::Filetize ( Config* cfg, bool onlyIfNew = false ) +Entry::Filetize ( Config* cfg, bool onlyIfNew = false ) { BDirectory* dir = new BDirectory( outputDir ); BFile* file = new BFile( title.String(), B_READ_WRITE ); @@ -26,13 +24,13 @@ Item::Filetize ( Config* cfg, bool onlyIfNew = false ) dir->CreateFile( title.String(), file ); BString betype = cfg->mimetype; - if ( pubDate != NULL ) { - int32 unixDate = (int32)pubDate.Time_t(); + if ( date != NULL ) { + int32 unixDate = (int32)date.Time_t(); file->WriteAttr( "unixDate", B_INT32_TYPE, 0, &unixDate, sizeof(int32) ); - file->WriteAttr( "pubDate", B_STRING_TYPE, 0, - dateTo3339String(pubDate).String(), - dateTo3339String(pubDate).CountChars() ); + file->WriteAttr( "date", B_STRING_TYPE, 0, + dateTo3339String(date).String(), + dateTo3339String(date).CountChars() ); } file->WriteAttr( "META:title", B_STRING_TYPE, 0, @@ -48,56 +46,56 @@ Item::Filetize ( Config* cfg, bool onlyIfNew = false ) return false; } -bool Item::SetTitle ( const char* titleStr ) { +bool Entry::SetTitle ( const char* titleStr ) { if ( titleStr != NULL ) title = BString( titleStr ); else return false; return true; } -bool Item::SetTitle ( tinyxml2::XMLElement* elem ) { +bool Entry::SetTitle ( tinyxml2::XMLElement* elem ) { if ( elem != NULL ) return SetTitle( elem->GetText() ); return false; } -bool Item::SetDesc ( const char* descStr ) { +bool Entry::SetDesc ( const char* descStr ) { if ( descStr != NULL ) description = BString( descStr ); else return false; return true; } -bool Item::SetDesc ( tinyxml2::XMLElement* elem ) { +bool Entry::SetDesc ( tinyxml2::XMLElement* elem ) { if ( elem != NULL ) return SetDesc( elem->GetText() ); return false; } -bool Item::SetContent ( const char* contentStr ) { +bool Entry::SetContent ( const char* contentStr ) { if ( contentStr != NULL ) content = BString( contentStr ); else return false; return true; } -bool Item::SetContent ( tinyxml2::XMLElement* elem ) { +bool Entry::SetContent ( tinyxml2::XMLElement* elem ) { if ( elem != NULL ) return SetContent( elem->GetText() ); return false; } -bool Item::SetPostUrl ( const char* urlStr ) { +bool Entry::SetPostUrl ( const char* urlStr ) { if ( urlStr != NULL ) postUrl = BString( urlStr ); else return false; return true; } -bool Item::SetPostUrl ( tinyxml2::XMLElement* elem ) { +bool Entry::SetPostUrl ( tinyxml2::XMLElement* elem ) { if ( elem != NULL ) return SetPostUrl( elem->GetText() ); return false; } -bool Item::SetPubDate ( const char* dateStr ) { +bool Entry::SetDate ( const char* dateStr ) { if ( dateStr == NULL ) return false; - BDateTime date = feedDateToBDate( dateStr ); - if ( date == NULL ) + BDateTime newDate = feedDateToBDate( dateStr ); + if ( newDate == NULL ) return false; - pubDate = date; + date = newDate; return true; } -bool Item::SetPubDate ( tinyxml2::XMLElement* elem ) { - if ( elem != NULL ) return SetPubDate( elem->GetText() ); +bool Entry::SetDate ( tinyxml2::XMLElement* elem ) { + if ( elem != NULL ) return SetDate( elem->GetText() ); return false; } diff --git a/src/Item.h b/src/Entry.h similarity index 72% rename from src/Item.h rename to src/Entry.h index 06c279e..10f6bd1 100644 --- a/src/Item.h +++ b/src/Entry.h @@ -1,23 +1,23 @@ -#ifndef ITEM_H -#define ITEM_H +#ifndef ENTRY_H +#define ENTRY_H #include #include #include #include #include +#include "Config.h" -class Item { +class Entry { public: BString title; BString description; - BDateTime pubDate; - BString homePage; + BDateTime date; BString postUrl; BString content; - BString outputDir; + BString outputDir; - Item ( BString ); + Entry ( BString ); bool Filetize ( Config*, bool ); @@ -29,8 +29,8 @@ public: bool SetContent ( tinyxml2::XMLElement* ); bool SetPostUrl ( const char* ); bool SetPostUrl ( tinyxml2::XMLElement* ); - bool SetPubDate ( const char* ); - bool SetPubDate ( tinyxml2::XMLElement* ); + bool SetDate ( const char* ); + bool SetDate ( tinyxml2::XMLElement* ); }; diff --git a/src/Feed.cpp b/src/Feed.cpp new file mode 100644 index 0000000..6098de2 --- /dev/null +++ b/src/Feed.cpp @@ -0,0 +1,70 @@ +#include +#include "Entry.h" +#include "Config.h" +#include "parsing.h" +#include "Util.h" +#include "Feed.h" + +Feed::Feed ( BString path, BString outputPath ) +{ + title = BString("Untitled Feed"); + description = BString("Nondescript, N/A."); + homeUrl = BString(""); + xmlUrl = BString(""); + filePath = path; +// lastDate = NULL; + outputDir = outputPath; +} + +void +Feed::Parse ( Config* cfg ) +{ + entries = BList(); + Feed* feed = this; + feedParser(&feed, cfg); +} + +bool Feed::SetTitle ( const char* titleStr ) { + if ( titleStr != NULL ) title = BString( titleStr ); + else return false; + return true; +} +bool Feed::SetTitle ( tinyxml2::XMLElement* elem ) { + if ( elem != NULL ) return SetTitle( elem->GetText() ); + else return false; +} + +bool Feed::SetDesc ( const char* descStr ) { + if ( descStr != NULL ) description = BString( descStr ); + else return false; + return true; +} +bool Feed::SetDesc ( tinyxml2::XMLElement* elem ) { + if ( elem != NULL ) return SetDesc( elem->GetText() ); + else return false; +} + +bool Feed::SetHomeUrl ( const char* homepageStr ) { + if ( homepageStr != NULL ) homeUrl = BString( homepageStr ); + else return false; + return true; +} +bool Feed::SetHomeUrl ( tinyxml2::XMLElement* elem ) { + if ( elem != NULL ) return SetHomeUrl( elem->GetText() ); + else return false; +} + +bool Feed::SetDate ( const char* dateCStr ) { + if ( dateCStr == NULL ) + return false; + BDateTime newDate = feedDateToBDate( dateCStr ); + if ( newDate == NULL ) + return false; + date = newDate; + return true; +} +bool Feed::SetDate ( tinyxml2::XMLElement* elem ) { + if ( elem != NULL ) return SetDate( elem->GetText() ); + + else return false; +} diff --git a/src/Channel.h b/src/Feed.h similarity index 58% rename from src/Channel.h rename to src/Feed.h index 95d2a54..62dbc7e 100644 --- a/src/Channel.h +++ b/src/Feed.h @@ -1,5 +1,5 @@ -#ifndef CHANNEL_H -#define CHANNEL_H +#ifndef FEED_H +#define FEED_H #include #include @@ -8,15 +8,15 @@ #include #include "Config.h" -class Channel { +class Feed { public: char lang[3]; BString title; BString description; - BDateTime lastDate; - BString homePage; + BDateTime date; + BString homeUrl; BString xmlUrl; - BList items; + BList entries; BString topLevelSubject; BString lastSubject; @@ -24,19 +24,18 @@ public: BString outputDir; - Channel ( BString, BString ); -// Channel ( BEntry ); -// Channel ( BUrl ); + Feed ( BString, BString ); + void Parse ( Config* ); bool SetTitle ( const char* ); bool SetTitle ( tinyxml2::XMLElement* ); bool SetDesc ( const char* ); bool SetDesc ( tinyxml2::XMLElement* ); - bool SetLastDate ( const char* ); - bool SetLastDate ( tinyxml2::XMLElement* ); - bool SetHomePage ( const char* ); - bool SetHomePage ( tinyxml2::XMLElement* ); + bool SetDate ( const char* ); + bool SetDate ( tinyxml2::XMLElement* ); + bool SetHomeUrl ( const char* ); + bool SetHomeUrl ( tinyxml2::XMLElement* ); }; #endif diff --git a/src/Pogger.cpp b/src/Pogger.cpp index b61d05a..92024e9 100644 --- a/src/Pogger.cpp +++ b/src/Pogger.cpp @@ -1,8 +1,8 @@ #include #include #include -#include "Channel.h" -#include "Item.h" +#include "Feed.h" +#include "Entry.h" #include "parsing.h" #include "Config.h" #include "Util.h" @@ -129,24 +129,24 @@ freeargInvocation ( int argc, char** argv, int optind, Config** cfgPtr ) // ---------------------------------------------------------------------------- bool -processItem ( void* item ) +processEntry ( void* entry ) { - Item* itemPtr = (Item*)item; - itemPtr->Filetize( main_cfg, false ); + Entry* entryPtr = (Entry*)entry; + entryPtr->Filetize( main_cfg, false ); return false; } bool -processFeed ( void* feed ) +processFeed ( void* feedArg ) { - BString* feedStr = (BString*)feed; + BString* feedStr = (BString*)feedArg; - Channel* chan = (Channel*)malloc( sizeof(Channel) ); - chan = new Channel(*(feedStr), main_cfg->outDir); - chan->Parse(main_cfg); - BList items = chan->items; - items.DoForEach(&processItem); - free(chan); + Feed* feed = (Feed*)malloc( sizeof(feed) ); + feed = new Feed(*(feedStr), main_cfg->outDir); + feed->Parse(main_cfg); + BList entries = feed->entries; + entries.DoForEach(&processEntry); + free(feed); return false; } diff --git a/src/parsing.cpp b/src/parsing.cpp index 635cf9b..e1fdae2 100644 --- a/src/parsing.cpp +++ b/src/parsing.cpp @@ -1,8 +1,8 @@ #include #include #include -#include "Channel.h" -#include "Item.h" +#include "Feed.h" +#include "Entry.h" #include "Util.h" #include "parsing.h" @@ -10,82 +10,83 @@ // ============================================================================ // PARSERS void -feedParser ( Channel** chanPtr, Config* cfg ) +feedParser ( Feed** feedPtr, Config* cfg ) { - Channel* chan = *(chanPtr); + Feed* feed = *(feedPtr); tinyxml2::XMLDocument xml; - xml.LoadFile( chan->filePath.String() ); + xml.LoadFile( feed->filePath.String() ); if ( xml.FirstChildElement("rss") ) - rssParser( chanPtr, cfg, &xml ); + rssParser( feedPtr, cfg, &xml ); else if ( xml.FirstChildElement("feed") ) - atomParser( chanPtr, cfg, &xml ); + atomParser( feedPtr, cfg, &xml ); } // ---------------------------------------------------------------------------- void -rssParser ( Channel** chanPtr, Config* cfg, tinyxml2::XMLDocument* xml ) +rssParser ( Feed** feedPtr, Config* cfg, tinyxml2::XMLDocument* xml ) { - Channel* chan = *(chanPtr); + Feed* chan = *(feedPtr); tinyxml2::XMLElement* xchan = xml->FirstChildElement("rss")->FirstChildElement("channel"); - rssRootParse( chanPtr, cfg, xchan ); - rssParseItems( chanPtr, cfg, xchan ); + rssRootParse( feedPtr, cfg, xchan ); + rssParseEntries( feedPtr, cfg, xchan ); } void -rssRootParse( Channel** chanPtr, Config* cfg, tinyxml2::XMLElement* xchan ) +rssRootParse( Feed** feedPtr, Config* cfg, tinyxml2::XMLElement* xchan ) { - Channel* chan = *(chanPtr); + Feed* feed = *(feedPtr); - chan->SetTitle( xchan->FirstChildElement("title") ); - chan->SetDesc( xchan->FirstChildElement("description") ); - chan->SetHomePage( xchan->FirstChildElement("link") ); - chan->SetLastDate( xchan->FirstChildElement("lastBuildDate") ); + feed->SetTitle ( xchan->FirstChildElement("title") ); + feed->SetDesc ( xchan->FirstChildElement("description") ); + feed->SetHomeUrl ( xchan->FirstChildElement("link") ); + feed->SetDate ( xchan->FirstChildElement("lastBuildDate") ); if ( cfg->verbose ) - printf("Channel '%s' at '%s':\n", chan->title.String(), chan->homePage.String()); + printf("Channel '%s' at '%s':\n", feed->title.String(), feed->homeUrl.String()); } void -rssItemParse ( Channel** chanPtr, Config* cfg, tinyxml2::XMLElement* xitem ) +rssEntryParse ( Feed** feedPtr, Config* cfg, tinyxml2::XMLElement* xitem ) { - Channel* chan = *(chanPtr); + Feed* feed = *(feedPtr); - Item* newItem = (Item*)malloc( sizeof(Item) ); - newItem = new Item( chan->outputDir ); + Entry* newEntry = (Entry*)malloc( sizeof(Entry) ); + newEntry = new Entry( feed->outputDir ); - newItem->SetTitle( xitem->FirstChildElement("title") ); - newItem->SetDesc( xitem->FirstChildElement("description") ); - newItem->SetPubDate( xitem->FirstChildElement("pubDate") ); - newItem->SetContent( xitem->FirstChildElement("content:encoded") ); + newEntry->SetTitle ( xitem->FirstChildElement("title") ); + newEntry->SetDesc ( xitem->FirstChildElement("description") ); + newEntry->SetDate ( xitem->FirstChildElement("pubDate") ); + newEntry->SetPostUrl ( xitem->FirstChildElement("link") ); + newEntry->SetContent ( xitem->FirstChildElement("content:encoded") ); if (cfg->verbose ) - printf("\t%s\n", newItem->title.String()); + printf("\t%s\n", newEntry->title.String()); - if ( withinDateRange( cfg->minDate, newItem->pubDate, cfg->maxDate ) ) - chan->items.AddItem( newItem ); + if ( withinDateRange( cfg->minDate, newEntry->date, cfg->maxDate ) ) + feed->entries.AddItem( newEntry ); } void -rssParseItems ( Channel** chanPtr, Config* cfg, tinyxml2::XMLElement* xchan ) +rssParseEntries ( Feed** feedPtr, Config* cfg, tinyxml2::XMLElement* xchan ) { - Channel* chan = *(chanPtr); + Feed* feed = *(feedPtr); tinyxml2::XMLElement* xitem; xitem = xchan->FirstChildElement("item"); - int itemCount = xmlCountSiblings( xitem, "item" ); - chan->items = BList(itemCount); + int entryCount = xmlCountSiblings( xitem, "item" ); + feed->entries = BList(entryCount); if ( cfg->verbose ) - printf("\t-%i items-\n", itemCount); + printf("\t-%i entries-\n", entryCount); while ( xitem ) { - rssItemParse( chanPtr, cfg, xitem ); + rssEntryParse( feedPtr, cfg, xitem ); xitem = xitem->NextSiblingElement("item"); } } @@ -93,20 +94,20 @@ rssParseItems ( Channel** chanPtr, Config* cfg, tinyxml2::XMLElement* xchan ) // ---------------------------------------------------------------------------- void -atomParser ( Channel** chanPtr, Config* cfg, tinyxml2::XMLDocument* xml ) +atomParser ( Feed** feedPtr, Config* cfg, tinyxml2::XMLDocument* xml ) { - Channel* chan = *(chanPtr); + Feed* feed = *(feedPtr); tinyxml2::XMLElement* xfeed = xml->FirstChildElement("feed"); - atomRootParse( chanPtr, cfg, xfeed ); - atomParseEntries( chanPtr, cfg, xfeed ); + atomRootParse( feedPtr, cfg, xfeed ); + atomParseEntries( feedPtr, cfg, xfeed ); } void -atomRootParse( Channel** chanPtr, Config* cfg, tinyxml2::XMLElement* xfeed ) +atomRootParse( Feed** feedPtr, Config* cfg, tinyxml2::XMLElement* xfeed ) { - Channel* chan = *(chanPtr); + Feed* feed = *(feedPtr); tinyxml2::XMLElement* xauthor = xfeed->FirstChildElement("author"); tinyxml2::XMLElement* xentry = xfeed->FirstChildElement("entry"); @@ -115,72 +116,72 @@ atomRootParse( Channel** chanPtr, Config* cfg, tinyxml2::XMLElement* xfeed ) bool set = false; - chan->SetTitle( xfeed->FirstChildElement("title") ); - chan->SetDesc( xfeed->FirstChildElement("description") ); + feed->SetTitle( xfeed->FirstChildElement("title") ); + feed->SetDesc( xfeed->FirstChildElement("description") ); - set = chan->SetLastDate( xfeed->FirstChildElement("updated") ); - if ( !set ) set = chan->SetLastDate( xfeed->FirstChildElement("published") ); - if ( !set && xentry ) set = chan->SetLastDate( xentry->FirstChildElement("updated") ); - if ( !set && xentry ) set = chan->SetLastDate( xentry->FirstChildElement("published") ); + set = feed->SetDate( xfeed->FirstChildElement("updated") ); + if ( !set ) set = feed->SetDate( xfeed->FirstChildElement("published") ); + if ( !set && xentry ) set = feed->SetDate( xentry->FirstChildElement("updated") ); + if ( !set && xentry ) set = feed->SetDate( xentry->FirstChildElement("published") ); - set = chan->SetHomePage( xlink->Attribute( "href" ) ); - if ( !set && xauthor ) set = chan->SetHomePage( xauthor->FirstChildElement("uri") ); - if ( !set && xauthlink ) set = chan->SetHomePage( xauthlink->Attribute( "href" ) ); + set = feed->SetHomeUrl( xlink->Attribute( "href" ) ); + if ( !set && xauthor ) set = feed->SetHomeUrl( xauthor->FirstChildElement("uri") ); + if ( !set && xauthlink ) set = feed->SetHomeUrl( xauthlink->Attribute( "href" ) ); if ( cfg->verbose ) - printf("Channel '%s' at '%s':\n", chan->title.String(), chan->homePage.String()); + printf("Channel '%s' at '%s':\n", feed->title.String(), feed->homeUrl.String()); } void -atomEntryParse ( Channel** chanPtr, Config* cfg, tinyxml2::XMLElement* xentry ) +atomEntryParse ( Feed** feedPtr, Config* cfg, tinyxml2::XMLElement* xentry ) { - Channel* chan = *(chanPtr); - Item* newItem = (Item*)malloc( sizeof(Item) ); - newItem = new Item( chan->outputDir ); + Feed* feed = *(feedPtr); + Entry* newEntry= (Entry*)malloc( sizeof(Entry) ); + newEntry = new Entry( feed->outputDir ); tinyxml2::XMLElement* xcontent = xentry->FirstChildElement("content"); tinyxml2::XMLElement* xmedia = xentry->FirstChildElement("media:group"); tinyxml2::XMLPrinter xprinter; - newItem->SetTitle( xentry->FirstChildElement("title") ); - newItem->SetPostUrl( xentry->FirstChildElement("link")->Attribute("href") ); + newEntry->SetTitle( xentry->FirstChildElement("title") ); + newEntry->SetPostUrl( xentry->FirstChildElement("link")->Attribute("href") ); bool set = false; - set = newItem->SetDesc( xentry->FirstChildElement("summary") ); - if ( !set ) set = newItem->SetDesc( xentry->FirstChildElement("description")); - if ( !set && xmedia ) set = newItem->SetDesc( xmedia->FirstChildElement("media:description")); + set = newEntry->SetDesc( xentry->FirstChildElement("summary") ); + if ( !set ) set = newEntry->SetDesc( xentry->FirstChildElement("description")); + if ( !set && xmedia ) set = newEntry->SetDesc( xmedia->FirstChildElement("media:description")); - set = newItem->SetPubDate( xentry->FirstChildElement("updated") ); - if ( !set ) set = newItem->SetPubDate( xentry->FirstChildElement("published") ); + set = newEntry->SetDate( xentry->FirstChildElement("updated") ); + if ( !set ) set = newEntry->SetDate( xentry->FirstChildElement("published") ); if ( xcontent ) { xcontent->Accept( &xprinter ); - newItem->SetContent( xprinter.CStr() ); + newEntry->SetContent( xprinter.CStr() ); } if ( cfg->verbose ) - printf("\t%s\n", newItem->title.String()); + printf("\t%s\n", newEntry->title.String()); - if ( withinDateRange( cfg->minDate, newItem->pubDate, cfg->maxDate ) ) - chan->items.AddItem( newItem ); + if ( withinDateRange( cfg->minDate, newEntry->date, cfg->maxDate ) ) + feed->entries.AddItem( newEntry ); } void -atomParseEntries ( Channel** chanPtr, Config* cfg, tinyxml2::XMLElement* xfeed ) +atomParseEntries ( Feed** feedPtr, Config* cfg, tinyxml2::XMLElement* xfeed ) { - Channel* chan = *(chanPtr); + Feed* feed = *(feedPtr); tinyxml2::XMLElement* xentry; xentry = xfeed->FirstChildElement("entry"); int entryCount = xmlCountSiblings( xentry, "entry" ); - chan->items = BList(entryCount); + feed->entries = BList(entryCount); if ( cfg->verbose ) - printf("\t-%i items-\n", entryCount); + printf("\t-%i entries-\n", entryCount); while ( xentry ) { - atomEntryParse( chanPtr, cfg, xentry ); + atomEntryParse( feedPtr, cfg, xentry ); xentry = xentry->NextSiblingElement("entry"); } } diff --git a/src/parsing.h b/src/parsing.h index db4254b..3a4bf31 100644 --- a/src/parsing.h +++ b/src/parsing.h @@ -3,17 +3,17 @@ #include #include "Config.h" -#include "Channel.h" +#include "Feed.h" -void feedParser ( Channel**, Config* ); -void rssParser ( Channel**, Config*, tinyxml2::XMLDocument* ); -void rssRootParse ( Channel**, Config*, tinyxml2::XMLElement* ); -void rssItemParse ( Channel**, Config*, tinyxml2::XMLElement* ); -void rssParseItems ( Channel**, Config*, tinyxml2::XMLElement* ); -void atomParser ( Channel**, Config*, tinyxml2::XMLDocument* ); -void atomRootParse ( Channel** chanPtr, Config*, tinyxml2::XMLElement* ); -void atomEntryParse ( Channel**, Config*, tinyxml2::XMLElement* ); -void atomParseEntries ( Channel**, Config*, tinyxml2::XMLElement* ); +void feedParser ( Feed**, Config* ); +void rssParser ( Feed**, Config*, tinyxml2::XMLDocument* ); +void rssRootParse ( Feed**, Config*, tinyxml2::XMLElement* ); +void rssEntryParse ( Feed**, Config*, tinyxml2::XMLElement* ); +void rssParseEntries ( Feed**, Config*, tinyxml2::XMLElement* ); +void atomParser ( Feed**, Config*, tinyxml2::XMLDocument* ); +void atomRootParse ( Feed**, Config*, tinyxml2::XMLElement* ); +void atomEntryParse ( Feed**, Config*, tinyxml2::XMLElement* ); +void atomParseEntries ( Feed**, Config*, tinyxml2::XMLElement* ); int xmlCountSiblings ( tinyxml2::XMLElement*, const char* ); #endif