diff options
author | Amadeusz Sławiński <amade@asmblr.net> | 2015-10-22 13:46:22 +0200 |
---|---|---|
committer | Amadeusz Sławiński <amade@asmblr.net> | 2015-12-06 12:53:04 +0100 |
commit | bdeb037e104005e09da11facf9a9be511e7fd032 (patch) | |
tree | 3d0d47ff0895492ad74c43db846e53c68ba41e6b | |
parent | b5a6d7688d35f8879bb18da44291164f31972747 (diff) | |
download | screen-bdeb037e104005e09da11facf9a9be511e7fd032.tar.gz |
more type conversions to bool
-rw-r--r-- | src/ansi.c | 13 | ||||
-rw-r--r-- | src/ansi.h | 9 | ||||
-rw-r--r-- | src/display.c | 4 | ||||
-rw-r--r-- | src/display.h | 5 | ||||
-rw-r--r-- | src/encoding.c | 2 | ||||
-rw-r--r-- | src/mark.c | 7 | ||||
-rw-r--r-- | src/mark.h | 8 | ||||
-rw-r--r-- | src/process.c | 147 | ||||
-rw-r--r-- | src/process.h | 7 | ||||
-rw-r--r-- | src/screen.c | 14 | ||||
-rw-r--r-- | src/screen.h | 8 | ||||
-rw-r--r-- | src/search.c | 2 | ||||
-rw-r--r-- | src/search.h | 2 | ||||
-rw-r--r-- | src/socket.c | 2 | ||||
-rw-r--r-- | src/termcap.c | 2 | ||||
-rw-r--r-- | src/tty.c | 8 | ||||
-rw-r--r-- | src/tty.h | 5 | ||||
-rw-r--r-- | src/utmp.c | 8 | ||||
-rw-r--r-- | src/utmp.h | 2 | ||||
-rw-r--r-- | src/window.c | 16 | ||||
-rw-r--r-- | src/window.h | 12 |
21 files changed, 144 insertions, 139 deletions
@@ -51,10 +51,11 @@ int Z0width, Z1width; /* widths for Z0/Z1 switching */ static Window *curr; /* window we are working on */ static int rows, cols; /* window size of the curr window */ -int visual_bell = 0; -int use_hardstatus = 1; /* display status line in hs */ +bool use_altscreen = false; /* enable alternate screen support? */ +bool use_hardstatus = true; /* display status line in hs */ +bool visual_bell = 0; + char *printcmd = 0; -int use_altscreen = 0; /* enable alternate screen support? */ uint32_t *blank; /* line filled with spaces */ uint32_t *null; /* line filled with '\0' */ @@ -584,7 +585,7 @@ void WriteString(Window *win, char *buf, size_t len) break; } if (curr->w_x == cols - 1) { - curr->w_x += curr->w_wrap ? 1 : -1; + curr->w_x += curr->w_wrap ? true : false; } if (curr->w_encoding != UTF8) { c = curr->w_mbcs; @@ -825,7 +826,7 @@ static void DoESC(int c, int intermediate) curr->w_ss = 0; break; case 'g': /* VBELL, private screen sequence */ - WBell(curr, 1); + WBell(curr, true); break; } break; @@ -2330,7 +2331,7 @@ int MFindUsedLine(Window *win, int ye, int ys) * Tricky: send only one bell even if the window is displayed * more than once. */ -void WBell(Window *win, int visual) +void WBell(Window *win, bool visual) { Canvas *cv; if (displays == NULL) @@ -155,7 +155,7 @@ void ChangeAKA (Window *, char *, size_t); void SetCharsets (Window *, char *); int GetAnsiStatus (Window *, char *); void WNewAutoFlow (Window *, int); -void WBell (Window *, int); +void WBell (Window *, bool); void WMsg (Window *, int, char *); void WChangeSize (Window *, int, int); void WindowChanged (Window *, int); @@ -163,6 +163,10 @@ int MFindUsedLine (Window *, int, int); /* global variables */ +extern bool visual_bell; +extern bool use_altscreen; +extern bool use_hardstatus; + extern char *printcmd; extern uint32_t *blank; @@ -170,9 +174,6 @@ extern uint32_t *null; extern uint64_t renditions[]; -extern int use_altscreen; -extern int use_hardstatus; -extern int visual_bell; extern int Z0width; extern int Z1width; diff --git a/src/display.c b/src/display.c index 72f3236..6a1fe37 100644 --- a/src/display.c +++ b/src/display.c @@ -78,15 +78,17 @@ Display *display, *displays; /* * The default values */ +bool defautonuke = false; + int defobuflimit = OBUF_MAX; int defnonblock = -1; int defmousetrack = 0; int defbracketed = 0; int defcursorstyle = 0; -int defautonuke = 0; int captionalways = 0; int captiontop = 0; int hardstatusemu = HSTATUS_IGNORE; + struct statusposstr statuspos = { STATUS_BOTTOM, STATUS_LEFT }; int focusminwidth, focusminheight; diff --git a/src/display.h b/src/display.h index bda825a..8c6f8f8 100644 --- a/src/display.h +++ b/src/display.h @@ -146,7 +146,7 @@ struct Display { int d_obuflenmax; /* len - max */ char *d_obufp; /* pointer in buffer */ int d_obuffree; /* free bytes in buffer */ - int d_auto_nuke; /* autonuke flag */ + bool d_auto_nuke; /* autonuke flag */ int d_nseqs; /* number of valid mappings */ int d_aseqs; /* number of allocated mappings */ unsigned char *d_kmaps; /* keymaps */ @@ -366,9 +366,10 @@ void ClearScrollbackBuffer (void); /* global variables */ +extern bool defautonuke; + extern int captionalways; extern int captiontop; -extern int defautonuke; extern int defmousetrack; extern int defnonblock; extern int defobuflimit; diff --git a/src/encoding.c b/src/encoding.c index 45967a4..556fe72 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -1071,7 +1071,7 @@ void ResetEncoding(Window *p) } else p->w_FontE = 0; if (encodings[encoding].noc1) - p->w_c1 = 0; + p->w_c1 = false; } /* decoded char: 32-bit <fontx><font><c2><c> @@ -63,7 +63,9 @@ static void MarkProcess(char **, size_t *); static void MarkAbort(void); static void MarkRedisplayLine(int, int, int, int); -int pastefont = 1; +bool compacthist = false; +bool join_with_cr = false; +bool pastefont = true; const struct LayFuncs MarkLf = { MarkProcess, @@ -75,9 +77,6 @@ const struct LayFuncs MarkLf = { 0 }; -int join_with_cr = 0; -int compacthist = 0; - unsigned char mark_key_tab[256]; /* this array must be initialised first! */ static struct markdata *markdata; @@ -67,11 +67,11 @@ void FreePaster (struct paster *); /* global variables */ -extern unsigned char mark_key_tab[]; +extern bool compacthist; +extern bool join_with_cr; +extern bool pastefont; -extern int compacthist; -extern int join_with_cr; -extern int pastefont; +extern unsigned char mark_key_tab[]; extern const struct LayFuncs MarkLf; diff --git a/src/process.c b/src/process.c index 42f5249..a827b83 100644 --- a/src/process.c +++ b/src/process.c @@ -74,13 +74,13 @@ static uint16_t NextWindow(void); static uint16_t PreviousWindow(void); static int MoreWindows(void); static void CollapseWindowlist(void); -static void LogToggle(int); +static void LogToggle(bool); static void ShowInfo(void); static void ShowDInfo(void); static Window *WindowByName(char *); static int WindowByNumber(char *); -static int ParseSwitch(struct action *, int *); -static int ParseOnOff(struct action *, int *); +static int ParseSwitch(struct action *, bool *); +static int ParseOnOff(struct action *, bool *); static int ParseWinNum(struct action *, int *); static int ParseBase(struct action *, char *, int *, int, char *); static int ParseSaveStr(struct action *, char **); @@ -121,8 +121,8 @@ struct plop plop_tab[MAX_PLOP_DEFS]; #endif int TtyMode = PTYMODE; -int hardcopy_append = 0; -int all_norefresh = 0; +bool hardcopy_append = false; +bool all_norefresh = 0; int zmodem_mode = 0; char *zmodem_sendcmd; char *zmodem_recvcmd; @@ -903,6 +903,7 @@ void DoAction(struct action *act, int key) char **args = act->args; int *argl = act->argl; Window *p; + bool b; int argc, n, msgok; int64_t i; int j; @@ -1048,9 +1049,9 @@ void DoAction(struct action *act, int key) (void)ParseOnOff(act, &nwin_default.Lflag); break; case RC_LOG: - n = fore->w_log ? 1 : 0; - ParseSwitch(act, &n); - LogToggle(n); + b = fore->w_log ? true : false; + ParseSwitch(act, &b); + LogToggle(b); break; case RC_SUSPEND: Detach(D_STOP); @@ -1708,11 +1709,8 @@ void DoAction(struct action *act, int key) if (args[0][0] == 'a') { fore->w_flow = (fore->w_flow & FLOW_AUTO) ? FLOW_AUTOFLAG | FLOW_AUTO | FLOW_NOW : FLOW_AUTOFLAG; - } else { - if (ParseOnOff(act, &n)) - break; - fore->w_flow = (fore->w_flow & FLOW_AUTO) | n; - } + } else if (ParseOnOff(act, &b) == 0) + fore->w_flow = (fore->w_flow & FLOW_AUTO) | b ? FLOW_NOW : 0; } else { if (fore->w_flow & FLOW_AUTOFLAG) fore->w_flow = (fore->w_flow & FLOW_AUTO) | FLOW_NOW; @@ -1729,20 +1727,17 @@ void DoAction(struct action *act, int key) case RC_DEFWRITELOCK: if (args[0][0] == 'a') nwin_default.wlock = WLOCK_AUTO; - else { - if (ParseOnOff(act, &n)) - break; - nwin_default.wlock = n ? WLOCK_ON : WLOCK_OFF; - } + else if (ParseOnOff(act, &b) == 0) + nwin_default.wlock = b ? WLOCK_ON : WLOCK_OFF; break; case RC_WRITELOCK: if (*args) { if (args[0][0] == 'a') { fore->w_wlock = WLOCK_AUTO; } else { - if (ParseOnOff(act, &n)) + if (ParseOnOff(act, &b)) break; - fore->w_wlock = n ? WLOCK_ON : WLOCK_OFF; + fore->w_wlock = b ? WLOCK_ON : WLOCK_OFF; } /* * user may have permission to change the writelock setting, @@ -1765,12 +1760,12 @@ void DoAction(struct action *act, int key) WriteString(fore, "\033c", 2); break; case RC_MONITOR: - n = fore->w_monitor != MON_OFF; + b = fore->w_monitor != MON_OFF; if (display) - n = n && (ACLBYTE(fore->w_mon_notify, D_user->u_id) & ACLBIT(D_user->u_id)); - if (ParseSwitch(act, &n)) + b = b && (ACLBYTE(fore->w_mon_notify, D_user->u_id) & ACLBIT(D_user->u_id)); + if (ParseSwitch(act, &b)) break; - if (n) { + if (b) { if (display) /* we tell only this user */ ACLBYTE(fore->w_mon_notify, D_user->u_id) |= ACLBIT(D_user->u_id); else @@ -2225,29 +2220,29 @@ void DoAction(struct action *act, int key) break; #if defined(UTMPOK) && defined(LOGOUTOK) case RC_LOGIN: - n = fore->w_slot != (slot_t) - 1; + b = fore->w_slot != (slot_t)(-1); if (*args && !strcmp(*args, "always")) { fore->w_lflag = 3; - if (!displays && n) - SlotToggle(n); + if (!displays && b) + SlotToggle(b); break; } if (*args && !strcmp(*args, "attached")) { fore->w_lflag = 1; - if (!displays && n) + if (!displays && b) SlotToggle(0); break; } - if (ParseSwitch(act, &n) == 0) - SlotToggle(n); + if (ParseSwitch(act, &b) == 0) + SlotToggle(b); break; case RC_DEFLOGIN: if (!strcmp(*args, "always")) nwin_default.lflag |= 2; else if (!strcmp(*args, "attached")) nwin_default.lflag &= ~2; - else - (void)ParseOnOff(act, &nwin_default.lflag); + else if (ParseOnOff(act, &b) == 0) + nwin_default.lflag = b ? 1 : 0; break; #endif case RC_DEFFLOW: @@ -2267,8 +2262,8 @@ void DoAction(struct action *act, int key) } if (args[0] && args[0][0] == 'a') nwin_default.flowflag = FLOW_AUTOFLAG; - else - (void)ParseOnOff(act, &nwin_default.flowflag); + else if (ParseOnOff(act, &b) == 0) + nwin_default.flowflag = b ? FLOW_NOW : 0; break; case RC_DEFWRAP: (void)ParseOnOff(act, &nwin_default.wrap); @@ -2277,37 +2272,39 @@ void DoAction(struct action *act, int key) (void)ParseOnOff(act, &nwin_default.c1); break; case RC_DEFBCE: - (void)ParseOnOff(act, &nwin_default.bce); + if (ParseOnOff(act, &b) == 0) + nwin_default.bce = b ? 1 : 0; break; case RC_DEFGR: - (void)ParseOnOff(act, &nwin_default.gr); + if (ParseOnOff(act, &b) == 0) + nwin_default.gr = b ? 1 : 0; break; case RC_DEFMONITOR: - if (ParseOnOff(act, &n) == 0) - nwin_default.monitor = (n == 0) ? MON_OFF : MON_ON; + if (ParseOnOff(act, &b) == 0) + nwin_default.monitor = b ? MON_ON : MON_OFF; break; case RC_DEFMOUSETRACK: - if (ParseOnOff(act, &n) == 0) - defmousetrack = (n == 0) ? 0 : 1000; + if (ParseOnOff(act, &b) == 0) + defmousetrack = b ? 1000 : 0; break; case RC_MOUSETRACK: if (!args[0]) { OutputMsg(0, "Mouse tracking for this display is turned %s", D_mousetrack ? "on" : "off"); - } else if (ParseOnOff(act, &n) == 0) { - D_mousetrack = n == 0 ? 0 : 1000; + } else if (ParseOnOff(act, &b) == 0) { + D_mousetrack = b ? 1000 : 0; if (D_fore) MouseMode(D_fore->w_mouse); } break; case RC_DEFSILENCE: - if (ParseOnOff(act, &n) == 0) - nwin_default.silence = (n == 0) ? SILENCE_OFF : SILENCE_ON; + if (ParseOnOff(act, &b) == 0) + nwin_default.silence = b ? SILENCE_ON : SILENCE_OFF; break; case RC_VERBOSE: if (!*args) OutputMsg(0, "W%s echo command when creating windows.", VerboseCreate ? "ill" : "on't"); - else if (ParseOnOff(act, &n) == 0) - VerboseCreate = n; + else + ParseOnOff(act, &VerboseCreate); break; case RC_HARDSTATUS: if (display) { @@ -2432,19 +2429,19 @@ void DoAction(struct action *act, int key) RedisplayDisplays(0); break; case RC_CONSOLE: - n = (console_window != 0); - if (ParseSwitch(act, &n)) + b = (console_window != 0); + if (ParseSwitch(act, &b)) break; - if (TtyGrabConsole(fore->w_ptyfd, n, rc_name)) + if (TtyGrabConsole(fore->w_ptyfd, b, rc_name)) break; - if (n == 0) + if (b == 0) OutputMsg(0, "%s: releasing console %s", rc_name, HostName); else if (console_window) OutputMsg(0, "%s: stealing console %s from window %d (%s)", rc_name, HostName, console_window->w_number, console_window->w_title); else OutputMsg(0, "%s: grabbing console %s", rc_name, HostName); - console_window = n ? fore : 0; + console_window = b ? fore : 0; break; case RC_ALLPARTIAL: if (ParseOnOff(act, &all_norefresh)) @@ -2455,8 +2452,8 @@ void DoAction(struct action *act, int key) OutputMsg(0, all_norefresh ? "No refresh on window change!\n" : "Window specific refresh\n"); break; case RC_PARTIAL: - (void)ParseSwitch(act, &n); - fore->w_norefresh = n; + (void)ParseSwitch(act, &b); + fore->w_norefresh = b; break; case RC_VBELL: if (ParseSwitch(act, &visual_bell) || !msgok) @@ -2558,15 +2555,15 @@ void DoAction(struct action *act, int key) WindowChanged((Window *)0, 0); break; case RC_SILENCE: - n = fore->w_silence != 0; + b = fore->w_silence != 0; j = fore->w_silencewait; if (args[0] && (args[0][0] == '-' || (args[0][0] >= '0' && args[0][0] <= '9'))) { if (ParseNum(act, &j)) break; n = j > 0; - } else if (ParseSwitch(act, &n)) + } else if (ParseSwitch(act, &b)) break; - if (n) { + if (b) { if (display) /* we tell only this user */ ACLBYTE(fore->w_lio_notify, D_user->u_id) |= ACLBIT(D_user->u_id); else @@ -3002,9 +2999,9 @@ void DoAction(struct action *act, int key) } break; case RC_MULTIUSER: - if (ParseOnOff(act, &n)) + if (ParseOnOff(act, &b)) break; - multi = n ? "" : 0; + multi = b ? "" : 0; chsock(); if (msgok) OutputMsg(0, "Multiuser mode %s", multi ? "enabled" : "disabled"); @@ -3017,8 +3014,8 @@ void DoAction(struct action *act, int key) if (*args && ((args[0][0] >= '0' && args[0][0] <= '9') || args[0][0] == '.')) { if (ParseNum1000(act, &j)) break; - } else if (!ParseSwitch(act, &j)) - j = j == 0 ? -1 : 1000; + } else if (!ParseSwitch(act, &b)) + j = b == 0 ? -1 : 1000; else break; if (msgok && j == -1) @@ -3035,8 +3032,8 @@ void DoAction(struct action *act, int key) if (*args && ((args[0][0] >= '0' && args[0][0] <= '9') || args[0][0] == '.')) { if (ParseNum1000(act, &defnonblock)) break; - } else if (!ParseOnOff(act, &defnonblock)) - defnonblock = defnonblock == 0 ? -1 : 1000; + } else if (!ParseOnOff(act, &b)) + defnonblock = b == 0 ? -1 : 1000; else break; if (display && *rc_name) { @@ -3048,8 +3045,10 @@ void DoAction(struct action *act, int key) case RC_GR: if (fore->w_gr == 2) fore->w_gr = 0; - if (ParseSwitch(act, &fore->w_gr) == 0 && msgok) + if (ParseSwitch(act, &b) == 0 && msgok) { + fore->w_gr = b ? 1 : 0; OutputMsg(0, "Will %suse GR", fore->w_gr ? "" : "not "); + } if (fore->w_gr == 0 && fore->w_FontE) fore->w_gr = 2; break; @@ -3105,11 +3104,11 @@ void DoAction(struct action *act, int key) nwin_default.encoding = n; break; case RC_DEFUTF8: - n = nwin_default.encoding == UTF8; - if (ParseSwitch(act, &n) == 0) { - nwin_default.encoding = n ? UTF8 : 0; + b = nwin_default.encoding == UTF8; + if (ParseSwitch(act, &b) == 0) { + nwin_default.encoding = b ? UTF8 : 0; if (msgok) - OutputMsg(0, "Will %suse UTF-8 encoding for new windows", n ? "" : "not "); + OutputMsg(0, "Will %suse UTF-8 encoding for new windows", b ? "" : "not "); } break; case RC_UTF8: @@ -4041,25 +4040,25 @@ void SetEscape(struct acluser *u, int e, int me) } } -static int ParseSwitch(struct action *act, int *var) +static int ParseSwitch(struct action *act, bool *var) { if (*act->args == 0) { - *var ^= 1; + *var ^= true; return 0; } return ParseOnOff(act, var); } -static int ParseOnOff(struct action *act, int *var) +static int ParseOnOff(struct action *act, bool *var) { int num = -1; char **args = act->args; if (args[1] == 0) { if (strcmp(args[0], "on") == 0) - num = 1; + num = true; else if (strcmp(args[0], "off") == 0) - num = 0; + num = false; } if (num < 0) { Msg(0, "%s: %s: invalid argument. Give 'on' or 'off'", rc_name, comms[act->nr].name); @@ -4437,7 +4436,7 @@ void KillWindow(Window *window) WindowChanged((Window *)0, 0); } -static void LogToggle(int on) +static void LogToggle(bool on) { char buf[1024]; @@ -5046,7 +5045,7 @@ void DoScreen(char *fn, char **av) nwin.monitor = MON_ON; break; case 'L': - nwin.Lflag = 1; + nwin.Lflag = true; break; default: Msg(0, "%s: screen: invalid option -%c.", fn, av[0][1]); diff --git a/src/process.h b/src/process.h index 7e13968..28b81ac 100644 --- a/src/process.h +++ b/src/process.h @@ -32,15 +32,16 @@ int StuffKey (int); /* global variables */ +extern bool hardcopy_append; + extern char *noargs[]; extern char NullStr[]; +extern char *zmodem_recvcmd; +extern char *zmodem_sendcmd; -extern int hardcopy_append; extern int idletimo; extern int kmap_extn; extern int zmodem_mode; -extern char *zmodem_recvcmd; -extern char *zmodem_sendcmd; extern int TtyMode; extern struct action idleaction; diff --git a/src/screen.c b/src/screen.c index a9a845b..229e308 100644 --- a/src/screen.c +++ b/src/screen.c @@ -101,7 +101,7 @@ char *home; char *screenlogfile; /* filename layout */ int log_flush = 10; /* flush interval in seconds */ -int logtstamp_on = 0; /* tstamp disabled */ +bool logtstamp_on = false; /* tstamp disabled */ char *logtstamp_string; /* stamp layout */ int logtstamp_after = 120; /* first tstamp after 120s */ char *hardcopydir = NULL; @@ -115,7 +115,7 @@ char *captionstring; char *timestring; char *wliststr; char *wlisttit; -int auto_detach = 1; +bool auto_detach = true; bool adaptflag, cmdflag, iflag, lsflag, quietflag, wipeflag, xflag; int rflag, dflag; int queryflag = -1; @@ -133,13 +133,13 @@ char HostName[MAXSTR]; int MasterPid, PanicPid; uid_t real_uid, eff_uid; gid_t real_gid, eff_gid; -int default_startup; +bool default_startup; int ZombieKey_destroy, ZombieKey_resurrect, ZombieKey_onerror; char *preselect = NULL; /* only used in Attach() */ char *screenencodings; -int cjkwidth; +bool cjkwidth; uint16_t maxwin; @@ -251,7 +251,7 @@ int main(int argc, char **argv) BufferFile = SaveStr(DEFAULT_BUFFERFILE); ShellProg = NULL; PowDetachString = 0; - default_startup = (argc > 1) ? 0 : 1; + default_startup = (argc > 1) ? false : true; adaptflag = false; VBellWait = VBELLWAIT * 1000; MsgWait = MSGWAIT * 1000; @@ -417,7 +417,7 @@ int main(int argc, char **argv) } break; case 'L': - nwin_options.Lflag = 1; + nwin_options.Lflag = true; break; case 'm': mflag = 1; @@ -1385,7 +1385,7 @@ void Detach(int mode) RestoreLoginSlot(); #endif if (displays->d_next == 0 && console_window) { - if (TtyGrabConsole(console_window->w_ptyfd, 0, "detach")) { + if (TtyGrabConsole(console_window->w_ptyfd, false, "detach")) { KillWindow(console_window); display = displays; /* restore display */ } diff --git a/src/screen.h b/src/screen.h index 3578490..b043e5c 100644 --- a/src/screen.h +++ b/src/screen.h @@ -269,21 +269,21 @@ extern char *VisualBellString; extern char **NewEnv; extern bool adaptflag; +extern bool auto_detach; +extern bool cjkwidth; +extern bool default_startup; extern bool hastruecolor; extern bool iflag; +extern bool logtstamp_on; extern bool lsflag; extern bool quietflag; extern bool wipeflag; extern bool xflag; extern int attach_fd; -extern int auto_detach; -extern int cjkwidth; -extern int default_startup; extern int dflag; extern int force_vt; extern int log_flush; -extern int logtstamp_on; extern int logtstamp_after; extern uint16_t maxwin; extern unsigned int multi_uid; diff --git a/src/search.c b/src/search.c index c54acdb..9811750 100644 --- a/src/search.c +++ b/src/search.c @@ -38,7 +38,7 @@ #define INPUTLINE (flayer->l_height - 1) -int search_ic; +bool search_ic; /******************************************************************** * VI style Search diff --git a/src/search.h b/src/search.h index 82fede0..729b0d7 100644 --- a/src/search.h +++ b/src/search.h @@ -6,6 +6,6 @@ void ISearch (int); /* global variables */ -extern int search_ic; +extern bool search_ic; #endif /* SCREEN_SEARCH_H */ diff --git a/src/socket.c b/src/socket.c index d133adf..4e8e078 100644 --- a/src/socket.c +++ b/src/socket.c @@ -1010,7 +1010,7 @@ static void FinishAttach(Message *m) if (!D_fore && !noshowwin) ShowWindows(-1); if (displays->d_next == 0 && console_window) { - if (TtyGrabConsole(console_window->w_ptyfd, 1, "reattach") == 0) + if (TtyGrabConsole(console_window->w_ptyfd, true, "reattach") == 0) Msg(0, "console %s is on window %d", HostName, console_window->w_number); } } diff --git a/src/termcap.c b/src/termcap.c index f3810c6..0928b3f 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -365,7 +365,7 @@ int InitTermcap(int width, int height) D_EIcost = CalcCost(D_EI); if (D_CAN) { - D_auto_nuke = 1; + D_auto_nuke = true; } if (D_COL > 0) { D_obufmax = D_COL; @@ -47,7 +47,7 @@ static void consredir_readev_fn(Event *, void *); -int separate_sids = 1; +bool separate_sids = true; static void DoSendBreak(int, int, int); static void SigAlrmDummy(int); @@ -765,7 +765,7 @@ static void consredir_readev_fn(Event * event, void *data) WriteString(console_window, p, n - p); } -int TtyGrabConsole(int fd, int on, char *rc_name) +int TtyGrabConsole(int fd, bool on, char *rc_name) { Display *d; #ifdef SRIOCSREDIR @@ -777,7 +777,7 @@ int TtyGrabConsole(int fd, int on, char *rc_name) (void)fd; /* unused */ - if (on > 0) { + if (on) { if (displays == 0) { Msg(0, "I need a display"); return -1; @@ -796,7 +796,7 @@ int TtyGrabConsole(int fd, int on, char *rc_name) close(consredirfd[1]); consredirfd[0] = consredirfd[1] = -1; } - if (on <= 0) + if (!on) return 0; #ifdef SRIOCSREDIR if ((cfd = secopen("/dev/console", O_RDWR | O_NOCTTY, 0)) == -1) { @@ -8,7 +8,7 @@ void SetTTY (int, struct mode *); void SetMode (struct mode *, struct mode *, int, int); void SetFlow (int); void SendBreak (Window *, int, int); -int TtyGrabConsole (int, int, char *); +int TtyGrabConsole (int, bool, char *); char *TtyGetModemStatus (int, char *); void brktty (int); struct baud_values *lookup_baud (int bps); @@ -18,7 +18,8 @@ int CheckTtyname (char *); /* global variables */ +extern bool separate_sids; + extern int breaktype; -extern int separate_sids; #endif /* SCREEN_TTY_H */ @@ -78,8 +78,8 @@ static int utmpfd = -1; /* * SlotToggle - modify the utmp slot of the fore window. * - * how > 0 do try to set a utmp slot. - * how = 0 try to withdraw a utmp slot. + * how == true try to set a utmp slot. + * how == false try to withdraw a utmp slot. * * w_slot = -1 window not logged in. * w_slot = 0 window not logged in, but should be logged in. @@ -87,7 +87,7 @@ static int utmpfd = -1; */ #ifndef UTMPOK -void SlotToggle(int how) +void SlotToggle(bool how) { #ifdef UTMPFILE Msg(0, "Unable to modify %s.\n", UTMPFILE); @@ -99,7 +99,7 @@ void SlotToggle(int how) #ifdef UTMPOK -void SlotToggle(int how) +void SlotToggle(bool how) { if (fore->w_type != W_TYPE_PTY) { Msg(0, "Can only work with normal windows.\n"); @@ -8,7 +8,7 @@ void RestoreLoginSlot (void); int SetUtmp (Window *); int RemoveUtmp (Window *); #endif /* UTMPOK */ -void SlotToggle (int); +void SlotToggle (bool); #ifdef CAREFULUTMP void CarefulUtmp (void); #else diff --git a/src/window.c b/src/window.c index 57805b9..ccdd51d 100644 --- a/src/window.c +++ b/src/window.c @@ -80,7 +80,7 @@ static int zmodem_parse(Window *, char *, int); Window **wtab; /* window table */ -int VerboseCreate = 0; /* XXX move this to user.h */ +bool VerboseCreate = false; /* XXX move this to user.h */ char DefaultShell[] = "/bin/sh"; #ifndef HAVE_EXECVPE @@ -100,11 +100,11 @@ struct NewWindow nwin_undef = { .monitor = -1, .wlock = -1, .silence = -1, - .wrap = -1, - .Lflag = -1, + .wrap = false, + .Lflag = false, .slow = -1, .gr = -1, - .c1 = -1, + .c1 = false, .bce = -1, .encoding = -1, .hstatus = (char *)0, @@ -125,11 +125,11 @@ struct NewWindow nwin_default = { .monitor = MON_OFF, .wlock = WLOCK_OFF, .silence = 0, - .wrap = 1, - .Lflag = 0, + .wrap = true, + .Lflag = false, .slow = 0, .gr = 0, - .c1 = 1, + .c1 = true, .bce = 0, .encoding = 0, .hstatus = (char *)0, @@ -745,7 +745,7 @@ void FreeWindow(Window *window) CloseDevice(window); if (window == console_window) { - TtyGrabConsole(-1, -1, "free"); + TtyGrabConsole(-1, false, "free"); console_window = 0; } if (window->w_log != NULL) diff --git a/src/window.h b/src/window.h index 2c39a32..cea7a2e 100644 --- a/src/window.h +++ b/src/window.h @@ -49,11 +49,11 @@ struct NewWindow { int monitor; int wlock; /* default writelock setting */ int silence; - int wrap; - int Lflag; /* logging */ + bool wrap; + bool Lflag; /* logging */ int slow; /* inter character milliseconds */ int gr; - int c1; + bool c1; int bce; int encoding; char *hstatus; @@ -184,7 +184,7 @@ struct Window { int Charsets[4]; } w_saved; int w_top, w_bot; /* scrollregion */ - int w_wrap; /* autowrap */ + bool w_wrap; /* autowrap */ int w_origin; /* origin mode */ int w_insert; /* window is in insert mode */ int w_keypad; /* keypad mode */ @@ -195,7 +195,7 @@ struct Window { int w_autolf; /* automatic linefeed */ char *w_hstatus; /* hardstatus line */ int w_gr; /* enable GR flag */ - int w_c1; /* enable C1 flag */ + bool w_c1; /* enable C1 flag */ int w_decodestate; /* state of our input decoder */ int w_mbcs; /* saved char for multibytes charset */ char w_string[MAXSTR]; @@ -326,7 +326,7 @@ void zmodem_abort(Window *, Display *); extern char DefaultShell[]; -extern int VerboseCreate; +extern bool VerboseCreate; extern const struct LayFuncs WinLf; extern struct NewWindow nwin_undef, nwin_default, nwin_options; |