diff --git a/readme.md b/readme.md index e112294..a5f35d2 100644 --- a/readme.md +++ b/readme.md @@ -220,8 +220,7 @@ library, you may find the following documentation useful: - `rss.h` - `rss.c` - through the handin and verify it compiles and works through the - grader. + and verify it compiles and works through the grader. 2. Even if you worked with a partner, you *both* should turn in all files. diff --git a/rss/makefile b/rss/makefile index 9478c8a..c1c60af 100644 --- a/rss/makefile +++ b/rss/makefile @@ -1,6 +1,6 @@ # # makefile for the RSS lab -# +# # compile with gcc CC = gcc -std=gnu99 -Wall @@ -15,6 +15,9 @@ CURL_LIB = -lcurl runRss: runRss.c rss_utils.o rss.o curl_utils.o $(CC) $(XML_INCLUDE) -o runRss runRss.c curl_utils.o rss_utils.o rss.o $(XML_LIB) $(CURL_LIB) +rssTest: rssTest.c rss.o + $(CC) $(XML_INCLUDE) -o rssTest rssTest.c rss.o + rss_utils.o: rss_utils.c rss_utils.h $(CC) -Wno-pointer-sign $(XML_INCLUDE) -c -o rss_utils.o rss_utils.c $(XML_LIB) @@ -27,5 +30,5 @@ curl_utils.o: curl_utils.c curl_utils.h curlTest: curl_utils.o $(CC) -o curlTest curl_utils.o curlTest.c $(CURL_LIB) -clean: +clean: rm -f *.o *~ diff --git a/rss/rss.c b/rss/rss.c index 5d7ad0e..bc1b57b 100644 --- a/rss/rss.c +++ b/rss/rss.c @@ -4,22 +4,22 @@ #include "rss.h" -// TODO: implement these functions - Rss * createEmptyRss() { - + // TODO: implement this functions } Rss * createRss(const char * title, const char * link, const char * date, const char * description) { - + // TODO: implement this functions } -void initRss(Rss *feed, const char* title, const char* link, const char* date, - const char* description) { - +void initRss(Rss *feed, const char* title, const char* link, const char* date, const char* description) { + // TODO: implement this functions } +char *rssToString(const Rss *item) { + // TODO: implement this functions +} void printRss(const Rss * item) { - + // TODO: implement this functions } diff --git a/rss/rss.h b/rss/rss.h index 6f5fa4e..2819597 100644 --- a/rss/rss.h +++ b/rss/rss.h @@ -31,6 +31,12 @@ void initRss(Rss *feed, const char* date, const char* description); +/** + * A function to construct a (human-readable) string representation + * of the given RSS item. + */ +char *rssToString(const Rss *item); + /** * A function that prints the given Rss structure * to the standard output. diff --git a/rss/rssTest.c b/rss/rssTest.c new file mode 100644 index 0000000..e5b0dac --- /dev/null +++ b/rss/rssTest.c @@ -0,0 +1,30 @@ +/** + * A stand alone test utility for your rss functions. + * + */ +#include +#include + +#include "rss.h" + +int main(int argc, char **argv) { + + Rss *empty = createEmptyRss(); + + Rss test01; + initRss(&test01, + "RSS TEST 001 - Title", + "RSS TEST 001 - Link", + "RSS TEST 001 - Date", + "RSS TEST 001 - Description"); + Rss *test02 = createRss( + "RSS TEST 002 - Title", + "RSS TEST 002 - Link", + "RSS TEST 002 - Date", + "RSS TEST 002 - Description"); + + printRss(&test01); + printRss(test02); + + return 0; +} diff --git a/rss/rss_utils.h b/rss/rss_utils.h index 77522b3..b542fe4 100644 --- a/rss/rss_utils.h +++ b/rss/rss_utils.h @@ -16,21 +16,39 @@ typedef struct { Version type; } RssService; +/** + * RSS feed for the School of Computing's weekly + * Bits and Bytes newsletter + */ static const RssService cseBitsAndBytes = { - "CSE Bits and Bytes", + "SoC Bits and Bytes", "https://newsroom.unl.edu/announce/cse/?format=rss", - RSS2}; + RSS2 +}; +/** + * RSS feed for Husker athletics news + */ static const RssService huskerNews = { "Husker Sports News", - "https://huskers.com/rss.aspx", - RSS2}; + "https://huskers.com/rss.aspx", + RSS2 +}; + +/** + * RSS feed for the University of Nebraska-Omaha + */ +static const RssService unoNews = { + "University of Nebraska-Omaha", + "https://www.unomaha.edu/news/index.rss", + RSS2 +}; /** - * An RSS feed of Reddit's front page. + * An RSS feed of Reddit's front page. */ static const RssService reddit = { - "Reddit", + "Reddit", "https://www.reddit.com/.rss", ATOM1}; diff --git a/rss/runRss.c b/rss/runRss.c index 0565087..64080a4 100644 --- a/rss/runRss.c +++ b/rss/runRss.c @@ -14,7 +14,7 @@ * command line arguments 1 - 3 to connect to different feeds. */ int main(int argc, char **argv) { - // default: UNL News + // default: School of Computing News RssService s = cseBitsAndBytes; if (argc > 1) { @@ -23,6 +23,8 @@ int main(int argc, char **argv) { s = huskerNews; } else if (choice == 3) { s = reddit; + } else if (choice == 4) { + s = unoNews; } }