This is a major lift into C++.

Much of the code is now building in C++, and I'm using C++23.

A spot test seems to work.  Now I can start to debride all the
painful memory management quirks...
This commit is contained in:
2025-03-01 03:03:25 -05:00
parent 3a474cb68e
commit 396b5fc2a6
52 changed files with 165 additions and 166 deletions

View File

@ -27,7 +27,7 @@ libDiof_a_SOURCES = \
mime.h \
about.c \
Url.h \
http.c \
http.cc \
tls.h \
tls.c \
$(TLS_OPENSSL) \

View File

@ -2,7 +2,7 @@
#define __IO_URL_H__
#include "../chain.h"
#include "../url.h"
#include "../url.hh"
#include "../../dlib/dlib.h"
#ifdef __cplusplus

View File

@ -36,9 +36,9 @@
#include "../dns.h"
#include "../web.hh"
#include "../cookies.h"
#include "../auth.h"
#include "../auth.hh"
#include "../prefs.h"
#include "../misc.h"
#include "../misc.hh"
#include "../uicmd.hh"
@ -177,7 +177,7 @@ static int Http_sock_new(void)
static int Http_fd_map_cmp(const void *v1, const void *v2)
{
int fd = VOIDP2INT(v2);
const FdMapEntry_t *e = v1;
const FdMapEntry_t *e = reinterpret_cast< const FdMapEntry_t * >( v1 );
return (fd != e->fd);
}
@ -214,15 +214,15 @@ static void Http_fd_map_remove_entry(int fd)
void a_Http_connect_done(int fd, bool_t success)
{
SocketData_t *sd;
FdMapEntry_t *fme = dList_find_custom(fd_map, INT2VOIDP(fd),
Http_fd_map_cmp);
FdMapEntry_t *fme = reinterpret_cast< FdMapEntry_t * >( dList_find_custom(fd_map, INT2VOIDP(fd),
Http_fd_map_cmp) );
if (fme && (sd = a_Klist_get_data(ValidSocks, fme->skey))) {
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);
if (success && valid_web) {
a_Chain_bfcb(OpSend, info, &sd->SockFD, "FD");
a_Chain_bfcb(OpSend, info, &sd->SockFD, const_cast< void * >( static_cast< const void * >( "FD" ) ));
Http_send_query(sd);
} else {
if (valid_web)
@ -230,7 +230,7 @@ void a_Http_connect_done(int fd, bool_t success)
MSG("fd %d is done and failed\n", sd->SockFD);
dClose(fd);
Http_socket_free(VOIDP2INT(info->LocalKey)); /* free sd */
a_Chain_bfcb(OpAbort, info, NULL, "Both");
a_Chain_bfcb(OpAbort, info, NULL, const_cast< void * >( static_cast< const void * >( "Both" ) ));
dFree(info);
}
} else {
@ -257,7 +257,7 @@ static void Http_connect_queued_sockets(Server_t *srv)
(i < dList_length(srv->queue) &&
srv->active_conns < prefs.http_max_conns);
i++) {
sd = dList_nth_data(srv->queue, i);
sd = reinterpret_cast< SocketData_t * >( dList_nth_data(srv->queue, i) );
if (sd->flags & HTTP_SOCKET_TO_BE_FREED) {
dList_remove(srv->queue, sd);
@ -297,7 +297,7 @@ static void Http_socket_free(int SKey)
{
SocketData_t *S;
if ((S = a_Klist_get_data(ValidSocks, SKey))) {
if ((S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, SKey) ))) {
a_Klist_remove(ValidSocks, SKey);
if (S->flags & HTTP_SOCKET_IOWATCH_ACTIVE) {
@ -363,7 +363,7 @@ static Dstr *Http_make_content_type(const DilloUrl *url)
if (URL_DATA(url)->len > 2) {
/* boundary lines have "--" prepended. Skip that. */
const char *start = URL_DATA(url)->str + 2;
char *eol = strchr(start, '\r');
const char *eol = strchr(start, '\r');
if (eol)
dStr_append_l(dstr, start, eol - start);
} else {
@ -504,14 +504,14 @@ static void Http_send_query(SocketData_t *S)
static void Http_connect_tls(ChainLink *info)
{
int SKey = VOIDP2INT(info->LocalKey);
SocketData_t *S = a_Klist_get_data(ValidSocks, SKey);
SocketData_t *S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, SKey) );
if (S->flags & HTTP_SOCKET_USE_PROXY) {
char *connect_str = Http_get_connect_str(S->url);
DataBuf *dbuf = a_Chain_dbuf_new(connect_str, strlen(connect_str), 0);
MSG_BW(S->web, 1, "Tunnel secure connection through proxy...");
a_Chain_bfcb(OpSend, info, &S->SockFD, "FD");
a_Chain_bfcb(OpSend, info, &S->SockFD, const_cast< void * >( static_cast< const void * >( "FD" ) ));
S->https_proxy_reply = dStr_new(NULL);
a_Chain_bcb(OpSend, info, dbuf, NULL);
@ -529,7 +529,7 @@ static void Http_connect_tls(ChainLink *info)
static void Http_connect_socket_cb(int fd, void *data)
{
int SKey = VOIDP2INT(data);
SocketData_t *S = a_Klist_get_data(ValidSocks, SKey);
SocketData_t *S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, SKey) );
if (S) {
int ret, connect_ret;
@ -567,9 +567,9 @@ static void Http_connect_socket_cb(int fd, void *data)
static void Http_connect_socket(ChainLink *Info)
{
DilloHost *dh;
SocketData_t *S = a_Klist_get_data(ValidSocks, VOIDP2INT(Info->LocalKey));
SocketData_t *S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, VOIDP2INT(Info->LocalKey)) );
for (; (dh = dList_nth_data(S->addr_list, S->addr_list_idx));
for (; (dh = reinterpret_cast< DilloHost * >( dList_nth_data(S->addr_list, S->addr_list_idx) ));
S->addr_list_idx++) {
#ifdef ENABLE_IPV6
struct sockaddr_in6 name;
@ -612,6 +612,7 @@ static void Http_connect_socket(ChainLink *Info)
#ifdef ENABLE_IPV6
case AF_INET6:
{
MSG("Doing 6 connect...\n");
char buf[128];
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&name;
socket_len = sizeof(struct sockaddr_in6);
@ -623,6 +624,8 @@ static void Http_connect_socket(ChainLink *Info)
MSG("Connecting to [%s]:%u\n", buf, S->connect_port);
break;
}
#else
#error Flenser requires modern IP protocol. Legacy IP protocol is deprecated.
#endif
} /* switch */
MSG_BW(S->web, 1, "Contacting host...");
@ -643,7 +646,9 @@ static void Http_connect_socket(ChainLink *Info)
S->flags |= HTTP_SOCKET_IOWATCH_ACTIVE;
break;
} else {
MSG("Http_connect_socket connect ERROR: %s\n", dStrerror(errno));
MSG("Http_connect_socket connect ERROR: %s %d\n", dStrerror(errno), errno);
MSG("Http_connect_socket connect args: %d %p %d(fam) %d\n", S->SockFD, reinterpret_cast< void * >( &name ),
reinterpret_cast< struct sockaddr * >( &name )->sa_family, socket_len );
MSG("We will try another IP address.\n");
}
}
@ -739,7 +744,7 @@ static void Http_dns_cb(int Status, Dlist *addr_list, void *data)
SocketData_t *S;
Server_t *srv;
S = a_Klist_get_data(ValidSocks, SKey);
S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, SKey) );
if (S) {
const char *host = URL_HOST((S->flags & HTTP_SOCKET_USE_PROXY) ?
HTTP_Proxy : S->url);
@ -763,7 +768,7 @@ static void Http_dns_cb(int Status, Dlist *addr_list, void *data)
ChainLink *info = S->Info;
Http_socket_free(SKey);
a_Chain_bfcb(OpAbort, info, NULL, "Both");
a_Chain_bfcb(OpAbort, info, NULL, const_cast< void * >( static_cast< const void * >( "Both" ) ));
dFree(info);
}
}
@ -782,9 +787,9 @@ static int Http_get(ChainLink *Info, void *Data1)
char *hostname;
const DilloUrl *url;
S = a_Klist_get_data(ValidSocks, VOIDP2INT(Info->LocalKey));
S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, VOIDP2INT(Info->LocalKey)) );
/* Reference Web data */
S->web = Data1;
S->web = reinterpret_cast< DilloWeb * >( Data1 );
/* Reference Info data */
S->Info = Info;
@ -819,17 +824,17 @@ static int Http_get(ChainLink *Info, void *Data1)
* This is not built to accept arbitrary sockets.
*/
static bool_t Http_socket_reuse_compatible(SocketData_t *old,
SocketData_t *new)
SocketData_t *new_)
{
/*
* If we are using TLS through a proxy, we need to ensure that old and new
* are going through to the same host:port.
*/
if (a_Web_valid(new->web) &&
if (a_Web_valid(new_->web) &&
((old->flags & HTTP_SOCKET_TLS) == 0 ||
(old->flags & HTTP_SOCKET_USE_PROXY) == 0 ||
((URL_PORT(old->url) == URL_PORT(new->url)) &&
!dStrAsciiCasecmp(URL_HOST(old->url), URL_HOST(new->url)))))
((URL_PORT(old->url) == URL_PORT(new_->url)) &&
!dStrAsciiCasecmp(URL_HOST(old->url), URL_HOST(new_->url)))))
return TRUE;
return FALSE;
}
@ -840,7 +845,7 @@ static bool_t Http_socket_reuse_compatible(SocketData_t *old,
*/
static void Http_socket_reuse(int SKey)
{
SocketData_t *new_sd, *old_sd = a_Klist_get_data(ValidSocks, SKey);
SocketData_t *new_sd, *old_sd = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, SKey) );
if (old_sd) {
Server_t *srv = Http_server_get(old_sd->connected_to,
@ -849,7 +854,7 @@ static void Http_socket_reuse(int SKey)
int i, n = dList_length(srv->queue);
for (i = 0; i < n; i++) {
new_sd = dList_nth_data(srv->queue, i);
new_sd = reinterpret_cast< SocketData_t * >( dList_nth_data(srv->queue, i) );
if (!(new_sd->flags & HTTP_SOCKET_TO_BE_FREED) &&
Http_socket_reuse_compatible(old_sd, new_sd)) {
@ -886,7 +891,7 @@ void a_Http_ccc(int Op, int Branch, int Dir, ChainLink *Info,
SocketData_t *sd;
DataBuf *dbuf;
dReturn_if_fail( a_Chain_check("a_Http_ccc", Op, Branch, Dir, Info) );
dReturn_if_fail( a_Chain_check(const_cast< char * >( "a_Http_ccc" ), Op, Branch, Dir, Info) );
if (Branch == 1) {
if (Dir == BCK) {
@ -922,10 +927,10 @@ void a_Http_ccc(int Op, int Branch, int Dir, ChainLink *Info,
switch (Op) {
case OpAbort:
_MSG("ABORT 1F\n");
if ((sd = a_Klist_get_data(ValidSocks, SKey)))
if ((sd = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, SKey) )))
MSG_BW(sd->web, 1, "Can't get %s", URL_STR(sd->url));
Http_socket_free(SKey);
a_Chain_fcb(OpAbort, Info, NULL, "Both");
a_Chain_fcb(OpAbort, Info, NULL, const_cast< void * >( static_cast< const void * >( "Both" ) ));
dFree(Info);
break;
default:
@ -935,13 +940,13 @@ void a_Http_ccc(int Op, int Branch, int Dir, ChainLink *Info,
}
} else if (Branch == 2) {
if (Dir == FWD) {
sd = a_Klist_get_data(ValidSocks, SKey);
sd = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, SKey) );
assert(sd);
/* Receiving from server */
switch (Op) {
case OpSend:
if (sd->https_proxy_reply) {
dbuf = Data1;
dbuf = reinterpret_cast< DataBuf * >( Data1 );
dStr_append(sd->https_proxy_reply, dbuf->Buf);
if (strstr(sd->https_proxy_reply->str, "\r\n\r\n")) {
if (sd->https_proxy_reply->len >= 12 &&
@ -959,13 +964,13 @@ void a_Http_ccc(int Op, int Branch, int Dir, ChainLink *Info,
MSG("CONNECT through proxy failed. Server sent:\n%s\n",
sd->https_proxy_reply->str);
Http_socket_free(SKey);
a_Chain_bfcb(OpAbort, Info, NULL, "Both");
a_Chain_bfcb(OpAbort, Info, NULL, const_cast< void * >( static_cast< const void * >( "Both" ) ));
dFree(Info);
}
}
} else {
/* Data1 = dbuf */
a_Chain_fcb(OpSend, Info, Data1, "send_page_2eof");
a_Chain_fcb(OpSend, Info, Data1, const_cast< void * >( static_cast< const void * >( "send_page_2eof" ) ));
}
break;
case OpEnd:
@ -975,7 +980,7 @@ void a_Http_ccc(int Op, int Branch, int Dir, ChainLink *Info,
sd->https_proxy_reply->len ? sd->https_proxy_reply->str :
"(nothing)");
Http_socket_free(SKey);
a_Chain_bfcb(OpAbort, Info, NULL, "Both");
a_Chain_bfcb(OpAbort, Info, NULL, const_cast< void * >( static_cast< const void * >( "Both" ) ));
} else {
Http_socket_free(SKey);
a_Chain_fcb(OpEnd, Info, NULL, NULL);
@ -990,7 +995,7 @@ void a_Http_ccc(int Op, int Branch, int Dir, ChainLink *Info,
"(nothing)");
}
Http_socket_free(SKey);
a_Chain_fcb(OpAbort, Info, NULL, "Both");
a_Chain_fcb(OpAbort, Info, NULL, const_cast< void * >( static_cast< const void * >( "Both" ) ));
dFree(Info);
break;
default:
@ -1005,13 +1010,13 @@ void a_Http_ccc(int Op, int Branch, int Dir, ChainLink *Info,
break;
case OpSend:
if (Data2) {
if (!strcmp(Data2, "FD")) {
if (!strcmp(reinterpret_cast< const char * >( Data2 ), "FD")) {
int fd = *(int*)Data1;
FdMapEntry_t *fme = dList_find_custom(fd_map, INT2VOIDP(fd),
Http_fd_map_cmp);
FdMapEntry_t *fme = reinterpret_cast< FdMapEntry_t * >( dList_find_custom(fd_map, INT2VOIDP(fd),
Http_fd_map_cmp) );
Info->LocalKey = INT2VOIDP(fme->skey);
a_Chain_bcb(OpSend, Info, Data1, Data2);
} else if (!strcmp(Data2, "reply_complete")) {
} else if (!strcmp(reinterpret_cast< const char * >( Data2 ), "reply_complete")) {
a_Chain_bfcb(OpEnd, Info, NULL, NULL);
Http_socket_reuse(SKey);
dFree(Info);
@ -1043,7 +1048,7 @@ static void Http_socket_enqueue(Server_t *srv, SocketData_t* sock)
int i, n = dList_length(srv->queue);
for (i = 0; i < n; i++) {
SocketData_t *curr = dList_nth_data(srv->queue, i);
SocketData_t *curr = reinterpret_cast< SocketData_t * >( dList_nth_data(srv->queue, i) );
if (a_Web_valid(curr->web) && (curr->web->flags & WEB_Image)) {
dList_insert_pos(srv->queue, sock, i);
@ -1082,7 +1087,7 @@ static void Http_server_remove(Server_t *srv)
{
SocketData_t *sd;
while ((sd = dList_nth_data(srv->queue, 0))) {
while ((sd = reinterpret_cast< SocketData_t * >( dList_nth_data(srv->queue, 0) ))) {
dList_remove_fast(srv->queue, sd);
dFree(sd);
}
@ -1099,7 +1104,7 @@ static void Http_servers_remove_all(void)
while (dList_length(servers) > 0) {
srv = (Server_t*) dList_nth_data(servers, 0);
while ((sd = dList_nth_data(srv->queue, 0))) {
while ((sd = reinterpret_cast< SocketData_t * >( dList_nth_data(srv->queue, 0) ))) {
dList_remove(srv->queue, sd);
dFree(sd);
}

View File

@ -19,7 +19,7 @@ extern "C" {
#endif /* __cplusplus */
#include "../cache.h"
#include "../cache.hh"
typedef void* (*Viewer_t) (const char*, void*, CA_Callback_t*, void**);

View File

@ -25,7 +25,7 @@
extern "C" {
#endif
#include "../url.h"
#include "../url.hh"
#define TLS_CONNECT_NEVER -1
#define TLS_CONNECT_NOT_YET 0

View File

@ -19,7 +19,7 @@
extern "C" {
#endif
#include "../url.h"
#include "../url.hh"
const char *a_Tls_mbedtls_version(char *buf, int n);
void a_Tls_mbedtls_init(void);

View File

@ -29,7 +29,7 @@
extern "C" {
#endif
#include "../url.h"
#include "../url.hh"
const char *a_Tls_openssl_version(char *buf, int n);
void a_Tls_openssl_init(void);

View File

@ -43,8 +43,8 @@ dillo_SOURCES = \
actions.h \
hsts.c \
hsts.h \
auth.c \
auth.h \
auth.cc \
auth.hh \
md5.c \
md5.h \
digest.c \
@ -52,8 +52,8 @@ dillo_SOURCES = \
colors.c \
colors.h \
binaryconst.h \
misc.c \
misc.h \
misc.cc \
misc.hh \
history.h \
history.c \
prefs.c \
@ -64,8 +64,8 @@ dillo_SOURCES = \
keys.hh \
msg.h \
list.h \
url.c \
url.h \
url.cc \
url.hh \
bitvec.c \
bitvec.h \
klist.c \
@ -84,8 +84,8 @@ dillo_SOURCES = \
web.hh \
nav.c \
nav.h \
cache.c \
cache.h \
cache.cc \
cache.hh \
decode.c \
decode.h \
dicache.c \

View File

@ -18,9 +18,9 @@
#include <ctype.h> /* iscntrl, isascii */
#include "auth.h"
#include "auth.hh"
#include "msg.h"
#include "misc.h"
#include "misc.hh"
#include "dialog.hh"
#include "digest.h"
#include "../dlib/dlib.h"
@ -359,7 +359,7 @@ static AuthHost_t *Auth_host_by_url(const DilloUrl *url)
AuthHost_t *host;
int i;
for (i = 0; (host = dList_nth_data(auth_hosts, i)); i++)
for (i = 0; (host = reinterpret_cast< AuthHost_t * >( dList_nth_data(auth_hosts, i) )); i++)
if (((dStrAsciiCasecmp(URL_SCHEME(url), host->scheme) == 0) &&
(dStrAsciiCasecmp(URL_AUTHORITY(url), host->authority) == 0)))
return host;
@ -376,7 +376,7 @@ static AuthRealm_t *Auth_realm_by_name(const AuthHost_t *host,
AuthRealm_t *realm;
int i;
for (i = 0; (realm = dList_nth_data(host->realms, i)); i++)
for (i = 0; (realm = reinterpret_cast< AuthRealm_t * >( dList_nth_data(host->realms, i) )); i++)
if (strcmp(realm->name, name) == 0)
return realm;
@ -394,10 +394,10 @@ static AuthRealm_t *Auth_realm_by_path(const AuthHost_t *host,
int match_length = 0;
realm_best = NULL;
for (i = 0; (realm = dList_nth_data(host->realms, i)); i++) {
for (i = 0; (realm = reinterpret_cast< AuthRealm_t * >( dList_nth_data(host->realms, i) )); i++) {
char *realm_path;
for (j = 0; (realm_path = dList_nth_data(realm->paths, j)); j++) {
for (j = 0; (realm_path = reinterpret_cast< char * >( dList_nth_data(realm->paths, j) )); j++) {
int realm_path_length = strlen(realm_path);
if (Auth_path_is_inside(path, realm_path, realm_path_length) &&
!(realm_best && match_length >= realm_path_length)) {
@ -433,7 +433,7 @@ static int Auth_realm_includes_path(const AuthRealm_t *realm, const char *path)
int i;
char *realm_path;
for (i = 0; (realm_path = dList_nth_data(realm->paths, i)); i++)
for (i = 0; (realm_path = reinterpret_cast< char * >( dList_nth_data(realm->paths, i) )); i++)
if (Auth_path_is_inside(path, realm_path, strlen(realm_path)))
return 1;
@ -453,7 +453,7 @@ static void Auth_realm_add_path(AuthRealm_t *realm, const char *path)
n_path[--len] = 0;
/* delete existing paths that are inside the new one */
for (i = 0; (realm_path = dList_nth_data(realm->paths, i)); i++) {
for (i = 0; (realm_path = reinterpret_cast< char * >( dList_nth_data(realm->paths, i) )); i++) {
if (Auth_path_is_inside(realm_path, path, len)) {
dList_remove_fast(realm->paths, realm_path);
dFree(realm_path);
@ -635,7 +635,7 @@ static int Auth_do_auth_dialog(const AuthParse_t *auth_parse,
data->url = a_Url_dup(url);
ret = a_Dialog_user_password(title, msg, Auth_do_auth_dialog_cb, data);
dFree(title); dFree(msg);
a_Url_free((void *)data->url);
a_Url_free(const_cast< DilloUrl * >( data->url ));
dFree(data);
return ret;
}
@ -673,11 +673,11 @@ int a_Auth_do_auth(Dlist *challenges, const DilloUrl *url)
int i;
char *chal;
for (i = 0; (chal = dList_nth_data(challenges, i)); ++i)
for (i = 0; (chal = reinterpret_cast< char * >( dList_nth_data(challenges, i) )); ++i)
if (!dStrnAsciiCasecmp(chal, "Digest ", 7))
if (Auth_do_auth(chal, DIGEST, url))
return 1;
for (i = 0; (chal = dList_nth_data(challenges, i)); ++i)
for (i = 0; (chal = reinterpret_cast< char * >( dList_nth_data(challenges, i) )); ++i)
if (!dStrnAsciiCasecmp(chal, "Basic ", 6))
if (Auth_do_auth(chal, BASIC, url))
return 1;

View File

@ -1,11 +1,6 @@
#ifndef __AUTH_H__
#define __AUTH_H__
#pragma once
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "url.h"
#include "url.hh"
enum AuthParseHTTPAuthType_t { TYPENOTSET, BASIC, DIGEST };
enum AuthParseDigestAlgorithm_t { ALGORITHMNOTSET, MD5, MD5SESS };
@ -33,8 +28,3 @@ char *a_Auth_get_auth_str(const DilloUrl *url, const char *request_uri);
int a_Auth_do_auth(Dlist *auth_string, const DilloUrl *url);
void a_Auth_init(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* !__AUTH_H__ */

View File

@ -13,7 +13,7 @@
#ifndef __BW_H__
#define __BW_H__
#include "url.h" /* for DilloUrl */
#include "url.hh" /* for DilloUrl */
/*
* Flag Defines for a_Bw_stop_clients()

View File

@ -29,10 +29,10 @@
#include "nav.h"
#include "cookies.h"
#include "hsts.h"
#include "misc.h"
#include "misc.hh"
#include "capi.h"
#include "decode.h"
#include "auth.h"
#include "auth.hh"
#include "domain.h"
#include "timeout.hh"
#include "uicmd.hh"
@ -96,7 +96,7 @@ static void Cache_entry_inject(const DilloUrl *Url, Dstr *data_ds);
*/
static int Cache_entry_cmp(const void *v1, const void *v2)
{
const CacheEntry_t *d1 = v1, *d2 = v2;
const CacheEntry_t *d1 = reinterpret_cast< const CacheEntry_t * >( v1 ), *d2 = reinterpret_cast< const CacheEntry_t * >( v2 );
return a_Url_cmp(d1->Url, d2->Url);
}
@ -106,8 +106,8 @@ static int Cache_entry_cmp(const void *v1, const void *v2)
*/
static int Cache_entry_by_url_cmp(const void *v1, const void *v2)
{
const DilloUrl *u1 = ((CacheEntry_t*)v1)->Url;
const DilloUrl *u2 = v2;
const DilloUrl *u1 = reinterpret_cast< const CacheEntry_t * >( v1 )->Url;
const DilloUrl *u2 = reinterpret_cast< const DilloUrl * >( v2 );
return a_Url_cmp(u1, u2);
}
@ -179,7 +179,7 @@ static void Cache_client_dequeue(CacheClient_t *Client)
{
if (Client) {
dList_remove(ClientQueue, Client);
a_Web_free(Client->Web);
a_Web_free(reinterpret_cast< DilloWeb * >( Client->Web ));
dFree(Client);
}
}
@ -217,7 +217,7 @@ static void Cache_entry_init(CacheEntry_t *NewEntry, const DilloUrl *Url)
*/
static CacheEntry_t *Cache_entry_search(const DilloUrl *Url)
{
return dList_find_sorted(CachedURLs, Url, Cache_entry_by_url_cmp);
return reinterpret_cast< CacheEntry_t * >( dList_find_sorted(CachedURLs, Url, Cache_entry_by_url_cmp) );
}
/**
@ -333,7 +333,7 @@ static void Cache_entry_remove(CacheEntry_t *entry, DilloUrl *url)
return;
/* remove all clients for this entry */
for (i = 0; (Client = dList_nth_data(ClientQueue, i)); ++i) {
for (i = 0; (Client = reinterpret_cast< CacheClient_t * >( dList_nth_data(ClientQueue, i) )); ++i) {
if (Client->Url == entry->Url) {
a_Cache_stop_client(Client->Key);
--i;
@ -377,7 +377,7 @@ int a_Cache_open_url(void *web, CA_Callback_t Call, void *CbData)
{
int ClientKey;
CacheEntry_t *entry;
DilloWeb *Web = web;
DilloWeb *Web = reinterpret_cast< DilloWeb * >( web );
DilloUrl *Url = Web->url;
if (URL_FLAGS(Url) & URL_E2EQuery) {
@ -766,9 +766,9 @@ static void Cache_parse_header(CacheEntry_t *entry)
if ((Cookies = Cache_parse_multiple_fields(header, "Set-Cookie"))) {
CacheClient_t *client;
for (i = 0; (client = dList_nth_data(ClientQueue, i)); ++i) {
for (i = 0; (client = reinterpret_cast< CacheClient_t * >( dList_nth_data(ClientQueue, i) )); ++i) {
if (client->Url == entry->Url) {
DilloWeb *web = client->Web;
DilloWeb *web = reinterpret_cast< DilloWeb * >( client->Web );
if (!web->requester ||
a_Url_same_organization(entry->Url, web->requester)) {
@ -975,7 +975,7 @@ bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size,
int i;
CacheClient_t *Client;
for (i = 0; (Client = dList_nth_data(ClientQueue, i)); ++i) {
for (i = 0; (Client = reinterpret_cast< CacheClient_t * >( dList_nth_data(ClientQueue, i) )); ++i) {
if (Client->Url == entry->Url) {
DilloWeb *web = (DilloWeb *)Client->Web;
@ -1106,7 +1106,7 @@ int a_Cache_download_enabled(const DilloUrl *url)
*/
static void Cache_null_client(int Op, CacheClient_t *Client)
{
DilloWeb *Web = Client->Web;
DilloWeb *Web = reinterpret_cast< DilloWeb * >( Client->Web );
/* make the stop button insensitive when done */
if (Op == CA_Close) {
@ -1145,7 +1145,7 @@ static void Cache_savelink_cb(void *vdata)
static void Cache_provide_redirection_blocked_page(CacheEntry_t *entry,
CacheClient_t *client)
{
DilloWeb *clientWeb = client->Web;
DilloWeb *clientWeb = reinterpret_cast< DilloWeb * >( client->Web );
a_Web_dispatch_by_type("text/html", clientWeb, &client->Callback,
&client->CbData);
@ -1155,7 +1155,7 @@ static void Cache_provide_redirection_blocked_page(CacheEntry_t *entry,
"</a> to <a href=\"", URL_STR(entry->Location), "\">",
URL_STR(entry->Location), "</a> based on your domainrc "
"settings.</body></html>", NULL);
client->BufSize = strlen(client->Buf);
client->BufSize = strlen(reinterpret_cast< const char * >( client->Buf ));
(client->Callback)(CA_Send, client);
dFree(client->Buf);
}
@ -1207,9 +1207,9 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
}
Busy = TRUE;
for (i = 0; (Client = dList_nth_data(ClientQueue, i)); ++i) {
for (i = 0; (Client = reinterpret_cast< CacheClient_t * >( dList_nth_data(ClientQueue, i) )); ++i) {
if (Client->Url == entry->Url) {
ClientWeb = Client->Web; /* It was a (void*) */
ClientWeb = reinterpret_cast< DilloWeb * >( Client->Web ); /* It was a (void*) */
Client_bw = ClientWeb->bw; /* 'bw' in a local var */
if (ClientWeb->flags & WEB_RootUrl) {
@ -1401,9 +1401,9 @@ CacheClient_t *a_Cache_client_get_if_unique(int Key)
int i, n = 0;
CacheClient_t *Client, *iClient;
if ((Client = dList_find_custom(ClientQueue, INT2VOIDP(Key),
Cache_client_by_key_cmp))) {
for (i = 0; (iClient = dList_nth_data(ClientQueue, i)); ++i) {
if ((Client = reinterpret_cast< CacheClient_t * >( dList_find_custom(ClientQueue, INT2VOIDP(Key),
Cache_client_by_key_cmp) ))) {
for (i = 0; (iClient = reinterpret_cast< CacheClient_t * >( dList_nth_data(ClientQueue, i) )); ++i) {
if (iClient->Url == Client->Url) {
++n;
}
@ -1423,8 +1423,8 @@ void a_Cache_stop_client(int Key)
DICacheEntry *DicEntry;
/* The client can be in both queues at the same time */
if ((Client = dList_find_custom(ClientQueue, INT2VOIDP(Key),
Cache_client_by_key_cmp))) {
if ((Client = reinterpret_cast< CacheClient_t * >( dList_find_custom(ClientQueue, INT2VOIDP(Key),
Cache_client_by_key_cmp) ))) {
/* Dicache */
if ((DicEntry = a_Dicache_get_entry(Client->Url, Client->Version)))
a_Dicache_unref(Client->Url, Client->Version);
@ -1451,13 +1451,13 @@ void a_Cache_freeall(void)
void *data;
/* free the client queue */
while ((Client = dList_nth_data(ClientQueue, 0)))
while ((Client = reinterpret_cast< CacheClient_t * >( dList_nth_data(ClientQueue, 0) )))
Cache_client_dequeue(Client);
/* Remove every cache entry */
while ((data = dList_nth_data(CachedURLs, 0))) {
dList_remove_fast(CachedURLs, data);
Cache_entry_free(data);
Cache_entry_free(reinterpret_cast< CacheEntry_t * >( data ));
}
/* Remove the cache list */
dList_free(CachedURLs);

View File

@ -7,7 +7,7 @@ extern "C" {
#include "chain.h"
#include "url.h"
#include "url.hh"
/*
* Cache Op codes

View File

@ -6,7 +6,7 @@ extern "C" {
#endif /* __cplusplus */
#include "cache.h"
#include "cache.hh"
#include "web.hh"
/*

View File

@ -1,6 +1,10 @@
#ifndef __CHAIN_H__
#define __CHAIN_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
* Concomitant control chain (CCC)
* Theory and code by Jorge Arellano Cid <jcid@dillo.org>
@ -73,4 +77,7 @@ int a_Chain_check(char *FuncStr, int Op, int Branch, int Dir,
DataBuf *a_Chain_dbuf_new(void *buf, int size, int code);
#ifdef __cplusplus
}
#endif
#endif /* __CHAIN_H__ */

View File

@ -5,7 +5,7 @@
extern "C" {
#endif /* __cplusplus */
#include "url.h"
#include "url.hh"
#include "image.hh"

View File

@ -16,6 +16,8 @@
#include <math.h> // for rint()
#include <string.h>
#include <cassert>
#include <memory>
#include <FL/fl_ask.H>
@ -33,7 +35,7 @@
#include "msg.h"
#include "dialog.hh"
#include "misc.h"
#include "misc.hh"
#include "prefs.h"
#include "dlib/dlib.h"
@ -224,6 +226,8 @@ const char *a_Dialog_input(const char *title, const char *msg)
input_str = dStrdup(c_inp->value());
prefs.search_url_idx = ch->value();
}
//delete b;
assert(window->contains(b));
window.reset();
return (input_answer == 1) ? input_str : NULL;

View File

@ -8,7 +8,7 @@ extern "C" {
#include "bitvec.h"
#include "image.hh"
#include "cache.h"
#include "cache.hh"
/** Symbolic name to request the last version of an image */
#define DIC_Last -1

View File

@ -1,9 +1,13 @@
#ifndef __DIGEST_H__
#define __DIGEST_H__
#include "auth.h"
#include "auth.hh"
#include "../dlib/dlib.h"
#ifdef __cplusplus
extern "C" {
#endif
char *a_Digest_create_cnonce(void);
int a_Digest_compute_digest(AuthRealm_t *realm,
@ -13,4 +17,7 @@ char *a_Digest_authorization_hdr(AuthRealm_t *realm,
const DilloUrl *url,
const char *uri);
#ifdef __cplusplus
}
#endif
#endif /* !__DIGEST_H__ */

View File

@ -45,7 +45,7 @@
#include "prefsparser.hh"
#include "keys.hh"
#include "bw.h"
#include "misc.h"
#include "misc.hh"
#include "history.h"
#include "version.hh"
@ -60,7 +60,7 @@
#include "actions.h"
#include "hsts.h"
#include "domain.h"
#include "auth.h"
#include "auth.hh"
#include "styleengine.hh"
#include "dw/fltkcore.hh"

View File

@ -5,7 +5,7 @@
extern "C" {
#endif /* __cplusplus */
#include "url.h"
#include "url.hh"
#include "image.hh"

View File

@ -6,7 +6,7 @@ extern "C" {
#endif
#include <stdio.h>
#include "url.h"
#include "url.hh"
void a_Domain_parse(FILE *fp);
void a_Domain_freeall(void);

View File

@ -5,9 +5,9 @@
extern "C" {
#endif /* __cplusplus */
#include "url.h"
#include "url.hh"
#include "image.hh"
#include "cache.h"
#include "cache.hh"
void *a_Png_new(DilloImage *Image, DilloUrl *url, int version);

View File

@ -5,7 +5,7 @@
extern "C" {
#endif /* __cplusplus */
#include "url.h"
#include "url.hh"
#include "image.hh"

View File

@ -5,7 +5,7 @@
extern "C" {
#endif /* __cplusplus */
#include "url.h"
#include "url.hh"
#include "image.hh"

View File

@ -21,7 +21,7 @@
#include "dw/textblock.hh"
#include "dlib/dlib.h"
#include "misc.h"
#include "misc.hh"
#include "msg.h"
#include "prefs.h"
#include "uicmd.hh"

View File

@ -1,7 +1,7 @@
#ifndef __FORM_HH__
#define __FORM_HH__
#include "url.h"
#include "url.hh"
/*
* Typedefs

View File

@ -67,7 +67,7 @@
#include "msg.h"
#include "image.hh"
#include "cache.h"
#include "cache.hh"
#include "dicache.h"
#define INTERLACE 0x40

View File

@ -2,7 +2,7 @@
#ifndef __DILLO_HISTORY_H__
#define __DILLO_HISTORY_H__
#include "url.h"
#include "url.hh"
#ifdef __cplusplus

View File

@ -2,7 +2,7 @@
#define __HSTS_H__
#include "d_size.h"
#include "url.h"
#include "url.hh"
#ifdef __cplusplus
extern "C" {

View File

@ -30,7 +30,7 @@
#include "html_charrefs.h"
#include "utf8.hh"
#include "misc.h"
#include "misc.hh"
#include "uicmd.hh"
#include "history.h"
#include "menu.hh"

View File

@ -13,7 +13,7 @@
#ifndef __HTML_HH__
#define __HTML_HH__
#include "url.h" // for DilloUrl
#include "url.hh" // for DilloUrl
#ifdef __cplusplus
extern "C" {

View File

@ -14,7 +14,7 @@
#ifndef __HTML_COMMON_HH__
#define __HTML_COMMON_HH__
#include "url.h"
#include "url.hh"
#include "bw.h"
#include "lout/misc.hh"

View File

@ -24,7 +24,7 @@ extern "C" {
#include "bitvec.h"
#include "url.h"
#include "url.hh"
/*
* Defines

View File

@ -33,7 +33,7 @@
#endif
#include "image.hh"
#include "cache.h"
#include "cache.hh"
#include "dicache.h"
#include "capi.h" /* get cache entry status */
#include "msg.h"

View File

@ -17,7 +17,7 @@
#include "utf8.hh"
#include "msg.h"
#include "misc.h"
#include "misc.hh"
/**
* Escape characters as %XX sequences.
@ -25,7 +25,7 @@
*/
char *a_Misc_escape_chars(const char *str, const char *esc_set)
{
static const char *const hex = "0123456789ABCDEF";
static const char hex[] = "0123456789ABCDEF";
char *p = NULL;
Dstr *dstr;
int i;
@ -136,7 +136,7 @@ typedef enum {
int a_Misc_get_content_type_from_data(void *Data, size_t Size, const char **PT)
{
size_t i, non_ascci, non_ascci_text, bin_chars;
char *p = Data;
char *p = reinterpret_cast< char * >( Data );
int st = 1; /* default to "doubt' */
DetectedContentType Type = DT_OCTET_STREAM; /* default to binary */

View File

@ -1,13 +1,7 @@
#ifndef __DILLO_MISC_H__
#define __DILLO_MISC_H__
#pragma once
#include <stddef.h> /* for size_t */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define d_isascii(c) (((c) & ~0x7f) == 0)
char *a_Misc_escape_chars(const char *str, const char *esc_set);
@ -21,10 +15,3 @@ int a_Misc_parse_geometry(char *geom, int *x, int *y, int *w, int *h);
int a_Misc_parse_search_url(char *source, char **label, char **urlstr);
char *a_Misc_encode_base64(const char *in);
Dstr *a_Misc_file2dstr(const char *filename);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __DILLO_MISC_H__ */

View File

@ -17,10 +17,10 @@
#include "msg.h"
#include "prefs.h"
#include "cache.h"
#include "cache.hh"
#include "bw.h"
#include "web.hh"
#include "misc.h"
#include "misc.hh"
#include "styleengine.hh"
#include "uicmd.hh"

View File

@ -27,7 +27,7 @@
#include "msg.h"
#include "image.hh"
#include "cache.h"
#include "cache.hh"
#include "dicache.h"
enum prog_state {

View File

@ -13,7 +13,7 @@
#ifndef __PREFS_H__
#define __PREFS_H__
#include "url.h"
#include "url.hh"
#ifdef __cplusplus
extern "C" {

View File

@ -22,7 +22,7 @@
#include <limits.h>
#include "prefs.h"
#include "misc.h"
#include "misc.hh"
#include "msg.h"
#include "colors.h"

View File

@ -13,7 +13,7 @@
#include "../dlib/dlib.h"
#include "msg.h"
#include "prefs.h"
#include "misc.h"
#include "misc.hh"
#include "html_common.hh"
#include "styleengine.hh"
#include "web.hh"

View File

@ -17,7 +17,7 @@
#include "msg.h"
#include "image.hh"
#include "cache.h"
#include "cache.hh"
#include "dicache.h"
#define NANOSVG_ALL_COLOR_KEYWORDS

View File

@ -45,7 +45,7 @@
#include "history.h"
#include "msg.h"
#include "prefs.h"
#include "misc.h"
#include "misc.hh"
#include "dlib/dlib.h"
#include "dw/fltkviewport.hh"

View File

@ -46,9 +46,9 @@
#include <string.h>
#include <ctype.h>
#include "url.h"
#include "url.hh"
#include "hsts.h"
#include "misc.h"
#include "misc.hh"
#include "msg.h"
static const char *HEX = "0123456789ABCDEF";
@ -97,7 +97,7 @@ char *a_Url_str(const DilloUrl *u)
*/
const char *a_Url_hostname(const DilloUrl *u)
{
char *p;
const char *p;
/* Internal url handling IS transparent to the caller */
DilloUrl *url = (DilloUrl *) u;
@ -603,7 +603,7 @@ char *a_Url_decode_hex_str(const char *str)
}
*dest++ = 0;
new_str = dRealloc(new_str, sizeof(char) * (dest - new_str));
new_str = reinterpret_cast< char * >( dRealloc(new_str, sizeof(char) * (dest - new_str)) );
return new_str;
}

View File

@ -1,9 +1,8 @@
#ifndef __WEB_H__
#define __WEB_H__
#pragma once
#include <stdio.h> /* for FILE */
#include "bw.h" /* for BrowserWindow */
#include "cache.h" /* for CA_Callback_t */
#include "cache.hh" /* for CA_Callback_t */
#include "image.hh" /* for DilloImage */
#ifdef __cplusplus
@ -47,4 +46,3 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *web,
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __WEB_H__ */

View File

@ -19,7 +19,7 @@
#include "msg.h"
#include "image.hh"
#include "cache.h"
#include "cache.hh"
#include "dicache.h"
enum prog_state {