1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 19:41:01 -05:00

Pageant's command line handling now uses my new split_into_argv()

function, because it's silly to have two (and because the old one
was not the same as the new one, violating the Principle of Least
Surprise).

[originally from svn r1811]
This commit is contained in:
Simon Tatham
2002-08-06 17:57:37 +00:00
parent 5e49e3fe1c
commit 437d740fb3
5 changed files with 47 additions and 52 deletions

View File

@ -15,6 +15,7 @@
#include "ssh.h"
#include "misc.h"
#include "tree234.h"
#include "winstuff.h"
#define IDI_MAINICON 200
#define IDI_TRAYICON 201
@ -1786,6 +1787,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
HMODULE advapi;
char *command = NULL;
int added_keys = 0;
int argc, i;
char **argv, **argstart;
/*
* Determine whether we're an NT system (should have security
@ -1936,46 +1939,23 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
/*
* Process the command line and add keys as listed on it.
* If we already determined that we need to spawn a program from above we
* need to ignore the first two arguments. [DBW]
*/
{
char *p;
int inquotes = 0;
p = cmdline;
while (*p) {
while (*p && isspace(*p))
p++;
if (*p && !isspace(*p)) {
char *q = p, *pp = p;
while (*p && (inquotes || !isspace(*p))) {
if (*p == '"') {
inquotes = !inquotes;
p++;
continue;
}
*pp++ = *p++;
}
if (*pp) {
if (*p)
p++;
*pp++ = '\0';
}
if (!strcmp(q, "-c")) {
/*
* If we see `-c', then the rest of the
* command line should be treated as a
* command to be spawned.
*/
while (*p && isspace(*p))
p++;
command = p;
break;
} else {
add_keyfile(q);
added_keys = TRUE;
}
}
split_into_argv(cmdline, &argc, &argv, &argstart);
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-c")) {
/*
* If we see `-c', then the rest of the
* command line should be treated as a
* command to be spawned.
*/
if (i < argc-1)
command = argstart[i+1];
else
command = "";
break;
} else {
add_keyfile(argv[i]);
added_keys = TRUE;
}
}