mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-26 01:32:25 +00:00
Move a recently introduced utility function out of the file in which I
declared it static, and into winutils.c where it can be more generally accessible. [originally from svn r9318]
This commit is contained in:
parent
da66c0656a
commit
535d77abf0
@ -2098,26 +2098,12 @@ void dlg_editbox_set(union control *ctrl, void *dlg, char const *text)
|
|||||||
SetDlgItemText(dp->hwnd, c->base_id+1, text);
|
SetDlgItemText(dp->hwnd, c->base_id+1, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *getdlgitemtext_alloc(HWND hwnd, int id)
|
|
||||||
{
|
|
||||||
char *ret = NULL;
|
|
||||||
int size = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
size = size * 4 / 3 + 512;
|
|
||||||
ret = sresize(ret, size, char);
|
|
||||||
GetDlgItemText(hwnd, id, ret, size);
|
|
||||||
} while (!memchr(ret, '\0', size-1));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *dlg_editbox_get(union control *ctrl, void *dlg)
|
char *dlg_editbox_get(union control *ctrl, void *dlg)
|
||||||
{
|
{
|
||||||
struct dlgparam *dp = (struct dlgparam *)dlg;
|
struct dlgparam *dp = (struct dlgparam *)dlg;
|
||||||
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
|
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
|
||||||
assert(c && c->ctrl->generic.type == CTRL_EDITBOX);
|
assert(c && c->ctrl->generic.type == CTRL_EDITBOX);
|
||||||
return getdlgitemtext_alloc(dp->hwnd, c->base_id+1);
|
return GetDlgItemText_alloc(dp->hwnd, c->base_id+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The `listbox' functions can also apply to combo boxes. */
|
/* The `listbox' functions can also apply to combo boxes. */
|
||||||
@ -2312,7 +2298,7 @@ Filename *dlg_filesel_get(union control *ctrl, void *dlg)
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
Filename *ret;
|
Filename *ret;
|
||||||
assert(c && c->ctrl->generic.type == CTRL_FILESELECT);
|
assert(c && c->ctrl->generic.type == CTRL_FILESELECT);
|
||||||
tmp = getdlgitemtext_alloc(dp->hwnd, c->base_id+1);
|
tmp = GetDlgItemText_alloc(dp->hwnd, c->base_id+1);
|
||||||
ret = filename_from_str(tmp);
|
ret = filename_from_str(tmp);
|
||||||
sfree(tmp);
|
sfree(tmp);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -287,6 +287,7 @@ BOOL request_file(filereq *state, OPENFILENAME *of, int preserve, int save);
|
|||||||
filereq *filereq_new(void);
|
filereq *filereq_new(void);
|
||||||
void filereq_free(filereq *state);
|
void filereq_free(filereq *state);
|
||||||
int message_box(LPCTSTR text, LPCTSTR caption, DWORD style, DWORD helpctxid);
|
int message_box(LPCTSTR text, LPCTSTR caption, DWORD style, DWORD helpctxid);
|
||||||
|
char *GetDlgItemText_alloc(HWND hwnd, int id);
|
||||||
void split_into_argv(char *, int *, char ***, char ***);
|
void split_into_argv(char *, int *, char ***, char ***);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -150,6 +150,25 @@ void pgp_fingerprints(void)
|
|||||||
HELPCTXID(pgp_fingerprints));
|
HELPCTXID(pgp_fingerprints));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handy wrapper around GetDlgItemText which doesn't make you invent
|
||||||
|
* an arbitrary length limit on the output string. Returned string is
|
||||||
|
* dynamically allocated; caller must free.
|
||||||
|
*/
|
||||||
|
char *GetDlgItemText_alloc(HWND hwnd, int id)
|
||||||
|
{
|
||||||
|
char *ret = NULL;
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
size = size * 4 / 3 + 512;
|
||||||
|
ret = sresize(ret, size, char);
|
||||||
|
GetDlgItemText(hwnd, id, ret, size);
|
||||||
|
} while (!memchr(ret, '\0', size-1));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Split a complete command line into argc/argv, attempting to do
|
* Split a complete command line into argc/argv, attempting to do
|
||||||
* it exactly the same way Windows itself would do it (so that
|
* it exactly the same way Windows itself would do it (so that
|
||||||
|
Loading…
Reference in New Issue
Block a user