15 char feed_title
[TEXT_BUFFER_SIZE
] = { 0 };
17 time_t feed_date_new
= 0;
18 bool feed_is_open
= false;
20 char item_title
[TEXT_BUFFER_SIZE
] = { 0 };
21 char item_link
[TEXT_BUFFER_SIZE
] = { 0 };
22 char item_desc
[TEXT_BUFFER_SIZE
] = { 0 };
25 void sanitize(char* str
)
28 while ((evil
= strchr(str
, '/'))) *evil
= '\\';
31 void set_item_date(const char* date
)
34 assert(strptime(date
, "%a, %d %b %Y %T %z", &t
));
35 item_date
= mktime(&t
);
36 assert(item_date
!= -1);
37 if (item_date
<= feed_date
) {
38 printf("No new feeds assumed.\n");
40 } else if (item_date
> feed_date_new
) {
41 feed_date_new
= item_date
;
45 void set_item_link(const char* link
)
47 strncpy(item_link
, link
, TEXT_BUFFER_SIZE
);
50 void set_item_desc(const char* desc
)
52 strncpy(item_desc
, desc
, TEXT_BUFFER_SIZE
);
55 void set_item_title(const char* title
)
57 strncpy(item_title
, title
, TEXT_BUFFER_SIZE
);
61 void feed_open(const char* title
)
65 strncpy(feed_title
, title
, TEXT_BUFFER_SIZE
);
68 if (!stat(feed_title
, &st
)) feed_date
= st
.st_mtime
;
69 mkdir(feed_title
, 0755);
70 assert(!chdir(feed_title
));
78 struct timeval times
[2];
79 times
[0].tv_sec
= feed_date_new
;
81 times
[1].tv_sec
= feed_date_new
;
84 if (!feed_is_open
) return;
87 assert(!utimes(feed_title
, times
));
93 struct timeval times
[2];
95 char buf
[FILE_NAME_LENGTH
+ 1];
99 strncpy(buf
, item_title
, 32);
101 assert(item_desc
[0]);
102 strncpy(buf
, item_desc
, 32);
105 assert(f
= fopen(buf
, "w"));
107 fprintf(f
, "%s\n\n", item_title
);
110 fprintf(f
, "%s\n\n", item_desc
);
113 fprintf(f
, "Link: <a href=\"%s\">%s</a>\n", item_link
, item_link
);
117 /* FIXME: item date might not have been set. */
118 times
[0].tv_sec
= item_date
;
119 times
[0].tv_usec
= 0;
120 times
[1].tv_sec
= item_date
;
121 times
[1].tv_usec
= 0;
123 assert(!utimes(buf
, times
));