};
struct PFwdPrivate {
- struct plug_function_table *fn;
+ const struct plug_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */
void *c; /* (channel) data used by ssh.c */
void *backhandle; /* instance of SSH backend itself */
char *pfd_newconnect(Socket *s, char *hostname, int port, void *c,
const Config *cfg)
{
- static struct plug_function_table fn_table = {
+ static const struct plug_function_table fn_table = {
pfd_closing,
pfd_receive,
pfd_sent,
static int pfd_accepting(Plug p, void *sock)
{
- static struct plug_function_table fn_table = {
+ static const struct plug_function_table fn_table = {
pfd_closing,
pfd_receive,
pfd_sent,
char *pfd_addforward(char *desthost, int destport, char *srcaddr, int port,
void *backhandle, const Config *cfg)
{
- static struct plug_function_table fn_table = {
+ static const struct plug_function_table fn_table = {
pfd_closing,
pfd_receive, /* should not happen... */
pfd_sent, /* also should not happen */
* which I can reliably set aside to indicate `nil'. The string
* function is perfectly all right returning NULL, of course.)
*/
-char *platform_default_s(char *name);
-int platform_default_i(char *name, int def);
+char *platform_default_s(const char *name);
+int platform_default_i(const char *name, int def);
/*
* Exports from terminal.c.
Socket s;
int bufsize;
+ int firstbyte;
int term_width, term_height;
void *frontend;
} *Rlogin;
* byte is expected to be NULL and is ignored, and the rest
* is printed.
*/
- static int firstbyte = 1;
- if (firstbyte) {
+ if (rlogin->firstbyte) {
if (data[0] == '\0') {
data++;
len--;
}
- firstbyte = 0;
+ rlogin->firstbyte = 0;
}
if (len > 0)
c_write(rlogin, data, len);
rlogin->frontend = frontend_handle;
rlogin->term_width = cfg->width;
rlogin->term_height = cfg->height;
+ rlogin->firstbyte = 1;
*backend_handle = rlogin;
/*
{ "des", CIPHER_DES }
};
-static void gpps(void *handle, char *name, char *def, char *val, int len)
+static void gpps(void *handle, const char *name, const char *def,
+ char *val, int len)
{
if (!read_setting_s(handle, name, val, len)) {
char *pdef;
gppi(sesskey, "TryPalette", 0, &cfg->try_palette);
gppi(sesskey, "BoldAsColour", 1, &cfg->bold_colour);
for (i = 0; i < 22; i++) {
- static char *defaults[] = {
+ static const char *const defaults[] = {
"187,187,187", "255,255,255", "0,0,0", "85,85,85", "0,0,0",
"0,255,0", "0,0,0", "85,85,85", "187,0,0", "255,85,85",
"0,187,0", "85,255,85", "187,187,0", "255,255,85", "0,0,187",
gppi(sesskey, "RectSelect", 0, &cfg->rect_select);
gppi(sesskey, "MouseOverride", 1, &cfg->mouse_override);
for (i = 0; i < 256; i += 32) {
- static char *defaults[] = {
+ static const char *const defaults[] = {
"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
"0,1,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1",
"1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,2",
* Keys may be up to 255 characters long. String values have no length
* limit.
*/
-void *open_settings_w(char *sessionname);
-void write_setting_s(void *handle, char *key, char *value);
-void write_setting_i(void *handle, char *key, int value);
+void *open_settings_w(const char *sessionname);
+void write_setting_s(void *handle, const char *key, const char *value);
+void write_setting_i(void *handle, const char *key, int value);
void close_settings_w(void *handle);
/*
* should invent a sensible default. If an integer setting is not
* present, read_setting_i() returns its provided default.
*/
-void *open_settings_r(char *sessionname);
-char *read_setting_s(void *handle, char *key, char *buffer, int buflen);
-int read_setting_i(void *handle, char *key, int defvalue);
+void *open_settings_r(const char *sessionname);
+char *read_setting_s(void *handle, const char *key, char *buffer, int buflen);
+int read_setting_i(void *handle, const char *key, int defvalue);
void close_settings_r(void *handle);
/*
* Delete a whole saved session.
*/
-void del_settings(char *sessionname);
+void del_settings(const char *sessionname);
/*
* Enumerate all saved sessions.
* be 0 (entry matches database), 1 (entry is absent in database),
* or 2 (entry exists in database and is different).
*/
-int verify_host_key(char *hostname, int port, char *keytype, char *key);
+int verify_host_key(const char *hostname, int port,
+ const char *keytype, const char *key);
/*
* Write a host key into the database, overwriting any previous
* entry that might have been there.
*/
-void store_host_key(char *hostname, int port, char *keytype, char *key);
+void store_host_key(const char *hostname, int port,
+ const char *keytype, const char *key);
/* ----------------------------------------------------------------------
* Functions to access PuTTY's random number seed file.
{
Telnet telnet = (Telnet) handle;
unsigned char *p, *end;
- static unsigned char iac[2] = { IAC, IAC };
- static unsigned char cr[2] = { CR, NUL };
+ static const unsigned char iac[2] = { IAC, IAC };
+ static const unsigned char cr[2] = { CR, NUL };
#if 0
- static unsigned char nl[2] = { CR, LF };
+ static const unsigned char nl[2] = { CR, LF };
#endif
if (telnet->s == NULL)
/* Last chance, if !unicode then try poorman links. */
if (cfg->vtmode != VT_UNICODE) {
- static char poorman_scoacs[] =
+ static const char poorman_scoacs[] =
"CueaaaaceeeiiiAAE**ooouuyOUc$YPsaiounNao?++**!<>###||||++||++++++--|-+||++--|-+----++++++++##||#aBTPEsyt******EN=+><++-=... n2* ";
- static char poorman_latin1[] =
+ static const char poorman_latin1[] =
" !cL.Y|S\"Ca<--R~o+23'u|.,1o>///?AAAAAAACEEEEIIIIDNOOOOOxOUUUUYPBaaaaaaaceeeeiiiionooooo/ouuuuypy";
- static char poorman_vt100[] = "*#****o~**+++++-----++++|****L.";
+ static const char poorman_vt100[] = "*#****o~**+++++-----++++|****L.";
for (i = 160; i < 256; i++)
if (!DIRECT_FONT(ucsdata->unitab_line[i]) &&
wchar_t xlat_uskbd2cyrllic(int ch)
{
- static wchar_t cyrtab[] = {
+ static const wchar_t cyrtab[] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
return cyrtab[ch&0x7F];
}
-int check_compose(int first, int second)
+int check_compose_internal(int first, int second, int recurse)
{
- static struct {
+ static const struct {
char first, second;
wchar_t composed;
} composetbl[] = {
0, 0, 0}
}, *c;
- static int recurse = 0;
int nc = -1;
for (c = composetbl; c->first; c++) {
}
if (recurse == 0) {
- recurse = 1;
- nc = check_compose(second, first);
+ nc = check_compose_internal(second, first, 1);
if (nc == -1)
- nc = check_compose(toupper(first), toupper(second));
+ nc = check_compose(toupper(first), toupper(second), 1);
if (nc == -1)
- nc = check_compose(toupper(second), toupper(first));
- recurse = 0;
+ nc = check_compose(toupper(second), toupper(first), 1);
}
return nc;
}
+int check_compose(int first, int second)
+{
+ return check_compose_internal(first, second, 0);
+}
+
int decode_codepage(char *cp_name)
{
char *s, *d;
static char *app_name = "pterm";
-char *x_get_default(char *key)
+char *x_get_default(const char *key)
{
return XGetDefault(GDK_DISPLAY(), app_name, key);
}
/*
* Default settings that are specific to pterm.
*/
-char *platform_default_s(char *name)
+char *platform_default_s(const char *name)
{
if (!strcmp(name, "Font"))
return "fixed"; /* COE_NORMAL works badly in an xterm */
return NULL;
}
-int platform_default_i(char *name, int def)
+int platform_default_i(const char *name, int def)
{
if (!strcmp(name, "CloseOnExit"))
return COE_ALWAYS; /* COE_NORMAL works badly in an xterm */
int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
/* Things uxstore.c needs from pterm.c */
-char *x_get_default(char *key);
+char *x_get_default(const char *key);
/* Things uxstore.c provides to pterm.c */
void provide_xrm_string(char *string);
/*
* Default settings that are specific to pterm.
*/
-char *platform_default_s(char *name)
+char *platform_default_s(const char *name)
{
if (!strcmp(name, "X11Display"))
return getenv("DISPLAY");
return NULL;
}
-int platform_default_i(char *name, int def)
+int platform_default_i(const char *name, int def)
{
if (!strcmp(name, "TermWidth") ||
!strcmp(name, "TermHeight")) {
return def;
}
-char *x_get_default(char *key)
+char *x_get_default(const char *key)
{
return NULL; /* this is a stub */
}
* file somewhere or other.
*/
-void *open_settings_w(char *sessionname)
+void *open_settings_w(const char *sessionname)
{
return NULL;
}
-void write_setting_s(void *handle, char *key, char *value)
+void write_setting_s(void *handle, const char *key, const char *value)
{
}
-void write_setting_i(void *handle, char *key, int value)
+void write_setting_i(void *handle, const char *key, int value)
{
}
*/
struct xrm_string {
- char *key;
- char *value;
+ const char *key;
+ const char *value;
};
static tree234 *xrmtree = NULL;
void provide_xrm_string(char *string)
{
- char *p, *q;
+ char *p, *q, *key;
struct xrm_string *xrms, *ret;
p = q = strchr(string, ':');
while (p > string && p[-1] != '.' && p[-1] != '*')
p--;
xrms = smalloc(sizeof(struct xrm_string));
- xrms->key = smalloc(q-p);
- memcpy(xrms->key, p, q-p);
- xrms->key[q-p-1] = '\0';
+ key = smalloc(q-p);
+ memcpy(key, p, q-p);
+ key[q-p-1] = '\0';
+ xrms->key = key;
while (*q && isspace(*q))
q++;
xrms->value = dupstr(q);
}
}
-char *get_setting(char *key)
+const char *get_setting(const char *key)
{
struct xrm_string tmp, *ret;
tmp.key = key;
return x_get_default(key);
}
-void *open_settings_r(char *sessionname)
+void *open_settings_r(const char *sessionname)
{
static int thing_to_return_an_arbitrary_non_null_pointer_to;
return &thing_to_return_an_arbitrary_non_null_pointer_to;
}
-char *read_setting_s(void *handle, char *key, char *buffer, int buflen)
+char *read_setting_s(void *handle, const char *key, char *buffer, int buflen)
{
- char *val = get_setting(key);
+ const char *val = get_setting(key);
if (!val)
return NULL;
else {
}
}
-int read_setting_i(void *handle, char *key, int defvalue)
+int read_setting_i(void *handle, const char *key, int defvalue)
{
- char *val = get_setting(key);
+ const char *val = get_setting(key);
if (!val)
return defvalue;
else
{
}
-void del_settings(char *sessionname)
+void del_settings(const char *sessionname)
{
}
*
* rsa@22:foovax.example.org 0x23,0x293487364395345345....2343
*/
-int verify_host_key(char *hostname, int port, char *keytype, char *key)
+int verify_host_key(const char *hostname, int port,
+ const char *keytype, const char *key)
{
FILE *fp;
char filename[FILENAME_MAX];
return ret;
}
-void store_host_key(char *hostname, int port, char *keytype, char *key)
+void store_host_key(const char *hostname, int port,
+ const char *keytype, const char *key)
{
FILE *fp;
int fd;
#include "putty.h"
-char *platform_default_s(char *name)
+char *platform_default_s(const char *name)
{
if (!strcmp(name, "Font"))
return "Courier New";
return NULL;
}
-int platform_default_i(char *name, int def)
+int platform_default_i(const char *name, int def)
{
if (!strcmp(name, "FontCharSet"))
return ANSI_CHARSET;
((ntohl(addr.s_addr) & 0xFF000000L) == 0x7F000000L)
struct Socket_tag {
- struct socket_function_table *fn;
+ const struct socket_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */
char *error;
SOCKET s;
Socket sk_register(void *sock, Plug plug)
{
- static struct socket_function_table fn_table = {
+ static const struct socket_function_table fn_table = {
sk_tcp_plug,
sk_tcp_close,
sk_tcp_write,
Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
int nodelay, Plug plug)
{
- static struct socket_function_table fn_table = {
+ static const struct socket_function_table fn_table = {
sk_tcp_plug,
sk_tcp_close,
sk_tcp_write,
Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only)
{
- static struct socket_function_table fn_table = {
+ static const struct socket_function_table fn_table = {
sk_tcp_plug,
sk_tcp_close,
sk_tcp_write,
static char seedpath[2 * MAX_PATH + 10] = "\0";
-static char hex[16] = "0123456789ABCDEF";
+static const char hex[16] = "0123456789ABCDEF";
-static void mungestr(char *in, char *out)
+static void mungestr(const char *in, char *out)
{
int candot = 0;
return;
}
-static void unmungestr(char *in, char *out, int outlen)
+static void unmungestr(const char *in, char *out, int outlen)
{
while (*in) {
if (*in == '%' && in[1] && in[2]) {
return;
}
-void *open_settings_w(char *sessionname)
+void *open_settings_w(const char *sessionname)
{
HKEY subkey1, sesskey;
int ret;
return (void *) sesskey;
}
-void write_setting_s(void *handle, char *key, char *value)
+void write_setting_s(void *handle, const char *key, const char *value)
{
if (handle)
RegSetValueEx((HKEY) handle, key, 0, REG_SZ, value,
1 + strlen(value));
}
-void write_setting_i(void *handle, char *key, int value)
+void write_setting_i(void *handle, const char *key, int value)
{
if (handle)
RegSetValueEx((HKEY) handle, key, 0, REG_DWORD,
RegCloseKey((HKEY) handle);
}
-void *open_settings_r(char *sessionname)
+void *open_settings_r(const char *sessionname)
{
HKEY subkey1, sesskey;
char *p;
return (void *) sesskey;
}
-char *read_setting_s(void *handle, char *key, char *buffer, int buflen)
+char *read_setting_s(void *handle, const char *key, char *buffer, int buflen)
{
DWORD type, size;
size = buflen;
return buffer;
}
-int read_setting_i(void *handle, char *key, int defvalue)
+int read_setting_i(void *handle, const char *key, int defvalue)
{
DWORD type, val, size;
size = sizeof(val);
RegCloseKey((HKEY) handle);
}
-void del_settings(char *sessionname)
+void del_settings(const char *sessionname)
{
HKEY subkey1;
char *p;
sfree(e);
}
-static void hostkey_regname(char *buffer, char *hostname,
- int port, char *keytype)
+static void hostkey_regname(char *buffer, const char *hostname,
+ int port, const char *keytype)
{
int len;
strcpy(buffer, keytype);
mungestr(hostname, buffer + strlen(buffer));
}
-int verify_host_key(char *hostname, int port, char *keytype, char *key)
+int verify_host_key(const char *hostname, int port,
+ const char *keytype, const char *key)
{
char *otherstr, *regname;
int len;
return 0; /* key matched OK in registry */
}
-void store_host_key(char *hostname, int port, char *keytype, char *key)
+void store_host_key(const char *hostname, int port,
+ const char *keytype, const char *key)
{
char *regname;
HKEY rkey;