]> infiniteadaptability.org Git - seeder/commitdiff
...
authoralex <[email protected]>
Tue, 28 Dec 2021 08:02:41 +0000 (00:02 -0800)
committeralex <[email protected]>
Tue, 28 Dec 2021 08:02:41 +0000 (00:02 -0800)
src/feed.c
src/rss/info.c
test/unit/rss.tests.c

index 16341ab67d06a70c17c787ebbbd5b607d17eab5d..afe6fac9821a241fa5d43fbb8ef9cae6434e61f3 100644 (file)
@@ -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;
 }
index 2d0317c68be63fe9332584374c8f10cf8766c1b7..84f62c9862f3dc56d33eb48b023fbfb76bef4816 100644 (file)
@@ -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; }
index 80bb43d3601ee052fadb6413c1c575d8f9e58496..ff0cc3d27ac429704c1d9318c5659d5b25a752bb 100644 (file)
@@ -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));