*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- if(inputline(c->ident, c->fpin, &r, '\n'))
+ if(inputline(c->ident, c->fpin, &r, '\n')) {
+ byte_xasprintf((char **)&c->last, "input error: %s", strerror(errno));
dynstr_terminate(&d);
D(("command: %s", d.vec));
if(fputs(d.vec, c->fpout) < 0 || fflush(c->fpout)) {
dynstr_terminate(&d);
D(("command: %s", d.vec));
if(fputs(d.vec, c->fpout) < 0 || fflush(c->fpout)) {
error(errno, "error calling socket");
return -1;
}
if(connect(fd, sa, salen) < 0) {
error(errno, "error calling socket");
return -1;
}
if(connect(fd, sa, salen) < 0) {
error(errno, "error calling connect");
goto error;
}
if((fd2 = dup(fd)) < 0) {
error(errno, "error calling connect");
goto error;
}
if((fd2 = dup(fd)) < 0) {
error(errno, "error calling dup");
goto error;
}
if(!(c->fpin = fdopen(fd, "rb"))) {
error(errno, "error calling dup");
goto error;
}
if(!(c->fpin = fdopen(fd, "rb"))) {
error(errno, "error calling fdopen");
goto error;
}
fd = -1;
if(!(c->fpout = fdopen(fd2, "wb"))) {
error(errno, "error calling fdopen");
goto error;
}
fd = -1;
if(!(c->fpout = fdopen(fd2, "wb"))) {
if(!(rvec = split(r, &nrvec, SPLIT_QUOTES, 0, 0)))
goto error;
if(nrvec != 3) {
if(!(rvec = split(r, &nrvec, SPLIT_QUOTES, 0, 0)))
goto error;
if(nrvec != 3) {
error(0, "cannot parse server greeting %s", r);
goto error;
}
protocol = *rvec++;
if(strcmp(protocol, "2")) {
error(0, "cannot parse server greeting %s", r);
goto error;
}
protocol = *rvec++;
if(strcmp(protocol, "2")) {
- if(!(res = authhash(nonce, nl, password, algorithm))) goto error;
+ if(!(res = authhash(nonce, nl, password, algorithm))) {
+ c->last = "error computing authorization hash";
+ goto error;
+ }
if((rc = disorder_simple(c, 0, "user", username, res, (char *)0)))
goto error_rc;
c->user = xstrdup(username);
if((rc = disorder_simple(c, 0, "user", username, res, (char *)0)))
goto error_rc;
c->user = xstrdup(username);
const char *username, *password;
if(!(username = config->username)) {
const char *username, *password;
if(!(username = config->username)) {
static int disorder_somequeue(disorder_client *c,
const char *cmd, struct queue_entry **qp) {
struct queue_entry *qh, **qt = &qh, *q;
static int disorder_somequeue(disorder_client *c,
const char *cmd, struct queue_entry **qp) {
struct queue_entry *qh, **qt = &qh, *q;
if((rc = disorder_simple(c, &r, "volume", (char *)0)))
return rc;
if(sscanf(r, "%d %d", left, right) != 2) {
if((rc = disorder_simple(c, &r, "volume", (char *)0)))
return rc;
if(sscanf(r, "%d %d", left, right) != 2) {
return rc;
while(inputline(c->ident, c->fpin, &l, '\n') >= 0 && strcmp(l, "."))
if(sink_printf(s, "%s\n", l) < 0) return -1;
return rc;
while(inputline(c->ident, c->fpin, &l, '\n') >= 0 && strcmp(l, "."))
if(sink_printf(s, "%s\n", l) < 0) return -1;
- if(ferror(c->fpin) || feof(c->fpin)) return -1;
+ if(ferror(c->fpin) || feof(c->fpin)) {
+ byte_xasprintf((char **)&c->last, "input error: %s",
+ ferror(c->fpin) ? strerror(errno) : "unexpxected EOF");
+ return -1;
+ }
return rc;
vec = split(r, &n, SPLIT_QUOTES, 0, 0);
if(n != 2) {
return rc;
vec = split(r, &n, SPLIT_QUOTES, 0, 0);
if(n != 2) {