From fd656308f5f0aea237959d606322ce7613d88954 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 29 Dec 2021 17:12:50 -0800 Subject: [PATCH] ... --- inc/meta.h | 7 +++++++ src/meta.c | 14 +++++++++++--- test/unit/test_utils.h | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/inc/meta.h b/inc/meta.h index 3f22178..94f0d12 100644 --- a/inc/meta.h +++ b/inc/meta.h @@ -1,6 +1,13 @@ #ifndef __META_H_ #define __META_H_ +#define _XOPEN_SOURCE +#define _POSIX_C_SOURCE 200809L +#include + +#include +#include + #include #include diff --git a/src/meta.c b/src/meta.c index f920bef..e0ebd80 100644 --- a/src/meta.c +++ b/src/meta.c @@ -22,7 +22,11 @@ int meta_entry(const char *path, struct rss_entry *entry) { } else if(strcmp(key,RSS_TAG_LINK)==0) { entry->link = strndup(value,i); } else if(strcmp(key,RSS_TAG_PUBDATE)==0) { - return -1; + if(NULL==strptime( + value, /* const char *s */ + "%a, %d %b %Y %H:%M:%S %z", /* const char *format */ + &(entry->pub_date) /* struct tm *tm */ + )) { return -1; } } else if(strcmp(key,RSS_TAG_DESCRIPTION)==0) { entry->description = strndup(value,i); } else if(strcmp(key,RSS_TAG_GUID)==0) { @@ -109,7 +113,11 @@ int meta_info(const char *path, struct rss_channel_info *info) { } else if(strcmp(key,RSS_TAG_LANGUAGE)==0) { info->language = strndup(value,i); } else if(strcmp(key,RSS_TAG_LASTBUILDDATE)==0) { - return -1; + if(NULL==strptime( + value, /* const char *s */ + "%a, %d %b %Y %H:%M:%S %z", /* const char *format */ + &(info->last_build_date) /* struct tm *tm */ + )) { return -1; } } else { goto panic; } } @@ -157,7 +165,7 @@ static ssize_t next_line(FILE *fp, char **key, char **value, char *buf, size_t b (*value) = strchr(buf,'='); if(NULL==(*value)) { return -1; } - (*value) = '\0'; + (**value) = '\0'; (*value)++; return buf_size - strlen(*key); } diff --git a/test/unit/test_utils.h b/test/unit/test_utils.h index cc42904..c7577b2 100644 --- a/test/unit/test_utils.h +++ b/test/unit/test_utils.h @@ -24,9 +24,9 @@ #define TEST_FILE_6 PREFIX "/file.torrent" #define TEST_FILE_7 PREFIX "/file.feed" #define TEST_FILE_8 PREFIX "/test.meta" -#define TEST_FILE_8_CONTENTS "title=test title\nlink=https://whatisarealink.com\npubDate=0000\ndescription=I wonder if \\n this'll properly be formatted/escaped \\>