#define DEFAULT_KEYSIZE 1024
-static int requested_help;
-
static char *cmdline_keyfile = NULL;
/*
{
OPENFILENAME of;
memset(&of, 0, sizeof(of));
-#ifdef OPENFILENAME_SIZE_VERSION_400
- of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
-#else
- of.lStructSize = sizeof(of);
-#endif
of.hwndOwner = hwnd;
if (ppk) {
of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.ppk\0"
*filename = '\0';
of.nMaxFile = FILENAME_MAX;
of.lpstrFileTitle = NULL;
- of.lpstrInitialDir = NULL;
of.lpstrTitle = dlgtitle;
of.Flags = 0;
- if (save)
- return GetSaveFileName(&of);
- else
- return GetOpenFileName(&of);
+ return request_file(NULL, &of, FALSE, save);
}
/*
int needs_pass;
int type, realtype;
int ret;
+ const char *errmsg = NULL;
char *comment;
struct PassphraseProcStruct pps;
struct RSAKey newkey1;
if (type != SSH_KEYTYPE_SSH1 &&
type != SSH_KEYTYPE_SSH2 &&
!import_possible(type)) {
- char msg[256];
- sprintf(msg, "Couldn't load private key (%s)",
- key_type_to_str(type));
- MessageBox(NULL, msg,
- "PuTTYgen Error", MB_OK | MB_ICONERROR);
+ char *msg = dupprintf("Couldn't load private key (%s)",
+ key_type_to_str(type));
+ message_box(msg, "PuTTYgen Error", MB_OK | MB_ICONERROR,
+ HELPCTXID(errors_cantloadkey));
+ sfree(msg);
return;
}
dlgret = DialogBoxParam(hinst,
MAKEINTRESOURCE(210),
NULL, PassphraseProc,
- (LPARAM) & pps);
+ (LPARAM) &pps);
if (!dlgret) {
ret = -2;
break;
if (type == SSH_KEYTYPE_SSH1) {
if (realtype == type)
ret = loadrsakey(&filename, &newkey1,
- passphrase, NULL);
+ passphrase, &errmsg);
else
ret = import_ssh1(&filename, realtype,
- &newkey1, passphrase);
+ &newkey1, passphrase, &errmsg);
} else {
if (realtype == type)
newkey2 = ssh2_load_userkey(&filename,
- passphrase, NULL);
+ passphrase, &errmsg);
else
newkey2 = import_ssh2(&filename, realtype,
- passphrase);
+ passphrase, &errmsg);
if (newkey2 == SSH2_WRONG_PASSPHRASE)
ret = -1;
else if (!newkey2)
if (comment)
sfree(comment);
if (ret == 0) {
- MessageBox(NULL, "Couldn't load private key.",
- "PuTTYgen Error", MB_OK | MB_ICONERROR);
+ char *msg = dupprintf("Couldn't load private key (%s)", errmsg);
+ message_box(msg, "PuTTYgen Error", MB_OK | MB_ICONERROR,
+ HELPCTXID(errors_cantloadkey));
+ sfree(msg);
} else if (ret == 1) {
/*
* Now update the key controls with all the
*/
*state->commentptr = snewn(30, char);
{
- time_t t;
- struct tm *tm;
- time(&t);
- tm = localtime(&t);
+ struct tm tm;
+ tm = ltime();
if (state->is_dsa)
- strftime(*state->commentptr, 30, "dsa-key-%Y%m%d", tm);
+ strftime(*state->commentptr, 30, "dsa-key-%Y%m%d", &tm);
else
- strftime(*state->commentptr, 30, "rsa-key-%Y%m%d", tm);
+ strftime(*state->commentptr, 30, "rsa-key-%Y%m%d", &tm);
}
/*
case WM_HELP:
if (help_path) {
int id = ((LPHELPINFO)lParam)->iCtrlId;
- char *cmd = NULL;
+ char *topic = NULL;
switch (id) {
case IDC_GENERATING:
case IDC_PROGRESS:
case IDC_GENSTATIC:
case IDC_GENERATE:
- cmd = "JI(`',`puttygen.generate')"; break;
+ topic = "puttygen.generate"; break;
case IDC_PKSTATIC:
case IDC_KEYDISPLAY:
- cmd = "JI(`',`puttygen.pastekey')"; break;
+ topic = "puttygen.pastekey"; break;
case IDC_FPSTATIC:
case IDC_FINGERPRINT:
- cmd = "JI(`',`puttygen.fingerprint')"; break;
+ topic = "puttygen.fingerprint"; break;
case IDC_COMMENTSTATIC:
case IDC_COMMENTEDIT:
- cmd = "JI(`',`puttygen.comment')"; break;
+ topic = "puttygen.comment"; break;
case IDC_PASSPHRASE1STATIC:
case IDC_PASSPHRASE1EDIT:
case IDC_PASSPHRASE2STATIC:
case IDC_PASSPHRASE2EDIT:
- cmd = "JI(`',`puttygen.passphrase')"; break;
+ topic = "puttygen.passphrase"; break;
case IDC_LOADSTATIC:
case IDC_LOAD:
- cmd = "JI(`',`puttygen.load')"; break;
+ topic = "puttygen.load"; break;
case IDC_SAVESTATIC:
case IDC_SAVE:
- cmd = "JI(`',`puttygen.savepriv')"; break;
+ topic = "puttygen.savepriv"; break;
case IDC_SAVEPUB:
- cmd = "JI(`',`puttygen.savepub')"; break;
+ topic = "puttygen.savepub"; break;
case IDC_TYPESTATIC:
case IDC_KEYSSH1:
case IDC_KEYSSH2RSA:
case IDC_KEYSSH2DSA:
- cmd = "JI(`',`puttygen.keytype')"; break;
+ topic = "puttygen.keytype"; break;
case IDC_BITSSTATIC:
case IDC_BITS:
- cmd = "JI(`',`puttygen.bits')"; break;
+ topic = "puttygen.bits"; break;
case IDC_IMPORT:
case IDC_EXPORT_OPENSSH:
case IDC_EXPORT_SSHCOM:
- cmd = "JI(`',`puttygen.conversions')"; break;
+ topic = "puttygen.conversions"; break;
}
- if (cmd) {
+ if (topic) {
+ char *cmd = dupprintf("JI(`',`%s')", topic);
WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
+ sfree(cmd);
requested_help = TRUE;
} else {
MessageBeep(0);
InitCommonControls();
hinst = inst;
+ hwnd = NULL;
/*
* See if we can find our Help file.
if (p && p >= r) r = p+1;
q = strrchr(b, ':');
if (q && q >= r) r = q+1;
- strcpy(r, "putty.hlp");
+ strcpy(r, PUTTY_HELP_FILE);
if ( (fp = fopen(b, "r")) != NULL) {
help_path = dupstr(b);
fclose(fp);
help_path = NULL;
}
- random_init();
+ random_ref();
return DialogBox(hinst, MAKEINTRESOURCE(201), NULL,
MainDlgProc) != IDOK;
}