Plumbing ownership further; some things became C++

This commit is contained in:
2025-04-14 03:48:28 -04:00
parent 76bae93e1c
commit d4a69c0b11
30 changed files with 192 additions and 193 deletions

View File

@ -66,11 +66,10 @@ static const char *HEX = "0123456789ABCDEF";
* Return the url as a string.
* (initializing 'url_string' field if necessary)
*/
char *a_Url_str(const DilloUrl &u)
char *a_Url_str(const DilloUrl *u)
{
DilloUrl &u_nc= const_cast< DilloUrl & >( u );
/* Internal url handling IS transparent to the caller */
DilloUrl *url = &u_nc;
DilloUrl *url = const_cast< DilloUrl * >( u );
dReturn_val_if_fail (url != NULL, NULL);
@ -96,12 +95,11 @@ char *a_Url_str(const DilloUrl &u)
* (initializing 'hostname' and 'port' fields if necessary)
* Note: a similar approach can be taken for user:password auth.
*/
const char *a_Url_hostname(const DilloUrl &u)
const char *a_Url_hostname(const DilloUrl *u)
{
DilloUrl &u_nc= const_cast< DilloUrl & >( u );
const char *p;
/* Internal url handling IS transparent to the caller */
DilloUrl *url = &u_nc;
DilloUrl *url= const_cast< DilloUrl * >( u );
if (!url->hostname && url->authority) {
if (url->authority[0] == '[' && (p = strchr(url->authority, ']'))) {
@ -431,7 +429,7 @@ std::unique_ptr< DilloUrl > a_Url_new(const char *url_str, const char *base_url)
* URLs like "http://en.wikipedia.org:80" to "https://en.wikipedia.org:443".
*/
if (prefs.http_strict_transport_security &&
a_Hsts_require_https(a_Url_hostname(*url))) {
a_Hsts_require_https(a_Url_hostname(url.get()))) {
_MSG("url: HSTS transformation for %s.\n", url->url_string->str);
switch_to_https = TRUE;
} else if (prefs.http_force_https) {
@ -465,18 +463,18 @@ std::unique_ptr< DilloUrl > a_Url_new(const char *url_str, const char *base_url)
/**
* Duplicate a Url structure
*/
std::unique_ptr< DilloUrl > a_Url_dup(const DilloUrl &ori)
std::unique_ptr< DilloUrl > a_Url_dup(const DilloUrl *ori)
{
auto url = Url_object_new(URL_STR_(&ori));
auto url = Url_object_new(URL_STR_(ori));
dReturn_val_if_fail (url != NULL, NULL);
url->url_string = URL_STR(&ori);
url->port = ori.port;
url->flags = ori.flags;
url->ismap_url_len = ori.ismap_url_len;
url->illegal_chars = ori.illegal_chars;
url->illegal_chars_spc = ori.illegal_chars_spc;
url->data = ori.data;
url->url_string = URL_STR(ori);
url->port = ori->port;
url->flags = ori->flags;
url->ismap_url_len = ori->ismap_url_len;
url->illegal_chars = ori->illegal_chars;
url->illegal_chars_spc = ori->illegal_chars_spc;
url->data = ori->data;
return url;
}
@ -491,11 +489,8 @@ std::unique_ptr< DilloUrl > a_Url_dup(const DilloUrl &ori)
*
* Note: this function defines a sorting order different from strcmp!
*/
int a_Url_cmp(const DilloUrl &A_, const DilloUrl &B_)
int a_Url_cmp(const DilloUrl *A, const DilloUrl *B)
{
const DilloUrl *const A= &A_;
const DilloUrl *const B= &B_;
int st;
dReturn_val_if_fail(A && B, 1);
@ -515,17 +510,17 @@ int a_Url_cmp(const DilloUrl &A_, const DilloUrl &B_)
/**
* Set DilloUrl flags
*/
void a_Url_set_flags(DilloUrl &u, int flags)
void a_Url_set_flags(DilloUrl *u, int flags)
{
u.flags = flags;
u->flags = flags;
}
/**
* Set DilloUrl data (like POST info, etc.)
*/
void a_Url_set_data(DilloUrl &u, std::string_view data)
void a_Url_set_data(DilloUrl *u, std::string_view data)
{
u.data= data;
u->data= data;
}
/**