#include <stdio.h>
#include "putty.h"
+/*
+ * This appname is not strictly in the right place, since Plink
+ * also uses this module. However, Plink doesn't currently use any
+ * of the dialog-box sorts of things that make use of appname, so
+ * it shouldn't do any harm here. I'm trying to avoid having to
+ * have tiny little source modules containing nothing but
+ * declarations of appname, for as long as I can...
+ */
+const char *const appname = "PuTTY";
+
#ifdef TELNET_DEFAULT
const int be_default_protocol = PROT_TELNET;
#else
const int be_default_protocol = PROT_TELNET;
+const char *const appname = "PuTTYtel";
+
struct backend_list backends[] = {
{PROT_TELNET, "telnet", &telnet_backend},
{PROT_RLOGIN, "rlogin", &rlogin_backend},
struct environ_data *ed;
struct portfwd_data *pfd;
union control *c;
+ char *str;
ssd = (struct sessionsaver_data *)
ctrl_alloc(b, sizeof(struct sessionsaver_data));
/*
* The Session panel.
*/
- ctrl_settitle(b, "Session", "Basic options for your PuTTY session");
+ str = dupprintf("Basic options for your %s session", appname);
+ ctrl_settitle(b, "Session", str);
+ sfree(str);
if (!midsession) {
s = ctrl_getset(b, "Session", "hostport",
/*
* The Window panel.
*/
- ctrl_settitle(b, "Window", "Options controlling PuTTY's window");
+ str = dupprintf("Options controlling %s's window", appname);
+ ctrl_settitle(b, "Window", str);
+ sfree(str);
s = ctrl_getset(b, "Window", "size", "Set the size of the window");
ctrl_columns(s, 2, 50, 50);
/*
* The Window/Appearance panel.
*/
- ctrl_settitle(b, "Window/Appearance",
- "Configure the appearance of PuTTY's window");
+ str = dupprintf("Configure the appearance of %s's window", appname);
+ ctrl_settitle(b, "Window/Appearance", str);
+ sfree(str);
s = ctrl_getset(b, "Window/Appearance", "cursor",
"Adjust the use of the cursor");
/*
* The Window/Behaviour panel.
*/
- ctrl_settitle(b, "Window/Behaviour",
- "Configure the behaviour of PuTTY's window");
+ str = dupprintf("Configure the behaviour of %s's window", appname);
+ ctrl_settitle(b, "Window/Behaviour", str);
+ sfree(str);
s = ctrl_getset(b, "Window/Behaviour", "title",
"Adjust the behaviour of the window title");
'r', 100, HELPCTX(translation_codepage),
codepage_handler, P(NULL), P(NULL));
- s = ctrl_getset(b, "Window/Translation", "linedraw",
- "Adjust how PuTTY displays line drawing characters");
+ str = dupprintf("Adjust how %s displays line drawing characters", appname);
+ s = ctrl_getset(b, "Window/Translation", "linedraw", str);
+ sfree(str);
ctrl_radiobuttons(s, "Handling of line drawing characters:", NO_SHORTCUT,1,
HELPCTX(translation_linedraw),
dlg_stdradiobutton_handler,
HELPCTX(colours_bold),
dlg_stdcheckbox_handler, I(offsetof(Config,bold_colour)));
- s = ctrl_getset(b, "Window/Colours", "adjust",
- "Adjust the precise colours PuTTY displays");
+ str = dupprintf("Adjust the precise colours %s displays", appname);
+ s = ctrl_getset(b, "Window/Colours", "adjust", str);
+ sfree(str);
ctrl_text(s, "Select a colour from the list, and then click the"
" Modify button to change its appearance.",
HELPCTX(colours_config));
exit(code);
}
-const char *const appname = "PuTTY";
-
Backend *select_backend(Config *cfg)
{
int i;
{
struct controlset *s;
union control *c;
+ char *str;
if (!midsession) {
/*
* additional options when working with line-drawing
* characters.
*/
- s = ctrl_getset(b, "Window/Translation", "linedraw",
- "Adjust how PuTTY displays line drawing characters");
+ str = dupprintf("Adjust how %s displays line drawing characters", appname);
+ s = ctrl_getset(b, "Window/Translation", "linedraw", str);
+ sfree(str);
{
int i;
for (i = 0; i < s->ncontrols; i++) {
dp->focused = dp->lastfocused = NULL;
memset(dp->shortcuts, 0, sizeof(dp->shortcuts));
dp->hwnd = NULL;
- dp->errtitle = NULL;
+ dp->wintitle = dp->errtitle = NULL;
dp->privdata = newtree234(perctrl_privdata_cmp);
}
freetree234(dp->privdata);
dp->privdata = NULL;
}
+ sfree(dp->wintitle);
+ sfree(dp->errtitle);
}
void *dlg_get_privdata(union control *ctrl, void *dlg)
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);
{
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,
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' */
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' */
ctrl_free_box(ctrlbox);
winctrl_cleanup(&ctrls_base);
winctrl_cleanup(&ctrls_panel);
+ sfree(dp.errtitle);
dp_cleanup(&dp);
if (!ret)
"The server'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"
"The new 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, 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, 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);
}
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{
- static char appname[] = "PuTTY";
WORD winsock_ver;
WSADATA wsadata;
WNDCLASS wndclass;
ZeroMemory(&osVersion, sizeof(osVersion));
osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (!GetVersionEx ( (OSVERSIONINFO *) &osVersion)) {
+ char *str = dupprintf("%s Fatal Error", appname);
MessageBox(NULL, "Windows refuses to report a version",
- "PuTTY Fatal Error", MB_OK | MB_ICONEXCLAMATION);
+ str, MB_OK | MB_ICONEXCLAMATION);
+ sfree(str);
return 1;
}
}
* entries associated with PuTTY, and also find
* and delete the random seed file.
*/
- if (MessageBox(NULL,
- "This procedure will remove ALL Registry\n"
- "entries associated with PuTTY, and will\n"
- "also remove the PuTTY random seed file.\n"
+ char *s1, *s2;
+ s1 = dupprintf("This procedure will remove ALL Registry\n"
+ "entries associated with %s, and will\n"
+ "also remove the random seed file.\n"
"\n"
"THIS PROCESS WILL DESTROY YOUR SAVED\n"
"SESSIONS. Are you really sure you want\n"
- "to continue?",
- "PuTTY Warning",
+ "to continue?", appname);
+ s2 = dupprintf("%s Warning", appname);
+ if (MessageBox(NULL, s1, s2,
MB_YESNO | MB_ICONWARNING) == IDYES) {
cleanup_all();
}
+ sfree(s1);
+ sfree(s2);
exit(0);
} else if (*p != '-') {
char *q = p;
break;
}
if (back == NULL) {
+ char *str = dupprintf("%s Internal Error", appname);
MessageBox(NULL, "Unsupported protocol number found",
- "PuTTY Internal Error", MB_OK | MB_ICONEXCLAMATION);
+ str, MB_OK | MB_ICONEXCLAMATION);
+ sfree(str);
WSACleanup();
return 1;
}
/* Check for invalid Port number (i.e. zero) */
if (cfg.port == 0) {
+ char *str = dupprintf("%s Internal Error", appname);
MessageBox(NULL, "Invalid Port Number",
- "PuTTY Internal Error", MB_OK | MB_ICONEXCLAMATION);
+ str, MB_OK | MB_ICONEXCLAMATION);
+ sfree(str);
WSACleanup();
return 1;
}
cfg.host, cfg.port, &realhost, cfg.tcp_nodelay);
back->provide_logctx(backhandle, logctx);
if (error) {
+ char *str = dupprintf("%s Error", appname);
sprintf(msg, "Unable to open connection to\n"
"%.800s\n" "%s", cfg.host, error);
- MessageBox(NULL, msg, "PuTTY Error", MB_ICONERROR | MB_OK);
+ MessageBox(NULL, msg, str, MB_ICONERROR | MB_OK);
+ sfree(str);
return 0;
}
window_name = icon_name = NULL;
if (*cfg.wintitle) {
title = cfg.wintitle;
} else {
- sprintf(msg, "%s - PuTTY", realhost);
+ sprintf(msg, "%s - %s", realhost, appname);
title = msg;
}
sfree(realhost);
HMENU m = GetSystemMenu(hwnd, FALSE);
HMENU s;
int i;
+ char *str;
AppendMenu(m, MF_SEPARATOR, 0, 0);
specials_menu_position = GetMenuItemCount(m);
- debug(("specials_menu_position = %d\n", specials_menu_position));
AppendMenu(m, MF_ENABLED, IDM_SHOWLOG, "&Event Log");
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session...");
AppendMenu(m, MF_SEPARATOR, 0, 0);
if (help_path)
AppendMenu(m, MF_ENABLED, IDM_HELP, "&Help");
- AppendMenu(m, MF_ENABLED, IDM_ABOUT, "&About PuTTY");
+ str = dupprintf("&About %s", appname);
+ AppendMenu(m, MF_ENABLED, IDM_ABOUT, str);
+ sfree(str);
}
update_specials_menu(NULL);
void connection_fatal(void *frontend, char *fmt, ...)
{
va_list ap;
- char stuff[200];
+ char stuff[200], morestuff[100];
va_start(ap, fmt);
vsprintf(stuff, fmt, ap);
va_end(ap);
- MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK);
+ sprintf(morestuff, "%.70s Fatal Error", appname);
+ MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
if (cfg.close_on_exit == FORCE_ON)
PostQuitMessage(1);
else {
session_closed = TRUE;
- set_icon(NULL, "PuTTY (inactive)");
- set_title(NULL, "PuTTY (inactive)");
+ sprintf(morestuff, "%.70s (inactive)", appname);
+ set_icon(NULL, morestuff);
+ set_title(NULL, morestuff);
}
}
void cmdline_error(char *fmt, ...)
{
va_list ap;
- char stuff[200];
+ char stuff[200], morestuff[100];
va_start(ap, fmt);
vsprintf(stuff, fmt, ap);
va_end(ap);
- MessageBox(hwnd, stuff, "PuTTY Command Line Error", MB_ICONERROR | MB_OK);
+ sprintf(morestuff, "%.70s Command Line Error", appname);
+ MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
exit(1);
}
if (cfg.close_on_exit == FORCE_ON ||
cfg.close_on_exit == AUTO) PostQuitMessage(0);
else {
+ char morestuff[100];
session_closed = TRUE;
- set_icon(NULL, "PuTTY (inactive)");
- set_title(NULL, "PuTTY (inactive)");
+ sprintf(morestuff, "%.70s (inactive)", appname);
+ set_icon(NULL, morestuff);
+ set_title(NULL, morestuff);
MessageBox(hwnd, "Connection closed by remote host",
- "PuTTY", MB_OK | MB_ICONINFORMATION);
+ appname, MB_OK | MB_ICONINFORMATION);
}
}
}
case WM_CREATE:
break;
case WM_CLOSE:
- show_mouseptr(1);
- if (!cfg.warn_on_close || session_closed ||
- MessageBox(hwnd,
- "Are you sure you want to close this session?",
- "PuTTY Exit Confirmation",
- MB_ICONWARNING | MB_OKCANCEL) == IDOK)
- DestroyWindow(hwnd);
+ {
+ char *str;
+ show_mouseptr(1);
+ str = dupprintf("%s Exit Confirmation", appname);
+ if (!cfg.warn_on_close || session_closed ||
+ MessageBox(hwnd,
+ "Are you sure you want to close this session?",
+ str, MB_ICONWARNING | MB_OKCANCEL) == IDOK)
+ DestroyWindow(hwnd);
+ sfree(str);
+ }
return 0;
case WM_DESTROY:
show_mouseptr(1);
void fatalbox(char *fmt, ...)
{
va_list ap;
- char stuff[200];
+ char stuff[200], morestuff[100];
va_start(ap, fmt);
vsprintf(stuff, fmt, ap);
va_end(ap);
- MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK);
+ sprintf(morestuff, "%.70s Fatal Error", appname);
+ MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
cleanup_exit(1);
}
void modalfatalbox(char *fmt, ...)
{
va_list ap;
- char stuff[200];
+ char stuff[200], morestuff[100];
va_start(ap, fmt);
vsprintf(stuff, fmt, ap);
va_end(ap);
- MessageBox(hwnd, stuff, "PuTTY Fatal Error",
+ sprintf(morestuff, "%.70s Fatal Error", appname);
+ MessageBox(hwnd, stuff, morestuff,
MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
cleanup_exit(1);
}
if (!PlaySound(cfg.bell_wavefile.path, NULL,
SND_ASYNC | SND_FILENAME)) {
char buf[sizeof(cfg.bell_wavefile) + 80];
+ char otherbuf[100];
sprintf(buf, "Unable to play sound file\n%s\n"
"Using default sound instead", cfg.bell_wavefile);
- MessageBox(hwnd, buf, "PuTTY Sound Error",
+ sprintf(otherbuf, "%.70s Sound Error", appname);
+ MessageBox(hwnd, buf, otherbuf,
MB_OK | MB_ICONEXCLAMATION);
cfg.beep = BELL_DEFAULT;
}
HWND hwnd; /* the hwnd of the dialog box */
struct winctrls *controltrees[8]; /* can have several of these */
int nctrltrees;
+ char *wintitle; /* title of actual window */
char *errtitle; /* title of error sub-messageboxes */
void *data; /* data to pass in refresh events */
union control *focused, *lastfocused; /* which ctrl has focus now/before */