mirror of
https://github.com/fangfufu/httpdirfs.git
synced 2024-09-30 22:21:15 +02:00
fixed beautification code
This commit is contained in:
parent
825c2541b7
commit
5f6643cfab
29
network.c
29
network.c
@ -344,6 +344,7 @@ static CURL *Link_to_curl(Link *link)
|
|||||||
/* for following directories without the '/' */
|
/* for following directories without the '/' */
|
||||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 2);
|
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 2);
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, link->f_url);
|
curl_easy_setopt(curl, CURLOPT_URL, link->f_url);
|
||||||
|
fprintf(stderr, "Link_to_curl(): link->f_url: %s\n", link->f_url);
|
||||||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1);
|
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1);
|
||||||
curl_easy_setopt(curl, CURLOPT_SHARE, curl_share);
|
curl_easy_setopt(curl, CURLOPT_SHARE, curl_share);
|
||||||
/*
|
/*
|
||||||
@ -459,20 +460,16 @@ static void HTML_to_LinkTable(GumboNode *node, LinkTable *linktbl)
|
|||||||
(href = gumbo_get_attribute(&node->v.element.attributes, "href"))) {
|
(href = gumbo_get_attribute(&node->v.element.attributes, "href"))) {
|
||||||
/* if it is valid, copy the link onto the heap */
|
/* if it is valid, copy the link onto the heap */
|
||||||
LinkType type = p_url_type(href->value);
|
LinkType type = p_url_type(href->value);
|
||||||
char *unescaped_p_url;
|
if (type) {
|
||||||
unescaped_p_url = curl_easy_unescape(NULL, href->value, 0, NULL);
|
LinkTable_add(linktbl, Link_new(href->value, type));
|
||||||
if (type) {
|
}
|
||||||
LinkTable_add(linktbl, Link_new(unescaped_p_url, type));
|
|
||||||
}
|
}
|
||||||
curl_free(unescaped_p_url);
|
/* Note the recursive call, lol. */
|
||||||
}
|
GumboVector *children = &node->v.element.children;
|
||||||
|
for (size_t i = 0; i < children->length; ++i) {
|
||||||
/* Note the recursive call, lol. */
|
HTML_to_LinkTable((GumboNode*)children->data[i], linktbl);
|
||||||
GumboVector *children = &node->v.element.children;
|
}
|
||||||
for (size_t i = 0; i < children->length; ++i) {
|
return;
|
||||||
HTML_to_LinkTable((GumboNode*)children->data[i], linktbl);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Link_get_stat(Link *this_link)
|
void Link_get_stat(Link *this_link)
|
||||||
@ -510,6 +507,12 @@ void LinkTable_fill(LinkTable *linktbl)
|
|||||||
strncpy(this_link->f_url, url, URL_LEN_MAX);
|
strncpy(this_link->f_url, url, URL_LEN_MAX);
|
||||||
free(url);
|
free(url);
|
||||||
|
|
||||||
|
char *unescaped_p_url;
|
||||||
|
unescaped_p_url = curl_easy_unescape(NULL, this_link->p_url, 0,
|
||||||
|
NULL);
|
||||||
|
strncpy(this_link->p_url, unescaped_p_url, LINK_LEN_MAX);
|
||||||
|
curl_free(unescaped_p_url);
|
||||||
|
|
||||||
if (this_link->type == LINK_FILE && !(this_link->content_length)) {
|
if (this_link->type == LINK_FILE && !(this_link->content_length)) {
|
||||||
Link_get_stat(this_link);
|
Link_get_stat(this_link);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user