# HG changeset patch # User Matti Hamalainen # Date 1670412025 -7200 # Node ID 93d0e1547842f030dfcc6fb1cbb0edf57cdc68c7 # Parent 3a3e4fc53ac7df7a3819fe02218b86c92d7fe7e3 th-libs now uses stdbool.h if possible, so we need to rename all BOOL/TRUE/FALSE to bool/true/false. diff -r 3a3e4fc53ac7 -r 93d0e1547842 Makefile --- a/Makefile Wed Dec 07 13:19:25 2022 +0200 +++ b/Makefile Wed Dec 07 13:20:25 2022 +0200 @@ -11,6 +11,7 @@ CFLAGS += -DUSE_XDG=1 CFLAGS += -DHAVE_STRING_H +CFLAGS += -DHAVE_STDBOOL_H CFLAGS += -DHAVE_INTTYPES_H #CFLAGS += -DHAVE_SYS_TYPES_H diff -r 3a3e4fc53ac7 -r 93d0e1547842 Makefile.cross-mingw --- a/Makefile.cross-mingw Wed Dec 07 13:19:25 2022 +0200 +++ b/Makefile.cross-mingw Wed Dec 07 13:20:25 2022 +0200 @@ -43,6 +43,7 @@ LDFLAGS += -s CFLAGS += -DHAVE_STRING_H +CFLAGS += -DHAVE_STDBOOL_H CFLAGS += -DHAVE_INTTYPES_H diff -r 3a3e4fc53ac7 -r 93d0e1547842 main.c --- a/main.c Wed Dec 07 13:19:25 2022 +0200 +++ b/main.c Wed Dec 07 13:20:25 2022 +0200 @@ -86,14 +86,14 @@ *optSite = "NN", *optNickSepStr = NULL; char optNickSep; -BOOL optDaemon = FALSE, - optProxyEnable = FALSE, - setIgnoreMode = FALSE, - optDebug = FALSE, - optLogEnable = FALSE, - optLogDaily = FALSE, - optOnlyFriendPrv = FALSE, - optShowHelp = FALSE; +bool optDaemon = false, + optProxyEnable = false, + setIgnoreMode = false, + optDebug = false, + optLogEnable = false, + optLogDaily = false, + optOnlyFriendPrv = false, + optShowHelp = false; char *setHomeDir = NULL, *setConfigDir = NULL, *setProxyURI = NULL; th_llist_t *setIgnoreList = NULL, @@ -178,7 +178,7 @@ } -BOOL argSplitStr(const char *src, const char *at, char **res1, char **res2) +bool argSplitStr(const char *src, const char *at, char **res1, char **res2) { char *pos, *tmp = th_strdup(src); @@ -189,29 +189,29 @@ *res1 = th_strdup_trim(tmp, TH_TRIM_BOTH); *res2 = th_strdup_trim(pos, TH_TRIM_BOTH); th_free(tmp); - return TRUE; + return true; } else { th_free(tmp); - return FALSE; + return false; } } -BOOL argHandleProxyURI(const char *uri) +bool argHandleProxyURI(const char *uri) { // Attempt to parse the proxy URI - BOOL ret = FALSE; + bool ret = false; char *proto = NULL, *rest = NULL, *host = NULL, *auth = NULL, *port = NULL; size_t len; - optProxyEnable = FALSE; + optProxyEnable = false; // Handle disable case if (th_strncasecmp(uri, "disab", 5) == 0) - return TRUE; + return true; // Split the URI if (!argSplitStr(uri, "://", &proto, &rest)) @@ -276,8 +276,8 @@ else optProxyAuthType = TH_PROXY_AUTH_NONE; - optProxyEnable = TRUE; - ret = TRUE; + optProxyEnable = true; + ret = true; out: th_free(proto); @@ -290,12 +290,12 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { case 0: - optShowHelp = TRUE; + optShowHelp = true; break; case 1: @@ -315,7 +315,7 @@ { THERR("Invalid color argument '%s', should be a RGB hex triplet '000000'.\n", optArg); - return FALSE; + return false; } THMSG(1, "Using color #%06x\n", optUserColor); break; @@ -325,19 +325,19 @@ break; case 6: - optDaemon = TRUE; + optDaemon = true; THMSG(1, "Running in pseudo-daemon mode.\n"); break; case 8: - optDebug = TRUE; + optDebug = true; THMSG(1, "Debug mode enabled.\n"); break; case 10: if (!argHandleProxyURI(optArg)) - return FALSE; + return false; break; case 13: @@ -347,24 +347,24 @@ if (!th_strcasecmp(nn_room_data[i].name, optArg)) { optPort = nn_room_data[i].port; - return TRUE; + return true; } THERR("Unsupported room '%s'.\n", optArg); - return FALSE; + return false; } break; default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { if (!optUserNameCmd) optUserNameCmd = currArg; @@ -373,19 +373,19 @@ else { THERR("Username '%s' already specified on commandline!\n", optUserNameCmd); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL nn_conn_send_msg(th_conn_t *conn, const char *user, const char *str) +bool nn_conn_send_msg(th_conn_t *conn, const char *user, const char *str) { char *msg; if (str == NULL) - return FALSE; + return false; msg = th_strdup_printf("%s%s", user, str); @@ -396,13 +396,13 @@ return ret == THERR_OK; } else - return FALSE; + return false; } -BOOL nn_conn_send_msg_v(th_conn_t *conn, const char *user, const char *fmt, ...) +bool nn_conn_send_msg_v(th_conn_t *conn, const char *user, const char *fmt, ...) { - BOOL res; + bool res; char *tmp; va_list ap; @@ -463,7 +463,7 @@ void printMsgF(nn_window_t *win, int flags, const char *fmt, ...); -BOOL nn_log_reopen(nn_window_t *win); +bool nn_log_reopen(nn_window_t *win); void printMsgConst(nn_window_t *win, int flags, const char *msg) @@ -628,23 +628,23 @@ } -BOOL nn_check_name_list(th_llist_t *list, const char *name) +bool nn_check_name_list(th_llist_t *list, const char *name) { th_llist_t *node; for (node = list; node != NULL; node = node->next) { if (th_strcasecmp(name, (char *) node->data) == 0) - return TRUE; + return true; } - return FALSE; + return false; } int nnproto_parse_user(th_conn_t *conn) { - BOOL isMine, isIgnored = FALSE; + bool isMine, isIgnored = false; char *name, *msg, *t; // Find start of the message @@ -903,7 +903,7 @@ int nn_parse_protocol(th_conn_t *conn) { - static BOOL protoCmdsInit = FALSE; + static bool protoCmdsInit = false; int i; if (!protoCmdsInit) @@ -911,7 +911,7 @@ for (i = 0; i < nprotoCmds; i++) protoCmds[i].len = strlen(protoCmds[i].name); - protoCmdsInit = TRUE; + protoCmdsInit = true; } for (i = 0; i < nprotoCmds; i++) @@ -1104,7 +1104,7 @@ { name = nn_username_decode(th_strdup(user->name)); printMsgQ(currWin, "Opening PRV query for '%s'.\n", name); - if (nnwin_open(name, TRUE)) + if (nnwin_open(name, true)) printMsgQ(currWin, "In PRV query with '%s'.\n", name); th_free(name); return 0; @@ -1315,7 +1315,7 @@ (void) conn; (void) buf; - appQuitFlag = TRUE; + appQuitFlag = true; return 0; } @@ -1431,7 +1431,7 @@ { // Server-side commands are just pass-through here char *tmp = nn_dblencode_str(buf); - BOOL result; + bool result; if (tmp == NULL) return -2; result = nn_conn_send_msg(conn, optUserNameEnc, tmp); th_free(tmp); @@ -1458,7 +1458,7 @@ } -nn_usercmd_t *nn_usercmd_match(th_llist_t *list, const char *pattern, const char *current, BOOL again) +nn_usercmd_t *nn_usercmd_match(th_llist_t *list, const char *pattern, const char *current, bool again) { nn_usercmd_t *curr; size_t len; @@ -1493,7 +1493,7 @@ int nn_handle_input(th_conn_t *conn, char *buf, size_t bufLen) { - BOOL result; + bool result; char *tmp; // Trim right side @@ -1566,12 +1566,12 @@ } -BOOL nn_tabcomplete_buffer(nn_editbuf_t *buf) +bool nn_tabcomplete_buffer(nn_editbuf_t *buf) { static char *previous = NULL, *pattern = NULL; char *str = buf->data; - BOOL again = FALSE, hasSeparator = FALSE, - hasSpace, newPattern = FALSE, isCommand; + bool again = false, hasSeparator = false, + hasSpace, newPattern = false, isCommand; size_t endPos, startPos = buf->pos; // previous word @@ -1588,7 +1588,7 @@ endPos = startPos; while (startPos > 0 && str[startPos - 1] != ' ') startPos--; while (endPos < buf->len - 1 && str[endPos + 1] != ' ') endPos++; - newPattern = TRUE; + newPattern = true; } else // previous word, new pattern @@ -1597,10 +1597,10 @@ startPos -= 1; endPos = startPos; while (startPos > 0 && str[startPos - 1] != ' ') startPos--; - newPattern = TRUE; + newPattern = true; } else - return FALSE; + return false; // Check if this is a command completion isCommand = (str[0] == '/' && startPos == 0); @@ -1609,8 +1609,8 @@ { endPos--; if (startPos > 0) - return FALSE; - hasSeparator = TRUE; + return false; + hasSeparator = true; } hasSpace = (buf->pos > 0 && str[buf->pos - 1] == ' ') || @@ -1621,7 +1621,7 @@ // Get pattern, check if it matches previous pattern and set 'again' flag char *npattern = nn_editbuf_get_string(buf, startPos, endPos); if (pattern && npattern && th_strcasecmp(npattern, pattern) == 0) - again = TRUE; + again = true; th_free(pattern); pattern = npattern; @@ -1633,7 +1633,7 @@ } if (!pattern) - return FALSE; + return false; if (isCommand) { @@ -1647,7 +1647,7 @@ nn_editbuf_insert(buf, i++, ' '); nn_tabcomplete_finish(buf, &previous, startPos, cmd->name); - return TRUE; + return true; } } else @@ -1672,15 +1672,15 @@ nn_editbuf_insert(buf, i++, ' '); nn_tabcomplete_finish(buf, &previous, startPos, user->name); - return TRUE; + return true; } } - return FALSE; + return false; } -BOOL processUserInput(int c, nn_editbuf_t *editBuf, nn_editstate_t *editState) +bool processUserInput(int c, nn_editbuf_t *editBuf, nn_editstate_t *editState) { // Chat window switching via Meta/Esc-[1..9] if (c >= 0x5001 && c <= 0x5009) @@ -1689,7 +1689,7 @@ if (win != NULL) { currWin = win; - editState->update = TRUE; + editState->update = true; } } else @@ -1721,7 +1721,7 @@ if (result < 0) { errorMsg("Fatal error handling user input: %s\n", editBuf->data); - editState->isError = TRUE; + editState->isError = true; } else { @@ -1746,7 +1746,7 @@ currWin->pos = 0; if (oldPos != currWin->pos) - editState->update = TRUE; + editState->update = true; } break; @@ -1783,7 +1783,7 @@ case KEY_F(9): // F9 = Quit printMsg(currWin, "Quitting per user request (%d/0x%x).\n", c, c); - appQuitFlag = TRUE; + appQuitFlag = true; break; case 0x09: // Tab = complete username or command @@ -1791,33 +1791,33 @@ break; default: - return FALSE; + return false; } - return TRUE; + return true; } -BOOL processUserPrompt(int c, nn_editbuf_t *editBuf, nn_editstate_t *editState) +bool processUserPrompt(int c, nn_editbuf_t *editBuf, nn_editstate_t *editState) { (void) editBuf; switch (c) { case KEY_ENTER: - editState->done = TRUE; + editState->done = true; break; case KEY_F(9): // F9 = Quit printMsg(currWin, "Quitting per user request (%d/0x%x).\n", c, c); - appQuitFlag = TRUE; + appQuitFlag = true; break; default: - return FALSE; + return false; } - return TRUE; + return true; } @@ -1830,12 +1830,12 @@ void clearEditState(nn_editstate_t *st) { memset(st, 0, sizeof(nn_editstate_t)); - st->insertMode = TRUE; + st->insertMode = true; st->debugMsg = debugMsg; } -BOOL nn_log_open(nn_window_t *win) +bool nn_log_open(nn_window_t *win) { char *path = NULL, *plt; #ifndef TH_PLAT_WINDOWS @@ -1843,7 +1843,7 @@ #endif if (!optLogEnable || optLogPath == NULL) - return FALSE; + return false; plt = strrchr(optLogPath, TH_DIR_SEPARATOR_CHR); if (plt == NULL || plt[1] != 0) @@ -1875,7 +1875,7 @@ char *cleaned; if ((cleaned = th_strdup(win->id)) == NULL) - return FALSE; + return false; for (pos = 0; cleaned[pos] != 0; pos++) { @@ -1909,7 +1909,7 @@ printMsg(win, "Logging to '%s'.\n", win->logFilename); th_free(path); - return TRUE; + return true; error: th_free(path); @@ -1921,7 +1921,7 @@ if (logFd >= 0) close(logFd); #endif - return FALSE; + return false; } @@ -1935,7 +1935,7 @@ } -BOOL nn_log_reopen(nn_window_t *win) +bool nn_log_reopen(nn_window_t *win) { nn_log_close(win); return nn_log_open(win); @@ -1961,7 +1961,7 @@ { char *tmpStr; int index, updateCount = 0, ret; - BOOL argsOK, colorSet = FALSE; + bool argsOK, colorSet = false; th_conn_t *conn = NULL; nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE); nn_editstate_t editState; @@ -2190,7 +2190,7 @@ printMsg(NULL, "%s\n", th_prog_author); printMsg(NULL, "%s\n", th_prog_license); - nnwin_update(TRUE, FALSE, NULL, optUserName, optUserColor); + nnwin_update(true, false, NULL, optUserName, optUserColor); // Check if we have username and password if (optUserName == NULL || optPassword == NULL) @@ -2199,14 +2199,14 @@ printMsg(NULL, "You can avoid doing this every time by issuing '/save' after logging in.\n"); printMsg(NULL, "Enter your NN username ...\n"); - optUserName = nnwin_prompt_requester(FALSE, &editState, processUserPrompt, updateUserPrompt); + optUserName = nnwin_prompt_requester(false, &editState, processUserPrompt, updateUserPrompt); if (appQuitFlag) goto err_exit; - editState.mask = TRUE; + editState.mask = true; printMsg(NULL, "Enter your NN password ...\n"); - optPassword = nnwin_prompt_requester(TRUE, &editState, processUserPrompt, updateUserPrompt); - editState.mask = FALSE; + optPassword = nnwin_prompt_requester(true, &editState, processUserPrompt, updateUserPrompt); + editState.mask = false; if (appQuitFlag) goto err_exit; } @@ -2300,7 +2300,7 @@ while (!editState.isError && !appQuitFlag) { int retries = 3, cres; - editState.update = FALSE; + editState.update = false; packet_retry: cres = th_conn_pull(conn); @@ -2328,20 +2328,20 @@ th_conn_buf_skip(conn, strlen(conn->base.ptr) + 1); } else - editState.isError = TRUE; + editState.isError = true; } } else if (cres < TH_CONN_ERROR || !th_conn_check(conn)) - editState.isError = TRUE; + editState.isError = true; // Handle user input - BOOL flushed = FALSE; + bool flushed = false; if (appCursesInit) { nnwin_input_process(editBuf, &editState, processUserInput); nnwin_update(editState.update, editState.mask, editBuf, optUserName, optUserColor); - flushed = TRUE; + flushed = true; } if (++updateCount > 10) @@ -2357,13 +2357,13 @@ if (!colorSet) { - colorSet = TRUE; + colorSet = true; nn_conn_send_msg_v(conn, optUserNameEnc, "%%2FSetFontColor%%20%%2Dcolor%%20%06X", optUserColor); } if (appCursesInit && !flushed) { - nnwin_update(FALSE, editState.mask, editBuf, optUserName, optUserColor); + nnwin_update(false, editState.mask, editBuf, optUserName, optUserColor); } updateCount = 0; @@ -2377,7 +2377,7 @@ char *tmp; printMsg(NULL, "Press enter to exit.\n"); clearEditState(&editState); - tmp = nnwin_prompt_requester(FALSE, &editState, processUserPrompt, updateUserPrompt); + tmp = nnwin_prompt_requester(false, &editState, processUserPrompt, updateUserPrompt); th_free(tmp); } diff -r 3a3e4fc53ac7 -r 93d0e1547842 ui.c --- a/ui.c Wed Dec 07 13:19:25 2022 +0200 +++ b/ui.c Wed Dec 07 13:20:25 2022 +0200 @@ -10,7 +10,7 @@ nn_window_t *chatWindows[SET_MAX_WINDOWS], *currWin = NULL; -BOOL appCursesInit = FALSE, appQuitFlag = FALSE; +bool appCursesInit = false, appQuitFlag = false; int cursorVisible = ERR, scrWidth, scrHeight; @@ -71,7 +71,7 @@ } -BOOL nnwin_init(int delay) +bool nnwin_init(int delay) { // Sanity check the terminal size if (LINES < 0 || LINES > 1000) LINES = 24; @@ -80,11 +80,11 @@ // Initialize (n)curses library and terminal settings initscr(); raw(); - keypad(stdscr, TRUE); + keypad(stdscr, true); noecho(); - meta(stdscr, TRUE); + meta(stdscr, true); timeout(delay); - scrollok(stdscr, FALSE); + scrollok(stdscr, false); cursorVisible = curs_set(1); if (has_colors()) @@ -109,7 +109,7 @@ init_pair(16, COLOR_CYAN, COLOR_RED); } - appCursesInit = TRUE; + appCursesInit = true; nnwin_reset(); #ifdef PDCURSES @@ -121,7 +121,7 @@ nn_log_open(chatWindows[0]); currWin = chatWindows[0]; - return TRUE; + return true; } @@ -165,16 +165,16 @@ } -BOOL nnwin_open(const char *name, BOOL curwin) +bool nnwin_open(const char *name, bool curwin) { nn_window_t *res; int i; if (name == NULL) - return FALSE; + return false; if ((res = nn_window_new(name)) == NULL) - return FALSE; + return false; nn_log_open(res); @@ -185,10 +185,10 @@ chatWindows[i] = res; if (curwin) currWin = res; - return TRUE; + return true; } - return FALSE; + return false; } @@ -208,7 +208,7 @@ } -static BOOL nnwin_get_color(char const **s, int *col) +static bool nnwin_get_color(char const **s, int *col) { int val = 0; @@ -219,33 +219,33 @@ (*s)++; } if (**s != '½') - return FALSE; + return false; if (val < 9) *col = A_DIM | COLOR_PAIR(val); else if (val < 30) *col = A_BOLD | COLOR_PAIR(val - 9); - return TRUE; + return true; } #define QPUTCH(ch) nnwin_putch(&(win->line->buf), &(win->line->bufsize), &(win->line->len), col, ch) -static BOOL nnwin_putch(int **buf, size_t *bufsize, size_t *len, int color, char ch) +static bool nnwin_putch(int **buf, size_t *bufsize, size_t *len, int color, char ch) { if (*buf == NULL || *len + 1 >= *bufsize) { *bufsize += TH_BUFGROW; *buf = (int *) th_realloc(*buf, *bufsize * sizeof(int)); if (*buf == NULL) - return FALSE; + return false; } (*buf)[*len] = ((unsigned char) ch) | color; (*len)++; - return TRUE; + return true; } @@ -283,7 +283,7 @@ { th_ringbuf_add(win->data, win->line); win->line = NULL; - win->dirty = TRUE; + win->dirty = true; } else if (*s != '\r') { @@ -297,7 +297,7 @@ } -static void nnwin_print_str(WINDOW *win, const char *fmt, BOOL clip) +static void nnwin_print_str(WINDOW *win, const char *fmt, bool clip) { const char *s = fmt; int col = 0; @@ -329,10 +329,10 @@ } -void nnwin_update(BOOL force, BOOL mask, nn_editbuf_t *ebuf, const char *username, const unsigned int usercolor) +void nnwin_update(bool force, bool mask, nn_editbuf_t *ebuf, const char *username, const unsigned int usercolor) { int sx, sy; - BOOL changed = FALSE; + bool changed = false; // Clear screen if forced or main or editbuf are dirty if (force || (currWin != NULL && currWin->dirty) || (ebuf != NULL && ebuf->dirty)) @@ -343,8 +343,8 @@ wattrset(stdscr, A_NORMAL); wbkgdset(stdscr, COLOR_PAIR(0)); werase(stdscr); - force = TRUE; - changed = TRUE; + force = true; + changed = true; } else { @@ -358,7 +358,7 @@ int y, offs; th_ringbuf_t *buf = currWin->data; - changed = TRUE; + changed = true; for (y = scrHeight - 4, offs = buf->size - 1 - currWin->pos; offs >= 0 && y > 0; offs--) { @@ -394,7 +394,7 @@ } } - currWin->dirty = FALSE; + currWin->dirty = false; } // Update statusline @@ -428,7 +428,7 @@ wmove(stdscr, scrHeight - 4, 0); wbkgdset(stdscr, COLOR_PAIR(10)); wclrtoeol(stdscr); - nnwin_print_str(stdscr, tmpStr, TRUE); + nnwin_print_str(stdscr, tmpStr, true); for (i = 0; i < SET_MAX_WINDOWS; i++) { @@ -453,7 +453,7 @@ wattrset(stdscr, A_NORMAL); wbkgdset(stdscr, COLOR_PAIR(0)); - ebuf->dirty = FALSE; + ebuf->dirty = false; if (mask) { size_t i; @@ -470,7 +470,7 @@ } wmove(stdscr, scrHeight - 3 + yoffs, xoffs); - changed = TRUE; + changed = true; } if (changed) @@ -479,7 +479,7 @@ void nnwin_input_process(nn_editbuf_t *editBuf, nn_editstate_t *editState, - BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *)) + bool (*callback)(int, nn_editbuf_t *, nn_editstate_t *)) { int c, cnt = 0; @@ -584,7 +584,7 @@ erase(); timeout(SET_DELAY); nnwin_reset(); - editState->update = TRUE; + editState->update = true; break; #endif @@ -594,7 +594,7 @@ editBuf->pos--; while (editBuf->pos > 0 && !isspace((int) editBuf->data[editBuf->pos - 1])) editBuf->pos--; - editBuf->dirty = TRUE; + editBuf->dirty = true; break; case 0x206: // ctrl+right arrow = Skip words right @@ -603,7 +603,7 @@ editBuf->pos++; while (editBuf->pos < editBuf->len && !isspace((int) editBuf->data[editBuf->pos])) editBuf->pos++; - editBuf->dirty = TRUE; + editBuf->dirty = true; break; case KEY_HOME: @@ -642,7 +642,7 @@ break; case 0x0c: // Ctrl + L - editState->update = TRUE; + editState->update = true; break; case ERR: @@ -671,14 +671,14 @@ -char *nnwin_prompt_requester(BOOL allowEmpty, nn_editstate_t *editState, - BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *), +char *nnwin_prompt_requester(bool allowEmpty, nn_editstate_t *editState, + bool (*callback)(int, nn_editbuf_t *, nn_editstate_t *), void (*update)(nn_editbuf_t *, nn_editstate_t *)) { nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE); char *res; - editState->done = FALSE; + editState->done = false; while (!editState->isError && !appQuitFlag && !editState->done) { nnwin_input_process(editBuf, editState, callback); diff -r 3a3e4fc53ac7 -r 93d0e1547842 ui.h --- a/ui.h Wed Dec 07 13:19:25 2022 +0200 +++ b/ui.h Wed Dec 07 13:20:25 2022 +0200 @@ -40,7 +40,7 @@ { th_ringbuf_t *data; // "Backbuffer" data for this window int pos; // Current position in the window, 0 = real time - BOOL dirty; + bool dirty; int num; char *id; // Chatter ID, NULL = main window @@ -57,41 +57,41 @@ typedef struct { time_t prevKeepAlive; - BOOL insertMode, isError, update, mask, done; + bool insertMode, isError, update, mask, done; th_conn_t *conn; void (*debugMsg)(const char *fmt, ...); } nn_editstate_t; extern nn_window_t *currWin; -extern BOOL appCursesInit, appQuitFlag; +extern bool appCursesInit, appQuitFlag; extern int scrHeight, scrWidth; -BOOL nnwin_init(int delay); +bool nnwin_init(int delay); void nnwin_shutdown(); void nnwin_reset(void); -void nnwin_update(BOOL force, BOOL mask, nn_editbuf_t *ebuf, const char *username, const unsigned int usercolor); +void nnwin_update(bool force, bool mask, nn_editbuf_t *ebuf, const char *username, const unsigned int usercolor); nn_window_t * nnwin_main_window(); nn_window_t * nnwin_get(const int index); nn_window_t * nnwin_find(const char *id); void nnwin_set_current(nn_window_t *); -BOOL nnwin_open(const char *name, BOOL curwin); +bool nnwin_open(const char *name, bool curwin); void nnwin_close(nn_window_t *win); int nnwin_print(nn_window_t *win, const char *fmt); void nnwin_input_process(nn_editbuf_t *editBuf, nn_editstate_t *editState, - BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *)); + bool (*callback)(int, nn_editbuf_t *, nn_editstate_t *)); -char * nnwin_prompt_requester(BOOL allowEmpty, nn_editstate_t *, - BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *), +char * nnwin_prompt_requester(bool allowEmpty, nn_editstate_t *, + bool (*callback)(int, nn_editbuf_t *, nn_editstate_t *), void (*update)(nn_editbuf_t *, nn_editstate_t *)); -BOOL nn_log_open(nn_window_t *win); +bool nn_log_open(nn_window_t *win); void nn_log_close(nn_window_t *win); #endif diff -r 3a3e4fc53ac7 -r 93d0e1547842 util.c --- a/util.c Wed Dec 07 13:19:25 2022 +0200 +++ b/util.c Wed Dec 07 13:20:25 2022 +0200 @@ -7,19 +7,19 @@ #include -BOOL str_get_timestamp(char *str, size_t len, const char *fmt) +bool str_get_timestamp(char *str, size_t len, const char *fmt) { time_t stamp = time(NULL); struct tm *stamp_tm; if ((stamp_tm = localtime(&stamp)) != NULL) { strftime(str, len, fmt, stamp_tm); - return TRUE; + return true; } else { str[0] = 0; - return FALSE; + return false; } } @@ -237,12 +237,12 @@ while (*s) { int i; - BOOL found = FALSE; + bool found = false; for (i = 0; i < numHTMLEntities; i++) if (HTMLEntities[i].c == *s) { PUSHSTR(HTMLEntities[i].ent); - found = TRUE; + found = true; break; } if (!found) PUSHCHAR(*s); @@ -272,7 +272,7 @@ if (*s == '&') { int i; - BOOL found = FALSE; + bool found = false; for (i = 0; i < numHTMLEntities; i++) { const html_entity_t *ent = &HTMLEntities[i]; @@ -281,7 +281,7 @@ { PUSHCHAR(ent->c); s += len; - found = TRUE; + found = true; break; } } @@ -333,7 +333,7 @@ else buf->data[pos] = ch; - buf->dirty = TRUE; + buf->dirty = true; return 0; } @@ -353,7 +353,7 @@ } buf->len++; - buf->dirty = TRUE; + buf->dirty = true; return 0; } @@ -364,7 +364,7 @@ { memmove(&(buf->data[pos]), &(buf->data[pos+1]), buf->len - pos); buf->len--; - buf->dirty = TRUE; + buf->dirty = true; return 0; } else @@ -376,7 +376,7 @@ { buf->len = 0; buf->pos = 0; - buf->dirty = TRUE; + buf->dirty = true; } @@ -386,7 +386,7 @@ res->data = (char *) th_malloc(n); res->size = n; - res->dirty = TRUE; + res->dirty = true; return res; } @@ -406,7 +406,7 @@ { memcpy(dst->data, src->data, src->size); dst->pos = dst->len = src->len; - dst->dirty = TRUE; + dst->dirty = true; } @@ -457,7 +457,7 @@ else buf->pos = pos; - buf->dirty = TRUE; + buf->dirty = true; } @@ -550,7 +550,7 @@ } -nn_user_t *nn_userhash_match(const nn_userhash_t *list, const char *pattern, const char *current, BOOL again) +nn_user_t *nn_userhash_match(const nn_userhash_t *list, const char *pattern, const char *current, bool again) { uint8_t hash; diff -r 3a3e4fc53ac7 -r 93d0e1547842 util.h --- a/util.h Wed Dec 07 13:19:25 2022 +0200 +++ b/util.h Wed Dec 07 13:20:25 2022 +0200 @@ -34,7 +34,7 @@ nn_userhash_t *nn_userhash_new(void); nn_user_t * nn_userhash_foreach(const nn_userhash_t *, int (*func)(const nn_user_t *, void *userdata), void *data); -nn_user_t * nn_userhash_match(const nn_userhash_t *list, const char *str, const char *current, BOOL again); +nn_user_t * nn_userhash_match(const nn_userhash_t *list, const char *str, const char *current, bool again); int nn_userhash_insert(nn_userhash_t *, const char *name); int nn_userhash_delete(nn_userhash_t *, const char *name); void nn_userhash_free(nn_userhash_t *); @@ -58,7 +58,7 @@ { size_t pos, len, size; char *data; - BOOL dirty; + bool dirty; } nn_editbuf_t; @@ -85,7 +85,7 @@ void nn_strtuple_free(nn_strtuple_t *); -BOOL str_get_timestamp(char *str, size_t len, const char *fmt); +bool str_get_timestamp(char *str, size_t len, const char *fmt); char * str_trim_left(char *buf); char * str_trim_right(char *buf); int str_compare(const void *s1, const void *s2);