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

@ -126,7 +126,7 @@ int a_Http_init(void)
if (env_proxy && strlen(env_proxy))
HTTP_Proxy = a_Url_new(env_proxy, NULL).release();
if (!HTTP_Proxy && prefs.http_proxy)
HTTP_Proxy = a_Url_dup(*prefs.http_proxy).release();
HTTP_Proxy = a_Url_dup(prefs.http_proxy).release();
/* This allows for storing the proxy password in "user:passwd" format
* in dillorc, but as this constitutes a security problem, it was disabled.
@ -802,7 +802,7 @@ static int Http_get(ChainLink *Info, void *Data1)
}
hostname = dStrdup(URL_HOST(url));
S->connect_port = URL_PORT(url);
S->url = a_Url_dup(*S->web->url).release();
S->url = a_Url_dup(S->web->url).release();
if (!dStrAsciiCasecmp(URL_SCHEME(S->url), "https"))
S->flags |= HTTP_SOCKET_TLS;

View File

@ -168,7 +168,7 @@ static int Tls_conn_new(int fd, const DilloUrl *url, SSL *ssl)
Conn_t *conn = dNew0(Conn_t, 1);
conn->fd = fd;
conn->url = a_Url_dup(*url).release();
conn->url = a_Url_dup(url).release();
conn->ssl = ssl;
conn->connecting = TRUE;
conn->in_connect = FALSE;

View File

@ -632,7 +632,7 @@ static int Auth_do_auth_dialog(const AuthParse_t *auth_parse,
"Authentication scheme: ", typestr, NULL);
data = dNew(AuthDialogData_t, 1);
data->auth_parse = auth_parse;
data->url = a_Url_dup(*url).release();
data->url = a_Url_dup(url).release();
ret = a_Dialog_user_password(title, msg, Auth_do_auth_dialog_cb, data);
dFree(title); dFree(msg);
delete const_cast< DilloUrl * >( data->url );

View File

@ -210,8 +210,8 @@ void a_Bw_add_url(BrowserWindow *bw, const DilloUrl *Url)
{
dReturn_if_fail ( bw != NULL && Url != NULL );
if (!dList_find_custom(bw->PageUrls, Url, (dCompareFunc)a_Url_cmp_c)) {
dList_append(bw->PageUrls, a_Url_dup(*Url).release());
if (!dList_find_custom(bw->PageUrls, Url, (dCompareFunc)a_Url_cmp)) {
dList_append(bw->PageUrls, a_Url_dup(Url).release());
}
}
@ -251,7 +251,7 @@ void *a_Bw_get_url_doc(BrowserWindow *bw, const DilloUrl *url)
{
void *doc = NULL;
if (url && dList_find_custom(bw->PageUrls, url, (dCompareFunc)a_Url_cmp_c)) {
if (url && dList_find_custom(bw->PageUrls, url, (dCompareFunc)a_Url_cmp)) {
doc = a_Bw_get_current_doc(bw);
}
return doc;
@ -322,7 +322,7 @@ BrowserWindow *a_Bw_get(int i)
void a_Bw_expect(BrowserWindow *bw, const DilloUrl *url)
{
delete bw->nav_expect_url;
bw->nav_expect_url = a_Url_dup(*url).release();
bw->nav_expect_url = a_Url_dup(url).release();
}
void a_Bw_cancel_expect(BrowserWindow *bw)

View File

@ -98,7 +98,7 @@ static int Cache_entry_cmp(const void *v1, const void *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);
return a_Url_cmp(d1->Url, d2->Url);
}
/**
@ -109,7 +109,7 @@ static int Cache_entry_by_url_cmp(const void *v1, const void *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);
return a_Url_cmp(u1, u2);
}
/**
@ -191,7 +191,7 @@ static void Cache_client_dequeue(CacheClient_t *Client)
*/
static void Cache_entry_init(CacheEntry_t *NewEntry, const DilloUrl *Url)
{
NewEntry->Url = a_Url_dup(*Url).release();
NewEntry->Url = a_Url_dup(Url).release();
NewEntry->TypeDet = NULL;
NewEntry->TypeHdr = NULL;
NewEntry->TypeMeta = NULL;
@ -1025,7 +1025,7 @@ static int Cache_redirect(CacheEntry_t *entry, int Flags, BrowserWindow *bw)
/* Redirection of the main page */
auto NewUrl = a_Url_new(URL_STR_(entry->Location), URL_STR_(entry->Url));
if (entry->Flags & CA_TempRedirect)
a_Url_set_flags(*NewUrl, URL_FLAGS(NewUrl) | URL_E2EQuery);
a_Url_set_flags(NewUrl.get(), URL_FLAGS(NewUrl) | URL_E2EQuery);
a_Nav_push(bw, NewUrl.get(), entry->Url);
} else {
/* Sub entity redirection (most probably an image) */
@ -1076,7 +1076,7 @@ static void Cache_auth_entry(CacheEntry_t *entry, BrowserWindow *bw)
busy = 1;
data = dNew(CacheAuthData_t, 1);
data->auth = entry->Auth;
data->url = a_Url_dup(*entry->Url).release();
data->url = a_Url_dup(entry->Url).release();
data->bw = bw;
entry->Auth = NULL;
a_Timeout_add(0.0, Cache_auth_callback, data);
@ -1325,7 +1325,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
if (AbortEntry) {
/* Abort the entry, remove it from cache, and maybe offer download. */
DilloUrl *url = a_Url_dup(*entry->Url).release();
DilloUrl *url = a_Url_dup(entry->Url).release();
a_Capi_conn_abort_by_url(url);
entry = NULL;
if (OfferDownload) {
@ -1334,7 +1334,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
if (a_Cache_download_enabled(url)) {
Cache_savelink_t *data = dNew(Cache_savelink_t, 1);
data->bw = Client_bw;
data->url = a_Url_dup(*url).release();
data->url = a_Url_dup(url).release();
a_Timeout_add(0.0, Cache_savelink_cb, data);
}
}

View File

@ -97,7 +97,7 @@ static capi_conn_t *
capi_conn_t *conn;
conn = dNew(capi_conn_t, 1);
conn->url = url ? a_Url_dup(*url).release() : nullptr;
conn->url = url ? a_Url_dup(url).release() : nullptr;
conn->bw = bw;
conn->server = dStrdup(server);
conn->datastr = dStrdup(datastr);
@ -204,7 +204,7 @@ void a_Capi_conn_abort_by_url(const DilloUrl *url)
for (i = 0; i < dList_length(CapiConns); ++i) {
conn = reinterpret_cast< capi_conn_t * >( dList_nth_data (CapiConns, i) );
if (a_Url_cmp(*conn->url, *url) == 0) {
if (a_Url_cmp(conn->url, url) == 0) {
if (conn->InfoSend) {
a_Capi_ccc(OpAbort, 1, BCK, conn->InfoSend, NULL, NULL);
}
@ -224,7 +224,7 @@ void a_Capi_conn_abort_by_url(const DilloUrl *url)
void a_Capi_set_vsource_url(const DilloUrl *url)
{
delete CapiVsUrl;
CapiVsUrl = a_Url_dup(*url).release();
CapiVsUrl = a_Url_dup(url).release();
}
/**
@ -435,7 +435,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
/* allow "view source" reload upon user request */
} else {
/* make the other "dpi:/" prefixed urls always reload. */
a_Url_set_flags(*web->url, URL_FLAGS(web->url) |URL_E2EQuery);
a_Url_set_flags(web->url, URL_FLAGS(web->url) |URL_E2EQuery);
reload = 1;
}
}

View File

@ -1610,8 +1610,8 @@ char * CssParser::parseUrl()
}
if (urlStr) {
DilloUrl *dilloUrl = a_Url_new(urlStr->str, a_Url_str(*this->baseUrl)).release();
char *url = dStrdup(a_Url_str(*dilloUrl));
DilloUrl *dilloUrl = a_Url_new(urlStr->str, a_Url_str(this->baseUrl)).release();
char *url = dStrdup(a_Url_str(dilloUrl));
delete dilloUrl;
dStr_free(urlStr, 1);
return url;
@ -1666,7 +1666,7 @@ void CssParser::parseImport(DilloHtml *html)
if (urlStr) {
if (importSyntaxIsOK && mediaIsSelected) {
MSG("CssParser::parseImport(): @import %s\n", urlStr);
auto url = a_Html_url_new (html, urlStr, a_Url_str(*this->baseUrl),
auto url = a_Html_url_new (html, urlStr, a_Url_str(this->baseUrl),
this->baseUrl ? 1 : 0);
a_Html_load_stylesheet(html, url.get());
}

View File

@ -60,7 +60,7 @@ static int Dicache_entry_cmp(const void *v1, const void *v2)
{
const DICacheEntry *e1 = reinterpret_cast< const DICacheEntry * >( v1 ), *e2 = reinterpret_cast< const DICacheEntry * >( v2 );
int st = a_Url_cmp(*e1->url, *e2->url);
int st = a_Url_cmp(e1->url, e2->url);
if (st == 0) {
if (e2->version == DIC_Last)
st = (e1->Flags & DIF_Last ? 0 : -1);
@ -133,7 +133,7 @@ static DICacheEntry *Dicache_add_entry(const DilloUrl *Url)
last->Flags &= ~DIF_Last;
entry->version = last->version + 1;
}
entry->url = a_Url_dup(*Url).release();
entry->url = a_Url_dup(Url).release();
entry->Flags |= DIF_Last;
dList_insert_sorted(CachedIMGs, entry, Dicache_entry_cmp);

View File

@ -392,7 +392,7 @@ static DilloUrl *makeStartUrl(char *str, bool local)
}
if (local)
a_Url_set_flags(*start_url, URL_FLAGS(start_url) | URL_SpamSafe);
a_Url_set_flags(start_url, URL_FLAGS(start_url) | URL_SpamSafe);
return start_url;
}

View File

@ -377,7 +377,7 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize)
else {
if (html->DocType != DT_HTML || html->DocTypeVersion <= 4.01f)
BUG_MSG("<form> requires action attribute.");
action = a_Url_dup(*html->base_url).release();
action = a_Url_dup(html->base_url).release();
}
content_type = DILLO_HTML_ENC_URLENCODED;
if ((method == DILLO_HTML_METHOD_POST) &&
@ -609,7 +609,7 @@ void Html_tag_open_isindex(DilloHtml *html, const char *tag, int tagsize)
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "action")))
action = a_Html_url_new(html, attrbuf, NULL, 0).release();
else
action = a_Url_dup(*html->base_url).release();
action = a_Url_dup(html->base_url).release();
html->formNew(DILLO_HTML_METHOD_GET, action, DILLO_HTML_ENC_URLENCODED,
html->charset.has_value() ? html->charset.value().c_str() : nullptr);
@ -1005,7 +1005,7 @@ DilloHtmlForm::DilloHtmlForm (DilloHtml *html2,
{
html = html2;
method = method2;
action = a_Url_dup(*action2).release();
action = a_Url_dup(action2).release();
content_type = content_type2;
submit_charset = dStrdup(charset);
num_entry_fields = 0;
@ -1106,10 +1106,10 @@ DilloUrl *DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input)
if (method == DILLO_HTML_METHOD_POST) {
new_url = a_Url_new(action_str, NULL).release();
/* new_url keeps the dStr and sets DataStr to NULL */
a_Url_set_data(*new_url, DataStr);
a_Url_set_flags(*new_url, URL_FLAGS(new_url) | URL_Post);
a_Url_set_data(new_url, DataStr);
a_Url_set_flags(new_url, URL_FLAGS(new_url) | URL_Post);
if (content_type == DILLO_HTML_ENC_MULTIPART)
a_Url_set_flags(*new_url, URL_FLAGS(new_url) | URL_MultipartEnc);
a_Url_set_flags(new_url, URL_FLAGS(new_url) | URL_MultipartEnc);
} else {
/* remove <fragment> and <query> sections if present */
char *url_str, *p;
@ -1120,7 +1120,7 @@ DilloUrl *DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input)
url_str = dStrconcat(action_str, "?", DataStr.c_str(), NULL);
new_url = a_Url_new(url_str, NULL).release();
a_Url_set_flags(*new_url, URL_FLAGS(new_url) | URL_Get);
a_Url_set_flags(new_url, URL_FLAGS(new_url) | URL_Get);
dFree(url_str);
}
dFree(action_str);

View File

@ -53,7 +53,7 @@ int a_History_add_url(DilloUrl *url)
_MSG("a_History_add_url: '%s' ", URL_STR(url));
for (i = 0; i < history_size; ++i)
if (!a_Url_cmp(*history[i].url, *url) &&
if (!a_Url_cmp(history[i].url, url) &&
!strcmp(URL_FRAGMENT(history[i].url), URL_FRAGMENT(url)))
break;
@ -63,7 +63,7 @@ int a_History_add_url(DilloUrl *url)
} else {
idx = history_size;
a_List_add(history, history_size, history_size_max, H_Item);
history[idx].url = a_Url_dup(*url).release();
history[idx].url = a_Url_dup(url).release();
history[idx].title = NULL;
++history_size;
_MSG("ADDED at idx=%d\n", idx);
@ -114,7 +114,7 @@ const char *a_History_get_title_by_url(const DilloUrl *url, int force)
dReturn_val_if_fail(url != NULL, NULL);
for (i = 0; i < history_size; ++i)
if (a_Url_cmp(*url, *history[i].url) == 0)
if (a_Url_cmp(url, history[i].url) == 0)
break;
if (i < history_size && history[i].title)
@ -134,7 +134,7 @@ void a_History_set_title_by_url(const DilloUrl *url, const char *title)
dReturn_if (url == NULL);
for (i = history_size - 1; i >= 0; --i)
if (a_Url_cmp(*url, *history[i].url) == 0)
if (a_Url_cmp(url, history[i].url) == 0)
break;
if (i >= 0) {

View File

@ -435,8 +435,8 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
{
/* Init main variables */
bw = p_bw;
page_url = a_Url_dup(*url).release();
base_url = a_Url_dup(*url).release();
page_url = a_Url_dup(url).release();
base_url = a_Url_dup(url).release();
dw = NULL;
/* Init event receiver */
@ -716,7 +716,7 @@ void DilloHtml::loadImages (const DilloUrl *pattern)
if (hi->image) {
assert(hi->url);
if ((!pattern) || (!a_Url_cmp(*hi->url, *pattern))) {
if ((!pattern) || (!a_Url_cmp(hi->url, pattern))) {
if (Html_load_image(bw, hi->url, requester, hi->image)) {
a_Image_unref (hi->image);
hi->image = NULL; // web owns it now
@ -733,7 +733,7 @@ void DilloHtml::addCssUrl(const DilloUrl *url)
{
int nu = cssUrls->size();
cssUrls->increase();
cssUrls->set(nu, a_Url_dup(*url).release());
cssUrls->set(nu, a_Url_dup(url).release());
}
bool DilloHtml::HtmlLinkReceiver::enter (Widget *widget, int link, int img,
@ -2299,7 +2299,7 @@ static void Html_tag_content_img(DilloHtml *html, const char *tag, int tagsize)
}
if (usemap_url) {
dwi->setUseMap(&html->maps, new ::object::String(URL_STR(usemap_url)));
dwi->setUseMap(&html->maps, new ::object::String(URL_STR(usemap_url.get())));
}
}
@ -2318,7 +2318,7 @@ static void Html_tag_content_map(DilloHtml *html, const char *tag, int tagsize)
html->InFlags |= IN_MAP;
hash_name = dStrconcat("#", attrbuf, NULL);
auto url = a_Html_url_new(html, hash_name, NULL, 0);
html->maps.startNewMap(new ::object::String(URL_STR(url)));
html->maps.startNewMap(new ::object::String(URL_STR(url.get())));
dFree(hash_name);
} else {
BUG_MSG("<map> requires name attribute.");
@ -2475,7 +2475,7 @@ static void Html_tag_open_object(DilloHtml *html, const char *tag, int tagsize)
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "data"))) {
url = a_Html_url_new(html, attrbuf,
URL_STR(base_url), (base_url != NULL)).release();
URL_STR(base_url.get()), (base_url != nullptr)).release();
dReturn_if_fail ( url != NULL );
if (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached) {
@ -3171,7 +3171,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
auto new_url = a_Html_url_new(html, mr_url, NULL, 0);
if (a_Url_cmp(*html->base_url, *new_url) == 0) {
if (a_Url_cmp(html->base_url, new_url.get()) == 0) {
/* redirection loop, or empty url string: ignore */
BUG_MSG("<meta> refresh: %s.",
*mr_url ? "redirection loop" : "no target URL");
@ -3189,7 +3189,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
* TODO: This is a hairy hack,
* It'd be much better to build a widget. */
Dstr *ds_msg = dStr_sized_new(256);
dStr_sprintf(ds_msg, meta_template, URL_STR(new_url), delay_str);
dStr_sprintf(ds_msg, meta_template, URL_STR(new_url.get()), delay_str);
{
int o_InFlags = html->InFlags;
int o_TagSoup = html->TagSoup;
@ -3351,7 +3351,7 @@ static void Html_tag_open_base(DilloHtml *html, const char *tag, int tagsize)
if (html5 || URL_SCHEME_(BaseUrl)) {
/* Pass the URL_SpamSafe flag to the new base url */
a_Url_set_flags(
*BaseUrl, URL_FLAGS(html->base_url) & URL_SpamSafe);
BaseUrl, URL_FLAGS(html->base_url) & URL_SpamSafe);
delete html->base_url;
html->base_url = BaseUrl;
} else {

View File

@ -376,7 +376,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
popup_y = Fl::event_y();
popup_bw = bw;
delete popup_url;
popup_url = a_Url_dup(*url).release();
popup_url = a_Url_dup(url).release();
has_bugs == TRUE ? pm[1].activate() : pm[1].deactivate();
@ -420,7 +420,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
}
stylesheets[j].label(FL_NORMAL_LABEL, label);
stylesheets[j].callback(Menu_stylesheet_cb, a_Url_dup(*url).release());
stylesheets[j].callback(Menu_stylesheet_cb, a_Url_dup(url).release());
}
pm[2].user_data(stylesheets);
@ -555,7 +555,7 @@ void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *p
popup_y = Fl::event_y();
popup_bw = bw;
delete popup_url;
popup_url = a_Url_dup(*url).release();
popup_url = a_Url_dup(url).release();
Fl_Menu_Item *link_menu = get_link_menu();
link_data.menu = link_menu;
@ -592,11 +592,11 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
popup_y = Fl::event_y();
popup_bw = bw;
delete popup_url;
popup_url = a_Url_dup(*url).release();
popup_url = a_Url_dup(url).release();
delete popup_page_url;
popup_page_url = a_Url_dup(*page_url).release();
popup_page_url = a_Url_dup(page_url).release();
delete popup_link_url;
popup_link_url = a_Url_dup(*link_url).release();
popup_link_url = a_Url_dup(link_url).release();
pm[0].user_data(popup_url);
@ -643,7 +643,7 @@ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
popup_y = Fl::event_y();
popup_bw = bw;
delete popup_url;
popup_url = a_Url_dup(*page_url).release();
popup_url = a_Url_dup(page_url).release();
popup_form = formptr;
hiddens_visible = hidvis;
@ -704,7 +704,7 @@ void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url)
popup_y = Fl::event_y();
popup_bw = bw;
delete popup_url;
popup_url = a_Url_dup(*url).release();
popup_url = a_Url_dup(url).release();
a_Timeout_add(0.0, Menu_simple_popup_cb, (void*)pm);
}

View File

@ -221,7 +221,7 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url,
/* Page must be reloaded, if old and new url (considering anchor) differ */
MustLoad = ForceReload || !old_url;
if (old_url){
MustLoad |= (a_Url_cmp(*old_url, *url) ||
MustLoad |= (a_Url_cmp(old_url, url) ||
strcmp(URL_FRAGMENT(old_url), URL_FRAGMENT(url)));
}
@ -259,7 +259,7 @@ void a_Nav_cancel_expect(BrowserWindow *bw)
*/
void a_Nav_cancel_expect_if_eq(BrowserWindow *bw, const DilloUrl *url)
{
if (a_Url_cmp(*url, *a_Bw_expected_url(bw)) == 0)
if (a_Url_cmp(url, a_Bw_expected_url(bw)) == 0)
a_Nav_cancel_expect(bw);
}
@ -278,7 +278,7 @@ void a_Nav_expect_done(BrowserWindow *bw)
if (a_Bw_expecting(bw)) {
{
auto url = a_Url_dup(*a_Bw_expected_url(bw));
auto url = a_Url_dup(a_Bw_expected_url(bw));
reload = (URL_FLAGS(url) & URL_ReloadPage);
repush = (URL_FLAGS(url) & URL_ReloadFromCache);
e2equery = (URL_FLAGS(url) & URL_E2EQuery);
@ -287,7 +287,7 @@ void a_Nav_expect_done(BrowserWindow *bw)
/* Unset E2EQuery, ReloadPage, ReloadFromCache and IgnoreScroll
* before adding this url to history */
m = URL_E2EQuery|URL_ReloadPage|URL_ReloadFromCache|URL_IgnoreScroll;
a_Url_set_flags(*url, URL_FLAGS(url) & ~m);
a_Url_set_flags(url.get(), URL_FLAGS(url) & ~m);
url_idx = a_History_add_url(url.get());
}
@ -346,7 +346,7 @@ void a_Nav_push(BrowserWindow *bw, const DilloUrl *url,
dReturn_if_fail (bw != NULL);
e_url = a_Bw_expected_url(bw);
if (e_url && !a_Url_cmp(*e_url, *url) &&
if (e_url && !a_Url_cmp(e_url, url) &&
!strcmp(URL_FRAGMENT(e_url),URL_FRAGMENT(url))) {
/* we're already expecting that url (most probably a double-click) */
return;
@ -364,9 +364,9 @@ static void Nav_repush(BrowserWindow *bw)
{
a_Nav_cancel_expect(bw);
if (a_Nav_stack_size(bw)) {
auto url = a_Url_dup(*a_History_get_url(NAV_TOP_UIDX(bw)));
auto url = a_Url_dup(a_History_get_url(NAV_TOP_UIDX(bw)));
/* Let's make reload be from Cache */
a_Url_set_flags(*url, URL_FLAGS(url) | URL_ReloadFromCache);
a_Url_set_flags(url.get(), URL_FLAGS(url) | URL_ReloadFromCache);
a_Bw_expect(bw, url.get());
Nav_open_url(bw, url.get(), NULL, 0);
}
@ -422,8 +422,8 @@ void a_Nav_redirection0(BrowserWindow *bw, const DilloUrl *new_url)
_MSG(">>>> a_Nav_redirection0 <<<<\n");
delete bw->meta_refresh_url;
bw->meta_refresh_url = a_Url_dup(*new_url).release();
a_Url_set_flags(*bw->meta_refresh_url,
bw->meta_refresh_url = a_Url_dup(new_url).release();
a_Url_set_flags(bw->meta_refresh_url,
URL_FLAGS(new_url)|URL_E2EQuery|URL_IgnoreScroll);
bw->meta_refresh_status = 2;
a_Timeout_add(0.0, Nav_redirection0_callback, (void*)bw);
@ -490,13 +490,13 @@ static void Nav_reload_callback(void *data)
}
if (confirmed) {
auto r_url = a_Url_dup(*h_url);
auto r_url = a_Url_dup(h_url);
/* Mark URL as reload to differentiate from push */
a_Url_set_flags(*r_url, URL_FLAGS(r_url) | URL_ReloadPage);
a_Url_set_flags(r_url.get(), URL_FLAGS(r_url) | URL_ReloadPage);
/* Let's make reload be end-to-end */
a_Url_set_flags(*r_url, URL_FLAGS(r_url) | URL_E2EQuery);
a_Url_set_flags(r_url.get(), URL_FLAGS(r_url) | URL_E2EQuery);
/* This is an explicit reload, so clear the SpamSafe flag */
a_Url_set_flags(*r_url, URL_FLAGS(r_url) & ~URL_SpamSafe);
a_Url_set_flags(r_url.get(), URL_FLAGS(r_url) & ~URL_SpamSafe);
a_Bw_expect(bw, r_url.get());
Nav_open_url(bw, r_url.get(), NULL, 0);
}

View File

@ -72,8 +72,8 @@ StyleEngine::StyleEngine (dw::core::Layout *layout,
cssContext = new CssContext ();
buildUserStyle ();
this->layout = layout;
this->pageUrl = pageUrl ? a_Url_dup(*pageUrl).release() : nullptr;
this->baseUrl = baseUrl ? a_Url_dup(*baseUrl).release() : nullptr;
this->pageUrl = pageUrl ? a_Url_dup(pageUrl).release() : nullptr;
this->baseUrl = baseUrl ? a_Url_dup(baseUrl).release() : nullptr;
importDepth = 0;
dpmm = layout->dpiX () / 25.4; /* assume dpiX == dpiY */
this->zoom = zoom;

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;
}
/**

View File

@ -58,8 +58,8 @@ extern "C++"
#define URL_PATH_(u) (u)->path
#define URL_QUERY_(u) (u)->query
#define URL_FRAGMENT_(u) (u)->fragment
#define URL_HOST_(u) a_Url_hostname(*(u))
#define URL_STR_(u) a_Url_str(*(u))
#define URL_HOST_(u) a_Url_hostname((u))
#define URL_STR_(u) a_Url_str((u))
/* this returns a Dstr* */
#define URL_DATA_(u) (u)->data
/* these return an integer */
@ -117,13 +117,12 @@ struct DilloUrl {
std::unique_ptr< DilloUrl > a_Url_new(const char *url_str, const char *base_url);
char *a_Url_str(const DilloUrl &url);
const char *a_Url_hostname(const DilloUrl &u);
std::unique_ptr< DilloUrl > a_Url_dup(const DilloUrl &u);
int a_Url_cmp(const DilloUrl &A, const DilloUrl &B);
inline int a_Url_cmp_c( const DilloUrl *const A, const DilloUrl *const B ) { return a_Url_cmp( *A, *B ); }
void a_Url_set_flags(DilloUrl &u, int flags);
void a_Url_set_data(DilloUrl &u, std::string_view data);
char *a_Url_str(const DilloUrl *url);
const char *a_Url_hostname(const DilloUrl *u);
std::unique_ptr< DilloUrl > a_Url_dup(const DilloUrl *u);
int a_Url_cmp(const DilloUrl *A, const DilloUrl *B);
void a_Url_set_flags(DilloUrl *u, int flags);
void a_Url_set_data(DilloUrl *u, std::string_view data);
void a_Url_set_ismap_coords(DilloUrl *u, char *coord_str);
char *a_Url_decode_hex_str(const char *str);
char *a_Url_encode_hex_str(const char *str);

View File

@ -124,8 +124,8 @@ DilloWeb* a_Web_new(BrowserWindow *bw, const DilloUrl *url,
DilloWeb *web= dNew(DilloWeb, 1);
_MSG(" a_Web_new: ValidWebs ==> %d\n", dList_length(ValidWebs));
web->url = a_Url_dup(*url).release();
web->requester = a_Url_dup(*requester).release();
web->url = a_Url_dup(url).release();
web->requester = a_Url_dup(requester).release();
web->bw = bw;
web->flags = 0;
web->Image = NULL;