static void read_data_cb(struct uclient *cl)
{
char buf[256];
+ ssize_t n;
int len;
if (!no_output && output_fd < 0)
while (1) {
len = uclient_read(cl, buf, sizeof(buf));
- if (!len)
+ if (len <= 0)
return;
out_bytes += len;
- if (!no_output)
- write(output_fd, buf, len);
+ if (!no_output) {
+ n = write(output_fd, buf, len);
+ if (n < 0)
+ return;
+ }
}
}
static int no_ssl(const char *progname)
{
- fprintf(stderr, "%s: SSL support not available, please install ustream-ssl\n", progname);
+ fprintf(stderr,
+ "%s: SSL support not available, please install one of the "
+ "libustream-ssl-* libraries as well as the ca-bundle and "
+ "ca-certificates packages.\n",
+ progname);
+
return 1;
}
L_CONTINUE,
L_PROXY,
L_NO_PROXY,
+ L_QUIET,
};
static const struct option longopts[] = {
[L_CONTINUE] = { "continue", no_argument },
[L_PROXY] = { "proxy", required_argument },
[L_NO_PROXY] = { "no-proxy", no_argument },
+ [L_QUIET] = { "quiet", no_argument },
{}
};
case L_NO_PROXY:
proxy = false;
break;
+ case L_QUIET:
+ quiet = true;
+ break;
default:
return usage(progname);
}
uloop_init();
if (username) {
- if (password)
- asprintf(&auth_str, "%s:%s", username, password);
- else
+ if (password) {
+ rc = asprintf(&auth_str, "%s:%s", username, password);
+ if (rc < 0)
+ return rc;
+ } else
auth_str = username;
}