--- /dev/null
+#ifndef __META_H_
+#define __META_H_
+
+#include<rss.h>
+
+#define META_MAX_LINE_SIZE 1024
+
+int meta_entry(const char*,struct rss_entry*);
+int meta_info(const char*,struct rss_channel_info*);
+
+#endif
char *guid;
};
-#define RSS_TAG_CHANNEL_START "<channel>"
-#define RSS_TAG_CHANNEL_END "</channel>"
-#define RSS_TAG_DESCRIPTION_START "<description>"
-#define RSS_TAG_DESCRIPTION_END "</description>"
-#define RSS_TAG_GUID_START "<guid>"
-#define RSS_TAG_GUID_END "</guid>"
-#define RSS_TAG_ITEM_START "<item>"
-#define RSS_TAG_ITEM_END "</item>"
-#define RSS_TAG_LANGUAGE_START "<language>"
-#define RSS_TAG_LANGUAGE_END "</language>"
-#define RSS_TAG_LASTBUILDDATE_START "<lastBuildDate>"
-#define RSS_TAG_LASTBUILDDATE_END "</lastBuildDate>"
-#define RSS_TAG_LINK_START "<link>"
-#define RSS_TAG_LINK_END "</link>"
-#define RSS_TAG_PUBDATE_START "<pubDate>"
-#define RSS_TAG_PUBDATE_END "</pubDate>"
-#define RSS_TAG_RSS_START "<rss version=\"2.0\">"
-#define RSS_TAG_RSS_END "</rss>"
-#define RSS_TAG_TITLE_START "<title>"
-#define RSS_TAG_TITLE_END "</title>"
+#define RSS_TAG_CHANNEL "channel"
+#define RSS_TAG_CHANNEL_START "<" RSS_TAG_CHANNEL ">"
+#define RSS_TAG_CHANNEL_END "</" RSS_TAG_CHANNEL ">"
+#define RSS_TAG_DESCRIPTION "description"
+#define RSS_TAG_DESCRIPTION_START "<" RSS_TAG_DESCRIPTION ">"
+#define RSS_TAG_DESCRIPTION_END "</" RSS_TAG_DESCRIPTION ">"
+#define RSS_TAG_GUID "guid"
+#define RSS_TAG_GUID_START "<" RSS_TAG_GUID ">"
+#define RSS_TAG_GUID_END "</" RSS_TAG_GUID ">"
+#define RSS_TAG_ITEM "item"
+#define RSS_TAG_ITEM_START "<" RSS_TAG_ITEM ">"
+#define RSS_TAG_ITEM_END "</" RSS_TAG_ITEM ">"
+#define RSS_TAG_LANGUAGE "language"
+#define RSS_TAG_LANGUAGE_START "<" RSS_TAG_LANGUAGE ">"
+#define RSS_TAG_LANGUAGE_END "</" RSS_TAG_LANGUAGE ">"
+#define RSS_TAG_LASTBUILDDATE "lastBuildDate"
+#define RSS_TAG_LASTBUILDDATE_START "<" RSS_TAG_LASTBUILDDATE ">"
+#define RSS_TAG_LASTBUILDDATE_END "</" RSS_TAG_LASTBUILDDATE ">"
+#define RSS_TAG_LINK "link"
+#define RSS_TAG_LINK_START "<" RSS_TAG_LINK ">"
+#define RSS_TAG_LINK_END "</" RSS_TAG_LINK ">"
+#define RSS_TAG_PUBDATE "pubDate"
+#define RSS_TAG_PUBDATE_START "<" RSS_TAG_PUBDATE ">"
+#define RSS_TAG_PUBDATE_END "</" RSS_TAG_PUBDATE ">"
+#define RSS_TAG_RSS "rss"
+#define RSS_TAG_RSS_START "<" RSS_TAG_RSS " version=\"2.0\">"
+#define RSS_TAG_RSS_END "</" RSS_TAG_RSS ">"
+#define RSS_TAG_TITLE "title"
+#define RSS_TAG_TITLE_START "<" RSS_TAG_TITLE ">"
+#define RSS_TAG_TITLE_END "</" RSS_TAG_TITLE ">"
#define RSS_DEFAULT_CHANNEL_DESCRIPTION ""
#define RSS_DEFAULT_ENTRY_DESCRIPTION "no description"
--- /dev/null
+#include<meta.h>
+
+static int meta_escape(char *buf, size_t buf_size);
+static FILE *meta_search(const char*);
+static ssize_t next_line(FILE*,char*,size_t);
+
+int meta_entry(const char *path, struct rss_entry *entry) {
+ char buf[META_MAX_LINE_SIZE];
+ char *key, *value;
+ FILE *fp;
+
+ fp = meta_search(path);
+ if(NULL==fp) { return 0; }
+
+ while((i = next_line(fp,&key,buf,META_MAX_SIZE))>0) {
+ if(strcmp(key,RSS_TAG_TITLE)==0) {
+ entry->title = strndup(value,i);
+ } else if(strcmp(key,RSS_TAG_LINK)==0) {
+ entry->link = strndup(value,i);
+ } else if(strcmp(key,RSS_TAG_PUBDATE)==0) {
+ return -1;
+ } else if(strcmp(key,RSS_TAG_DESCRIPTION)==0) {
+ entry->description = strndup(value,i);
+ } else if(strcmp(key,RSS_TAG_GUID)==0) {
+ entry->guid = strndup(value,i);
+ } else { goto panic; }
+ }
+
+ if(i<0) { goto panic; }
+
+ fclose(fp);
+
+ return 1;
+panic:
+ fclose(fp);
+ return -1;
+}
+
+static int meta_escape(char *buf, size_t buf_size) {
+ return -1;
+}
+
+int meta_info(const char *path, struct rss_channel_info *info) {
+ char buf[META_MAX_LINE_SIZE];
+ char *key, *value;
+ FILE *fp;
+
+ fp = meta_search(path);
+ if(NULL==fp) { return 0; }
+
+ while((i = next_line(fp,&key,&value,buf,META_MAX_SIZE))>0) {
+ if(strcmp(key,RSS_TAG_TITLE)==0) {
+ info->title = strndup(value,i);
+ } else if(strcmp(key,RSS_TAG_LINK)==0) {
+ info->link = strndup(value,i);
+ } else if(strcmp(key,RSS_TAG_DESCRIPTION)==0) {
+ info->description = strndup(value,i);
+ } else if(strcmp(key,RSS_TAG_LANGUAGE)==0) {
+ entry->language = strndup(value,i);
+ } else if(strcmp(key,RSS_TAG_LASTBUILDDATE)==0) {
+ return -1;
+ } else { goto panic; }
+ }
+
+ if(i<0) { goto panic; }
+
+ fclose(fp);
+
+ return 1;
+panic:
+ fclose(fp);
+ return -1;
+}
+
+static FILE *meta_search(const char *path) {
+ return NULL;
+}
+
+static ssize_t next_line(FILE *fp, char *buf, size_t buf_size) {
+ // escape+parse
+ //
+ return -1;
+}