Compare commits

...

2 Commits

3 changed files with 19 additions and 3 deletions

View File

@ -20,12 +20,14 @@ all: config.h minrss
debug: CFLAGS += -g3 debug: CFLAGS += -g3
debug: config.h minrss debug: config.h minrss
config.h: $(OBJ): config.h
cp config.def.h config.h
.c.o: .c.o:
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
config.h:
cp config.def.h config.h
minrss: $(OBJ) minrss: $(OBJ)
$(CC) -o $@ $(OBJ) $(LIBS) $(CC) -o $@ $(OBJ) $(LIBS)

View File

@ -76,6 +76,10 @@ atomLink(itemStruct *item, xmlNodePtr node)
copyField(item, FIELD_LINK, (char *)href); copyField(item, FIELD_LINK, (char *)href);
} else if (propIs(rel, "enclosure")) { } else if (propIs(rel, "enclosure")) {
copyField(item, FIELD_ENCLOSURE_URL, (char *)href); copyField(item, FIELD_ENCLOSURE_URL, (char *)href);
xmlChar *enclosure_type = xmlGetProp(node, (xmlChar *) "type");
copyField(item, FIELD_ENCLOSURE_TYPE, (char *)enclosure_type);
xmlFree(enclosure_type);
} }
xmlFree(href); xmlFree(href);
@ -94,8 +98,11 @@ rssEnclosure(itemStruct *item, xmlNodePtr node)
} }
copyField(item, FIELD_ENCLOSURE_URL, (char *)href); copyField(item, FIELD_ENCLOSURE_URL, (char *)href);
xmlFree(href); xmlFree(href);
xmlChar *enclosure_type = xmlGetProp(node, (xmlChar *) "type");
copyField(item, FIELD_ENCLOSURE_TYPE, (char *)enclosure_type);
xmlFree(enclosure_type);
return 0; return 0;
} }
@ -156,6 +163,8 @@ outputHtml(itemStruct *item, FILE *f)
fprintf(f, "<a href=\"%s\">Link</a><br>\n", item->fields[FIELD_LINK]); fprintf(f, "<a href=\"%s\">Link</a><br>\n", item->fields[FIELD_LINK]);
if (item->fields[FIELD_ENCLOSURE_URL]) if (item->fields[FIELD_ENCLOSURE_URL])
fprintf(f, "<a href=\"%s\">Enclosure</a><br>\n", item->fields[FIELD_ENCLOSURE_URL]); fprintf(f, "<a href=\"%s\">Enclosure</a><br>\n", item->fields[FIELD_ENCLOSURE_URL]);
if (item->fields[FIELD_ENCLOSURE_TYPE])
fprintf(f, "Enclosure type: %s\n", item->fields[FIELD_ENCLOSURE_TYPE]);
if (item->fields[FIELD_DESCRIPTION]) if (item->fields[FIELD_DESCRIPTION])
fprintf(f, "%s", item->fields[FIELD_DESCRIPTION]); fprintf(f, "%s", item->fields[FIELD_DESCRIPTION]);
} }
@ -178,6 +187,10 @@ outputJson(itemStruct *item, FILE *f)
json_object *enclosure = json_object_new_object(); json_object *enclosure = json_object_new_object();
json_object_object_add(enclosure, "link", json_object_object_add(enclosure, "link",
json_object_new_string(item->fields[FIELD_ENCLOSURE_URL])); json_object_new_string(item->fields[FIELD_ENCLOSURE_URL]));
if (item->fields[FIELD_ENCLOSURE_TYPE]) {
json_object_object_add(enclosure, "type",
json_object_new_string(item->fields[FIELD_ENCLOSURE_TYPE]));
}
json_object_object_add(root, "enclosure", enclosure); json_object_object_add(root, "enclosure", enclosure);
} }

View File

@ -20,6 +20,7 @@ enum fields {
FIELD_LINK, FIELD_LINK,
FIELD_DESCRIPTION, FIELD_DESCRIPTION,
FIELD_ENCLOSURE_URL, FIELD_ENCLOSURE_URL,
FIELD_ENCLOSURE_TYPE,
FIELD_END FIELD_END
}; };