Use bool for function return values instead of 1 or 0.
This commit is contained in:
@@ -88,33 +88,33 @@ tcsetattr_nointr(int fd, int flags, struct termios *tp)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Restore saved terminal settings.
|
* Restore saved terminal settings.
|
||||||
* Returns 1 on success or 0 on failure.
|
* Returns true on success or false on failure.
|
||||||
*/
|
*/
|
||||||
int
|
bool
|
||||||
term_restore(int fd, int flush)
|
term_restore(int fd, bool flush)
|
||||||
{
|
{
|
||||||
debug_decl(term_restore, SUDO_DEBUG_UTIL)
|
debug_decl(term_restore, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
const int flags = flush ? (TCSASOFT|TCSAFLUSH) : (TCSASOFT|TCSADRAIN);
|
const int flags = flush ? (TCSASOFT|TCSAFLUSH) : (TCSASOFT|TCSADRAIN);
|
||||||
if (tcsetattr_nointr(fd, flags, &oterm) != 0)
|
if (tcsetattr_nointr(fd, flags, &oterm) != 0)
|
||||||
debug_return_int(0);
|
debug_return_bool(false);
|
||||||
changed = 0;
|
changed = 0;
|
||||||
}
|
}
|
||||||
debug_return_int(1);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disable terminal echo.
|
* Disable terminal echo.
|
||||||
* Returns 1 on success or 0 on failure.
|
* Returns true on success or false on failure.
|
||||||
*/
|
*/
|
||||||
int
|
bool
|
||||||
term_noecho(int fd)
|
term_noecho(int fd)
|
||||||
{
|
{
|
||||||
debug_decl(term_noecho, SUDO_DEBUG_UTIL)
|
debug_decl(term_noecho, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
if (!changed && tcgetattr(fd, &oterm) != 0)
|
if (!changed && tcgetattr(fd, &oterm) != 0)
|
||||||
debug_return_int(0);
|
debug_return_bool(false);
|
||||||
(void) memcpy(&term, &oterm, sizeof(term));
|
(void) memcpy(&term, &oterm, sizeof(term));
|
||||||
CLR(term.c_lflag, ECHO|ECHONL);
|
CLR(term.c_lflag, ECHO|ECHONL);
|
||||||
#ifdef VSTATUS
|
#ifdef VSTATUS
|
||||||
@@ -122,16 +122,16 @@ term_noecho(int fd)
|
|||||||
#endif
|
#endif
|
||||||
if (tcsetattr_nointr(fd, TCSADRAIN|TCSASOFT, &term) == 0) {
|
if (tcsetattr_nointr(fd, TCSADRAIN|TCSASOFT, &term) == 0) {
|
||||||
changed = 1;
|
changed = 1;
|
||||||
debug_return_int(1);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
debug_return_int(0);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set terminal to raw mode.
|
* Set terminal to raw mode.
|
||||||
* Returns 1 on success or 0 on failure.
|
* Returns true on success or false on failure.
|
||||||
*/
|
*/
|
||||||
int
|
bool
|
||||||
term_raw(int fd, int isig)
|
term_raw(int fd, int isig)
|
||||||
{
|
{
|
||||||
struct termios term;
|
struct termios term;
|
||||||
@@ -150,16 +150,16 @@ term_raw(int fd, int isig)
|
|||||||
SET(term.c_lflag, ISIG);
|
SET(term.c_lflag, ISIG);
|
||||||
if (tcsetattr_nointr(fd, TCSADRAIN|TCSASOFT, &term) == 0) {
|
if (tcsetattr_nointr(fd, TCSADRAIN|TCSASOFT, &term) == 0) {
|
||||||
changed = 1;
|
changed = 1;
|
||||||
debug_return_int(1);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
debug_return_int(0);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set terminal to cbreak mode.
|
* Set terminal to cbreak mode.
|
||||||
* Returns 1 on success or 0 on failure.
|
* Returns true on success or false on failure.
|
||||||
*/
|
*/
|
||||||
int
|
bool
|
||||||
term_cbreak(int fd)
|
term_cbreak(int fd)
|
||||||
{
|
{
|
||||||
debug_decl(term_cbreak, SUDO_DEBUG_UTIL)
|
debug_decl(term_cbreak, SUDO_DEBUG_UTIL)
|
||||||
@@ -181,24 +181,24 @@ term_cbreak(int fd)
|
|||||||
term_erase = term.c_cc[VERASE];
|
term_erase = term.c_cc[VERASE];
|
||||||
term_kill = term.c_cc[VKILL];
|
term_kill = term.c_cc[VKILL];
|
||||||
changed = 1;
|
changed = 1;
|
||||||
debug_return_int(1);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
debug_return_int(0);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy terminal settings from one descriptor to another.
|
* Copy terminal settings from one descriptor to another.
|
||||||
* Returns 1 on success or 0 on failure.
|
* Returns true on success or false on failure.
|
||||||
*/
|
*/
|
||||||
int
|
bool
|
||||||
term_copy(int src, int dst)
|
term_copy(int src, int dst)
|
||||||
{
|
{
|
||||||
struct termios tt;
|
struct termios tt;
|
||||||
debug_decl(term_copy, SUDO_DEBUG_UTIL)
|
debug_decl(term_copy, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
if (tcgetattr(src, &tt) != 0)
|
if (tcgetattr(src, &tt) != 0)
|
||||||
debug_return_int(0);
|
debug_return_bool(false);
|
||||||
if (tcsetattr_nointr(dst, TCSANOW|TCSASOFT, &tt) != 0)
|
if (tcsetattr_nointr(dst, TCSANOW|TCSASOFT, &tt) != 0)
|
||||||
debug_return_int(0);
|
debug_return_bool(false);
|
||||||
debug_return_int(1);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
|
@@ -163,11 +163,11 @@ void initprogname(const char *);
|
|||||||
int sudo_setgroups(int ngids, const GETGROUPS_T *gids);
|
int sudo_setgroups(int ngids, const GETGROUPS_T *gids);
|
||||||
|
|
||||||
/* term.c */
|
/* term.c */
|
||||||
int term_cbreak(int);
|
bool term_cbreak(int);
|
||||||
int term_copy(int, int);
|
bool term_copy(int, int);
|
||||||
int term_noecho(int);
|
bool term_noecho(int);
|
||||||
int term_raw(int, int);
|
bool term_raw(int, int);
|
||||||
int term_restore(int, int);
|
bool term_restore(int, bool);
|
||||||
|
|
||||||
/* ttysize.c */
|
/* ttysize.c */
|
||||||
void get_ttysize(int *rowp, int *colp);
|
void get_ttysize(int *rowp, int *colp);
|
||||||
|
Reference in New Issue
Block a user