projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
And everyone's favourite cosmetic change: Unix PuTTY now doesn't
[u/mdw/putty]
/
plink.c
diff --git
a/plink.c
b/plink.c
index
528eee6
..
3848214
100644
(file)
--- a/
plink.c
+++ b/
plink.c
@@
-62,8
+62,6
@@
void cmdline_error(char *p, ...)
exit(1);
}
exit(1);
}
-static char *password = NULL;
-
HANDLE inhandle, outhandle, errhandle;
DWORD orig_console_mode;
HANDLE inhandle, outhandle, errhandle;
DWORD orig_console_mode;
@@
-71,6
+69,7
@@
WSAEVENT netevent;
static Backend *back;
static void *backhandle;
static Backend *back;
static void *backhandle;
+static Config cfg;
int term_ldisc(Terminal *term, int mode)
{
int term_ldisc(Terminal *term, int mode)
{
@@
-167,9
+166,9
@@
void try_output(int is_stderr)
}
}
}
}
-int from_backend(void *frontend_handle, int is_stderr, char *data, int len)
+int from_backend(void *frontend_handle, int is_stderr,
+ const char *data, int len)
{
{
- HANDLE h = (is_stderr ? errhandle : outhandle);
int osize, esize;
assert(len > 0);
int osize, esize;
assert(len > 0);
@@
-256,6
+255,7
@@
int main(int argc, char **argv)
int skcount, sksize;
int connopen;
int exitcode;
int skcount, sksize;
int connopen;
int exitcode;
+ int errors;
ssh_get_line = console_get_line;
ssh_get_line = console_get_line;
@@
-275,6
+275,7
@@
int main(int argc, char **argv)
do_defaults(NULL, &cfg);
default_protocol = cfg.protocol;
default_port = cfg.port;
do_defaults(NULL, &cfg);
default_protocol = cfg.protocol;
default_port = cfg.port;
+ errors = 0;
{
/*
* Override the default protocol if PLINK_PROTOCOL is set.
{
/*
* Override the default protocol if PLINK_PROTOCOL is set.
@@
-295,16
+296,21
@@
int main(int argc, char **argv)
while (--argc) {
char *p = *++argv;
if (*p == '-') {
while (--argc) {
char *p = *++argv;
if (*p == '-') {
- int ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL), 1);
+ int ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL),
+ 1, &cfg);
if (ret == -2) {
fprintf(stderr,
"plink: option \"%s\" requires an argument\n", p);
if (ret == -2) {
fprintf(stderr,
"plink: option \"%s\" requires an argument\n", p);
+ errors = 1;
} else if (ret == 2) {
--argc, ++argv;
} else if (ret == 1) {
continue;
} else if (!strcmp(p, "-batch")) {
console_batch_mode = 1;
} else if (ret == 2) {
--argc, ++argv;
} else if (ret == 1) {
continue;
} else if (!strcmp(p, "-batch")) {
console_batch_mode = 1;
+ } else {
+ fprintf(stderr, "plink: unknown option \"%s\"\n", p);
+ errors = 1;
}
} else if (*p) {
if (!*cfg.host) {
}
} else if (*p) {
if (!*cfg.host) {
@@
-404,13
+410,13
@@
int main(int argc, char **argv)
while (*p) {
if (cmdlen >= cmdsize) {
cmdsize = cmdlen + 512;
while (*p) {
if (cmdlen >= cmdsize) {
cmdsize = cmdlen + 512;
- command = sre
alloc(command, cmdsize
);
+ command = sre
size(command, cmdsize, char
);
}
command[cmdlen++]=*p++;
}
if (cmdlen >= cmdsize) {
cmdsize = cmdlen + 512;
}
command[cmdlen++]=*p++;
}
if (cmdlen >= cmdsize) {
cmdsize = cmdlen + 512;
- command = sre
alloc(command, cmdsize
);
+ command = sre
size(command, cmdsize, char
);
}
command[cmdlen++]=' '; /* always add trailing space */
if (--argc) p = *++argv;
}
command[cmdlen++]=' '; /* always add trailing space */
if (--argc) p = *++argv;
@@
-426,6
+432,9
@@
int main(int argc, char **argv)
}
}
}
}
+ if (errors)
+ return 1;
+
if (!*cfg.host) {
usage();
}
if (!*cfg.host) {
usage();
}
@@
-454,7
+463,7
@@
int main(int argc, char **argv)
/*
* Perform command-line overrides on session configuration.
*/
/*
* Perform command-line overrides on session configuration.
*/
- cmdline_run_saved();
+ cmdline_run_saved(
&cfg
);
/*
* Trim a colon suffix off the hostname if it's there.
/*
* Trim a colon suffix off the hostname if it's there.
@@
-532,14
+541,15
@@
int main(int argc, char **argv)
int nodelay = cfg.tcp_nodelay &&
(GetFileType(GetStdHandle(STD_INPUT_HANDLE)) == FILE_TYPE_CHAR);
int nodelay = cfg.tcp_nodelay &&
(GetFileType(GetStdHandle(STD_INPUT_HANDLE)) == FILE_TYPE_CHAR);
- error = back->init(NULL, &backhandle, cfg.host, cfg.port,
+ error = back->init(NULL, &backhandle,
&cfg,
cfg.host, cfg.port,
&realhost, nodelay);
if (error) {
fprintf(stderr, "Unable to open connection:\n%s", error);
return 1;
}
&realhost, nodelay);
if (error) {
fprintf(stderr, "Unable to open connection:\n%s", error);
return 1;
}
- logctx = log_init(NULL);
+ logctx = log_init(NULL
, &cfg
);
back->provide_logctx(backhandle, logctx);
back->provide_logctx(backhandle, logctx);
+ console_provide_logctx(logctx);
sfree(realhost);
}
connopen = 1;
sfree(realhost);
}
connopen = 1;
@@
-641,7
+651,7
@@
int main(int argc, char **argv)
/* Expand the buffer if necessary. */
if (i > sksize) {
sksize = i + 16;
/* Expand the buffer if necessary. */
if (i > sksize) {
sksize = i + 16;
- sklist = sre
alloc(sklist, sksize * sizeof(*sklist)
);
+ sklist = sre
size(sklist, sksize, SOCKET
);
}
/* Retrieve the sockets into sklist. */
}
/* Retrieve the sockets into sklist. */