if (command) spawn_cmd(command, show);
if (command) { char *args; if (command[0] == '"') args = strchr(++command, '"'); else args = strchr(command, ' '); if (args) { *args++ = 0; while(*args && isspace(*args)) args++; } spawn_cmd(command, args, show); }
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show){    WNDCLASS wndclass;    MSG msg;    OSVERSIONINFO osi;    HMODULE advapi;    char *command = NULL;    int added_keys = 0;    /*     * Determine whether we're an NT system (should have security     * APIs) or a non-NT system (don't do security).     */    memset(&osi, 0, sizeof(OSVERSIONINFO));    osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);    if (GetVersionEx(&osi) && osi.dwPlatformId == VER_PLATFORM_WIN32_NT) {	has_security = TRUE;    } else	has_security = FALSE;    if (has_security) {#ifndef NO_SECURITY	/*	 * Attempt to get the security API we need.	 */	advapi = LoadLibrary("ADVAPI32.DLL");	getsecurityinfo =	    (gsi_fn_t) GetProcAddress(advapi, "GetSecurityInfo");	if (!getsecurityinfo) {	    MessageBox(NULL,		       "Unable to access security APIs. Pageant will\n"		       "not run, in case it causes a security breach.",		       "Pageant Fatal Error", MB_ICONERROR | MB_OK);	    return 1;	}#else	MessageBox(NULL,		   "This program has been compiled for Win9X and will\n"		   "not run on NT, in case it causes a security breach.",		   "Pageant Fatal Error", MB_ICONERROR | MB_OK);	return 1;#endif    } else	advapi = NULL;    instance = inst;    /*     * Find out if Pageant is already running.     */    already_running = FALSE;    if (agent_exists())	already_running = TRUE;    else {	if (!prev) {	    wndclass.style = 0;	    wndclass.lpfnWndProc = WndProc;	    wndclass.cbClsExtra = 0;	    wndclass.cbWndExtra = 0;	    wndclass.hInstance = inst;	    wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON));	    wndclass.hCursor = LoadCursor(NULL, IDC_IBEAM);	    wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);	    wndclass.lpszMenuName = NULL;	    wndclass.lpszClassName = APPNAME;	    RegisterClass(&wndclass);	}	hwnd = keylist = NULL;	hwnd = CreateWindow(APPNAME, APPNAME,			    WS_OVERLAPPEDWINDOW | WS_VSCROLL,			    CW_USEDEFAULT, CW_USEDEFAULT,			    100, 100, NULL, NULL, inst, NULL);	/* Set up a system tray icon */	AddTrayIcon(hwnd);        systray_menu = CreatePopupMenu();        /* accelerators used: vkxa */        AppendMenu(systray_menu, MF_ENABLED, IDM_VIEWKEYS,               "&View Keys");        AppendMenu(systray_menu, MF_ENABLED, IDM_ADDKEY, "Add &Key");        AppendMenu(systray_menu, MF_ENABLED, IDM_ABOUT, "&About");        AppendMenu(systray_menu, MF_ENABLED, IDM_CLOSE, "E&xit");	ShowWindow(hwnd, SW_HIDE);	/*	 * Initialise storage for RSA keys.	 */	rsakeys = newtree234(cmpkeys_rsa);	ssh2keys = newtree234(cmpkeys_ssh2);    }    /*     * Initialise storage for short-term passphrase cache.     */    passphrases = newtree234(NULL);    /*     * 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;		}	    }	}    }    /*     * Forget any passphrase that we retained while going over     * command line keyfiles.     */    forget_passphrases();    if (command)	spawn_cmd(command, show);    /*     * If Pageant was already running, we leave now. If we haven't     * even taken any auxiliary action (spawned a command or added     * keys), complain.     */    if (already_running) {	if (!command && !added_keys) {	    MessageBox(NULL, "Pageant is already running", "Pageant Error",		       MB_ICONERROR | MB_OK);	}	if (advapi)	    FreeLibrary(advapi);	return 0;    }    /*     * Main message loop.     */    while (GetMessage(&msg, NULL, 0, 0) == 1) {	TranslateMessage(&msg);	DispatchMessage(&msg);    }    /* Clean up the system tray icon */    {	NOTIFYICONDATA tnid;	tnid.cbSize = sizeof(NOTIFYICONDATA);	tnid.hWnd = hwnd;	tnid.uID = 1;	Shell_NotifyIcon(NIM_DELETE, &tnid);	DestroyMenu(systray_menu);    }    if (advapi)	FreeLibrary(advapi);    exit(msg.wParam);}