Browse Source

remove getopt and add hash table to TODO

master
Shokara 7 months ago
parent
commit
f4f342dce9
Signed by: shokara GPG Key ID: 7F5702DEF8E6DC82
  1. 2
      README
  2. 1
      TODO
  3. 35
      main.c
  4. 2
      parse.c

2
README

@ -12,4 +12,4 @@ Dependencies
Usage
-----
./rssdl -m maildir rss_url
./rssdl maildir rss_url

1
TODO

@ -1,6 +1,7 @@
TODO
====
- add atom support
- check element against a hash table in sax_cb when parsing
- add unit tests via something like MinUnit/JTN002
revisit later

35
main.c

@ -5,40 +5,25 @@
void usage(char *name)
{
printf("Usage: %s -m maildir rss_url\n", name);
printf("Usage: %s maildir rss_url\n", name);
}
int main(int argc, char **argv)
{
char option;
char *outfile, *url, *feeddata;
char *maildir, *url, *feeddata;
if (argc != 4) {
if (argc != 3) {
usage(argv[0]);
return 1;
}
url = argv[3];
while ((option = getopt(argc, argv, ":m:")) != -1) {
switch(option) {
case 'm':
outfile = optarg;
if((feeddata = fetchrss(url)) == NULL)
return -1;
save_feed_maildir(feeddata, outfile);
free(feeddata);
break;
case ':':
fprintf(stderr, "Option '-%c' requires an operand\n", optopt);
return 1;
case '?':
fprintf(stderr, "Unrecognized option: '-%c'\n", optopt);
return 1;
default:
usage(argv[0]);
return 1;
}
}
maildir = argv[1];
url = argv[2];
if ((feeddata = fetchrss(url)) == NULL)
return -1;
save_feed_maildir(feeddata, maildir);
free(feeddata);
return 0;
}

2
parse.c

@ -10,7 +10,7 @@ void sax_cb(mxml_node_t *curnode, mxml_sax_event_t event, void *data)
{
if (event == MXML_SAX_ELEMENT_OPEN) {
const char *element = mxmlGetElement(curnode);
/* shokara please learn what a hash table is */
/* TODO use a hash table here */
if (!strcmp(element, "rss") ||
!strcmp(element, "feed") ||
!strcmp(element, "updated") ||

Loading…
Cancel
Save