Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
size_t read_from_url(const char *url, char *buf, size_t sz)
{
char *cmd = malloc(strlen(url) + 13);
FILE *f;
size_t off = 0;
sprintf(cmd, "wget -O - '%s'", url);
f = popen(cmd, "r");
free(cmd);
while (sz) {
size_t rd = fread(buf + off, 1, sz, f);
if (rd == 0)
break;
off += rd;
sz -= rd;
}
pclose(f);
return off;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question