mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Convert a lot of 'int' variables to 'bool'.
My normal habit these days, in new code, is to treat int and bool as _almost_ completely separate types. I'm still willing to use C's implicit test for zero on an integer (e.g. 'if (!blob.len)' is fine, no need to spell it out as blob.len != 0), but generally, if a variable is going to be conceptually a boolean, I like to declare it bool and assign to it using 'true' or 'false' rather than 0 or 1. PuTTY is an exception, because it predates the C99 bool, and I've stuck to its existing coding style even when adding new code to it. But it's been annoying me more and more, so now that I've decided C99 bool is an acceptable thing to require from our toolchain in the first place, here's a quite thorough trawl through the source doing 'boolification'. Many variables and function parameters are now typed as bool rather than int; many assignments of 0 or 1 to those variables are now spelled 'true' or 'false'. I managed this thorough conversion with the help of a custom clang plugin that I wrote to trawl the AST and apply heuristics to point out where things might want changing. So I've even managed to do a decent job on parts of the code I haven't looked at in years! To make the plugin's work easier, I pushed platform front ends generally in the direction of using standard 'bool' in preference to platform-specific boolean types like Windows BOOL or GTK's gboolean; I've left the platform booleans in places they _have_ to be for the platform APIs to work right, but variables only used by my own code have been converted wherever I found them. In a few places there are int values that look very like booleans in _most_ of the places they're used, but have a rarely-used third value, or a distinction between different nonzero values that most users don't care about. In these cases, I've _removed_ uses of 'true' and 'false' for the return values, to emphasise that there's something more subtle going on than a simple boolean answer: - the 'multisel' field in dialog.h's list box structure, for which the GTK front end in particular recognises a difference between 1 and 2 but nearly everything else treats as boolean - the 'urgent' parameter to plug_receive, where 1 vs 2 tells you something about the specific location of the urgent pointer, but most clients only care about 0 vs 'something nonzero' - the return value of wc_match, where -1 indicates a syntax error in the wildcard. - the return values from SSH-1 RSA-key loading functions, which use -1 for 'wrong passphrase' and 0 for all other failures (so any caller which already knows it's not loading an _encrypted private_ key can treat them as boolean) - term->esc_query, and the 'query' parameter in toggle_mode in terminal.c, which _usually_ hold 0 for ESC[123h or 1 for ESC[?123h, but can also hold -1 for some other intervening character that we don't support. In a few places there's an integer that I haven't turned into a bool even though it really _can_ only take values 0 or 1 (and, as above, tried to make the call sites consistent in not calling those values true and false), on the grounds that I thought it would make it more confusing to imply that the 0 value was in some sense 'negative' or bad and the 1 positive or good: - the return value of plug_accepting uses the POSIXish convention of 0=success and nonzero=error; I think if I made it bool then I'd also want to reverse its sense, and that's a job for a separate piece of work. - the 'screen' parameter to lineptr() in terminal.c, where 0 and 1 represent the default and alternate screens. There's no obvious reason why one of those should be considered 'true' or 'positive' or 'success' - they're just indices - so I've left it as int. ssh_scp_recv had particularly confusing semantics for its previous int return value: its call sites used '<= 0' to check for error, but it never actually returned a negative number, just 0 or 1. Now the function and its call sites agree that it's a bool. In a couple of places I've renamed variables called 'ret', because I don't like that name any more - it's unclear whether it means the return value (in preparation) for the _containing_ function or the return value received from a subroutine call, and occasionally I've accidentally used the same variable for both and introduced a bug. So where one of those got in my way, I've renamed it to 'toret' or 'retd' (the latter short for 'returned') in line with my usual modern practice, but I haven't done a thorough job of finding all of them. Finally, one amusing side effect of doing this is that I've had to separate quite a few chained assignments. It used to be perfectly fine to write 'a = b = c = TRUE' when a,b,c were int and TRUE was just a the 'true' defined by stdbool.h, that idiom provokes a warning from gcc: 'suggest parentheses around assignment used as truth value'!
This commit is contained in:
@ -91,7 +91,7 @@ static LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg,
|
||||
}
|
||||
|
||||
static HWND tip_wnd = NULL;
|
||||
static int tip_enabled = 0;
|
||||
static bool tip_enabled = false;
|
||||
|
||||
void UpdateSizeTip(HWND src, int cx, int cy)
|
||||
{
|
||||
@ -183,7 +183,7 @@ void UpdateSizeTip(HWND src, int cx, int cy)
|
||||
}
|
||||
}
|
||||
|
||||
void EnableSizeTip(int bEnable)
|
||||
void EnableSizeTip(bool bEnable)
|
||||
{
|
||||
if (tip_wnd && !bEnable) {
|
||||
DestroyWindow(tip_wnd);
|
||||
|
@ -9,10 +9,10 @@
|
||||
#define WINCAPI_GLOBAL
|
||||
#include "wincapi.h"
|
||||
|
||||
int got_crypt(void)
|
||||
bool got_crypt(void)
|
||||
{
|
||||
static int attempted = false;
|
||||
static int successful;
|
||||
static bool attempted = false;
|
||||
static bool successful;
|
||||
static HMODULE crypt;
|
||||
|
||||
if (!attempted) {
|
||||
|
@ -13,6 +13,6 @@
|
||||
DECL_WINDOWS_FUNCTION(WINCAPI_GLOBAL, BOOL, CryptProtectMemory,
|
||||
(LPVOID,DWORD,DWORD));
|
||||
|
||||
int got_crypt(void);
|
||||
bool got_crypt(void);
|
||||
|
||||
#endif
|
||||
|
@ -40,8 +40,8 @@ static void variable_pitch_handler(union control *ctrl, dlgparam *dlg,
|
||||
}
|
||||
}
|
||||
|
||||
void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
int midsession, int protocol)
|
||||
void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help,
|
||||
bool midsession, int protocol)
|
||||
{
|
||||
struct controlset *s;
|
||||
union control *c;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "storage.h"
|
||||
#include "ssh.h"
|
||||
|
||||
int console_batch_mode = false;
|
||||
bool console_batch_mode = false;
|
||||
|
||||
/*
|
||||
* Clean up and exit.
|
||||
@ -481,14 +481,11 @@ int console_get_userpass_input(prompts_t *p)
|
||||
len = 0;
|
||||
while (1) {
|
||||
DWORD ret = 0;
|
||||
BOOL r;
|
||||
|
||||
prompt_ensure_result_size(pr, len * 5 / 4 + 512);
|
||||
|
||||
r = ReadFile(hin, pr->result + len, pr->resultsize - len - 1,
|
||||
&ret, NULL);
|
||||
|
||||
if (!r || ret == 0) {
|
||||
if (!ReadFile(hin, pr->result + len, pr->resultsize - len - 1,
|
||||
&ret, NULL) || ret == 0) {
|
||||
len = -1;
|
||||
break;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ void endbox(struct ctlpos *cp)
|
||||
/*
|
||||
* A static line, followed by a full-width edit box.
|
||||
*/
|
||||
void editboxfw(struct ctlpos *cp, int password, char *text,
|
||||
void editboxfw(struct ctlpos *cp, bool password, char *text,
|
||||
int staticid, int editid)
|
||||
{
|
||||
RECT r;
|
||||
@ -534,7 +534,7 @@ void staticbtn(struct ctlpos *cp, char *stext, int sid,
|
||||
/*
|
||||
* A simple push button.
|
||||
*/
|
||||
void button(struct ctlpos *cp, char *btext, int bid, int defbtn)
|
||||
void button(struct ctlpos *cp, char *btext, int bid, bool defbtn)
|
||||
{
|
||||
RECT r;
|
||||
|
||||
@ -769,7 +769,7 @@ void bigeditctrl(struct ctlpos *cp, char *stext,
|
||||
* A list box with a static labelling it.
|
||||
*/
|
||||
void listbox(struct ctlpos *cp, char *stext,
|
||||
int sid, int lid, int lines, int multi)
|
||||
int sid, int lid, int lines, bool multi)
|
||||
{
|
||||
RECT r;
|
||||
|
||||
@ -994,7 +994,7 @@ static void pl_moveitem(HWND hwnd, int listid, int src, int dst)
|
||||
sfree (txt);
|
||||
}
|
||||
|
||||
int pl_itemfrompt(HWND hwnd, POINT cursor, BOOL scroll)
|
||||
int pl_itemfrompt(HWND hwnd, POINT cursor, bool scroll)
|
||||
{
|
||||
int ret;
|
||||
POINT uppoint, downpoint;
|
||||
@ -1041,7 +1041,7 @@ int pl_itemfrompt(HWND hwnd, POINT cursor, BOOL scroll)
|
||||
*/
|
||||
int handle_prefslist(struct prefslist *hdl,
|
||||
int *array, int maxmemb,
|
||||
int is_dlmsg, HWND hwnd,
|
||||
bool is_dlmsg, HWND hwnd,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int i;
|
||||
@ -1063,7 +1063,7 @@ int handle_prefslist(struct prefslist *hdl,
|
||||
LB_ADDSTRING, 0, (LPARAM) "");
|
||||
|
||||
hdl->srcitem = p_LBItemFromPt(dlm->hWnd, dlm->ptCursor, true);
|
||||
hdl->dragging = 0;
|
||||
hdl->dragging = false;
|
||||
/* XXX hack Q183115 */
|
||||
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, true);
|
||||
ret |= 1; break;
|
||||
@ -1071,10 +1071,10 @@ int handle_prefslist(struct prefslist *hdl,
|
||||
p_DrawInsert(hwnd, dlm->hWnd, -1); /* Clear arrow */
|
||||
SendDlgItemMessage(hwnd, hdl->listid,
|
||||
LB_DELETESTRING, hdl->dummyitem, 0);
|
||||
hdl->dragging = 0;
|
||||
hdl->dragging = false;
|
||||
ret |= 1; break;
|
||||
case DL_DRAGGING:
|
||||
hdl->dragging = 1;
|
||||
hdl->dragging = true;
|
||||
dest = pl_itemfrompt(dlm->hWnd, dlm->ptCursor, true);
|
||||
if (dest > hdl->dummyitem) dest = hdl->dummyitem;
|
||||
p_DrawInsert (hwnd, dlm->hWnd, dest);
|
||||
@ -1092,7 +1092,7 @@ int handle_prefslist(struct prefslist *hdl,
|
||||
SendDlgItemMessage(hwnd, hdl->listid,
|
||||
LB_DELETESTRING, hdl->dummyitem, 0);
|
||||
if (hdl->dragging) {
|
||||
hdl->dragging = 0;
|
||||
hdl->dragging = false;
|
||||
if (dest >= 0) {
|
||||
/* Correct for "missing" item. */
|
||||
if (dest > hdl->srcitem) dest--;
|
||||
@ -1654,7 +1654,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
|
||||
shortcuts[nshortcuts++] = ctrl->fontselect.shortcut;
|
||||
statictext(&pos, escaped, 1, base_id);
|
||||
staticbtn(&pos, "", base_id+1, "Change...", base_id+2);
|
||||
data = fontspec_new("", 0, 0, 0);
|
||||
data = fontspec_new("", false, 0, 0);
|
||||
sfree(escaped);
|
||||
break;
|
||||
default:
|
||||
@ -1710,7 +1710,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
|
||||
}
|
||||
|
||||
static void winctrl_set_focus(union control *ctrl, struct dlgparam *dp,
|
||||
int has_focus)
|
||||
bool has_focus)
|
||||
{
|
||||
if (has_focus) {
|
||||
if (dp->focused)
|
||||
@ -1731,12 +1731,13 @@ union control *dlg_last_focused(union control *ctrl, dlgparam *dp)
|
||||
* The dialog-box procedure calls this function to handle Windows
|
||||
* messages on a control we manage.
|
||||
*/
|
||||
int winctrl_handle_command(struct dlgparam *dp, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
bool winctrl_handle_command(struct dlgparam *dp, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
struct winctrl *c;
|
||||
union control *ctrl;
|
||||
int i, id, ret;
|
||||
int i, id;
|
||||
bool ret;
|
||||
static UINT draglistmsg = WM_NULL;
|
||||
|
||||
/*
|
||||
@ -1747,7 +1748,7 @@ int winctrl_handle_command(struct dlgparam *dp, UINT msg,
|
||||
draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
|
||||
|
||||
if (msg != draglistmsg && msg != WM_COMMAND && msg != WM_DRAWITEM)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
/*
|
||||
* Look up the control ID in our data.
|
||||
@ -1759,7 +1760,7 @@ int winctrl_handle_command(struct dlgparam *dp, UINT msg,
|
||||
break;
|
||||
}
|
||||
if (!c)
|
||||
return 0; /* we have nothing to do */
|
||||
return false; /* we have nothing to do */
|
||||
|
||||
if (msg == WM_DRAWITEM) {
|
||||
/*
|
||||
@ -1787,7 +1788,7 @@ int winctrl_handle_command(struct dlgparam *dp, UINT msg,
|
||||
id = LOWORD(wParam) - c->base_id;
|
||||
|
||||
if (!ctrl || !ctrl->generic.handler)
|
||||
return 0; /* nothing we can do here */
|
||||
return false; /* nothing we can do here */
|
||||
|
||||
/*
|
||||
* From here on we do not issue `return' statements until the
|
||||
@ -1796,7 +1797,7 @@ int winctrl_handle_command(struct dlgparam *dp, UINT msg,
|
||||
* to reach the end of this switch statement so that the
|
||||
* subsequent code can test dp->coloursel_wanted().
|
||||
*/
|
||||
ret = 0;
|
||||
ret = false;
|
||||
dp->coloursel_wanted = false;
|
||||
|
||||
/*
|
||||
@ -2021,7 +2022,7 @@ int winctrl_handle_command(struct dlgparam *dp, UINT msg,
|
||||
* This function can be called to produce context help on a
|
||||
* control. Returns true if it has actually launched some help.
|
||||
*/
|
||||
int winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id)
|
||||
bool winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id)
|
||||
{
|
||||
int i;
|
||||
struct winctrl *c;
|
||||
@ -2036,17 +2037,17 @@ int winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id)
|
||||
break;
|
||||
}
|
||||
if (!c)
|
||||
return 0; /* we have nothing to do */
|
||||
return false; /* we have nothing to do */
|
||||
|
||||
/*
|
||||
* This is the Windows front end, so we're allowed to assume
|
||||
* `helpctx.p' is a context string.
|
||||
*/
|
||||
if (!c->ctrl || !c->ctrl->generic.helpctx.p)
|
||||
return 0; /* no help available for this ctrl */
|
||||
return false; /* no help available for this ctrl */
|
||||
|
||||
launch_help(hwnd, c->ctrl->generic.helpctx.p);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2088,14 +2089,14 @@ int dlg_radiobutton_get(union control *ctrl, dlgparam *dp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dlg_checkbox_set(union control *ctrl, dlgparam *dp, int checked)
|
||||
void dlg_checkbox_set(union control *ctrl, dlgparam *dp, bool checked)
|
||||
{
|
||||
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
|
||||
assert(c && c->ctrl->generic.type == CTRL_CHECKBOX);
|
||||
CheckDlgButton(dp->hwnd, c->base_id, (checked != 0));
|
||||
CheckDlgButton(dp->hwnd, c->base_id, checked);
|
||||
}
|
||||
|
||||
int dlg_checkbox_get(union control *ctrl, dlgparam *dp)
|
||||
bool dlg_checkbox_get(union control *ctrl, dlgparam *dp)
|
||||
{
|
||||
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
|
||||
assert(c && c->ctrl->generic.type == CTRL_CHECKBOX);
|
||||
@ -2210,7 +2211,7 @@ int dlg_listbox_index(union control *ctrl, dlgparam *dp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int dlg_listbox_issel(union control *ctrl, dlgparam *dp, int index)
|
||||
bool dlg_listbox_issel(union control *ctrl, dlgparam *dp, int index)
|
||||
{
|
||||
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
|
||||
assert(c && c->ctrl->generic.type == CTRL_LISTBOX &&
|
||||
@ -2447,16 +2448,16 @@ void dlg_coloursel_start(union control *ctrl, dlgparam *dp, int r, int g, int b)
|
||||
dp->coloursel_result.b = b;
|
||||
}
|
||||
|
||||
int dlg_coloursel_results(union control *ctrl, dlgparam *dp,
|
||||
int *r, int *g, int *b)
|
||||
bool dlg_coloursel_results(union control *ctrl, dlgparam *dp,
|
||||
int *r, int *g, int *b)
|
||||
{
|
||||
if (dp->coloursel_result.ok) {
|
||||
*r = dp->coloursel_result.r;
|
||||
*g = dp->coloursel_result.g;
|
||||
*b = dp->coloursel_result.b;
|
||||
return 1;
|
||||
return true;
|
||||
} else
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void dlg_auto_set_fixed_pitch_flag(dlgparam *dp)
|
||||
@ -2467,7 +2468,7 @@ void dlg_auto_set_fixed_pitch_flag(dlgparam *dp)
|
||||
HFONT hfont;
|
||||
HDC hdc;
|
||||
TEXTMETRIC tm;
|
||||
int is_var;
|
||||
bool is_var;
|
||||
|
||||
/*
|
||||
* Attempt to load the current font, and see if it's
|
||||
@ -2502,12 +2503,12 @@ void dlg_auto_set_fixed_pitch_flag(dlgparam *dp)
|
||||
dp->fixed_pitch_fonts = false;
|
||||
}
|
||||
|
||||
int dlg_get_fixed_pitch_flag(dlgparam *dp)
|
||||
bool dlg_get_fixed_pitch_flag(dlgparam *dp)
|
||||
{
|
||||
return dp->fixed_pitch_fonts;
|
||||
}
|
||||
|
||||
void dlg_set_fixed_pitch_flag(dlgparam *dp, int flag)
|
||||
void dlg_set_fixed_pitch_flag(dlgparam *dp, bool flag)
|
||||
{
|
||||
dp->fixed_pitch_fonts = flag;
|
||||
}
|
||||
|
@ -9,9 +9,9 @@
|
||||
FontSpec *platform_default_fontspec(const char *name)
|
||||
{
|
||||
if (!strcmp(name, "Font"))
|
||||
return fontspec_new("Courier New", 0, 10, ANSI_CHARSET);
|
||||
return fontspec_new("Courier New", false, 10, ANSI_CHARSET);
|
||||
else
|
||||
return fontspec_new("", 0, 0, 0);
|
||||
return fontspec_new("", false, 0, 0);
|
||||
}
|
||||
|
||||
Filename *platform_default_filename(const char *name)
|
||||
|
@ -55,20 +55,20 @@ extern Conf *conf; /* defined in window.c */
|
||||
|
||||
void force_normal(HWND hwnd)
|
||||
{
|
||||
static int recurse = 0;
|
||||
static bool recurse = false;
|
||||
|
||||
WINDOWPLACEMENT wp;
|
||||
|
||||
if (recurse)
|
||||
return;
|
||||
recurse = 1;
|
||||
recurse = true;
|
||||
|
||||
wp.length = sizeof(wp);
|
||||
if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
|
||||
wp.showCmd = SW_SHOWNORMAL;
|
||||
SetWindowPlacement(hwnd, &wp);
|
||||
}
|
||||
recurse = 0;
|
||||
recurse = false;
|
||||
}
|
||||
|
||||
static char *getevent(int i)
|
||||
@ -693,9 +693,9 @@ void defuse_showwindow(void)
|
||||
}
|
||||
}
|
||||
|
||||
int do_config(void)
|
||||
bool do_config(void)
|
||||
{
|
||||
int ret;
|
||||
bool ret;
|
||||
|
||||
ctrlbox = ctrl_new_box();
|
||||
setup_config_box(ctrlbox, false, 0, 0);
|
||||
@ -723,10 +723,11 @@ int do_config(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int do_reconfig(HWND hwnd, int protcfginfo)
|
||||
bool do_reconfig(HWND hwnd, int protcfginfo)
|
||||
{
|
||||
Conf *backup_conf;
|
||||
int ret, protocol;
|
||||
bool ret;
|
||||
int protocol;
|
||||
|
||||
backup_conf = conf_copy(conf);
|
||||
|
||||
|
266
windows/window.c
266
windows/window.c
@ -102,24 +102,25 @@ static void set_input_locale(HKL);
|
||||
static void update_savedsess_menu(void);
|
||||
static void init_winfuncs(void);
|
||||
|
||||
static int is_full_screen(void);
|
||||
static bool is_full_screen(void);
|
||||
static void make_full_screen(void);
|
||||
static void clear_full_screen(void);
|
||||
static void flip_full_screen(void);
|
||||
static void process_clipdata(HGLOBAL clipdata, int unicode);
|
||||
static void process_clipdata(HGLOBAL clipdata, bool unicode);
|
||||
static void setup_clipboards(Terminal *, Conf *);
|
||||
|
||||
/* Window layout information */
|
||||
static void reset_window(int);
|
||||
static int extra_width, extra_height;
|
||||
static int font_width, font_height, font_dualwidth, font_varpitch;
|
||||
static int font_width, font_height;
|
||||
static bool font_dualwidth, font_varpitch;
|
||||
static int offset_width, offset_height;
|
||||
static int was_zoomed = 0;
|
||||
static bool was_zoomed = false;
|
||||
static int prev_rows, prev_cols;
|
||||
|
||||
static void flash_window(int mode);
|
||||
static void sys_cursor_update(void);
|
||||
static int get_fullscreen_rect(RECT * ss);
|
||||
static bool get_fullscreen_rect(RECT * ss);
|
||||
|
||||
static int caret_x = -1, caret_y = -1;
|
||||
|
||||
@ -129,8 +130,8 @@ static Ldisc *ldisc;
|
||||
static Backend *backend;
|
||||
|
||||
static struct unicode_data ucsdata;
|
||||
static int session_closed;
|
||||
static int reconfiguring = false;
|
||||
static bool session_closed;
|
||||
static bool reconfiguring = false;
|
||||
|
||||
static const SessionSpecial *specials = NULL;
|
||||
static HMENU specials_menu = NULL;
|
||||
@ -183,11 +184,11 @@ struct agent_callback {
|
||||
#define FONT_SHIFT 5
|
||||
static HFONT fonts[FONT_MAXNO];
|
||||
static LOGFONT lfont;
|
||||
static int fontflag[FONT_MAXNO];
|
||||
static bool fontflag[FONT_MAXNO];
|
||||
static enum {
|
||||
BOLD_NONE, BOLD_SHADOW, BOLD_FONT
|
||||
} bold_font_mode;
|
||||
static int bold_colours;
|
||||
static bool bold_colours;
|
||||
static enum {
|
||||
UND_LINE, UND_FONT
|
||||
} und_mode;
|
||||
@ -210,7 +211,7 @@ static int dbltime, lasttime, lastact;
|
||||
static Mouse_Button lastbtn;
|
||||
|
||||
/* this allows xterm-style mouse handling. */
|
||||
static int send_raw_mouse = 0;
|
||||
static bool send_raw_mouse = false;
|
||||
static int wheel_accumulator = 0;
|
||||
|
||||
static BusyStatus busy_status = BUSY_NOT;
|
||||
@ -227,7 +228,7 @@ static UINT wm_mousewheel = WM_MOUSEWHEEL;
|
||||
(((wch) >= 0x180B && (wch) <= 0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR */ \
|
||||
((wch) >= 0xFE00 && (wch) <= 0xFE0F)) /* VARIATION SELECTOR 1-16 */
|
||||
|
||||
static int wintw_setup_draw_ctx(TermWin *);
|
||||
static bool wintw_setup_draw_ctx(TermWin *);
|
||||
static void wintw_draw_text(TermWin *, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attrs, int lattrs, truecolour tc);
|
||||
static void wintw_draw_cursor(TermWin *, int x, int y, wchar_t *text, int len,
|
||||
@ -235,29 +236,29 @@ static void wintw_draw_cursor(TermWin *, int x, int y, wchar_t *text, int len,
|
||||
static int wintw_char_width(TermWin *, int uc);
|
||||
static void wintw_free_draw_ctx(TermWin *);
|
||||
static void wintw_set_cursor_pos(TermWin *, int x, int y);
|
||||
static void wintw_set_raw_mouse_mode(TermWin *, int enable);
|
||||
static void wintw_set_raw_mouse_mode(TermWin *, bool enable);
|
||||
static void wintw_set_scrollbar(TermWin *, int total, int start, int page);
|
||||
static void wintw_bell(TermWin *, int mode);
|
||||
static void wintw_clip_write(
|
||||
TermWin *, int clipboard, wchar_t *text, int *attrs,
|
||||
truecolour *colours, int len, int must_deselect);
|
||||
truecolour *colours, int len, bool must_deselect);
|
||||
static void wintw_clip_request_paste(TermWin *, int clipboard);
|
||||
static void wintw_refresh(TermWin *);
|
||||
static void wintw_request_resize(TermWin *, int w, int h);
|
||||
static void wintw_set_title(TermWin *, const char *title);
|
||||
static void wintw_set_icon_title(TermWin *, const char *icontitle);
|
||||
static void wintw_set_minimised(TermWin *, int minimised);
|
||||
static int wintw_is_minimised(TermWin *);
|
||||
static void wintw_set_maximised(TermWin *, int maximised);
|
||||
static void wintw_set_minimised(TermWin *, bool minimised);
|
||||
static bool wintw_is_minimised(TermWin *);
|
||||
static void wintw_set_maximised(TermWin *, bool maximised);
|
||||
static void wintw_move(TermWin *, int x, int y);
|
||||
static void wintw_set_zorder(TermWin *, int top);
|
||||
static int wintw_palette_get(TermWin *, int n, int *r, int *g, int *b);
|
||||
static void wintw_set_zorder(TermWin *, bool top);
|
||||
static bool wintw_palette_get(TermWin *, int n, int *r, int *g, int *b);
|
||||
static void wintw_palette_set(TermWin *, int n, int r, int g, int b);
|
||||
static void wintw_palette_reset(TermWin *);
|
||||
static void wintw_get_pos(TermWin *, int *x, int *y);
|
||||
static void wintw_get_pixels(TermWin *, int *x, int *y);
|
||||
static const char *wintw_get_title(TermWin *, int icon);
|
||||
static int wintw_is_utf8(TermWin *);
|
||||
static const char *wintw_get_title(TermWin *, bool icon);
|
||||
static bool wintw_is_utf8(TermWin *);
|
||||
|
||||
static const TermWinVtable windows_termwin_vt = {
|
||||
wintw_setup_draw_ctx,
|
||||
@ -292,20 +293,20 @@ static const TermWinVtable windows_termwin_vt = {
|
||||
static TermWin wintw[1];
|
||||
static HDC wintw_hdc;
|
||||
|
||||
const int share_can_be_downstream = true;
|
||||
const int share_can_be_upstream = true;
|
||||
const bool share_can_be_downstream = true;
|
||||
const bool share_can_be_upstream = true;
|
||||
|
||||
static int is_utf8(void)
|
||||
static bool is_utf8(void)
|
||||
{
|
||||
return ucsdata.line_codepage == CP_UTF8;
|
||||
}
|
||||
|
||||
static int wintw_is_utf8(TermWin *tw)
|
||||
static bool wintw_is_utf8(TermWin *tw)
|
||||
{
|
||||
return is_utf8();
|
||||
}
|
||||
|
||||
static int win_seat_is_utf8(Seat *seat)
|
||||
static bool win_seat_is_utf8(Seat *seat)
|
||||
{
|
||||
return is_utf8();
|
||||
}
|
||||
@ -315,14 +316,14 @@ char *win_seat_get_ttymode(Seat *seat, const char *mode)
|
||||
return term_get_ttymode(term, mode);
|
||||
}
|
||||
|
||||
int win_seat_get_window_pixel_size(Seat *seat, int *x, int *y)
|
||||
bool win_seat_get_window_pixel_size(Seat *seat, int *x, int *y)
|
||||
{
|
||||
win_get_pixels(wintw, x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
static int win_seat_output(Seat *seat, int is_stderr, const void *, int);
|
||||
static int win_seat_eof(Seat *seat);
|
||||
static int win_seat_output(Seat *seat, bool is_stderr, const void *, int);
|
||||
static bool win_seat_eof(Seat *seat);
|
||||
static int win_seat_get_userpass_input(
|
||||
Seat *seat, prompts_t *p, bufchain *input);
|
||||
static void win_seat_notify_remote_exit(Seat *seat);
|
||||
@ -511,7 +512,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
*/
|
||||
{
|
||||
char *p;
|
||||
int special_launchable_argument = false;
|
||||
bool special_launchable_argument = false;
|
||||
|
||||
default_protocol = be_default_protocol;
|
||||
/* Find the appropriate default port. */
|
||||
@ -1006,7 +1007,7 @@ void cleanup_exit(int code)
|
||||
/*
|
||||
* Set up, or shut down, an AsyncSelect. Called from winnet.c.
|
||||
*/
|
||||
char *do_select(SOCKET skt, int startup)
|
||||
char *do_select(SOCKET skt, bool startup)
|
||||
{
|
||||
int msg, events;
|
||||
if (startup) {
|
||||
@ -1122,8 +1123,8 @@ static void win_seat_update_specials_menu(Seat *seat)
|
||||
static void update_mouse_pointer(void)
|
||||
{
|
||||
LPTSTR curstype = NULL;
|
||||
int force_visible = false;
|
||||
static int forced_visible = false;
|
||||
bool force_visible = false;
|
||||
static bool forced_visible = false;
|
||||
switch (busy_status) {
|
||||
case BUSY_NOT:
|
||||
if (send_raw_mouse)
|
||||
@ -1166,7 +1167,7 @@ static void win_seat_set_busy_status(Seat *seat, BusyStatus status)
|
||||
/*
|
||||
* set or clear the "raw mouse message" mode
|
||||
*/
|
||||
static void wintw_set_raw_mouse_mode(TermWin *tw, int activate)
|
||||
static void wintw_set_raw_mouse_mode(TermWin *tw, bool activate)
|
||||
{
|
||||
activate = activate && !conf_get_bool(conf, CONF_no_mouse_rep);
|
||||
send_raw_mouse = activate;
|
||||
@ -1343,7 +1344,7 @@ static void init_palette(void)
|
||||
*/
|
||||
static void exact_textout(HDC hdc, int x, int y, CONST RECT *lprc,
|
||||
unsigned short *lpString, UINT cbCount,
|
||||
CONST INT *lpDx, int opaque)
|
||||
CONST INT *lpDx, bool opaque)
|
||||
{
|
||||
#ifdef __LCC__
|
||||
/*
|
||||
@ -1385,15 +1386,16 @@ static void exact_textout(HDC hdc, int x, int y, CONST RECT *lprc,
|
||||
*/
|
||||
static void general_textout(HDC hdc, int x, int y, CONST RECT *lprc,
|
||||
unsigned short *lpString, UINT cbCount,
|
||||
CONST INT *lpDx, int opaque)
|
||||
CONST INT *lpDx, bool opaque)
|
||||
{
|
||||
int i, j, xp, xn;
|
||||
int bkmode = 0, got_bkmode = false;
|
||||
int bkmode = 0;
|
||||
bool got_bkmode = false;
|
||||
|
||||
xp = xn = x;
|
||||
|
||||
for (i = 0; i < (int)cbCount ;) {
|
||||
int rtl = is_rtl(lpString[i]);
|
||||
bool rtl = is_rtl(lpString[i]);
|
||||
|
||||
xn += lpDx[i];
|
||||
|
||||
@ -1592,7 +1594,8 @@ static void init_fonts(int pick_width, int pick_height)
|
||||
{
|
||||
HDC und_dc;
|
||||
HBITMAP und_bm, und_oldbm;
|
||||
int i, gotit;
|
||||
int i;
|
||||
bool gotit;
|
||||
COLORREF c;
|
||||
|
||||
und_dc = CreateCompatibleDC(hdc);
|
||||
@ -1653,7 +1656,9 @@ static void init_fonts(int pick_width, int pick_height)
|
||||
DeleteObject(fonts[FONT_BOLD]);
|
||||
fonts[FONT_BOLD] = 0;
|
||||
}
|
||||
fontflag[0] = fontflag[1] = fontflag[2] = 1;
|
||||
fontflag[0] = true;
|
||||
fontflag[1] = true;
|
||||
fontflag[2] = true;
|
||||
|
||||
init_ucs(conf, &ucsdata);
|
||||
}
|
||||
@ -1662,7 +1667,8 @@ static void another_font(int fontno)
|
||||
{
|
||||
int basefont;
|
||||
int fw_dontcare, fw_bold, quality;
|
||||
int c, u, w, x;
|
||||
int c, w, x;
|
||||
bool u;
|
||||
char *s;
|
||||
FontSpec *font;
|
||||
|
||||
@ -1708,7 +1714,7 @@ static void another_font(int fontno)
|
||||
CLIP_DEFAULT_PRECIS, FONT_QUALITY(quality),
|
||||
DEFAULT_PITCH | FF_DONTCARE, s);
|
||||
|
||||
fontflag[fontno] = 1;
|
||||
fontflag[fontno] = true;
|
||||
}
|
||||
|
||||
static void deinit_fonts(void)
|
||||
@ -1718,7 +1724,7 @@ static void deinit_fonts(void)
|
||||
if (fonts[i])
|
||||
DeleteObject(fonts[i]);
|
||||
fonts[i] = 0;
|
||||
fontflag[i] = 0;
|
||||
fontflag[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1998,7 +2004,8 @@ static void set_input_locale(HKL kl)
|
||||
kbd_codepage = atoi(lbuf);
|
||||
}
|
||||
|
||||
static void click(Mouse_Button b, int x, int y, int shift, int ctrl, int alt)
|
||||
static void click(Mouse_Button b, int x, int y,
|
||||
bool shift, bool ctrl, bool alt)
|
||||
{
|
||||
int thistime = GetMessageTime();
|
||||
|
||||
@ -2041,13 +2048,13 @@ static Mouse_Button translate_button(Mouse_Button button)
|
||||
return 0; /* shouldn't happen */
|
||||
}
|
||||
|
||||
static void show_mouseptr(int show)
|
||||
static void show_mouseptr(bool show)
|
||||
{
|
||||
/* NB that the counter in ShowCursor() is also frobbed by
|
||||
* update_mouse_pointer() */
|
||||
static int cursor_visible = 1;
|
||||
static bool cursor_visible = true;
|
||||
if (!conf_get_bool(conf, CONF_hide_mouseptr))
|
||||
show = 1; /* override if this feature disabled */
|
||||
show = true; /* override if this feature disabled */
|
||||
if (cursor_visible && !show)
|
||||
ShowCursor(false);
|
||||
else if (!cursor_visible && show)
|
||||
@ -2055,7 +2062,7 @@ static void show_mouseptr(int show)
|
||||
cursor_visible = show;
|
||||
}
|
||||
|
||||
static int is_alt_pressed(void)
|
||||
static bool is_alt_pressed(void)
|
||||
{
|
||||
BYTE keystate[256];
|
||||
int r = GetKeyboardState(keystate);
|
||||
@ -2068,7 +2075,7 @@ static int is_alt_pressed(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
static int resizing;
|
||||
static bool resizing;
|
||||
|
||||
static void win_seat_notify_remote_exit(Seat *seat)
|
||||
{
|
||||
@ -2143,10 +2150,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
static int ignore_clip = false;
|
||||
static int need_backend_resize = false;
|
||||
static int fullscr_on_max = false;
|
||||
static int processed_resize = false;
|
||||
static bool ignore_clip = false;
|
||||
static bool need_backend_resize = false;
|
||||
static bool fullscr_on_max = false;
|
||||
static bool processed_resize = false;
|
||||
static UINT last_mousemove = 0;
|
||||
int resize_action;
|
||||
|
||||
@ -2167,7 +2174,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
case WM_CLOSE:
|
||||
{
|
||||
char *str;
|
||||
show_mouseptr(1);
|
||||
show_mouseptr(true);
|
||||
str = dupprintf("%s Exit Confirmation", appname);
|
||||
if (session_closed || !conf_get_bool(conf, CONF_warn_on_close) ||
|
||||
MessageBox(hwnd,
|
||||
@ -2179,7 +2186,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
}
|
||||
return 0;
|
||||
case WM_DESTROY:
|
||||
show_mouseptr(1);
|
||||
show_mouseptr(true);
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
case WM_INITMENUPOPUP:
|
||||
@ -2205,7 +2212,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
char b[2048];
|
||||
char *cl;
|
||||
const char *argprefix;
|
||||
BOOL inherit_handles;
|
||||
bool inherit_handles;
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
HANDLE filemap = NULL;
|
||||
@ -2295,7 +2302,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
{
|
||||
Conf *prev_conf;
|
||||
int init_lvl = 1;
|
||||
int reconfig_result;
|
||||
bool reconfig_result;
|
||||
|
||||
if (reconfiguring)
|
||||
break;
|
||||
@ -2506,7 +2513,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
* We get this if the System menu has been activated
|
||||
* using the mouse.
|
||||
*/
|
||||
show_mouseptr(1);
|
||||
show_mouseptr(true);
|
||||
break;
|
||||
case SC_KEYMENU:
|
||||
/*
|
||||
@ -2517,7 +2524,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
* the menu up_ rather than just sitting there in
|
||||
* `ready to appear' state.
|
||||
*/
|
||||
show_mouseptr(1); /* make sure pointer is visible */
|
||||
show_mouseptr(true); /* make sure pointer is visible */
|
||||
if( lParam == 0 )
|
||||
PostMessage(hwnd, WM_CHAR, ' ', 0);
|
||||
break;
|
||||
@ -2560,7 +2567,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
(conf_get_int(conf, CONF_mouse_is_xterm) == 2))) {
|
||||
POINT cursorpos;
|
||||
|
||||
show_mouseptr(1); /* make sure pointer is visible */
|
||||
show_mouseptr(true); /* make sure pointer is visible */
|
||||
GetCursorPos(&cursorpos);
|
||||
TrackPopupMenu(popup_menus[CTXMENU].menu,
|
||||
TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON,
|
||||
@ -2569,43 +2576,45 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
break;
|
||||
}
|
||||
{
|
||||
int button, press;
|
||||
int button;
|
||||
bool press;
|
||||
|
||||
switch (message) {
|
||||
case WM_LBUTTONDOWN:
|
||||
button = MBT_LEFT;
|
||||
wParam |= MK_LBUTTON;
|
||||
press = 1;
|
||||
press = true;
|
||||
break;
|
||||
case WM_MBUTTONDOWN:
|
||||
button = MBT_MIDDLE;
|
||||
wParam |= MK_MBUTTON;
|
||||
press = 1;
|
||||
press = true;
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
button = MBT_RIGHT;
|
||||
wParam |= MK_RBUTTON;
|
||||
press = 1;
|
||||
press = true;
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
button = MBT_LEFT;
|
||||
wParam &= ~MK_LBUTTON;
|
||||
press = 0;
|
||||
press = false;
|
||||
break;
|
||||
case WM_MBUTTONUP:
|
||||
button = MBT_MIDDLE;
|
||||
wParam &= ~MK_MBUTTON;
|
||||
press = 0;
|
||||
press = false;
|
||||
break;
|
||||
case WM_RBUTTONUP:
|
||||
button = MBT_RIGHT;
|
||||
wParam &= ~MK_RBUTTON;
|
||||
press = 0;
|
||||
press = false;
|
||||
break;
|
||||
default:
|
||||
button = press = 0; /* shouldn't happen */
|
||||
default: /* shouldn't happen */
|
||||
button = 0;
|
||||
press = false;
|
||||
}
|
||||
show_mouseptr(1);
|
||||
show_mouseptr(true);
|
||||
/*
|
||||
* Special case: in full-screen mode, if the left
|
||||
* button is clicked in the very top left corner of the
|
||||
@ -2613,7 +2622,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
* selection.
|
||||
*/
|
||||
{
|
||||
char mouse_on_hotspot = 0;
|
||||
bool mouse_on_hotspot = false;
|
||||
POINT pt;
|
||||
|
||||
GetCursorPos(&pt);
|
||||
@ -2630,13 +2639,13 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
|
||||
if (mi.rcMonitor.left == pt.x &&
|
||||
mi.rcMonitor.top == pt.y) {
|
||||
mouse_on_hotspot = 1;
|
||||
mouse_on_hotspot = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (pt.x == 0 && pt.y == 0) {
|
||||
mouse_on_hotspot = 1;
|
||||
mouse_on_hotspot = true;
|
||||
}
|
||||
#endif
|
||||
if (is_full_screen() && press &&
|
||||
@ -2674,7 +2683,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
static LPARAM lp = 0;
|
||||
if (wParam != wp || lParam != lp ||
|
||||
last_mousemove != WM_MOUSEMOVE) {
|
||||
show_mouseptr(1);
|
||||
show_mouseptr(true);
|
||||
wp = wParam; lp = lParam;
|
||||
last_mousemove = WM_MOUSEMOVE;
|
||||
}
|
||||
@ -2706,7 +2715,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
static LPARAM lp = 0;
|
||||
if (wParam != wp || lParam != lp ||
|
||||
last_mousemove != WM_NCMOUSEMOVE) {
|
||||
show_mouseptr(1);
|
||||
show_mouseptr(true);
|
||||
wp = wParam; lp = lParam;
|
||||
last_mousemove = WM_NCMOUSEMOVE;
|
||||
}
|
||||
@ -2846,7 +2855,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
term_update(term);
|
||||
break;
|
||||
case WM_KILLFOCUS:
|
||||
show_mouseptr(1);
|
||||
show_mouseptr(true);
|
||||
term_set_focus(term, false);
|
||||
DestroyCaret();
|
||||
caret_x = caret_y = -1; /* ensure caret is replaced next time */
|
||||
@ -2856,12 +2865,12 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
#ifdef RDB_DEBUG_PATCH
|
||||
debug((27, "WM_ENTERSIZEMOVE"));
|
||||
#endif
|
||||
EnableSizeTip(1);
|
||||
EnableSizeTip(true);
|
||||
resizing = true;
|
||||
need_backend_resize = false;
|
||||
break;
|
||||
case WM_EXITSIZEMOVE:
|
||||
EnableSizeTip(0);
|
||||
EnableSizeTip(false);
|
||||
resizing = false;
|
||||
#ifdef RDB_DEBUG_PATCH
|
||||
debug((27, "WM_EXITSIZEMOVE"));
|
||||
@ -3031,7 +3040,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
height = HIWORD(lParam);
|
||||
|
||||
if (wParam == SIZE_MAXIMIZED && !was_zoomed) {
|
||||
was_zoomed = 1;
|
||||
was_zoomed = true;
|
||||
prev_rows = term->rows;
|
||||
prev_cols = term->cols;
|
||||
if (resize_action == RESIZE_TERM) {
|
||||
@ -3058,7 +3067,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
}
|
||||
reset_window(0);
|
||||
} else if (wParam == SIZE_RESTORED && was_zoomed) {
|
||||
was_zoomed = 0;
|
||||
was_zoomed = false;
|
||||
if (resize_action == RESIZE_TERM) {
|
||||
w = (width-window_border*2) / font_width;
|
||||
if (w < 1) w = 1;
|
||||
@ -3205,8 +3214,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
*/
|
||||
term_seen_key_event(term);
|
||||
if (ldisc)
|
||||
ldisc_send(ldisc, buf, len, 1);
|
||||
show_mouseptr(0);
|
||||
ldisc_send(ldisc, buf, len, true);
|
||||
show_mouseptr(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3258,12 +3267,13 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
if (IS_HIGH_SURROGATE(hs) && i+2 < n) {
|
||||
WCHAR ls = *(unsigned short *)(buff+i+2);
|
||||
if (IS_LOW_SURROGATE(ls)) {
|
||||
luni_send(ldisc, (unsigned short *)(buff+i), 2, 1);
|
||||
luni_send(ldisc, (unsigned short *)(buff+i),
|
||||
2, true);
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
luni_send(ldisc, (unsigned short *)(buff+i), 1, 1);
|
||||
luni_send(ldisc, (unsigned short *)(buff+i), 1, true);
|
||||
}
|
||||
}
|
||||
free(buff);
|
||||
@ -3280,12 +3290,12 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
buf[0] = wParam >> 8;
|
||||
term_seen_key_event(term);
|
||||
if (ldisc)
|
||||
lpage_send(ldisc, kbd_codepage, buf, 2, 1);
|
||||
lpage_send(ldisc, kbd_codepage, buf, 2, true);
|
||||
} else {
|
||||
char c = (unsigned char) wParam;
|
||||
term_seen_key_event(term);
|
||||
if (ldisc)
|
||||
lpage_send(ldisc, kbd_codepage, &c, 1, 1);
|
||||
lpage_send(ldisc, kbd_codepage, &c, 1, true);
|
||||
}
|
||||
return (0);
|
||||
case WM_CHAR:
|
||||
@ -3307,10 +3317,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
pair[0] = pending_surrogate;
|
||||
pair[1] = c;
|
||||
term_seen_key_event(term);
|
||||
luni_send(ldisc, pair, 2, 1);
|
||||
luni_send(ldisc, pair, 2, true);
|
||||
} else if (!IS_SURROGATE(c)) {
|
||||
term_seen_key_event(term);
|
||||
luni_send(ldisc, &c, 1, 1);
|
||||
luni_send(ldisc, &c, 1, true);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -3336,7 +3346,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
return 0;
|
||||
default:
|
||||
if (message == wm_mousewheel || message == WM_MOUSEWHEEL) {
|
||||
int shift_pressed=0, control_pressed=0;
|
||||
bool shift_pressed = false, control_pressed = false;
|
||||
|
||||
if (message == WM_MOUSEWHEEL) {
|
||||
wheel_accumulator += (short)HIWORD(wParam);
|
||||
@ -3465,12 +3475,13 @@ static void do_text_internal(
|
||||
COLORREF fg, bg, t;
|
||||
int nfg, nbg, nfont;
|
||||
RECT line_box;
|
||||
int force_manual_underline = 0;
|
||||
bool force_manual_underline = false;
|
||||
int fnt_width, char_width;
|
||||
int text_adjust = 0;
|
||||
int xoffset = 0;
|
||||
int maxlen, remaining, opaque;
|
||||
int is_cursor = false;
|
||||
int maxlen, remaining;
|
||||
bool opaque;
|
||||
bool is_cursor = false;
|
||||
static int *lpDx = NULL;
|
||||
static int lpDx_len = 0;
|
||||
int *lpDx_maybe;
|
||||
@ -3540,7 +3551,7 @@ static void do_text_internal(
|
||||
text[0] = ucsdata.unitab_xterm['q'];
|
||||
if (attr & ATTR_UNDER) {
|
||||
attr &= ~ATTR_UNDER;
|
||||
force_manual_underline = 1;
|
||||
force_manual_underline = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -3566,7 +3577,7 @@ static void do_text_internal(
|
||||
another_font(nfont);
|
||||
if (!fonts[nfont]) {
|
||||
if (nfont & FONT_UNDERLINE)
|
||||
force_manual_underline = 1;
|
||||
force_manual_underline = true;
|
||||
/* Don't do the same for manual bold, it could be bad news. */
|
||||
|
||||
nfont &= ~(FONT_BOLD | FONT_UNDERLINE);
|
||||
@ -4056,7 +4067,8 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
unsigned char *output)
|
||||
{
|
||||
BYTE keystate[256];
|
||||
int scan, left_alt = 0, key_down, shift_state;
|
||||
int scan, shift_state;
|
||||
bool left_alt = false, key_down;
|
||||
int r, i, code;
|
||||
unsigned char *p = output;
|
||||
static int alt_sum = 0;
|
||||
@ -4178,7 +4190,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
return 0;
|
||||
|
||||
if ((HIWORD(lParam) & KF_ALTDOWN) && (keystate[VK_RMENU] & 0x80) == 0)
|
||||
left_alt = 1;
|
||||
left_alt = true;
|
||||
|
||||
key_down = ((HIWORD(lParam) & KF_UP) == 0);
|
||||
|
||||
@ -4188,7 +4200,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
keystate[VK_MENU] = 0;
|
||||
else {
|
||||
keystate[VK_RMENU] = 0x80;
|
||||
left_alt = 0;
|
||||
left_alt = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4373,7 +4385,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
}
|
||||
/* Control-Numlock for app-keypad mode switch */
|
||||
if (wParam == VK_PAUSE && shift_state == 2) {
|
||||
term->app_keypad_keys ^= 1;
|
||||
term->app_keypad_keys = !term->app_keypad_keys;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4782,7 +4794,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
/* Okay we've done everything interesting; let windows deal with
|
||||
* the boring stuff */
|
||||
{
|
||||
BOOL capsOn=0;
|
||||
bool capsOn = false;
|
||||
|
||||
/* helg: clear CAPS LOCK state if caps lock switches to cyrillic */
|
||||
if(keystate[VK_CAPITAL] != 0 &&
|
||||
@ -4862,7 +4874,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
keybuf = nc;
|
||||
term_seen_key_event(term);
|
||||
if (ldisc)
|
||||
luni_send(ldisc, &keybuf, 1, 1);
|
||||
luni_send(ldisc, &keybuf, 1, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -4874,7 +4886,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
keybuf = alt_sum;
|
||||
term_seen_key_event(term);
|
||||
if (ldisc)
|
||||
luni_send(ldisc, &keybuf, 1, 1);
|
||||
luni_send(ldisc, &keybuf, 1, true);
|
||||
} else {
|
||||
char ch = (char) alt_sum;
|
||||
/*
|
||||
@ -4888,13 +4900,13 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
*/
|
||||
term_seen_key_event(term);
|
||||
if (ldisc)
|
||||
ldisc_send(ldisc, &ch, 1, 1);
|
||||
ldisc_send(ldisc, &ch, 1, true);
|
||||
}
|
||||
alt_sum = 0;
|
||||
} else {
|
||||
term_seen_key_event(term);
|
||||
if (ldisc)
|
||||
luni_send(ldisc, &wch, 1, 1);
|
||||
luni_send(ldisc, &wch, 1, true);
|
||||
}
|
||||
} else {
|
||||
if(capsOn && wch < 0x80) {
|
||||
@ -4903,17 +4915,19 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
cbuf[1] = xlat_uskbd2cyrllic(wch);
|
||||
term_seen_key_event(term);
|
||||
if (ldisc)
|
||||
luni_send(ldisc, cbuf+!left_alt, 1+!!left_alt, 1);
|
||||
luni_send(ldisc, cbuf+!left_alt, 1+!!left_alt,
|
||||
true);
|
||||
} else {
|
||||
WCHAR cbuf[2];
|
||||
cbuf[0] = '\033';
|
||||
cbuf[1] = wch;
|
||||
term_seen_key_event(term);
|
||||
if (ldisc)
|
||||
luni_send(ldisc, cbuf +!left_alt, 1+!!left_alt, 1);
|
||||
luni_send(ldisc, cbuf +!left_alt, 1+!!left_alt,
|
||||
true);
|
||||
}
|
||||
}
|
||||
show_mouseptr(0);
|
||||
show_mouseptr(false);
|
||||
}
|
||||
|
||||
/* This is so the ALT-Numpad and dead keys work correctly. */
|
||||
@ -4978,7 +4992,7 @@ static void wintw_set_scrollbar(TermWin *tw, int total, int start, int page)
|
||||
SetScrollInfo(hwnd, SB_VERT, &si, true);
|
||||
}
|
||||
|
||||
static int wintw_setup_draw_ctx(TermWin *tw)
|
||||
static bool wintw_setup_draw_ctx(TermWin *tw)
|
||||
{
|
||||
assert(!wintw_hdc);
|
||||
wintw_hdc = make_hdc();
|
||||
@ -5004,7 +5018,7 @@ static void real_palette_set(int n, int r, int g, int b)
|
||||
}
|
||||
}
|
||||
|
||||
static int wintw_palette_get(TermWin *tw, int n, int *r, int *g, int *b)
|
||||
static bool wintw_palette_get(TermWin *tw, int n, int *r, int *g, int *b)
|
||||
{
|
||||
if (n < 0 || n >= NALLCOLOURS)
|
||||
return false;
|
||||
@ -5064,7 +5078,7 @@ static void wintw_palette_reset(TermWin *tw)
|
||||
}
|
||||
}
|
||||
|
||||
void write_aclip(int clipboard, char *data, int len, int must_deselect)
|
||||
void write_aclip(int clipboard, char *data, int len, bool must_deselect)
|
||||
{
|
||||
HGLOBAL clipdata;
|
||||
void *lock;
|
||||
@ -5113,7 +5127,7 @@ int cmpCOLORREF(void *va, void *vb)
|
||||
*/
|
||||
static void wintw_clip_write(
|
||||
TermWin *tw, int clipboard, wchar_t *data, int *attr,
|
||||
truecolour *truecolour, int len, int must_deselect)
|
||||
truecolour *truecolour, int len, bool must_deselect)
|
||||
{
|
||||
HGLOBAL clipdata, clipdata2, clipdata3;
|
||||
int len2;
|
||||
@ -5536,9 +5550,11 @@ static DWORD WINAPI clipboard_read_threadfunc(void *param)
|
||||
|
||||
if (OpenClipboard(NULL)) {
|
||||
if ((clipdata = GetClipboardData(CF_UNICODETEXT))) {
|
||||
SendMessage(hwnd, WM_GOT_CLIPDATA, (WPARAM)1, (LPARAM)clipdata);
|
||||
SendMessage(hwnd, WM_GOT_CLIPDATA,
|
||||
(WPARAM)true, (LPARAM)clipdata);
|
||||
} else if ((clipdata = GetClipboardData(CF_TEXT))) {
|
||||
SendMessage(hwnd, WM_GOT_CLIPDATA, (WPARAM)0, (LPARAM)clipdata);
|
||||
SendMessage(hwnd, WM_GOT_CLIPDATA,
|
||||
(WPARAM)false, (LPARAM)clipdata);
|
||||
}
|
||||
CloseClipboard();
|
||||
}
|
||||
@ -5546,7 +5562,7 @@ static DWORD WINAPI clipboard_read_threadfunc(void *param)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void process_clipdata(HGLOBAL clipdata, int unicode)
|
||||
static void process_clipdata(HGLOBAL clipdata, bool unicode)
|
||||
{
|
||||
wchar_t *clipboard_contents = NULL;
|
||||
size_t clipboard_length = 0;
|
||||
@ -5641,7 +5657,7 @@ void nonfatal(const char *fmt, ...)
|
||||
sfree(stuff);
|
||||
}
|
||||
|
||||
static BOOL flash_window_ex(DWORD dwFlags, UINT uCount, DWORD dwTimeout)
|
||||
static bool flash_window_ex(DWORD dwFlags, UINT uCount, DWORD dwTimeout)
|
||||
{
|
||||
if (p_FlashWindowEx) {
|
||||
FLASHWINFO fi;
|
||||
@ -5658,7 +5674,7 @@ static BOOL flash_window_ex(DWORD dwFlags, UINT uCount, DWORD dwTimeout)
|
||||
|
||||
static void flash_window(int mode);
|
||||
static long next_flash;
|
||||
static int flashing = 0;
|
||||
static bool flashing = false;
|
||||
|
||||
/*
|
||||
* Timer for platforms where we must maintain window flashing manually
|
||||
@ -5681,7 +5697,7 @@ static void flash_window(int mode)
|
||||
if ((mode == 0) || (beep_ind == B_IND_DISABLED)) {
|
||||
/* stop */
|
||||
if (flashing) {
|
||||
flashing = 0;
|
||||
flashing = false;
|
||||
if (p_FlashWindowEx)
|
||||
flash_window_ex(FLASHW_STOP, 0, 0);
|
||||
else
|
||||
@ -5691,7 +5707,7 @@ static void flash_window(int mode)
|
||||
} else if (mode == 2) {
|
||||
/* start */
|
||||
if (!flashing) {
|
||||
flashing = 1;
|
||||
flashing = true;
|
||||
if (p_FlashWindowEx) {
|
||||
/* For so-called "steady" mode, we use uCount=2, which
|
||||
* seems to be the traditional number of flashes used
|
||||
@ -5783,7 +5799,7 @@ static void wintw_bell(TermWin *tw, int mode)
|
||||
* Minimise or restore the window in response to a server-side
|
||||
* request.
|
||||
*/
|
||||
static void wintw_set_minimised(TermWin *tw, int minimised)
|
||||
static void wintw_set_minimised(TermWin *tw, bool minimised)
|
||||
{
|
||||
if (IsIconic(hwnd)) {
|
||||
if (!minimised)
|
||||
@ -5812,7 +5828,7 @@ static void wintw_move(TermWin *tw, int x, int y)
|
||||
* Move the window to the top or bottom of the z-order in response
|
||||
* to a server-side request.
|
||||
*/
|
||||
static void wintw_set_zorder(TermWin *tw, int top)
|
||||
static void wintw_set_zorder(TermWin *tw, bool top)
|
||||
{
|
||||
if (conf_get_bool(conf, CONF_alwaysontop))
|
||||
return; /* ignore */
|
||||
@ -5832,7 +5848,7 @@ static void wintw_refresh(TermWin *tw)
|
||||
* Maximise or restore the window in response to a server-side
|
||||
* request.
|
||||
*/
|
||||
static void wintw_set_maximised(TermWin *tw, int maximised)
|
||||
static void wintw_set_maximised(TermWin *tw, bool maximised)
|
||||
{
|
||||
if (IsZoomed(hwnd)) {
|
||||
if (!maximised)
|
||||
@ -5846,7 +5862,7 @@ static void wintw_set_maximised(TermWin *tw, int maximised)
|
||||
/*
|
||||
* Report whether the window is iconic, for terminal reports.
|
||||
*/
|
||||
static int wintw_is_minimised(TermWin *tw)
|
||||
static bool wintw_is_minimised(TermWin *tw)
|
||||
{
|
||||
return IsIconic(hwnd);
|
||||
}
|
||||
@ -5876,7 +5892,7 @@ static void wintw_get_pixels(TermWin *tw, int *x, int *y)
|
||||
/*
|
||||
* Return the window or icon title.
|
||||
*/
|
||||
static const char *wintw_get_title(TermWin *tw, int icon)
|
||||
static const char *wintw_get_title(TermWin *tw, bool icon)
|
||||
{
|
||||
return icon ? icon_name : window_name;
|
||||
}
|
||||
@ -5884,7 +5900,7 @@ static const char *wintw_get_title(TermWin *tw, int icon)
|
||||
/*
|
||||
* See if we're in full-screen mode.
|
||||
*/
|
||||
static int is_full_screen()
|
||||
static bool is_full_screen()
|
||||
{
|
||||
if (!IsZoomed(hwnd))
|
||||
return false;
|
||||
@ -5896,7 +5912,7 @@ static int is_full_screen()
|
||||
/* Get the rect/size of a full screen window using the nearest available
|
||||
* monitor in multimon systems; default to something sensible if only
|
||||
* one monitor is present. */
|
||||
static int get_fullscreen_rect(RECT * ss)
|
||||
static bool get_fullscreen_rect(RECT * ss)
|
||||
{
|
||||
#if defined(MONITOR_DEFAULTTONEAREST) && !defined(NO_MULTIMON)
|
||||
HMONITOR mon;
|
||||
@ -6009,13 +6025,13 @@ static void flip_full_screen()
|
||||
}
|
||||
}
|
||||
|
||||
static int win_seat_output(Seat *seat, int is_stderr,
|
||||
static int win_seat_output(Seat *seat, bool is_stderr,
|
||||
const void *data, int len)
|
||||
{
|
||||
return term_data(term, is_stderr, data, len);
|
||||
}
|
||||
|
||||
static int win_seat_eof(Seat *seat)
|
||||
static bool win_seat_eof(Seat *seat)
|
||||
{
|
||||
return true; /* do respond to incoming EOF with outgoing */
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ struct handle_generic {
|
||||
HANDLE h; /* the handle itself */
|
||||
HANDLE ev_to_main; /* event used to signal main thread */
|
||||
HANDLE ev_from_main; /* event used to signal back to us */
|
||||
int moribund; /* are we going to kill this soon? */
|
||||
int done; /* request subthread to terminate */
|
||||
int defunct; /* has the subthread already gone? */
|
||||
int busy; /* operation currently in progress? */
|
||||
bool moribund; /* are we going to kill this soon? */
|
||||
bool done; /* request subthread to terminate */
|
||||
bool defunct; /* has the subthread already gone? */
|
||||
bool busy; /* operation currently in progress? */
|
||||
void *privdata; /* for client to remember who they are */
|
||||
};
|
||||
|
||||
@ -81,10 +81,10 @@ struct handle_input {
|
||||
HANDLE h; /* the handle itself */
|
||||
HANDLE ev_to_main; /* event used to signal main thread */
|
||||
HANDLE ev_from_main; /* event used to signal back to us */
|
||||
int moribund; /* are we going to kill this soon? */
|
||||
int done; /* request subthread to terminate */
|
||||
int defunct; /* has the subthread already gone? */
|
||||
int busy; /* operation currently in progress? */
|
||||
bool moribund; /* are we going to kill this soon? */
|
||||
bool done; /* request subthread to terminate */
|
||||
bool defunct; /* has the subthread already gone? */
|
||||
bool busy; /* operation currently in progress? */
|
||||
void *privdata; /* for client to remember who they are */
|
||||
|
||||
/*
|
||||
@ -115,7 +115,8 @@ static DWORD WINAPI handle_input_threadfunc(void *param)
|
||||
struct handle_input *ctx = (struct handle_input *) param;
|
||||
OVERLAPPED ovl, *povl;
|
||||
HANDLE oev;
|
||||
int readret, readlen, finished;
|
||||
bool readret, finished;
|
||||
int readlen;
|
||||
|
||||
if (ctx->flags & HANDLE_FLAG_OVERLAPPED) {
|
||||
povl = &ovl;
|
||||
@ -241,10 +242,10 @@ struct handle_output {
|
||||
HANDLE h; /* the handle itself */
|
||||
HANDLE ev_to_main; /* event used to signal main thread */
|
||||
HANDLE ev_from_main; /* event used to signal back to us */
|
||||
int moribund; /* are we going to kill this soon? */
|
||||
int done; /* request subthread to terminate */
|
||||
int defunct; /* has the subthread already gone? */
|
||||
int busy; /* operation currently in progress? */
|
||||
bool moribund; /* are we going to kill this soon? */
|
||||
bool done; /* request subthread to terminate */
|
||||
bool defunct; /* has the subthread already gone? */
|
||||
bool busy; /* operation currently in progress? */
|
||||
void *privdata; /* for client to remember who they are */
|
||||
|
||||
/*
|
||||
@ -284,7 +285,7 @@ static DWORD WINAPI handle_output_threadfunc(void *param)
|
||||
struct handle_output *ctx = (struct handle_output *) param;
|
||||
OVERLAPPED ovl, *povl;
|
||||
HANDLE oev;
|
||||
int writeret;
|
||||
bool writeret;
|
||||
|
||||
if (ctx->flags & HANDLE_FLAG_OVERLAPPED) {
|
||||
povl = &ovl;
|
||||
@ -377,10 +378,10 @@ struct handle_foreign {
|
||||
HANDLE h; /* the handle itself */
|
||||
HANDLE ev_to_main; /* event used to signal main thread */
|
||||
HANDLE ev_from_main; /* event used to signal back to us */
|
||||
int moribund; /* are we going to kill this soon? */
|
||||
int done; /* request subthread to terminate */
|
||||
int defunct; /* has the subthread already gone? */
|
||||
int busy; /* operation currently in progress? */
|
||||
bool moribund; /* are we going to kill this soon? */
|
||||
bool done; /* request subthread to terminate */
|
||||
bool defunct; /* has the subthread already gone? */
|
||||
bool busy; /* operation currently in progress? */
|
||||
void *privdata; /* for client to remember who they are */
|
||||
|
||||
/*
|
||||
|
@ -15,9 +15,9 @@
|
||||
#include <htmlhelp.h>
|
||||
#endif /* NO_HTMLHELP */
|
||||
|
||||
static int requested_help;
|
||||
static bool requested_help;
|
||||
static char *help_path;
|
||||
static int help_has_contents;
|
||||
static bool help_has_contents;
|
||||
#ifndef NO_HTMLHELP
|
||||
DECL_WINDOWS_FUNCTION(static, HWND, HtmlHelpA, (HWND, LPCSTR, UINT, DWORD_PTR));
|
||||
static char *chm_path;
|
||||
@ -74,7 +74,7 @@ void shutdown_help(void)
|
||||
* call HH_UNINITIALIZE.) */
|
||||
}
|
||||
|
||||
int has_help(void)
|
||||
bool has_help(void)
|
||||
{
|
||||
/*
|
||||
* FIXME: it would be nice here to disregard help_path on
|
||||
|
@ -36,7 +36,7 @@ typedef struct HandleSocket {
|
||||
/* Data received from stderr_H, if we have one. */
|
||||
bufchain stderrdata;
|
||||
|
||||
int defer_close, deferred_close; /* in case of re-entrance */
|
||||
bool defer_close, deferred_close; /* in case of re-entrance */
|
||||
|
||||
char *error;
|
||||
|
||||
@ -209,7 +209,7 @@ static void handle_socket_unfreeze(void *hsv)
|
||||
}
|
||||
}
|
||||
|
||||
static void sk_handle_set_frozen(Socket *s, int is_frozen)
|
||||
static void sk_handle_set_frozen(Socket *s, bool is_frozen)
|
||||
{
|
||||
HandleSocket *hs = container_of(s, HandleSocket, sock);
|
||||
|
||||
@ -324,7 +324,7 @@ static const SocketVtable HandleSocket_sockvt = {
|
||||
};
|
||||
|
||||
Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
|
||||
Plug *plug, int overlapped)
|
||||
Plug *plug, bool overlapped)
|
||||
{
|
||||
HandleSocket *hs;
|
||||
int flags = (overlapped ? HANDLE_FLAG_OVERLAPPED : 0);
|
||||
|
@ -492,7 +492,7 @@ static void update_jumplist_from_registry(void)
|
||||
IObjectArray *array = NULL;
|
||||
IShellLink *link = NULL;
|
||||
IObjectArray *pRemoved = NULL;
|
||||
int need_abort = false;
|
||||
bool need_abort = false;
|
||||
|
||||
/*
|
||||
* Create an ICustomDestinationList: the top-level object which
|
||||
@ -538,7 +538,7 @@ static void update_jumplist_from_registry(void)
|
||||
link = make_shell_link(NULL, piterator);
|
||||
if (link) {
|
||||
UINT i;
|
||||
int found;
|
||||
bool found;
|
||||
|
||||
/*
|
||||
* Check that the link isn't in the user-removed list.
|
||||
@ -715,7 +715,7 @@ void remove_session_from_jumplist(const char * const sessionname)
|
||||
/* Set Explicit App User Model Id to fix removable media error with
|
||||
jump lists */
|
||||
|
||||
BOOL set_explicit_app_user_model_id()
|
||||
bool set_explicit_app_user_model_id()
|
||||
{
|
||||
DECL_WINDOWS_FUNCTION(static, HRESULT, SetCurrentProcessExplicitAppUserModelID,
|
||||
(PCWSTR));
|
||||
|
@ -35,12 +35,12 @@ const char *filename_to_str(const Filename *fn)
|
||||
return fn->path;
|
||||
}
|
||||
|
||||
int filename_equal(const Filename *f1, const Filename *f2)
|
||||
bool filename_equal(const Filename *f1, const Filename *f2)
|
||||
{
|
||||
return !strcmp(f1->path, f2->path);
|
||||
}
|
||||
|
||||
int filename_is_null(const Filename *fn)
|
||||
bool filename_is_null(const Filename *fn)
|
||||
{
|
||||
return !*fn->path;
|
||||
}
|
||||
@ -81,12 +81,12 @@ char *get_username(void)
|
||||
{
|
||||
DWORD namelen;
|
||||
char *user;
|
||||
int got_username = false;
|
||||
bool got_username = false;
|
||||
DECL_WINDOWS_FUNCTION(static, BOOLEAN, GetUserNameExA,
|
||||
(EXTENDED_NAME_FORMAT, LPSTR, PULONG));
|
||||
|
||||
{
|
||||
static int tried_usernameex = false;
|
||||
static bool tried_usernameex = false;
|
||||
if (!tried_usernameex) {
|
||||
/* Not available on Win9x, so load dynamically */
|
||||
HMODULE secur32 = load_system32_dll("secur32.dll");
|
||||
@ -125,7 +125,7 @@ char *get_username(void)
|
||||
if (!got_username) {
|
||||
/* Fall back to local user name */
|
||||
namelen = 0;
|
||||
if (GetUserName(NULL, &namelen) == false) {
|
||||
if (!GetUserName(NULL, &namelen)) {
|
||||
/*
|
||||
* Apparently this doesn't work at least on Windows XP SP2.
|
||||
* Thus assume a maximum of 256. It will fail again if it
|
||||
@ -559,8 +559,7 @@ void *minefield_c_realloc(void *p, size_t size)
|
||||
|
||||
#endif /* MINEFIELD */
|
||||
|
||||
FontSpec *fontspec_new(const char *name,
|
||||
int bold, int height, int charset)
|
||||
FontSpec *fontspec_new(const char *name, bool bold, int height, int charset)
|
||||
{
|
||||
FontSpec *f = snew(FontSpec);
|
||||
f->name = dupstr(name);
|
||||
@ -594,7 +593,7 @@ FontSpec *fontspec_deserialise(BinarySource *src)
|
||||
return fontspec_new(name, isbold, height, charset);
|
||||
}
|
||||
|
||||
int open_for_write_would_lose_data(const Filename *fn)
|
||||
bool open_for_write_would_lose_data(const Filename *fn)
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA attrs;
|
||||
if (!GetFileAttributesEx(fn->path, GetFileExInfoStandard, &attrs)) {
|
||||
|
131
windows/winnet.c
131
windows/winnet.c
@ -53,20 +53,20 @@ struct NetSocket {
|
||||
SOCKET s;
|
||||
Plug *plug;
|
||||
bufchain output_data;
|
||||
int connected;
|
||||
int writable;
|
||||
int frozen; /* this causes readability notifications to be ignored */
|
||||
int frozen_readable; /* this means we missed at least one readability
|
||||
* notification while we were frozen */
|
||||
int localhost_only; /* for listening sockets */
|
||||
bool connected;
|
||||
bool writable;
|
||||
bool frozen; /* this causes readability notifications to be ignored */
|
||||
bool frozen_readable; /* this means we missed at least one readability
|
||||
* notification while we were frozen */
|
||||
bool localhost_only; /* for listening sockets */
|
||||
char oobdata[1];
|
||||
int sending_oob;
|
||||
int oobinline, nodelay, keepalive, privport;
|
||||
bool oobinline, nodelay, keepalive, privport;
|
||||
enum { EOF_NO, EOF_PENDING, EOF_SENT } outgoingeof;
|
||||
SockAddr *addr;
|
||||
SockAddrStep step;
|
||||
int port;
|
||||
int pending_error; /* in case send() returns error */
|
||||
int pending_error; /* in case send() returns error */
|
||||
/*
|
||||
* We sometimes need pairs of Socket structures to be linked:
|
||||
* if we are listening on the same IPv6 and v4 port, for
|
||||
@ -81,9 +81,9 @@ struct NetSocket {
|
||||
struct SockAddr {
|
||||
int refcount;
|
||||
char *error;
|
||||
int resolved;
|
||||
int namedpipe; /* indicates that this SockAddr is phony, holding a Windows
|
||||
* named pipe pathname instead of a network address */
|
||||
bool resolved;
|
||||
bool namedpipe; /* indicates that this SockAddr is phony, holding a Windows
|
||||
* named pipe pathname instead of a network address */
|
||||
#ifndef NO_IPV6
|
||||
struct addrinfo *ais; /* Addresses IPv6 style. */
|
||||
#endif
|
||||
@ -206,7 +206,7 @@ static HMODULE winsock2_module = NULL;
|
||||
static HMODULE wship6_module = NULL;
|
||||
#endif
|
||||
|
||||
int sk_startup(int hi, int lo)
|
||||
bool sk_startup(int hi, int lo)
|
||||
{
|
||||
WORD winsock_ver;
|
||||
|
||||
@ -657,7 +657,7 @@ SockAddr *sk_namedpipe_addr(const char *pipename)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sk_nextaddr(SockAddr *addr, SockAddrStep *step)
|
||||
bool sk_nextaddr(SockAddr *addr, SockAddrStep *step)
|
||||
{
|
||||
#ifndef NO_IPV6
|
||||
if (step->ai) {
|
||||
@ -739,12 +739,12 @@ static SockAddr sk_extractaddr_tmp(
|
||||
return toret;
|
||||
}
|
||||
|
||||
int sk_addr_needs_port(SockAddr *addr)
|
||||
bool sk_addr_needs_port(SockAddr *addr)
|
||||
{
|
||||
return addr->namedpipe ? false : true;
|
||||
return !addr->namedpipe;
|
||||
}
|
||||
|
||||
int sk_hostname_is_local(const char *name)
|
||||
bool sk_hostname_is_local(const char *name)
|
||||
{
|
||||
return !strcmp(name, "localhost") ||
|
||||
!strcmp(name, "::1") ||
|
||||
@ -754,10 +754,10 @@ int sk_hostname_is_local(const char *name)
|
||||
static INTERFACE_INFO local_interfaces[16];
|
||||
static int n_local_interfaces; /* 0=not yet, -1=failed, >0=number */
|
||||
|
||||
static int ipv4_is_local_addr(struct in_addr addr)
|
||||
static bool ipv4_is_local_addr(struct in_addr addr)
|
||||
{
|
||||
if (ipv4_is_loopback(addr))
|
||||
return 1; /* loopback addresses are local */
|
||||
return true; /* loopback addresses are local */
|
||||
if (!n_local_interfaces) {
|
||||
SOCKET s = p_socket(AF_INET, SOCK_DGRAM, 0);
|
||||
DWORD retbytes;
|
||||
@ -778,13 +778,13 @@ static int ipv4_is_local_addr(struct in_addr addr)
|
||||
SOCKADDR_IN *address =
|
||||
(SOCKADDR_IN *)&local_interfaces[i].iiAddress;
|
||||
if (address->sin_addr.s_addr == addr.s_addr)
|
||||
return 1; /* this address is local */
|
||||
return true; /* this address is local */
|
||||
}
|
||||
}
|
||||
return 0; /* this address is not local */
|
||||
return false; /* this address is not local */
|
||||
}
|
||||
|
||||
int sk_address_is_local(SockAddr *addr)
|
||||
bool sk_address_is_local(SockAddr *addr)
|
||||
{
|
||||
SockAddrStep step;
|
||||
int family;
|
||||
@ -811,13 +811,13 @@ int sk_address_is_local(SockAddr *addr)
|
||||
}
|
||||
} else {
|
||||
assert(family == AF_UNSPEC);
|
||||
return 0; /* we don't know; assume not */
|
||||
return false; /* we don't know; assume not */
|
||||
}
|
||||
}
|
||||
|
||||
int sk_address_is_special_local(SockAddr *addr)
|
||||
bool sk_address_is_special_local(SockAddr *addr)
|
||||
{
|
||||
return 0; /* no Unix-domain socket analogue here */
|
||||
return false; /* no Unix-domain socket analogue here */
|
||||
}
|
||||
|
||||
int sk_addrtype(SockAddr *addr)
|
||||
@ -902,11 +902,11 @@ static void sk_net_close(Socket *s);
|
||||
static int sk_net_write(Socket *s, const void *data, int len);
|
||||
static int sk_net_write_oob(Socket *s, const void *data, int len);
|
||||
static void sk_net_write_eof(Socket *s);
|
||||
static void sk_net_set_frozen(Socket *s, int is_frozen);
|
||||
static void sk_net_set_frozen(Socket *s, bool is_frozen);
|
||||
static const char *sk_net_socket_error(Socket *s);
|
||||
static SocketPeerInfo *sk_net_peer_info(Socket *s);
|
||||
|
||||
extern char *do_select(SOCKET skt, int startup);
|
||||
extern char *do_select(SOCKET skt, bool startup);
|
||||
|
||||
static const SocketVtable NetSocket_sockvt = {
|
||||
sk_net_plug,
|
||||
@ -934,12 +934,12 @@ static Socket *sk_net_accept(accept_ctx_t ctx, Plug *plug)
|
||||
ret->error = NULL;
|
||||
ret->plug = plug;
|
||||
bufchain_init(&ret->output_data);
|
||||
ret->writable = 1; /* to start with */
|
||||
ret->writable = true; /* to start with */
|
||||
ret->sending_oob = 0;
|
||||
ret->outgoingeof = EOF_NO;
|
||||
ret->frozen = 1;
|
||||
ret->frozen_readable = 0;
|
||||
ret->localhost_only = 0; /* unused, but best init anyway */
|
||||
ret->frozen = true;
|
||||
ret->frozen_readable = false;
|
||||
ret->localhost_only = false; /* unused, but best init anyway */
|
||||
ret->pending_error = 0;
|
||||
ret->parent = ret->child = NULL;
|
||||
ret->addr = NULL;
|
||||
@ -952,11 +952,11 @@ static Socket *sk_net_accept(accept_ctx_t ctx, Plug *plug)
|
||||
return &ret->sock;
|
||||
}
|
||||
|
||||
ret->oobinline = 0;
|
||||
ret->oobinline = false;
|
||||
|
||||
/* Set up a select mechanism. This could be an AsyncSelect on a
|
||||
* window, or an EventSelect on an event object. */
|
||||
errstr = do_select(ret->s, 1);
|
||||
errstr = do_select(ret->s, true);
|
||||
if (errstr) {
|
||||
ret->error = errstr;
|
||||
return &ret->sock;
|
||||
@ -980,7 +980,7 @@ static DWORD try_connect(NetSocket *sock)
|
||||
int family;
|
||||
|
||||
if (sock->s != INVALID_SOCKET) {
|
||||
do_select(sock->s, 0);
|
||||
do_select(sock->s, false);
|
||||
p_closesocket(sock->s);
|
||||
}
|
||||
|
||||
@ -1112,7 +1112,7 @@ static DWORD try_connect(NetSocket *sock)
|
||||
|
||||
/* Set up a select mechanism. This could be an AsyncSelect on a
|
||||
* window, or an EventSelect on an event object. */
|
||||
errstr = do_select(s, 1);
|
||||
errstr = do_select(s, true);
|
||||
if (errstr) {
|
||||
sock->error = errstr;
|
||||
err = 1;
|
||||
@ -1145,7 +1145,7 @@ static DWORD try_connect(NetSocket *sock)
|
||||
* If we _don't_ get EWOULDBLOCK, the connect has completed
|
||||
* and we should set the socket as writable.
|
||||
*/
|
||||
sock->writable = 1;
|
||||
sock->writable = true;
|
||||
}
|
||||
|
||||
err = 0;
|
||||
@ -1165,8 +1165,8 @@ static DWORD try_connect(NetSocket *sock)
|
||||
return err;
|
||||
}
|
||||
|
||||
Socket *sk_new(SockAddr *addr, int port, int privport, int oobinline,
|
||||
int nodelay, int keepalive, Plug *plug)
|
||||
Socket *sk_new(SockAddr *addr, int port, bool privport, bool oobinline,
|
||||
bool nodelay, bool keepalive, Plug *plug)
|
||||
{
|
||||
NetSocket *ret;
|
||||
DWORD err;
|
||||
@ -1179,13 +1179,13 @@ Socket *sk_new(SockAddr *addr, int port, int privport, int oobinline,
|
||||
ret->error = NULL;
|
||||
ret->plug = plug;
|
||||
bufchain_init(&ret->output_data);
|
||||
ret->connected = 0; /* to start with */
|
||||
ret->writable = 0; /* to start with */
|
||||
ret->connected = false; /* to start with */
|
||||
ret->writable = false; /* to start with */
|
||||
ret->sending_oob = 0;
|
||||
ret->outgoingeof = EOF_NO;
|
||||
ret->frozen = 0;
|
||||
ret->frozen_readable = 0;
|
||||
ret->localhost_only = 0; /* unused, but best init anyway */
|
||||
ret->frozen = false;
|
||||
ret->frozen_readable = false;
|
||||
ret->localhost_only = false; /* unused, but best init anyway */
|
||||
ret->pending_error = 0;
|
||||
ret->parent = ret->child = NULL;
|
||||
ret->oobinline = oobinline;
|
||||
@ -1206,7 +1206,7 @@ Socket *sk_new(SockAddr *addr, int port, int privport, int oobinline,
|
||||
}
|
||||
|
||||
Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
|
||||
int local_host_only, int orig_address_family)
|
||||
bool local_host_only, int orig_address_family)
|
||||
{
|
||||
SOCKET s;
|
||||
#ifndef NO_IPV6
|
||||
@ -1230,11 +1230,11 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
|
||||
ret->error = NULL;
|
||||
ret->plug = plug;
|
||||
bufchain_init(&ret->output_data);
|
||||
ret->writable = 0; /* to start with */
|
||||
ret->writable = false; /* to start with */
|
||||
ret->sending_oob = 0;
|
||||
ret->outgoingeof = EOF_NO;
|
||||
ret->frozen = 0;
|
||||
ret->frozen_readable = 0;
|
||||
ret->frozen = false;
|
||||
ret->frozen_readable = false;
|
||||
ret->localhost_only = local_host_only;
|
||||
ret->pending_error = 0;
|
||||
ret->parent = ret->child = NULL;
|
||||
@ -1273,7 +1273,7 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
|
||||
|
||||
SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0);
|
||||
|
||||
ret->oobinline = 0;
|
||||
ret->oobinline = false;
|
||||
|
||||
p_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));
|
||||
|
||||
@ -1308,7 +1308,7 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
int got_addr = 0;
|
||||
bool got_addr = false;
|
||||
a.sin_family = AF_INET;
|
||||
|
||||
/*
|
||||
@ -1320,7 +1320,7 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
|
||||
if (a.sin_addr.s_addr != INADDR_NONE) {
|
||||
/* Override localhost_only with specified listen addr. */
|
||||
ret->localhost_only = ipv4_is_loopback(a.sin_addr);
|
||||
got_addr = 1;
|
||||
got_addr = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1366,7 +1366,7 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
|
||||
|
||||
/* Set up a select mechanism. This could be an AsyncSelect on a
|
||||
* window, or an EventSelect on an event object. */
|
||||
errstr = do_select(s, 1);
|
||||
errstr = do_select(s, true);
|
||||
if (errstr) {
|
||||
p_closesocket(s);
|
||||
ret->error = errstr;
|
||||
@ -1401,14 +1401,13 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
|
||||
|
||||
static void sk_net_close(Socket *sock)
|
||||
{
|
||||
extern char *do_select(SOCKET skt, int startup);
|
||||
NetSocket *s = container_of(sock, NetSocket, sock);
|
||||
|
||||
if (s->child)
|
||||
sk_net_close(&s->child->sock);
|
||||
|
||||
del234(sktree, s);
|
||||
do_select(s->s, 0);
|
||||
do_select(s->s, false);
|
||||
p_closesocket(s->s);
|
||||
if (s->addr)
|
||||
sk_addr_free(s->addr);
|
||||
@ -1578,7 +1577,7 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
||||
DWORD err;
|
||||
char buf[20480]; /* nice big buffer for plenty of speed */
|
||||
NetSocket *s;
|
||||
u_long atmark;
|
||||
bool atmark;
|
||||
|
||||
/* wParam is the socket itself */
|
||||
|
||||
@ -1612,7 +1611,8 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
||||
|
||||
switch (WSAGETSELECTEVENT(lParam)) {
|
||||
case FD_CONNECT:
|
||||
s->connected = s->writable = 1;
|
||||
s->connected = true;
|
||||
s->writable = true;
|
||||
/*
|
||||
* Once a socket is connected, we can stop falling
|
||||
* back through the candidate addresses to connect
|
||||
@ -1626,7 +1626,7 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
||||
case FD_READ:
|
||||
/* In the case the socket is still frozen, we don't even bother */
|
||||
if (s->frozen) {
|
||||
s->frozen_readable = 1;
|
||||
s->frozen_readable = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1637,8 +1637,8 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
||||
* (data prior to urgent).
|
||||
*/
|
||||
if (s->oobinline) {
|
||||
atmark = 1;
|
||||
p_ioctlsocket(s->s, SIOCATMARK, &atmark);
|
||||
u_long atmark_from_ioctl = 1;
|
||||
p_ioctlsocket(s->s, SIOCATMARK, &atmark_from_ioctl);
|
||||
/*
|
||||
* Avoid checking the return value from ioctlsocket(),
|
||||
* on the grounds that some WinSock wrappers don't
|
||||
@ -1646,8 +1646,9 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
||||
* which is equivalent to `no OOB pending', so the
|
||||
* effect will be to non-OOB-ify any OOB data.
|
||||
*/
|
||||
atmark = atmark_from_ioctl;
|
||||
} else
|
||||
atmark = 1;
|
||||
atmark = true;
|
||||
|
||||
ret = p_recv(s->s, buf, sizeof(buf), 0);
|
||||
noise_ultralight(ret);
|
||||
@ -1684,7 +1685,7 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
||||
case FD_WRITE:
|
||||
{
|
||||
int bufsize_before, bufsize_after;
|
||||
s->writable = 1;
|
||||
s->writable = true;
|
||||
bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
|
||||
try_send(s);
|
||||
bufsize_after = s->sending_oob + bufchain_size(&s->output_data);
|
||||
@ -1812,20 +1813,20 @@ static SocketPeerInfo *sk_net_peer_info(Socket *sock)
|
||||
return pi;
|
||||
}
|
||||
|
||||
static void sk_net_set_frozen(Socket *sock, int is_frozen)
|
||||
static void sk_net_set_frozen(Socket *sock, bool is_frozen)
|
||||
{
|
||||
NetSocket *s = container_of(sock, NetSocket, sock);
|
||||
if (s->frozen == is_frozen)
|
||||
return;
|
||||
s->frozen = is_frozen;
|
||||
if (!is_frozen) {
|
||||
do_select(s->s, 1);
|
||||
do_select(s->s, true);
|
||||
if (s->frozen_readable) {
|
||||
char c;
|
||||
p_recv(s->s, &c, 1, MSG_PEEK);
|
||||
}
|
||||
}
|
||||
s->frozen_readable = 0;
|
||||
s->frozen_readable = false;
|
||||
}
|
||||
|
||||
void socket_reselect_all(void)
|
||||
@ -1835,7 +1836,7 @@ void socket_reselect_all(void)
|
||||
|
||||
for (i = 0; (s = index234(sktree, i)) != NULL; i++) {
|
||||
if (!s->frozen)
|
||||
do_select(s->s, 1);
|
||||
do_select(s->s, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1856,14 +1857,14 @@ SOCKET next_socket(int *state)
|
||||
return s ? s->s : INVALID_SOCKET;
|
||||
}
|
||||
|
||||
extern int socket_writable(SOCKET skt)
|
||||
extern bool socket_writable(SOCKET skt)
|
||||
{
|
||||
NetSocket *s = find234(sktree, (void *)skt, cmpforsearch);
|
||||
|
||||
if (s)
|
||||
return bufchain_size(&s->output_data) > 0;
|
||||
else
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
int net_service_lookup(char *service)
|
||||
|
@ -19,9 +19,9 @@ DECL_WINDOWS_FUNCTION(static, BOOL, CryptReleaseContext,
|
||||
(HCRYPTPROV, DWORD));
|
||||
static HMODULE wincrypt_module = NULL;
|
||||
|
||||
int win_read_random(void *buf, unsigned wanted)
|
||||
bool win_read_random(void *buf, unsigned wanted)
|
||||
{
|
||||
int toret = false;
|
||||
bool toret = false;
|
||||
HCRYPTPROV crypt_provider;
|
||||
|
||||
if (!wincrypt_module) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "winsecur.h"
|
||||
|
||||
Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
|
||||
Plug *plug, int overlapped);
|
||||
Plug *plug, bool overlapped);
|
||||
|
||||
Socket *new_named_pipe_client(const char *pipename, Plug *plug)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "winsecur.h"
|
||||
|
||||
Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
|
||||
Plug *plug, int overlapped);
|
||||
Plug *plug, bool overlapped);
|
||||
|
||||
typedef struct NamedPipeServerSocket {
|
||||
/* Parameters for (repeated) creation of named pipe objects */
|
||||
@ -73,7 +73,7 @@ static SocketPeerInfo *sk_namedpipeserver_peer_info(Socket *s)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int create_named_pipe(NamedPipeServerSocket *ps, int first_instance)
|
||||
static bool create_named_pipe(NamedPipeServerSocket *ps, bool first_instance)
|
||||
{
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
|
||||
@ -127,7 +127,7 @@ static Socket *named_pipe_accept(accept_ctx_t ctx, Plug *plug)
|
||||
SockAddr *sk_namedpipe_addr(const char *pipename);
|
||||
|
||||
static void named_pipe_accept_loop(NamedPipeServerSocket *ps,
|
||||
int got_one_already)
|
||||
bool got_one_already)
|
||||
{
|
||||
while (1) {
|
||||
int error;
|
||||
|
@ -71,7 +71,7 @@ void queue_idempotent_callback(IdempotentCallback *ic) { assert(0); }
|
||||
struct progress {
|
||||
int nphases;
|
||||
struct {
|
||||
int exponential;
|
||||
bool exponential;
|
||||
unsigned startpoint, total;
|
||||
unsigned param, current, n; /* if exponential */
|
||||
unsigned mult; /* if linear */
|
||||
@ -93,11 +93,11 @@ static void progress_update(void *param, int action, int phase, int iprogress)
|
||||
p->nphases = 0;
|
||||
break;
|
||||
case PROGFN_LIN_PHASE:
|
||||
p->phases[phase-1].exponential = 0;
|
||||
p->phases[phase-1].exponential = false;
|
||||
p->phases[phase-1].mult = p->phases[phase].total / progress;
|
||||
break;
|
||||
case PROGFN_EXP_PHASE:
|
||||
p->phases[phase-1].exponential = 1;
|
||||
p->phases[phase-1].exponential = true;
|
||||
p->phases[phase-1].param = 0x10000 + progress;
|
||||
p->phases[phase-1].current = p->phases[phase-1].total;
|
||||
p->phases[phase-1].n = 0;
|
||||
@ -212,8 +212,8 @@ static INT_PTR CALLBACK PassphraseProc(HWND hwnd, UINT msg,
|
||||
* Prompt for a key file. Assumes the filename buffer is of size
|
||||
* FILENAME_MAX.
|
||||
*/
|
||||
static int prompt_keyfile(HWND hwnd, char *dlgtitle,
|
||||
char *filename, int save, int ppk)
|
||||
static bool prompt_keyfile(HWND hwnd, char *dlgtitle,
|
||||
char *filename, bool save, bool ppk)
|
||||
{
|
||||
OPENFILENAME of;
|
||||
memset(&of, 0, sizeof(of));
|
||||
@ -379,12 +379,12 @@ static DWORD WINAPI generate_key_thread(void *param)
|
||||
}
|
||||
|
||||
struct MainDlgState {
|
||||
int collecting_entropy;
|
||||
int generation_thread_exists;
|
||||
int key_exists;
|
||||
bool collecting_entropy;
|
||||
bool generation_thread_exists;
|
||||
bool key_exists;
|
||||
int entropy_got, entropy_required, entropy_size;
|
||||
int key_bits, curve_bits;
|
||||
int ssh2;
|
||||
bool ssh2;
|
||||
keytype keytype;
|
||||
char **commentptr; /* points to key.comment or ssh2key.comment */
|
||||
struct ssh2_userkey ssh2key;
|
||||
@ -397,7 +397,7 @@ struct MainDlgState {
|
||||
HMENU filemenu, keymenu, cvtmenu;
|
||||
};
|
||||
|
||||
static void hidemany(HWND hwnd, const int *ids, int hideit)
|
||||
static void hidemany(HWND hwnd, const int *ids, bool hideit)
|
||||
{
|
||||
while (*ids) {
|
||||
ShowWindow(GetDlgItem(hwnd, *ids++), (hideit ? SW_HIDE : SW_SHOW));
|
||||
@ -642,10 +642,10 @@ void ui_set_key_type(HWND hwnd, struct MainDlgState *state, int button)
|
||||
}
|
||||
|
||||
void load_key_file(HWND hwnd, struct MainDlgState *state,
|
||||
Filename *filename, int was_import_cmd)
|
||||
Filename *filename, bool was_import_cmd)
|
||||
{
|
||||
char *passphrase;
|
||||
int needs_pass;
|
||||
bool needs_pass;
|
||||
int type, realtype;
|
||||
int ret;
|
||||
const char *errmsg = NULL;
|
||||
@ -1029,7 +1029,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
||||
*/
|
||||
if (cmdline_keyfile) {
|
||||
Filename *fn = filename_from_str(cmdline_keyfile);
|
||||
load_key_file(hwnd, state, fn, 0);
|
||||
load_key_file(hwnd, state, fn, false);
|
||||
filename_free(fn);
|
||||
}
|
||||
|
||||
@ -1280,7 +1280,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
||||
}
|
||||
}
|
||||
if (prompt_keyfile(hwnd, "Save private key as:",
|
||||
filename, 1, (type == realtype))) {
|
||||
filename, true, (type == realtype))) {
|
||||
int ret;
|
||||
FILE *fp = fopen(filename, "r");
|
||||
if (fp) {
|
||||
@ -1334,7 +1334,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
||||
if (state->key_exists) {
|
||||
char filename[FILENAME_MAX];
|
||||
if (prompt_keyfile(hwnd, "Save public key as:",
|
||||
filename, 1, 0)) {
|
||||
filename, true, false)) {
|
||||
int ret;
|
||||
FILE *fp = fopen(filename, "r");
|
||||
if (fp) {
|
||||
@ -1380,8 +1380,8 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
||||
(struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
if (!state->generation_thread_exists) {
|
||||
char filename[FILENAME_MAX];
|
||||
if (prompt_keyfile(hwnd, "Load private key:",
|
||||
filename, 0, LOWORD(wParam)==IDC_LOAD)) {
|
||||
if (prompt_keyfile(hwnd, "Load private key:", filename, false,
|
||||
LOWORD(wParam) == IDC_LOAD)) {
|
||||
Filename *fn = filename_from_str(filename);
|
||||
load_key_file(hwnd, state, fn, LOWORD(wParam) != IDC_LOAD);
|
||||
filename_free(fn);
|
||||
|
@ -55,10 +55,10 @@ extern const char ver[];
|
||||
static HWND keylist;
|
||||
static HWND aboutbox;
|
||||
static HMENU systray_menu, session_menu;
|
||||
static int already_running;
|
||||
static bool already_running;
|
||||
|
||||
static char *putty_path;
|
||||
static int restrict_putty_acl = false;
|
||||
static bool restrict_putty_acl = false;
|
||||
|
||||
/* CWD for "add key" file requester. */
|
||||
static filereq *keypath = NULL;
|
||||
@ -116,7 +116,7 @@ static void unmungestr(char *in, char *out, int outlen)
|
||||
/* Stubs needed to link against misc.c */
|
||||
void queue_idempotent_callback(IdempotentCallback *ic) { assert(0); }
|
||||
|
||||
static int has_security;
|
||||
static bool has_security;
|
||||
|
||||
struct PassphraseProcStruct {
|
||||
char **passphrase;
|
||||
@ -783,7 +783,7 @@ PSID get_default_sid(void)
|
||||
struct PageantReply {
|
||||
char *buf;
|
||||
size_t size, len;
|
||||
int overflowed;
|
||||
bool overflowed;
|
||||
BinarySink_IMPLEMENTATION;
|
||||
};
|
||||
|
||||
@ -969,7 +969,7 @@ static char *answer_filemapping_message(const char *mapname)
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static int menuinprogress;
|
||||
static bool menuinprogress;
|
||||
static UINT msgTaskbarCreated = 0;
|
||||
|
||||
switch (message) {
|
||||
@ -1000,14 +1000,14 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
break;
|
||||
case WM_SYSTRAY2:
|
||||
if (!menuinprogress) {
|
||||
menuinprogress = 1;
|
||||
menuinprogress = true;
|
||||
update_sessions();
|
||||
SetForegroundWindow(hwnd);
|
||||
TrackPopupMenu(systray_menu,
|
||||
TPM_RIGHTALIGN | TPM_BOTTOMALIGN |
|
||||
TPM_RIGHTBUTTON,
|
||||
wParam, lParam, 0, hwnd, NULL);
|
||||
menuinprogress = 0;
|
||||
menuinprogress = false;
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
@ -1169,7 +1169,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
WNDCLASS wndclass;
|
||||
MSG msg;
|
||||
const char *command = NULL;
|
||||
int added_keys = 0;
|
||||
bool added_keys = false;
|
||||
int argc, i;
|
||||
char **argv, **argstart;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#define AGENT_COPYDATA_ID 0x804e50ba /* random goop */
|
||||
|
||||
int agent_exists(void)
|
||||
bool agent_exists(void)
|
||||
{
|
||||
HWND hwnd;
|
||||
hwnd = FindWindow("Pageant", "Pageant");
|
||||
|
@ -40,11 +40,11 @@ WSAEVENT netevent;
|
||||
static Backend *backend;
|
||||
static Conf *conf;
|
||||
|
||||
int term_ldisc(Terminal *term, int mode)
|
||||
bool term_ldisc(Terminal *term, int mode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
static void plink_echoedit_update(Seat *seat, int echo, int edit)
|
||||
static void plink_echoedit_update(Seat *seat, bool echo, bool edit)
|
||||
{
|
||||
/* Update stdin read mode to reflect changes in line discipline. */
|
||||
DWORD mode;
|
||||
@ -61,7 +61,7 @@ static void plink_echoedit_update(Seat *seat, int echo, int edit)
|
||||
SetConsoleMode(inhandle, mode);
|
||||
}
|
||||
|
||||
static int plink_output(Seat *seat, int is_stderr, const void *data, int len)
|
||||
static int plink_output(Seat *seat, bool is_stderr, const void *data, int len)
|
||||
{
|
||||
if (is_stderr) {
|
||||
handle_write(stderr_handle, data, len);
|
||||
@ -72,7 +72,7 @@ static int plink_output(Seat *seat, int is_stderr, const void *data, int len)
|
||||
return handle_backlog(stdout_handle) + handle_backlog(stderr_handle);
|
||||
}
|
||||
|
||||
static int plink_eof(Seat *seat)
|
||||
static bool plink_eof(Seat *seat)
|
||||
{
|
||||
handle_write_eof(stdout_handle);
|
||||
return false; /* do not respond to incoming EOF with outgoing */
|
||||
@ -185,7 +185,7 @@ static void version(void)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
char *do_select(SOCKET skt, int startup)
|
||||
char *do_select(SOCKET skt, bool startup)
|
||||
{
|
||||
int events;
|
||||
if (startup) {
|
||||
@ -254,18 +254,18 @@ void stdouterr_sent(struct handle *h, int new_backlog)
|
||||
}
|
||||
}
|
||||
|
||||
const int share_can_be_downstream = true;
|
||||
const int share_can_be_upstream = true;
|
||||
const bool share_can_be_downstream = true;
|
||||
const bool share_can_be_upstream = true;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int sending;
|
||||
bool sending;
|
||||
SOCKET *sklist;
|
||||
int skcount, sksize;
|
||||
int exitcode;
|
||||
int errors;
|
||||
int use_subsystem = 0;
|
||||
int just_test_share_exists = false;
|
||||
bool errors;
|
||||
bool use_subsystem = false;
|
||||
bool just_test_share_exists = false;
|
||||
unsigned long now, next, then;
|
||||
const struct BackendVtable *vt;
|
||||
|
||||
@ -295,7 +295,7 @@ int main(int argc, char **argv)
|
||||
loaded_session = false;
|
||||
default_protocol = conf_get_int(conf, CONF_protocol);
|
||||
default_port = conf_get_int(conf, CONF_port);
|
||||
errors = 0;
|
||||
errors = false;
|
||||
{
|
||||
/*
|
||||
* Override the default protocol if PLINK_PROTOCOL is set.
|
||||
@ -318,16 +318,16 @@ int main(int argc, char **argv)
|
||||
if (ret == -2) {
|
||||
fprintf(stderr,
|
||||
"plink: option \"%s\" requires an argument\n", p);
|
||||
errors = 1;
|
||||
errors = true;
|
||||
} else if (ret == 2) {
|
||||
--argc, ++argv;
|
||||
} else if (ret == 1) {
|
||||
continue;
|
||||
} else if (!strcmp(p, "-batch")) {
|
||||
console_batch_mode = 1;
|
||||
console_batch_mode = true;
|
||||
} else if (!strcmp(p, "-s")) {
|
||||
/* Save status to write to conf later. */
|
||||
use_subsystem = 1;
|
||||
use_subsystem = true;
|
||||
} else if (!strcmp(p, "-V") || !strcmp(p, "--version")) {
|
||||
version();
|
||||
} else if (!strcmp(p, "--help")) {
|
||||
@ -367,7 +367,7 @@ int main(int argc, char **argv)
|
||||
break; /* done with cmdline */
|
||||
} else {
|
||||
fprintf(stderr, "plink: unknown option \"%s\"\n", p);
|
||||
errors = 1;
|
||||
errors = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ int main(int argc, char **argv)
|
||||
const char *error;
|
||||
char *realhost;
|
||||
/* nodelay is only useful if stdin is a character device (console) */
|
||||
int nodelay = conf_get_bool(conf, CONF_tcp_nodelay) &&
|
||||
bool nodelay = conf_get_bool(conf, CONF_tcp_nodelay) &&
|
||||
(GetFileType(GetStdHandle(STD_INPUT_HANDLE)) == FILE_TYPE_CHAR);
|
||||
|
||||
error = backend_init(vt, plink_seat, &backend, logctx, conf,
|
||||
|
@ -32,7 +32,7 @@ DECL_WINDOWS_FUNCTION(static, BOOL, WritePrinter,
|
||||
|
||||
static void init_winfuncs(void)
|
||||
{
|
||||
static int initialised = false;
|
||||
static bool initialised = false;
|
||||
if (initialised)
|
||||
return;
|
||||
{
|
||||
@ -56,8 +56,8 @@ static void init_winfuncs(void)
|
||||
initialised = true;
|
||||
}
|
||||
|
||||
static int printer_add_enum(int param, DWORD level, char **buffer,
|
||||
int offset, int *nprinters_ptr)
|
||||
static bool printer_add_enum(int param, DWORD level, char **buffer,
|
||||
int offset, int *nprinters_ptr)
|
||||
{
|
||||
DWORD needed = 0, nprinters = 0;
|
||||
|
||||
@ -169,7 +169,7 @@ printer_job *printer_start_job(char *printer)
|
||||
{
|
||||
printer_job *ret = snew(printer_job);
|
||||
DOC_INFO_1 docinfo;
|
||||
int jobstarted = 0, pagestarted = 0;
|
||||
bool jobstarted = false, pagestarted = false;
|
||||
|
||||
init_winfuncs();
|
||||
|
||||
@ -183,11 +183,11 @@ printer_job *printer_start_job(char *printer)
|
||||
|
||||
if (!p_StartDocPrinter(ret->hprinter, 1, (LPBYTE)&docinfo))
|
||||
goto error;
|
||||
jobstarted = 1;
|
||||
jobstarted = true;
|
||||
|
||||
if (!p_StartPagePrinter(ret->hprinter))
|
||||
goto error;
|
||||
pagestarted = 1;
|
||||
pagestarted = true;
|
||||
|
||||
return ret;
|
||||
|
||||
|
@ -13,11 +13,11 @@
|
||||
#include "proxy.h"
|
||||
|
||||
Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
|
||||
Plug *plug, int overlapped);
|
||||
Plug *plug, bool overlapped);
|
||||
|
||||
Socket *platform_new_connection(SockAddr *addr, const char *hostname,
|
||||
int port, int privport,
|
||||
int oobinline, int nodelay, int keepalive,
|
||||
int port, bool privport,
|
||||
bool oobinline, bool nodelay, bool keepalive,
|
||||
Plug *plug, Conf *conf)
|
||||
{
|
||||
char *cmd;
|
||||
|
@ -16,10 +16,10 @@
|
||||
static PSID worldsid, networksid, usersid;
|
||||
|
||||
|
||||
int got_advapi(void)
|
||||
bool got_advapi(void)
|
||||
{
|
||||
static int attempted = false;
|
||||
static int successful;
|
||||
static bool attempted = false;
|
||||
static bool successful;
|
||||
static HMODULE advapi;
|
||||
|
||||
if (!attempted) {
|
||||
@ -92,7 +92,7 @@ PSID get_user_sid(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int getsids(char **error)
|
||||
bool getsids(char **error)
|
||||
{
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
@ -104,7 +104,7 @@ int getsids(char **error)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
int ret = false;
|
||||
bool ret = false;
|
||||
|
||||
*error = NULL;
|
||||
|
||||
@ -142,14 +142,14 @@ int getsids(char **error)
|
||||
}
|
||||
|
||||
|
||||
int make_private_security_descriptor(DWORD permissions,
|
||||
PSECURITY_DESCRIPTOR *psd,
|
||||
PACL *acl,
|
||||
char **error)
|
||||
bool make_private_security_descriptor(DWORD permissions,
|
||||
PSECURITY_DESCRIPTOR *psd,
|
||||
PACL *acl,
|
||||
char **error)
|
||||
{
|
||||
EXPLICIT_ACCESS ea[3];
|
||||
int acl_err;
|
||||
int ret = false;
|
||||
bool ret = false;
|
||||
|
||||
|
||||
*psd = NULL;
|
||||
@ -228,11 +228,11 @@ int make_private_security_descriptor(DWORD permissions,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int really_restrict_process_acl(char **error)
|
||||
static bool really_restrict_process_acl(char **error)
|
||||
{
|
||||
EXPLICIT_ACCESS ea[2];
|
||||
int acl_err;
|
||||
int ret=false;
|
||||
bool ret = false;
|
||||
PACL acl = NULL;
|
||||
|
||||
static const DWORD nastyace=WRITE_DAC | WRITE_OWNER |
|
||||
@ -312,7 +312,7 @@ static int really_restrict_process_acl(char **error)
|
||||
void restrict_process_acl(void)
|
||||
{
|
||||
char *error = NULL;
|
||||
int ret;
|
||||
bool ret;
|
||||
|
||||
#if !defined NO_SECURITY
|
||||
ret = really_restrict_process_acl(&error);
|
||||
|
@ -33,7 +33,7 @@ DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, SetSecurityInfo,
|
||||
PSID, PSID, PACL, PACL));
|
||||
DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, SetEntriesInAclA,
|
||||
(ULONG, PEXPLICIT_ACCESS, PACL, PACL *));
|
||||
int got_advapi(void);
|
||||
bool got_advapi(void);
|
||||
|
||||
/*
|
||||
* Find the SID describing the current user. The return value (if not
|
||||
@ -51,9 +51,7 @@ PSID get_user_sid(void);
|
||||
* freed later using LocalFree). If it returns false, then instead
|
||||
* 'error' has been filled with a dynamically allocated error message.
|
||||
*/
|
||||
int make_private_security_descriptor(DWORD permissions,
|
||||
PSECURITY_DESCRIPTOR *psd,
|
||||
PACL *acl,
|
||||
char **error);
|
||||
bool make_private_security_descriptor(
|
||||
DWORD permissions, PSECURITY_DESCRIPTOR *psd, PACL *acl, char **error);
|
||||
|
||||
#endif
|
||||
|
@ -18,7 +18,7 @@ struct Serial {
|
||||
LogContext *logctx;
|
||||
int bufsize;
|
||||
long clearbreak_time;
|
||||
int break_in_progress;
|
||||
bool break_in_progress;
|
||||
Backend backend;
|
||||
};
|
||||
|
||||
@ -193,7 +193,7 @@ static const char *serial_configure(Serial *serial, HANDLE serport, Conf *conf)
|
||||
static const char *serial_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port,
|
||||
char **realhost, int nodelay, int keepalive)
|
||||
char **realhost, bool nodelay, bool keepalive)
|
||||
{
|
||||
Serial *serial;
|
||||
HANDLE serport;
|
||||
@ -375,14 +375,14 @@ static const SessionSpecial *serial_get_specials(Backend *be)
|
||||
return specials;
|
||||
}
|
||||
|
||||
static int serial_connected(Backend *be)
|
||||
static bool serial_connected(Backend *be)
|
||||
{
|
||||
return 1; /* always connected */
|
||||
return true; /* always connected */
|
||||
}
|
||||
|
||||
static int serial_sendok(Backend *be)
|
||||
static bool serial_sendok(Backend *be)
|
||||
{
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void serial_unthrottle(Backend *be, int backlog)
|
||||
@ -392,12 +392,12 @@ static void serial_unthrottle(Backend *be, int backlog)
|
||||
handle_unthrottle(serial->in, backlog);
|
||||
}
|
||||
|
||||
static int serial_ldisc(Backend *be, int option)
|
||||
static bool serial_ldisc(Backend *be, int option)
|
||||
{
|
||||
/*
|
||||
* Local editing and local echo are off by default.
|
||||
*/
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void serial_provide_ldisc(Backend *be, Ldisc *ldisc)
|
||||
|
@ -25,7 +25,7 @@ void platform_get_x11_auth(struct X11Display *display, Conf *conf)
|
||||
{
|
||||
/* Do nothing, therefore no auth. */
|
||||
}
|
||||
const int platform_uses_x11_unix_by_default = true;
|
||||
const bool platform_uses_x11_unix_by_default = true;
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* File access abstraction.
|
||||
@ -131,10 +131,8 @@ RFile *open_existing_file(const char *name, uint64_t *size,
|
||||
|
||||
int read_from_file(RFile *f, void *buffer, int length)
|
||||
{
|
||||
int ret;
|
||||
DWORD read;
|
||||
ret = ReadFile(f->h, buffer, length, &read, NULL);
|
||||
if (!ret)
|
||||
if (!ReadFile(f->h, buffer, length, &read, NULL))
|
||||
return -1; /* error */
|
||||
else
|
||||
return read;
|
||||
@ -190,10 +188,8 @@ WFile *open_existing_wfile(const char *name, uint64_t *size)
|
||||
|
||||
int write_to_file(WFile *f, void *buffer, int length)
|
||||
{
|
||||
int ret;
|
||||
DWORD written;
|
||||
ret = WriteFile(f->h, buffer, length, &written, NULL);
|
||||
if (!ret)
|
||||
if (!WriteFile(f->h, buffer, length, &written, NULL))
|
||||
return -1; /* error */
|
||||
else
|
||||
return written;
|
||||
@ -296,8 +292,7 @@ char *read_filename(DirHandle *dir)
|
||||
|
||||
if (!dir->name) {
|
||||
WIN32_FIND_DATA fdat;
|
||||
int ok = FindNextFile(dir->h, &fdat);
|
||||
if (!ok)
|
||||
if (!FindNextFile(dir->h, &fdat))
|
||||
return NULL;
|
||||
else
|
||||
dir->name = dupstr(fdat.cFileName);
|
||||
@ -329,7 +324,7 @@ void close_directory(DirHandle *dir)
|
||||
sfree(dir);
|
||||
}
|
||||
|
||||
int test_wildcard(const char *name, int cmdline)
|
||||
int test_wildcard(const char *name, bool cmdline)
|
||||
{
|
||||
HANDLE fh;
|
||||
WIN32_FIND_DATA fdat;
|
||||
@ -353,7 +348,7 @@ struct WildcardMatcher {
|
||||
char *srcpath;
|
||||
};
|
||||
|
||||
char *stripslashes(const char *str, int local)
|
||||
char *stripslashes(const char *str, bool local)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -391,7 +386,7 @@ WildcardMatcher *begin_wildcard_matching(const char *name)
|
||||
ret = snew(WildcardMatcher);
|
||||
ret->h = h;
|
||||
ret->srcpath = dupstr(name);
|
||||
last = stripslashes(ret->srcpath, 1);
|
||||
last = stripslashes(ret->srcpath, true);
|
||||
*last = '\0';
|
||||
if (fdat.cFileName[0] == '.' &&
|
||||
(fdat.cFileName[1] == '\0' ||
|
||||
@ -407,9 +402,8 @@ char *wildcard_get_filename(WildcardMatcher *dir)
|
||||
{
|
||||
while (!dir->name) {
|
||||
WIN32_FIND_DATA fdat;
|
||||
int ok = FindNextFile(dir->h, &fdat);
|
||||
|
||||
if (!ok)
|
||||
if (!FindNextFile(dir->h, &fdat))
|
||||
return NULL;
|
||||
|
||||
if (fdat.cFileName[0] == '.' &&
|
||||
@ -437,7 +431,7 @@ void finish_wildcard_matching(WildcardMatcher *dir)
|
||||
sfree(dir);
|
||||
}
|
||||
|
||||
int vet_filename(const char *name)
|
||||
bool vet_filename(const char *name)
|
||||
{
|
||||
if (strchr(name, '/') || strchr(name, '\\') || strchr(name, ':'))
|
||||
return false;
|
||||
@ -448,7 +442,7 @@ int vet_filename(const char *name)
|
||||
return true;
|
||||
}
|
||||
|
||||
int create_directory(const char *name)
|
||||
bool create_directory(const char *name)
|
||||
{
|
||||
return CreateDirectory(name, NULL) != 0;
|
||||
}
|
||||
@ -467,7 +461,7 @@ char *dir_file_cat(const char *dir, const char *file)
|
||||
*/
|
||||
static SOCKET sftp_ssh_socket = INVALID_SOCKET;
|
||||
static HANDLE netevent = INVALID_HANDLE_VALUE;
|
||||
char *do_select(SOCKET skt, int startup)
|
||||
char *do_select(SOCKET skt, bool startup)
|
||||
{
|
||||
int events;
|
||||
if (startup)
|
||||
@ -702,7 +696,7 @@ static DWORD WINAPI command_read_thread(void *param)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *ssh_sftp_get_cmdline(const char *prompt, int no_fds_ok)
|
||||
char *ssh_sftp_get_cmdline(const char *prompt, bool no_fds_ok)
|
||||
{
|
||||
int ret;
|
||||
struct command_read_ctx actx, *ctx = &actx;
|
||||
|
@ -121,7 +121,7 @@ Socket *new_named_pipe_listener(const char *pipename, Plug *plug);
|
||||
int platform_ssh_share(const char *pi_name, Conf *conf,
|
||||
Plug *downplug, Plug *upplug, Socket **sock,
|
||||
char **logtext, char **ds_err, char **us_err,
|
||||
int can_upstream, int can_downstream)
|
||||
bool can_upstream, bool can_downstream)
|
||||
{
|
||||
char *name, *mutexname, *pipename;
|
||||
HANDLE mutex;
|
||||
|
@ -24,14 +24,14 @@ static const char *const puttystr = PUTTY_REG_POS "\\Sessions";
|
||||
|
||||
static const char hex[16] = "0123456789ABCDEF";
|
||||
|
||||
static int tried_shgetfolderpath = false;
|
||||
static bool tried_shgetfolderpath = false;
|
||||
static HMODULE shell32_module = NULL;
|
||||
DECL_WINDOWS_FUNCTION(static, HRESULT, SHGetFolderPathA,
|
||||
(HWND, int, HANDLE, DWORD, LPSTR));
|
||||
|
||||
static void mungestr(const char *in, char *out)
|
||||
{
|
||||
int candot = 0;
|
||||
bool candot = false;
|
||||
|
||||
while (*in) {
|
||||
if (*in == ' ' || *in == '\\' || *in == '*' || *in == '?' ||
|
||||
@ -43,7 +43,7 @@ static void mungestr(const char *in, char *out)
|
||||
} else
|
||||
*out++ = *in;
|
||||
in++;
|
||||
candot = 1;
|
||||
candot = true;
|
||||
}
|
||||
*out = '\0';
|
||||
return;
|
||||
@ -470,7 +470,7 @@ int verify_host_key(const char *hostname, int port,
|
||||
return 0; /* key matched OK in registry */
|
||||
}
|
||||
|
||||
int have_ssh_host_key(const char *hostname, int port,
|
||||
bool have_ssh_host_key(const char *hostname, int port,
|
||||
const char *keytype)
|
||||
{
|
||||
/*
|
||||
@ -503,7 +503,7 @@ void store_host_key(const char *hostname, int port,
|
||||
* Open (or delete) the random seed file.
|
||||
*/
|
||||
enum { DEL, OPEN_R, OPEN_W };
|
||||
static int try_random_seed(char const *path, int action, HANDLE *ret)
|
||||
static bool try_random_seed(char const *path, int action, HANDLE *ret)
|
||||
{
|
||||
if (action == DEL) {
|
||||
if (!DeleteFile(path) && GetLastError() != ERROR_FILE_NOT_FOUND) {
|
||||
|
@ -44,12 +44,12 @@ struct Filename {
|
||||
|
||||
struct FontSpec {
|
||||
char *name;
|
||||
int isbold;
|
||||
bool isbold;
|
||||
int height;
|
||||
int charset;
|
||||
};
|
||||
struct FontSpec *fontspec_new(const char *name,
|
||||
int bold, int height, int charset);
|
||||
struct FontSpec *fontspec_new(
|
||||
const char *name, bool bold, int height, int charset);
|
||||
|
||||
#ifndef CLEARTYPE_QUALITY
|
||||
#define CLEARTYPE_QUALITY 5
|
||||
@ -228,7 +228,7 @@ GLOBAL HINSTANCE hinst;
|
||||
*/
|
||||
void init_help(void);
|
||||
void shutdown_help(void);
|
||||
int has_help(void);
|
||||
bool has_help(void);
|
||||
void launch_help(HWND hwnd, const char *topic);
|
||||
void quit_help(HWND hwnd);
|
||||
|
||||
@ -259,7 +259,7 @@ int win_seat_confirm_weak_cached_hostkey(
|
||||
* which takes the data string in the system code page instead of
|
||||
* Unicode.
|
||||
*/
|
||||
void write_aclip(int clipboard, char *, int, int);
|
||||
void write_aclip(int clipboard, char *, int, bool);
|
||||
|
||||
#define WM_NETEVENT (WM_APP + 5)
|
||||
|
||||
@ -331,7 +331,7 @@ DECL_WINDOWS_FUNCTION(GLOBAL, int, select,
|
||||
fd_set FAR *, const struct timeval FAR *));
|
||||
#endif
|
||||
|
||||
extern int socket_writable(SOCKET skt);
|
||||
extern bool socket_writable(SOCKET skt);
|
||||
|
||||
extern void socket_reselect_all(void);
|
||||
|
||||
@ -354,7 +354,7 @@ void init_common_controls(void); /* also does some DLL-loading */
|
||||
* Exports from winutils.c.
|
||||
*/
|
||||
typedef struct filereq_tag filereq; /* cwd for file requester */
|
||||
BOOL request_file(filereq *state, OPENFILENAME *of, int preserve, int save);
|
||||
bool request_file(filereq *state, OPENFILENAME *of, bool preserve, bool save);
|
||||
filereq *filereq_new(void);
|
||||
void filereq_free(filereq *state);
|
||||
int message_box(LPCTSTR text, LPCTSTR caption, DWORD style, DWORD helpctxid);
|
||||
@ -369,7 +369,7 @@ struct prefslist {
|
||||
int listid, upbid, dnbid;
|
||||
int srcitem;
|
||||
int dummyitem;
|
||||
int dragging;
|
||||
bool dragging;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -384,13 +384,17 @@ struct dlgparam {
|
||||
char *errtitle; /* title of error sub-messageboxes */
|
||||
void *data; /* data to pass in refresh events */
|
||||
union control *focused, *lastfocused; /* which ctrl has focus now/before */
|
||||
char shortcuts[128]; /* track which shortcuts in use */
|
||||
int coloursel_wanted; /* has an event handler asked for
|
||||
bool shortcuts[128]; /* track which shortcuts in use */
|
||||
bool coloursel_wanted; /* has an event handler asked for
|
||||
* a colour selector? */
|
||||
struct { unsigned char r, g, b, ok; } coloursel_result; /* 0-255 */
|
||||
struct {
|
||||
unsigned char r, g, b; /* 0-255 */
|
||||
bool ok;
|
||||
} coloursel_result;
|
||||
tree234 *privdata; /* stores per-control private data */
|
||||
int ended, endresult; /* has the dialog been ended? */
|
||||
int fixed_pitch_fonts; /* are we constrained to fixed fonts? */
|
||||
bool ended; /* has the dialog been ended? */
|
||||
int endresult; /* and if so, what was the result? */
|
||||
bool fixed_pitch_fonts; /* are we constrained to fixed fonts? */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -403,7 +407,7 @@ HWND doctl(struct ctlpos *cp, RECT r,
|
||||
void bartitle(struct ctlpos *cp, char *name, int id);
|
||||
void beginbox(struct ctlpos *cp, char *name, int idbox);
|
||||
void endbox(struct ctlpos *cp);
|
||||
void editboxfw(struct ctlpos *cp, int password, char *text,
|
||||
void editboxfw(struct ctlpos *cp, bool password, char *text,
|
||||
int staticid, int editid);
|
||||
void radioline(struct ctlpos *cp, char *text, int id, int nacross, ...);
|
||||
void bareradioline(struct ctlpos *cp, int nacross, ...);
|
||||
@ -440,7 +444,7 @@ void prefslist(struct prefslist *hdl, struct ctlpos *cp, int lines,
|
||||
char *stext, int sid, int listid, int upbid, int dnbid);
|
||||
int handle_prefslist(struct prefslist *hdl,
|
||||
int *array, int maxmemb,
|
||||
int is_dlmsg, HWND hwnd,
|
||||
bool is_dlmsg, HWND hwnd,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
void progressbar(struct ctlpos *cp, int id);
|
||||
void fwdsetter(struct ctlpos *cp, int listid, char *stext, int sid,
|
||||
@ -450,8 +454,8 @@ void fwdsetter(struct ctlpos *cp, int listid, char *stext, int sid,
|
||||
char *r1text, int r1id, char *r2text, int r2id);
|
||||
|
||||
void dlg_auto_set_fixed_pitch_flag(dlgparam *dlg);
|
||||
int dlg_get_fixed_pitch_flag(dlgparam *dlg);
|
||||
void dlg_set_fixed_pitch_flag(dlgparam *dlg, int flag);
|
||||
bool dlg_get_fixed_pitch_flag(dlgparam *dlg);
|
||||
void dlg_set_fixed_pitch_flag(dlgparam *dlg, bool flag);
|
||||
|
||||
#define MAX_SHORTCUTS_PER_CTRL 16
|
||||
|
||||
@ -503,10 +507,10 @@ struct winctrl *winctrl_findbyid(struct winctrls *, int);
|
||||
struct winctrl *winctrl_findbyindex(struct winctrls *, int);
|
||||
void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
|
||||
struct ctlpos *cp, struct controlset *s, int *id);
|
||||
int winctrl_handle_command(struct dlgparam *dp, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
bool winctrl_handle_command(struct dlgparam *dp, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
void winctrl_rem_shortcuts(struct dlgparam *dp, struct winctrl *c);
|
||||
int winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id);
|
||||
bool winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id);
|
||||
|
||||
void dp_init(struct dlgparam *dp);
|
||||
void dp_add_tree(struct dlgparam *dp, struct winctrls *tree);
|
||||
@ -515,15 +519,15 @@ void dp_cleanup(struct dlgparam *dp);
|
||||
/*
|
||||
* Exports from wincfg.c.
|
||||
*/
|
||||
void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
int midsession, int protocol);
|
||||
void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help,
|
||||
bool midsession, int protocol);
|
||||
|
||||
/*
|
||||
* Exports from windlg.c.
|
||||
*/
|
||||
void defuse_showwindow(void);
|
||||
int do_config(void);
|
||||
int do_reconfig(HWND, int);
|
||||
bool do_config(void);
|
||||
bool do_reconfig(HWND, int);
|
||||
void showeventlog(HWND);
|
||||
void showabout(HWND);
|
||||
void force_normal(HWND hwnd);
|
||||
@ -539,7 +543,7 @@ void dll_hijacking_protection(void);
|
||||
HMODULE load_system32_dll(const char *libname);
|
||||
const char *win_strerror(int error);
|
||||
void restrict_process_acl(void);
|
||||
GLOBAL int restricted_acl;
|
||||
GLOBAL bool restricted_acl;
|
||||
|
||||
/* A few pieces of up-to-date Windows API definition needed for older
|
||||
* compilers. */
|
||||
@ -561,7 +565,7 @@ DECLSPEC_IMPORT DLL_DIRECTORY_COOKIE WINAPI AddDllDirectory (PCWSTR NewDirectory
|
||||
* Exports from sizetip.c.
|
||||
*/
|
||||
void UpdateSizeTip(HWND src, int cx, int cy);
|
||||
void EnableSizeTip(int bEnable);
|
||||
void EnableSizeTip(bool bEnable);
|
||||
|
||||
/*
|
||||
* Exports from unicode.c.
|
||||
@ -617,12 +621,12 @@ extern const struct BackendVtable serial_backend;
|
||||
void add_session_to_jumplist(const char * const sessionname);
|
||||
void remove_session_from_jumplist(const char * const sessionname);
|
||||
void clear_jumplist(void);
|
||||
BOOL set_explicit_app_user_model_id();
|
||||
bool set_explicit_app_user_model_id();
|
||||
|
||||
/*
|
||||
* Exports from winnoise.c.
|
||||
*/
|
||||
int win_read_random(void *buf, unsigned wanted); /* returns true on success */
|
||||
bool win_read_random(void *buf, unsigned wanted); /* returns true on success */
|
||||
|
||||
/*
|
||||
* Extra functions in winstore.c over and above the interface in
|
||||
|
@ -440,7 +440,7 @@ static void link_font(WCHAR * line_tbl, WCHAR * font_tbl, WCHAR attr);
|
||||
void init_ucs(Conf *conf, struct unicode_data *ucsdata)
|
||||
{
|
||||
int i, j;
|
||||
int used_dtf = 0;
|
||||
bool used_dtf = false;
|
||||
int vtmode;
|
||||
|
||||
/* Decide on the Line and Font codepages */
|
||||
@ -449,13 +449,13 @@ void init_ucs(Conf *conf, struct unicode_data *ucsdata)
|
||||
|
||||
if (ucsdata->font_codepage <= 0) {
|
||||
ucsdata->font_codepage=0;
|
||||
ucsdata->dbcs_screenfont=0;
|
||||
ucsdata->dbcs_screenfont=false;
|
||||
}
|
||||
|
||||
vtmode = conf_get_int(conf, CONF_vtmode);
|
||||
if (vtmode == VT_OEMONLY) {
|
||||
ucsdata->font_codepage = 437;
|
||||
ucsdata->dbcs_screenfont = 0;
|
||||
ucsdata->dbcs_screenfont = false;
|
||||
if (ucsdata->line_codepage <= 0)
|
||||
ucsdata->line_codepage = GetACP();
|
||||
} else if (ucsdata->line_codepage <= 0)
|
||||
@ -493,7 +493,7 @@ void init_ucs(Conf *conf, struct unicode_data *ucsdata)
|
||||
vtmode == VT_POORMAN || ucsdata->font_codepage==0)) {
|
||||
|
||||
/* For DBCS and POOR fonts force direct to font */
|
||||
used_dtf = 1;
|
||||
used_dtf = true;
|
||||
for (i = 0; i < 32; i++)
|
||||
ucsdata->unitab_line[i] = (WCHAR) i;
|
||||
for (i = 32; i < 256; i++)
|
||||
@ -1201,7 +1201,7 @@ int mb_to_wc(int codepage, int flags, const char *mbstr, int mblen,
|
||||
return MultiByteToWideChar(codepage, flags, mbstr, mblen, wcstr, wclen);
|
||||
}
|
||||
|
||||
int is_dbcs_leadbyte(int codepage, char byte)
|
||||
bool is_dbcs_leadbyte(int codepage, char byte)
|
||||
{
|
||||
return IsDBCSLeadByteEx(codepage, byte);
|
||||
}
|
||||
|
@ -34,17 +34,17 @@ struct filereq_tag {
|
||||
* save==1 -> GetSaveFileName; save==0 -> GetOpenFileName
|
||||
* `state' is optional.
|
||||
*/
|
||||
BOOL request_file(filereq *state, OPENFILENAME *of, int preserve, int save)
|
||||
bool request_file(filereq *state, OPENFILENAME *of, bool preserve, bool save)
|
||||
{
|
||||
TCHAR cwd[MAX_PATH]; /* process CWD */
|
||||
BOOL ret;
|
||||
bool ret;
|
||||
|
||||
/* Get process CWD */
|
||||
if (preserve) {
|
||||
DWORD r = GetCurrentDirectory(lenof(cwd), cwd);
|
||||
if (r == 0 || r >= lenof(cwd))
|
||||
/* Didn't work, oh well. Stop trying to be clever. */
|
||||
preserve = 0;
|
||||
preserve = false;
|
||||
}
|
||||
|
||||
/* Open the file requester, maybe setting lpstrInitialDir */
|
||||
@ -321,7 +321,7 @@ void split_into_argv(char *cmdline, int *argc, char ***argv,
|
||||
p = cmdline; q = outputline; outputargc = 0;
|
||||
|
||||
while (*p) {
|
||||
int quote;
|
||||
bool quote;
|
||||
|
||||
/* Skip whitespace searching for start of argument. */
|
||||
while (*p && isspace(*p)) p++;
|
||||
@ -331,7 +331,7 @@ void split_into_argv(char *cmdline, int *argc, char ***argv,
|
||||
outputargv[outputargc] = q;
|
||||
outputargstart[outputargc] = p;
|
||||
outputargc++;
|
||||
quote = 0;
|
||||
quote = false;
|
||||
|
||||
/* Copy data into the argument until it's finished. */
|
||||
while (*p) {
|
||||
|
@ -16,4 +16,4 @@ void platform_get_x11_auth(struct X11Display *disp, Conf *conf)
|
||||
x11_get_auth_from_authfile(disp, xauthpath);
|
||||
}
|
||||
|
||||
const int platform_uses_x11_unix_by_default = false;
|
||||
const bool platform_uses_x11_unix_by_default = false;
|
||||
|
Reference in New Issue
Block a user