-#include <windows.h>
-#include <commctrl.h>
-#include <commdlg.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <time.h>
-#include "ssh.h"
#include "putty.h"
-#include "winstuff.h"
+#include "ssh.h"
#include "win_res.h"
#include "storage.h"
#include "dialog.h"
+#include <commctrl.h>
+#include <commdlg.h>
+#include <shellapi.h>
+
#ifdef MSVC4
#define TVINSERTSTRUCT TV_INSERTSTRUCT
#define TVITEM TV_ITEM
switch (msg) {
case WM_INITDIALOG:
{
+ char *str = dupprintf("%s Event Log", appname);
+ SetWindowText(hwnd, str);
+ sfree(str);
+ }
+ {
static int tabs[4] = { 78, 108 };
SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
(LPARAM) tabs);
break;
}
- selitems = smalloc(selcount * sizeof(int));
+ selitems = snewn(selcount, int);
if (selitems) {
int count = SendDlgItemMessage(hwnd, IDN_LIST,
LB_GETSELITEMS,
size +=
strlen(events[selitems[i]]) + sizeof(sel_nl);
- clipdata = smalloc(size);
+ clipdata = snewn(size, char);
if (clipdata) {
char *p = clipdata;
for (i = 0; i < count; i++) {
{
switch (msg) {
case WM_INITDIALOG:
+ {
+ char *str = dupprintf("%s Licence", appname);
+ SetWindowText(hwnd, str);
+ sfree(str);
+ }
return 1;
case WM_COMMAND:
switch (LOWORD(wParam)) {
static int CALLBACK AboutProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
+ char *str;
+
switch (msg) {
case WM_INITDIALOG:
+ str = dupprintf("About %s", appname);
+ SetWindowText(hwnd, str);
+ sfree(str);
+ SetDlgItemText(hwnd, IDA_TEXT1, appname);
SetDlgItemText(hwnd, IDA_VERSION, ver);
return 1;
case WM_COMMAND:
case WM_INITDIALOG:
dp.hwnd = hwnd;
create_controls(hwnd, ""); /* Open and Cancel buttons etc */
+ SetWindowText(hwnd, dp.wintitle);
SetWindowLong(hwnd, GWL_USERDATA, 0);
if (help_path)
SetWindowLong(hwnd, GWL_EXSTYLE,
*/
ReleaseCapture();
if (dp.ended)
- EndDialog(hwnd, dp.endresult ? 1 : 0);
+ SaneEndDialog(hwnd, dp.endresult ? 1 : 0);
break;
case WM_NOTIFY:
if (LOWORD(wParam) == IDCX_TREEVIEW &&
if (GetWindowLong(hwnd, GWL_USERDATA) == 1) {
ret = winctrl_handle_command(&dp, msg, wParam, lParam);
if (dp.ended && GetCapture() != hwnd)
- EndDialog(hwnd, dp.endresult ? 1 : 0);
+ SaneEndDialog(hwnd, dp.endresult ? 1 : 0);
} else
ret = 0;
return ret;
WinHelp(hwnd, help_path, HELP_QUIT, 0);
requested_help = FALSE;
}
- EndDialog(hwnd, 0);
+ SaneEndDialog(hwnd, 0);
return 0;
/* Grrr Explorer will maximize Dialogs! */
winctrl_init(&ctrls_panel);
dp_add_tree(&dp, &ctrls_base);
dp_add_tree(&dp, &ctrls_panel);
- dp.errtitle = "PuTTY Error";
+ dp.wintitle = dupprintf("%s Configuration", appname);
+ dp.errtitle = dupprintf("%s Error", appname);
dp.data = &cfg;
dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */
get_sesslist(&sesslist, TRUE);
ret =
- DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL,
+ SaneDialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL,
GenericMainDlgProc);
get_sesslist(&sesslist, FALSE);
winctrl_init(&ctrls_panel);
dp_add_tree(&dp, &ctrls_base);
dp_add_tree(&dp, &ctrls_panel);
- dp.errtitle = "PuTTY Error";
+ dp.wintitle = dupprintf("%s Reconfiguration", appname);
+ dp.errtitle = dupprintf("%s Error", appname);
dp.data = &cfg;
dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */
- ret =
- DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL,
+ ret = SaneDialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL,
GenericMainDlgProc);
ctrl_free_box(ctrlbox);
return ret;
}
-void logevent(void *frontend, char *string)
+void logevent(void *frontend, const char *string)
{
char timebuf[40];
time_t t;
if (nevents >= negsize) {
negsize += 64;
- events = srealloc(events, negsize * sizeof(*events));
+ events = sresize(events, negsize, char *);
}
time(&t);
strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
localtime(&t));
- events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
+ events[nevents] = snewn(strlen(timebuf) + strlen(string) + 1, char);
strcpy(events[nevents], timebuf);
strcat(events[nevents], string);
if (logbox) {
"The server's host key is not cached in the registry. You\n"
"have no guarantee that the server is the computer you\n"
"think it is.\n"
- "The server's key fingerprint is:\n"
+ "The server's %s key fingerprint is:\n"
"%s\n"
"If you trust this host, hit Yes to add the key to\n"
- "PuTTY's cache and carry on connecting.\n"
+ "%s's cache and carry on connecting.\n"
"If you want to carry on connecting just once, without\n"
"adding the key to the cache, hit No.\n"
"If you do not trust this host, hit Cancel to abandon the\n"
static const char wrongmsg[] =
"WARNING - POTENTIAL SECURITY BREACH!\n"
"\n"
- "The server's host key does not match the one PuTTY has\n"
+ "The server's host key does not match the one %s has\n"
"cached in the registry. This means that either the\n"
"server administrator has changed the host key, or you\n"
"have actually connected to another computer pretending\n"
"to be the server.\n"
- "The new key fingerprint is:\n"
+ "The new %s key fingerprint is:\n"
"%s\n"
"If you were expecting this change and trust the new key,\n"
- "hit Yes to update PuTTY's cache and continue connecting.\n"
+ "hit Yes to update %s's cache and continue connecting.\n"
"If you want to carry on connecting but without updating\n"
"the cache, hit No.\n"
"If you want to abandon the connection completely, hit\n"
"Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
- static const char mbtitle[] = "PuTTY Security Alert";
-
- char message[160 +
- /* sensible fingerprint max size */
- (sizeof(absentmsg) > sizeof(wrongmsg) ?
- sizeof(absentmsg) : sizeof(wrongmsg))];
+ static const char mbtitle[] = "%s Security Alert";
/*
* Verify the key against the registry.
return;
if (ret == 2) { /* key was different */
int mbret;
- sprintf(message, wrongmsg, fingerprint);
- mbret = MessageBox(NULL, message, mbtitle,
+ char *message, *title;
+ message = dupprintf(wrongmsg, appname, keytype, fingerprint, appname);
+ title = dupprintf(mbtitle, appname);
+ mbret = MessageBox(NULL, message, title,
MB_ICONWARNING | MB_YESNOCANCEL);
+ sfree(message);
+ sfree(title);
if (mbret == IDYES)
store_host_key(host, port, keytype, keystr);
if (mbret == IDCANCEL)
}
if (ret == 1) { /* key was absent */
int mbret;
- sprintf(message, absentmsg, fingerprint);
- mbret = MessageBox(NULL, message, mbtitle,
+ char *message, *title;
+ message = dupprintf(absentmsg, keytype, fingerprint, appname);
+ title = dupprintf(mbtitle, appname);
+ mbret = MessageBox(NULL, message, title,
MB_ICONWARNING | MB_YESNOCANCEL);
+ sfree(message);
+ sfree(title);
if (mbret == IDYES)
store_host_key(host, port, keytype, keystr);
if (mbret == IDCANCEL)
*/
void askcipher(void *frontend, char *ciphername, int cs)
{
- static const char mbtitle[] = "PuTTY Security Alert";
+ static const char mbtitle[] = "%s Security Alert";
static const char msg[] =
"The first %.35scipher supported by the server\n"
"is %.64s, which is below the configured\n"
"warning threshold.\n"
"Do you want to continue with this connection?\n";
- /* guessed cipher name + type max length */
- char message[100 + sizeof(msg)];
+ char *message, *title;
int mbret;
- sprintf(message, msg,
- (cs == 0) ? "" :
- (cs == 1) ? "client-to-server " :
- "server-to-client ",
- ciphername);
- mbret = MessageBox(NULL, message, mbtitle,
+ message = dupprintf(msg, ((cs == 0) ? "" :
+ (cs == 1) ? "client-to-server " :
+ "server-to-client "), ciphername);
+ title = dupprintf(mbtitle, appname);
+ mbret = MessageBox(NULL, message, title,
MB_ICONWARNING | MB_YESNO);
+ sfree(message);
+ sfree(title);
if (mbret == IDYES)
return;
else
*/
int askappend(void *frontend, Filename filename)
{
- static const char mbtitle[] = "PuTTY Log to File";
static const char msgtemplate[] =
"The session log file \"%.*s\" already exists.\n"
"You can overwrite it with a new session log,\n"
"or disable session logging for this session.\n"
"Hit Yes to wipe the file, No to append to it,\n"
"or Cancel to disable logging.";
- char message[sizeof(msgtemplate) + FILENAME_MAX];
+ char *message;
+ char *mbtitle;
int mbret;
- sprintf(message, msgtemplate, FILENAME_MAX, filename.path);
+ message = dupprintf(msgtemplate, FILENAME_MAX, filename.path);
+ mbtitle = dupprintf("%s Log to File", appname);
mbret = MessageBox(NULL, message, mbtitle,
MB_ICONQUESTION | MB_YESNOCANCEL);
+
+ sfree(message);
+ sfree(mbtitle);
+
if (mbret == IDYES)
return 2;
else if (mbret == IDNO)
*/
void old_keyfile_warning(void)
{
- static const char mbtitle[] = "PuTTY Key File Warning";
+ static const char mbtitle[] = "%s Key File Warning";
static const char message[] =
"You are loading an SSH 2 private key which has an\n"
"old version of the file format. This means your key\n"
"file is not fully tamperproof. Future versions of\n"
- "PuTTY may stop supporting this private key format,\n"
+ "%s may stop supporting this private key format,\n"
"so we recommend you convert your key to the new\n"
"format.\n"
"\n"
"You can perform this conversion by loading the key\n"
"into PuTTYgen and then saving it again.";
- MessageBox(NULL, message, mbtitle, MB_OK);
+ char *msg, *title;
+ msg = dupprintf(message, appname);
+ title = dupprintf(mbtitle, appname);
+
+ MessageBox(NULL, msg, title, MB_OK);
+
+ sfree(msg);
+ sfree(title);
}