mirror of
https://github.com/curl/curl.git
synced 2026-08-24 15:03:34 +03:00
example: fix formatting nits
Also: - drop non-portable `__STRING()` macro use where still used. Closes #19746
This commit is contained in:
parent
c10dda9ebb
commit
aad3c2e8e1
50 changed files with 225 additions and 227 deletions
|
|
@ -65,7 +65,7 @@ struct memory {
|
|||
static size_t write_cb(void *contents, size_t sz, size_t nmemb, void *ctx)
|
||||
{
|
||||
size_t realsize = sz * nmemb;
|
||||
struct memory *mem = (struct memory*) ctx;
|
||||
struct memory *mem = (struct memory *)ctx;
|
||||
char *ptr = realloc(mem->buf, mem->size + realsize);
|
||||
if(!ptr) {
|
||||
/* out of memory */
|
||||
|
|
@ -109,7 +109,7 @@ static CURL *make_handle(const char *url)
|
|||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 2000L);
|
||||
/* skip files larger than a gigabyte */
|
||||
curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE,
|
||||
(curl_off_t)1024*1024*1024);
|
||||
(curl_off_t)1024 * 1024 * 1024);
|
||||
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
|
||||
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "mini crawler");
|
||||
|
|
@ -121,8 +121,7 @@ static CURL *make_handle(const char *url)
|
|||
}
|
||||
|
||||
/* HREF finder implemented in libxml2 but could be any HTML parser */
|
||||
static size_t follow_links(CURLM *multi, struct memory *mem,
|
||||
const char *url)
|
||||
static size_t follow_links(CURLM *multi, struct memory *mem, const char *url)
|
||||
{
|
||||
int opts = HTML_PARSE_NOBLANKS | HTML_PARSE_NOERROR | \
|
||||
HTML_PARSE_NOWARNING | HTML_PARSE_NONET;
|
||||
|
|
@ -135,7 +134,7 @@ static size_t follow_links(CURLM *multi, struct memory *mem,
|
|||
xmlXPathObjectPtr result;
|
||||
if(!doc)
|
||||
return 0;
|
||||
xpath = (xmlChar*) "//a/@href";
|
||||
xpath = (xmlChar *)"//a/@href";
|
||||
context = xmlXPathNewContext(doc);
|
||||
result = xmlXPathEvalExpression(xpath, context);
|
||||
xmlXPathFreeContext(context);
|
||||
|
|
@ -155,10 +154,10 @@ static size_t follow_links(CURLM *multi, struct memory *mem,
|
|||
char *link;
|
||||
if(follow_relative_links) {
|
||||
xmlChar *orig = href;
|
||||
href = xmlBuildURI(href, (xmlChar *) url);
|
||||
href = xmlBuildURI(href, (xmlChar *)url);
|
||||
xmlFree(orig);
|
||||
}
|
||||
link = (char *) href;
|
||||
link = (char *)href;
|
||||
if(!link || strlen(link) < 20)
|
||||
continue;
|
||||
if(!strncmp(link, "http://", 7) || !strncmp(link, "https://", 8)) {
|
||||
|
|
@ -240,7 +239,7 @@ int main(void)
|
|||
}
|
||||
}
|
||||
else {
|
||||
printf("[%d] HTTP %d: %s\n", complete, (int) res_status, url);
|
||||
printf("[%d] HTTP %d: %s\n", complete, (int)res_status, url);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue