if(strcmp(ent->d_name,".")==0) { continue; }
if(strcmp(ent->d_name,"..")==0) { continue; }
- p = malloc(sizeof(char)*(strlen(PREFIX)+strlen(ent->d_name)+1));
- if(NULL==p) {
- perror("malloc");
- return -1;
- }
+ if(ent->d_type==DT_DIR) {
+ p = malloc(sizeof(char)*(strlen(PREFIX)+strlen(ent->d_name)+1));
+ if(NULL==p) {
+ perror("malloc");
+ return -1;
+ }
+
+ sprintf(p,PREFIX "/%s",ent->d_name);
+ if(opt_add_watch(p)<0) {
+ free(p);
+ return -1;
+ }
- sprintf(p,PREFIX "/%s",ent->d_name);
- if(opt_add_watch(p)<0) {
free(p);
- return -1;
}
-
- free(p);
}
closedir(dir);
int main();
static void meta_entry_basic_test();
+static void meta_entry_overwrite_test();
static void meta_escape_basic_test();
static void meta_escape_length_test();
static void meta_info_basic_test();
+static void meta_info_overwrite_test();
static void meta_search_basic_test();
int main() {
meta_search_basic_test();
meta_entry_basic_test();
+ meta_entry_overwrite_test();
meta_info_basic_test();
+ meta_info_overwrite_test();
clean_env();
assert(meta_entry(TEST_FILE_1,entry)==1);
+ // pub_date is skipped because of strptime issue
+ // (had to be mocked because of compilation issue during testing)
assert(strcmp(entry->title,"test title")==0);
assert(strcmp(entry->link,"https://whatisarealink.com")==0);
-// assert(strcmp(entry->pub_date,"")==0);
assert(strcmp(entry->description,"I wonder if \n this'll properly be formatted/escaped \\><?")==0);
assert(strcmp(entry->guid,"magnet=asldkfjsldkfjslkdjfldsdjlfkjsdf")==0);
rss_entry_free(entry);
}
+static void meta_entry_overwrite_test() {
+ struct rss_entry *entry;
+
+ assert(1==rss_entry_init(&entry));
+
+ assert(meta_entry(TEST_FILE_1,entry)==1);
+ assert(meta_entry(TEST_FILE_1,entry)==1);
+
+ rss_entry_free(entry);
+}
+
static void meta_escape_length_test() {
char buf[10];
assert(meta_info(PREFIX,info)==1);
+ // last_build_date is skipped because of strptime issue
+ // (had to be mocked because of compilation issue during testing)
assert(strcmp(info->title,"TITLE")==0);
assert(strcmp(info->link,"http://test.com")==0);
assert(strcmp(info->description,"what is a description")==0);
assert(strcmp(info->language,"en-us")==0);
-// assert(strcmp(info->last_build_date,"")==0);
rss_channel_info_free(info);
}
+static void meta_info_overwrite_test() {
+ struct rss_channel_info *info;
+
+ assert(rss_channel_info_init(&info)==1);
+
+ assert(meta_info(PREFIX,info)==1);
+ assert(meta_info(PREFIX,info)==1);
+
+ rss_channel_info_free(info);
+}
+
static void meta_search_basic_test() {
FILE *fp;
fp = meta_search(NULL);