URI header now returns pointers with ownership.
I've put `.release()` at most of the callsites, but this gives me something to search for when taking the next steps.
This commit is contained in:
@ -124,9 +124,9 @@ int a_Http_init(void)
|
||||
dStrdup("");
|
||||
|
||||
if (env_proxy && strlen(env_proxy))
|
||||
HTTP_Proxy = a_Url_new(env_proxy, NULL);
|
||||
HTTP_Proxy = a_Url_new(env_proxy, NULL).release();
|
||||
if (!HTTP_Proxy && prefs.http_proxy)
|
||||
HTTP_Proxy = a_Url_dup(prefs.http_proxy);
|
||||
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);
|
||||
S->url = a_Url_dup(*S->web->url).release();
|
||||
if (!dStrAsciiCasecmp(URL_SCHEME(S->url), "https"))
|
||||
S->flags |= HTTP_SOCKET_TLS;
|
||||
|
||||
|
||||
@ -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);
|
||||
conn->url = a_Url_dup(*url).release();
|
||||
conn->ssl = ssl;
|
||||
conn->connecting = TRUE;
|
||||
conn->in_connect = FALSE;
|
||||
|
||||
@ -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);
|
||||
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 );
|
||||
|
||||
12
src/bw.cc
12
src/bw.cc
@ -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)) {
|
||||
dList_append(bw->PageUrls, a_Url_dup(Url));
|
||||
if (!dList_find_custom(bw->PageUrls, Url, (dCompareFunc)a_Url_cmp_c)) {
|
||||
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)) {
|
||||
if (url && dList_find_custom(bw->PageUrls, url, (dCompareFunc)a_Url_cmp_c)) {
|
||||
doc = a_Bw_get_current_doc(bw);
|
||||
}
|
||||
return doc;
|
||||
@ -322,18 +322,18 @@ 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);
|
||||
bw->nav_expect_url = a_Url_dup(*url).release();
|
||||
}
|
||||
|
||||
void a_Bw_cancel_expect(BrowserWindow *bw)
|
||||
{
|
||||
delete bw->nav_expect_url;
|
||||
bw->nav_expect_url = NULL;
|
||||
bw->nav_expect_url = nullptr;
|
||||
}
|
||||
|
||||
bool_t a_Bw_expecting(BrowserWindow *bw)
|
||||
{
|
||||
return (bw->nav_expect_url != NULL);
|
||||
return (bw->nav_expect_url != nullptr);
|
||||
}
|
||||
|
||||
const DilloUrl *a_Bw_expected_url(BrowserWindow *bw)
|
||||
|
||||
30
src/cache.cc
30
src/cache.cc
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,11 +123,10 @@ void a_Cache_init(void)
|
||||
|
||||
/* inject the splash screen in the cache */
|
||||
{
|
||||
DilloUrl *url = a_Url_new("about:splash", NULL);
|
||||
auto url = a_Url_new("about:splash", NULL);
|
||||
Dstr *ds = dStr_new(AboutSplash);
|
||||
Cache_entry_inject(url, ds);
|
||||
Cache_entry_inject(url.get(), ds);
|
||||
dStr_free(ds, 1);
|
||||
delete url;
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,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);
|
||||
NewEntry->Url = a_Url_dup(*Url).release();
|
||||
NewEntry->TypeDet = NULL;
|
||||
NewEntry->TypeHdr = NULL;
|
||||
NewEntry->TypeMeta = NULL;
|
||||
@ -684,7 +683,7 @@ static void Cache_parse_header(CacheEntry_t *entry)
|
||||
if (header[9] == '3' && header[10] == '0' &&
|
||||
(location_str = Cache_parse_field(header, "Location"))) {
|
||||
/* 30x: URL redirection */
|
||||
entry->Location = a_Url_new(location_str, URL_STR_(entry->Url));
|
||||
entry->Location = a_Url_new(location_str, URL_STR_(entry->Url)).release();
|
||||
|
||||
if (!a_Domain_permit(entry->Url, entry->Location) ||
|
||||
(URL_FLAGS(entry->Location) & (URL_Post + URL_Get) &&
|
||||
@ -772,7 +771,7 @@ static void Cache_parse_header(CacheEntry_t *entry)
|
||||
DilloWeb *web = reinterpret_cast< DilloWeb * >( client->Web );
|
||||
|
||||
if (!web->requester ||
|
||||
a_Url_same_organization(entry->Url, web->requester)) {
|
||||
a_Url_same_organization(*entry->Url, *web->requester)) {
|
||||
/* If cookies are third party, don't even consider them. */
|
||||
char *server_date = Cache_parse_field(header, "Date");
|
||||
|
||||
@ -996,8 +995,6 @@ bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size,
|
||||
*/
|
||||
static int Cache_redirect(CacheEntry_t *entry, int Flags, BrowserWindow *bw)
|
||||
{
|
||||
DilloUrl *NewUrl;
|
||||
|
||||
_MSG(" Cache_redirect: redirect_level = %d\n", bw->redirect_level);
|
||||
|
||||
/* Don't allow redirection for SpamSafe/local URLs */
|
||||
@ -1026,11 +1023,10 @@ static int Cache_redirect(CacheEntry_t *entry, int Flags, BrowserWindow *bw)
|
||||
|
||||
if (Flags & WEB_RootUrl) {
|
||||
/* Redirection of the main page */
|
||||
NewUrl = a_Url_new(URL_STR_(entry->Location), URL_STR_(entry->Url));
|
||||
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_Nav_push(bw, NewUrl, entry->Url);
|
||||
delete NewUrl;
|
||||
a_Url_set_flags(*NewUrl, URL_FLAGS(NewUrl) | URL_E2EQuery);
|
||||
a_Nav_push(bw, NewUrl.get(), entry->Url);
|
||||
} else {
|
||||
/* Sub entity redirection (most probably an image) */
|
||||
if (!entry->Data->len) {
|
||||
@ -1080,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);
|
||||
data->url = a_Url_dup(*entry->Url).release();
|
||||
data->bw = bw;
|
||||
entry->Auth = NULL;
|
||||
a_Timeout_add(0.0, Cache_auth_callback, data);
|
||||
@ -1329,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);
|
||||
DilloUrl *url = a_Url_dup(*entry->Url).release();
|
||||
a_Capi_conn_abort_by_url(url);
|
||||
entry = NULL;
|
||||
if (OfferDownload) {
|
||||
@ -1338,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);
|
||||
data->url = a_Url_dup(*url).release();
|
||||
a_Timeout_add(0.0, Cache_savelink_cb, data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) : NULL;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ char *a_Cookies_get_query(const DilloUrl *query_url, const DilloUrl *requester)
|
||||
|
||||
if (requester == NULL) {
|
||||
/* request made by user */
|
||||
} else if (!a_Url_same_organization(query_url, requester)) {
|
||||
} else if (!a_Url_same_organization(*query_url, *requester)) {
|
||||
MSG("Cookies: not sent for request by '%s' for '%s'\n",
|
||||
URL_HOST(requester), URL_HOST(query_url));
|
||||
return dStrdup("");
|
||||
|
||||
@ -1610,8 +1610,8 @@ char * CssParser::parseUrl()
|
||||
}
|
||||
|
||||
if (urlStr) {
|
||||
DilloUrl *dilloUrl = a_Url_new(urlStr->str, a_Url_str(this->baseUrl));
|
||||
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);
|
||||
DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(this->baseUrl),
|
||||
DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(*this->baseUrl),
|
||||
this->baseUrl ? 1 : 0);
|
||||
a_Html_load_stylesheet(html, url);
|
||||
delete url;
|
||||
|
||||
@ -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);
|
||||
entry->url = a_Url_dup(*Url).release();
|
||||
entry->Flags |= DIF_Last;
|
||||
dList_insert_sorted(CachedIMGs, entry, Dicache_entry_cmp);
|
||||
|
||||
|
||||
@ -133,7 +133,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (a_Url_same_organization(source, dest))
|
||||
if (a_Url_same_organization(*source, *dest))
|
||||
return TRUE;
|
||||
|
||||
ret = default_deny ? FALSE : TRUE;
|
||||
|
||||
@ -382,17 +382,17 @@ static DilloUrl *makeStartUrl(char *str, bool local)
|
||||
if (access(p.c_str(), F_OK) == 0) {
|
||||
/* absolute path may have non-URL characters */
|
||||
url_str = a_Misc_escape_chars(p.c_str(), "% #");
|
||||
start_url = a_Url_new(url_str.c_str() + 1, "file:/");
|
||||
start_url = a_Url_new(url_str.c_str() + 1, "file:/").release();
|
||||
} else {
|
||||
/* Not a file, filter URL string */
|
||||
char *const tmp= a_Url_string_strip_delimiters(str);
|
||||
url_str = tmp;
|
||||
dFree( tmp );
|
||||
start_url = a_Url_new(url_str.c_str(), NULL);
|
||||
start_url = a_Url_new(url_str.c_str(), NULL).release();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
18
src/form.cc
18
src/form.cc
@ -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);
|
||||
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);
|
||||
else
|
||||
action = a_Url_dup(html->base_url);
|
||||
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);
|
||||
action = a_Url_dup(*action2).release();
|
||||
content_type = content_type2;
|
||||
submit_charset = dStrdup(charset);
|
||||
num_entry_fields = 0;
|
||||
@ -1104,12 +1104,12 @@ DilloUrl *DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input)
|
||||
char *action_str = dStrdup(URL_STR(action));
|
||||
|
||||
if (method == DILLO_HTML_METHOD_POST) {
|
||||
new_url = a_Url_new(action_str, NULL);
|
||||
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;
|
||||
@ -1119,8 +1119,8 @@ DilloUrl *DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input)
|
||||
*p = 0;
|
||||
|
||||
url_str = dStrconcat(action_str, "?", DataStr.c_str(), NULL);
|
||||
new_url = a_Url_new(url_str, NULL);
|
||||
a_Url_set_flags(new_url, URL_FLAGS(new_url) | URL_Get);
|
||||
new_url = a_Url_new(url_str, NULL).release();
|
||||
a_Url_set_flags(*new_url, URL_FLAGS(new_url) | URL_Get);
|
||||
dFree(url_str);
|
||||
}
|
||||
dFree(action_str);
|
||||
|
||||
@ -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);
|
||||
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) {
|
||||
|
||||
14
src/html.cc
14
src/html.cc
@ -181,7 +181,7 @@ DilloUrl *a_Html_url_new(DilloHtml *html,
|
||||
}
|
||||
|
||||
DilloUrl *url = a_Url_new(url_str,
|
||||
(use_base_url) ? base_url : URL_STR_(html->base_url));
|
||||
(use_base_url) ? base_url : URL_STR_(html->base_url)).release();
|
||||
|
||||
if (!url) {
|
||||
BUG_MSG("URL is not valid '%s'.", url_str);
|
||||
@ -435,8 +435,8 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
|
||||
{
|
||||
/* Init main variables */
|
||||
bw = p_bw;
|
||||
page_url = a_Url_dup(url);
|
||||
base_url = a_Url_dup(url);
|
||||
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));
|
||||
cssUrls->set(nu, a_Url_dup(*url).release());
|
||||
}
|
||||
|
||||
bool DilloHtml::HtmlLinkReceiver::enter (Widget *widget, int link, int img,
|
||||
@ -3176,7 +3176,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
|
||||
|
||||
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) == 0) {
|
||||
/* redirection loop, or empty url string: ignore */
|
||||
BUG_MSG("<meta> refresh: %s.",
|
||||
*mr_url ? "redirection loop" : "no target URL");
|
||||
@ -3358,7 +3358,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 {
|
||||
|
||||
16
src/menu.cc
16
src/menu.cc
@ -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);
|
||||
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));
|
||||
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);
|
||||
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);
|
||||
popup_url = a_Url_dup(*url).release();
|
||||
delete popup_page_url;
|
||||
popup_page_url = a_Url_dup(page_url);
|
||||
popup_page_url = a_Url_dup(*page_url).release();
|
||||
delete popup_link_url;
|
||||
popup_link_url = a_Url_dup(link_url);
|
||||
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);
|
||||
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);
|
||||
popup_url = a_Url_dup(*url).release();
|
||||
|
||||
a_Timeout_add(0.0, Menu_simple_popup_cb, (void*)pm);
|
||||
}
|
||||
|
||||
45
src/nav.cc
45
src/nav.cc
@ -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);
|
||||
}
|
||||
|
||||
@ -272,13 +272,13 @@ void a_Nav_cancel_expect_if_eq(BrowserWindow *bw, const DilloUrl *url)
|
||||
void a_Nav_expect_done(BrowserWindow *bw)
|
||||
{
|
||||
int m, url_idx, posx, posy, reload, repush, e2equery, goto_old_scroll=TRUE;
|
||||
DilloUrl *url;
|
||||
char *fragment = NULL;
|
||||
|
||||
dReturn_if_fail(bw != NULL);
|
||||
|
||||
if (a_Bw_expecting(bw)) {
|
||||
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,9 +287,9 @@ 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);
|
||||
url_idx = a_History_add_url(url);
|
||||
delete url;
|
||||
a_Url_set_flags(*url, URL_FLAGS(url) & ~m);
|
||||
url_idx = a_History_add_url(url.get());
|
||||
}
|
||||
|
||||
if (repush) {
|
||||
MSG("a_Nav_expect_done: repush!\n");
|
||||
@ -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;
|
||||
@ -362,16 +362,13 @@ void a_Nav_push(BrowserWindow *bw, const DilloUrl *url,
|
||||
*/
|
||||
static void Nav_repush(BrowserWindow *bw)
|
||||
{
|
||||
DilloUrl *url;
|
||||
|
||||
a_Nav_cancel_expect(bw);
|
||||
if (a_Nav_stack_size(bw)) {
|
||||
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_Bw_expect(bw, url);
|
||||
Nav_open_url(bw, url, NULL, 0);
|
||||
delete url;
|
||||
a_Url_set_flags(*url, URL_FLAGS(url) | URL_ReloadFromCache);
|
||||
a_Bw_expect(bw, url.get());
|
||||
Nav_open_url(bw, url.get(), NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,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);
|
||||
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);
|
||||
@ -475,7 +472,6 @@ static void Nav_reload_callback(void *data)
|
||||
{
|
||||
BrowserWindow *bw = reinterpret_cast< BrowserWindow * >( data );
|
||||
const DilloUrl *h_url;
|
||||
DilloUrl *r_url;
|
||||
int choice, confirmed = 1;
|
||||
|
||||
a_Nav_cancel_expect(bw);
|
||||
@ -494,16 +490,15 @@ static void Nav_reload_callback(void *data)
|
||||
}
|
||||
|
||||
if (confirmed) {
|
||||
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, 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, 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_Bw_expect(bw, r_url);
|
||||
Nav_open_url(bw, r_url, NULL, 0);
|
||||
delete r_url;
|
||||
a_Url_set_flags(*r_url, URL_FLAGS(r_url) & ~URL_SpamSafe);
|
||||
a_Bw_expect(bw, r_url.get());
|
||||
Nav_open_url(bw, r_url.get(), NULL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ void a_Prefs_init(void)
|
||||
prefs.xpos = PREFS_GEOMETRY_DEFAULT_XPOS;
|
||||
prefs.ypos = PREFS_GEOMETRY_DEFAULT_YPOS;
|
||||
|
||||
prefs.home = a_Url_new(PREFS_HOME, NULL);
|
||||
prefs.home = a_Url_new(PREFS_HOME, NULL).release();
|
||||
prefs.http_language = NULL;
|
||||
prefs.http_proxy = NULL;
|
||||
prefs.http_max_conns = 6;
|
||||
@ -116,8 +116,8 @@ void a_Prefs_init(void)
|
||||
prefs.show_tooltip = TRUE;
|
||||
prefs.show_ui_tooltip = TRUE;
|
||||
prefs.small_icons = FALSE;
|
||||
prefs.start_page = a_Url_new(PREFS_START_PAGE, NULL);
|
||||
prefs.new_tab_page = a_Url_new(PREFS_NEW_TAB_PAGE, NULL);
|
||||
prefs.start_page = a_Url_new(PREFS_START_PAGE, NULL).release();
|
||||
prefs.new_tab_page = a_Url_new(PREFS_NEW_TAB_PAGE, NULL).release();
|
||||
prefs.theme = dStrdup(PREFS_THEME);
|
||||
prefs.ui_button_highlight_color = -1;
|
||||
prefs.ui_fg_color = -1;
|
||||
|
||||
@ -101,7 +101,7 @@ static int parseOption(char *name, char *value,
|
||||
}
|
||||
case PREFS_URL:
|
||||
delete *(DilloUrl **)node->pref;
|
||||
*(DilloUrl **)node->pref = a_Url_new(value, NULL);
|
||||
*(DilloUrl **)node->pref = a_Url_new(value, NULL).release();
|
||||
break;
|
||||
case PREFS_INT32:
|
||||
*(int32_t *)node->pref = strtol(value, NULL, 10);
|
||||
|
||||
@ -72,8 +72,8 @@ StyleEngine::StyleEngine (dw::core::Layout *layout,
|
||||
cssContext = new CssContext ();
|
||||
buildUserStyle ();
|
||||
this->layout = layout;
|
||||
this->pageUrl = pageUrl ? a_Url_dup(pageUrl) : NULL;
|
||||
this->baseUrl = baseUrl ? a_Url_dup(baseUrl) : NULL;
|
||||
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;
|
||||
@ -531,7 +531,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
|
||||
break;
|
||||
case CSS_PROPERTY_BACKGROUND_IMAGE:
|
||||
// p->value.strVal should be absolute, so baseUrl is not needed
|
||||
imgUrl = a_Url_new (p->value.strVal, NULL);
|
||||
imgUrl = a_Url_new (p->value.strVal, NULL).release();
|
||||
break;
|
||||
case CSS_PROPERTY_BACKGROUND_POSITION:
|
||||
computeLength (&attrs->backgroundPositionX, p->value.posVal->posX,
|
||||
|
||||
24
src/uicmd.cc
24
src/uicmd.cc
@ -776,14 +776,14 @@ void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
|
||||
/* file URI */
|
||||
ch = new_urlstr[5];
|
||||
if (!ch || ch == '.') {
|
||||
url = a_Url_new(Paths::getOldWorkingDir(), "file:");
|
||||
url = a_Url_new(Paths::getOldWorkingDir(), "file:").release();
|
||||
} else {
|
||||
url = a_Url_new(new_urlstr, "file:");
|
||||
url = a_Url_new(new_urlstr, "file:").release();
|
||||
}
|
||||
|
||||
} else {
|
||||
/* common case */
|
||||
url = a_Url_new(new_urlstr, NULL);
|
||||
url = a_Url_new(new_urlstr, NULL).release();
|
||||
}
|
||||
dFree(new_urlstr);
|
||||
|
||||
@ -1152,14 +1152,11 @@ void a_UIcmd_tools(void *vbw, int x, int y)
|
||||
*/
|
||||
void a_UIcmd_open_file(void *vbw)
|
||||
{
|
||||
DilloUrl *url;
|
||||
|
||||
auto name = a_Dialog_open_file("Flenser: Open File", std::nullopt, "");
|
||||
|
||||
if (name.has_value()) {
|
||||
url = a_Url_new(name.value().c_str(), "file:");
|
||||
a_UIcmd_open_url((BrowserWindow*)vbw, url);
|
||||
delete url;
|
||||
auto url = a_Url_new(name.value().c_str(), "file:");
|
||||
a_UIcmd_open_url((BrowserWindow*)vbw, url.get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1240,9 +1237,8 @@ void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url)
|
||||
*/
|
||||
void a_UIcmd_book(void *vbw)
|
||||
{
|
||||
DilloUrl *url = a_Url_new("dpi:/bm/", NULL);
|
||||
a_UIcmd_open_url((BrowserWindow*)vbw, url);
|
||||
delete url;
|
||||
auto url = a_Url_new("dpi:/bm/", NULL);
|
||||
a_UIcmd_open_url((BrowserWindow*)vbw, url.get());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1315,7 +1311,6 @@ void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
|
||||
char *buf, *major;
|
||||
int buf_size;
|
||||
Dstr *dstr_url;
|
||||
DilloUrl *vs_url;
|
||||
static int post_id = 0;
|
||||
char tag[16];
|
||||
const char *content_type = a_Nav_get_content_type(url);
|
||||
@ -1333,9 +1328,8 @@ void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
|
||||
snprintf(tag, 16, "_%.4d", post_id);
|
||||
dStr_append(dstr_url, tag);
|
||||
}
|
||||
vs_url = a_Url_new(dstr_url->str, NULL);
|
||||
a_UIcmd_open_url_nt(bw, vs_url, 1);
|
||||
delete vs_url;
|
||||
auto vs_url = a_Url_new(dstr_url->str, NULL);
|
||||
a_UIcmd_open_url_nt(bw, vs_url.get(), 1);
|
||||
dStr_free(dstr_url, 1);
|
||||
a_Nav_unref_buf(url);
|
||||
}
|
||||
|
||||
59
src/url.cc
59
src/url.cc
@ -66,10 +66,11 @@ 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 = (DilloUrl *) u;
|
||||
DilloUrl *url = &u_nc;
|
||||
|
||||
dReturn_val_if_fail (url != NULL, NULL);
|
||||
|
||||
@ -95,11 +96,12 @@ 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 = (DilloUrl *) u;
|
||||
DilloUrl *url = &u_nc;
|
||||
|
||||
if (!url->hostname && url->authority) {
|
||||
if (url->authority[0] == '[' && (p = strchr(url->authority, ']'))) {
|
||||
@ -358,7 +360,7 @@ static std::string Url_resolve_relative(const char *RelStr,
|
||||
*
|
||||
* Return NULL if URL is badly formed.
|
||||
*/
|
||||
DilloUrl* a_Url_new(const char *url_str, const char *base_url)
|
||||
std::unique_ptr< DilloUrl > a_Url_new(const char *url_str, const char *base_url)
|
||||
{
|
||||
std::unique_ptr< DilloUrl > url;
|
||||
char *urlstr = (char *)url_str; /* auxiliary variable, don't free */
|
||||
@ -367,12 +369,12 @@ DilloUrl* a_Url_new(const char *url_str, const char *base_url)
|
||||
int i, n_ic, n_ic_spc;
|
||||
|
||||
if (!url_str)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/* Empty URL without base_url is not valid.
|
||||
* They are used for action="" in forms with base_url set. */
|
||||
if (url_str[0] == '\0' && base_url == NULL)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/* Count illegal characters (0x00-0x1F, 0x7F-0xFF and space) */
|
||||
n_ic = n_ic_spc = 0;
|
||||
@ -429,7 +431,7 @@ 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.get()))) {
|
||||
a_Hsts_require_https(a_Url_hostname(*url))) {
|
||||
_MSG("url: HSTS transformation for %s.\n", url->url_string->str);
|
||||
switch_to_https = TRUE;
|
||||
} else if (prefs.http_force_https) {
|
||||
@ -456,26 +458,26 @@ DilloUrl* a_Url_new(const char *url_str, const char *base_url)
|
||||
url->url_string.reset();
|
||||
}
|
||||
|
||||
return url.release();
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Duplicate a Url structure
|
||||
*/
|
||||
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;
|
||||
return url.release();
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -489,8 +491,11 @@ 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);
|
||||
@ -510,18 +515,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)
|
||||
{
|
||||
if (u)
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -777,8 +781,11 @@ static const char *Url_host_find_public_suffix(const char *host)
|
||||
return s;
|
||||
}
|
||||
|
||||
bool_t a_Url_same_organization(const DilloUrl *u1, const DilloUrl *u2)
|
||||
bool_t a_Url_same_organization(const DilloUrl &u1_, const DilloUrl &u2_)
|
||||
{
|
||||
const DilloUrl *const u1= &u1_;
|
||||
const DilloUrl *const u2= &u2_;
|
||||
|
||||
if (!u1 || !u2)
|
||||
return FALSE;
|
||||
|
||||
|
||||
25
src/url.hh
25
src/url.hh
@ -19,6 +19,7 @@ extern "C++"
|
||||
{
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <memory>
|
||||
}
|
||||
|
||||
|
||||
@ -57,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 */
|
||||
@ -72,7 +73,8 @@ extern "C++"
|
||||
* When the "empty" and "undefined" concepts of RFC-2396 are irrelevant to
|
||||
* the caller, and a string is required, use these methods instead:
|
||||
*/
|
||||
#define NPTR2STR(p) ((p) ? (p) : "")
|
||||
//#define NPTR2STR(p) ((p) ? (p) : "")
|
||||
inline const char *NPTR2STR( const char *const p ) { return p ? p : ""; }
|
||||
#define URL_SCHEME(u) NPTR2STR(URL_SCHEME_(u))
|
||||
#define URL_AUTHORITY(u) NPTR2STR(URL_AUTHORITY_(u))
|
||||
#define URL_PATH(u) NPTR2STR(URL_PATH_(u))
|
||||
@ -113,20 +115,21 @@ struct DilloUrl {
|
||||
};
|
||||
|
||||
|
||||
DilloUrl* a_Url_new(const char *url_str, const char *base_url);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
char *a_Url_string_strip_delimiters(const char *str);
|
||||
int a_Url_host_type(const char *host);
|
||||
bool_t a_Url_same_organization(const DilloUrl *u1, const DilloUrl *u2);
|
||||
bool_t a_Url_same_organization(const DilloUrl &u1, const DilloUrl &u2);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@ -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);
|
||||
web->requester = a_Url_dup(requester);
|
||||
web->url = a_Url_dup(*url).release();
|
||||
web->requester = a_Url_dup(*requester).release();
|
||||
web->bw = bw;
|
||||
web->flags = 0;
|
||||
web->Image = NULL;
|
||||
|
||||
Reference in New Issue
Block a user