void *senddata;
int sendlen, ret;
+ if (bufchain_size(chain) == 0)
+ return;
+
bufchain_prefix(chain, &senddata, &sendlen);
ret = write(fd, senddata, sendlen);
if (ret > 0)
int i, skcount, sksize, socketstate;
int connopen;
int exitcode;
- void *logctx;
void *ldisc;
ssh_get_line = console_get_line;
continue;
} else if (!strcmp(p, "-batch")) {
console_batch_mode = 1;
+ } else if (!strcmp(p, "-o")) {
+ if (argc <= 1)
+ fprintf(stderr,
+ "plink: option \"-o\" requires an argument\n");
+ else
+ --argc, provide_xrm_string(*++argv);
}
} else if (*p) {
if (!*cfg.host) {
char *q = p;
+
+ do_defaults(NULL, &cfg);
+
/*
* If the hostname starts with "telnet:", set the
* protocol to Telnet and process the string as a
/*
* Start up the connection.
*/
+ logctx = log_init(NULL);
{
char *error;
char *realhost;
error = back->init(NULL, &backhandle, cfg.host, cfg.port,
&realhost, nodelay);
if (error) {
- fprintf(stderr, "Unable to open connection:\n%s", error);
+ fprintf(stderr, "Unable to open connection:\n%s\n", error);
return 1;
}
- logctx = log_init(NULL);
back->provide_logctx(backhandle, logctx);
ldisc = ldisc_create(NULL, back, backhandle, NULL);
sfree(realhost);
for (i = 0; i < skcount; i++) {
socket = sklist[i];
+ /*
+ * We must process exceptional notifications before
+ * ordinary readability ones, or we may go straight
+ * past the urgent marker.
+ */
+ if (FD_ISSET(socket, &xset))
+ select_result(socket, 4);
if (FD_ISSET(socket, &rset))
select_result(socket, 1);
if (FD_ISSET(socket, &wset))
select_result(socket, 2);
- if (FD_ISSET(socket, &xset))
- select_result(socket, 4);
}
if (FD_ISSET(0, &rset)) {
fprintf(stderr, "Remote process exit code unavailable\n");
exitcode = 1; /* this is an error condition */
}
- return exitcode;
+ cleanup_exit(exitcode);
+ return exitcode; /* shouldn't happen, but placates gcc */
}