summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
fb4fbe1)
Having found a lot of unfixed constness issues in recent development,
I thought perhaps it was time to get proactive, so I compiled the
whole codebase with -Wwrite-strings. That turned up a huge load of
const problems, which I've fixed in this commit: the Unix build now
goes cleanly through with -Wwrite-strings, and the Windows build is as
close as I could get it (there are some lingering issues due to
occasional Windows API functions like AcquireCredentialsHandle not
having the right constness).
Notable fallout beyond the purely mechanical changing of types:
- the stuff saved by cmdline_save_param() is now explicitly
dupstr()ed, and freed in cmdline_run_saved.
- I couldn't make both string arguments to cmdline_process_param()
const, because it intentionally writes to one of them in the case
where it's the argument to -pw (in the vain hope of being at least
slightly friendly to 'ps'), so elsewhere I had to temporarily
dupstr() something for the sake of passing it to that function
- I had to invent a silly parallel version of const_cmp() so I could
pass const string literals in to lookup functions.
- stripslashes() in pscp.c and psftp.c has the annoying strchr nature
65 files changed:
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
{
va_list ap;
fprintf(stderr, "ERROR: ");
{
va_list ap;
fprintf(stderr, "ERROR: ");
*/
static struct cmdline_saved_param_set saves[NPRIORITIES];
*/
static struct cmdline_saved_param_set saves[NPRIORITIES];
-static void cmdline_save_param(char *p, char *value, int pri)
+static void cmdline_save_param(const char *p, const char *value, int pri)
{
if (saves[pri].nsaved >= saves[pri].savesize) {
saves[pri].savesize = saves[pri].nsaved + 32;
saves[pri].params = sresize(saves[pri].params, saves[pri].savesize,
struct cmdline_saved_param);
}
{
if (saves[pri].nsaved >= saves[pri].savesize) {
saves[pri].savesize = saves[pri].nsaved + 32;
saves[pri].params = sresize(saves[pri].params, saves[pri].savesize,
struct cmdline_saved_param);
}
- saves[pri].params[saves[pri].nsaved].p = p;
- saves[pri].params[saves[pri].nsaved].value = value;
+ saves[pri].params[saves[pri].nsaved].p = dupstr(p);
+ saves[pri].params[saves[pri].nsaved].value = dupstr(value);
* return means that we aren't capable of processing the prompt and
* someone else should do it.
*/
* return means that we aren't capable of processing the prompt and
* someone else should do it.
*/
-int cmdline_get_passwd_input(prompts_t *p, unsigned char *in, int inlen) {
-
+int cmdline_get_passwd_input(prompts_t *p, const unsigned char *in, int inlen)
+{
static int tried_once = 0;
/*
static int tried_once = 0;
/*
*/
int cmdline_tooltype = 0;
*/
int cmdline_tooltype = 0;
-static int cmdline_check_unavailable(int flag, char *p)
+static int cmdline_check_unavailable(int flag, const char *p)
{
if (cmdline_tooltype & flag) {
cmdline_error("option \"%s\" not available in this tool", p);
{
if (cmdline_tooltype & flag) {
cmdline_error("option \"%s\" not available in this tool", p);
if (need_save < 0) return x; \
} while (0)
if (need_save < 0) return x; \
} while (0)
-int cmdline_process_param(char *p, char *value, int need_save, Conf *conf)
+int cmdline_process_param(const char *p, char *value,
+ int need_save, Conf *conf)
sfree(host);
}
if (!strcmp(p, "-m")) {
sfree(host);
}
if (!strcmp(p, "-m")) {
- char *filename, *command;
+ const char *filename;
+ char *command;
int cmdlen, cmdsize;
FILE *fp;
int c, d;
int cmdlen, cmdsize;
FILE *fp;
int c, d;
void cmdline_run_saved(Conf *conf)
{
int pri, i;
void cmdline_run_saved(Conf *conf)
{
int pri, i;
- for (pri = 0; pri < NPRIORITIES; pri++)
- for (i = 0; i < saves[pri].nsaved; i++)
+ for (pri = 0; pri < NPRIORITIES; pri++) {
+ for (i = 0; i < saves[pri].nsaved; i++) {
cmdline_process_param(saves[pri].params[i].p,
saves[pri].params[i].value, 0, conf);
cmdline_process_param(saves[pri].params[i].p,
saves[pri].params[i].value, 0, conf);
+ sfree(saves[pri].params[i].p);
+ sfree(saves[pri].params[i].value);
+ }
+ saves[pri].nsaved = 0;
+ }
+/* Variant form of struct key which doesn't contain dynamic data, used
+ * for lookups. */
+struct constkey {
+ int primary;
+ union {
+ int i;
+ const char *s;
+ } secondary;
+};
+
struct value {
union {
int intval;
struct value {
union {
int intval;
+static int conf_cmp_constkey(void *av, void *bv)
+{
+ struct key *a = (struct key *)av;
+ struct constkey *b = (struct constkey *)bv;
+
+ if (a->primary < b->primary)
+ return -1;
+ else if (a->primary > b->primary)
+ return +1;
+ switch (subkeytypes[a->primary]) {
+ case TYPE_INT:
+ if (a->secondary.i < b->secondary.i)
+ return -1;
+ else if (a->secondary.i > b->secondary.i)
+ return +1;
+ return 0;
+ case TYPE_STR:
+ return strcmp(a->secondary.s, b->secondary.s);
+ default:
+ return 0;
+ }
+}
+
/*
* Free any dynamic data items pointed to by a 'struct key'. We
* don't free the structure itself, since it's probably part of a
/*
* Free any dynamic data items pointed to by a 'struct key'. We
* don't free the structure itself, since it's probably part of a
char *conf_get_str_strs(Conf *conf, int primary,
char *subkeyin, char **subkeyout)
{
char *conf_get_str_strs(Conf *conf, int primary,
char *subkeyin, char **subkeyout)
{
struct conf_entry *entry;
assert(subkeytypes[primary] == TYPE_STR);
struct conf_entry *entry;
assert(subkeytypes[primary] == TYPE_STR);
entry = findrel234(conf->tree, &key, NULL, REL234_GT);
} else {
key.secondary.s = "";
entry = findrel234(conf->tree, &key, NULL, REL234_GT);
} else {
key.secondary.s = "";
- entry = findrel234(conf->tree, &key, NULL, REL234_GE);
+ entry = findrel234(conf->tree, &key, conf_cmp_constkey, REL234_GE);
}
if (!entry || entry->key.primary != primary)
return NULL;
}
if (!entry || entry->key.primary != primary)
return NULL;
char *conf_get_str_nthstrkey(Conf *conf, int primary, int n)
{
char *conf_get_str_nthstrkey(Conf *conf, int primary, int n)
{
struct conf_entry *entry;
int index;
struct conf_entry *entry;
int index;
assert(valuetypes[primary] == TYPE_STR);
key.primary = primary;
key.secondary.s = "";
assert(valuetypes[primary] == TYPE_STR);
key.primary = primary;
key.secondary.s = "";
- entry = findrelpos234(conf->tree, &key, NULL, REL234_GE, &index);
+ entry = findrelpos234(conf->tree, &key, conf_cmp_constkey,
+ REL234_GE, &index);
if (!entry || entry->key.primary != primary)
return NULL;
entry = index234(conf->tree, index + n);
if (!entry || entry->key.primary != primary)
return NULL;
entry = index234(conf->tree, index + n);
if (event == EVENT_REFRESH) {
int i;
if (event == EVENT_REFRESH) {
int i;
- static const struct { char *s; int c; } ciphers[] = {
+ static const struct { const char *s; int c; } ciphers[] = {
{ "3DES", CIPHER_3DES },
{ "Blowfish", CIPHER_BLOWFISH },
{ "DES", CIPHER_DES },
{ "3DES", CIPHER_3DES },
{ "Blowfish", CIPHER_BLOWFISH },
{ "DES", CIPHER_DES },
for (i = 0; i < CIPHER_MAX; i++) {
int c = conf_get_int_int(conf, CONF_ssh_cipherlist, i);
int j;
for (i = 0; i < CIPHER_MAX; i++) {
int c = conf_get_int_int(conf, CONF_ssh_cipherlist, i);
int j;
+ const char *cstr = NULL;
for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
if (ciphers[j].c == c) {
cstr = ciphers[j].s;
for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
if (ciphers[j].c == c) {
cstr = ciphers[j].s;
if (event == EVENT_REFRESH) {
int i;
if (event == EVENT_REFRESH) {
int i;
- static const struct { char *s; int k; } kexes[] = {
+ static const struct { const char *s; int k; } kexes[] = {
{ "Diffie-Hellman group 1", KEX_DHGROUP1 },
{ "Diffie-Hellman group 14", KEX_DHGROUP14 },
{ "Diffie-Hellman group exchange", KEX_DHGEX },
{ "Diffie-Hellman group 1", KEX_DHGROUP1 },
{ "Diffie-Hellman group 14", KEX_DHGROUP14 },
{ "Diffie-Hellman group exchange", KEX_DHGEX },
for (i = 0; i < KEX_MAX; i++) {
int k = conf_get_int_int(conf, CONF_ssh_kexlist, i);
int j;
for (i = 0; i < KEX_MAX; i++) {
int k = conf_get_int_int(conf, CONF_ssh_kexlist, i);
int j;
+ const char *kstr = NULL;
for (j = 0; j < (sizeof kexes) / (sizeof kexes[0]); j++) {
if (kexes[j].k == k) {
kstr = kexes[j].s;
for (j = 0; j < (sizeof kexes) / (sizeof kexes[0]); j++) {
if (kexes[j].k == k) {
kstr = kexes[j].s;
if (event == EVENT_REFRESH) {
int nprinters, i;
printer_enum *pe;
if (event == EVENT_REFRESH) {
int nprinters, i;
printer_enum *pe;
dlg_update_start(ctrl, dlg);
/*
dlg_update_start(ctrl, dlg);
/*
}
} else if (event == EVENT_ACTION) {
if (ctrl == pfd->addbutton) {
}
} else if (event == EVENT_ACTION) {
if (ctrl == pfd->addbutton) {
- char *family, *type, *src, *key, *val;
+ const char *family, *type;
+ char *src, *key, *val;
int whichbutton;
#ifndef NO_IPV6
int whichbutton;
#ifndef NO_IPV6
if (i < 0) {
dlg_beep(dlg);
} else {
if (i < 0) {
dlg_beep(dlg);
} else {
+ char *key, *p;
+ const char *val;
key = conf_get_str_nthstrkey(conf, CONF_portfwd, i);
if (key) {
key = conf_get_str_nthstrkey(conf, CONF_portfwd, i);
if (key) {
* logging can sensibly be available.
*/
{
* logging can sensibly be available.
*/
{
- char *sshlogname, *sshrawlogname;
+ const char *sshlogname, *sshrawlogname;
if ((midsession && protocol == PROT_SSH) ||
(!midsession && backend_from_proto(PROT_SSH))) {
sshlogname = "SSH packets";
if ((midsession && protocol == PROT_SSH) ||
(!midsession && backend_from_proto(PROT_SSH))) {
sshlogname = "SSH packets";
- char *label = backend_from_proto(PROT_SSH) ?
+ const char *label = backend_from_proto(PROT_SSH) ?
"Logical name of remote host (e.g. for SSH key lookup):" :
"Logical name of remote host:";
s = ctrl_getset(b, "Connection", "identity",
"Logical name of remote host (e.g. for SSH key lookup):" :
"Logical name of remote host:";
s = ctrl_getset(b, "Connection", "identity",
#include "putty.h"
#include "dialog.h"
#include "putty.h"
#include "dialog.h"
-int ctrl_path_elements(char *path)
+int ctrl_path_elements(const char *path)
{
int i = 1;
while (*path) {
{
int i = 1;
while (*path) {
/* Return the number of matching path elements at the starts of p1 and p2,
* or INT_MAX if the paths are identical. */
/* Return the number of matching path elements at the starts of p1 and p2,
* or INT_MAX if the paths are identical. */
-int ctrl_path_compare(char *p1, char *p2)
+int ctrl_path_compare(const char *p1, const char *p2)
{
int i = 0;
while (*p1 || *p2) {
{
int i = 0;
while (*p1 || *p2) {
* path. If that path doesn't exist, return the index where it
* should be inserted.
*/
* path. If that path doesn't exist, return the index where it
* should be inserted.
*/
-static int ctrl_find_set(struct controlbox *b, char *path, int start)
+static int ctrl_find_set(struct controlbox *b, const char *path, int start)
* path, or -1 if no such controlset exists. If -1 is passed as
* input, finds the first.
*/
* path, or -1 if no such controlset exists. If -1 is passed as
* input, finds the first.
*/
-int ctrl_find_path(struct controlbox *b, char *path, int index)
+int ctrl_find_path(struct controlbox *b, const char *path, int index)
{
if (index < 0)
index = ctrl_find_set(b, path, 1);
{
if (index < 0)
index = ctrl_find_set(b, path, 1);
/* Set up a panel title. */
struct controlset *ctrl_settitle(struct controlbox *b,
/* Set up a panel title. */
struct controlset *ctrl_settitle(struct controlbox *b,
- char *path, char *title)
+ const char *path, const char *title)
{
struct controlset *s = snew(struct controlset);
{
struct controlset *s = snew(struct controlset);
}
/* Retrieve a pointer to a controlset, creating it if absent. */
}
/* Retrieve a pointer to a controlset, creating it if absent. */
-struct controlset *ctrl_getset(struct controlbox *b,
- char *path, char *name, char *boxtitle)
+struct controlset *ctrl_getset(struct controlbox *b, const char *path,
+ const char *name, const char *boxtitle)
{
struct controlset *s;
int index = ctrl_find_set(b, path, 1);
{
struct controlset *s;
int index = ctrl_find_set(b, path, 1);
-union control *ctrl_editbox(struct controlset *s, char *label, char shortcut,
- int percentage,
+union control *ctrl_editbox(struct controlset *s, const char *label,
+ char shortcut, int percentage,
intorptr helpctx, handler_fn handler,
intorptr context, intorptr context2)
{
intorptr helpctx, handler_fn handler,
intorptr context, intorptr context2)
{
-union control *ctrl_combobox(struct controlset *s, char *label, char shortcut,
- int percentage,
+union control *ctrl_combobox(struct controlset *s, const char *label,
+ char shortcut, int percentage,
intorptr helpctx, handler_fn handler,
intorptr context, intorptr context2)
{
intorptr helpctx, handler_fn handler,
intorptr context, intorptr context2)
{
* title is expected to be followed by a shortcut _iff_ `shortcut'
* is NO_SHORTCUT.
*/
* title is expected to be followed by a shortcut _iff_ `shortcut'
* is NO_SHORTCUT.
*/
-union control *ctrl_radiobuttons(struct controlset *s, char *label,
+union control *ctrl_radiobuttons(struct controlset *s, const char *label,
char shortcut, int ncolumns, intorptr helpctx,
handler_fn handler, intorptr context, ...)
{
char shortcut, int ncolumns, intorptr helpctx,
handler_fn handler, intorptr context, ...)
{
-union control *ctrl_pushbutton(struct controlset *s,char *label,char shortcut,
- intorptr helpctx, handler_fn handler,
- intorptr context)
+union control *ctrl_pushbutton(struct controlset *s, const char *label,
+ char shortcut, intorptr helpctx,
+ handler_fn handler, intorptr context)
{
union control *c = ctrl_new(s, CTRL_BUTTON, helpctx, handler, context);
c->button.label = label ? dupstr(label) : NULL;
{
union control *c = ctrl_new(s, CTRL_BUTTON, helpctx, handler, context);
c->button.label = label ? dupstr(label) : NULL;
-union control *ctrl_listbox(struct controlset *s,char *label,char shortcut,
- intorptr helpctx, handler_fn handler,
- intorptr context)
+union control *ctrl_listbox(struct controlset *s, const char *label,
+ char shortcut, intorptr helpctx,
+ handler_fn handler, intorptr context)
{
union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
c->listbox.label = label ? dupstr(label) : NULL;
{
union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
c->listbox.label = label ? dupstr(label) : NULL;
-union control *ctrl_droplist(struct controlset *s, char *label, char shortcut,
- int percentage, intorptr helpctx,
+union control *ctrl_droplist(struct controlset *s, const char *label,
+ char shortcut, int percentage, intorptr helpctx,
handler_fn handler, intorptr context)
{
union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
handler_fn handler, intorptr context)
{
union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
-union control *ctrl_draglist(struct controlset *s,char *label,char shortcut,
- intorptr helpctx, handler_fn handler,
- intorptr context)
+union control *ctrl_draglist(struct controlset *s, const char *label,
+ char shortcut, intorptr helpctx,
+ handler_fn handler, intorptr context)
{
union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
c->listbox.label = label ? dupstr(label) : NULL;
{
union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
c->listbox.label = label ? dupstr(label) : NULL;
-union control *ctrl_filesel(struct controlset *s,char *label,char shortcut,
- char const *filter, int write, char *title,
- intorptr helpctx, handler_fn handler,
- intorptr context)
+union control *ctrl_filesel(struct controlset *s, const char *label,
+ char shortcut, const char *filter, int write,
+ const char *title, intorptr helpctx,
+ handler_fn handler, intorptr context)
{
union control *c = ctrl_new(s, CTRL_FILESELECT, helpctx, handler, context);
c->fileselect.label = label ? dupstr(label) : NULL;
{
union control *c = ctrl_new(s, CTRL_FILESELECT, helpctx, handler, context);
c->fileselect.label = label ? dupstr(label) : NULL;
-union control *ctrl_fontsel(struct controlset *s,char *label,char shortcut,
- intorptr helpctx, handler_fn handler,
- intorptr context)
+union control *ctrl_fontsel(struct controlset *s, const char *label,
+ char shortcut, intorptr helpctx,
+ handler_fn handler, intorptr context)
{
union control *c = ctrl_new(s, CTRL_FONTSELECT, helpctx, handler, context);
c->fontselect.label = label ? dupstr(label) : NULL;
{
union control *c = ctrl_new(s, CTRL_FONTSELECT, helpctx, handler, context);
c->fontselect.label = label ? dupstr(label) : NULL;
-union control *ctrl_text(struct controlset *s, char *text, intorptr helpctx)
+union control *ctrl_text(struct controlset *s, const char *text,
+ intorptr helpctx)
{
union control *c = ctrl_new(s, CTRL_TEXT, helpctx, NULL, P(NULL));
c->text.label = dupstr(text);
return c;
}
{
union control *c = ctrl_new(s, CTRL_TEXT, helpctx, NULL, P(NULL));
c->text.label = dupstr(text);
return c;
}
-union control *ctrl_checkbox(struct controlset *s, char *label, char shortcut,
- intorptr helpctx, handler_fn handler,
- intorptr context)
+union control *ctrl_checkbox(struct controlset *s, const char *label,
+ char shortcut, intorptr helpctx,
+ handler_fn handler, intorptr context)
{
union control *c = ctrl_new(s, CTRL_CHECKBOX, helpctx, handler, context);
c->checkbox.label = label ? dupstr(label) : NULL;
{
union control *c = ctrl_new(s, CTRL_CHECKBOX, helpctx, handler, context);
c->checkbox.label = label ? dupstr(label) : NULL;
/* Set up a panel title. */
struct controlset *ctrl_settitle(struct controlbox *,
/* Set up a panel title. */
struct controlset *ctrl_settitle(struct controlbox *,
- char *path, char *title);
+ const char *path, const char *title);
/* Retrieve a pointer to a controlset, creating it if absent. */
/* Retrieve a pointer to a controlset, creating it if absent. */
-struct controlset *ctrl_getset(struct controlbox *,
- char *path, char *name, char *boxtitle);
+struct controlset *ctrl_getset(struct controlbox *, const char *path,
+ const char *name, const char *boxtitle);
void ctrl_free_set(struct controlset *);
void ctrl_free(union control *);
void ctrl_free_set(struct controlset *);
void ctrl_free(union control *);
/* `ncolumns' is followed by that many percentages, as integers. */
union control *ctrl_columns(struct controlset *, int ncolumns, ...);
/* `ncolumns' is followed by that many percentages, as integers. */
union control *ctrl_columns(struct controlset *, int ncolumns, ...);
-union control *ctrl_editbox(struct controlset *, char *label, char shortcut,
- int percentage, intorptr helpctx,
+union control *ctrl_editbox(struct controlset *, const char *label,
+ char shortcut, int percentage, intorptr helpctx,
handler_fn handler,
intorptr context, intorptr context2);
handler_fn handler,
intorptr context, intorptr context2);
-union control *ctrl_combobox(struct controlset *, char *label, char shortcut,
- int percentage, intorptr helpctx,
+union control *ctrl_combobox(struct controlset *, const char *label,
+ char shortcut, int percentage, intorptr helpctx,
handler_fn handler,
intorptr context, intorptr context2);
/*
handler_fn handler,
intorptr context, intorptr context2);
/*
* title is expected to be followed by a shortcut _iff_ `shortcut'
* is NO_SHORTCUT.
*/
* title is expected to be followed by a shortcut _iff_ `shortcut'
* is NO_SHORTCUT.
*/
-union control *ctrl_radiobuttons(struct controlset *, char *label,
- char shortcut, int ncolumns,
- intorptr helpctx,
+union control *ctrl_radiobuttons(struct controlset *, const char *label,
+ char shortcut, int ncolumns, intorptr helpctx,
handler_fn handler, intorptr context, ...);
handler_fn handler, intorptr context, ...);
-union control *ctrl_pushbutton(struct controlset *,char *label,char shortcut,
- intorptr helpctx,
+union control *ctrl_pushbutton(struct controlset *, const char *label,
+ char shortcut, intorptr helpctx,
handler_fn handler, intorptr context);
handler_fn handler, intorptr context);
-union control *ctrl_listbox(struct controlset *,char *label,char shortcut,
- intorptr helpctx,
+union control *ctrl_listbox(struct controlset *, const char *label,
+ char shortcut, intorptr helpctx,
handler_fn handler, intorptr context);
handler_fn handler, intorptr context);
-union control *ctrl_droplist(struct controlset *, char *label, char shortcut,
- int percentage, intorptr helpctx,
+union control *ctrl_droplist(struct controlset *, const char *label,
+ char shortcut, int percentage, intorptr helpctx,
handler_fn handler, intorptr context);
handler_fn handler, intorptr context);
-union control *ctrl_draglist(struct controlset *,char *label,char shortcut,
- intorptr helpctx,
+union control *ctrl_draglist(struct controlset *, const char *label,
+ char shortcut, intorptr helpctx,
handler_fn handler, intorptr context);
handler_fn handler, intorptr context);
-union control *ctrl_filesel(struct controlset *,char *label,char shortcut,
- char const *filter, int write, char *title,
- intorptr helpctx,
+union control *ctrl_filesel(struct controlset *, const char *label,
+ char shortcut, const char *filter, int write,
+ const char *title, intorptr helpctx,
handler_fn handler, intorptr context);
handler_fn handler, intorptr context);
-union control *ctrl_fontsel(struct controlset *,char *label,char shortcut,
- intorptr helpctx,
+union control *ctrl_fontsel(struct controlset *, const char *label,
+ char shortcut, intorptr helpctx,
handler_fn handler, intorptr context);
handler_fn handler, intorptr context);
-union control *ctrl_text(struct controlset *, char *text, intorptr helpctx);
-union control *ctrl_checkbox(struct controlset *, char *label, char shortcut,
- intorptr helpctx,
+union control *ctrl_text(struct controlset *, const char *text,
+ intorptr helpctx);
+union control *ctrl_checkbox(struct controlset *, const char *label,
+ char shortcut, intorptr helpctx,
handler_fn handler, intorptr context);
union control *ctrl_tabdelay(struct controlset *, union control *);
handler_fn handler, intorptr context);
union control *ctrl_tabdelay(struct controlset *, union control *);
* error; dlg_error() puts up a message-box or equivalent.
*/
void dlg_beep(void *dlg);
* error; dlg_error() puts up a message-box or equivalent.
*/
void dlg_beep(void *dlg);
-void dlg_error_msg(void *dlg, char *msg);
+void dlg_error_msg(void *dlg, const char *msg);
/*
* This function signals to the front end that the dialog's
* processing is completed, and passes an integer value (typically
/*
* This function signals to the front end that the dialog's
* processing is completed, and passes an integer value (typically
* ... process this controlset ...
* }
*/
* ... process this controlset ...
* }
*/
-int ctrl_find_path(struct controlbox *b, char *path, int index);
-int ctrl_path_elements(char *path);
+int ctrl_find_path(struct controlbox *b, const char *path, int index);
+int ctrl_path_elements(const char *path);
/* Return the number of matching path elements at the starts of p1 and p2,
* or INT_MAX if the paths are identical. */
/* Return the number of matching path elements at the starts of p1 and p2,
* or INT_MAX if the paths are identical. */
-int ctrl_path_compare(char *p1, char *p2);
+int ctrl_path_compare(const char *p1, const char *p2);
struct openssh_pem_key *ret;
FILE *fp = NULL;
char *line = NULL;
struct openssh_pem_key *ret;
FILE *fp = NULL;
char *line = NULL;
+ const char *errmsg;
+ char *p;
int headers_done;
char base64_bit[4];
int base64_chars = 0;
int headers_done;
char base64_bit[4];
int base64_chars = 0;
int ret, id, len, flags;
int i, num_integers;
struct ssh2_userkey *retval = NULL;
int ret, id, len, flags;
int i, num_integers;
struct ssh2_userkey *retval = NULL;
unsigned char *blob;
int blobsize = 0, blobptr, privptr;
char *modptr = NULL;
unsigned char *blob;
int blobsize = 0, blobptr, privptr;
char *modptr = NULL;
int outlen;
struct mpint_pos numbers[9];
int nnumbers, pos, len, seqlen, i;
int outlen;
struct mpint_pos numbers[9];
int nnumbers, pos, len, seqlen, i;
+ const char *header, *footer;
char zero[1];
unsigned char iv[8];
int ret = 0;
char zero[1];
unsigned char iv[8];
int ret = 0;
struct openssh_new_key *ret;
FILE *fp = NULL;
char *line = NULL;
struct openssh_new_key *ret;
FILE *fp = NULL;
char *line = NULL;
+ const char *errmsg;
+ char *p;
char base64_bit[4];
int base64_chars = 0;
const void *filedata;
char base64_bit[4];
int base64_chars = 0;
const void *filedata;
struct ssh2_userkey *retkey;
int i;
struct ssh2_userkey *retval = NULL;
struct ssh2_userkey *retkey;
int i;
struct ssh2_userkey *retval = NULL;
unsigned char *blob;
int blobsize = 0;
unsigned checkint0, checkint1;
unsigned char *blob;
int blobsize = 0;
unsigned checkint0, checkint1;
FILE *fp;
char *line = NULL;
int hdrstart, len;
FILE *fp;
char *line = NULL;
int hdrstart, len;
+ const char *errmsg;
+ char *p;
int headers_done;
char base64_bit[4];
int base64_chars = 0;
int headers_done;
char base64_bit[4];
int base64_chars = 0;
const char **errmsg_p)
{
struct sshcom_key *key = load_sshcom_key(filename, errmsg_p);
const char **errmsg_p)
{
struct sshcom_key *key = load_sshcom_key(filename, errmsg_p);
int pos, len;
const char prefix_rsa[] = "if-modn{sign{rsa";
const char prefix_dsa[] = "dl-modp{sign{dsa";
int pos, len;
const char prefix_rsa[] = "if-modn{sign{rsa";
const char prefix_dsa[] = "dl-modp{sign{dsa";
int outlen;
struct mpint_pos numbers[6];
int nnumbers, initial_zero, pos, lenpos, i;
int outlen;
struct mpint_pos numbers[6];
int nnumbers, initial_zero, pos, lenpos, i;
char *ciphertext;
int cipherlen;
int ret = 0;
char *ciphertext;
int cipherlen;
int ret = 0;
pos += 4; /* length field, fill in later */
pos += put_string(outblob+pos, type, strlen(type));
{
pos += 4; /* length field, fill in later */
pos += put_string(outblob+pos, type, strlen(type));
{
- char *ciphertype = passphrase ? "3des-cbc" : "none";
+ const char *ciphertype = passphrase ? "3des-cbc" : "none";
pos += put_string(outblob+pos, ciphertype, strlen(ciphertype));
}
lenpos = pos; /* remember this position */
pos += put_string(outblob+pos, ciphertype, strlen(ciphertype));
}
lenpos = pos; /* remember this position */
(ldisc->back->ldisc(ldisc->backhandle, LD_EDIT) || \
term_ldisc(ldisc->term, LD_EDIT))))
(ldisc->back->ldisc(ldisc->backhandle, LD_EDIT) || \
term_ldisc(ldisc->term, LD_EDIT))))
-static void c_write(Ldisc ldisc, char *buf, int len)
+static void c_write(Ldisc ldisc, const char *buf, int len)
{
from_backend(ldisc->frontend, 0, buf, len);
}
{
from_backend(ldisc->frontend, 0, buf, len);
}
frontend_echoedit_update(ldisc->frontend, ECHOING, EDITING);
}
frontend_echoedit_update(ldisc->frontend, ECHOING, EDITING);
}
-void ldisc_send(void *handle, char *buf, int len, int interactive)
+void ldisc_send(void *handle, const char *buf, int len, int interactive)
{
Ldisc ldisc = (Ldisc) handle;
int keyflag = 0;
{
Ldisc ldisc = (Ldisc) handle;
int keyflag = 0;
#include "ldisc.h"
void lpage_send(void *handle,
#include "ldisc.h"
void lpage_send(void *handle,
- int codepage, char *buf, int len, int interactive)
+ int codepage, const char *buf, int len, int interactive)
{
Ldisc ldisc = (Ldisc)handle;
wchar_t *widebuffer = 0;
{
Ldisc ldisc = (Ldisc)handle;
wchar_t *widebuffer = 0;
-void luni_send(void *handle, wchar_t * widebuf, int len, int interactive)
+void luni_send(void *handle, const wchar_t *widebuf, int len, int interactive)
{
Ldisc ldisc = (Ldisc)handle;
int ratio = (in_utf(ldisc->term))?3:1;
{
Ldisc ldisc = (Ldisc)handle;
int ratio = (in_utf(ldisc->term))?3:1;
* Set of blanking areas must be in increasing order.
*/
void log_packet(void *handle, int direction, int type,
* Set of blanking areas must be in increasing order.
*/
void log_packet(void *handle, int direction, int type,
- char *texttype, const void *data, int len,
+ const char *texttype, const void *data, int len,
int n_blanks, const struct logblank_t *blanks,
const unsigned long *seq,
unsigned downstream_id, const char *additional_log_text)
int n_blanks, const struct logblank_t *blanks,
const unsigned long *seq,
unsigned downstream_id, const char *additional_log_text)
-void dlg_error_msg(void *dv, char *msg)
+void dlg_error_msg(void *dv, const char *msg)
[win endSession:FALSE];
}
[win endSession:FALSE];
}
-void connection_fatal(void *frontend, char *p, ...)
+void connection_fatal(void *frontend, const char *p, ...)
{
SessionWindow *win = (SessionWindow *)frontend;
va_list ap;
{
SessionWindow *win = (SessionWindow *)frontend;
va_list ap;
return NULL; /* this is a stub */
}
return NULL; /* this is a stub */
}
-static void commonfatalbox(char *p, va_list ap)
+static void commonfatalbox(const char *p, va_list ap)
{
char errorbuf[2048];
NSAlert *alert;
{
char errorbuf[2048];
NSAlert *alert;
-void nonfatal(void *frontend, char *p, ...)
+void nonfatal(void *frontend, const char *p, ...)
{
char *errorbuf;
NSAlert *alert;
{
char *errorbuf;
NSAlert *alert;
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
{
va_list ap;
va_start(ap, p);
{
va_list ap;
va_start(ap, p);
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
{
va_list ap;
va_start(ap, p);
{
va_list ap;
va_start(ap, p);
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
{
va_list ap;
fprintf(stderr, "%s: ", appname);
{
va_list ap;
fprintf(stderr, "%s: ", appname);
return [win fromBackendUntrusted:data len:len];
}
return [win fromBackendUntrusted:data len:len];
}
-int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{
SessionWindow *win = (SessionWindow *)p->frontend;
Terminal *term = [win term];
{
SessionWindow *win = (SessionWindow *)p->frontend;
Terminal *term = [win term];
return fails != 0 ? 1 : 0;
}
/* Stubs to stop the rest of this module causing compile failures. */
return fails != 0 ? 1 : 0;
}
/* Stubs to stop the rest of this module causing compile failures. */
-void modalfatalbox(char *fmt, ...) {}
+void modalfatalbox(const char *fmt, ...) {}
int conf_get_int(Conf *conf, int primary) { return 0; }
char *conf_get_str(Conf *conf, int primary) { return NULL; }
#endif /* TEST_HOST_STRFOO */
int conf_get_int(Conf *conf, int primary) { return 0; }
char *conf_get_str(Conf *conf, int primary) { return NULL; }
#endif /* TEST_HOST_STRFOO */
-extern void dputs(char *); /* defined in per-platform *misc.c */
+extern void dputs(const char *); /* defined in per-platform *misc.c */
void debug_printf(const char *fmt, ...)
{
void debug_printf(const char *fmt, ...)
{
/* proxy indirection layer */
/* NB, control of 'addr' is passed via new_connection, which takes
* responsibility for freeing it */
/* proxy indirection layer */
/* NB, control of 'addr' is passed via new_connection, which takes
* responsibility for freeing it */
-Socket new_connection(SockAddr addr, char *hostname,
+Socket new_connection(SockAddr addr, const char *hostname,
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf);
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf);
-Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only,
- Conf *conf, int addressfamily);
-SockAddr name_lookup(char *host, int port, char **canonicalname,
+Socket new_listener(const char *srcaddr, int port, Plug plug,
+ int local_host_only, Conf *conf, int addressfamily);
+SockAddr name_lookup(const char *host, int port, char **canonicalname,
Conf *conf, int addressfamily);
int proxy_for_destination (SockAddr addr, const char *hostname, int port,
Conf *conf);
/* platform-dependent callback from new_connection() */
/* (same caveat about addr as new_connection()) */
Conf *conf, int addressfamily);
int proxy_for_destination (SockAddr addr, const char *hostname, int port,
Conf *conf);
/* platform-dependent callback from new_connection() */
/* (same caveat about addr as new_connection()) */
-Socket platform_new_connection(SockAddr addr, char *hostname,
+Socket platform_new_connection(SockAddr addr, const char *hostname,
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf);
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf);
Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
int nodelay, int keepalive, Plug p);
Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
int nodelay, int keepalive, Plug p);
-Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, int address_family);
+Socket sk_newlistener(const char *srcaddr, int port, Plug plug,
+ int local_host_only, int address_family);
#define sk_plug(s,p) (((*s)->plug) (s, p))
#define sk_close(s) (((*s)->close) (s))
#define sk_plug(s,p) (((*s)->plug) (s, p))
#define sk_close(s) (((*s)->close) (s))
-SockAddr name_lookup(char *host, int port, char **canonicalname,
+SockAddr name_lookup(const char *host, int port, char **canonicalname,
Conf *conf, int addressfamily)
{
if (conf_get_int(conf, CONF_proxy_type) != PROXY_NONE &&
Conf *conf, int addressfamily)
{
if (conf_get_int(conf, CONF_proxy_type) != PROXY_NONE &&
return sk_namelookup(host, canonicalname, addressfamily);
}
return sk_namelookup(host, canonicalname, addressfamily);
}
-Socket new_connection(SockAddr addr, char *hostname,
+Socket new_connection(SockAddr addr, const char *hostname,
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf)
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf)
return sk_new(addr, port, privport, oobinline, nodelay, keepalive, plug);
}
return sk_new(addr, port, privport, oobinline, nodelay, keepalive, plug);
}
-Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only,
- Conf *conf, int addressfamily)
+Socket new_listener(const char *srcaddr, int port, Plug plug,
+ int local_host_only, Conf *conf, int addressfamily)
{
/* TODO: SOCKS (and potentially others) support inbound
* TODO: connections via the proxy. support them.
{
/* TODO: SOCKS (and potentially others) support inbound
* TODO: connections via the proxy. support them.
const struct socket_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */
const struct socket_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */
Socket sub_socket;
Plug plug;
Socket sub_socket;
Plug plug;
static Conf *conf;
int sent_eof = FALSE;
static Conf *conf;
int sent_eof = FALSE;
-static void source(char *src);
-static void rsource(char *src);
-static void sink(char *targ, char *src);
+static void source(const char *src);
+static void rsource(const char *src);
+static void sink(const char *targ, const char *src);
const char *const appname = "PSCP";
const char *const appname = "PSCP";
void ldisc_echoedit_update(void *handle) { }
void ldisc_echoedit_update(void *handle) { }
-static void tell_char(FILE * stream, char c)
+static void tell_char(FILE *stream, char c)
-static void tell_str(FILE * stream, char *str)
+static void tell_str(FILE *stream, const char *str)
tell_char(stream, str[i]);
}
tell_char(stream, str[i]);
}
-static void tell_user(FILE * stream, char *fmt, ...)
+static void tell_user(FILE *stream, const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
/*
* Print an error message and perform a fatal exit.
*/
/*
* Print an error message and perform a fatal exit.
*/
-void fatalbox(char *fmt, ...)
+void fatalbox(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
-void nonfatal(char *fmt, ...)
+void nonfatal(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
-void connection_fatal(void *frontend, char *fmt, ...)
+void connection_fatal(void *frontend, const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
/*
* Print an error message and exit after closing the SSH link.
*/
/*
* Print an error message and exit after closing the SSH link.
*/
-static void bump(char *fmt, ...)
+static void bump(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
/*
* Update statistic information about current file.
*/
/*
* Update statistic information about current file.
*/
-static void print_stats(char *name, uint64 size, uint64 done,
+static void print_stats(const char *name, uint64 size, uint64 done,
time_t start, time_t now)
{
float ratebs;
time_t start, time_t now)
{
float ratebs;
/*
* Return a pointer to the portion of str that comes after the last
* slash (or backslash or colon, if `local' is TRUE).
/*
* Return a pointer to the portion of str that comes after the last
* slash (or backslash or colon, if `local' is TRUE).
+ *
+ * This function has the annoying strstr() property of taking a const
+ * char * and returning a char *. You should treat it as if it was a
+ * pair of overloaded functions, one mapping mutable->mutable and the
+ * other const->const :-(
-static char *stripslashes(char *str, int local)
+static char *stripslashes(const char *str, int local)
const struct fxp_name *b = (const struct fxp_name *) bv;
return strcmp(a->filename, b->filename);
}
const struct fxp_name *b = (const struct fxp_name *) bv;
return strcmp(a->filename, b->filename);
}
-void scp_sftp_listdir(char *dirname)
+void scp_sftp_listdir(const char *dirname)
{
struct fxp_handle *dirh;
struct fxp_names *names;
{
struct fxp_handle *dirh;
struct fxp_names *names;
static struct fxp_xfer *scp_sftp_xfer;
static uint64 scp_sftp_fileoffset;
static struct fxp_xfer *scp_sftp_xfer;
static uint64 scp_sftp_fileoffset;
-int scp_source_setup(char *target, int shouldbedir)
+int scp_source_setup(const char *target, int shouldbedir)
-int scp_send_filename(char *name, uint64 size, int permissions)
+int scp_send_filename(const char *name, uint64 size, int permissions)
{
if (using_sftp) {
char *fullname;
{
if (using_sftp) {
char *fullname;
scp_sftp_remotepath = data;
}
scp_sftp_remotepath = data;
}
-int scp_send_dirname(char *name, int modes)
+int scp_send_dirname(const char *name, int modes)
{
if (using_sftp) {
char *fullname;
{
if (using_sftp) {
char *fullname;
* right at the start, whereas scp_sink_init is called to
* initialise every level of recursion in the protocol.
*/
* right at the start, whereas scp_sink_init is called to
* initialise every level of recursion in the protocol.
*/
-int scp_sink_setup(char *source, int preserve, int recursive)
+int scp_sink_setup(const char *source, int preserve, int recursive)
{
if (using_sftp) {
char *newsource;
{
if (using_sftp) {
char *newsource;
/*
* Execute the source part of the SCP protocol.
*/
/*
* Execute the source part of the SCP protocol.
*/
-static void source(char *src)
+static void source(const char *src)
{
uint64 size;
unsigned long mtime, atime;
long permissions;
{
uint64 size;
unsigned long mtime, atime;
long permissions;
RFile *f;
int attr;
uint64 i;
RFile *f;
int attr;
uint64 i;
/*
* Avoid . and .. directories.
*/
/*
* Avoid . and .. directories.
*/
p = strrchr(src, '/');
if (!p)
p = strrchr(src, '\\');
p = strrchr(src, '/');
if (!p)
p = strrchr(src, '\\');
/*
* Recursively send the contents of a directory.
*/
/*
* Recursively send the contents of a directory.
*/
-static void rsource(char *src)
+static void rsource(const char *src)
char *save_target;
DirHandle *dir;
char *save_target;
DirHandle *dir;
/*
* Execute the sink part of the SCP protocol.
*/
/*
* Execute the sink part of the SCP protocol.
*/
-static void sink(char *targ, char *src)
+static void sink(const char *targ, const char *src)
{
char *destfname;
int targisdir = 0;
{
char *destfname;
int targisdir = 0;
*/
static void toremote(int argc, char *argv[])
{
*/
static void toremote(int argc, char *argv[])
{
- char *src, *targ, *host, *user;
+ char *src, *wtarg, *host, *user;
+ const char *targ;
char *cmd;
int i, wc_type;
uploading = 1;
char *cmd;
int i, wc_type;
uploading = 1;
+ wtarg = argv[argc - 1];
/* Separate host from filename */
/* Separate host from filename */
- host = targ;
- targ = colon(targ);
- if (targ == NULL)
- bump("targ == NULL in toremote()");
- *targ++ = '\0';
- if (*targ == '\0')
- targ = ".";
+ host = wtarg;
+ wtarg = colon(wtarg);
+ if (wtarg == NULL)
+ bump("wtarg == NULL in toremote()");
+ *wtarg++ = '\0';
/* Substitute "." for empty target */
/* Substitute "." for empty target */
+ if (*wtarg == '\0')
+ targ = ".";
+ else
+ targ = wtarg;
/* Separate host and username */
user = host;
/* Separate host and username */
user = host;
*/
static void tolocal(int argc, char *argv[])
{
*/
static void tolocal(int argc, char *argv[])
{
- char *src, *targ, *host, *user;
+ char *wsrc, *host, *user;
+ const char *src, *targ;
char *cmd;
uploading = 0;
char *cmd;
uploading = 0;
if (argc != 2)
bump("More than one remote source not supported");
if (argc != 2)
bump("More than one remote source not supported");
targ = argv[1];
/* Separate host from filename */
targ = argv[1];
/* Separate host from filename */
- host = src;
- src = colon(src);
- if (src == NULL)
+ host = wsrc;
+ wsrc = colon(wsrc);
+ if (wsrc == NULL)
bump("Local to local copy not supported");
bump("Local to local copy not supported");
- *src++ = '\0';
- if (*src == '\0')
- src = ".";
/* Substitute "." for empty filename */
/* Substitute "." for empty filename */
+ if (*wsrc == '\0')
+ src = ".";
+ else
+ src = wsrc;
/* Separate username and hostname */
user = host;
/* Separate username and hostname */
user = host;
*/
static void get_dir_list(int argc, char *argv[])
{
*/
static void get_dir_list(int argc, char *argv[])
{
- char *src, *host, *user;
- char *cmd, *p, *q;
+ char *wsrc, *host, *user;
+ const char *src;
+ char *cmd, *p;
+ const char *q;
/* Separate host from filename */
/* Separate host from filename */
- host = src;
- src = colon(src);
- if (src == NULL)
+ host = wsrc;
+ wsrc = colon(wsrc);
+ if (wsrc == NULL)
bump("Local file listing not supported");
bump("Local file listing not supported");
- *src++ = '\0';
- if (*src == '\0')
- src = ".";
/* Substitute "." for empty filename */
/* Substitute "." for empty filename */
+ if (*wsrc == '\0')
+ src = ".";
+ else
+ src = wsrc;
/* Separate username and hostname */
user = host;
/* Separate username and hostname */
user = host;
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
{
va_list ap;
fprintf(stderr, "pscp: ");
{
va_list ap;
fprintf(stderr, "pscp: ");
* canonification fails, at least fall back to returning a _valid_
* pathname (though it may be ugly, eg /home/simon/../foobar).
*/
* canonification fails, at least fall back to returning a _valid_
* pathname (though it may be ugly, eg /home/simon/../foobar).
*/
-char *canonify(char *name)
+char *canonify(const char *name)
{
char *fullname, *canonname;
struct sftp_packet *pktin;
{
char *fullname, *canonname;
struct sftp_packet *pktin;
if (name[0] == '/') {
fullname = dupstr(name);
} else {
if (name[0] == '/') {
fullname = dupstr(name);
} else {
if (pwd[strlen(pwd) - 1] == '/')
slash = "";
else
if (pwd[strlen(pwd) - 1] == '/')
slash = "";
else
/*
* Return a pointer to the portion of str that comes after the last
* slash (or backslash or colon, if `local' is TRUE).
/*
* Return a pointer to the portion of str that comes after the last
* slash (or backslash or colon, if `local' is TRUE).
+ *
+ * This function has the annoying strstr() property of taking a const
+ * char * and returning a char *. You should treat it as if it was a
+ * pair of overloaded functions, one mapping mutable->mutable and the
+ * other const->const :-(
-static char *stripslashes(char *str, int local)
+static char *stripslashes(const char *str, int local)
struct fxp_names *names;
struct fxp_name **ournames;
int nnames, namesize;
struct fxp_names *names;
struct fxp_name **ournames;
int nnames, namesize;
- char *dir, *cdir, *unwcdir, *wildcard;
+ const char *dir;
+ char *cdir, *unwcdir, *wildcard;
struct sftp_packet *pktin;
struct sftp_request *req;
int i;
struct sftp_packet *pktin;
struct sftp_request *req;
int i;
static int sftp_cmd_help(struct sftp_command *cmd);
static struct sftp_cmd_lookup {
static int sftp_cmd_help(struct sftp_command *cmd);
static struct sftp_cmd_lookup {
/*
* For help purposes, there are two kinds of command:
*
/*
* For help purposes, there are two kinds of command:
*
* contains the help that should double up for this command.
*/
int listed; /* do we list this in primary help? */
* contains the help that should double up for this command.
*/
int listed; /* do we list this in primary help? */
- char *shorthelp;
- char *longhelp;
+ const char *shorthelp;
+ const char *longhelp;
int (*obey) (struct sftp_command *);
} sftp_lookup[] = {
/*
int (*obey) (struct sftp_command *);
} sftp_lookup[] = {
/*
-const struct sftp_cmd_lookup *lookup_command(char *name)
+const struct sftp_cmd_lookup *lookup_command(const char *name)
/*
* Print an error message and perform a fatal exit.
*/
/*
* Print an error message and perform a fatal exit.
*/
-void fatalbox(char *fmt, ...)
+void fatalbox(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
-void nonfatal(char *fmt, ...)
+void nonfatal(const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
fputs(str2, stderr);
sfree(str2);
}
fputs(str2, stderr);
sfree(str2);
}
-void connection_fatal(void *frontend, char *fmt, ...)
+void connection_fatal(void *frontend, const char *fmt, ...)
{
char *str, *str2;
va_list ap;
{
char *str, *str2;
va_list ap;
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
{
va_list ap;
fprintf(stderr, "psftp: ");
{
va_list ap;
fprintf(stderr, "psftp: ");
* FALSE, a back end is not (intentionally) active at all (e.g.
* psftp before an `open' command).
*/
* FALSE, a back end is not (intentionally) active at all (e.g.
* psftp before an `open' command).
*/
-char *ssh_sftp_get_cmdline(char *prompt, int backend_required);
+char *ssh_sftp_get_cmdline(const char *prompt, int backend_required);
/*
* The main program in psftp.c. Called from main() in the platform-
/*
* The main program in psftp.c. Called from main() in the platform-
* probably only ever be supported on Windows, so these functions
* can safely be stubs on all other platforms.
*/
* probably only ever be supported on Windows, so these functions
* can safely be stubs on all other platforms.
*/
-void gui_update_stats(char *name, unsigned long size,
+void gui_update_stats(const char *name, unsigned long size,
int percentage, unsigned long elapsed,
unsigned long done, unsigned long eta,
unsigned long ratebs);
void gui_send_errcount(int list, int errs);
void gui_send_char(int is_stderr, int c);
int percentage, unsigned long elapsed,
unsigned long done, unsigned long eta,
unsigned long ratebs);
void gui_send_errcount(int list, int errs);
void gui_send_char(int is_stderr, int c);
-void gui_enable(char *arg);
+void gui_enable(const char *arg);
/*
* It's likely that a given platform's implementation of file
/*
* It's likely that a given platform's implementation of file
typedef struct WFile WFile;
/* Output params size, perms, mtime and atime can all be NULL if
* desired. perms will be -1 if the OS does not support POSIX permissions. */
typedef struct WFile WFile;
/* Output params size, perms, mtime and atime can all be NULL if
* desired. perms will be -1 if the OS does not support POSIX permissions. */
-RFile *open_existing_file(char *name, uint64 *size,
+RFile *open_existing_file(const char *name, uint64 *size,
unsigned long *mtime, unsigned long *atime,
long *perms);
unsigned long *mtime, unsigned long *atime,
long *perms);
-WFile *open_existing_wfile(char *name, uint64 *size);
+WFile *open_existing_wfile(const char *name, uint64 *size);
/* Returns <0 on error, 0 on eof, or number of bytes read, as usual */
int read_from_file(RFile *f, void *buffer, int length);
/* Closes and frees the RFile */
void close_rfile(RFile *f);
/* Returns <0 on error, 0 on eof, or number of bytes read, as usual */
int read_from_file(RFile *f, void *buffer, int length);
/* Closes and frees the RFile */
void close_rfile(RFile *f);
-WFile *open_new_file(char *name, long perms);
+WFile *open_new_file(const char *name, long perms);
/* Returns <0 on error, 0 on eof, or number of bytes written, as usual */
int write_to_file(WFile *f, void *buffer, int length);
void set_file_times(WFile *f, unsigned long mtime, unsigned long atime);
/* Returns <0 on error, 0 on eof, or number of bytes written, as usual */
int write_to_file(WFile *f, void *buffer, int length);
void set_file_times(WFile *f, unsigned long mtime, unsigned long atime);
enum {
FILE_TYPE_NONEXISTENT, FILE_TYPE_FILE, FILE_TYPE_DIRECTORY, FILE_TYPE_WEIRD
};
enum {
FILE_TYPE_NONEXISTENT, FILE_TYPE_FILE, FILE_TYPE_DIRECTORY, FILE_TYPE_WEIRD
};
-int file_type(char *name);
+int file_type(const char *name);
/*
* Read all the file names out of a directory.
*/
typedef struct DirHandle DirHandle;
/*
* Read all the file names out of a directory.
*/
typedef struct DirHandle DirHandle;
-DirHandle *open_directory(char *name);
+DirHandle *open_directory(const char *name);
/* The string returned from this will need freeing if not NULL */
char *read_filename(DirHandle *dir);
void close_directory(DirHandle *dir);
/* The string returned from this will need freeing if not NULL */
char *read_filename(DirHandle *dir);
void close_directory(DirHandle *dir);
enum {
WCTYPE_NONEXISTENT, WCTYPE_FILENAME, WCTYPE_WILDCARD
};
enum {
WCTYPE_NONEXISTENT, WCTYPE_FILENAME, WCTYPE_WILDCARD
};
-int test_wildcard(char *name, int cmdline);
+int test_wildcard(const char *name, int cmdline);
/*
* Actually return matching file names for a local wildcard.
*/
typedef struct WildcardMatcher WildcardMatcher;
/*
* Actually return matching file names for a local wildcard.
*/
typedef struct WildcardMatcher WildcardMatcher;
-WildcardMatcher *begin_wildcard_matching(char *name);
+WildcardMatcher *begin_wildcard_matching(const char *name);
/* The string returned from this will need freeing if not NULL */
char *wildcard_get_filename(WildcardMatcher *dir);
void finish_wildcard_matching(WildcardMatcher *dir);
/* The string returned from this will need freeing if not NULL */
char *wildcard_get_filename(WildcardMatcher *dir);
void finish_wildcard_matching(WildcardMatcher *dir);
*
* Returns TRUE if the filename is kosher, FALSE if dangerous.
*/
*
* Returns TRUE if the filename is kosher, FALSE if dangerous.
*/
-int vet_filename(char *name);
+int vet_filename(const char *name);
/*
* Create a directory. Returns 0 on error, !=0 on success.
*/
/*
* Create a directory. Returns 0 on error, !=0 on success.
*/
-int create_directory(char *name);
+int create_directory(const char *name);
/*
* Concatenate a directory name and a file name. The way this is
* done will depend on the OS.
*/
/*
* Concatenate a directory name and a file name. The way this is
* done will depend on the OS.
*/
-char *dir_file_cat(char *dir, char *file);
+char *dir_file_cat(const char *dir, const char *file);
#endif /* PUTTY_PSFTP_H */
#endif /* PUTTY_PSFTP_H */
struct sesslist {
int nsessions;
struct sesslist {
int nsessions;
char *buffer; /* so memory can be freed later */
};
char *buffer; /* so memory can be freed later */
};
* Two fields which define a string and enum value to be
* equivalent to each other.
*/
* Two fields which define a string and enum value to be
* equivalent to each other.
*/
struct backend_tag {
const char *(*init) (void *frontend_handle, void **backend_handle,
struct backend_tag {
const char *(*init) (void *frontend_handle, void **backend_handle,
- Conf *conf, char *host, int port, char **realhost,
- int nodelay, int keepalive);
+ Conf *conf, const char *host, int port,
+ char **realhost, int nodelay, int keepalive);
void (*free) (void *handle);
/* back->reconfig() passes in a replacement configuration. */
void (*reconfig) (void *handle, Conf *conf);
/* back->send() returns the current amount of buffered data. */
void (*free) (void *handle);
/* back->reconfig() passes in a replacement configuration. */
void (*reconfig) (void *handle, Conf *conf);
/* back->send() returns the current amount of buffered data. */
- int (*send) (void *handle, char *buf, int len);
+ int (*send) (void *handle, const char *buf, int len);
/* back->sendbuffer() does the same thing but without attempting a send */
int (*sendbuffer) (void *handle);
void (*size) (void *handle, int width, int height);
/* back->sendbuffer() does the same thing but without attempting a send */
int (*sendbuffer) (void *handle);
void (*size) (void *handle, int width, int height);
*/
void (*unthrottle) (void *handle, int);
int (*cfg_info) (void *handle);
*/
void (*unthrottle) (void *handle, int);
int (*cfg_info) (void *handle);
int protocol;
int default_port;
};
int protocol;
int default_port;
};
void get_clip(void *frontend, wchar_t **, int *);
void optimised_move(void *frontend, int, int, int);
void set_raw_mouse_mode(void *frontend, int);
void get_clip(void *frontend, wchar_t **, int *);
void optimised_move(void *frontend, int, int, int);
void set_raw_mouse_mode(void *frontend, int);
-void connection_fatal(void *frontend, char *, ...);
-void nonfatal(char *, ...);
-void fatalbox(char *, ...);
-void modalfatalbox(char *, ...);
+void connection_fatal(void *frontend, const char *, ...);
+void nonfatal(const char *, ...);
+void fatalbox(const char *, ...);
+void modalfatalbox(const char *, ...);
#ifdef macintosh
#pragma noreturn(fatalbox)
#pragma noreturn(modalfatalbox)
#ifdef macintosh
#pragma noreturn(fatalbox)
#pragma noreturn(modalfatalbox)
* 0 = `user cancelled' (FIXME distinguish "give up entirely" and "next auth"?)
* <0 = `please call back later with more in/inlen'
*/
* 0 = `user cancelled' (FIXME distinguish "give up entirely" and "next auth"?)
* <0 = `please call back later with more in/inlen'
*/
-int get_userpass_input(prompts_t *p, unsigned char *in, int inlen);
+int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen);
#define OPTIMISE_IS_SCROLL 1
void set_iconic(void *frontend, int iconic);
#define OPTIMISE_IS_SCROLL 1
void set_iconic(void *frontend, int iconic);
Backend *backend_from_name(const char *name);
Backend *backend_from_proto(int proto);
char *get_remote_username(Conf *conf); /* dynamically allocated */
Backend *backend_from_name(const char *name);
Backend *backend_from_proto(int proto);
char *get_remote_username(Conf *conf); /* dynamically allocated */
-char *save_settings(char *section, Conf *conf);
+char *save_settings(const char *section, Conf *conf);
void save_open_settings(void *sesskey, Conf *conf);
void save_open_settings(void *sesskey, Conf *conf);
-void load_settings(char *section, Conf *conf);
+void load_settings(const char *section, Conf *conf);
void load_open_settings(void *sesskey, Conf *conf);
void get_sesslist(struct sesslist *, int allocate);
void load_open_settings(void *sesskey, Conf *conf);
void get_sesslist(struct sesslist *, int allocate);
-void do_defaults(char *, Conf *);
+void do_defaults(const char *, Conf *);
void registry_cleanup(void);
/*
void registry_cleanup(void);
/*
void term_set_focus(Terminal *term, int has_focus);
char *term_get_ttymode(Terminal *term, const char *mode);
int term_get_userpass_input(Terminal *term, prompts_t *p,
void term_set_focus(Terminal *term, int has_focus);
char *term_get_ttymode(Terminal *term, const char *mode);
int term_get_userpass_input(Terminal *term, prompts_t *p,
- unsigned char *in, int inlen);
+ const unsigned char *in, int inlen);
int format_arrow_key(char *buf, Terminal *term, int xkey, int ctrl);
int format_arrow_key(char *buf, Terminal *term, int xkey, int ctrl);
int type;
};
void log_packet(void *logctx, int direction, int type,
int type;
};
void log_packet(void *logctx, int direction, int type,
- char *texttype, const void *data, int len,
+ const char *texttype, const void *data, int len,
int n_blanks, const struct logblank_t *blanks,
const unsigned long *sequence,
unsigned downstream_id, const char *additional_log_text);
int n_blanks, const struct logblank_t *blanks,
const unsigned long *sequence,
unsigned downstream_id, const char *additional_log_text);
void *ldisc_create(Conf *, Terminal *, Backend *, void *, void *);
void ldisc_configure(void *, Conf *);
void ldisc_free(void *);
void *ldisc_create(Conf *, Terminal *, Backend *, void *, void *);
void ldisc_configure(void *, Conf *);
void ldisc_free(void *);
-void ldisc_send(void *handle, char *buf, int len, int interactive);
+void ldisc_send(void *handle, const char *buf, int len, int interactive);
void ldisc_echoedit_update(void *handle);
/*
* Exports from ldiscucs.c.
*/
void ldisc_echoedit_update(void *handle);
/*
* Exports from ldiscucs.c.
*/
-void lpage_send(void *, int codepage, char *buf, int len, int interactive);
-void luni_send(void *, wchar_t * widebuf, int len, int interactive);
+void lpage_send(void *, int codepage, const char *buf, int len,
+ int interactive);
+void luni_send(void *, const wchar_t * widebuf, int len, int interactive);
/*
* Exports from sshrand.c.
/*
* Exports from sshrand.c.
int mb_to_wc(int codepage, int flags, const char *mbstr, int mblen,
wchar_t *wcstr, int wclen);
int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
int mb_to_wc(int codepage, int flags, const char *mbstr, int mblen,
wchar_t *wcstr, int wclen);
int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
- char *mbstr, int mblen, char *defchr, int *defused,
+ char *mbstr, int mblen, const char *defchr, int *defused,
struct unicode_data *ucsdata);
wchar_t xlat_uskbd2cyrllic(int ch);
int check_compose(int first, int second);
struct unicode_data *ucsdata);
wchar_t xlat_uskbd2cyrllic(int ch);
int check_compose(int first, int second);
* that aren't equivalents to things in windlg.c et al.
*/
extern int console_batch_mode;
* that aren't equivalents to things in windlg.c et al.
*/
extern int console_batch_mode;
-int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen);
+int console_get_userpass_input(prompts_t *p, const unsigned char *in,
+ int inlen);
void console_provide_logctx(void *logctx);
int is_interactive(void);
void console_provide_logctx(void *logctx);
int is_interactive(void);
* Exports from cmdline.c (and also cmdline_error(), which is
* defined differently in various places and required _by_
* cmdline.c).
* Exports from cmdline.c (and also cmdline_error(), which is
* defined differently in various places and required _by_
* cmdline.c).
+ *
+ * Note that cmdline_process_param takes a const option string, but a
+ * writable argument string. That's not a mistake - that's so it can
+ * zero out password arguments in the hope of not having them show up
+ * avoidably in Unix 'ps'.
-int cmdline_process_param(char *, char *, int, Conf *);
+int cmdline_process_param(const char *, char *, int, Conf *);
void cmdline_run_saved(Conf *);
void cmdline_cleanup(void);
void cmdline_run_saved(Conf *);
void cmdline_cleanup(void);
-int cmdline_get_passwd_input(prompts_t *p, unsigned char *in, int inlen);
+int cmdline_get_passwd_input(prompts_t *p, const unsigned char *in, int inlen);
#define TOOLTYPE_FILETRANSFER 1
#define TOOLTYPE_NONNETWORK 2
extern int cmdline_tooltype;
#define TOOLTYPE_FILETRANSFER 1
#define TOOLTYPE_NONNETWORK 2
extern int cmdline_tooltype;
-void cmdline_error(char *, ...);
+void cmdline_error(const char *, ...);
/*
* Exports from config.c.
/*
* Exports from config.c.
*/
static const char *raw_init(void *frontend_handle, void **backend_handle,
Conf *conf,
*/
static const char *raw_init(void *frontend_handle, void **backend_handle,
Conf *conf,
- char *host, int port, char **realhost, int nodelay,
- int keepalive)
+ const char *host, int port, char **realhost,
+ int nodelay, int keepalive)
{
static const struct plug_function_table fn_table = {
raw_log,
{
static const struct plug_function_table fn_table = {
raw_log,
/*
* Called to send data down the raw connection.
*/
/*
* Called to send data down the raw connection.
*/
-static int raw_send(void *handle, char *buf, int len)
+static int raw_send(void *handle, const char *buf, int len)
{
Raw raw = (Raw) handle;
{
Raw raw = (Raw) handle;
*/
static const char *rlogin_init(void *frontend_handle, void **backend_handle,
Conf *conf,
*/
static const char *rlogin_init(void *frontend_handle, void **backend_handle,
Conf *conf,
- char *host, int port, char **realhost,
+ const char *host, int port, char **realhost,
int nodelay, int keepalive)
{
static const struct plug_function_table fn_table = {
int nodelay, int keepalive)
{
static const struct plug_function_table fn_table = {
/*
* Called to send data down the rlogin connection.
*/
/*
* Called to send data down the rlogin connection.
*/
-static int rlogin_send(void *handle, char *buf, int len)
+static int rlogin_send(void *handle, const char *buf, int len)
{
Rlogin rlogin = (Rlogin) handle;
{
Rlogin rlogin = (Rlogin) handle;
-static int gppi_raw(void *handle, char *name, int def)
+static int gppi_raw(void *handle, const char *name, int def)
{
def = platform_default_i(name, def);
return read_setting_i(handle, name, def);
}
{
def = platform_default_i(name, def);
return read_setting_i(handle, name, def);
}
-static void gppi(void *handle, char *name, int def, Conf *conf, int primary)
+static void gppi(void *handle, const char *name, int def,
+ Conf *conf, int primary)
{
conf_set_int(conf, primary, gppi_raw(handle, name, def));
}
{
conf_set_int(conf, primary, gppi_raw(handle, name, def));
}
* If there's no "=VALUE" (e.g. just NAME,NAME,NAME) then those keys
* are mapped to the empty string.
*/
* If there's no "=VALUE" (e.g. just NAME,NAME,NAME) then those keys
* are mapped to the empty string.
*/
-static int gppmap(void *handle, char *name, Conf *conf, int primary)
+static int gppmap(void *handle, const char *name, Conf *conf, int primary)
{
char *buf, *p, *q, *key, *val;
{
char *buf, *p, *q, *key, *val;
static void wmap(void *handle, char const *outkey, Conf *conf, int primary,
int include_values)
{
static void wmap(void *handle, char const *outkey, Conf *conf, int primary,
int include_values)
{
- char *buf, *p, *q, *key, *realkey, *val;
+ char *buf, *p, *key, *realkey;
+ const char *val, *q;
int len;
len = 1; /* allow for NUL */
int len;
len = 1; /* allow for NUL */
* to the end and duplicates are weeded.
* XXX: assumes vals in 'mapping' are small +ve integers
*/
* to the end and duplicates are weeded.
* XXX: assumes vals in 'mapping' are small +ve integers
*/
-static void gprefs(void *sesskey, char *name, char *def,
+static void gprefs(void *sesskey, const char *name, const char *def,
const struct keyvalwhere *mapping, int nvals,
Conf *conf, int primary)
{
const struct keyvalwhere *mapping, int nvals,
Conf *conf, int primary)
{
/*
* Write out a preference list.
*/
/*
* Write out a preference list.
*/
-static void wprefs(void *sesskey, char *name,
+static void wprefs(void *sesskey, const char *name,
const struct keyvalwhere *mapping, int nvals,
Conf *conf, int primary)
{
const struct keyvalwhere *mapping, int nvals,
Conf *conf, int primary)
{
-char *save_settings(char *section, Conf *conf)
+char *save_settings(const char *section, Conf *conf)
{
void *sesskey;
char *errmsg;
{
void *sesskey;
char *errmsg;
void save_open_settings(void *sesskey, Conf *conf)
{
int i;
void save_open_settings(void *sesskey, Conf *conf)
{
int i;
write_setting_i(sesskey, "Present", 1);
write_setting_s(sesskey, "HostName", conf_get_str(conf, CONF_host));
write_setting_i(sesskey, "Present", 1);
write_setting_s(sesskey, "HostName", conf_get_str(conf, CONF_host));
wmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys, FALSE);
}
wmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys, FALSE);
}
-void load_settings(char *section, Conf *conf)
+void load_settings(const char *section, Conf *conf)
* disable gex under the "bugs" panel after one report of
* a server which offered it then choked, but we never got
* a server version string or any other reports. */
* disable gex under the "bugs" panel after one report of
* a server which offered it then choked, but we never got
* a server version string or any other reports. */
+ const char *default_kexes;
i = 2 - gppi_raw(sesskey, "BugDHGEx2", 0);
if (i == FORCE_ON)
default_kexes = "ecdh,dh-group14-sha1,dh-group1-sha1,rsa,"
i = 2 - gppi_raw(sesskey, "BugDHGEx2", 0);
if (i == FORCE_ON)
default_kexes = "ecdh,dh-group14-sha1,dh-group1-sha1,rsa,"
gppmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys);
}
gppmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys);
}
-void do_defaults(char *session, Conf *conf)
+void do_defaults(const char *session, Conf *conf)
{
load_settings(session, conf);
}
{
load_settings(session, conf);
}
- list->sessions = snewn(list->nsessions + 1, char *);
+ list->sessions = snewn(list->nsessions + 1, const char *);
list->sessions[0] = "Default Settings";
p = list->buffer;
i = 1;
list->sessions[0] = "Default Settings";
p = list->buffer;
i = 1;
- qsort(list->sessions, i, sizeof(char *), sessioncmp);
+ qsort(list->sessions, i, sizeof(const char *), sessioncmp);
} else {
sfree(list->buffer);
sfree(list->sessions);
} else {
sfree(list->buffer);
sfree(list->sessions);
static const char *fxp_error_message;
static int fxp_errtype;
static const char *fxp_error_message;
static int fxp_errtype;
-static void fxp_internal_error(char *msg);
+static void fxp_internal_error(const char *msg);
/* ----------------------------------------------------------------------
* SFTP packet construction functions.
/* ----------------------------------------------------------------------
* SFTP packet construction functions.
pkt->data = sresize(pkt->data, pkt->maxlen, char);
}
}
pkt->data = sresize(pkt->data, pkt->maxlen, char);
}
}
-static void sftp_pkt_adddata(struct sftp_packet *pkt, void *data, int len)
+static void sftp_pkt_adddata(struct sftp_packet *pkt,
+ const void *data, int len)
{
pkt->length += len;
sftp_pkt_ensure(pkt, pkt->length);
{
pkt->length += len;
sftp_pkt_ensure(pkt, pkt->length);
sftp_pkt_adduint32(pkt, 0);
pkt->savedpos = pkt->length;
}
sftp_pkt_adduint32(pkt, 0);
pkt->savedpos = pkt->length;
}
-static void sftp_pkt_addstring_str(struct sftp_packet *pkt, char *data)
+static void sftp_pkt_addstring_str(struct sftp_packet *pkt, const char *data)
{
sftp_pkt_adddata(pkt, data, strlen(data));
PUT_32BIT(pkt->data + pkt->savedpos - 4, pkt->length - pkt->savedpos);
}
static void sftp_pkt_addstring_data(struct sftp_packet *pkt,
{
sftp_pkt_adddata(pkt, data, strlen(data));
PUT_32BIT(pkt->data + pkt->savedpos - 4, pkt->length - pkt->savedpos);
}
static void sftp_pkt_addstring_data(struct sftp_packet *pkt,
+ const char *data, int len)
{
sftp_pkt_adddata(pkt, data, len);
PUT_32BIT(pkt->data + pkt->savedpos - 4, pkt->length - pkt->savedpos);
}
{
sftp_pkt_adddata(pkt, data, len);
PUT_32BIT(pkt->data + pkt->savedpos - 4, pkt->length - pkt->savedpos);
}
-static void sftp_pkt_addstring(struct sftp_packet *pkt, char *data)
+static void sftp_pkt_addstring(struct sftp_packet *pkt, const char *data)
{
sftp_pkt_addstring_start(pkt);
sftp_pkt_addstring_str(pkt, data);
{
sftp_pkt_addstring_start(pkt);
sftp_pkt_addstring_str(pkt, data);
-static void fxp_internal_error(char *msg)
+static void fxp_internal_error(const char *msg)
{
fxp_error_message = msg;
fxp_errtype = -1;
{
fxp_error_message = msg;
fxp_errtype = -1;
/*
* Canonify a pathname.
*/
/*
* Canonify a pathname.
*/
-struct sftp_request *fxp_realpath_send(char *path)
+struct sftp_request *fxp_realpath_send(const char *path)
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
-struct sftp_request *fxp_open_send(char *path, int type,
+struct sftp_request *fxp_open_send(const char *path, int type,
struct fxp_attrs *attrs)
{
struct sftp_request *req = sftp_alloc_request();
struct fxp_attrs *attrs)
{
struct sftp_request *req = sftp_alloc_request();
/*
* Open a directory.
*/
/*
* Open a directory.
*/
-struct sftp_request *fxp_opendir_send(char *path)
+struct sftp_request *fxp_opendir_send(const char *path)
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
-struct sftp_request *fxp_mkdir_send(char *path)
+struct sftp_request *fxp_mkdir_send(const char *path)
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
-struct sftp_request *fxp_rmdir_send(char *path)
+struct sftp_request *fxp_rmdir_send(const char *path)
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
-struct sftp_request *fxp_remove_send(char *fname)
+struct sftp_request *fxp_remove_send(const char *fname)
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
-struct sftp_request *fxp_rename_send(char *srcfname, char *dstfname)
+struct sftp_request *fxp_rename_send(const char *srcfname,
+ const char *dstfname)
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
* Retrieve the attributes of a file. We have fxp_stat which works
* on filenames, and fxp_fstat which works on open file handles.
*/
* Retrieve the attributes of a file. We have fxp_stat which works
* on filenames, and fxp_fstat which works on open file handles.
*/
-struct sftp_request *fxp_stat_send(char *fname)
+struct sftp_request *fxp_stat_send(const char *fname)
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
/*
* Set the attributes of a file.
*/
/*
* Set the attributes of a file.
*/
-struct sftp_request *fxp_setstat_send(char *fname, struct fxp_attrs attrs)
+struct sftp_request *fxp_setstat_send(const char *fname,
+ struct fxp_attrs attrs)
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
* Canonify a pathname. Concatenate the two given path elements
* with a separating slash, unless the second is NULL.
*/
* Canonify a pathname. Concatenate the two given path elements
* with a separating slash, unless the second is NULL.
*/
-struct sftp_request *fxp_realpath_send(char *path);
+struct sftp_request *fxp_realpath_send(const char *path);
char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Open a file. 'attrs' contains attributes to be applied to the file
* if it's being created.
*/
char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Open a file. 'attrs' contains attributes to be applied to the file
* if it's being created.
*/
-struct sftp_request *fxp_open_send(char *path, int type,
+struct sftp_request *fxp_open_send(const char *path, int type,
struct fxp_attrs *attrs);
struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin,
struct sftp_request *req);
struct fxp_attrs *attrs);
struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin,
struct sftp_request *req);
/*
* Open a directory.
*/
/*
* Open a directory.
*/
-struct sftp_request *fxp_opendir_send(char *path);
+struct sftp_request *fxp_opendir_send(const char *path);
struct fxp_handle *fxp_opendir_recv(struct sftp_packet *pktin,
struct sftp_request *req);
struct fxp_handle *fxp_opendir_recv(struct sftp_packet *pktin,
struct sftp_request *req);
/*
* Make a directory.
*/
/*
* Make a directory.
*/
-struct sftp_request *fxp_mkdir_send(char *path);
+struct sftp_request *fxp_mkdir_send(const char *path);
int fxp_mkdir_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Remove a directory.
*/
int fxp_mkdir_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Remove a directory.
*/
-struct sftp_request *fxp_rmdir_send(char *path);
+struct sftp_request *fxp_rmdir_send(const char *path);
int fxp_rmdir_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Remove a file.
*/
int fxp_rmdir_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Remove a file.
*/
-struct sftp_request *fxp_remove_send(char *fname);
+struct sftp_request *fxp_remove_send(const char *fname);
int fxp_remove_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Rename a file.
*/
int fxp_remove_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Rename a file.
*/
-struct sftp_request *fxp_rename_send(char *srcfname, char *dstfname);
+struct sftp_request *fxp_rename_send(const char *srcfname,
+ const char *dstfname);
int fxp_rename_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Return file attributes.
*/
int fxp_rename_recv(struct sftp_packet *pktin, struct sftp_request *req);
/*
* Return file attributes.
*/
-struct sftp_request *fxp_stat_send(char *fname);
+struct sftp_request *fxp_stat_send(const char *fname);
int fxp_stat_recv(struct sftp_packet *pktin, struct sftp_request *req,
struct fxp_attrs *attrs);
struct sftp_request *fxp_fstat_send(struct fxp_handle *handle);
int fxp_stat_recv(struct sftp_packet *pktin, struct sftp_request *req,
struct fxp_attrs *attrs);
struct sftp_request *fxp_fstat_send(struct fxp_handle *handle);
/*
* Set file attributes.
*/
/*
* Set file attributes.
*/
-struct sftp_request *fxp_setstat_send(char *fname, struct fxp_attrs attrs);
+struct sftp_request *fxp_setstat_send(const char *fname,
+ struct fxp_attrs attrs);
int fxp_setstat_recv(struct sftp_packet *pktin, struct sftp_request *req);
struct sftp_request *fxp_fsetstat_send(struct fxp_handle *handle,
struct fxp_attrs attrs);
int fxp_setstat_recv(struct sftp_packet *pktin, struct sftp_request *req);
struct sftp_request *fxp_fsetstat_send(struct fxp_handle *handle,
struct fxp_attrs attrs);
#define translate(x) if (type == x) return #x
#define translatek(x,ctx) if (type == x && (pkt_kctx == ctx)) return #x
#define translatea(x,ctx) if (type == x && (pkt_actx == ctx)) return #x
#define translate(x) if (type == x) return #x
#define translatek(x,ctx) if (type == x && (pkt_kctx == ctx)) return #x
#define translatea(x,ctx) if (type == x && (pkt_actx == ctx)) return #x
-static char *ssh1_pkt_type(int type)
+static const char *ssh1_pkt_type(int type)
{
translate(SSH1_MSG_DISCONNECT);
translate(SSH1_SMSG_PUBLIC_KEY);
{
translate(SSH1_MSG_DISCONNECT);
translate(SSH1_SMSG_PUBLIC_KEY);
translate(SSH1_CMSG_AUTH_CCARD_RESPONSE);
return "unknown";
}
translate(SSH1_CMSG_AUTH_CCARD_RESPONSE);
return "unknown";
}
-static char *ssh2_pkt_type(Pkt_KCtx pkt_kctx, Pkt_ACtx pkt_actx, int type)
+static const char *ssh2_pkt_type(Pkt_KCtx pkt_kctx, Pkt_ACtx pkt_actx,
+ int type)
{
translatea(SSH2_MSG_USERAUTH_GSSAPI_RESPONSE,SSH2_PKTCTX_GSSAPI);
translatea(SSH2_MSG_USERAUTH_GSSAPI_TOKEN,SSH2_PKTCTX_GSSAPI);
{
translatea(SSH2_MSG_USERAUTH_GSSAPI_RESPONSE,SSH2_PKTCTX_GSSAPI);
translatea(SSH2_MSG_USERAUTH_GSSAPI_TOKEN,SSH2_PKTCTX_GSSAPI);
static int ssh2_pkt_construct(Ssh, struct Packet *);
static void ssh2_pkt_send(Ssh, struct Packet *);
static void ssh2_pkt_send_noqueue(Ssh, struct Packet *);
static int ssh2_pkt_construct(Ssh, struct Packet *);
static void ssh2_pkt_send(Ssh, struct Packet *);
static void ssh2_pkt_send_noqueue(Ssh, struct Packet *);
-static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
+static int do_ssh1_login(Ssh ssh, const unsigned char *in, int inlen,
-static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
+static void do_ssh2_authconn(Ssh ssh, const unsigned char *in, int inlen,
struct Packet *pktin);
static void ssh2_channel_check_close(struct ssh_channel *c);
static void ssh_channel_destroy(struct ssh_channel *c);
struct Packet *pktin);
static void ssh2_channel_check_close(struct ssh_channel *c);
static void ssh_channel_destroy(struct ssh_channel *c);
const char *additional_log_text;
};
const char *additional_log_text;
};
-static void ssh1_protocol(Ssh ssh, void *vin, int inlen,
+static void ssh1_protocol(Ssh ssh, const void *vin, int inlen,
-static void ssh2_protocol(Ssh ssh, void *vin, int inlen,
+static void ssh2_protocol(Ssh ssh, const void *vin, int inlen,
-static void ssh2_bare_connection_protocol(Ssh ssh, void *vin, int inlen,
+static void ssh2_bare_connection_protocol(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin);
static void ssh1_protocol_setup(Ssh ssh);
static void ssh2_protocol_setup(Ssh ssh);
struct Packet *pktin);
static void ssh1_protocol_setup(Ssh ssh);
static void ssh2_protocol_setup(Ssh ssh);
static void ssh_size(void *handle, int width, int height);
static void ssh_special(void *handle, Telnet_Special);
static int ssh2_try_send(struct ssh_channel *c);
static void ssh_size(void *handle, int width, int height);
static void ssh_special(void *handle, Telnet_Special);
static int ssh2_try_send(struct ssh_channel *c);
-static void ssh2_add_channel_data(struct ssh_channel *c, char *buf, int len);
+static void ssh2_add_channel_data(struct ssh_channel *c,
+ const char *buf, int len);
static void ssh_throttle_all(Ssh ssh, int enable, int bufsize);
static void ssh2_set_window(struct ssh_channel *c, int newwin);
static int ssh_sendbuffer(void *handle);
static void ssh_throttle_all(Ssh ssh, int enable, int bufsize);
static void ssh2_set_window(struct ssh_channel *c, int newwin);
static int ssh_sendbuffer(void *handle);
static int ssh2_pkt_getbool(struct Packet *pkt);
static void ssh_pkt_getstring(struct Packet *pkt, char **p, int *length);
static void ssh2_timer(void *ctx, unsigned long now);
static int ssh2_pkt_getbool(struct Packet *pkt);
static void ssh_pkt_getstring(struct Packet *pkt, char **p, int *length);
static void ssh2_timer(void *ctx, unsigned long now);
-static void do_ssh2_transport(Ssh ssh, void *vin, int inlen,
+static void do_ssh2_transport(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin);
static void ssh2_msg_unexpected(Ssh ssh, struct Packet *pktin);
struct Packet *pktin);
static void ssh2_msg_unexpected(Ssh ssh, struct Packet *pktin);
/* SSH-1 and SSH-2 use this for different things, but both use it */
int protocol_initial_phase_done;
/* SSH-1 and SSH-2 use this for different things, but both use it */
int protocol_initial_phase_done;
- void (*protocol) (Ssh ssh, void *vin, int inlen,
+ void (*protocol) (Ssh ssh, const void *vin, int inlen,
- struct Packet *(*s_rdpkt) (Ssh ssh, unsigned char **data, int *datalen);
+ struct Packet *(*s_rdpkt) (Ssh ssh, const unsigned char **data,
+ int *datalen);
int (*do_ssh_init)(Ssh ssh, unsigned char c);
/*
int (*do_ssh_init)(Ssh ssh, unsigned char c);
/*
unsigned long max_data_size;
int kex_in_progress;
unsigned long next_rekey, last_rekey;
unsigned long max_data_size;
int kex_in_progress;
unsigned long next_rekey, last_rekey;
- char *deferred_rekey_reason; /* points to STATIC string; don't free */
+ const char *deferred_rekey_reason;
/*
* Fully qualified host name, which we need if doing GSSAPI.
/*
* Fully qualified host name, which we need if doing GSSAPI.
* Update the *data and *datalen variables.
* Return a Packet structure when a packet is completed.
*/
* Update the *data and *datalen variables.
* Return a Packet structure when a packet is completed.
*/
-static struct Packet *ssh1_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
+static struct Packet *ssh1_rdpkt(Ssh ssh, const unsigned char **data,
+ int *datalen)
{
struct rdpkt1_state_tag *st = &ssh->rdpkt1_state;
{
struct rdpkt1_state_tag *st = &ssh->rdpkt1_state;
pkt->length += (pkt->body - pkt->data);
}
pkt->length += (pkt->body - pkt->data);
}
-static struct Packet *ssh2_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
+static struct Packet *ssh2_rdpkt(Ssh ssh, const unsigned char **data,
+ int *datalen)
{
struct rdpkt2_state_tag *st = &ssh->rdpkt2_state;
{
struct rdpkt2_state_tag *st = &ssh->rdpkt2_state;
-static struct Packet *ssh2_bare_connection_rdpkt(Ssh ssh, unsigned char **data,
+static struct Packet *ssh2_bare_connection_rdpkt(Ssh ssh,
+ const unsigned char **data,
int *datalen)
{
struct rdpkt2_bare_state_tag *st = &ssh->rdpkt2_bare_state;
int *datalen)
{
struct rdpkt2_bare_state_tag *st = &ssh->rdpkt2_bare_state;
s_wrpkt_defer(ssh, pkt);
}
s_wrpkt_defer(ssh, pkt);
}
-static int ssh_versioncmp(char *a, char *b)
+static int ssh_versioncmp(const char *a, const char *b)
{
char *ae, *be;
unsigned long av, bv;
{
char *ae, *be;
unsigned long av, bv;
}
static void ssh_process_incoming_data(Ssh ssh,
}
static void ssh_process_incoming_data(Ssh ssh,
- unsigned char **data, int *datalen)
+ const unsigned char **data, int *datalen)
}
static void ssh_queue_incoming_data(Ssh ssh,
}
static void ssh_queue_incoming_data(Ssh ssh,
- unsigned char **data, int *datalen)
+ const unsigned char **data, int *datalen)
{
bufchain_add(&ssh->queued_incoming_data, *data, *datalen);
*data += *datalen;
{
bufchain_add(&ssh->queued_incoming_data, *data, *datalen);
*data += *datalen;
static void ssh_process_queued_incoming_data(Ssh ssh)
{
void *vdata;
static void ssh_process_queued_incoming_data(Ssh ssh)
{
void *vdata;
+ const unsigned char *data;
int len, origlen;
while (!ssh->frozen && bufchain_size(&ssh->queued_incoming_data)) {
int len, origlen;
while (!ssh->frozen && bufchain_size(&ssh->queued_incoming_data)) {
-static void ssh_gotdata(Ssh ssh, unsigned char *data, int datalen)
+static void ssh_gotdata(Ssh ssh, const unsigned char *data, int datalen)
{
/* Log raw data, if we're in that mode. */
if (ssh->logctx)
{
/* Log raw data, if we're in that mode. */
if (ssh->logctx)
* Also places the canonical host name into `realhost'. It must be
* freed by the caller.
*/
* Also places the canonical host name into `realhost'. It must be
* freed by the caller.
*/
-static const char *connect_to_host(Ssh ssh, char *host, int port,
+static const char *connect_to_host(Ssh ssh, const char *host, int port,
char **realhost, int nodelay, int keepalive)
{
static const struct plug_function_table fn_table = {
char **realhost, int nodelay, int keepalive)
{
static const struct plug_function_table fn_table = {
{
struct ssh_channel *c = (struct ssh_channel *)cv;
Ssh ssh = c->ssh;
{
struct ssh_channel *c = (struct ssh_channel *)cv;
Ssh ssh = c->ssh;
- void *sentreply = reply;
+ const void *sentreply = reply;
c->u.a.outstanding_requests--;
if (!sentreply) {
c->u.a.outstanding_requests--;
if (!sentreply) {
* non-NULL, otherwise just close the connection. `client_reason' == NULL
* => log `wire_reason'.
*/
* non-NULL, otherwise just close the connection. `client_reason' == NULL
* => log `wire_reason'.
*/
-static void ssh_disconnect(Ssh ssh, char *client_reason, char *wire_reason,
+static void ssh_disconnect(Ssh ssh, const char *client_reason,
+ const char *wire_reason,
int code, int clean_exit)
{
char *error;
int code, int clean_exit)
{
char *error;
/*
* Handle the key exchange and user authentication phases.
*/
/*
* Handle the key exchange and user authentication phases.
*/
-static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
+static int do_ssh1_login(Ssh ssh, const unsigned char *in, int inlen,
struct Packet *pktin)
{
int i, j, ret;
struct Packet *pktin)
{
int i, j, ret;
{
int cipher_chosen = 0, warn = 0;
{
int cipher_chosen = 0, warn = 0;
- char *cipher_string = NULL;
+ const char *cipher_string = NULL;
int i;
for (i = 0; !cipher_chosen && i < CIPHER_MAX; i++) {
int next_cipher = conf_get_int_int(ssh->conf,
int i;
for (i = 0; !cipher_chosen && i < CIPHER_MAX; i++) {
int next_cipher = conf_get_int_int(ssh->conf,
return conf_get_int(ssh->conf, CONF_agentfwd) && agent_exists();
}
return conf_get_int(ssh->conf, CONF_agentfwd) && agent_exists();
}
-static void do_ssh1_connection(Ssh ssh, unsigned char *in, int inlen,
+static void do_ssh1_connection(Ssh ssh, const unsigned char *in, int inlen,
struct Packet *pktin)
{
crBegin(ssh->do_ssh1_connection_crstate);
struct Packet *pktin)
{
crBegin(ssh->do_ssh1_connection_crstate);
ssh->packet_dispatch[SSH1_MSG_DEBUG] = ssh1_msg_debug;
}
ssh->packet_dispatch[SSH1_MSG_DEBUG] = ssh1_msg_debug;
}
-static void ssh1_protocol(Ssh ssh, void *vin, int inlen,
+static void ssh1_protocol(Ssh ssh, const void *vin, int inlen,
- unsigned char *in=(unsigned char*)vin;
+ const unsigned char *in = (const unsigned char *)vin;
if (ssh->state == SSH_STATE_CLOSED)
return;
if (ssh->state == SSH_STATE_CLOSED)
return;
/*
* Handle the SSH-2 transport layer.
*/
/*
* Handle the SSH-2 transport layer.
*/
-static void do_ssh2_transport(Ssh ssh, void *vin, int inlen,
+static void do_ssh2_transport(Ssh ssh, const void *vin, int inlen,
- unsigned char *in = (unsigned char *)vin;
+ const unsigned char *in = (const unsigned char *)vin;
struct do_ssh2_transport_state {
int crLine;
int nbits, pbits, warn_kex, warn_cscipher, warn_sccipher;
struct do_ssh2_transport_state {
int crLine;
int nbits, pbits, warn_kex, warn_cscipher, warn_sccipher;
+ char *str;
+ const char *preferred;
int i, j, len;
if (pktin->type != SSH2_MSG_KEXINIT) {
int i, j, len;
if (pktin->type != SSH2_MSG_KEXINIT) {
/*
* Add data to an SSH-2 channel output buffer.
*/
/*
* Add data to an SSH-2 channel output buffer.
*/
-static void ssh2_add_channel_data(struct ssh_channel *c, char *buf,
+static void ssh2_add_channel_data(struct ssh_channel *c, const char *buf,
int len)
{
bufchain_add(&c->v.v2.outbuffer, buf, len);
int len)
{
bufchain_add(&c->v.v2.outbuffer, buf, len);
/*
* Construct the common parts of a CHANNEL_OPEN.
*/
/*
* Construct the common parts of a CHANNEL_OPEN.
*/
-static struct Packet *ssh2_chanopen_init(struct ssh_channel *c, char *type)
+static struct Packet *ssh2_chanopen_init(struct ssh_channel *c,
+ const char *type)
* the server initiated channel closure before we saw the response)
* and the handler should free any storage it's holding.
*/
* the server initiated channel closure before we saw the response)
* and the handler should free any storage it's holding.
*/
-static struct Packet *ssh2_chanreq_init(struct ssh_channel *c, char *type,
+static struct Packet *ssh2_chanreq_init(struct ssh_channel *c,
+ const char *type,
cchandler_fn_t handler, void *ctx)
{
struct Packet *pktout;
cchandler_fn_t handler, void *ctx)
{
struct Packet *pktout;
!memcmp(type, "exit-signal", 11)) {
int is_plausible = TRUE, is_int = FALSE;
!memcmp(type, "exit-signal", 11)) {
int is_plausible = TRUE, is_int = FALSE;
- char *fmt_sig = "", *fmt_msg = "";
+ char *fmt_sig = NULL, *fmt_msg = NULL;
char *msg;
int msglen = 0, core = FALSE;
/* ICK: older versions of OpenSSH (e.g. 3.4p1)
char *msg;
int msglen = 0, core = FALSE;
/* ICK: older versions of OpenSSH (e.g. 3.4p1)
/* ignore lang tag */
} /* else don't attempt to parse */
logeventf(ssh, "Server exited on signal%s%s%s",
/* ignore lang tag */
} /* else don't attempt to parse */
logeventf(ssh, "Server exited on signal%s%s%s",
- fmt_sig, core ? " (core dumped)" : "",
- fmt_msg);
- if (*fmt_sig) sfree(fmt_sig);
- if (*fmt_msg) sfree(fmt_msg);
+ fmt_sig ? fmt_sig : "",
+ core ? " (core dumped)" : "",
+ fmt_msg ? fmt_msg : "");
+ sfree(fmt_sig);
+ sfree(fmt_msg);
reply = SSH2_MSG_CHANNEL_SUCCESS;
}
reply = SSH2_MSG_CHANNEL_SUCCESS;
}
char *peeraddr;
int peeraddrlen;
int peerport;
char *peeraddr;
int peeraddrlen;
int peerport;
+ const char *error = NULL;
struct ssh_channel *c;
unsigned remid, winsize, pktsize;
unsigned our_winsize_override = 0;
struct ssh_channel *c;
unsigned remid, winsize, pktsize;
unsigned our_winsize_override = 0;
do_ssh2_authconn(c->ssh, NULL, 0, pktin);
}
do_ssh2_authconn(c->ssh, NULL, 0, pktin);
}
-static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
+static void do_ssh2_authconn(Ssh ssh, const unsigned char *in, int inlen,
struct Packet *pktin)
{
struct do_ssh2_authconn_state {
struct Packet *pktin)
{
struct do_ssh2_authconn_state {
int prompt_len; /* not live over crReturn */
{
int prompt_len; /* not live over crReturn */
{
if (changereq_first_time)
msg = "Server requested password change";
else
if (changereq_first_time)
msg = "Server requested password change";
else
-static void ssh2_protocol(Ssh ssh, void *vin, int inlen,
+static void ssh2_protocol(Ssh ssh, const void *vin, int inlen,
- unsigned char *in = (unsigned char *)vin;
+ const unsigned char *in = (const unsigned char *)vin;
if (ssh->state == SSH_STATE_CLOSED)
return;
if (ssh->state == SSH_STATE_CLOSED)
return;
do_ssh2_authconn(ssh, in, inlen, pktin);
}
do_ssh2_authconn(ssh, in, inlen, pktin);
}
-static void ssh2_bare_connection_protocol(Ssh ssh, void *vin, int inlen,
+static void ssh2_bare_connection_protocol(Ssh ssh, const void *vin, int inlen,
- unsigned char *in = (unsigned char *)vin;
+ const unsigned char *in = (const unsigned char *)vin;
if (ssh->state == SSH_STATE_CLOSED)
return;
if (ssh->state == SSH_STATE_CLOSED)
return;
* Returns an error message, or NULL on success.
*/
static const char *ssh_init(void *frontend_handle, void **backend_handle,
* Returns an error message, or NULL on success.
*/
static const char *ssh_init(void *frontend_handle, void **backend_handle,
- Conf *conf, char *host, int port, char **realhost,
+ Conf *conf,
+ const char *host, int port, char **realhost,
int nodelay, int keepalive)
{
const char *p;
int nodelay, int keepalive)
{
const char *p;
static void ssh_reconfig(void *handle, Conf *conf)
{
Ssh ssh = (Ssh) handle;
static void ssh_reconfig(void *handle, Conf *conf)
{
Ssh ssh = (Ssh) handle;
- char *rekeying = NULL, rekey_mandatory = FALSE;
+ const char *rekeying = NULL;
+ int rekey_mandatory = FALSE;
unsigned long old_max_data_size;
int i, rekey_time;
unsigned long old_max_data_size;
int i, rekey_time;
/*
* Called to send data down the SSH connection.
*/
/*
* Called to send data down the SSH connection.
*/
-static int ssh_send(void *handle, char *buf, int len)
+static int ssh_send(void *handle, const char *buf, int len)
{
Ssh ssh = (Ssh) handle;
if (ssh == NULL || ssh->s == NULL || ssh->protocol == NULL)
return 0;
{
Ssh ssh = (Ssh) handle;
if (ssh == NULL || ssh->s == NULL || ssh->protocol == NULL)
return 0;
- ssh->protocol(ssh, (unsigned char *)buf, len, 0);
+ ssh->protocol(ssh, (const unsigned char *)buf, len, 0);
return ssh_sendbuffer(ssh);
}
return ssh_sendbuffer(ssh);
}
}
} else {
/* Is is a POSIX signal? */
}
} else {
/* Is is a POSIX signal? */
+ const char *signame = NULL;
if (code == TS_SIGABRT) signame = "ABRT";
if (code == TS_SIGALRM) signame = "ALRM";
if (code == TS_SIGFPE) signame = "FPE";
if (code == TS_SIGABRT) signame = "ABRT";
if (code == TS_SIGALRM) signame = "ALRM";
if (code == TS_SIGFPE) signame = "FPE";
ssh_process_queued_incoming_data(ssh);
}
ssh_process_queued_incoming_data(ssh);
}
-void ssh_send_port_open(void *channel, char *hostname, int port, char *org)
+void ssh_send_port_open(void *channel, const char *hostname, int port,
+ const char *org)
{
struct ssh_channel *c = (struct ssh_channel *)channel;
Ssh ssh = c->ssh;
{
struct ssh_channel *c = (struct ssh_channel *)channel;
Ssh ssh = c->ssh;
void (*setkey) (void *, unsigned char *key);/* for SSH-2 */
void (*encrypt) (void *, unsigned char *blk, int len);
void (*decrypt) (void *, unsigned char *blk, int len);
void (*setkey) (void *, unsigned char *key);/* for SSH-2 */
void (*encrypt) (void *, unsigned char *blk, int len);
void (*decrypt) (void *, unsigned char *blk, int len);
int blksize;
int keylen;
unsigned int flags;
int blksize;
int keylen;
unsigned int flags;
- char *name, *groupname;
+ const char *name, *groupname;
enum { KEXTYPE_DH, KEXTYPE_RSA, KEXTYPE_ECDH } main_type;
const struct ssh_hash *hash;
const void *extra; /* private to the kex methods */
enum { KEXTYPE_DH, KEXTYPE_RSA, KEXTYPE_ECDH } main_type;
const struct ssh_hash *hash;
const void *extra; /* private to the kex methods */
/* For zlib@openssh.com: if non-NULL, this name will be considered once
* userauth has completed successfully. */
/* For zlib@openssh.com: if non-NULL, this name will be considered once
* userauth has completed successfully. */
+ const char *delayed_name;
void *(*compress_init) (void);
void (*compress_cleanup) (void *);
int (*compress) (void *, unsigned char *block, int len,
void *(*compress_init) (void);
void (*compress_cleanup) (void *);
int (*compress) (void *, unsigned char *block, int len,
/* Allocate and register a new channel for port forwarding */
void *new_sock_channel(void *handle, struct PortForwarding *pf);
/* Allocate and register a new channel for port forwarding */
void *new_sock_channel(void *handle, struct PortForwarding *pf);
-void ssh_send_port_open(void *channel, char *hostname, int port, char *org);
+void ssh_send_port_open(void *channel, const char *hostname, int port,
+ const char *org);
/* Exports from portfwd.c */
extern char *pfd_connect(struct PortForwarding **pf, char *hostname, int port,
/* Exports from portfwd.c */
extern char *pfd_connect(struct PortForwarding **pf, char *hostname, int port,
char *ssh2_fingerprint_blob(const void *blob, int bloblen);
char *ssh2_fingerprint(const struct ssh_signkey *alg, void *data);
int key_type(const Filename *filename);
char *ssh2_fingerprint_blob(const void *blob, int bloblen);
char *ssh2_fingerprint(const struct ssh_signkey *alg, void *data);
int key_type(const Filename *filename);
-char *key_type_to_str(int type);
+const char *key_type_to_str(int type);
int import_possible(int type);
int import_target_type(int type);
int import_possible(int type);
int import_target_type(int type);
* testdata/bignum.py .
*/
* testdata/bignum.py .
*/
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
int passlen;
int cipherblk;
int i;
int passlen;
int cipherblk;
int i;
unsigned char priv_mac[20];
/*
unsigned char priv_mac[20];
/*
* Convert the type word to a string, for `wrong type' error
* messages.
*/
* Convert the type word to a string, for `wrong type' error
* messages.
*/
-char *key_type_to_str(int type)
+const char *key_type_to_str(int type)
{
switch (type) {
case SSH_KEYTYPE_UNOPENABLE: return "unable to open file"; break;
{
switch (type) {
case SSH_KEYTYPE_UNOPENABLE: return "unable to open file"; break;
( (x) != IAC && \
(telnet->opt_states[o_we_bin.index] == ACTIVE || (x) != CR))
( (x) != IAC && \
(telnet->opt_states[o_we_bin.index] == ACTIVE || (x) != CR))
-static char *telopt(int opt)
+static const char *telopt(int opt)
{
#define telnet_str(x,y) case TELOPT_##x: return #x;
switch (opt) {
{
#define telnet_str(x,y) case TELOPT_##x: return #x;
switch (opt) {
-static void c_write(Telnet telnet, char *buf, int len)
+static void c_write(Telnet telnet, const char *buf, int len)
{
int backlog;
backlog = from_backend(telnet->frontend, 0, buf, len);
sk_set_frozen(telnet->s, backlog > TELNET_MAX_BACKLOG);
}
{
int backlog;
backlog = from_backend(telnet->frontend, 0, buf, len);
sk_set_frozen(telnet->s, backlog > TELNET_MAX_BACKLOG);
}
-static void log_option(Telnet telnet, char *sender, int cmd, int option)
+static void log_option(Telnet telnet, const char *sender, int cmd, int option)
* freed by the caller.
*/
static const char *telnet_init(void *frontend_handle, void **backend_handle,
* freed by the caller.
*/
static const char *telnet_init(void *frontend_handle, void **backend_handle,
- Conf *conf, char *host, int port,
+ Conf *conf, const char *host, int port,
char **realhost, int nodelay, int keepalive)
{
static const struct plug_function_table fn_table = {
char **realhost, int nodelay, int keepalive)
{
static const struct plug_function_table fn_table = {
/*
* Called to send data down the Telnet connection.
*/
/*
* Called to send data down the Telnet connection.
*/
-static int telnet_send(void *handle, char *buf, int len)
+static int telnet_send(void *handle, const char *buf, int len)
{
Telnet telnet = (Telnet) handle;
unsigned char *p, *end;
{
Telnet telnet = (Telnet) handle;
unsigned char *p, *end;
#define has_compat(x) ( ((CL_##x)&term->compatibility_level) != 0 )
#define has_compat(x) ( ((CL_##x)&term->compatibility_level) != 0 )
-char *EMPTY_WINDOW_TITLE = "";
+const char *EMPTY_WINDOW_TITLE = "";
const char sco2ansicolour[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
const char sco2ansicolour[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
switch (term->esc_args[0]) {
int x, y, len;
switch (term->esc_args[0]) {
int x, y, len;
+ char buf[80];
+ const char *p;
case 1:
set_iconic(term->frontend, FALSE);
break;
case 1:
set_iconic(term->frontend, FALSE);
break;
*/
char *term_get_ttymode(Terminal *term, const char *mode)
{
*/
char *term_get_ttymode(Terminal *term, const char *mode)
{
+ const char *val = NULL;
if (strcmp(mode, "ERASE") == 0) {
val = term->bksp_is_delete ? "^?" : "^H";
}
if (strcmp(mode, "ERASE") == 0) {
val = term->bksp_is_delete ? "^?" : "^H";
}
* input.
*/
int term_get_userpass_input(Terminal *term, prompts_t *p,
* input.
*/
int term_get_userpass_input(Terminal *term, prompts_t *p,
- unsigned char *in, int inlen)
+ const unsigned char *in, int inlen)
{
struct term_userpass_state *s = (struct term_userpass_state *)p->data;
if (!s) {
{
struct term_userpass_state *s = (struct term_userpass_state *)p->data;
if (!s) {
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
gtk_widget_set_uposition(GTK_WIDGET(child), dx, dy);
}
gtk_widget_set_uposition(GTK_WIDGET(child), dx, dy);
}
-void dlg_error_msg(void *dlg, char *msg)
+void dlg_error_msg(void *dlg, const char *msg)
{
struct dlgparam *dp = (struct dlgparam *)dlg;
GtkWidget *window, *hbox, *text, *ok;
{
struct dlgparam *dp = (struct dlgparam *)dlg;
GtkWidget *window, *hbox, *text, *ok;
{
GtkWidget *ww;
GtkRequisition req;
{
GtkWidget *ww;
GtkRequisition req;
+ const char *browsebtn =
(ctrl->generic.type == CTRL_FILESELECT ?
"Browse..." : "Change...");
(ctrl->generic.type == CTRL_FILESELECT ?
"Browse..." : "Change...");
if (event == EVENT_ACTION)
dlg_end(dlg, ctrl->generic.context.i);
}
if (event == EVENT_ACTION)
dlg_end(dlg, ctrl->generic.context.i);
}
-int messagebox(GtkWidget *parentwin, char *title, char *msg, int minwid, ...)
+int messagebox(GtkWidget *parentwin, const char *title, const char *msg,
+ int minwid, ...)
{
GtkWidget *window, *w0, *w1;
struct controlbox *ctrlbox;
{
GtkWidget *window, *w0, *w1;
struct controlbox *ctrlbox;
-int string_width(char *text)
+int string_width(const char *text)
{
GtkWidget *label = gtk_label_new(text);
GtkRequisition req;
{
GtkWidget *label = gtk_label_new(text);
GtkRequisition req;
-void fatal_message_box(void *window, char *msg)
+void fatal_message_box(void *window, const char *msg)
{
messagebox(window, "PuTTY Fatal Error", msg,
string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"),
"OK", 'o', 1, 1, NULL);
}
{
messagebox(window, "PuTTY Fatal Error", msg,
string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"),
"OK", 'o', 1, 1, NULL);
}
-void nonfatal_message_box(void *window, char *msg)
+void nonfatal_message_box(void *window, const char *msg)
{
messagebox(window, "PuTTY Error", msg,
string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"),
"OK", 'o', 1, 1, NULL);
}
{
messagebox(window, "PuTTY Error", msg,
string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"),
"OK", 'o', 1, 1, NULL);
}
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
"Copyright 1997-2015 Simon Tatham.\n\n"
"Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
"Copyright 1997-2015 Simon Tatham.\n\n"
"Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
if (XGetFontProperty(xfs, fontprop, &ret)) {
char *name = XGetAtomName(disp, (Atom)ret);
if (name && name[0] == '-') {
if (XGetFontProperty(xfs, fontprop, &ret)) {
char *name = XGetAtomName(disp, (Atom)ret);
if (name && name[0] == '-') {
+ const char *strings[13];
char *dupname, *extrafree = NULL, *ret;
char *p, *q;
int nstr;
char *dupname, *extrafree = NULL, *ret;
char *p, *q;
int nstr;
static int send_raw_mouse;
static int send_raw_mouse;
-static char *app_name = "pterm";
+static const char *app_name = "pterm";
static void start_backend(struct gui_data *inst);
static void exit_callback(void *vinst);
static void start_backend(struct gui_data *inst);
static void exit_callback(void *vinst);
return XGetDefault(GDK_DISPLAY(), app_name, key);
}
return XGetDefault(GDK_DISPLAY(), app_name, key);
}
-void connection_fatal(void *frontend, char *p, ...)
+void connection_fatal(void *frontend, const char *p, ...)
{
struct gui_data *inst = (struct gui_data *)frontend;
{
struct gui_data *inst = (struct gui_data *)frontend;
return TRUE; /* do respond to incoming EOF with outgoing */
}
return TRUE; /* do respond to incoming EOF with outgoing */
}
-int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{
struct gui_data *inst = (struct gui_data *)p->frontend;
int ret;
{
struct gui_data *inst = (struct gui_data *)p->frontend;
int ret;
* NetHack keypad mode.
*/
if (nethack_mode) {
* NetHack keypad mode.
*/
if (nethack_mode) {
+ const char *keys = NULL;
switch (event->keyval) {
case GDK_KP_1: case GDK_KP_End: keys = "bB\002"; break;
case GDK_KP_2: case GDK_KP_Down: keys = "jJ\012"; break;
switch (event->keyval) {
case GDK_KP_1: case GDK_KP_End: keys = "bB\002"; break;
case GDK_KP_2: case GDK_KP_Down: keys = "jJ\012"; break;
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
{
va_list ap;
fprintf(stderr, "%s: ", appname);
{
va_list ap;
fprintf(stderr, "%s: ", appname);
#define SECOND_PASS_ONLY { if (!do_everything) continue; }
while (--argc > 0) {
#define SECOND_PASS_ONLY { if (!do_everything) continue; }
while (--argc > 0) {
+ const char *p = *++argv;
/* Things pterm.c needs from gtkdlg.c */
int do_config_box(const char *title, Conf *conf,
int midsession, int protcfginfo);
/* Things pterm.c needs from gtkdlg.c */
int do_config_box(const char *title, Conf *conf,
int midsession, int protcfginfo);
-void fatal_message_box(void *window, char *msg);
-void nonfatal_message_box(void *window, char *msg);
+void fatal_message_box(void *window, const char *msg);
+void nonfatal_message_box(void *window, const char *msg);
void about_box(void *window);
void *eventlogstuff_new(void);
void showeventlog(void *estuff, void *parentwin);
void logevent_dlg(void *estuff, const char *string);
int reallyclose(void *frontend);
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
void about_box(void *window);
void *eventlogstuff_new(void);
void showeventlog(void *estuff, void *parentwin);
void logevent_dlg(void *estuff, const char *string);
int reallyclose(void *frontend);
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
-int messagebox(GtkWidget *parentwin, char *title, char *msg, int minwid, ...);
-int string_width(char *text);
+int messagebox(GtkWidget *parentwin, const char *title,
+ const char *msg, int minwid, ...);
+int string_width(const char *text);
#endif
/* Things pterm.c needs from {ptermm,uxputty}.c */
char *make_default_wintitle(char *hostname);
#endif
/* Things pterm.c needs from {ptermm,uxputty}.c */
char *make_default_wintitle(char *hostname);
-int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch);
+int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch);
/* pterm.c needs this special function in xkeysym.c */
int keysym_to_unicode(int keysym);
/* pterm.c needs this special function in xkeysym.c */
int keysym_to_unicode(int keysym);
-int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+int console_get_userpass_input(prompts_t *p, const unsigned char *in,
+ int inlen)
{
size_t curr_prompt;
FILE *outfp = NULL;
{
size_t curr_prompt;
FILE *outfp = NULL;
#ifdef DEBUG
static FILE *debug_fp = NULL;
#ifdef DEBUG
static FILE *debug_fp = NULL;
+void dputs(const char *buf)
{
if (!debug_fp) {
debug_fp = fopen("debug.log", "w");
{
if (!debug_fp) {
debug_fp = fopen("debug.log", "w");
-Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, int orig_address_family)
+Socket sk_newlistener(const char *srcaddr, int port, Plug plug,
+ int local_host_only, int orig_address_family)
SockAddr unix_sock_addr(const char *path);
Socket new_unix_listener(SockAddr listenaddr, Plug plug);
SockAddr unix_sock_addr(const char *path);
Socket new_unix_listener(SockAddr listenaddr, Plug plug);
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
fputc('\n', stderr);
exit(1);
}
fputc('\n', stderr);
exit(1);
}
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
fputc('\n', stderr);
exit(1);
}
fputc('\n', stderr);
exit(1);
}
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
{
va_list ap;
fprintf(stderr, "ERROR: ");
{
va_list ap;
fprintf(stderr, "ERROR: ");
va_end(ap);
fputc('\n', stderr);
}
va_end(ap);
fputc('\n', stderr);
}
-void connection_fatal(void *frontend, char *p, ...)
+void connection_fatal(void *frontend, const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
fputc('\n', stderr);
exit(1);
}
fputc('\n', stderr);
exit(1);
}
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
{
va_list ap;
fprintf(stderr, "pageant: ");
{
va_list ap;
fprintf(stderr, "pageant: ");
static struct termios orig_termios;
static struct termios orig_termios;
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
{
struct termios cf;
va_list ap;
{
struct termios cf;
va_list ap;
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
{
struct termios cf;
va_list ap;
{
struct termios cf;
va_list ap;
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
{
struct termios cf;
va_list ap;
{
struct termios cf;
va_list ap;
fputc('\n', stderr);
postmsg(&cf);
}
fputc('\n', stderr);
postmsg(&cf);
}
-void connection_fatal(void *frontend, char *p, ...)
+void connection_fatal(void *frontend, const char *p, ...)
{
struct termios cf;
va_list ap;
{
struct termios cf;
va_list ap;
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
{
struct termios cf;
va_list ap;
{
struct termios cf;
va_list ap;
return FALSE; /* do not respond to incoming EOF with outgoing */
}
return FALSE; /* do not respond to incoming EOF with outgoing */
}
-int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
-Socket platform_new_connection(SockAddr addr, char *hostname,
+Socket platform_new_connection(SockAddr addr, const char *hostname,
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf)
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf)
-int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch)
+int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch)
{
return 0; /* pterm doesn't have any. */
}
{
return 0; /* pterm doesn't have any. */
}
* freed by the caller.
*/
static const char *pty_init(void *frontend, void **backend_handle, Conf *conf,
* freed by the caller.
*/
static const char *pty_init(void *frontend, void **backend_handle, Conf *conf,
- char *host, int port, char **realhost, int nodelay,
- int keepalive)
+ const char *host, int port, char **realhost,
+ int nodelay, int keepalive)
{
int slavefd;
pid_t pid, pgrp;
{
int slavefd;
pid_t pid, pgrp;
/*
* Called to send data down the pty.
*/
/*
* Called to send data down the pty.
*/
-static int pty_send(void *handle, char *buf, int len)
+static int pty_send(void *handle, const char *buf, int len)
const int use_event_log = 1, new_session = 1, saved_sessions = 1;
const int use_event_log = 1, new_session = 1, saved_sessions = 1;
-int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch)
+int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch)
+ char *argdup, *p, *q;
+ argdup = dupstr(arg);
+ q = argdup;
* argument, so that it will be deferred until it's a good
* moment to run it.
*/
* argument, so that it will be deferred until it's a good
* moment to run it.
*/
- int ret = cmdline_process_param("-P", arg, 1, conf);
+ int ret = cmdline_process_param("-P", argdup, 1, conf);
assert(ret == 2);
} else if (!strncmp(q, "telnet:", 7)) {
/*
assert(ret == 2);
} else if (!strncmp(q, "telnet:", 7)) {
/*
/*
* Otherwise, treat this argument as a host name.
*/
/*
* Otherwise, treat this argument as a host name.
*/
while (*p && !isspace((unsigned char)*p))
p++;
if (*p)
while (*p && !isspace((unsigned char)*p))
p++;
if (*p)
}
if (got_host)
*allow_launch = TRUE;
}
if (got_host)
*allow_launch = TRUE;
*/
static const char *serial_init(void *frontend_handle, void **backend_handle,
Conf *conf,
*/
static const char *serial_init(void *frontend_handle, void **backend_handle,
Conf *conf,
- char *host, int port, char **realhost, int nodelay,
- int keepalive)
+ const char *host, int port, char **realhost,
+ int nodelay, int keepalive)
{
Serial serial;
const char *err;
{
Serial serial;
const char *err;
/*
* Called to send data down the serial connection.
*/
/*
* Called to send data down the serial connection.
*/
-static int serial_send(void *handle, char *buf, int len)
+static int serial_send(void *handle, const char *buf, int len)
{
Serial serial = (Serial) handle;
{
Serial serial = (Serial) handle;
char *get_ttymode(void *frontend, const char *mode) { return NULL; }
char *get_ttymode(void *frontend, const char *mode) { return NULL; }
-int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
-RFile *open_existing_file(char *name, uint64 *size,
+RFile *open_existing_file(const char *name, uint64 *size,
unsigned long *mtime, unsigned long *atime,
long *perms)
{
unsigned long *mtime, unsigned long *atime,
long *perms)
{
-WFile *open_new_file(char *name, long perms)
+WFile *open_new_file(const char *name, long perms)
-WFile *open_existing_wfile(char *name, uint64 *size)
+WFile *open_existing_wfile(const char *name, uint64 *size)
-int file_type(char *name)
+int file_type(const char *name)
-DirHandle *open_directory(char *name)
+DirHandle *open_directory(const char *name)
{
DIR *dir;
DirHandle *ret;
{
DIR *dir;
DirHandle *ret;
-int test_wildcard(char *name, int cmdline)
+int test_wildcard(const char *name, int cmdline)
glob_t globbed;
int i;
};
glob_t globbed;
int i;
};
-WildcardMatcher *begin_wildcard_matching(char *name) {
+WildcardMatcher *begin_wildcard_matching(const char *name) {
WildcardMatcher *ret = snew(WildcardMatcher);
if (glob(name, 0, NULL, &ret->globbed) < 0) {
WildcardMatcher *ret = snew(WildcardMatcher);
if (glob(name, 0, NULL, &ret->globbed) < 0) {
-int vet_filename(char *name)
+int vet_filename(const char *name)
{
if (strchr(name, '/'))
return FALSE;
{
if (strchr(name, '/'))
return FALSE;
-int create_directory(char *name)
+int create_directory(const char *name)
{
return mkdir(name, 0777) == 0;
}
{
return mkdir(name, 0777) == 0;
}
-char *dir_file_cat(char *dir, char *file)
+char *dir_file_cat(const char *dir, const char *file)
{
return dupcat(dir, "/", file, NULL);
}
{
return dupcat(dir, "/", file, NULL);
}
/*
* Read a PSFTP command line from stdin.
*/
/*
* Read a PSFTP command line from stdin.
*/
-char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok)
+char *ssh_sftp_get_cmdline(const char *prompt, int no_fds_ok)
{
char *buf;
int buflen, bufsize, ret;
{
char *buf;
int buflen, bufsize, ret;
}
int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
}
int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
- char *mbstr, int mblen, char *defchr, int *defused,
+ char *mbstr, int mblen, const char *defchr, int *defused,
struct unicode_data *ucsdata)
{
/* FIXME: we should remove the defused param completely... */
struct unicode_data *ucsdata)
{
/* FIXME: we should remove the defused param completely... */
WriteFile(hout, data, len, &dummy, NULL);
}
WriteFile(hout, data, len, &dummy, NULL);
}
-int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+int console_get_userpass_input(prompts_t *p,
+ const unsigned char *in, int inlen)
{
HANDLE hin, hout;
size_t curr_prompt;
{
HANDLE hin, hout;
size_t curr_prompt;
-void dlg_error_msg(void *dlg, char *msg)
+void dlg_error_msg(void *dlg, const char *msg)
{
struct dlgparam *dp = (struct dlgparam *)dlg;
MessageBox(dp->hwnd, msg,
{
struct dlgparam *dp = (struct dlgparam *)dlg;
MessageBox(dp->hwnd, msg,
/*
* Print a message box and close the connection.
*/
/*
* Print a message box and close the connection.
*/
-void connection_fatal(void *frontend, char *fmt, ...)
+void connection_fatal(void *frontend, const char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
{
va_list ap;
char *stuff, morestuff[100];
/*
* Report an error at the command-line parsing stage.
*/
/*
* Report an error at the command-line parsing stage.
*/
-void cmdline_error(char *fmt, ...)
+void cmdline_error(const char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
{
va_list ap;
char *stuff, morestuff[100];
unsigned int sessno = ((lParam - IDM_SAVED_MIN)
/ MENU_SAVED_STEP) + 1;
if (sessno < (unsigned)sesslist.nsessions) {
unsigned int sessno = ((lParam - IDM_SAVED_MIN)
/ MENU_SAVED_STEP) + 1;
if (sessno < (unsigned)sesslist.nsessions) {
- char *session = sesslist.sessions[sessno];
+ const char *session = sesslist.sessions[sessno];
cl = dupprintf("putty @%s", session);
inherit_handles = FALSE;
freecl = TRUE;
cl = dupprintf("putty @%s", session);
inherit_handles = FALSE;
freecl = TRUE;
/*
* Print a message box and perform a fatal exit.
*/
/*
* Print a message box and perform a fatal exit.
*/
-void fatalbox(char *fmt, ...)
+void fatalbox(const char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
{
va_list ap;
char *stuff, morestuff[100];
/*
* Print a modal (Really Bad) message box and perform a fatal exit.
*/
/*
* Print a modal (Really Bad) message box and perform a fatal exit.
*/
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
{
va_list ap;
char *stuff, morestuff[100];
/*
* Print a message box and don't close the connection.
*/
/*
* Print a message box and don't close the connection.
*/
-void nonfatal(char *fmt, ...)
+void nonfatal(const char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
{
va_list ap;
char *stuff, morestuff[100];
return TRUE; /* do respond to incoming EOF with outgoing */
}
return TRUE; /* do respond to incoming EOF with outgoing */
}
-int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
Ssh_gss_ctx ctx, Ssh_gss_buf *buf)
{
winSsh_gss_ctx *winctx = (winSsh_gss_ctx *) ctx;
Ssh_gss_ctx ctx, Ssh_gss_buf *buf)
{
winSsh_gss_ctx *winctx = (winSsh_gss_ctx *) ctx;
if (winctx == NULL) return SSH_GSS_FAILURE;
if (winctx == NULL) return SSH_GSS_FAILURE;
static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
static int debug_got_console = 0;
static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
static int debug_got_console = 0;
+void dputs(const char *buf)
struct Socket_tag {
const struct socket_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */
struct Socket_tag {
const struct socket_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */
SOCKET s;
Plug plug;
bufchain output_data;
SOCKET s;
Plug plug;
bufchain output_data;
static tree234 *errstrings = NULL;
static tree234 *errstrings = NULL;
-char *winsock_error_string(int error)
+const char *winsock_error_string(int error)
{
const char prefix[] = "Network error: ";
struct errstring *es;
{
const char prefix[] = "Network error: ";
struct errstring *es;
-Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only,
- int orig_address_family)
+Socket sk_newlistener(const char *srcaddr, int port, Plug plug,
+ int local_host_only, int orig_address_family)
{
static const struct socket_function_table fn_table = {
sk_tcp_plug,
{
static const struct socket_function_table fn_table = {
sk_tcp_plug,
/*
* Print a modal (Really Bad) message box and perform a fatal exit.
*/
/*
* Print a modal (Really Bad) message box and perform a fatal exit.
*/
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
{
va_list ap;
char *stuff;
{
va_list ap;
char *stuff;
/*
* Print a non-fatal message box and do not exit.
*/
/*
* Print a non-fatal message box and do not exit.
*/
-void nonfatal(char *fmt, ...)
+void nonfatal(const char *fmt, ...)
{
va_list ap;
char *stuff;
{
va_list ap;
char *stuff;
case WM_HELP:
{
int id = ((LPHELPINFO)lParam)->iCtrlId;
case WM_HELP:
{
int id = ((LPHELPINFO)lParam)->iCtrlId;
+ const char *topic = NULL;
switch (id) {
case IDC_GENERATING:
case IDC_PROGRESS:
switch (id) {
case IDC_GENERATING:
case IDC_PROGRESS:
/*
* Print a modal (Really Bad) message box and perform a fatal exit.
*/
/*
* Print a modal (Really Bad) message box and perform a fatal exit.
*/
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
case WM_HELP:
{
int id = ((LPHELPINFO)lParam)->iCtrlId;
case WM_HELP:
{
int id = ((LPHELPINFO)lParam)->iCtrlId;
+ const char *topic = NULL;
switch (id) {
case 100: topic = WINHELP_CTX_pageant_keylist; break;
case 101: topic = WINHELP_CTX_pageant_addkey; break;
switch (id) {
case 100: topic = WINHELP_CTX_pageant_keylist; break;
case 101: topic = WINHELP_CTX_pageant_addkey; break;
/*
* Fork and Exec the command in cmdline. [DBW]
*/
/*
* Fork and Exec the command in cmdline. [DBW]
*/
-void spawn_cmd(char *cmdline, char * args, int show)
+void spawn_cmd(const char *cmdline, const char *args, int show)
{
if (ShellExecute(NULL, _T("open"), cmdline,
args, NULL, show) <= (HINSTANCE) 32) {
{
if (ShellExecute(NULL, _T("open"), cmdline,
args, NULL, show) <= (HINSTANCE) 32) {
{
WNDCLASS wndclass;
MSG msg;
{
WNDCLASS wndclass;
MSG msg;
+ const char *command = NULL;
int added_keys = 0;
int argc, i;
char **argv, **argstart;
int added_keys = 0;
int argc, i;
char **argv, **argstart;
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
{
va_list ap;
fprintf(stderr, "ERROR: ");
{
va_list ap;
fprintf(stderr, "ERROR: ");
va_end(ap);
fputc('\n', stderr);
}
va_end(ap);
fputc('\n', stderr);
}
-void connection_fatal(void *frontend, char *p, ...)
+void connection_fatal(void *frontend, const char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
{
va_list ap;
fprintf(stderr, "plink: ");
{
va_list ap;
fprintf(stderr, "plink: ");
return FALSE; /* do not respond to incoming EOF with outgoing */
}
return FALSE; /* do not respond to incoming EOF with outgoing */
}
-int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
Socket make_handle_socket(HANDLE send_H, HANDLE recv_H, Plug plug,
int overlapped);
Socket make_handle_socket(HANDLE send_H, HANDLE recv_H, Plug plug,
int overlapped);
-Socket platform_new_connection(SockAddr addr, char *hostname,
+Socket platform_new_connection(SockAddr addr, const char *hostname,
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf)
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf)
* freed by the caller.
*/
static const char *serial_init(void *frontend_handle, void **backend_handle,
* freed by the caller.
*/
static const char *serial_init(void *frontend_handle, void **backend_handle,
- Conf *conf, char *host, int port,
+ Conf *conf, const char *host, int port,
char **realhost, int nodelay, int keepalive)
{
Serial serial;
char **realhost, int nodelay, int keepalive)
{
Serial serial;
/*
* Called to send data down the serial connection.
*/
/*
* Called to send data down the serial connection.
*/
-static int serial_send(void *handle, char *buf, int len)
+static int serial_send(void *handle, const char *buf, int len)
{
Serial serial = (Serial) handle;
{
Serial serial = (Serial) handle;
char *get_ttymode(void *frontend, const char *mode) { return NULL; }
char *get_ttymode(void *frontend, const char *mode) { return NULL; }
-int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
-RFile *open_existing_file(char *name, uint64 *size,
+RFile *open_existing_file(const char *name, uint64 *size,
unsigned long *mtime, unsigned long *atime,
long *perms)
{
unsigned long *mtime, unsigned long *atime,
long *perms)
{
-WFile *open_new_file(char *name, long perms)
+WFile *open_new_file(const char *name, long perms)
-WFile *open_existing_wfile(char *name, uint64 *size)
+WFile *open_existing_wfile(const char *name, uint64 *size)
-int file_type(char *name)
+int file_type(const char *name)
{
DWORD attr;
attr = GetFileAttributes(name);
{
DWORD attr;
attr = GetFileAttributes(name);
-DirHandle *open_directory(char *name)
+DirHandle *open_directory(const char *name)
{
HANDLE h;
WIN32_FIND_DATA fdat;
{
HANDLE h;
WIN32_FIND_DATA fdat;
-int test_wildcard(char *name, int cmdline)
+int test_wildcard(const char *name, int cmdline)
{
HANDLE fh;
WIN32_FIND_DATA fdat;
{
HANDLE fh;
WIN32_FIND_DATA fdat;
-WildcardMatcher *begin_wildcard_matching(char *name)
+WildcardMatcher *begin_wildcard_matching(const char *name)
{
HANDLE h;
WIN32_FIND_DATA fdat;
{
HANDLE h;
WIN32_FIND_DATA fdat;
-int vet_filename(char *name)
+int vet_filename(const char *name)
{
if (strchr(name, '/') || strchr(name, '\\') || strchr(name, ':'))
return FALSE;
{
if (strchr(name, '/') || strchr(name, '\\') || strchr(name, ':'))
return FALSE;
-int create_directory(char *name)
+int create_directory(const char *name)
{
return CreateDirectory(name, NULL) != 0;
}
{
return CreateDirectory(name, NULL) != 0;
}
-char *dir_file_cat(char *dir, char *file)
+char *dir_file_cat(const char *dir, const char *file)
{
return dupcat(dir, "\\", file, NULL);
}
{
return dupcat(dir, "\\", file, NULL);
}
-char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok)
+char *ssh_sftp_get_cmdline(const char *prompt, int no_fds_ok)
{
int ret;
struct command_read_ctx actx, *ctx = &actx;
{
int ret;
struct command_read_ctx actx, *ctx = &actx;
}
int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
}
int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
- char *mbstr, int mblen, char *defchr, int *defused,
+ char *mbstr, int mblen, const char *defchr, int *defused,
struct unicode_data *ucsdata)
{
char *p;
struct unicode_data *ucsdata)
{
char *p;
/* Callback function to launch context help. */
static VOID CALLBACK message_box_help_callback(LPHELPINFO lpHelpInfo)
{
/* Callback function to launch context help. */
static VOID CALLBACK message_box_help_callback(LPHELPINFO lpHelpInfo)
{
+ const char *context = NULL;
#define CHECK_CTX(name) \
do { \
if (lpHelpInfo->dwContextId == WINHELP_CTXID_ ## name) \
#define CHECK_CTX(name) \
do { \
if (lpHelpInfo->dwContextId == WINHELP_CTXID_ ## name) \
#define XDM_MAXSKEW 20*60 /* 20 minute clock skew should be OK */
#define XDM_MAXSKEW 20*60 /* 20 minute clock skew should be OK */
-static char *x11_verify(unsigned long peer_ip, int peer_port,
- tree234 *authtree, char *proto,
- unsigned char *data, int dlen,
- struct X11FakeAuth **auth_ret)
+static const char *x11_verify(unsigned long peer_ip, int peer_port,
+ tree234 *authtree, char *proto,
+ unsigned char *data, int dlen,
+ struct X11FakeAuth **auth_ret)
{
struct X11FakeAuth match_dummy; /* for passing to find234 */
struct X11FakeAuth *auth;
{
struct X11FakeAuth match_dummy; /* for passing to find234 */
struct X11FakeAuth *auth;