-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for user_agent configuration #62
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,7 @@ struct channel_configuration *channel_configuration_new( | |
c->comment_tag = | ||
_read_channel_configuration_key(kf, identifier, "comment_tag"); | ||
c->regex_filter = _read_channel_configuration_key(kf, identifier, "filter"); | ||
c->user_agent = _read_channel_configuration_key(kf, identifier, "user_agent"); | ||
|
||
/* Populate with defaults if necessary. */ | ||
if (defaults) { | ||
|
@@ -143,6 +144,9 @@ struct channel_configuration *channel_configuration_new( | |
|
||
if (!c->regex_filter && defaults->regex_filter) | ||
c->regex_filter = g_strdup(defaults->regex_filter); | ||
|
||
if (!c->user_agent && defaults->user_agent) | ||
c->user_agent = g_strdup(defaults->user_agent); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also free the duplicated string in |
||
} | ||
|
||
return c; | ||
|
@@ -198,7 +202,8 @@ int channel_configuration_verify_keys(GKeyFile *kf, const char *identifier) | |
!strcmp(key_list[i], "genre_tag") || | ||
!strcmp(key_list[i], "year_tag") || | ||
!strcmp(key_list[i], "comment_tag") || | ||
!strcmp(key_list[i], "filter"))) { | ||
!strcmp(key_list[i], "filter") || | ||
!strcmp(key_list[i], "user_agent"))) { | ||
fprintf(stderr, "Invalid key %s in configuration of channel %s.\n", | ||
key_list[i], identifier); | ||
return -1; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
#include "config.h" | ||
#endif /* HAVE_CONFIG_H */ | ||
|
||
#include "channel.h" | ||
#include "htmlent.h" | ||
#include "libxmlutil.h" | ||
#include "rss.h" | ||
|
@@ -252,20 +253,20 @@ rss_file *rss_open_file(const char *filename) | |
return f; | ||
} | ||
|
||
static int _rss_open_url_cb(FILE *f, gpointer user_data, int debug) | ||
static int _rss_open_url_cb(FILE *f, gpointer user_data, int debug, channel *c) | ||
{ | ||
gchar *url = (gchar *)user_data; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better if you passed the channel to the function via That said, the callbacks already make this code hard to read, and it is in general need of a rewrite so perhaps it's better to address this separately after merging this change. |
||
|
||
return urlget_file(url, f, debug); | ||
return urlget_file(url, f, debug, c); | ||
} | ||
|
||
rss_file *rss_open_url(const char *url, int debug) | ||
rss_file *rss_open_url(const char *url, int debug, channel *c) | ||
{ | ||
rss_file *f; | ||
gchar *rss_filename; | ||
|
||
if (write_by_temporary_file(NULL, _rss_open_url_cb, (gpointer)url, | ||
&rss_filename, debug)) | ||
&rss_filename, debug, c)) | ||
return NULL; | ||
|
||
f = rss_open_file(rss_filename); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename the new parameter to
c
for consistency.(Ideally, we'd avoid this new parameter, cf. comment on
_rss_open_url_cb()
).