From d1f575667000f4f5a3555b57c9c825df0a043c65d928cd373011970fd7d53f4e Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 21 Aug 2025 13:59:12 -0400 Subject: [PATCH] Use standard bool types. I'm using `stdbool.h` for the few remaining C files. That will have to change, soon. --- d_size.h | 1 - dlib/dlib.cc | 4 +- dlib/dlib.h | 4 +- dpi/cookies.cc | 132 +++++++++++++++++++++--------------------- dpi/file.cc | 4 +- src/IO/IO.cc | 14 ++--- src/IO/Url.h | 2 +- src/IO/http.cc | 24 ++++---- src/IO/tls_openssl.cc | 86 +++++++++++++-------------- src/bw.cc | 2 +- src/bw.hh | 2 +- src/cache.cc | 34 +++++------ src/cache.hh | 2 +- src/capi.cc | 12 ++-- src/cookies.cc | 12 ++-- src/decode.cc | 2 +- src/decode.hh | 4 +- src/domain.cc | 26 ++++----- src/domain.hh | 2 +- src/hsts.cc | 16 ++--- src/hsts.hh | 2 +- src/html.cc | 18 +++--- src/html.hh | 2 +- src/html_common.hh | 2 +- src/menu.cc | 6 +- src/menu.hh | 6 +- src/nav.cc | 9 +-- src/prefs.hh | 86 +++++++++++++-------------- src/prefsparser.cc | 2 +- src/uicmd.cc | 6 +- src/uicmd.hh | 6 +- src/url.cc | 15 +++-- src/url.hh | 2 +- src/utf8.cc | 8 +-- src/utf8.hh | 4 +- 35 files changed, 280 insertions(+), 279 deletions(-) diff --git a/d_size.h b/d_size.h index 908a222..8786551 100644 --- a/d_size.h +++ b/d_size.h @@ -18,7 +18,6 @@ typedef unsigned char uchar_t; typedef unsigned short ushort_t; typedef unsigned long ulong_t; typedef unsigned int uint_t; -typedef unsigned char bool_t; #endif /* __D_SIZE_H__ */ diff --git a/dlib/dlib.cc b/dlib/dlib.cc index 331b2d7..531d62c 100644 --- a/dlib/dlib.cc +++ b/dlib/dlib.cc @@ -29,7 +29,7 @@ #include "dlib.h" -static bool_t dLib_show_msg = TRUE; +static bool dLib_show_msg = TRUE; /* dlib msgs go to stderr to avoid problems with filter dpis */ #define DLIB_MSG(...) \ @@ -890,7 +890,7 @@ int dParser_parse_rc_line(char **line, char **name, char **value) /* *- Dlib messages ------------------------------------------------------------- */ -void dLib_show_messages(bool_t show) +void dLib_show_messages(bool show) { dLib_show_msg = show; } diff --git a/dlib/dlib.h b/dlib/dlib.h index 1f71f99..400a15f 100644 --- a/dlib/dlib.h +++ b/dlib/dlib.h @@ -6,6 +6,8 @@ #include /* for va_list */ #include /* for strerror */ +#include + #include "d_size.h" #ifdef __cplusplus @@ -175,7 +177,7 @@ int dParser_parse_rc_line(char **line, char **name, char **value); /* *- Dlib messages ------------------------------------------------------------- */ -void dLib_show_messages(bool_t show); +void dLib_show_messages(bool show); /* *- Misc utility functions ---------------------------------------------------- diff --git a/dpi/cookies.cc b/dpi/cookies.cc index 6afa7c2..cbebb26 100644 --- a/dpi/cookies.cc +++ b/dpi/cookies.cc @@ -103,9 +103,9 @@ typedef struct { char *domain; char *path; time_t expires_at; - bool_t host_only; - bool_t secure; - bool_t session_only; + bool host_only; + bool secure; + bool session_only; long last_used; } CookieData_t; @@ -130,7 +130,7 @@ static int num_ccontrol_max = 1; static CookieControlAction default_action = COOKIE_DENY; static long cookies_use_counter = 0; -static bool_t disabled; +static bool disabled; static FILE *file_stream; static const char *const cookies_txt_header_str = "# HTTP Cookie File\n" @@ -279,15 +279,15 @@ static void Cookies_load_cookies(FILE *stream) char *line_marker = line; CookieData_t *cookie = dNew0(CookieData_t, 1); - cookie->session_only = FALSE; + cookie->session_only = false; cookie->domain = dStrdup(dStrsep(&line_marker, "\t")); piece = dStrsep(&line_marker, "\t"); if (piece != NULL && piece[0] == 'F') - cookie->host_only = TRUE; + cookie->host_only = true; cookie->path = dStrdup(dStrsep(&line_marker, "\t")); piece = dStrsep(&line_marker, "\t"); if (piece != NULL && piece[0] == 'T') - cookie->secure = TRUE; + cookie->secure = true; piece = dStrsep(&line_marker, "\t"); if (piece != NULL) { /* There is some problem with simply putting the maximum value @@ -318,7 +318,7 @@ static void Cookies_load_cookies(FILE *stream) Cookies_free_cookie(cookie); continue; } else if (action == COOKIE_ACCEPT_SESSION) { - cookie->session_only = TRUE; + cookie->session_only = true; } /* Save cookie in memory */ @@ -341,7 +341,7 @@ static void Cookies_init(void) struct tm future_tm = {7, 14, 3, 19, 0, 138, 0, 0, 0, 0, 0}; /* Default setting */ - disabled = TRUE; + disabled = true; cookies_epoch_time = mktime(&cookies_epoch_tm); cookies_future_time = mktime(&future_tm); @@ -457,7 +457,7 @@ static void Cookies_save_and_free(void) /* * Month parsing */ -static bool_t Cookies_get_month(struct tm *tm, const char **str) +static bool Cookies_get_month(struct tm *tm, const char **str) { static const char *const months[] = { "Jan", "Feb", "Mar", @@ -472,10 +472,10 @@ static bool_t Cookies_get_month(struct tm *tm, const char **str) _MSG("Found month: %s\n", months[i]); tm->tm_mon = i; *str += 3; - return TRUE; + return true; } } - return FALSE; + return false; } /* @@ -505,47 +505,47 @@ static int Cookies_get_timefield(const char **str) * Time parsing: 'time-field ":" time-field ":" time-field' * 'time-field = 1*2DIGIT' */ -static bool_t Cookies_get_time(struct tm *tm, const char **str) +static bool Cookies_get_time(struct tm *tm, const char **str) { const char *s = *str; if ((tm->tm_hour = Cookies_get_timefield(&s)) == -1) - return FALSE; + return false; if (*(s++) != ':') - return FALSE; + return false; if ((tm->tm_min = Cookies_get_timefield(&s)) == -1) - return FALSE; + return false; if (*(s++) != ':') - return FALSE; + return false; if ((tm->tm_sec = Cookies_get_timefield(&s)) == -1) - return FALSE; + return false; *str = s; - return TRUE; + return true; } /* * Day parsing: "day-of-month = 1*2DIGIT" */ -static bool_t Cookies_get_day(struct tm *tm, const char **str) +static bool Cookies_get_day(struct tm *tm, const char **str) { const char *s = *str; if ((tm->tm_mday = Cookies_get_timefield(&s)) == -1) - return FALSE; + return false; *str = s; - return TRUE; + return true; } /* * Date parsing: "year = 2*4DIGIT" */ -static bool_t Cookies_get_year(struct tm *tm, const char **str) +static bool Cookies_get_year(struct tm *tm, const char **str) { int n; const char *s = *str; @@ -553,12 +553,12 @@ static bool_t Cookies_get_year(struct tm *tm, const char **str) if (isdigit(*s)) n = *(s++) - '0'; else - return FALSE; + return false; if (isdigit(*s)) { n *= 10; n += *(s++) - '0'; } else - return FALSE; + return false; if (isdigit(*s)) { n *= 10; n += *(s++) - '0'; @@ -569,7 +569,7 @@ static bool_t Cookies_get_year(struct tm *tm, const char **str) } if (isdigit(*s)) { /* Sorry, users of prehistoric software in the year 10000! */ - return FALSE; + return false; } if (n >= 70 && n <= 99) n += 1900; @@ -579,13 +579,13 @@ static bool_t Cookies_get_year(struct tm *tm, const char **str) tm->tm_year = n - 1900; *str = s; - return TRUE; + return true; } /* * As given in RFC 6265. */ -static bool_t Cookies_date_delim(char c) +static bool Cookies_date_delim(char c) { return (c == '\x09' || (c >= '\x20' && c <= '\x2F') || @@ -605,13 +605,13 @@ static bool_t Cookies_date_delim(char c) */ static struct tm *Cookies_parse_date(const char *date) { - bool_t found_time = FALSE, found_day = FALSE, found_month = FALSE, - found_year = FALSE, matched; + bool found_time = false, found_day = false, found_month = false, + found_year = false, matched; struct tm *tm = dNew0(struct tm, 1); const char *s = date; while (*s) { - matched = FALSE; + matched = false; if (!found_time) matched = found_time = Cookies_get_time(tm, &s); @@ -893,9 +893,9 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date) { CookieData_t *cookie = NULL; char *str = cookie_str; - bool_t first_attr = TRUE; - bool_t max_age = FALSE; - bool_t expires = FALSE; + bool first_attr = true; + bool max_age = false; + bool expires = false; /* Iterate until there is nothing left of the string */ while (*str) { @@ -1023,26 +1023,26 @@ static int Cookies_cmp(const void *a, const void *b) /* * Is the domain an IP address? */ -static bool_t Cookies_domain_is_ip(const char *domain) +static bool Cookies_domain_is_ip(const char *domain) { uint_t len; if (!domain) - return FALSE; + return false; len = strlen(domain); if (len == strspn(domain, "0123456789.")) { _MSG("an IPv4 address\n"); - return TRUE; + return true; } if (strchr(domain, ':') && (len == strspn(domain, "0123456789abcdefABCDEF:."))) { /* The precise format is shown in section 3.2.2 of rfc 3986 */ MSG("an IPv6 address\n"); - return TRUE; + return true; } - return FALSE; + return false; } /* @@ -1051,13 +1051,13 @@ static bool_t Cookies_domain_is_ip(const char *domain) * Note different user agents apparently vary in path-matching behaviour, * but this is the recommended method at the moment. */ -static bool_t Cookies_path_matches(const char *url_path, +static bool Cookies_path_matches(const char *url_path, const char *cookie_path) { - bool_t ret = TRUE; + bool ret = true; if (!url_path || !cookie_path) { - ret = FALSE; + ret = false; } else { uint_t c_len = strlen(cookie_path); uint_t u_len = strlen(url_path); @@ -1093,12 +1093,12 @@ static void Cookies_validate_path(CookieData_t *cookie, const char *url_path) /* * Check whether host name A domain-matches host name B. */ -static bool_t Cookies_domain_matches(char *A, char *B) +static bool Cookies_domain_matches(char *A, char *B) { int diff; if (!A || !*A || !B || !*B) - return FALSE; + return false; if (*B == '.') B++; @@ -1109,10 +1109,10 @@ static bool_t Cookies_domain_matches(char *A, char *B) */ if (!dStrAsciiCasecmp(A, B)) - return TRUE; + return true; if (Cookies_domain_is_ip(B)) - return FALSE; + return false; diff = strlen(A) - strlen(B); @@ -1120,7 +1120,7 @@ static bool_t Cookies_domain_matches(char *A, char *B) /* B is the tail of A, and the match is preceded by a '.' */ return (dStrAsciiCasecmp(A + diff, B) == 0 && A[diff - 1] == '.'); } else { - return FALSE; + return false; } } @@ -1178,18 +1178,18 @@ static uint_t Cookies_internal_dots_required(const char *host) /* * Validate cookies domain against some security checks. */ -static bool_t Cookies_validate_domain(CookieData_t *cookie, char *host) +static bool Cookies_validate_domain(CookieData_t *cookie, char *host) { uint_t i, internal_dots; if (!cookie->domain) { cookie->domain = dStrdup(host); - cookie->host_only = TRUE; - return TRUE; + cookie->host_only = true; + return true; } if (!Cookies_domain_matches(host, cookie->domain)) - return FALSE; + return false; internal_dots = 0; for (i = 1; i < strlen(cookie->domain) - 1; i++) { @@ -1202,11 +1202,11 @@ static bool_t Cookies_validate_domain(CookieData_t *cookie, char *host) */ if (internal_dots < Cookies_internal_dots_required(host)) { MSG("not enough dots in %s\n", cookie->domain); - return FALSE; + return false; } _MSG("host %s and domain %s is all right\n", host, cookie->domain); - return TRUE; + return true; } /* @@ -1252,29 +1252,29 @@ static int Cookies_set(char *cookie_string, char *url_host, /* * Compare the cookie with the supplied data to see whether it matches */ -static bool_t Cookies_match(CookieData_t *cookie, const char *url_path, - bool_t host_only_val, bool_t is_tls) +static bool Cookies_match(CookieData_t *cookie, const char *url_path, + bool host_only_val, bool is_tls) { if (cookie->host_only != host_only_val) - return FALSE; + return false; /* Insecure cookies match both secure and insecure urls, secure cookies match only secure urls */ if (cookie->secure && !is_tls) - return FALSE; + return false; if (!Cookies_path_matches(url_path, cookie->path)) - return FALSE; + return false; /* It's a match */ - return TRUE; + return true; } static void Cookies_add_matching_cookies(const char *domain, const char *url_path, - bool_t host_only_val, + bool host_only_val, Dlist *matching_cookies, - bool_t is_tls) + bool is_tls) { DomainNode *node = reinterpret_cast< DomainNode * >( dList_find_sorted(domains, domain, Domain_node_by_domain_cmp) ); @@ -1324,7 +1324,7 @@ static std::string Cookies_get(char *url_host, char *url_path, char *domain_str; CookieData_t *cookie; Dlist *matching_cookies; - bool_t is_tls, is_ip_addr, host_only_val; + bool is_tls, is_ip_addr, host_only_val; int i; @@ -1345,7 +1345,7 @@ static std::string Cookies_get(char *url_host, char *url_path, * attrs can have leading dots, which should be ignored for matching * purposes. */ - host_only_val = FALSE; + host_only_val = false; if (!is_ip_addr) { /* e.g., sub.example.com set a cookie with domain ".sub.example.com". */ domain_str = dStrconcat(".", url_host, NULL); @@ -1353,11 +1353,11 @@ static std::string Cookies_get(char *url_host, char *url_path, matching_cookies, is_tls); dFree(domain_str); } - host_only_val = TRUE; + host_only_val = true; /* e.g., sub.example.com set a cookie with no domain attribute. */ Cookies_add_matching_cookies(url_host, url_path, host_only_val, matching_cookies, is_tls); - host_only_val = FALSE; + host_only_val = false; /* e.g., sub.example.com set a cookie with domain "sub.example.com". */ Cookies_add_matching_cookies(url_host, url_path, host_only_val, matching_cookies, is_tls); @@ -1422,7 +1422,7 @@ static int Cookie_control_init(void) char line[LINE_MAXLEN]; char domain[LINE_MAXLEN]; char rule[LINE_MAXLEN]; - bool_t enabled = FALSE; + bool enabled = false; /* Get a file pointer */ filename = dStrconcat(dGethomedir(), "/.flenser/cookiesrc", NULL); diff --git a/dpi/file.cc b/dpi/file.cc index fcf41b3..95c9d39 100644 --- a/dpi/file.cc +++ b/dpi/file.cc @@ -702,7 +702,7 @@ static int File_send_file(ClientInfo *client) const char *unknown_type = "application/octet-stream"; char buf[LBUF], *d_cmd, *name; int st, st2, namelen; - bool_t gzipped = FALSE; + bool gzipped = false; if (client->state == st_start) { /* Send DPI command */ @@ -719,7 +719,7 @@ static int File_send_file(ClientInfo *client) namelen = strlen(client->filename); if (namelen > 3 && !dStrAsciiCasecmp(client->filename + namelen - 3, ".gz")) { - gzipped = TRUE; + gzipped = true; namelen -= 3; } /* Content-Type info is based on filename extension (with ".gz" removed). diff --git a/src/IO/IO.cc b/src/IO/IO.cc index d79d9f8..bc894ee 100644 --- a/src/IO/IO.cc +++ b/src/IO/IO.cc @@ -154,11 +154,11 @@ static void IO_close_fd(IOData_t *io, int CloseCode) /** * Read data from a file descriptor into a specific buffer */ -static bool_t IO_read(IOData_t *io) +static bool IO_read(IOData_t *io) { char Buf[IOBufLen]; ssize_t St; - bool_t ret = FALSE; + bool ret = false; int io_key = io->Key; void *conn = a_Tls_connection(io->FD); @@ -178,7 +178,7 @@ static bool_t IO_read(IOData_t *io) if (errno == EINTR) { continue; } else if (errno == EAGAIN) { - ret = TRUE; + ret = true; break; } else { if (conn) { @@ -216,10 +216,10 @@ static bool_t IO_read(IOData_t *io) /** * Write data, from a specific buffer, into a file descriptor */ -static bool_t IO_write(IOData_t *io) +static bool IO_write(IOData_t *io) { ssize_t St; - bool_t ret = FALSE; + bool ret = false; void *conn = a_Tls_connection(io->FD); _MSG(" IO_write\n"); @@ -233,7 +233,7 @@ static bool_t IO_write(IOData_t *io) if (errno == EINTR) { continue; } else if (errno == EAGAIN) { - ret = TRUE; + ret = true; break; } else { if (conn) { @@ -264,7 +264,7 @@ static bool_t IO_write(IOData_t *io) */ static int IO_callback(IOData_t *io) { - bool_t ret = FALSE; + bool ret = false; _MSG("IO_callback:: (%s) FD = %d\n", (io->Op == IORead) ? "IORead" : "IOWrite", io->FD); diff --git a/src/IO/Url.h b/src/IO/Url.h index 199f274..e90f004 100644 --- a/src/IO/Url.h +++ b/src/IO/Url.h @@ -16,7 +16,7 @@ extern void a_Http_freeall(void); int a_Http_init(void); int a_Http_proxy_auth(void); void a_Http_set_proxy_passwd(const char *str); -void a_Http_connect_done(int fd, bool_t success); +void a_Http_connect_done(int fd, bool success); void a_Http_ccc (int Op, int Branch, int Dir, ChainLink *Info, void *Data1, void *Data2); diff --git a/src/IO/http.cc b/src/IO/http.cc index e0cae0a..79ed346 100644 --- a/src/IO/http.cc +++ b/src/IO/http.cc @@ -84,7 +84,7 @@ struct SocketData_t { typedef struct { char *host; uint_t port; - bool_t https; + bool https; int active_conns; int running_the_queue; @@ -97,7 +97,7 @@ struct FdMapEntry_t { }; static void Http_socket_enqueue(Server_t *srv, SocketData_t* sock); -static Server_t *Http_server_get(const char *host, uint_t port, bool_t https); +static Server_t *Http_server_get(const char *host, uint_t port, bool https); static void Http_server_remove(Server_t *srv); static void Http_connect_socket(ChainLink *Info); static char *Http_get_connect_str(const DilloUrl *url); @@ -214,7 +214,7 @@ static void Http_fd_map_remove_entry(int fd) } } -void a_Http_connect_done(int fd, bool_t success) +void a_Http_connect_done(int fd, bool success) { SocketData_t *sd; std::optional< FdMapEntry_t > fme; @@ -222,7 +222,7 @@ void a_Http_connect_done(int fd, bool_t success) if (fme && (sd = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, fme->skey) ))) { ChainLink *info = sd->Info; - bool_t valid_web = a_Web_valid(sd->web); + bool valid_web = a_Web_valid(sd->web); if (success && valid_web) { a_Chain_bfcb(OpSend, info, &sd->SockFD, const_cast< void * >( static_cast< const void * >( "FD" ) )); @@ -383,7 +383,7 @@ static std::string Http_make_content_type(const DilloUrl *url) /** * Make the http query string */ -static Dstr *Http_make_query_str(DilloWeb *web, bool_t use_proxy, bool_t use_tls) +static Dstr *Http_make_query_str(DilloWeb *web, bool use_proxy, bool use_tls) { char *ptr, *cookies, *referer, *auth; const DilloUrl *url = web->url.get(); @@ -668,7 +668,7 @@ static void Http_connect_socket(ChainLink *Info) if (S->addr_list_idx >= S->addr_list.size() ) { MSG("Http_connect_socket ran out of IP addrs to try.\n"); - a_Http_connect_done(S->SockFD, FALSE); + a_Http_connect_done(S->SockFD, false); } } @@ -752,7 +752,7 @@ static char *Http_get_connect_str(const DilloUrl *url) static void Http_dns_cb(int Status, std::optional< std::vector< std::shared_ptr< DilloHost > > > &addr_list, void *data) { int SKey = VOIDP2INT(data); - bool_t clean_up = TRUE; + bool clean_up = true; SocketData_t *S; Server_t *srv; @@ -766,7 +766,7 @@ static void Http_dns_cb(int Status, std::optional< std::vector< std::shared_ptr< /* Successful DNS answer; save the IP */ S->addr_list = addr_list.value(); S->addr_list_idx = 0; - clean_up = FALSE; + clean_up = false; srv = Http_server_get(host, S->connect_port, (S->flags & HTTP_SOCKET_TLS)); Http_socket_enqueue(srv, S); @@ -833,7 +833,7 @@ static int Http_get(ChainLink *Info, void *Data1) * NOTE: old and new must come from the same Server_t. * This is not built to accept arbitrary sockets. */ -static bool_t Http_socket_reuse_compatible(SocketData_t *old, +static bool Http_socket_reuse_compatible(SocketData_t *old, SocketData_t *new_) { /* @@ -868,11 +868,11 @@ static void Http_socket_reuse(int SKey) if (!(new_sd->flags & HTTP_SOCKET_TO_BE_FREED) && Http_socket_reuse_compatible(old_sd, new_sd)) { - const bool_t success = TRUE; + const bool success = true; new_sd->SockFD = old_sd->SockFD; - old_sd->connected_to = NULL; + old_sd->connected_to = nullptr; srv->active_conns--; Http_socket_free(SKey); @@ -1068,7 +1068,7 @@ static void Http_socket_enqueue(Server_t *srv, SocketData_t* sock) dList_append(srv->queue, sock); } -static Server_t *Http_server_get(const char *host, uint_t port, bool_t https) +static Server_t *Http_server_get(const char *host, uint_t port, bool https) { int i; Server_t *srv; diff --git a/src/IO/tls_openssl.cc b/src/IO/tls_openssl.cc index e05a165..91fca43 100644 --- a/src/IO/tls_openssl.cc +++ b/src/IO/tls_openssl.cc @@ -82,9 +82,9 @@ typedef struct { int fd; DilloUrl *url; SSL *ssl; - bool_t connecting; - bool_t in_connect; - bool_t do_shutdown; + bool connecting; + bool in_connect; + bool do_shutdown; } Conn_t; /* List of active TLS connections */ @@ -170,9 +170,9 @@ static int Tls_conn_new(int fd, const DilloUrl *url, SSL *ssl) conn->fd = fd; conn->url = a_Url_dup(url).release(); conn->ssl = ssl; - conn->connecting = TRUE; - conn->in_connect = FALSE; - conn->do_shutdown = TRUE; + conn->connecting = true; + conn->in_connect = false; + conn->do_shutdown = true; key = a_Klist_insert(&conn_list, conn); @@ -457,14 +457,14 @@ int a_Tls_openssl_certificate_is_clean(const DilloUrl *url) * not good practice, but feels justified by the fact that it's so much * trouble to get this information out of openssl even once. * - * Return FALSE if MD5 (MD*) hash is found and user does not accept it, + * Return `false` if MD5 (MD*) hash is found and user does not accept it, * otherwise TRUE. */ -static bool_t Tls_check_cert_strength(SSL *ssl, Server_t *srv, int *choice) +static bool Tls_check_cert_strength(SSL *ssl, Server_t *srv, int *choice) { /* print for first connection to server */ - const bool_t print_chain = srv->cert_status == CERT_STATUS_RECEIVING; - bool_t success = TRUE; + const bool print_chain = srv->cert_status == CERT_STATUS_RECEIVING; + bool success = true; STACK_OF(X509) *sk = SSL_get_peer_cert_chain(ssl); @@ -507,14 +507,14 @@ static bool_t Tls_check_cert_strength(SSL *ssl, Server_t *srv, int *choice) if (print_chain) MSG_WARN("In 2015, browsers have begun to deprecate SHA1 " "certificates.\n"); - } else if (!strncmp(buf, "md", 2) && success == TRUE) { + } else if (!strncmp(buf, "md", 2) && success == true) { const char *msg = "A certificate in the chain uses the MD5 " "signature algorithm, which is too weak " "to trust."; *choice = a_Dialog_choice("Flenser TLS security warning", msg, "Continue", "Cancel", NULL); if (*choice != 1) - success = FALSE; + success = false; } } } @@ -574,7 +574,7 @@ static bool_t Tls_check_cert_strength(SSL *ssl, Server_t *srv, int *choice) If the pattern contain no wildcards, pattern_match(a, b) is equivalent to !strcasecmp(a, b). */ -static bool_t pattern_match (const char *pattern, const char *string) +static bool pattern_match (const char *pattern, const char *string) { const char *p = pattern, *n = string; @@ -586,17 +586,17 @@ static bool_t pattern_match (const char *pattern, const char *string) ; for (; *n != '\0'; n++) if (tolower (*n) == c && pattern_match (p, n)) - return TRUE; + return true; #ifdef ASTERISK_EXCLUDES_DOT else if (*n == '.') - return FALSE; + return false; #endif return c == '\0'; } else { if (c != tolower (*n)) - return FALSE; + return false; } return *n == '\0'; } @@ -604,10 +604,10 @@ static bool_t pattern_match (const char *pattern, const char *string) /* * Check that the certificate corresponds to the site it's presented for. * - * Return TRUE if the hostname matched or the user indicated acceptance. - * FALSE on failure. + * Return `true` if the hostname matched or the user indicated acceptance. + * `false` on failure. */ -static bool_t Tls_check_cert_hostname(X509 *cert, const char *host, +static bool Tls_check_cert_hostname(X509 *cert, const char *host, int *choice) { if (cert == NULL || host == NULL) @@ -615,7 +615,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host, char *msg; GENERAL_NAMES *subjectAltNames; - bool_t success = TRUE, alt_name_checked = FALSE;; + bool success = true, alt_name_checked = false;; char common_name[256]; /* Check that HOST matches the common name in the certificate. @@ -657,7 +657,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host, /* Check for ipAddress */ /* TODO: Should we convert between IPv4-mapped IPv6 * addresses and IPv4 addresses? */ - alt_name_checked = TRUE; + alt_name_checked = true; if (!ASN1_STRING_cmp (host_in_octet_string, name->d.iPAddress)) break; @@ -671,7 +671,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host, unsigned char *name_in_utf8 = NULL; /* Check for dNSName */ - alt_name_checked = TRUE; + alt_name_checked = true; if (0 <= ASN1_STRING_to_UTF8 (&name_in_utf8, name->d.dNSName)) { @@ -693,15 +693,15 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host, if (host_in_octet_string) ASN1_OCTET_STRING_free(host_in_octet_string); - if (alt_name_checked == TRUE && i >= numaltnames) + if (alt_name_checked == true && i >= numaltnames) { - success = FALSE; + success = false; *choice = a_Dialog_choice("Flenser TLS security warning", err->str, "Continue", "Cancel", NULL); switch (*choice){ case 1: - success = TRUE; + success = true; break; case 2: break; @@ -712,7 +712,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host, dStr_free(err, 1); } - if (alt_name_checked == FALSE) + if (alt_name_checked == false) { /* Test commomName */ X509_NAME *xname = X509_get_subject_name(cert); @@ -722,7 +722,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host, if (!pattern_match (common_name, host)) { - success = FALSE; + success = false; msg = dStrconcat("Certificate common name ", common_name, " doesn't match requested host name ", host, NULL); *choice = a_Dialog_choice("Flenser TLS security warning", @@ -731,7 +731,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host, switch (*choice){ case 1: - success = TRUE; + success = true; break; case 2: break; @@ -1106,7 +1106,7 @@ static void Tls_close_by_key(int connkey) static void Tls_connect(int fd, int connkey) { int ret; - bool_t ongoing = FALSE, failed = TRUE; + bool ongoing = false, failed = true; Conn_t *conn; if (!(conn = reinterpret_cast< Conn_t * >( a_Klist_get_data(conn_list, connkey) ))) { @@ -1118,7 +1118,7 @@ static void Tls_connect(int fd, int connkey) MSG("Tls_connect: nested call to Tls_connect(), aborting\n"); abort(); } else { - conn->in_connect = TRUE; + conn->in_connect = true; } if (ERR_peek_error()) { @@ -1143,14 +1143,14 @@ static void Tls_connect(int fd, int connkey) _MSG("iowatching fd %d for tls -- want %s\n", fd, err1_ret == SSL_ERROR_WANT_READ ? "read" : "write"); a_IOwatch_add_fd(fd, want, Tls_connect_cb, INT2VOIDP(connkey)); - ongoing = TRUE; - failed = FALSE; + ongoing = true; + failed = false; } else if (err1_ret == SSL_ERROR_SYSCALL || err1_ret == SSL_ERROR_SSL) { /* From the OpenSSL documentation: "Note that SSL_shutdown() must not * be called if a previous fatal error has occurred on a connection * i.e. if SSL_get_error() has returned SSL_ERROR_SYSCALL or * SSL_ERROR_SSL." */ - conn->do_shutdown = FALSE; + conn->do_shutdown = false; unsigned long err2_ret = ERR_get_error(); @@ -1199,7 +1199,7 @@ static void Tls_connect(int fd, int connkey) if (srv->cert_status == CERT_STATUS_USER_ACCEPTED || (Tls_examine_certificate(conn->ssl, srv) != -1)) { - failed = FALSE; + failed = false; } } @@ -1210,22 +1210,22 @@ static void Tls_connect(int fd, int connkey) if (!ongoing) { if (a_Klist_get_data(conn_list, connkey)) { - conn->connecting = FALSE; + conn->connecting = false; if (failed) { - conn->in_connect = FALSE; + conn->in_connect = false; Tls_close_by_key(connkey); /* conn is freed now */ conn = NULL; } a_IOwatch_remove_fd(fd, DIO_READ|DIO_WRITE); - a_Http_connect_done(fd, failed ? FALSE : TRUE); + a_Http_connect_done(fd, not( failed ) ); } else { MSG("Connection disappeared. Too long with a popup popped up?\n"); } } if (conn) - conn->in_connect = FALSE; + conn->in_connect = false; } static void Tls_connect_cb(int fd, void *vconnkey) @@ -1239,14 +1239,14 @@ static void Tls_connect_cb(int fd, void *vconnkey) void a_Tls_openssl_connect(int fd, const DilloUrl *url) { SSL *ssl; - bool_t success = TRUE; + bool success = true; int connkey = -1; if (!ssl_context) - success = FALSE; + success = false; if (success && Tls_user_said_no(url)) { - success = FALSE; + success = false; } if (ERR_peek_error()) { @@ -1263,7 +1263,7 @@ void a_Tls_openssl_connect(int fd, const DilloUrl *url) do { MSG("SSL_new() failed: %s\n", ERR_error_string(err_ret, NULL)); } while ((err_ret = ERR_get_error())); - success = FALSE; + success = false; } /* assign TLS connection to this file descriptor */ @@ -1272,7 +1272,7 @@ void a_Tls_openssl_connect(int fd, const DilloUrl *url) do { MSG("SSL_set_fd() failed: %s\n", ERR_error_string(err_ret, NULL)); } while ((err_ret = ERR_get_error())); - success = FALSE; + success = false; } if (success) diff --git a/src/bw.cc b/src/bw.cc index 364a040..bd27ed3 100644 --- a/src/bw.cc +++ b/src/bw.cc @@ -313,7 +313,7 @@ void a_Bw_cancel_expect(BrowserWindow *bw) bw->nav_expect_url.reset(); } -bool_t a_Bw_expecting(BrowserWindow *bw) +bool a_Bw_expecting(BrowserWindow *bw) { return (bw->nav_expect_url != nullptr); } diff --git a/src/bw.hh b/src/bw.hh index 17d055f..d34db45 100644 --- a/src/bw.hh +++ b/src/bw.hh @@ -121,7 +121,7 @@ void a_Bw_cleanup(BrowserWindow *bw); /* expect API */ void a_Bw_expect(BrowserWindow *bw, const DilloUrl *Url); void a_Bw_cancel_expect(BrowserWindow *bw); -bool_t a_Bw_expecting(BrowserWindow *bw); +bool a_Bw_expecting(BrowserWindow *bw); const DilloUrl *a_Bw_expected_url(BrowserWindow *bw); typedef void (*BwCallback_t)(BrowserWindow *bw, const void *data); diff --git a/src/cache.cc b/src/cache.cc index 343650e..532710b 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -661,7 +661,7 @@ static Dlist *Cache_parse_multiple_fields(const char *header, static void Cache_parse_header(CacheEntry_t *entry) { const char *header = entry->Header.c_str(); - bool_t server1point0 = !strncmp(entry->Header.c_str(), "HTTP/1.0", 8); + bool server1point0 = !strncmp(entry->Header.c_str(), "HTTP/1.0", 8); char *Length, *Type, *location_str, *encoding, *connection, *hsts; #ifndef DISABLE_COOKIES Dlist *Cookies; @@ -894,17 +894,17 @@ static void Cache_finish_msg(CacheEntry_t *entry) * 'Op' is the operation to perform * 'VPtr' is a (void) pointer to the IO control structure */ -bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size, +bool a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size, const DilloUrl *Url) { int offset, len; const char *str; Dstr *dstr1, *dstr2, *dstr3; - bool_t done = FALSE; + bool done = false; CacheEntry_t *entry = Cache_entry_search(Url); /* Assert a valid entry (not aborted) */ - dReturn_val_if_fail (entry != NULL, FALSE); + dReturn_val_if_fail (entry != NULL, false); _MSG("__a_Cache_process_dbuf__\n"); @@ -952,11 +952,11 @@ bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size, if ((entry->Flags & CA_GotLength) && (entry->TransferSize >= entry->ExpectedSize)) { - done = TRUE; + done = true; } if (!(entry->Flags & CA_KeepAlive)) { /* Let IOClose finish it later */ - done = FALSE; + done = false; } entry = Cache_process_queue(entry); @@ -1178,10 +1178,10 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) CacheClient_t *Client; DilloWeb *ClientWeb; BrowserWindow *Client_bw = NULL; - static bool_t Busy = FALSE; - bool_t AbortEntry = FALSE; - bool_t OfferDownload = FALSE; - bool_t TypeMismatch = FALSE; + static bool Busy = false; + bool AbortEntry = false; + bool OfferDownload = false; + bool TypeMismatch = false; if (Busy) MSG_ERR("FATAL!: >>>> Cache_process_queue Caught busy!!! <<<<\n"); @@ -1195,7 +1195,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) if (a_Misc_content_type_check(entry->TypeHdr, Type) < 0) { MSG_HTTP("Content-Type '%s' doesn't match the real data.\n", entry->TypeHdr); - TypeMismatch = TRUE; + TypeMismatch = true; } entry->TypeDet = dStrdup(Type); entry->Flags |= CA_GotContentType; @@ -1203,7 +1203,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) return entry; /* i.e., wait for more data */ } - Busy = TRUE; + Busy = true; for (i = 0; (Client = reinterpret_cast< CacheClient_t * >( dList_nth_data(ClientQueue, i) )); ++i) { if (Client->Url == entry->Url.get()) { ClientWeb = reinterpret_cast< DilloWeb * >( Client->Web ); /* It was a (void*) */ @@ -1218,7 +1218,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) if (TypeMismatch) { a_UIcmd_set_msg(Client_bw,"HTTP warning: Content-Type '%s' " "doesn't match the real data.", entry->TypeHdr); - OfferDownload = TRUE; + OfferDownload = true; } if (entry->Flags & CA_Redirect) { if (!Client->Callback) { @@ -1231,7 +1231,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) if (entry->Flags & CA_HugeFile) { a_UIcmd_set_msg(Client_bw, "Huge file! (%d MB)", entry->ExpectedSize / (1024*1024)); - AbortEntry = OfferDownload = TRUE; + AbortEntry = OfferDownload = true; } } else { /* For non root URLs, ignore redirections and 404 answers */ @@ -1247,7 +1247,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) /* Not following redirection, so don't display page body. */ } else { if (TypeMismatch) { - AbortEntry = TRUE; + AbortEntry = true; } else { const char *curr_type = Cache_current_content_type(entry); st = a_Web_dispatch_by_type(curr_type, ClientWeb, @@ -1258,7 +1258,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) if (ClientWeb->flags & WEB_RootUrl) { MSG("Content-Type '%s' not viewable.\n", curr_type); /* prepare a download offer... */ - AbortEntry = OfferDownload = TRUE; + AbortEntry = OfferDownload = true; } else { /* TODO: Resource Type not handled. * Not aborted to avoid multiple connections on the @@ -1347,7 +1347,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) a_Dicache_cleanup(); } - Busy = FALSE; + Busy = false; _MSG("QueueSize ====> %d\n", dList_length(ClientQueue)); return entry; } diff --git a/src/cache.hh b/src/cache.hh index 9578ac4..53765ed 100644 --- a/src/cache.hh +++ b/src/cache.hh @@ -68,7 +68,7 @@ const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype, const char *from); uint_t a_Cache_get_flags(const DilloUrl *url); uint_t a_Cache_get_flags_with_redirection(const DilloUrl *url); -bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size, +bool a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size, const DilloUrl *Url); int a_Cache_download_enabled(const DilloUrl *url); void a_Cache_entry_remove_by_url(DilloUrl *url); diff --git a/src/capi.cc b/src/capi.cc index 5098c85..455ca81 100644 --- a/src/capi.cc +++ b/src/capi.cc @@ -346,13 +346,13 @@ static void Capi_dpi_send_source(BrowserWindow *bw, DilloUrl *url) /** * Shall we permit this request to open a URL? */ -static bool_t Capi_request_permitted(DilloWeb *web) +static bool Capi_request_permitted(DilloWeb *web) { - bool_t permit = FALSE; + bool permit = false; /* web->requester is NULL if the action is initiated by user */ if (!web->requester) - return TRUE; + return true; if (web->flags & ~WEB_RootUrl && !dStrAsciiCasecmp(URL_SCHEME(web->requester), "https")) { @@ -372,13 +372,13 @@ static bool_t Capi_request_permitted(DilloWeb *web) if (dStrAsciiCasecmp(s, "https") && dStrAsciiCasecmp(s, "data")) { MSG("capi: Blocked mixed content: %s -> %s\n", URL_STR(web->requester.get()), URL_STR(web->url.get())); - return FALSE; + return false; } } if (a_Capi_get_flags(web->url.get()) & CAPI_IsCached || a_Domain_permit(web->requester.get(), web->url.get())) { - permit = TRUE; + permit = true; } return permit; } @@ -771,7 +771,7 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, if (strcmp(reinterpret_cast< const char * >( Data2 ), "send_page_2eof") == 0) { /* Data1 = dbuf */ DataBuf *dbuf = reinterpret_cast< DataBuf * >( Data1 ); - bool_t finished = a_Cache_process_dbuf(IORead, dbuf->Buf, + bool finished = a_Cache_process_dbuf(IORead, dbuf->Buf, dbuf->Size, conn->url); if (finished && Capi_conn_valid(conn) && conn->InfoRecv) { /* If we have a persistent connection where cache tells us diff --git a/src/cookies.cc b/src/cookies.cc index cbabec4..c3c760c 100644 --- a/src/cookies.cc +++ b/src/cookies.cc @@ -66,7 +66,7 @@ static int num_ccontrol = 0; static int num_ccontrol_max = 1; static CookieControlAction default_action = COOKIE_DENY; -static bool_t disabled; +static bool disabled; static FILE *Cookies_fopen(const char *file, char *init_str); static CookieControlAction Cookies_control_check(const DilloUrl *url); @@ -117,7 +117,7 @@ static FILE *Cookies_fopen(const char *filename, char *init_str) void a_Cookies_init(void) { /* Default setting */ - disabled = TRUE; + disabled = true; /* Read and parse the cookie control file (cookiesrc) */ if (Cookie_control_init() != 0) { @@ -126,7 +126,7 @@ void a_Cookies_init(void) } MSG("Enabling cookies as from cookiesrc...\n"); - disabled = FALSE; + disabled = false; } /** @@ -246,7 +246,7 @@ static int Cookie_control_init(void) char line[LINE_MAXLEN]; char domain[LINE_MAXLEN]; char rule[LINE_MAXLEN]; - bool_t enabled = FALSE; + bool enabled = false; /* Get a file pointer */ filename = dStrconcat(dGethomedir(), "/.flenser/cookiesrc", NULL); @@ -320,13 +320,13 @@ static int Cookie_control_init(void) } if (cc.action != COOKIE_DENY) - enabled = TRUE; + enabled = true; } } fclose(stream); - return (enabled ? 0 : 1); + return not( enabled ); } /** diff --git a/src/decode.cc b/src/decode.cc index 7876873..1f9481d 100644 --- a/src/decode.cc +++ b/src/decode.cc @@ -82,7 +82,7 @@ Dstr *a_Decode_transfer_process(DecodeTransfer *dc, const char *instr, return output; } -bool_t a_Decode_transfer_finished(DecodeTransfer *dc) +bool a_Decode_transfer_finished(DecodeTransfer *dc) { return dc->finished; } diff --git a/src/decode.hh b/src/decode.hh index 42214d1..e959826 100644 --- a/src/decode.hh +++ b/src/decode.hh @@ -21,13 +21,13 @@ struct Decode { struct DecodeTransfer { Dstr *leftover; void *state; - bool_t finished; /**< has the terminating chunk been seen? */ + bool finished; /**< has the terminating chunk been seen? */ }; DecodeTransfer *a_Decode_transfer_init(const char *format); Dstr *a_Decode_transfer_process(DecodeTransfer *dc, const char *instr, int inlen); -bool_t a_Decode_transfer_finished(DecodeTransfer *dc); +bool a_Decode_transfer_finished(DecodeTransfer *dc); void a_Decode_transfer_free(DecodeTransfer *dc); Decode *a_Decode_content_init(const char *format); diff --git a/src/domain.cc b/src/domain.cc index da577da..b9cf094 100644 --- a/src/domain.cc +++ b/src/domain.cc @@ -24,7 +24,7 @@ struct Rule { std::vector< Rule > exceptions; -static bool_t default_deny = FALSE; +static bool default_deny = false; /** * Parse domainrc. @@ -56,10 +56,10 @@ void a_Domain_parse(FILE *fp) } else { if (dStrAsciiCasecmp(tok1, "default") == 0) { if (dStrAsciiCasecmp(tok2, "deny") == 0) { - default_deny = TRUE; + default_deny = true; MSG("Domain: Default deny.\n"); } else if (dStrAsciiCasecmp(tok2, "accept") == 0) { - default_deny = FALSE; + default_deny = false; MSG("Domain: Default accept.\n"); } else { MSG("Domain: Default action \"%s\" not recognised.\n", tok2); @@ -84,7 +84,7 @@ void a_Domain_freeall(void) * "example.org" pattern matches "example.org". * ".example.org" pattern matches "example.org" and "sub.example.org". */ -static bool_t Domain_match(const char *host, const char *pattern) { +static bool Domain_match(const char *host, const char *pattern) { int cmp = strcmp(pattern, "*"); if (cmp) { @@ -99,20 +99,20 @@ static bool_t Domain_match(const char *host, const char *pattern) { cmp = dStrAsciiCasecmp(host + diff, pattern); } } - return cmp ? FALSE : TRUE; + return not( cmp ); } /** * Is the resource at 'source' permitted to request the resource at 'dest'? */ -bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest) +bool a_Domain_permit(const DilloUrl *source, const DilloUrl *dest) { int i; - bool_t ret; + bool ret; const char *source_host, *dest_host; - if (default_deny == FALSE && exceptions.size() == 0) - return TRUE; + if (default_deny == false && exceptions.size() == 0) + return true; source_host = URL_HOST(source); dest_host = URL_HOST(dest); @@ -120,15 +120,15 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest) if (dest_host[0] == '\0') { ret = source_host[0] == '\0' || !dStrAsciiCasecmp(URL_SCHEME(dest), "data"); - if (ret == FALSE) + if (ret == false) MSG("Domain: DENIED %s -> %s.\n", source_host, URL_STR(dest)); return ret; } if (a_Url_same_organization(*source, *dest)) - return TRUE; + return true; - ret = default_deny ? FALSE : TRUE; + ret = not( default_deny ); for (i = 0; i < exceptions.size(); i++) { if (Domain_match(source_host, exceptions[i].origin.c_str()) && @@ -140,7 +140,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest) } } - if (ret == FALSE) { + if (ret == false) { const char *src = source_host[0] ? source_host : URL_STR(source); MSG("Domain: DENIED %s -> %s.\n", src, dest_host); diff --git a/src/domain.hh b/src/domain.hh index 3655592..f22ba2d 100644 --- a/src/domain.hh +++ b/src/domain.hh @@ -10,7 +10,7 @@ extern "C" { void a_Domain_parse(FILE *fp); void a_Domain_freeall(void); -bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest); +bool a_Domain_permit(const DilloUrl *source, const DilloUrl *dest); #ifdef __cplusplus } diff --git a/src/hsts.cc b/src/hsts.cc index 0dbe98b..cfb69ad 100644 --- a/src/hsts.cc +++ b/src/hsts.cc @@ -42,7 +42,7 @@ struct HstsData_t { std::string host; time_t expires_at; - bool_t subdomains; + bool subdomains; }; /* When there is difficulty in representing future dates, use the (by far) @@ -103,7 +103,7 @@ static time_t Hsts_future_time(long seconds_from_now) return ret; } -static void Hsts_set_policy(const char *host, long max_age, bool_t subdomains) +static void Hsts_set_policy(const char *host, long max_age, bool subdomains) { time_t exp = Hsts_future_time(max_age); HstsData_t *policy = Hsts_get_policy(host); @@ -186,7 +186,7 @@ void a_Hsts_set(const char *header, const DilloUrl *url) { long max_age = 0; const char *host = URL_HOST(url); - bool_t max_age_valid = FALSE, subdomains = FALSE; + bool max_age_valid = false, subdomains = false; _MSG("HSTS header for %s: %s\n", host, header); @@ -239,10 +239,10 @@ void a_Hsts_set(const char *header, const DilloUrl *url) } } -static bool_t Hsts_expired(HstsData_t *policy) +static bool Hsts_expired(HstsData_t *policy) { - time_t now = time(NULL); - bool_t ret = (now > policy->expires_at) ? TRUE : FALSE; + time_t now = time(nullptr); + bool ret = not( now > policy->expires_at ); if (ret) { _MSG("HSTS: expired\n"); @@ -250,9 +250,9 @@ static bool_t Hsts_expired(HstsData_t *policy) return ret; } -bool_t a_Hsts_require_https(const char *host) +bool a_Hsts_require_https(const char *host) { - bool_t ret = FALSE; + bool ret = false; if (host) { HstsData_t *policy = Hsts_get_policy(host); diff --git a/src/hsts.hh b/src/hsts.hh index b340915..c63cf2d 100644 --- a/src/hsts.hh +++ b/src/hsts.hh @@ -10,7 +10,7 @@ extern "C" { void a_Hsts_init(FILE *fp); void a_Hsts_set(const char *header, const DilloUrl *url); -bool_t a_Hsts_require_https(const char *host); +bool a_Hsts_require_https(const char *host); void a_Hsts_freeall( void ); #ifdef __cplusplus diff --git a/src/html.cc b/src/html.cc index c3a214f..870bd03 100644 --- a/src/html.cc +++ b/src/html.cc @@ -288,7 +288,7 @@ void a_Html_form_reset(void *v_html, void *v_form) /** * Used by the "Show/Hide hiddens" form menuitem. */ -void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display) +void a_Html_form_display_hiddens(void *v_html, void *v_form, bool display) { DilloHtml *html = (DilloHtml*)v_html; @@ -640,7 +640,7 @@ DilloHtmlForm *DilloHtml::getCurrentForm () return forms.back().get(); } -bool_t DilloHtml::unloadedImages() +bool DilloHtml::unloadedImages() { for (int i = 0; i < images.size(); i++) { if (images.at(i)->image != NULL) { @@ -722,7 +722,7 @@ bool DilloHtml::HtmlLinkReceiver::press (Widget *widget, int link, int img, // image menu if (link != -1) linkurl = html->links.at(link).get(); - const bool_t loaded_img = (html->images.at(img)->image == NULL); + const bool loaded_img = (html->images.at(img)->image == NULL); a_UIcmd_image_popup(bw, html->images.at(img)->url.get(), loaded_img, html->page_url.get(), linkurl); ret = true; @@ -825,7 +825,7 @@ static int Html_ms_stupid_quotes_2ucs(int codepoint) * The "&#" has already been consumed. */ static const char *Html_parse_numeric_charref(DilloHtml *html, char *tok, - bool_t is_attr, int *entsize) + bool is_attr, int *entsize) { static char buf[5]; char *s = tok; @@ -928,7 +928,7 @@ static Charref_t *Html_charref_search(char *key) * The "&" has already been consumed. */ static const char *Html_parse_named_charref(DilloHtml *html, char *tok, - bool_t is_attr, int *entsize) + bool is_attr, int *entsize) { Charref_t *p; char c; @@ -984,7 +984,7 @@ static const char *Html_parse_named_charref(DilloHtml *html, char *tok, * For valid entities, *entsize is set to the length of the parsed entity. */ static const char *Html_parse_entity(DilloHtml *html, const char *token, - int toksize, int *entsize, bool_t is_attr) + int toksize, int *entsize, bool is_attr) { const char *ret = NULL; @@ -1034,7 +1034,7 @@ a_Html_parse_entities(DilloHtml *html, const char *token, int toksize) for (i = s; i < toksize; i++) { const char *entstr; - const bool_t is_attr = FALSE; + const bool is_attr = false; if (token[i] == '&' && (entstr = Html_parse_entity(html, token+i, toksize-i, &entsize, @@ -3257,7 +3257,7 @@ static void Html_tag_open_base(DilloHtml *html, const char *tag, int tagsize) if (html->InFlags & IN_HEAD) { if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "href"))) { - bool_t html5 = html->DocType == DT_HTML && + bool html5 = html->DocType == DT_HTML && html->DocTypeVersion >= 5.0f; BaseUrl = html5 ? a_Html_url_new(html, attrbuf, NULL, 0) : @@ -4129,7 +4129,7 @@ static const char *Html_get_attr2(DilloHtml *html, } else if (tag[i] == '&' && (tag_parsing_flags & HTML_ParseEntities)) { const char *entstr; - const bool_t is_attr = TRUE; + const bool is_attr = true; if ((entstr = Html_parse_entity(html, tag+i, tagsize-i, &entsize, is_attr))) { diff --git a/src/html.hh b/src/html.hh index 5746130..233b1a8 100644 --- a/src/html.hh +++ b/src/html.hh @@ -29,7 +29,7 @@ extern "C" { void a_Html_load_images(void *v_html, DilloUrl *pattern); void a_Html_form_submit(void *v_html, void *v_form); void a_Html_form_reset(void *v_html, void *v_form); -void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display); +void a_Html_form_display_hiddens(void *v_html, void *v_form, bool display); #ifdef __cplusplus } diff --git a/src/html_common.hh b/src/html_common.hh index cc8e7cd..2fcf31d 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -243,7 +243,7 @@ public: int formNew(DilloHtmlMethod method, const DilloUrl *action, DilloHtmlEnc enc, const char *charset); DilloHtmlForm *getCurrentForm (); - bool_t unloadedImages(); + bool unloadedImages(); void loadImages (const DilloUrl *pattern); void addCssUrl(const DilloUrl *url); diff --git a/src/menu.cc b/src/menu.cc index 05629d1..d5ee62d 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -352,7 +352,7 @@ static void Menu_popup_cb(void *data) * Page popup menu (construction & popup) */ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, - bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls) + bool has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls) { int j = 0; @@ -564,7 +564,7 @@ void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *p * Image popup menu (construction & popup) */ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url, - bool_t loaded_img, DilloUrl *page_url, + bool loaded_img, DilloUrl *page_url, DilloUrl *link_url) { static DilloUrl *popup_page_url = NULL; @@ -622,7 +622,7 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url, * Form popup menu (construction & popup) */ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, - void *formptr, bool_t hidvis) + void *formptr, bool hidvis) { static bool hiddens_visible; static Fl_Menu_Item pm[] = { diff --git a/src/menu.hh b/src/menu.hh index 0fc43c1..3b469a4 100644 --- a/src/menu.hh +++ b/src/menu.hh @@ -8,14 +8,14 @@ extern "C" { #endif /* __cplusplus */ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, - bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls); + bool has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls); void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *page_url); void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url, - bool_t loaded_img, DilloUrl *page_url, + bool loaded_img, DilloUrl *page_url, DilloUrl *link_url); void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, - void *vform, bool_t showing_hiddens); + void *vform, bool showing_hiddens); void a_Menu_file_popup(BrowserWindow *bw, void *v_wid); void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url); void a_Menu_history_popup(BrowserWindow *bw, int x, int y, int direction); diff --git a/src/nav.cc b/src/nav.cc index f550f97..c2a7a54 100644 --- a/src/nav.cc +++ b/src/nav.cc @@ -184,7 +184,7 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *requester, int offset) { const DilloUrl *old_url; - bool_t MustLoad, ForceReload, IgnoreScroll; + bool MustLoad, ForceReload, IgnoreScroll; int x, y, idx, ClientKey; DilloWeb *Web; @@ -261,7 +261,8 @@ void a_Nav_cancel_expect_if_eq(BrowserWindow *bw, const DilloUrl *url) */ void a_Nav_expect_done(BrowserWindow *bw) { - int m, url_idx, posx, posy, reload, repush, e2equery, goto_old_scroll=TRUE; + int m, url_idx, posx, posy, reload, repush, e2equery; + bool goto_old_scroll= true; std::optional< std::string > fragment; dReturn_if_fail(bw != NULL); @@ -292,11 +293,11 @@ void a_Nav_expect_done(BrowserWindow *bw) } if (fragment) { - goto_old_scroll = FALSE; + goto_old_scroll = false; if (repush) { Nav_get_scroll_pos(bw, &posx, &posy); if (posx || posy) - goto_old_scroll = TRUE; + goto_old_scroll = true; } else if (e2equery) { /* Reset scroll, so repush goes to fragment in the next pass */ Nav_save_scroll_pos(bw, a_Nav_stack_ptr(bw), 0, 0); diff --git a/src/prefs.hh b/src/prefs.hh index 51c95ca..96096f0 100644 --- a/src/prefs.hh +++ b/src/prefs.hh @@ -51,7 +51,7 @@ typedef struct { DilloUrl *start_page; DilloUrl *home; DilloUrl *new_tab_page; - bool_t allow_white_bg; + bool allow_white_bg; int32_t white_bg_replacement; int32_t bg_color; int32_t ui_button_highlight_color; @@ -64,65 +64,65 @@ typedef struct { int32_t ui_tab_fg_color; int32_t ui_tab_height; int32_t ui_text_bg_color; - bool_t contrast_visited_color; - bool_t show_tooltip; - bool_t show_ui_tooltip; + bool contrast_visited_color; + bool show_tooltip; + bool show_ui_tooltip; char *theme; int panel_size; - bool_t small_icons; - bool_t limit_text_width; - bool_t adjust_min_width; - bool_t adjust_table_min_width; - bool_t focus_new_tab; + bool small_icons; + bool limit_text_width; + bool adjust_min_width; + bool adjust_table_min_width; + bool focus_new_tab; double font_factor; double zoom_factor; int32_t font_max_size; int32_t font_min_size; int32_t scroll_step; int32_t scroll_page_overlap; - bool_t scrollbar_on_left; - bool_t scrollbar_page_mode; - bool_t show_back; - bool_t show_forw; - bool_t show_home; - bool_t show_reload; - bool_t show_save; - bool_t show_stop; - bool_t show_bookmarks; - bool_t show_tools; - bool_t show_filemenu; - bool_t show_clear_url; - bool_t show_url; - bool_t show_search; - bool_t show_help; - bool_t show_progress_box; - bool_t show_quit_dialog; - bool_t fullwindow_start; - bool_t load_images; + bool scrollbar_on_left; + bool scrollbar_page_mode; + bool show_back; + bool show_forw; + bool show_home; + bool show_reload; + bool show_save; + bool show_stop; + bool show_bookmarks; + bool show_tools; + bool show_filemenu; + bool show_clear_url; + bool show_url; + bool show_search; + bool show_help; + bool show_progress_box; + bool show_quit_dialog; + bool fullwindow_start; + bool load_images; char *ignore_image_formats; - bool_t load_background_images; - bool_t load_stylesheets; - bool_t parse_embedded_css; - bool_t http_persistent_conns; - bool_t http_strict_transport_security; - bool_t http_force_https; + bool load_background_images; + bool load_stylesheets; + bool parse_embedded_css; + bool http_persistent_conns; + bool http_strict_transport_security; + bool http_force_https; int32_t buffered_drawing; char *font_serif; char *font_sans_serif; char *font_cursive; char *font_fantasy; char *font_monospace; - bool_t enterpress_forces_submit; - bool_t middle_click_opens_new_tab; - bool_t right_click_closes_tab; - bool_t scroll_switches_tabs; - bool_t scroll_switches_tabs_reverse; - bool_t search_url_idx; + bool enterpress_forces_submit; + bool middle_click_opens_new_tab; + bool right_click_closes_tab; + bool scroll_switches_tabs; + bool scroll_switches_tabs_reverse; + bool search_url_idx; Dlist *search_urls; char *save_dir; - bool_t show_msg; - bool_t show_extra_warnings; - bool_t middle_click_drags_page; + bool show_msg; + bool show_extra_warnings; + bool middle_click_drags_page; int penalty_hyphen, penalty_hyphen_2; int penalty_em_dash_left, penalty_em_dash_right, penalty_em_dash_right_2; int stretchability_factor; diff --git a/src/prefsparser.cc b/src/prefsparser.cc index e489fff..6ba2fea 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -73,7 +73,7 @@ static int parseOption(char *name, char *value, switch (node->type) { case PREFS_BOOL: - *(bool_t *)node->pref = (!dStrAsciiCasecmp(value, "yes") || + *(bool *)node->pref = (!dStrAsciiCasecmp(value, "yes") || !dStrAsciiCasecmp(value, "true")); break; case PREFS_COLOR: diff --git a/src/uicmd.cc b/src/uicmd.cc index a5e8fad..31ee70d 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -1245,7 +1245,7 @@ void a_UIcmd::a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url) /* * Popup the page menu */ -void a_UIcmd::a_UIcmd_page_popup(void *vbw, bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls) +void a_UIcmd::a_UIcmd_page_popup(void *vbw, bool has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls) { BrowserWindow *bw = (BrowserWindow*)vbw; const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw)); @@ -1263,7 +1263,7 @@ void a_UIcmd::a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl /* * Pop up the image menu */ -void a_UIcmd::a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, +void a_UIcmd::a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool loaded_img, DilloUrl *page_url, DilloUrl *link_url) { a_Menu_image_popup((BrowserWindow*)vbw, url, loaded_img, page_url,link_url); @@ -1273,7 +1273,7 @@ void a_UIcmd::a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_ * Pop up the form menu */ void a_UIcmd::a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform, - bool_t showing_hiddens) + bool showing_hiddens) { a_Menu_form_popup((BrowserWindow*)vbw, url, vform, showing_hiddens); } diff --git a/src/uicmd.hh b/src/uicmd.hh index ae67b44..8633963 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -56,12 +56,12 @@ void a_UIcmd_findtext_reset(BrowserWindow *bw); void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on); void a_UIcmd_focus_main_area(BrowserWindow *bw); void a_UIcmd_focus_location(void *vbw); -void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls); +void a_UIcmd_page_popup(void *vbw, bool has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls); void a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl *page_url); -void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, +void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool loaded_img, DilloUrl *page_url, DilloUrl *link_url); void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform, - bool_t showing_hiddens); + bool showing_hiddens); void a_UIcmd_file_popup(void *vbw, void *v_wid); void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr); void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url); diff --git a/src/url.cc b/src/url.cc index 62b4f8e..d9fa55c 100644 --- a/src/url.cc +++ b/src/url.cc @@ -420,7 +420,7 @@ std::unique_ptr< DilloUrl > a_Url_new(const char *url_str, const char *base_url) dFree(str1); dFree(str2); - bool_t switch_to_https = FALSE; + bool switch_to_https = false; if (url->scheme && !dStrAsciiCasecmp(url->scheme, "http")) { /* @@ -430,10 +430,10 @@ std::unique_ptr< DilloUrl > a_Url_new(const char *url_str, const char *base_url) if (prefs.http_strict_transport_security && a_Hsts_require_https(a_Url_hostname(url.get()))) { _MSG("url: HSTS transformation for %s.\n", url->url_string->str); - switch_to_https = TRUE; + switch_to_https = true; } else if (prefs.http_force_https) { _MSG("url: Force HTTPS transformation for %s.\n", url->url_string->str); - switch_to_https = TRUE; + switch_to_https = true; } } @@ -773,15 +773,14 @@ static const char *Url_host_find_public_suffix(const char *host) return s; } -bool_t a_Url_same_organization(const DilloUrl &u1_, const DilloUrl &u2_) +bool a_Url_same_organization(const DilloUrl &u1_, const DilloUrl &u2_) { const DilloUrl *const u1= &u1_; const DilloUrl *const u2= &u2_; if (!u1 || !u2) - return FALSE; + return false; - return dStrAsciiCasecmp(Url_host_find_public_suffix(URL_HOST(u1)), - Url_host_find_public_suffix(URL_HOST(u2))) - ? FALSE : TRUE; + return not( dStrAsciiCasecmp(Url_host_find_public_suffix(URL_HOST(u1)), + Url_host_find_public_suffix(URL_HOST(u2))) ); } diff --git a/src/url.hh b/src/url.hh index de011d5..8a55826 100644 --- a/src/url.hh +++ b/src/url.hh @@ -136,7 +136,7 @@ std::optional< std::string > a_Url_decode_hex_str(const char *str); std::optional< std::string > a_Url_encode_hex_str(const char *str); std::optional< std::string > a_Url_string_strip_delimiters(const char *str); int a_Url_host_type(const char *host); -bool_t a_Url_same_organization(const DilloUrl &u1, const DilloUrl &u2); +bool a_Url_same_organization(const DilloUrl &u1, const DilloUrl &u2); #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/utf8.cc b/src/utf8.cc index 669c342..e180f8e 100644 --- a/src/utf8.cc +++ b/src/utf8.cc @@ -73,9 +73,9 @@ int a_Utf8_test(const char* src, unsigned int srclen) * for what might make the most sense for Dillo. Surprisingly, they include * Hangul Compatibility Jamo, but they're the experts, so I'll follow along. */ -bool_t a_Utf8_ideographic(const char *s, const char *end, int *len) +bool a_Utf8_ideographic(const char *s, const char *end, int *len) { - bool_t ret = FALSE; + bool ret = false; if ((uchar_t)*s >= 0xe2) { /* Unicode char >= U+2000. */ @@ -85,7 +85,7 @@ bool_t a_Utf8_ideographic(const char *s, const char *end, int *len) ((unicode <= 0xa4cf) || (unicode >= 0xf900 && unicode <= 0xfaff) || (unicode >= 0xff00 && unicode <= 0xff9f))) { - ret = TRUE; + ret = true; } } else { *len = 1 + (int)a_Utf8_end_of_char(s, 0); @@ -93,7 +93,7 @@ bool_t a_Utf8_ideographic(const char *s, const char *end, int *len) return ret; } -bool_t a_Utf8_combining_char(int unicode) +bool a_Utf8_combining_char(int unicode) { return ((unicode >= 0x0300 && unicode <= 0x036f) || (unicode >= 0x1dc0 && unicode <= 0x1dff) || diff --git a/src/utf8.hh b/src/utf8.hh index 6cc1e2a..c8412f4 100644 --- a/src/utf8.hh +++ b/src/utf8.hh @@ -22,8 +22,8 @@ uint_t a_Utf8_end_of_char(const char *str, uint_t i); uint_t a_Utf8_decode(const char*, const char* end, int* len); int a_Utf8_encode(unsigned int ucs, char *buf); int a_Utf8_test(const char* src, unsigned int srclen); -bool_t a_Utf8_ideographic(const char *s, const char *end, int *len); -bool_t a_Utf8_combining_char(int unicode); +bool a_Utf8_ideographic(const char *s, const char *end, int *len); +bool a_Utf8_combining_char(int unicode); int a_Utf8_char_count(const char *str, int len); #ifdef __cplusplus