From 3882cab39cf786a5ca095dcd09d42d25444ddeaa Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 28 Dec 2021 00:02:41 -0800 Subject: [PATCH] ... --- src/feed.c | 9 +++++++-- src/rss/info.c | 4 +++- test/unit/rss.tests.c | 7 ++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/feed.c b/src/feed.c index 16341ab..afe6fac 100644 --- a/src/feed.c +++ b/src/feed.c @@ -15,8 +15,8 @@ int feed() { static int feed_generate(struct torrent *torrent) { FILE *fp; - char *path; struct rss_channel_info info; + char *path; path = feed_path(PREFIX FEED_DIRECTORY,torrent->name); if(NULL==path) { return -1; } @@ -30,7 +30,8 @@ static int feed_generate(struct torrent *torrent) { if(torrent_file(PREFIX TORRENT_FILE_DIRECTORY,torrent)<0) { goto clean; } if(rss_header(fp)<0) { goto clean; } - if(rss_info(fp,&info)<0) { goto clean; } + if(feed_info(torrent,&info)<0) { goto clean; } + if(rss_info(fp,&info)<0) { return -1; } if(feed_entries(fp,torrent)<0) { goto clean; } @@ -51,6 +52,10 @@ static int feed_entries(FILE *fp, struct torrent *torrent) { return -1; } +static int feed_info(struct torrent *torrent_p, struct rss_channel_info *info) { + return -1; +} + static char *feed_path(const char *directory, const char *name) { return NULL; } diff --git a/src/rss/info.c b/src/rss/info.c index 2d0317c..84f62c9 100644 --- a/src/rss/info.c +++ b/src/rss/info.c @@ -71,12 +71,14 @@ static int rss_info_language(FILE *fp, const char *language) { static int rss_info_last_build_date(FILE *fp, const struct tm *date) { char buf[40]; - size_t buf_size = 40; + size_t len, buf_size = 40; const char start[] = RSS_TAG_LASTBUILDDATE_START; if(fwrite(start,sizeof(char),sizeof(start)-1,fp)!=sizeof(start)-1) { return -1; } if(!(strftime(buf,buf_size, "%a, %d %b %Y %H:%M:%S %z", date))) { return -1; } + len = strlen(buf); + if(fwrite(buf,sizeof(char),len,fp)!=len) { return -1; } const char end[] = RSS_TAG_LASTBUILDDATE_END; if(fwrite(end,sizeof(char),sizeof(end)-1,fp)!=sizeof(end)-1) { return -1; } diff --git a/test/unit/rss.tests.c b/test/unit/rss.tests.c index 80bb43d..ff0cc3d 100644 --- a/test/unit/rss.tests.c +++ b/test/unit/rss.tests.c @@ -157,10 +157,7 @@ static void rss_header_basic_test() { static void rss_header_correctness_test() { FILE *fp; unsigned char hash[crypto_hash_sha256_BYTES]; - unsigned char expected[crypto_hash_sha256_BYTES] = {251 199 202 195 224 186 198 234 -0x7fffffffe158: 41 214 110 130 12 238 175 97 -0x7fffffffe160: 31 7 105 99 201 7 250 79 -0x7fffffffe168: 182 57 225 209 120 28 212 179}; + unsigned char expected[crypto_hash_sha256_BYTES] = {251,199,202,195,224,186,198,234,41,214,110,130,12,238,175,97,31,7,105,99,201,7,250,79,182,57,225,209,120,28,212,179}; fp = setup_file_pointer(); @@ -230,7 +227,7 @@ static void rss_info_correctness_test() { FILE *fp; struct rss_channel_info p; unsigned char hash[crypto_hash_sha256_BYTES]; - unsigned char expected[crypto_hash_sha256_BYTES] = {252,1,77,6,36,221,191,114,180,137,47,54,77,39,151,196,0,85,115,184,127,210,230,152,114,130,36,140,33,239,194,30}; + unsigned char expected[crypto_hash_sha256_BYTES] = {175,238,191,8,225,134,109,105,86,61,240,232,31,206,163,165,243,43,229,34,169,83,166,18,54,229,225,99,110,47,38,243}; memset(&p,0,sizeof(struct rss_channel_info)); -- 2.30.2