Support the siteconf feature

Patch to support the siteconf feature, from [w3m-dev 04463]
on 2012-06-27, provided by AIDA Shinra.
This commit is contained in:
Tatsuya Kinoshita
2013-04-08 21:48:49 +09:00
parent dbd52ac2ca
commit a32bf68c85
21 changed files with 781 additions and 263 deletions

29
form.c
View File

@@ -787,7 +787,7 @@ struct pre_form {
static struct pre_form *PreForm = NULL;
static struct pre_form *
add_pre_form(struct pre_form *prev, char *url, char *name, char *action)
add_pre_form(struct pre_form *prev, char *url, Regex *re_url, char *name, char *action)
{
ParsedURL pu;
struct pre_form *new;
@@ -796,21 +796,13 @@ add_pre_form(struct pre_form *prev, char *url, char *name, char *action)
new = prev->next = New(struct pre_form);
else
new = PreForm = New(struct pre_form);
if (url && *url == '/') {
int l = strlen(url);
if (l > 1 && url[l - 1] == '/')
new->url = allocStr(url + 1, l - 2);
else
new->url = url + 1;
new->re_url = newRegex(new->url, FALSE, NULL, NULL);
if (!new->re_url)
new->url = NULL;
}
else if (url) {
if (url && !re_url) {
parseURL2(url, &pu, NULL);
new->url = parsedURL2Str(&pu)->ptr;
new->re_url = NULL;
}
else
new->url = url;
new->re_url = re_url;
new->name = (name && *name) ? name : NULL;
new->action = (action && *action) ? action : NULL;
new->item = NULL;
@@ -834,7 +826,7 @@ add_pre_form_item(struct pre_form *pf, struct pre_form_item *prev, int type,
new->name = name;
new->value = value;
if (checked && *checked && (!strcmp(checked, "0") ||
strcasecmp(checked, "off")
!strcasecmp(checked, "off")
|| !strcasecmp(checked, "no")))
new->checked = 0;
else
@@ -875,6 +867,7 @@ loadPreForm(void)
return;
while (1) {
char *p, *s, *arg;
Regex *re_arg;
line = Strfgets(fp);
if (line->length == 0)
@@ -890,18 +883,20 @@ loadPreForm(void)
if (*p == '#' || *p == '\0')
continue; /* comment or empty line */
s = getWord(&p);
arg = getWord(&p);
if (!strcmp(s, "url")) {
arg = getRegexWord((const char **)&p, &re_arg);
if (!arg || !*arg)
continue;
p = getQWord(&p);
pf = add_pre_form(pf, arg, NULL, p);
pf = add_pre_form(pf, arg, re_arg, NULL, p);
pi = pf->item;
continue;
}
if (!pf)
continue;
arg = getWord(&p);
if (!strcmp(s, "form")) {
if (!arg || !*arg)
continue;
@@ -913,7 +908,7 @@ loadPreForm(void)
}
if (pf->item) {
struct pre_form *prev = pf;
pf = add_pre_form(prev, "", s, p);
pf = add_pre_form(prev, "", NULL, s, p);
/* copy previous URL */
pf->url = prev->url;
pf->re_url = prev->re_url;