From 06f8226487e551b38328cb8238ca0c50d9d810d2dd3b366e138f8b1698ccaf64 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 10 Apr 2025 02:46:06 -0400 Subject: [PATCH] Migrate a lot of C to C++. It will let me put a lot more dtors into certain structs that C++ code calls `free` on members within. --- src/IO/{IO.c => IO.cc} | 42 ++++----- src/IO/{IO.h => IO.hh} | 2 +- src/IO/Makefile.am | 14 +-- src/IO/Url.h | 2 +- src/IO/{dpi.c => dpi.cc} | 36 ++++---- src/IO/http.cc | 12 +-- src/IO/{mime.c => mime.cc} | 6 +- src/IO/{mime.h => mime.hh} | 0 src/IO/{tls.c => tls.cc} | 6 +- src/IO/{tls.h => tls.hh} | 1 + src/IO/{tls_openssl.c => tls_openssl.cc} | 41 +++++---- src/IO/{tls_openssl.h => tls_openssl.hh} | 0 src/Makefile.am | 90 +++++++++--------- src/{actions.c => actions.cc} | 8 +- src/{actions.h => actions.hh} | 0 src/auth.cc | 4 +- src/{bookmark.c => bookmark.cc} | 16 ++-- src/{bookmark.h => bookmark.hh} | 2 +- src/{bw.c => bw.cc} | 12 +-- src/{bw.h => bw.hh} | 0 src/cache.cc | 18 ++-- src/cache.hh | 2 +- src/{capi.c => capi.cc} | 112 +++++++++++------------ src/{capi.h => capi.hh} | 0 src/{chain.c => chain.cc} | 6 +- src/{chain.h => chain.hh} | 0 src/{colors.c => colors.cc} | 4 +- src/{colors.h => colors.hh} | 0 src/{cookies.c => cookies.cc} | 12 +-- src/{cookies.h => cookies.hh} | 0 src/css.cc | 2 +- src/cssparser.cc | 4 +- src/{decode.c => decode.cc} | 4 +- src/{decode.h => decode.hh} | 0 src/{dgif.h => dgif.hh} | 0 src/dialog.cc | 4 +- src/{dicache.c => dicache.cc} | 42 ++++----- src/{dicache.h => dicache.hh} | 0 src/{digest.c => digest.cc} | 4 +- src/{digest.h => digest.hh} | 0 src/dillo.cc | 26 +++--- src/{djpeg.h => djpeg.hh} | 0 src/{dns.c => dns.cc} | 10 +- src/{dns.h => dns.hh} | 0 src/{domain.c => domain.cc} | 6 +- src/{domain.h => domain.hh} | 0 src/{dpiapi.c => dpiapi.cc} | 8 +- src/{dpiapi.h => dpiapi.hh} | 0 src/{dpng.h => dpng.hh} | 2 + src/{dsvg.h => dsvg.hh} | 1 + src/{dwebp.h => dwebp.hh} | 0 src/findbar.cc | 4 +- src/form.cc | 4 +- src/{gif.c => gif.cc} | 31 ++++--- src/{history.c => history.cc} | 6 +- src/{history.h => history.hh} | 0 src/{hsts.c => hsts.cc} | 16 ++-- src/{hsts.h => hsts.hh} | 0 src/html.cc | 12 +-- src/html_common.hh | 2 +- src/image.cc | 2 +- src/imgbuf.cc | 2 +- src/{jpeg.c => jpeg.cc} | 27 +++--- src/keys.cc | 2 +- src/list.h | 10 +- src/menu.cc | 6 +- src/menu.hh | 2 +- src/misc.cc | 2 +- src/{msg.h => msg.hh} | 4 +- src/nanosvg.h | 8 +- src/nanosvgrast.h | 2 +- src/{nav.c => nav.cc} | 24 ++--- src/{nav.h => nav.hh} | 2 +- src/paths.cc | 2 +- src/plain.cc | 6 +- src/{png.c => png.cc} | 27 +++--- src/{prefs.c => prefs.cc} | 2 +- src/{prefs.h => prefs.hh} | 2 + src/prefsparser.cc | 6 +- src/styleengine.cc | 6 +- src/{svg.c => svg.cc} | 18 ++-- src/table.cc | 4 +- src/tipwin.cc | 2 +- src/ui.cc | 6 +- src/uicmd.cc | 10 +- src/uicmd.hh | 2 +- src/url.cc | 4 +- src/url.hh | 2 + src/version.cc | 8 +- src/web.cc | 8 +- src/web.hh | 2 +- src/{webp.c => webp.cc} | 19 ++-- 92 files changed, 447 insertions(+), 418 deletions(-) rename src/IO/{IO.c => IO.cc} (88%) rename src/IO/{IO.h => IO.hh} (94%) rename src/IO/{dpi.c => dpi.cc} (93%) rename src/IO/{mime.c => mime.cc} (95%) rename src/IO/{mime.h => mime.hh} (100%) rename src/IO/{tls.c => tls.cc} (98%) rename src/IO/{tls.h => tls.hh} (97%) rename src/IO/{tls_openssl.c => tls_openssl.cc} (96%) rename src/IO/{tls_openssl.h => tls_openssl.hh} (100%) rename src/{actions.c => actions.cc} (85%) rename src/{actions.h => actions.hh} (100%) rename src/{bookmark.c => bookmark.cc} (81%) rename src/{bookmark.h => bookmark.hh} (95%) rename src/{bw.c => bw.cc} (96%) rename src/{bw.h => bw.hh} (100%) rename src/{capi.c => capi.cc} (84%) rename src/{capi.h => capi.hh} (100%) rename src/{chain.c => chain.cc} (98%) rename src/{chain.h => chain.hh} (100%) rename src/{colors.c => colors.cc} (99%) rename src/{colors.h => colors.hh} (100%) rename src/{cookies.c => cookies.cc} (96%) rename src/{cookies.h => cookies.hh} (100%) rename src/{decode.c => decode.cc} (99%) rename src/{decode.h => decode.hh} (100%) rename src/{dgif.h => dgif.hh} (100%) rename src/{dicache.c => dicache.cc} (92%) rename src/{dicache.h => dicache.hh} (100%) rename src/{digest.c => digest.cc} (99%) rename src/{digest.h => digest.hh} (100%) rename src/{djpeg.h => djpeg.hh} (100%) rename src/{dns.c => dns.cc} (97%) rename src/{dns.h => dns.hh} (100%) rename src/{domain.c => domain.cc} (98%) rename src/{domain.h => domain.hh} (100%) rename src/{dpiapi.c => dpiapi.cc} (95%) rename src/{dpiapi.h => dpiapi.hh} (100%) rename src/{dpng.h => dpng.hh} (90%) rename src/{dsvg.h => dsvg.hh} (94%) rename src/{dwebp.h => dwebp.hh} (100%) rename src/{gif.c => gif.cc} (96%) rename src/{history.c => history.cc} (96%) rename src/{history.h => history.hh} (100%) rename src/{hsts.c => hsts.cc} (94%) rename src/{hsts.h => hsts.hh} (100%) rename src/{jpeg.c => jpeg.cc} (93%) rename src/{msg.h => msg.hh} (92%) rename src/{nav.c => nav.cc} (95%) rename src/{nav.h => nav.hh} (98%) rename src/{png.c => png.cc} (94%) rename src/{prefs.c => prefs.cc} (99%) rename src/{prefs.h => prefs.hh} (98%) rename src/{svg.c => svg.cc} (89%) rename src/{webp.c => webp.cc} (92%) diff --git a/src/IO/IO.c b/src/IO/IO.cc similarity index 88% rename from src/IO/IO.c rename to src/IO/IO.cc index 3547021..d79d9f8 100644 --- a/src/IO/IO.c +++ b/src/IO/IO.cc @@ -16,12 +16,12 @@ #include #include #include -#include "../msg.h" -#include "../chain.h" +#include "../msg.hh" +#include "../chain.hh" #include "../klist.h" -#include "IO.h" +#include "IO.hh" #include "iowatch.hh" -#include "tls.h" +#include "tls.hh" /* * Symbolic defines for shutdown() function @@ -52,7 +52,7 @@ static Klist_t *ValidIOs = NULL; /* Active IOs list. It holds pointers to /* * Forward declarations */ -void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, +extern "C" void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, void *Data1, void *Data2); @@ -197,7 +197,7 @@ static bool_t IO_read(IOData_t *io) if (io->Buf->len > 0) { /* send what we've got so far */ - a_IO_ccc(OpSend, 2, FWD, io->Info, io, NULL); + a_IO_ccc(OpSend, 2, FWD, reinterpret_cast< ChainLink * >( io->Info ), io, NULL); } if (St == 0) { /* TODO: design a general way to avoid reentrancy problems with CCC. */ @@ -207,7 +207,7 @@ static bool_t IO_read(IOData_t *io) if ((io = IO_get(io_key))) { /* All data read (EOF) */ _MSG("IO_read: io->Key=%d io_key=%d\n", io->Key, io_key); - a_IO_ccc(OpEnd, 2, FWD, io->Info, io, NULL); + a_IO_ccc(OpEnd, 2, FWD, reinterpret_cast< ChainLink * >( io->Info ), io, NULL); } } return ret; @@ -295,7 +295,7 @@ static void IO_fd_read_cb(int fd, void *data) a_IOwatch_remove_fd(fd, DIO_READ); if ((io = IO_get(io_key)) && io->Status) { /* check io because IO_read OpSend could trigger abort */ - a_IO_ccc(OpAbort, 2, FWD, io->Info, io, NULL); + a_IO_ccc(OpAbort, 2, FWD, reinterpret_cast< ChainLink * >( io->Info ), io, NULL); } } } @@ -317,7 +317,7 @@ static void IO_fd_write_cb(int fd, void *data) if (IO_callback(io) == 0) a_IOwatch_remove_fd(fd, DIO_WRITE); if (io->Status) - a_IO_ccc(OpAbort, 1, FWD, io->Info, NULL, NULL); + a_IO_ccc(OpAbort, 1, FWD, reinterpret_cast< ChainLink * >( io->Info ), NULL, NULL); } } @@ -362,7 +362,7 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, IOData_t *io; DataBuf *dbuf; - dReturn_if_fail( a_Chain_check("a_IO_ccc", Op, Branch, Dir, Info) ); + dReturn_if_fail( a_Chain_check(const_cast< char * >( "a_IO_ccc" ), Op, Branch, Dir, Info) ); if (Branch == 1) { if (Dir == BCK) { @@ -374,20 +374,20 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, Info->LocalKey = io; break; case OpSend: - io = Info->LocalKey; - if (Data2 && !strcmp(Data2, "FD")) { + io = reinterpret_cast< IOData_t * >( Info->LocalKey ); + if (Data2 && !strcmp(reinterpret_cast< const char * >( Data2 ), "FD")) { io->FD = *(int*)Data1; /* SockFD */ } else { - dbuf = Data1; + dbuf = reinterpret_cast< DataBuf * >( Data1 ); dStr_append_l(io->Buf, dbuf->Buf, dbuf->Size); IO_submit(io); } break; case OpEnd: case OpAbort: - io = Info->LocalKey; + io = reinterpret_cast< IOData_t * >( Info->LocalKey ); if (io->Buf->len > 0) { - char *newline = memchr(io->Buf->str, '\n', io->Buf->len); + char *newline = reinterpret_cast< char * >( memchr(io->Buf->str, '\n', io->Buf->len) ); int msglen = newline ? newline - io->Buf->str : 2048; MSG("IO_write, closing with pending data not sent: \"%s\"\n", @@ -406,7 +406,7 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, /* Write-data status */ switch (Op) { case OpAbort: - io = Info->LocalKey; + io = reinterpret_cast< IOData_t * >( Info->LocalKey ); IO_close_fd(io, IO_StopRdWr); IO_free(io); a_Chain_fcb(OpAbort, Info, NULL, NULL); @@ -428,15 +428,15 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, io->Info = Info; break; case OpSend: - io = Info->LocalKey; - if (Data2 && !strcmp(Data2, "FD")) { - io->FD = *(int*)Data1; /* SockFD */ + io = reinterpret_cast< IOData_t * >( Info->LocalKey ); + if (Data2 && !strcmp(reinterpret_cast< const char * >( Data2 ), "FD")) { + io->FD = *reinterpret_cast< int * >( Data1 ); /* SockFD */ IO_submit(io); } break; case OpEnd: case OpAbort: - io = Info->LocalKey; + io = reinterpret_cast< IOData_t * >( Info->LocalKey ); IO_close_fd(io, Op == OpEnd ? IO_StopRd : IO_StopRdWr); IO_free(io); dFree(Info); @@ -447,7 +447,7 @@ void a_IO_ccc(int Op, int Branch, int Dir, ChainLink *Info, } } else { /* 2 FWD */ /* Send read-data */ - io = Data1; + io = reinterpret_cast< IOData_t * >( Data1 ); switch (Op) { case OpSend: dbuf = a_Chain_dbuf_new(io->Buf->str, io->Buf->len, 0); diff --git a/src/IO/IO.h b/src/IO/IO.hh similarity index 94% rename from src/IO/IO.h rename to src/IO/IO.hh index eb9e817..d67d28e 100644 --- a/src/IO/IO.h +++ b/src/IO/IO.hh @@ -3,7 +3,7 @@ #include "d_size.h" #include "../../dlib/dlib.h" -#include "../chain.h" +#include "../chain.hh" /* * IO Operations diff --git a/src/IO/Makefile.am b/src/IO/Makefile.am index ff0277c..11796d7 100644 --- a/src/IO/Makefile.am +++ b/src/IO/Makefile.am @@ -23,17 +23,17 @@ endif libDiof_a_SOURCES = \ - mime.c \ - mime.h \ + mime.cc \ + mime.hh \ about.c \ Url.h \ http.cc \ - tls.h \ - tls.c \ + tls.hh \ + tls.cc \ $(TLS_OPENSSL) \ $(TLS_MBEDTLS) \ - dpi.c \ - IO.c \ + dpi.cc \ + IO.cc \ iowatch.cc \ iowatch.hh \ - IO.h + IO.hh diff --git a/src/IO/Url.h b/src/IO/Url.h index 61b2655..199f274 100644 --- a/src/IO/Url.h +++ b/src/IO/Url.h @@ -1,7 +1,7 @@ #ifndef __IO_URL_H__ #define __IO_URL_H__ -#include "../chain.h" +#include "../chain.hh" #include "../url.hh" #include "../../dlib/dlib.h" diff --git a/src/IO/dpi.c b/src/IO/dpi.cc similarity index 93% rename from src/IO/dpi.c rename to src/IO/dpi.cc index 5714bd6..16049e8 100644 --- a/src/IO/dpi.c +++ b/src/IO/dpi.cc @@ -35,9 +35,9 @@ #include #include -#include "../msg.h" +#include "../msg.hh" #include "../klist.h" -#include "IO.h" +#include "IO.hh" #include "Url.h" #include "../../dpip/dpip.h" #include "dlib/dlib.h" @@ -205,7 +205,7 @@ static void Dpi_parse_token(dpi_conn_t *conn) if (conn->Send2EOF) { /* we're receiving data chunks from a HTML page */ dbuf = a_Chain_dbuf_new(Tok, conn->TokSize, 0); - a_Chain_fcb(OpSend, conn->InfoRecv, dbuf, "send_page_2eof"); + a_Chain_fcb(OpSend, conn->InfoRecv, dbuf, const_cast< char * >( "send_page_2eof" )); dFree(dbuf); return; } @@ -314,7 +314,7 @@ static char *Dpi_blocking_read(int fd) */ static void Dpi_process_dbuf(int Op, void *Data1, dpi_conn_t *conn) { - DataBuf *dbuf = Data1; + DataBuf *dbuf = reinterpret_cast< DataBuf * >( Data1 ); int key = conn->Key; /* Very useful for debugging: show the data stream as received. */ @@ -504,12 +504,12 @@ static int Dpi_check_dpid(int num_tries) */ static int Dpi_blocking_start_dpid(void) { - int cst, try = 0, + int cst, try_ = 0, n_tries = 12; /* 3 seconds */ /* test the dpid, and wait a bit for it to start if necessary */ while ((cst = Dpi_check_dpid(n_tries)) == 1) { - MSG("Dpi_blocking_start_dpid: try %d\n", ++try); + MSG("Dpi_blocking_start_dpid: try %d\n", ++try_); dUsleep(250000UL); } return cst; @@ -622,7 +622,7 @@ static int Dpi_connect_socket(const char *server_name) if ((sock_fd = Dpi_make_socket_fd()) == -1) { MSG_ERR("[Dpi_connect_socket] %s\n", dStrerror(errno)); - } else if (connect(sock_fd, (void*)&sin, sizeof(sin)) == -1) { + } else if (connect(sock_fd, reinterpret_cast< struct sockaddr * >( &sin ), sizeof(sin)) == -1) { MSG_ERR("[Dpi_connect_socket] errno:%d %s\n", errno, dStrerror(errno)); /* send authentication Key (the server closes sock_fd on auth error) */ @@ -649,7 +649,7 @@ void a_Dpi_ccc(int Op, int Branch, int Dir, ChainLink *Info, dpi_conn_t *conn; int SockFD = -1, st; - dReturn_if_fail( a_Chain_check("a_Dpi_ccc", Op, Branch, Dir, Info) ); + dReturn_if_fail( a_Chain_check(const_cast< char * >( "a_Dpi_ccc" ), Op, Branch, Dir, Info) ); if (Branch == 1) { if (Dir == BCK) { @@ -657,22 +657,22 @@ void a_Dpi_ccc(int Op, int Branch, int Dir, ChainLink *Info, switch (Op) { case OpStart: if ((st = Dpi_blocking_start_dpid()) == 0) { - if ((SockFD = Dpi_connect_socket(Data1)) != -1) { + if ((SockFD = Dpi_connect_socket(reinterpret_cast< const char * >( Data1 ))) != -1) { int *fd = dNew(int, 1); *fd = SockFD; Info->LocalKey = fd; a_Chain_link_new(Info, a_Dpi_ccc, BCK, a_IO_ccc, 1, 1); a_Chain_bcb(OpStart, Info, NULL, NULL); /* Let the FD known and tracked */ - a_Chain_bcb(OpSend, Info, &SockFD, "FD"); - a_Chain_fcb(OpSend, Info, &SockFD, "FD"); - a_Chain_fcb(OpSend, Info, NULL, "DpidOK"); + a_Chain_bcb(OpSend, Info, &SockFD, const_cast< char * >( "FD" )); + a_Chain_fcb(OpSend, Info, &SockFD, const_cast< char * >( "FD" )); + a_Chain_fcb(OpSend, Info, NULL, const_cast< char * >( "DpidOK" )); } else { a_Dpi_ccc(OpAbort, 1, FWD, Info, NULL, NULL); } } else { MSG_ERR("dpi.c: can't start dpi daemon\n"); - a_Dpi_ccc(OpAbort, 1, FWD, Info, NULL, "DpidERROR"); + a_Dpi_ccc(OpAbort, 1, FWD, Info, NULL, const_cast< char * >( "DpidERROR" )); } break; case OpSend: @@ -711,11 +711,11 @@ void a_Dpi_ccc(int Op, int Branch, int Dir, ChainLink *Info, switch (Op) { case OpSend: /* Data1 = dbuf */ - Dpi_process_dbuf(IORead, Data1, Info->LocalKey); + Dpi_process_dbuf(IORead, Data1, reinterpret_cast< dpi_conn_t * >( Info->LocalKey )); break; case OpEnd: a_Chain_fcb(OpEnd, Info, NULL, NULL); - Dpi_conn_free(Info->LocalKey); + Dpi_conn_free(reinterpret_cast< dpi_conn_t * >( Info->LocalKey )); dFree(Info); break; default: @@ -729,7 +729,7 @@ void a_Dpi_ccc(int Op, int Branch, int Dir, ChainLink *Info, Info->LocalKey = conn; /* Hack: for receiving HTTP through the DPI framework */ - if (strcmp(Data2, "http") == 0) { + if (strcmp(reinterpret_cast< const char * >( Data2 ), "http") == 0) { conn->Send2EOF = 1; } @@ -737,13 +737,13 @@ void a_Dpi_ccc(int Op, int Branch, int Dir, ChainLink *Info, a_Chain_bcb(OpStart, Info, NULL, NULL); /* IORead */ break; case OpSend: - if (Data2 && !strcmp(Data2, "FD")) { + if (Data2 && !strcmp(reinterpret_cast< const char * >( Data2 ), "FD")) { a_Chain_bcb(OpSend, Info, Data1, Data2); } break; case OpAbort: a_Chain_bcb(OpAbort, Info, NULL, NULL); - Dpi_conn_free(Info->LocalKey); + Dpi_conn_free(reinterpret_cast< dpi_conn_t * >( Info->LocalKey )); dFree(Info); break; default: diff --git a/src/IO/http.cc b/src/IO/http.cc index 930707f..651c2e1 100644 --- a/src/IO/http.cc +++ b/src/IO/http.cc @@ -27,17 +27,17 @@ #include /* for ntohl and stuff */ #include /* for inet_ntop */ -#include "IO.h" +#include "IO.hh" #include "iowatch.hh" -#include "tls.h" +#include "tls.hh" #include "Url.h" -#include "../msg.h" +#include "../msg.hh" #include "../klist.h" -#include "../dns.h" +#include "../dns.hh" #include "../web.hh" -#include "../cookies.h" +#include "../cookies.hh" #include "../auth.hh" -#include "../prefs.h" +#include "../prefs.hh" #include "../misc.hh" #include "../uicmd.hh" diff --git a/src/IO/mime.c b/src/IO/mime.cc similarity index 95% rename from src/IO/mime.c rename to src/IO/mime.cc index cf508f7..7baf036 100644 --- a/src/IO/mime.c +++ b/src/IO/mime.cc @@ -10,7 +10,7 @@ * (at your option) any later version. */ -#include "mime.h" +#include "mime.hh" #include "../list.h" @@ -37,7 +37,7 @@ static MimeItem_t *MimeMajItems = NULL; */ static int Mime_add_minor_type(const char *Key, Viewer_t Method) { - a_List_add(MimeMinItems, MimeMinItemsSize, MimeMinItemsMax); + a_List_add(MimeMinItems, MimeMinItemsSize, MimeMinItemsMax, MimeItem_t); MimeMinItems[MimeMinItemsSize].Name = Key; MimeMinItems[MimeMinItemsSize].Data = Method; MimeMinItemsSize++; @@ -51,7 +51,7 @@ static int Mime_add_minor_type(const char *Key, Viewer_t Method) */ static int Mime_add_major_type(const char *Key, Viewer_t Method) { - a_List_add(MimeMajItems, MimeMajItemsSize, MimeMajItemsMax); + a_List_add(MimeMajItems, MimeMajItemsSize, MimeMajItemsMax, MimeItem_t); MimeMajItems[MimeMajItemsSize].Name = Key; MimeMajItems[MimeMajItemsSize].Data = Method; MimeMajItemsSize++; diff --git a/src/IO/mime.h b/src/IO/mime.hh similarity index 100% rename from src/IO/mime.h rename to src/IO/mime.hh diff --git a/src/IO/tls.c b/src/IO/tls.cc similarity index 98% rename from src/IO/tls.c rename to src/IO/tls.cc index 3f0e8da..4421b06 100644 --- a/src/IO/tls.c +++ b/src/IO/tls.cc @@ -19,10 +19,10 @@ */ #include "config.h" -#include "../msg.h" +#include "../msg.hh" -#include "tls.h" -#include "tls_openssl.h" +#include "tls.hh" +#include "tls_openssl.hh" #include "tls_mbedtls.h" /** diff --git a/src/IO/tls.h b/src/IO/tls.hh similarity index 97% rename from src/IO/tls.h rename to src/IO/tls.hh index a3dda0c..78af00d 100644 --- a/src/IO/tls.h +++ b/src/IO/tls.hh @@ -18,6 +18,7 @@ * all respects for all of the code used other than OpenSSL or LibreSSL. */ +static_assert( __cplusplus > 2023'00 ); #ifndef __TLS_H__ #define __TLS_H__ diff --git a/src/IO/tls_openssl.c b/src/IO/tls_openssl.cc similarity index 96% rename from src/IO/tls_openssl.c rename to src/IO/tls_openssl.cc index f3d97bd..d9682e3 100644 --- a/src/IO/tls_openssl.c +++ b/src/IO/tls_openssl.cc @@ -32,7 +32,10 @@ */ #include "config.h" -#include "../msg.h" + +#include "tls_openssl.hh" + +#include "../msg.hh" #include @@ -46,7 +49,7 @@ #include "../dialog.hh" #include "../klist.h" #include "iowatch.hh" -#include "tls.h" +#include "tls.hh" #include "Url.h" #include @@ -102,7 +105,7 @@ static void Tls_connect_cb(int fd, void *vconnkey); static int Tls_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); } @@ -147,10 +150,10 @@ void *a_Tls_openssl_connection(int fd) Conn_t *conn; if (fd_map) { - FdMapEntry_t *fme = dList_find_custom(fd_map, INT2VOIDP(fd), - Tls_fd_map_cmp); + FdMapEntry_t *fme = reinterpret_cast< FdMapEntry_t * >( dList_find_custom(fd_map, INT2VOIDP(fd), + Tls_fd_map_cmp) ); - if (fme && (conn = a_Klist_get_data(conn_list, fme->connkey))) + if (fme && (conn = reinterpret_cast< Conn_t * >( a_Klist_get_data(conn_list, fme->connkey) ))) return conn; } return NULL; @@ -403,7 +406,7 @@ int a_Tls_openssl_connect_ready(const DilloUrl *url) if (ssl_context == NULL) return TLS_CONNECT_NEVER; - if ((s = dList_find_sorted(servers, url, Tls_servers_by_url_cmp))) { + if ((s = reinterpret_cast< Server_t * >( dList_find_sorted(servers, url, Tls_servers_by_url_cmp) ))) { if (s->cert_status == CERT_STATUS_RECEIVING) ret = TLS_CONNECT_NOT_YET; else if (s->cert_status == CERT_STATUS_BAD) @@ -424,7 +427,7 @@ int a_Tls_openssl_connect_ready(const DilloUrl *url) static int Tls_cert_status(const DilloUrl *url) { - Server_t *s = dList_find_sorted(servers, url, Tls_servers_by_url_cmp); + Server_t *s = reinterpret_cast< Server_t * >( dList_find_sorted(servers, url, Tls_servers_by_url_cmp) ); return s ? s->cert_status : CERT_STATUS_NONE; } @@ -625,7 +628,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host, - Ensure that ASN1 strings from the certificate are encoded as UTF-8 which can be meaningfully compared to HOST. */ - subjectAltNames = X509_get_ext_d2i (cert, NID_subject_alt_name, NULL, NULL); + subjectAltNames = reinterpret_cast< GENERAL_NAMES * >( X509_get_ext_d2i (cert, NID_subject_alt_name, NULL, NULL) ); if (subjectAltNames) { @@ -864,6 +867,8 @@ static int Tls_examine_certificate(SSL *ssl, Server_t *srv) Tls_check_cert_hostname(remote_cert, srv->hostname, &choice)) { /* Figure out if (and why) the remote system can't be trusted */ st = SSL_get_verify_result(ssl); + X509_NAME *subject_name = NULL; + char *subj = NULL; switch (st) { case X509_V_OK: ret = 0; @@ -872,8 +877,8 @@ static int Tls_examine_certificate(SSL *ssl, Server_t *srv) ; /* Case follows declaration */ /* Either self signed and untrusted */ /* Extract CN from certificate name information */ - X509_NAME *subject_name = X509_get_subject_name(remote_cert); - char *subj = X509_NAME_oneline(subject_name, NULL, 0); + subject_name = X509_get_subject_name(remote_cert); + subj = X509_NAME_oneline(subject_name, NULL, 0); if ((cn = strstr(subj, "/CN=")) == NULL) { strcpy(buf, "(no CN given)"); } else { @@ -1057,7 +1062,7 @@ static int Tls_examine_certificate(SSL *ssl, Server_t *srv) void a_Tls_openssl_reset_server_state(const DilloUrl *url) { if (servers) { - Server_t *s = dList_find_sorted(servers, url, Tls_servers_by_url_cmp); + Server_t *s = reinterpret_cast< Server_t * >( dList_find_sorted(servers, url, Tls_servers_by_url_cmp) ); if (s && s->cert_status == CERT_STATUS_RECEIVING) s->cert_status = CERT_STATUS_NONE; @@ -1071,7 +1076,7 @@ static void Tls_close_by_key(int connkey) { Conn_t *c; - if ((c = a_Klist_get_data(conn_list, connkey))) { + if ((c = reinterpret_cast< Conn_t * >( a_Klist_get_data(conn_list, connkey) ))) { a_Tls_openssl_reset_server_state(c->url); if (c->connecting) { a_IOwatch_remove_fd(c->fd, -1); @@ -1104,7 +1109,7 @@ static void Tls_connect(int fd, int connkey) bool_t ongoing = FALSE, failed = TRUE; Conn_t *conn; - if (!(conn = a_Klist_get_data(conn_list, connkey))) { + if (!(conn = reinterpret_cast< Conn_t * >( a_Klist_get_data(conn_list, connkey) ))) { MSG("Tls_connect: conn for fd %d not valid\n", fd); return; } @@ -1179,8 +1184,8 @@ static void Tls_connect(int fd, int connkey) MSG("SSL_get_error() returned %d on a connect.\n", err1_ret); } } else { - Server_t *srv = dList_find_sorted(servers, conn->url, - Tls_servers_by_url_cmp); + Server_t *srv = reinterpret_cast< Server_t * >( dList_find_sorted(servers, conn->url, + Tls_servers_by_url_cmp) ); if (srv->cert_status == CERT_STATUS_RECEIVING) { /* Making first connection with the server. Show cipher used. */ @@ -1355,8 +1360,8 @@ int a_Tls_openssl_write(void *conn, void *buf, size_t len) void a_Tls_openssl_close_by_fd(int fd) { - FdMapEntry_t *fme = dList_find_custom(fd_map, INT2VOIDP(fd), - Tls_fd_map_cmp); + FdMapEntry_t *fme = reinterpret_cast< FdMapEntry_t * >( dList_find_custom(fd_map, INT2VOIDP(fd), + Tls_fd_map_cmp) ); if (fme) { Tls_close_by_key(fme->connkey); diff --git a/src/IO/tls_openssl.h b/src/IO/tls_openssl.hh similarity index 100% rename from src/IO/tls_openssl.h rename to src/IO/tls_openssl.hh diff --git a/src/Makefile.am b/src/Makefile.am index 72bad4c..4b02ac7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,34 +35,34 @@ dillo_SOURCES = \ ui.hh \ uicmd.cc \ uicmd.hh \ - bw.h \ - bw.c \ - cookies.c \ - cookies.h \ - actions.c \ - actions.h \ - hsts.c \ - hsts.h \ + bw.hh \ + bw.cc \ + cookies.cc \ + cookies.hh \ + actions.cc \ + actions.hh \ + hsts.cc \ + hsts.hh \ auth.cc \ auth.hh \ md5.c \ md5.h \ - digest.c \ - digest.h \ - colors.c \ - colors.h \ + digest.cc \ + digest.hh \ + colors.cc \ + colors.hh \ binaryconst.h \ misc.cc \ misc.hh \ - history.h \ - history.c \ - prefs.c \ - prefs.h \ + history.hh \ + history.cc \ + prefs.cc \ + prefs.hh \ prefsparser.cc \ prefsparser.hh \ keys.cc \ keys.hh \ - msg.h \ + msg.hh \ list.h \ url.cc \ url.hh \ @@ -70,8 +70,8 @@ dillo_SOURCES = \ bitvec.h \ klist.c \ klist.h \ - chain.c \ - chain.h \ + chain.cc \ + chain.hh \ utf8.cc \ utf8.hh \ timeout.cc \ @@ -82,18 +82,18 @@ dillo_SOURCES = \ \ web.cc \ web.hh \ - nav.c \ - nav.h \ + nav.cc \ + nav.hh \ cache.cc \ cache.hh \ - decode.c \ - decode.h \ - dicache.c \ - dicache.h \ - capi.c \ - capi.h \ - domain.c \ - domain.h \ + decode.cc \ + decode.hh \ + dicache.cc \ + dicache.hh \ + capi.cc \ + capi.hh \ + domain.cc \ + domain.hh \ css.cc \ css.hh \ cssparser.cc \ @@ -110,30 +110,30 @@ dillo_SOURCES = \ form.hh \ table.cc \ table.hh \ - bookmark.c \ - bookmark.h \ - dns.c \ - dns.h \ - gif.c \ - dgif.h \ - jpeg.c \ - djpeg.h \ - png.c \ - dpng.h \ - webp.c \ - dwebp.h \ - svg.c \ + bookmark.cc \ + bookmark.hh \ + dns.cc \ + dns.hh \ + gif.cc \ + dgif.hh \ + jpeg.cc \ + djpeg.hh \ + png.cc \ + dpng.hh \ + webp.cc \ + dwebp.hh \ + svg.cc \ nanosvg.h \ nanosvgrast.h \ - dsvg.h \ + dsvg.hh \ imgbuf.cc \ imgbuf.hh \ image.cc \ image.hh \ menu.hh \ menu.cc \ - dpiapi.c \ - dpiapi.h \ + dpiapi.cc \ + dpiapi.hh \ pixmaps.h \ findbar.cc \ findbar.hh \ diff --git a/src/actions.c b/src/actions.cc similarity index 85% rename from src/actions.c rename to src/actions.cc index 57d021f..6daa5a7 100644 --- a/src/actions.c +++ b/src/actions.cc @@ -9,8 +9,8 @@ * (at your option) any later version. */ -#include "actions.h" -#include "msg.h" +#include "actions.hh" +#include "msg.hh" #include "../dlib/dlib.h" #include @@ -37,7 +37,7 @@ action_parse(char *line) //MSG("Got action label='%s' cmd='%s'\n", label, cmd); - Action *action = dMalloc(sizeof(Action)); + Action *action = reinterpret_cast< Action * >( dMalloc(sizeof(Action)) ); action->label = dStrdup(label); action->cmd = dStrdup(cmd); @@ -52,7 +52,7 @@ a_Actions_init(void) link_actions = dList_new(n); for (int i = 0; i < n; i++) { - char *line = dList_nth_data(prefs.link_actions, i); + char *line = reinterpret_cast< char * >( dList_nth_data(prefs.link_actions, i) ); if (line) action_parse(line); } diff --git a/src/actions.h b/src/actions.hh similarity index 100% rename from src/actions.h rename to src/actions.hh diff --git a/src/auth.cc b/src/auth.cc index 3305d9e..de3484a 100644 --- a/src/auth.cc +++ b/src/auth.cc @@ -19,10 +19,10 @@ #include /* iscntrl, isascii */ #include "auth.hh" -#include "msg.h" +#include "msg.hh" #include "misc.hh" #include "dialog.hh" -#include "digest.h" +#include "digest.hh" #include "../dlib/dlib.h" typedef struct { diff --git a/src/bookmark.c b/src/bookmark.cc similarity index 81% rename from src/bookmark.c rename to src/bookmark.cc index cf6f39d..381bc00 100644 --- a/src/bookmark.c +++ b/src/bookmark.cc @@ -11,10 +11,10 @@ #include -#include "msg.h" -#include "history.h" -#include "capi.h" -#include "bookmark.h" /* for prototypes */ +#include "msg.hh" +#include "history.hh" +#include "capi.hh" +#include "bookmark.hh" /* for prototypes */ #include "../dpip/dpip.h" @@ -44,20 +44,20 @@ void a_Bookmarks_chat_add(BrowserWindow *Bw, char *Cmd, char *answer) cmd4 = dStrdup(Cmd); if (!answer) { - a_Capi_dpi_send_cmd(NULL, bw, cmd1, "bookmarks", 1); + a_Capi_dpi_send_cmd(NULL, bw, cmd1, const_cast< char * >( "bookmarks" ), 1); } else { /* we have an answer */ if (answer) { if (*answer == 'H') { /* "Hi browser" */ - a_Capi_dpi_send_cmd(NULL, bw, cmd2, "bookmarks", 0); + a_Capi_dpi_send_cmd(NULL, bw, cmd2, const_cast< char * >( "bookmarks" ), 0); } else if (*answer == 'I') { /* "Is it worth?" */ - a_Capi_dpi_send_cmd(NULL, bw, cmd3, "bookmarks", 0); + a_Capi_dpi_send_cmd(NULL, bw, cmd3, const_cast< char * >( "bookmarks" ), 0); } else if (*answer == 'O') { /* "OK, send it!" */ - a_Capi_dpi_send_cmd(NULL, bw, cmd4, "bookmarks", 0); + a_Capi_dpi_send_cmd(NULL, bw, cmd4, const_cast< char * >( "bookmarks" ), 0); dFree(cmd4); cmd4 = NULL; } diff --git a/src/bookmark.h b/src/bookmark.hh similarity index 95% rename from src/bookmark.h rename to src/bookmark.hh index a2d54e3..d8388ec 100644 --- a/src/bookmark.h +++ b/src/bookmark.hh @@ -1,7 +1,7 @@ #ifndef __BOOKMARK_H__ #define __BOOKMARK_H__ -#include "bw.h" +#include "bw.hh" #ifdef __cplusplus extern "C" { diff --git a/src/bw.c b/src/bw.cc similarity index 96% rename from src/bw.c rename to src/bw.cc index bb9dd4a..74c9a29 100644 --- a/src/bw.c +++ b/src/bw.cc @@ -15,10 +15,10 @@ */ -#include "bw.h" -#include "msg.h" +#include "bw.hh" +#include "msg.hh" #include "list.h" -#include "capi.h" +#include "capi.hh" #include "uicmd.hh" @@ -50,7 +50,7 @@ BrowserWindow *a_Bw_new(void) /* We use dNew0() to zero the memory */ bw = dNew0(BrowserWindow, 1); - a_List_add(bws, num_bws, num_bws_max); + a_List_add(bws, num_bws, num_bws_max, BrowserWindow *); bws[num_bws++] = bw; /* Initialize nav_stack */ @@ -100,7 +100,7 @@ void a_Bw_free(BrowserWindow *bw) a_Url_free(bw->nav_expect_url); for (j = 0; j < dList_length(bw->PageUrls); ++j) - a_Url_free(dList_nth_data(bw->PageUrls, j)); + a_Url_free(reinterpret_cast< DilloUrl * >( dList_nth_data(bw->PageUrls, j) )); dList_free(bw->PageUrls); for (j = 0; j < dList_length(bw->nav_stack); ++j) @@ -288,7 +288,7 @@ void a_Bw_cleanup(BrowserWindow *bw) } /* Remove PageUrls */ while ((data = dList_nth_data(bw->PageUrls, 0))) { - a_Url_free(data); + a_Url_free(reinterpret_cast< DilloUrl * >( data )); dList_remove_fast(bw->PageUrls, data); } diff --git a/src/bw.h b/src/bw.hh similarity index 100% rename from src/bw.h rename to src/bw.hh diff --git a/src/cache.cc b/src/cache.cc index bf60bd7..53cde43 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -21,19 +21,19 @@ #include #include -#include "msg.h" +#include "msg.hh" #include "IO/Url.h" -#include "IO/IO.h" +#include "IO/IO.hh" #include "web.hh" -#include "dicache.h" -#include "nav.h" -#include "cookies.h" -#include "hsts.h" +#include "dicache.hh" +#include "nav.hh" +#include "cookies.hh" +#include "hsts.hh" #include "misc.hh" -#include "capi.h" -#include "decode.h" +#include "capi.hh" +#include "decode.hh" #include "auth.hh" -#include "domain.h" +#include "domain.hh" #include "timeout.hh" #include "uicmd.hh" diff --git a/src/cache.hh b/src/cache.hh index 7148ae0..9578ac4 100644 --- a/src/cache.hh +++ b/src/cache.hh @@ -6,7 +6,7 @@ extern "C" { #endif /* __cplusplus */ -#include "chain.h" +#include "chain.hh" #include "url.hh" /* diff --git a/src/capi.c b/src/capi.cc similarity index 84% rename from src/capi.c rename to src/capi.cc index 232cfec..2d34aa3 100644 --- a/src/capi.c +++ b/src/capi.cc @@ -21,21 +21,21 @@ #include #include "config.h" -#include "msg.h" -#include "capi.h" -#include "IO/IO.h" /* for IORead &friends */ +#include "msg.hh" +#include "capi.hh" +#include "IO/IO.hh" /* for IORead &friends */ #include "IO/Url.h" -#include "chain.h" -#include "history.h" -#include "nav.h" -#include "dpiapi.h" +#include "chain.hh" +#include "history.hh" +#include "nav.hh" +#include "dpiapi.hh" #include "uicmd.hh" -#include "domain.h" +#include "domain.hh" #include "../dpip/dpip.h" -#include "prefs.h" +#include "prefs.hh" /* for testing dpi chat */ -#include "bookmark.h" +#include "bookmark.hh" typedef struct { DilloUrl *url; /**< local copy of web->url */ @@ -115,7 +115,7 @@ static capi_conn_t * */ static capi_conn_t *Capi_conn_valid(capi_conn_t *conn) { - return dList_find(CapiConns, conn); + return reinterpret_cast< capi_conn_t * >( dList_find(CapiConns, conn) ); } /** @@ -155,8 +155,8 @@ static void Capi_conn_unref(capi_conn_t *conn) */ static int Capi_conn_by_server_cmp(const void *v1, const void *v2) { - const capi_conn_t *node = v1; - const char *server = v2; + const capi_conn_t *node = reinterpret_cast< const capi_conn_t * >( v1 ); + const char *server = reinterpret_cast< const char * >( v2 ); dReturn_val_if_fail(node && node->server && server, 1); return strcmp(node->server, server); } @@ -166,7 +166,7 @@ static int Capi_conn_by_server_cmp(const void *v1, const void *v2) */ static capi_conn_t *Capi_conn_find(char *server) { - return dList_find_custom(CapiConns, (void*)server, Capi_conn_by_server_cmp); + return reinterpret_cast< capi_conn_t * >( dList_find_custom(CapiConns, (void*)server, Capi_conn_by_server_cmp) ); } /** @@ -179,7 +179,7 @@ static void Capi_conn_resume(void) capi_conn_t *conn; for (i = 0; i < dList_length(CapiConns); ++i) { - conn = dList_nth_data (CapiConns, i); + conn = reinterpret_cast< capi_conn_t * >( dList_nth_data (CapiConns, i) ); if (conn->Flags & PENDING) { dbuf = a_Chain_dbuf_new(conn->datastr,(int)strlen(conn->datastr), 0); if (conn->InfoSend) { @@ -203,7 +203,7 @@ void a_Capi_conn_abort_by_url(const DilloUrl *url) capi_conn_t *conn; for (i = 0; i < dList_length(CapiConns); ++i) { - conn = dList_nth_data (CapiConns, i); + conn = reinterpret_cast< capi_conn_t * >( dList_nth_data (CapiConns, i) ); if (a_Url_cmp(conn->url, url) == 0) { if (conn->InfoSend) { a_Capi_ccc(OpAbort, 1, BCK, conn->InfoSend, NULL, NULL); @@ -269,7 +269,7 @@ int a_Capi_dpi_verify_request(BrowserWindow *bw, DilloUrl *url) */ static int Capi_url_uses_dpi(DilloUrl *url, char **server_ptr) { - char *p, *server = NULL, *url_str = URL_STR(url); + char *p, *server = NULL, *url_str = const_cast< char * >( URL_STR(url) ); Dstr *tmp; if ((dStrnAsciiCasecmp(url_str, "http:", 5) == 0) || @@ -322,10 +322,10 @@ static char *Capi_dpi_build_cmd(DilloWeb *web, char *server) */ static void Capi_dpi_send_source(BrowserWindow *bw, DilloUrl *url) { - char *p, *buf, *cmd, size_str[32], *server="vsource"; + char *p, *buf, *cmd, size_str[32], *server= const_cast< char * >( "vsource" ); int buf_size; - if (!(p = strchr(URL_STR(url), ':')) || !(p = strchr(p + 1, ':'))) + if (!(p = const_cast< char * >( strchr(URL_STR(url), ':') )) || !(p = const_cast< char * >( strchr(p + 1, ':') ))) return; if (a_Capi_get_buf(CapiVsUrl, &buf, &buf_size)) { @@ -417,7 +417,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData) } } } else if (a_Cache_download_enabled(web->url)) { - server = "downloads"; + server = const_cast< char * >( "downloads" ); cmd = Capi_dpi_build_cmd(web, server); a_Capi_dpi_send_cmd(web->url, web->bw, cmd, server, 1); dFree(cmd); @@ -470,10 +470,10 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData) if (reload) { a_Capi_conn_abort_by_url(web->url); /* create a new connection and start the CCC operations */ - conn = Capi_conn_new(web->url, web->bw, "http", "none"); + conn = Capi_conn_new(web->url, web->bw, const_cast< char * >( "http" ), const_cast< char * >( "none" )); /* start the reception branch before the query one because the DNS * may callback immediately. This may avoid a race condition. */ - a_Capi_ccc(OpStart, 2, BCK, a_Chain_new(), conn, "http"); + a_Capi_ccc(OpStart, 2, BCK, a_Chain_new(), conn, const_cast< char * >( "http" )); a_Capi_ccc(OpStart, 1, BCK, a_Chain_new(), conn, web); } use_cache = 1; @@ -642,7 +642,7 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, { capi_conn_t *conn; - dReturn_if_fail( a_Chain_check("a_Capi_ccc", Op, Branch, Dir, Info) ); + dReturn_if_fail( a_Chain_check(const_cast< char * >( "a_Capi_ccc" ), Op, Branch, Dir, Info) ); if (Branch == 1) { if (Dir == BCK) { @@ -650,7 +650,7 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, switch (Op) { case OpStart: /* Data1 = conn; Data2 = {Web | server} */ - conn = Data1; + conn = reinterpret_cast< capi_conn_t * >( Data1 ); Capi_conn_ref(conn); Info->LocalKey = conn; conn->InfoSend = Info; @@ -668,14 +668,14 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, a_Chain_bcb(OpSend, Info, Data1, NULL); break; case OpEnd: - conn = Info->LocalKey; + conn = reinterpret_cast< capi_conn_t * >( Info->LocalKey ); conn->InfoSend = NULL; a_Chain_bcb(OpEnd, Info, NULL, NULL); Capi_conn_unref(conn); dFree(Info); break; case OpAbort: - conn = Info->LocalKey; + conn = reinterpret_cast< capi_conn_t * >( Info->LocalKey ); conn->InfoSend = NULL; a_Chain_bcb(OpAbort, Info, NULL, NULL); Capi_conn_unref(conn); @@ -691,33 +691,33 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, case OpSend: if (!Data2) { MSG_WARN("Capi.c: Opsend [1F] Data2 = NULL\n"); - } else if (strcmp(Data2, "FD") == 0) { - conn = Info->LocalKey; + } else if (strcmp(reinterpret_cast< const char * >( Data2 ), "FD") == 0) { + conn = reinterpret_cast< capi_conn_t * >( Info->LocalKey ); conn->SockFD = *(int*)Data1; /* communicate the FD through the answer branch */ - a_Capi_ccc(OpSend, 2, BCK, conn->InfoRecv, &conn->SockFD, "FD"); - } else if (strcmp(Data2, "DpidOK") == 0) { + a_Capi_ccc(OpSend, 2, BCK, conn->InfoRecv, &conn->SockFD, const_cast< char * >( "FD" )); + } else if (strcmp(reinterpret_cast< const char * >( Data2 ), "DpidOK") == 0) { /* resume pending dpi requests */ Capi_conn_resume(); } break; case OpAbort: - conn = Info->LocalKey; + conn = reinterpret_cast< capi_conn_t * >( Info->LocalKey ); conn->InfoSend = NULL; a_Cache_process_dbuf(IOAbort, NULL, 0, conn->url); if (Data2) { - if (!strcmp(Data2, "DpidERROR")) { - a_UIcmd_set_msg(conn->bw, + if (!strcmp(reinterpret_cast< const char * >( Data2 ), "DpidERROR")) { + a_UIcmd_set_msg(reinterpret_cast< BrowserWindow * >( conn->bw ), "ERROR: can't start dpid daemon " "(URL scheme = '%s')!", conn->url ? URL_SCHEME(conn->url) : ""); - } else if (!strcmp(Data2, "Both") && conn->InfoRecv) { + } else if (!strcmp(reinterpret_cast< const char * >( Data2 ), "Both") && conn->InfoRecv) { /* abort the other branch too */ a_Capi_ccc(OpAbort, 2, BCK, conn->InfoRecv, NULL, NULL); } } /* if URL == expect-url */ - a_Nav_cancel_expect_if_eq(conn->bw, conn->url); + a_Nav_cancel_expect_if_eq(reinterpret_cast< BrowserWindow * >( conn->bw ), conn->url); /* finish conn */ Capi_conn_unref(conn); dFree(Info); @@ -734,7 +734,7 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, switch (Op) { case OpStart: /* Data1 = conn; Data2 = {"http" | ""} */ - conn = Data1; + conn = reinterpret_cast< capi_conn_t * >( Data1 ); Capi_conn_ref(conn); Info->LocalKey = conn; conn->InfoRecv = Info; @@ -746,12 +746,12 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, break; case OpSend: /* Data1 = FD */ - if (Data2 && strcmp(Data2, "FD") == 0) { + if (Data2 && strcmp(reinterpret_cast< const char * >( Data2 ), "FD") == 0) { a_Chain_bcb(OpSend, Info, Data1, Data2); } break; case OpAbort: - conn = Info->LocalKey; + conn = reinterpret_cast< capi_conn_t * >( Info->LocalKey ); conn->InfoRecv = NULL; a_Chain_bcb(OpAbort, Info, NULL, NULL); /* remove the cache entry for this URL */ @@ -767,10 +767,10 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, /* Server listening branch */ switch (Op) { case OpSend: - conn = Info->LocalKey; - if (strcmp(Data2, "send_page_2eof") == 0) { + conn = reinterpret_cast< capi_conn_t * >( Info->LocalKey ); + if (strcmp(reinterpret_cast< const char * >( Data2 ), "send_page_2eof") == 0) { /* Data1 = dbuf */ - DataBuf *dbuf = Data1; + DataBuf *dbuf = reinterpret_cast< DataBuf * >( Data1 ); bool_t finished = a_Cache_process_dbuf(IORead, dbuf->Buf, dbuf->Size, conn->url); if (finished && Capi_conn_valid(conn) && conn->InfoRecv) { @@ -778,18 +778,18 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, * that we've received the full response, and cache didn't * trigger an abort and tear everything down, tell upstream. */ - a_Chain_bcb(OpSend, conn->InfoRecv, NULL, "reply_complete"); + a_Chain_bcb(OpSend, conn->InfoRecv, NULL, const_cast< char * >( "reply_complete" )); } - } else if (strcmp(Data2, "send_status_message") == 0) { - a_UIcmd_set_msg(conn->bw, "%s", Data1); - } else if (strcmp(Data2, "chat") == 0) { - a_UIcmd_set_msg(conn->bw, "%s", Data1); - a_Bookmarks_chat_add(NULL, NULL, Data1); - } else if (strcmp(Data2, "dialog") == 0) { - a_Dpiapi_dialog(conn->bw, conn->server, Data1); - } else if (strcmp(Data2, "reload_request") == 0) { - a_Nav_reload(conn->bw); - } else if (strcmp(Data2, "start_send_page") == 0) { + } else if (strcmp(reinterpret_cast< const char * >( Data2 ), "send_status_message") == 0) { + a_UIcmd_set_msg(reinterpret_cast< BrowserWindow * >( conn->bw ), "%s", Data1); + } else if (strcmp(reinterpret_cast< const char * >( Data2 ), "chat") == 0) { + a_UIcmd_set_msg(reinterpret_cast< BrowserWindow * >( conn->bw ), "%s", Data1); + a_Bookmarks_chat_add(NULL, NULL, reinterpret_cast< char * >( Data1 )); + } else if (strcmp(reinterpret_cast< const char * >( Data2 ), "dialog") == 0) { + a_Dpiapi_dialog(reinterpret_cast< BrowserWindow * >( conn->bw ), conn->server, reinterpret_cast< char * >( Data1 )); + } else if (strcmp(reinterpret_cast< const char * >( Data2 ), "reload_request") == 0) { + a_Nav_reload(reinterpret_cast< BrowserWindow * >( conn->bw )); + } else if (strcmp(reinterpret_cast< const char * >( Data2 ), "start_send_page") == 0) { /* prepare the cache to receive the data stream for this URL * * a_Capi_open_url() already added a new cache entry, @@ -798,7 +798,7 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, } break; case OpEnd: - conn = Info->LocalKey; + conn = reinterpret_cast< capi_conn_t * >( Info->LocalKey ); conn->InfoRecv = NULL; a_Cache_process_dbuf(IOClose, NULL, 0, conn->url); @@ -811,17 +811,17 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info, dFree(Info); break; case OpAbort: - conn = Info->LocalKey; + conn = reinterpret_cast< capi_conn_t * >( Info->LocalKey ); conn->InfoRecv = NULL; a_Cache_process_dbuf(IOAbort, NULL, 0, conn->url); if (Data2) { - if (!strcmp(Data2, "Both") && conn->InfoSend) { + if (!strcmp(reinterpret_cast< const char * >( Data2 ), "Both") && conn->InfoSend) { /* abort the other branch too */ a_Capi_ccc(OpAbort, 1, BCK, conn->InfoSend, NULL, NULL); } } /* if URL == expect-url */ - a_Nav_cancel_expect_if_eq(conn->bw, conn->url); + a_Nav_cancel_expect_if_eq(reinterpret_cast< BrowserWindow * >( conn->bw ), conn->url); /* finish conn */ Capi_conn_unref(conn); dFree(Info); diff --git a/src/capi.h b/src/capi.hh similarity index 100% rename from src/capi.h rename to src/capi.hh diff --git a/src/chain.c b/src/chain.cc similarity index 98% rename from src/chain.c rename to src/chain.cc index 6915c49..aba4f16 100644 --- a/src/chain.c +++ b/src/chain.cc @@ -13,8 +13,8 @@ * Theory and code by Jorge Arellano Cid */ -#include "msg.h" -#include "chain.h" +#include "msg.hh" +#include "chain.hh" #include "../dlib/dlib.h" #define VERBOSE 0 @@ -171,7 +171,7 @@ int a_Chain_bfcb(int Op, ChainLink *Info, void *Data1, void *Data2) DataBuf *a_Chain_dbuf_new(void *buf, int size, int code) { DataBuf *dbuf = dNew(DataBuf, 1); - dbuf->Buf = buf; + dbuf->Buf = reinterpret_cast< char * >( buf ); dbuf->Size = size; dbuf->Code = code; return dbuf; diff --git a/src/chain.h b/src/chain.hh similarity index 100% rename from src/chain.h rename to src/chain.hh diff --git a/src/colors.c b/src/colors.cc similarity index 99% rename from src/colors.c rename to src/colors.cc index 88fea94..3cbb78a 100644 --- a/src/colors.c +++ b/src/colors.cc @@ -12,9 +12,9 @@ #include #include #include -#include "colors.h" +#include "colors.hh" -#include "msg.h" +#include "msg.hh" /* * If EXTENDED_COLOR is defined, the extended set of named colors is supported. diff --git a/src/colors.h b/src/colors.hh similarity index 100% rename from src/colors.h rename to src/colors.hh diff --git a/src/cookies.c b/src/cookies.cc similarity index 96% rename from src/cookies.c rename to src/cookies.cc index aab5e4f..6bb0579 100644 --- a/src/cookies.c +++ b/src/cookies.cc @@ -15,7 +15,7 @@ * Handling of cookies takes place here. */ -#include "msg.h" +#include "msg.hh" #ifdef DISABLE_COOKIES @@ -41,8 +41,8 @@ void a_Cookies_init(void) #include "IO/Url.h" #include "list.h" -#include "cookies.h" -#include "capi.h" +#include "cookies.hh" +#include "capi.hh" #include "../dpip/dpip.h" @@ -156,7 +156,7 @@ void a_Cookies_set(Dlist *cookie_strings, const DilloUrl *set_url, return; } - for (i = 0; (cookie_string = dList_nth_data(cookie_strings, i)); ++i) { + for (i = 0; (cookie_string = reinterpret_cast< char * >( dList_nth_data(cookie_strings, i) )); ++i) { path = URL_PATH_(set_url); if (date) cmd = a_Dpip_build_cmd("cmd=%s cookie=%s host=%s path=%s date=%s", @@ -250,7 +250,7 @@ static int Cookie_control_init(void) /* Get a file pointer */ filename = dStrconcat(dGethomedir(), "/.dillo/cookiesrc", NULL); - stream = Cookies_fopen(filename, "DEFAULT DENY\n"); + stream = Cookies_fopen(filename, const_cast< char * >( "DEFAULT DENY\n" )); dFree(filename); if (!stream) @@ -310,7 +310,7 @@ static int Cookie_control_init(void) uint_t len = strlen(cc.domain); /* Insert into list such that longest rules come first. */ - a_List_add(ccontrol, num_ccontrol, num_ccontrol_max); + a_List_add(ccontrol, num_ccontrol, num_ccontrol_max, CookieControl); for (i = num_ccontrol++; i > 0 && (len > strlen(ccontrol[i-1].domain)); i--) { diff --git a/src/cookies.h b/src/cookies.hh similarity index 100% rename from src/cookies.h rename to src/cookies.hh diff --git a/src/css.cc b/src/css.cc index 060ef0c..4f68345 100644 --- a/src/css.cc +++ b/src/css.cc @@ -11,7 +11,7 @@ #include #include "../dlib/dlib.h" -#include "msg.h" +#include "msg.hh" #include "html_common.hh" #include "css.hh" diff --git a/src/cssparser.cc b/src/cssparser.cc index 465d56b..67ca56c 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -20,8 +20,8 @@ #include #include -#include "msg.h" -#include "colors.h" +#include "msg.hh" +#include "colors.hh" #include "html_common.hh" #include "css.hh" #include "cssparser.hh" diff --git a/src/decode.c b/src/decode.cc similarity index 99% rename from src/decode.c rename to src/decode.cc index a116685..7876873 100644 --- a/src/decode.c +++ b/src/decode.cc @@ -14,9 +14,9 @@ #include #include /* strtol */ -#include "decode.h" +#include "decode.hh" #include "utf8.hh" -#include "msg.h" +#include "msg.hh" static const int bufsize = 8*1024; diff --git a/src/decode.h b/src/decode.hh similarity index 100% rename from src/decode.h rename to src/decode.hh diff --git a/src/dgif.h b/src/dgif.hh similarity index 100% rename from src/dgif.h rename to src/dgif.hh diff --git a/src/dialog.cc b/src/dialog.cc index eadbe0a..fc5798f 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -33,10 +33,10 @@ #include #include -#include "msg.h" +#include "msg.hh" #include "dialog.hh" #include "misc.hh" -#include "prefs.h" +#include "prefs.hh" #include "dlib/dlib.h" /* diff --git a/src/dicache.c b/src/dicache.cc similarity index 92% rename from src/dicache.c rename to src/dicache.cc index 79fb6e2..52b271f 100644 --- a/src/dicache.c +++ b/src/dicache.cc @@ -13,16 +13,16 @@ #include /* for memset */ #include -#include "msg.h" +#include "msg.hh" #include "image.hh" #include "imgbuf.hh" #include "web.hh" -#include "dicache.h" -#include "dpng.h" -#include "dwebp.h" -#include "dgif.h" -#include "djpeg.h" -#include "dsvg.h" +#include "dicache.hh" +#include "dpng.hh" +#include "dwebp.hh" +#include "dgif.hh" +#include "djpeg.hh" +#include "dsvg.hh" enum { DIC_Gif = 0, @@ -58,7 +58,7 @@ static uint_t dicache_size_total; /* invariant: dicache_size_total is */ static int Dicache_entry_cmp(const void *v1, const void *v2) { - const DICacheEntry *e1 = v1, *e2 = v2; + const DICacheEntry *e1 = reinterpret_cast< const DICacheEntry * >( v1 ), *e2 = reinterpret_cast< const DICacheEntry * >( v2 ); int st = a_Url_cmp(e1->url, e2->url); if (st == 0) { @@ -127,7 +127,7 @@ static DICacheEntry *Dicache_add_entry(const DilloUrl *Url) entry = Dicache_entry_new(); e.url = (DilloUrl*)Url; e.version = DIC_Last; - last = dList_find_sorted(CachedIMGs, &e, Dicache_entry_cmp); + last = reinterpret_cast< DICacheEntry * >( dList_find_sorted(CachedIMGs, &e, Dicache_entry_cmp) ); if (last) { /* URL is already in CachedIMGs, make a new version */ last->Flags &= ~DIF_Last; @@ -153,9 +153,9 @@ DICacheEntry *a_Dicache_get_entry(const DilloUrl *Url, int version) DICacheEntry *entry = NULL; dReturn_val_if_fail(version != 0, NULL); - e.url = (DilloUrl*)Url; + e.url = const_cast< DilloUrl * >( Url ); e.version = version; - entry = dList_find_sorted(CachedIMGs, &e, Dicache_entry_cmp); + entry = reinterpret_cast< DICacheEntry * >( dList_find_sorted(CachedIMGs, &e, Dicache_entry_cmp) ); if (entry && !(entry->Flags & DIF_Valid) && version == DIC_Last) entry = NULL; return entry; @@ -169,9 +169,9 @@ static void Dicache_remove(const DilloUrl *Url, int version) DICacheEntry e, *entry; _MSG("Dicache_remove url=%s\n", URL_STR(Url)); - e.url = (DilloUrl*)Url; + e.url = const_cast< DilloUrl * >( Url ); e.version = version; - entry = dList_find_sorted(CachedIMGs, &e, Dicache_entry_cmp); + entry = reinterpret_cast< DICacheEntry * >( dList_find_sorted(CachedIMGs, &e, Dicache_entry_cmp) ); dReturn_if (entry == NULL); _MSG("Dicache_remove Imgbuf=%p Decoder=%p DecoderData=%p\n", @@ -186,7 +186,7 @@ static void Dicache_remove(const DilloUrl *Url, int version) a_Bitvec_free(entry->BitVec); a_Imgbuf_unref(entry->v_imgbuf); if (entry->Decoder) { - entry->Decoder(CA_Abort, entry->DecoderData); + entry->Decoder(CA_Abort, reinterpret_cast< CacheClient * >( entry->DecoderData )); } dFree(entry); } @@ -348,7 +348,7 @@ void a_Dicache_write(DilloUrl *url, int version, const uchar_t *buf, uint_t Y) */ void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client) { - DilloWeb *Web = Client->Web; + DilloWeb *Web = reinterpret_cast< DilloWeb * >( Client->Web ); DICacheEntry *DicEntry = a_Dicache_get_entry(url, version); dReturn_if_fail ( DicEntry != NULL ); @@ -386,7 +386,7 @@ void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client) static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr, CA_Callback_t *Call, void **Data) { - DilloWeb *web = Ptr; + DilloWeb *web = reinterpret_cast< DilloWeb * >( Ptr ); DICacheEntry *DicEntry; dReturn_val_if_fail(MimeType && Ptr, NULL); @@ -453,7 +453,7 @@ void *a_Dicache_png_image(const char *Type, void *Ptr, CA_Callback_t *Call, /** * WEBP wrapper for Dicache_image() */ -void *a_Dicache_webp_image(const char *Type, void *Ptr, CA_Callback_t *Call, +extern "C" void *a_Dicache_webp_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data) { return Dicache_image(DIC_Webp, Type, Ptr, Call, Data); @@ -480,7 +480,7 @@ void *a_Dicache_jpeg_image(const char *Type, void *Ptr, CA_Callback_t *Call, /** * SVG wrapper for Dicache_image() */ -void *a_Dicache_svg_image(const char *Type, void *Ptr, CA_Callback_t *Call, +extern "C" void *a_Dicache_svg_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data) { return Dicache_image(DIC_Svg, Type, Ptr, Call, Data); @@ -492,7 +492,7 @@ void *a_Dicache_svg_image(const char *Type, void *Ptr, CA_Callback_t *Call, void a_Dicache_callback(int Op, CacheClient_t *Client) { uint_t i; - DilloWeb *Web = Client->Web; + DilloWeb *Web = reinterpret_cast< DilloWeb * >( Client->Web ); DilloImage *Image = Web->Image; DICacheEntry *DicEntry = a_Dicache_get_entry(Web->url, DIC_Last); @@ -562,7 +562,7 @@ void a_Dicache_cleanup(void) int i; DICacheEntry *entry; - for (i = 0; (entry = dList_nth_data(CachedIMGs, i)); ++i) { + for (i = 0; (entry = reinterpret_cast< DICacheEntry * >( dList_nth_data(CachedIMGs, i) )); ++i) { _MSG(" SurvCleanup = %d\n", entry->SurvCleanup); if (entry->RefCount == 0 && (!entry->v_imgbuf || a_Imgbuf_last_reference(entry->v_imgbuf))) { @@ -588,7 +588,7 @@ void a_Dicache_freeall(void) DICacheEntry *entry; /* Remove all the dicache entries */ - while ((entry = dList_nth_data(CachedIMGs, dList_length(CachedIMGs)-1))) { + while ((entry = reinterpret_cast< DICacheEntry * >( dList_nth_data(CachedIMGs, dList_length(CachedIMGs)-1) ))) { dList_remove_fast(CachedIMGs, entry); a_Url_free(entry->url); dFree(entry->cmap); diff --git a/src/dicache.h b/src/dicache.hh similarity index 100% rename from src/dicache.h rename to src/dicache.hh diff --git a/src/digest.c b/src/digest.cc similarity index 99% rename from src/digest.c rename to src/digest.cc index 985ff02..a343fb4 100644 --- a/src/digest.c +++ b/src/digest.cc @@ -10,9 +10,9 @@ */ #include -#include "digest.h" +#include "digest.hh" #include "md5.h" -#include "msg.h" +#include "msg.hh" #include "../dlib/dlib.h" static const char *ALGORITHM2STR[] = { NULL, "MD5", "MD5-sess" }; diff --git a/src/digest.h b/src/digest.hh similarity index 100% rename from src/digest.h rename to src/digest.hh diff --git a/src/dillo.cc b/src/dillo.cc index fc4a08b..94e4288 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -37,29 +37,29 @@ #include #include -#include "msg.h" +#include "msg.hh" #include "paths.hh" #include "uicmd.hh" -#include "prefs.h" +#include "prefs.hh" #include "prefsparser.hh" #include "keys.hh" -#include "bw.h" +#include "bw.hh" #include "misc.hh" -#include "history.h" +#include "history.hh" #include "version.hh" -#include "dns.h" +#include "dns.hh" #include "web.hh" -#include "IO/tls.h" +#include "IO/tls.hh" #include "IO/Url.h" -#include "IO/mime.h" -#include "capi.h" -#include "dicache.h" -#include "cookies.h" -#include "actions.h" -#include "hsts.h" -#include "domain.h" +#include "IO/mime.hh" +#include "capi.hh" +#include "dicache.hh" +#include "cookies.hh" +#include "actions.hh" +#include "hsts.hh" +#include "domain.hh" #include "auth.hh" #include "styleengine.hh" diff --git a/src/djpeg.h b/src/djpeg.hh similarity index 100% rename from src/djpeg.h rename to src/djpeg.hh diff --git a/src/dns.c b/src/dns.cc similarity index 97% rename from src/dns.c rename to src/dns.cc index d32a7bf..c73d882 100644 --- a/src/dns.c +++ b/src/dns.cc @@ -37,8 +37,8 @@ #include #include -#include "msg.h" -#include "dns.h" +#include "msg.hh" +#include "dns.hh" #include "list.h" #include "IO/iowatch.hh" @@ -103,7 +103,7 @@ static int dns_notify_pipe[2]; static void Dns_queue_add(int channel, const char *hostname, DnsCallback_t cb_func, void *cb_data) { - a_List_add(dns_queue, dns_queue_size, dns_queue_size_max); + a_List_add(dns_queue, dns_queue_size, dns_queue_size_max, GDnsQueue); dns_queue[dns_queue_size].channel = channel; dns_queue[dns_queue_size].hostname = dStrdup(hostname); dns_queue[dns_queue_size].cb_func = cb_func; @@ -163,7 +163,7 @@ void Dns_queue_print() */ static void Dns_cache_add(char *hostname, Dlist *addr_list) { - a_List_add(dns_cache, dns_cache_size, dns_cache_size_max); + a_List_add(dns_cache, dns_cache_size, dns_cache_size_max, GDnsCache); dns_cache[dns_cache_size].hostname = dStrdup(hostname); dns_cache[dns_cache_size].addr_list = addr_list; ++dns_cache_size; @@ -307,7 +307,7 @@ static void *Dns_server(void *data) dns_server[channel].hostname); if ((length = dList_length(hosts))) { for (i = 0; i < length; i++) { - a_Dns_dillohost_to_string(dList_nth_data(hosts, i), + a_Dns_dillohost_to_string(reinterpret_cast< DilloHost * >( dList_nth_data(hosts, i) ), addr_string, sizeof(addr_string)); MSG(" %s", addr_string); } diff --git a/src/dns.h b/src/dns.hh similarity index 100% rename from src/dns.h rename to src/dns.hh diff --git a/src/domain.c b/src/domain.cc similarity index 98% rename from src/domain.c rename to src/domain.cc index c0b244f..788fa0a 100644 --- a/src/domain.c +++ b/src/domain.cc @@ -10,9 +10,9 @@ #include #include "../dlib/dlib.h" -#include "msg.h" +#include "msg.hh" #include "list.h" -#include "domain.h" +#include "domain.hh" typedef struct { char *origin; @@ -64,7 +64,7 @@ void a_Domain_parse(FILE *fp) MSG("Domain: Default action \"%s\" not recognised.\n", tok2); } } else { - a_List_add(exceptions, num_exceptions, num_exceptions_max); + a_List_add(exceptions, num_exceptions, num_exceptions_max, Rule); exceptions[num_exceptions].origin = dStrdup(tok1); exceptions[num_exceptions].destination = dStrdup(tok2); num_exceptions++; diff --git a/src/domain.h b/src/domain.hh similarity index 100% rename from src/domain.h rename to src/domain.hh diff --git a/src/dpiapi.c b/src/dpiapi.cc similarity index 95% rename from src/dpiapi.c rename to src/dpiapi.cc index 1cb03f0..5dd7220 100644 --- a/src/dpiapi.c +++ b/src/dpiapi.cc @@ -13,10 +13,10 @@ * Support for dpi/dpip from Dillo's side */ -#include "msg.h" -#include "bw.h" -#include "capi.h" -#include "dpiapi.h" /* for prototypes */ +#include "msg.hh" +#include "bw.hh" +#include "capi.hh" +#include "dpiapi.hh" /* for prototypes */ #include "dialog.hh" #include "../dpip/dpip.h" diff --git a/src/dpiapi.h b/src/dpiapi.hh similarity index 100% rename from src/dpiapi.h rename to src/dpiapi.hh diff --git a/src/dpng.h b/src/dpng.hh similarity index 90% rename from src/dpng.h rename to src/dpng.hh index 960f511..0f35287 100644 --- a/src/dpng.h +++ b/src/dpng.hh @@ -3,6 +3,8 @@ #ifdef __cplusplus extern "C" { +#else +#error PNG header is now C++ only #endif /* __cplusplus */ #include "url.hh" diff --git a/src/dsvg.h b/src/dsvg.hh similarity index 94% rename from src/dsvg.h rename to src/dsvg.hh index 4c886c4..e6d3076 100644 --- a/src/dsvg.h +++ b/src/dsvg.hh @@ -7,6 +7,7 @@ extern "C" { #include "url.hh" #include "image.hh" +#include "cache.hh" void *a_Svg_new(DilloImage *Image, DilloUrl *url, int version); diff --git a/src/dwebp.h b/src/dwebp.hh similarity index 100% rename from src/dwebp.h rename to src/dwebp.hh diff --git a/src/findbar.cc b/src/findbar.cc index 8b9c0ac..c48c4ee 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -13,10 +13,10 @@ #include #include "findbar.hh" -#include "msg.h" +#include "msg.hh" #include "pixmaps.h" #include "uicmd.hh" -#include "bw.h" +#include "bw.hh" /* * Local sub class diff --git a/src/form.cc b/src/form.cc index eea20ae..aa08aed 100644 --- a/src/form.cc +++ b/src/form.cc @@ -22,8 +22,8 @@ #include "dlib/dlib.h" #include "misc.hh" -#include "msg.h" -#include "prefs.h" +#include "msg.hh" +#include "prefs.hh" #include "uicmd.hh" #include "dialog.hh" diff --git a/src/gif.c b/src/gif.cc similarity index 96% rename from src/gif.c rename to src/gif.cc index 3bc531e..b9c25cc 100644 --- a/src/gif.c +++ b/src/gif.cc @@ -60,15 +60,18 @@ */ #include + +#include "dgif.hh" + #ifdef ENABLE_GIF #include /* for sprintf */ #include /* for memcpy and memmove */ -#include "msg.h" +#include "msg.hh" #include "image.hh" #include "cache.hh" -#include "dicache.h" +#include "dicache.hh" #define INTERLACE 0x40 #define LOCALCOLORMAP 0x80 @@ -152,7 +155,7 @@ static size_t Gif_process_bytes(DilloGif *gif, const uchar_t *buf, */ void *a_Gif_new(DilloImage *Image, DilloUrl *url, int version) { - DilloGif *gif = dMalloc(sizeof(DilloGif)); + DilloGif *gif = reinterpret_cast< DilloGif * >( dMalloc(sizeof(DilloGif)) ); _MSG("a_Gif_new: gif=%p\n", gif); gif->Image = Image; @@ -199,13 +202,13 @@ static void Gif_free(DilloGif *gif) void a_Gif_callback(int Op, void *data) { if (Op == CA_Send) { - CacheClient_t *Client = data; - Gif_write(Client->CbData, Client->Buf, Client->BufSize); + CacheClient_t *Client = reinterpret_cast< CacheClient_t * >( data ); + Gif_write(reinterpret_cast< DilloGif * >( Client->CbData ), Client->Buf, Client->BufSize); } else if (Op == CA_Close) { - CacheClient_t *Client = data; - Gif_close(Client->CbData, Client); + CacheClient_t *Client = reinterpret_cast< CacheClient_t * >( data ); + Gif_close(reinterpret_cast< DilloGif * >( Client->CbData ), Client); } else if (Op == CA_Abort) { - Gif_free(data); + Gif_free(reinterpret_cast< DilloGif * >( data )); } } @@ -368,9 +371,9 @@ static size_t Gif_do_extension(DilloGif *gif, uint_t Label, static void Gif_lwz_init(DilloGif *gif) { gif->num_spill_lines_max = 1; - gif->spill_lines = dMalloc(sizeof(uchar_t *) * gif->num_spill_lines_max); + gif->spill_lines = reinterpret_cast< unsigned char ** >( dMalloc(sizeof(uchar_t *) * gif->num_spill_lines_max) ); - gif->spill_lines[0] = dMalloc(gif->Width); + gif->spill_lines[0] = reinterpret_cast< unsigned char * >( dMalloc(gif->Width) ); gif->bits_in_window = 0; /* First code in table = clear_code +1 @@ -474,14 +477,14 @@ static void Gif_sequence(DilloGif *gif, uint_t code) /* Allocate more spill lines. */ spill_line_index = gif->num_spill_lines_max; gif->num_spill_lines_max = num_spill_lines << 1; - gif->spill_lines = dRealloc(gif->spill_lines, + gif->spill_lines = reinterpret_cast< unsigned char ** >( dRealloc(gif->spill_lines, gif->num_spill_lines_max * - sizeof(uchar_t *)); + sizeof(uchar_t *)) ); for (; spill_line_index < gif->num_spill_lines_max; spill_line_index++) gif->spill_lines[spill_line_index] = - dMalloc(gif->Width); + reinterpret_cast< unsigned char * >( dMalloc(gif->Width) ); } spill_line_index = num_spill_lines - 1; obuf = gif->spill_lines[spill_line_index]; @@ -845,7 +848,7 @@ static size_t Gif_do_img_desc(DilloGif *gif, void *Buf, gif->y = 0; Gif_lwz_init(gif); gif->spill_line_index = 0; - gif->linebuf = dMalloc(gif->Width); + gif->linebuf = reinterpret_cast< unsigned char * >( dMalloc(gif->Width) ); gif->state = 3; /*Process the lzw data next */ if (gif->ColorMap_ofs) { a_Dicache_set_cmap(gif->url, gif->version, gif->Background, diff --git a/src/history.c b/src/history.cc similarity index 96% rename from src/history.c rename to src/history.cc index a3711ce..ae94d1e 100644 --- a/src/history.c +++ b/src/history.cc @@ -13,9 +13,9 @@ * Linear history (it also provides indexes for the navigation stack) */ -#include "msg.h" +#include "msg.hh" #include "list.h" -#include "history.h" +#include "history.hh" typedef struct { @@ -62,7 +62,7 @@ int a_History_add_url(DilloUrl *url) _MSG("FOUND at idx=%d\n", idx); } else { idx = history_size; - a_List_add(history, history_size, history_size_max); + a_List_add(history, history_size, history_size_max, H_Item); history[idx].url = a_Url_dup(url); history[idx].title = NULL; ++history_size; diff --git a/src/history.h b/src/history.hh similarity index 100% rename from src/history.h rename to src/history.hh diff --git a/src/hsts.c b/src/hsts.cc similarity index 94% rename from src/hsts.c rename to src/hsts.cc index 92f4167..9d6a1da 100644 --- a/src/hsts.c +++ b/src/hsts.cc @@ -29,10 +29,10 @@ #include /* for isspace */ #include /* for strtol */ -#include "hsts.h" -#include "msg.h" +#include "hsts.hh" +#include "msg.hh" #include "../dlib/dlib.h" -#include "IO/tls.h" +#include "IO/tls.hh" typedef struct { char *host; @@ -59,7 +59,7 @@ void a_Hsts_freeall(void) int i, n = dList_length(domains); for (i = 0; i < n; i++) { - policy = dList_nth_data(domains, i); + policy = reinterpret_cast< HstsData_t * >( dList_nth_data(domains, i) ); Hsts_free_policy(policy); } dList_free(domains); @@ -71,15 +71,15 @@ void a_Hsts_freeall(void) */ static int Domain_node_domain_str_cmp(const void *v1, const void *v2) { - const HstsData_t *node = v1; - const char *host = v2; + const HstsData_t *node = reinterpret_cast< const HstsData_t * >( v1 ); + const char *host = reinterpret_cast< const char * >( v2 ); return dStrAsciiCasecmp(node->host, host); } static HstsData_t *Hsts_get_policy(const char *host) { - return dList_find_sorted(domains, host, Domain_node_domain_str_cmp); + return reinterpret_cast< HstsData_t * >( dList_find_sorted(domains, host, Domain_node_domain_str_cmp) ); } static void Hsts_remove_policy(HstsData_t *policy) @@ -116,7 +116,7 @@ static time_t Hsts_future_time(long seconds_from_now) */ static int Domain_node_cmp(const void *v1, const void *v2) { - const HstsData_t *node1 = v1, *node2 = v2; + const HstsData_t *node1 = reinterpret_cast< const HstsData_t * >( v1 ), *node2 = reinterpret_cast< const HstsData_t * >( v2 ); return dStrAsciiCasecmp(node1->host, node2->host); } diff --git a/src/hsts.h b/src/hsts.hh similarity index 100% rename from src/hsts.h rename to src/hsts.hh diff --git a/src/html.cc b/src/html.cc index a5596ff..9813e18 100644 --- a/src/html.cc +++ b/src/html.cc @@ -25,19 +25,19 @@ #include -#include "bw.h" /* for BrowserWindow */ -#include "msg.h" +#include "bw.hh" /* for BrowserWindow */ +#include "msg.hh" #include "binaryconst.h" -#include "colors.h" +#include "colors.hh" #include "html_charrefs.h" #include "utf8.hh" #include "misc.hh" #include "uicmd.hh" -#include "history.h" +#include "history.hh" #include "menu.hh" -#include "prefs.h" -#include "capi.h" +#include "prefs.hh" +#include "capi.hh" #include "html.hh" #include "html_common.hh" #include "form.hh" diff --git a/src/html_common.hh b/src/html_common.hh index 9e877ab..bfbf857 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -18,7 +18,7 @@ #include #include "url.hh" -#include "bw.h" +#include "bw.hh" #include "lout/misc.hh" #include "dw/core.hh" diff --git a/src/image.cc b/src/image.cc index 51017e6..8591b5a 100644 --- a/src/image.cc +++ b/src/image.cc @@ -16,7 +16,7 @@ * of data from an Image to a DwImage widget. */ -#include "msg.h" +#include "msg.hh" #include "image.hh" #include "dw/core.hh" diff --git a/src/imgbuf.cc b/src/imgbuf.cc index a7d505c..852fb4b 100644 --- a/src/imgbuf.cc +++ b/src/imgbuf.cc @@ -9,7 +9,7 @@ * (at your option) any later version. */ -#include "msg.h" +#include "msg.hh" #include "imgbuf.hh" #include "dw/core.hh" #include "dw/image.hh" diff --git a/src/jpeg.c b/src/jpeg.cc similarity index 93% rename from src/jpeg.c rename to src/jpeg.cc index 3625f2f..4c64b16 100644 --- a/src/jpeg.c +++ b/src/jpeg.cc @@ -18,6 +18,9 @@ */ #include + +#include "djpeg.hh" + #ifdef ENABLE_JPEG #include @@ -34,9 +37,9 @@ #include "image.hh" #include "cache.hh" -#include "dicache.h" -#include "capi.h" /* get cache entry status */ -#include "msg.h" +#include "dicache.hh" +#include "capi.hh" /* get cache entry status */ +#include "msg.hh" typedef enum { DILLO_JPEG_INIT, @@ -186,7 +189,7 @@ static void term_source(struct jpeg_decompress_struct *p) void *a_Jpeg_new(DilloImage *Image, DilloUrl *url, int version) { my_source_mgr *src; - DilloJpeg *jpeg = dMalloc(sizeof(*jpeg)); + DilloJpeg *jpeg = reinterpret_cast< DilloJpeg * >( dMalloc(sizeof(*jpeg)) ); _MSG("a_Jpeg_new: jpeg=%p\n", jpeg); jpeg->Image = Image; @@ -223,13 +226,13 @@ void *a_Jpeg_new(DilloImage *Image, DilloUrl *url, int version) void a_Jpeg_callback(int Op, void *data) { if (Op == CA_Send) { - CacheClient_t *Client = data; - Jpeg_write(Client->CbData, Client->Buf, Client->BufSize); + CacheClient_t *Client = reinterpret_cast< CacheClient_t * >( data ); + Jpeg_write(reinterpret_cast< DilloJpeg * >( Client->CbData ), Client->Buf, Client->BufSize); } else if (Op == CA_Close) { - CacheClient_t *Client = data; - Jpeg_close(Client->CbData, Client); + CacheClient_t *Client = reinterpret_cast< CacheClient_t * >( data ); + Jpeg_close(reinterpret_cast< DilloJpeg * >( Client->CbData ), Client); } else if (Op == CA_Abort) { - Jpeg_free(data); + Jpeg_free(reinterpret_cast< DilloJpeg * >( data )); } } @@ -269,7 +272,7 @@ static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize) jpeg->cinfo.src->next_input_byte = (uchar_t *)Buf + jpeg->Start_Ofs; jpeg->cinfo.src->bytes_in_buffer = BufSize - jpeg->Start_Ofs; jpeg->NewStart = BufSize; - jpeg->Data = Buf; + jpeg->Data = reinterpret_cast< char * >( Buf ); if (setjmp(jpeg->jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ @@ -356,8 +359,8 @@ static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize) } if (jpeg->state == DILLO_JPEG_READ_IN_SCAN) { - linebuf = dMalloc(jpeg->cinfo.image_width * - jpeg->cinfo.num_components); + linebuf = reinterpret_cast< unsigned char * >( dMalloc(jpeg->cinfo.image_width * + jpeg->cinfo.num_components) ); array[0] = linebuf; while (1) { diff --git a/src/keys.cc b/src/keys.cc index 11d797d..9e1c925 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -19,7 +19,7 @@ #include "dlib/dlib.h" #include "keys.hh" #include "utf8.hh" -#include "msg.h" +#include "msg.hh" #include #include diff --git a/src/list.h b/src/list.h index ebcf50f..d0cb376 100644 --- a/src/list.h +++ b/src/list.h @@ -13,22 +13,22 @@ * (First, allocate an 'alloc_step' sized chunk, after that, double the * list size --to make it faster) */ -#define a_List_resize(list,num_items,alloc_step) \ +#define a_List_resize(list,num_items,alloc_step, type) \ if (!list) { \ - list = dMalloc(alloc_step * sizeof(*list)); \ + list = (type *) dMalloc(alloc_step * sizeof(*list)); \ } \ if (num_items >= alloc_step){ \ while ( num_items >= alloc_step ) \ alloc_step <<= 1; \ - list = dRealloc(list, alloc_step * sizeof(*list)); \ + list = (type *) dRealloc(list, alloc_step * sizeof(*list)); \ } /** * Make sure there's space for one more item within the list. */ -#define a_List_add(list,num_items,alloc_step) \ - a_List_resize(list,num_items,alloc_step) +#define a_List_add(list,num_items,alloc_step, type) \ + a_List_resize(list,num_items,alloc_step, type) /** diff --git a/src/menu.cc b/src/menu.cc index 3797840..af68f78 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -21,11 +21,11 @@ #include #include #include "lout/misc.hh" /* SimpleVector */ -#include "msg.h" +#include "msg.hh" #include "menu.hh" -#include "actions.h" +#include "actions.hh" #include "uicmd.hh" -#include "history.h" +#include "history.hh" #include "html.hh" #include "ui.hh" // for (UI *) #include "keys.hh" diff --git a/src/menu.hh b/src/menu.hh index e35d00e..0aa43ea 100644 --- a/src/menu.hh +++ b/src/menu.hh @@ -1,7 +1,7 @@ #ifndef __MENU_HH__ #define __MENU_HH__ -#include "bw.h" +#include "bw.hh" #ifdef __cplusplus extern "C" { diff --git a/src/misc.cc b/src/misc.cc index 386c6d4..92b228b 100644 --- a/src/misc.cc +++ b/src/misc.cc @@ -16,7 +16,7 @@ #include #include "utf8.hh" -#include "msg.h" +#include "msg.hh" #include "misc.hh" /** diff --git a/src/msg.h b/src/msg.hh similarity index 92% rename from src/msg.h rename to src/msg.hh index 94fde67..17cc47f 100644 --- a/src/msg.h +++ b/src/msg.hh @@ -1,8 +1,10 @@ +static_assert( __cplusplus > 2023'00 ); + #ifndef __MSG_H__ #define __MSG_H__ #include -#include "prefs.h" +#include "prefs.hh" /* * You can disable any MSG* macro by adding the '_' prefix. diff --git a/src/nanosvg.h b/src/nanosvg.h index bcc5845..63be288 100644 --- a/src/nanosvg.h +++ b/src/nanosvg.h @@ -149,7 +149,7 @@ typedef struct NSVGshape char strokeDashCount; // Number of dash values in dash array. char strokeLineJoin; // Stroke join type. char strokeLineCap; // Stroke cap type. - char virtual; // A shape from not to be drawn + char virtual_; // A shape from not to be drawn float miterLimit; // Miter limit char fillRule; // Fill rule, see NSVGfillRule. unsigned char flags; // Logical or of NSVG_FLAGS_* flags @@ -979,7 +979,7 @@ static void nsvg__addShape(NSVGparser* p) shape->miterLimit = attr->miterLimit; shape->fillRule = attr->fillRule; shape->opacity = attr->opacity; - shape->virtual = p->defsFlag; + shape->virtual_ = p->defsFlag; shape->paths = p->plist; p->plist = NULL; @@ -3030,7 +3030,7 @@ static void nsvg__scaleToViewbox(NSVGparser* p, const char* units) sy *= us; avgs = (sx+sy) / 2.0f; for (shape = p->image->shapes; shape != NULL; shape = shape->next) { - if (shape->virtual) + if (shape->virtual_) continue; shape->bounds[0] = (shape->bounds[0] + tx) * sx; @@ -3072,7 +3072,7 @@ static void nsvg__createGradients(NSVGparser* p) NSVGshape* shape; for (shape = p->image->shapes; shape != NULL; shape = shape->next) { - if (shape->virtual) + if (shape->virtual_) continue; if (shape->fill.type == NSVG_PAINT_UNDEF) { diff --git a/src/nanosvgrast.h b/src/nanosvgrast.h index ec46d6e..b0e3c2e 100644 --- a/src/nanosvgrast.h +++ b/src/nanosvgrast.h @@ -1408,7 +1408,7 @@ void nsvgRasterizeXY(NSVGrasterizer* r, memset(&dst[i*stride], 0, w*4); for (shape = image->shapes; shape != NULL; shape = shape->next) { - if (!(shape->flags & NSVG_FLAGS_VISIBLE) || shape->virtual) + if (!(shape->flags & NSVG_FLAGS_VISIBLE) || shape->virtual_) continue; if (shape->fill.type != NSVG_PAINT_NONE) { diff --git a/src/nav.c b/src/nav.cc similarity index 95% rename from src/nav.c rename to src/nav.cc index df2d4ba..3248242 100644 --- a/src/nav.c +++ b/src/nav.cc @@ -14,14 +14,14 @@ #include #include -#include "msg.h" -#include "nav.h" -#include "history.h" +#include "msg.hh" +#include "nav.hh" +#include "history.hh" #include "web.hh" #include "uicmd.hh" #include "dialog.hh" -#include "prefs.h" -#include "capi.h" +#include "prefs.hh" +#include "capi.hh" #include "timeout.hh" /* @@ -62,7 +62,7 @@ int a_Nav_stack_ptr(BrowserWindow *bw) */ int a_Nav_get_uidx(BrowserWindow *bw, int i) { - nav_stack_item *nsi = dList_nth_data (bw->nav_stack, i); + nav_stack_item *nsi = reinterpret_cast< nav_stack_item * >( dList_nth_data (bw->nav_stack, i) ); return (nsi) ? nsi->url_idx : -1; } @@ -73,7 +73,7 @@ int a_Nav_get_top_uidx(BrowserWindow *bw) { nav_stack_item *nsi; - nsi = dList_nth_data (bw->nav_stack, a_Nav_stack_ptr(bw)); + nsi = reinterpret_cast< nav_stack_item * >( dList_nth_data (bw->nav_stack, a_Nav_stack_ptr(bw)) ); return (nsi) ? nsi->url_idx : -1; } @@ -140,7 +140,7 @@ static void Nav_get_scroll_pos(BrowserWindow *bw, int *posx, int *posy) { nav_stack_item *nsi; - if ((nsi = dList_nth_data (bw->nav_stack, a_Nav_stack_ptr(bw)))) { + if ((nsi = reinterpret_cast< nav_stack_item * >( dList_nth_data (bw->nav_stack, a_Nav_stack_ptr(bw)) ))) { *posx = nsi->posx; *posy = nsi->posy; } else { @@ -155,7 +155,7 @@ static void Nav_save_scroll_pos(BrowserWindow *bw, int idx, int posx, int posy) { nav_stack_item *nsi; - if ((nsi = dList_nth_data (bw->nav_stack, idx))) { + if ((nsi = reinterpret_cast< nav_stack_item * >( dList_nth_data (bw->nav_stack, idx) ))) { nsi->posx = posx; nsi->posy = posy; } @@ -378,7 +378,7 @@ static void Nav_repush(BrowserWindow *bw) static void Nav_repush_callback(void *data) { _MSG(">>>> Nav_repush_callback <<<<\n"); - Nav_repush(data); + Nav_repush(reinterpret_cast< BrowserWindow * >( data )); a_Timeout_remove(); } @@ -473,7 +473,7 @@ void a_Nav_home(BrowserWindow *bw) */ static void Nav_reload_callback(void *data) { - BrowserWindow *bw = data; + BrowserWindow *bw = reinterpret_cast< BrowserWindow * >( data ); const DilloUrl *h_url; DilloUrl *r_url; int choice, confirmed = 1; @@ -543,7 +543,7 @@ void a_Nav_jump(BrowserWindow *bw, int offset, int new_bw) */ static void Nav_save_cb(int Op, CacheClient_t *Client) { - DilloWeb *Web = Client->Web; + DilloWeb *Web = reinterpret_cast< DilloWeb * >( Client->Web ); int Bytes; if (Op){ diff --git a/src/nav.h b/src/nav.hh similarity index 98% rename from src/nav.h rename to src/nav.hh index f576329..9e093cf 100644 --- a/src/nav.h +++ b/src/nav.hh @@ -1,7 +1,7 @@ #ifndef __NAV_H__ #define __NAV_H__ -#include "bw.h" +#include "bw.hh" /* * useful macros for the navigation stack diff --git a/src/paths.cc b/src/paths.cc index 3f71ab1..910a209 100644 --- a/src/paths.cc +++ b/src/paths.cc @@ -13,7 +13,7 @@ #include #include -#include "msg.h" +#include "msg.hh" #include "../dlib/dlib.h" #include "paths.hh" diff --git a/src/plain.cc b/src/plain.cc index fe75791..898266f 100644 --- a/src/plain.cc +++ b/src/plain.cc @@ -15,10 +15,10 @@ * Module for decoding a text/plain object into a dw widget. */ -#include "msg.h" -#include "prefs.h" +#include "msg.hh" +#include "prefs.hh" #include "cache.hh" -#include "bw.h" +#include "bw.hh" #include "web.hh" #include "misc.hh" #include "styleengine.hh" diff --git a/src/png.c b/src/png.cc similarity index 94% rename from src/png.c rename to src/png.cc index 8db0e5f..d52cacb 100644 --- a/src/png.c +++ b/src/png.cc @@ -15,6 +15,7 @@ */ #include +#include "dpng.hh" #ifdef ENABLE_PNG #include /* For abort() */ @@ -25,10 +26,10 @@ #include #endif -#include "msg.h" +#include "msg.hh" #include "image.hh" #include "cache.hh" -#include "dicache.h" +#include "dicache.hh" enum prog_state { IS_finished, IS_init, IS_nextdata @@ -106,7 +107,7 @@ void Png_error_handling(png_structp png_ptr, png_const_charp msg) { DilloPng *png; - png = png_get_error_ptr(png_ptr); + png = reinterpret_cast< DilloPng * >( png_get_error_ptr(png_ptr) ); MSG("Png_error_handling: %s: %s\n", URL_STR(png->url), msg); png->error = 1; @@ -120,7 +121,7 @@ void Png_warning_handler(png_structp png_ptr, png_const_charp msg) { DilloPng *png; - png = png_get_error_ptr(png_ptr); + png = reinterpret_cast< DilloPng * >( png_get_error_ptr(png_ptr) ); MSG_WARN("Png warning: %s in %s\n", msg, URL_STR(png->url)); } @@ -136,7 +137,7 @@ Png_datainfo_callback(png_structp png_ptr, png_infop info_ptr) _MSG("Png_datainfo_callback:\n"); - png = png_get_progressive_ptr(png_ptr); + png = reinterpret_cast< DilloPng * >( png_get_progressive_ptr(png_ptr) ); dReturn_if_fail (png != NULL); png_get_IHDR(png_ptr, info_ptr, &png->width, &png->height, @@ -211,7 +212,7 @@ Png_datainfo_callback(png_structp png_ptr, png_infop info_ptr) for (i = 0; i < png->height; i++) png->row_pointers[i] = png->image_data + (i * png->rowbytes); - png->linebuf = dMalloc(3 * png->width); + png->linebuf = reinterpret_cast< unsigned char * >( dMalloc(3 * png->width) ); /* Initialize the dicache-entry here */ a_Dicache_set_parms(png->url, png->version, png->Image, @@ -232,7 +233,7 @@ static void _MSG("Png_datarow_callback: row_num = %ld\n", row_num); - png = png_get_progressive_ptr(png_ptr); + png = reinterpret_cast< DilloPng * >( png_get_progressive_ptr(png_ptr) ); png_progressive_combine_row(png_ptr, png->row_pointers[row_num], new_row); @@ -300,7 +301,7 @@ static void Png_dataend_callback(png_structp png_ptr, png_infop info_ptr) if (!info_ptr) MSG("Png_dataend_callback: info_ptr = NULL\n"); - png = png_get_progressive_ptr(png_ptr); + png = reinterpret_cast< DilloPng * >( png_get_progressive_ptr(png_ptr) ); png->state = IS_finished; } @@ -341,7 +342,7 @@ static void Png_write(DilloPng *png, void *Buf, uint_t BufSize) /* Keep local copies so we don't have to pass multiple args to * a number of functions. */ - png->ipbuf = Buf; + png->ipbuf = reinterpret_cast< unsigned char * >( Buf ); png->ipbufsize = BufSize; /* start/resume the FSM here */ @@ -424,16 +425,16 @@ static void Png_write(DilloPng *png, void *Buf, uint_t BufSize) * failure. This means that you can't just wait for all the data to be * presented before starting conversion and display. */ -void a_Png_callback(int Op, void *data) +extern "C" void a_Png_callback(int Op, CacheClient_t *data) { if (Op == CA_Send) { CacheClient_t *Client = data; - Png_write(Client->CbData, Client->Buf, Client->BufSize); + Png_write(reinterpret_cast< DilloPng * >( Client->CbData ), Client->Buf, Client->BufSize); } else if (Op == CA_Close) { CacheClient_t *Client = data; - Png_close(Client->CbData, Client); + Png_close(reinterpret_cast< DilloPng * >( Client->CbData ), Client); } else if (Op == CA_Abort) { - Png_free(data); + Png_free(reinterpret_cast< DilloPng * >( data )); } } diff --git a/src/prefs.c b/src/prefs.cc similarity index 99% rename from src/prefs.c rename to src/prefs.cc index bee22df..f2a7749 100644 --- a/src/prefs.c +++ b/src/prefs.cc @@ -10,7 +10,7 @@ * (at your option) any later version. */ -#include "prefs.h" +#include "prefs.hh" #define PREFS_START_PAGE "about:splash" #define PREFS_HOME "https://dillo-browser.github.io/" diff --git a/src/prefs.h b/src/prefs.hh similarity index 98% rename from src/prefs.h rename to src/prefs.hh index d496fb5..51c95ca 100644 --- a/src/prefs.h +++ b/src/prefs.hh @@ -17,6 +17,8 @@ #ifdef __cplusplus extern "C" { +#else +#error Prefs header is now C++ #endif /* __cplusplus */ #define PREFS_GEOMETRY_DEFAULT_WIDTH 780 diff --git a/src/prefsparser.cc b/src/prefsparser.cc index d910211..36706a8 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -21,10 +21,10 @@ #include /* for HUGE_VAL */ #include -#include "prefs.h" +#include "prefs.hh" #include "misc.hh" -#include "msg.h" -#include "colors.h" +#include "msg.hh" +#include "colors.hh" #include "prefsparser.hh" diff --git a/src/styleengine.cc b/src/styleengine.cc index 2a9b02c..f8a8ec8 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -11,13 +11,13 @@ */ #include "../dlib/dlib.h" -#include "msg.h" -#include "prefs.h" +#include "msg.hh" +#include "prefs.hh" #include "misc.hh" #include "html_common.hh" #include "styleengine.hh" #include "web.hh" -#include "capi.h" +#include "capi.hh" using namespace lout::misc; using namespace dw::core::style; diff --git a/src/svg.c b/src/svg.cc similarity index 89% rename from src/svg.c rename to src/svg.cc index 1c112ed..33fd01e 100644 --- a/src/svg.c +++ b/src/svg.cc @@ -11,14 +11,16 @@ #include +#include "dsvg.hh" + #ifdef ENABLE_SVG #include /* For abort() */ -#include "msg.h" +#include "msg.hh" #include "image.hh" #include "cache.hh" -#include "dicache.h" +#include "dicache.hh" #define NANOSVG_ALL_COLOR_KEYWORDS #define NANOSVG_IMPLEMENTATION @@ -69,7 +71,7 @@ static void Svg_write(DilloSvg *svg, void *Buf, uint_t BufSize) return; /* SVG image not finished yet */ - if (strstr(Buf, "") == NULL) + if (strstr(reinterpret_cast< char * >( Buf ), "") == NULL) return; /* Use foreground as the current color, but transform to @@ -80,7 +82,7 @@ static void Svg_write(DilloSvg *svg, void *Buf, uint_t BufSize) unsigned curcolor = NSVG_RGB(fg_r, fg_g, fg_b); /* NULL-terminate Buf */ - char *str = dStrndup(Buf, BufSize); + char *str = dStrndup(reinterpret_cast< const char * >( Buf ), BufSize); NSVGimage *nimg = nsvgParse(str, "px", svg->Image->dpi, curcolor); dFree(str); @@ -132,16 +134,16 @@ static void Svg_write(DilloSvg *svg, void *Buf, uint_t BufSize) nsvgDelete(nimg); } -void a_Svg_callback(int Op, void *data) +extern "C" void a_Svg_callback(int Op, CacheClient_t *data) { if (Op == CA_Send) { CacheClient_t *Client = data; - Svg_write(Client->CbData, Client->Buf, Client->BufSize); + Svg_write(reinterpret_cast< DilloSvg * >( Client->CbData ), Client->Buf, Client->BufSize); } else if (Op == CA_Close) { CacheClient_t *Client = data; - Svg_close(Client->CbData, Client); + Svg_close(reinterpret_cast< DilloSvg * >( Client->CbData ), Client); } else if (Op == CA_Abort) { - Svg_free(data); + Svg_free(reinterpret_cast< DilloSvg * >( data )); } } diff --git a/src/table.cc b/src/table.cc index 59cc8e2..8059f59 100644 --- a/src/table.cc +++ b/src/table.cc @@ -23,8 +23,8 @@ #include "dw/table.hh" #include "dw/simpletablecell.hh" -#include "prefs.h" -#include "msg.h" +#include "prefs.hh" +#include "msg.hh" #include "css.hh" using namespace dw; diff --git a/src/tipwin.cc b/src/tipwin.cc index 8dd6ebb..4d3583c 100644 --- a/src/tipwin.cc +++ b/src/tipwin.cc @@ -25,7 +25,7 @@ #include #include -#include "prefs.h" +#include "prefs.hh" #include "tipwin.hh" #include "dlib/dlib.h" diff --git a/src/ui.cc b/src/ui.cc index 7c2b2da..b8fc2e6 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -20,7 +20,7 @@ #include "keys.hh" #include "ui.hh" -#include "msg.h" +#include "msg.hh" #include "timeout.hh" #include "utf8.hh" #include "tipwin.hh" @@ -33,8 +33,8 @@ // Include image data #include "pixmaps.h" #include "uicmd.hh" -#include "history.h" -#include "nav.h" +#include "history.hh" +#include "nav.hh" struct iconset { Fl_Image *ImgMeterOK, *ImgMeterBug, diff --git a/src/uicmd.cc b/src/uicmd.cc index b92742c..b5a3936 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -41,16 +41,16 @@ #include "menu.hh" #include "dialog.hh" #include "xembed.hh" -#include "bookmark.h" -#include "history.h" -#include "msg.h" -#include "prefs.h" +#include "bookmark.hh" +#include "history.hh" +#include "msg.hh" +#include "prefs.hh" #include "misc.hh" #include "dlib/dlib.h" #include "dw/fltkviewport.hh" -#include "nav.h" +#include "nav.hh" //#define DEFAULT_TAB_LABEL "-.untitled.-" #define DEFAULT_TAB_LABEL "-.new.-" diff --git a/src/uicmd.hh b/src/uicmd.hh index 41ccf3a..3673d0d 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -13,7 +13,7 @@ #ifndef __UICMD_HH__ #define __UICMD_HH__ -#include "bw.h" +#include "bw.hh" #ifdef __cplusplus extern "C" { diff --git a/src/url.cc b/src/url.cc index 5b89c95..b8e765f 100644 --- a/src/url.cc +++ b/src/url.cc @@ -47,9 +47,9 @@ #include #include "url.hh" -#include "hsts.h" +#include "hsts.hh" #include "misc.hh" -#include "msg.h" +#include "msg.hh" static const char *HEX = "0123456789ABCDEF"; diff --git a/src/url.hh b/src/url.hh index da61fef..d45c77e 100644 --- a/src/url.hh +++ b/src/url.hh @@ -83,6 +83,8 @@ #ifdef __cplusplus extern "C" { +#else +#error URL header is now C++ #endif /* __cplusplus */ typedef struct { diff --git a/src/version.cc b/src/version.cc index bd18f15..b3791be 100644 --- a/src/version.cc +++ b/src/version.cc @@ -20,10 +20,10 @@ #include "config.h" #include "commit.h" -#include "djpeg.h" -#include "dpng.h" -#include "dwebp.h" -#include "IO/tls.h" +#include "djpeg.hh" +#include "dpng.hh" +#include "dwebp.hh" +#include "IO/tls.hh" #include #include diff --git a/src/web.cc b/src/web.cc index d0da091..6a5d79b 100644 --- a/src/web.cc +++ b/src/web.cc @@ -10,13 +10,13 @@ * (at your option) any later version. */ -#include "msg.h" -#include "nav.h" +#include "msg.hh" +#include "nav.hh" #include "uicmd.hh" -#include "IO/IO.h" -#include "IO/mime.h" +#include "IO/IO.hh" +#include "IO/mime.hh" #include "dw/core.hh" #include "styleengine.hh" diff --git a/src/web.hh b/src/web.hh index 9f746e5..7c46cd8 100644 --- a/src/web.hh +++ b/src/web.hh @@ -1,7 +1,7 @@ #pragma once #include /* for FILE */ -#include "bw.h" /* for BrowserWindow */ +#include "bw.hh" /* for BrowserWindow */ #include "cache.hh" /* for CA_Callback_t */ #include "image.hh" /* for DilloImage */ diff --git a/src/webp.c b/src/webp.cc similarity index 92% rename from src/webp.c rename to src/webp.cc index d8bdcae..7b6d839 100644 --- a/src/webp.c +++ b/src/webp.cc @@ -11,16 +11,21 @@ */ #include + +#include "dwebp.hh" + #ifdef ENABLE_WEBP #include /* For abort() */ +#include + #include -#include "msg.h" +#include "msg.hh" #include "image.hh" #include "cache.hh" -#include "dicache.h" +#include "dicache.hh" enum prog_state { IS_finished, IS_init, IS_nextdata @@ -86,7 +91,7 @@ static void Webp_close(DilloWebp *webp, CacheClient_t *Client) */ void a_Webp_callback(int Op, void *data) { - CacheClient_t *Client = data; + CacheClient_t *Client = reinterpret_cast< CacheClient_t * >( data ); if (Op == CA_Send) { uint8_t* output; @@ -97,7 +102,7 @@ void a_Webp_callback(int Op, void *data) if (webp->state == IS_init) { WebPBitstreamFeatures features; - ret = WebPGetFeatures(Client->Buf, Client->BufSize, &features); + ret = WebPGetFeatures(reinterpret_cast< const std::uint8_t * >( Client->Buf ), Client->BufSize, &features); if (ret != VP8_STATUS_OK) { MSG("features ret is %d\n", ret); return; @@ -115,7 +120,7 @@ void a_Webp_callback(int Op, void *data) webp->state = IS_nextdata; } - ret = WebPIUpdate(webp->idec, Client->Buf, Client->BufSize); + ret = WebPIUpdate(webp->idec, reinterpret_cast< const std::uint8_t * >( Client->Buf ), Client->BufSize); /* SUSPENDED is a success state that means you don't have the entire file yet */ if (ret == VP8_STATUS_SUSPENDED || ret == VP8_STATUS_OK) { /* last_y seems 1-based, which would be kind of crazy, but I would expect @@ -167,9 +172,9 @@ void a_Webp_callback(int Op, void *data) MSG("webp WebPIUpdate failed with %d\n", ret); } } else if (Op == CA_Close) { - Webp_close(Client->CbData, Client); + Webp_close(reinterpret_cast< DilloWebp * >( Client->CbData ), Client); } else if (Op == CA_Abort) { - Webp_free(data); + Webp_free(reinterpret_cast< DilloWebp * >( data )); } }