Plumbing ownership further; some things became C++
This commit is contained in:
@ -45,12 +45,12 @@ datauri_filter_dpi_LDADD = \
|
||||
|
||||
downloads_dpi_CXXFLAGS = @LIBFLTK_CXXFLAGS@
|
||||
|
||||
bookmarks_dpi_SOURCES = bookmarks.c dpiutil.cc dpiutil.h
|
||||
downloads_dpi_SOURCES = downloads.cc dpiutil.cc dpiutil.h
|
||||
ftp_filter_dpi_SOURCES = ftp.c dpiutil.cc dpiutil.h
|
||||
hello_filter_dpi_SOURCES = hello.c dpiutil.cc dpiutil.h
|
||||
vsource_filter_dpi_SOURCES = vsource.c dpiutil.cc dpiutil.h
|
||||
file_dpi_SOURCES = file.c dpiutil.cc dpiutil.h
|
||||
cookies_dpi_SOURCES = cookies.c dpiutil.cc dpiutil.h
|
||||
datauri_filter_dpi_SOURCES = datauri.c dpiutil.cc dpiutil.h
|
||||
bookmarks_dpi_SOURCES = bookmarks.cc dpiutil.cc dpiutil.hh
|
||||
downloads_dpi_SOURCES = downloads.cc dpiutil.cc dpiutil.hh
|
||||
ftp_filter_dpi_SOURCES = ftp.cc dpiutil.cc dpiutil.hh
|
||||
hello_filter_dpi_SOURCES = hello.cc dpiutil.cc dpiutil.hh
|
||||
vsource_filter_dpi_SOURCES = vsource.cc dpiutil.cc dpiutil.hh
|
||||
file_dpi_SOURCES = file.cc dpiutil.cc dpiutil.hh
|
||||
cookies_dpi_SOURCES = cookies.cc dpiutil.cc dpiutil.hh
|
||||
datauri_filter_dpi_SOURCES = datauri.cc dpiutil.cc dpiutil.hh
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include "../dpip/dpip.h"
|
||||
#include "dpiutil.h"
|
||||
#include "dpiutil.hh"
|
||||
|
||||
|
||||
/*
|
||||
@ -393,7 +393,7 @@ static int Bms_sec_by_number_cmp(const void *node, const void *key)
|
||||
*/
|
||||
static BmRec *Bms_get(int key)
|
||||
{
|
||||
return dList_find_custom(B_bms, INT2VOIDP(key), Bms_node_by_key_cmp);
|
||||
return reinterpret_cast< BmRec * >( dList_find_custom(B_bms, INT2VOIDP(key), Bms_node_by_key_cmp) );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -401,7 +401,7 @@ static BmRec *Bms_get(int key)
|
||||
*/
|
||||
static BmSec *Bms_get_sec(int key)
|
||||
{
|
||||
return dList_find_custom(B_secs, INT2VOIDP(key), Bms_sec_by_number_cmp);
|
||||
return reinterpret_cast< BmSec * >( dList_find_custom(B_secs, INT2VOIDP(key), Bms_sec_by_number_cmp) );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -414,7 +414,7 @@ static void Bms_add(int section, char *url, char *title)
|
||||
bm_node = dNew(BmRec, 1);
|
||||
bm_node->key = ++bm_key;
|
||||
bm_node->section = section;
|
||||
bm_node->url = Escape_uri_str(url, "'");
|
||||
bm_node->url = dStrdup(Escape_uri_str(url, "'").c_str());
|
||||
bm_node->title = Escape_html_str(title);
|
||||
dList_append(B_bms, bm_node);
|
||||
}
|
||||
@ -439,7 +439,7 @@ static void Bms_del(int key)
|
||||
{
|
||||
BmRec *bm_node;
|
||||
|
||||
bm_node = dList_find_custom(B_bms, INT2VOIDP(key), Bms_node_by_key_cmp);
|
||||
bm_node = reinterpret_cast< BmRec * >( dList_find_custom(B_bms, INT2VOIDP(key), Bms_node_by_key_cmp) );
|
||||
if (bm_node) {
|
||||
dList_remove(B_bms, bm_node);
|
||||
dFree(bm_node->title);
|
||||
@ -458,16 +458,16 @@ static void Bms_sec_del(int section)
|
||||
BmSec *sec_node;
|
||||
BmRec *bm_node;
|
||||
|
||||
sec_node = dList_find_custom(B_secs, INT2VOIDP(section),
|
||||
Bms_sec_by_number_cmp);
|
||||
sec_node = reinterpret_cast< BmSec * >( dList_find_custom(B_secs, INT2VOIDP(section),
|
||||
Bms_sec_by_number_cmp) );
|
||||
if (sec_node) {
|
||||
dList_remove(B_secs, sec_node);
|
||||
dFree(sec_node->title);
|
||||
dFree(sec_node);
|
||||
|
||||
/* iterate B_bms and remove those that match the section */
|
||||
while ((bm_node = dList_find_custom(B_bms, INT2VOIDP(section),
|
||||
Bms_node_by_section_cmp))) {
|
||||
while ((bm_node = reinterpret_cast< BmRec * >( dList_find_custom(B_bms, INT2VOIDP(section),
|
||||
Bms_node_by_section_cmp) ))) {
|
||||
Bms_del(bm_node->key);
|
||||
}
|
||||
}
|
||||
@ -482,7 +482,7 @@ static void Bms_move(int key, int target_section)
|
||||
{
|
||||
BmRec *bm_node;
|
||||
|
||||
bm_node = dList_find_custom(B_bms, INT2VOIDP(key), Bms_node_by_key_cmp);
|
||||
bm_node = reinterpret_cast< BmRec * >( dList_find_custom(B_bms, INT2VOIDP(key), Bms_node_by_key_cmp) );
|
||||
if (bm_node) {
|
||||
bm_node->section = target_section;
|
||||
}
|
||||
@ -495,7 +495,7 @@ static void Bms_update_title(int key, char *n_title)
|
||||
{
|
||||
BmRec *bm_node;
|
||||
|
||||
bm_node = dList_find_custom(B_bms, INT2VOIDP(key), Bms_node_by_key_cmp);
|
||||
bm_node = reinterpret_cast< BmRec * >( dList_find_custom(B_bms, INT2VOIDP(key), Bms_node_by_key_cmp) );
|
||||
if (bm_node) {
|
||||
dFree(bm_node->title);
|
||||
bm_node->title = Escape_html_str(n_title);
|
||||
@ -509,7 +509,7 @@ static void Bms_update_sec_title(int key, char *n_title)
|
||||
{
|
||||
BmSec *sec_node;
|
||||
|
||||
sec_node = dList_find_custom(B_secs, INT2VOIDP(key), Bms_sec_by_number_cmp);
|
||||
sec_node = reinterpret_cast< BmSec * >( dList_find_custom(B_secs, INT2VOIDP(key), Bms_sec_by_number_cmp) );
|
||||
if (sec_node) {
|
||||
dFree(sec_node->title);
|
||||
sec_node->title = Escape_html_str(n_title);
|
||||
@ -525,11 +525,11 @@ static void Bms_free(void)
|
||||
BmSec *sec_node;
|
||||
|
||||
/* free B_bms */
|
||||
while ((bm_node = dList_nth_data(B_bms, 0))) {
|
||||
while ((bm_node = reinterpret_cast< BmRec * >( dList_nth_data(B_bms, 0) ))) {
|
||||
Bms_del(bm_node->key);
|
||||
}
|
||||
/* free B_secs */
|
||||
while ((sec_node = dList_nth_data(B_secs, 0))) {
|
||||
while ((sec_node = reinterpret_cast< BmSec * >( dList_nth_data(B_secs, 0) ))) {
|
||||
Bms_sec_del(sec_node->section);
|
||||
}
|
||||
}
|
||||
@ -548,16 +548,16 @@ static void Bms_normalize(void)
|
||||
Bms_sec_add("Unclassified");
|
||||
|
||||
/* make correlative section numbers */
|
||||
for (i = 0; (sec_node = dList_nth_data(B_secs, i)); ++i) {
|
||||
for (i = 0; (sec_node = reinterpret_cast< BmSec * >( dList_nth_data(B_secs, i) )); ++i) {
|
||||
sec_node->o_sec = sec_node->section;
|
||||
sec_node->section = i;
|
||||
}
|
||||
|
||||
/* iterate B_secs and make the changes in B_bms */
|
||||
for (i = 0; (sec_node = dList_nth_data(B_secs, i)); ++i) {
|
||||
for (i = 0; (sec_node = reinterpret_cast< BmSec * >( dList_nth_data(B_secs, i) )); ++i) {
|
||||
if (sec_node->section != sec_node->o_sec) {
|
||||
/* update section numbers */
|
||||
for (j = 0; (bm_node = dList_nth_data(B_bms, j)); ++j) {
|
||||
for (j = 0; (bm_node = reinterpret_cast< BmRec * >( dList_nth_data(B_bms, j) )); ++j) {
|
||||
if (bm_node->section == sec_node->o_sec)
|
||||
bm_node->section = sec_node->section;
|
||||
}
|
||||
@ -738,7 +738,7 @@ static int Bms_save(void)
|
||||
Bms_normalize();
|
||||
|
||||
/* save sections */
|
||||
for (i = 0; (sec_node = dList_nth_data(B_secs, i)); ++i) {
|
||||
for (i = 0; (sec_node = reinterpret_cast< BmSec * >( dList_nth_data(B_secs, i) )); ++i) {
|
||||
u_title = Unescape_html_str(sec_node->title);
|
||||
dStr_sprintf(dstr, ":s%d: %s\n", sec_node->section, u_title);
|
||||
fwrite(dstr->str, (size_t)dstr->len, 1, BmTxt);
|
||||
@ -746,8 +746,8 @@ static int Bms_save(void)
|
||||
}
|
||||
|
||||
/* save bookmarks (section url title) */
|
||||
for (i = 0; (sec_node = dList_nth_data(B_secs, i)); ++i) {
|
||||
for (j = 0; (bm_node = dList_nth_data(B_bms, j)); ++j) {
|
||||
for (i = 0; (sec_node = reinterpret_cast< BmSec * >( dList_nth_data(B_secs, i) )); ++i) {
|
||||
for (j = 0; (bm_node = reinterpret_cast< BmRec * >( dList_nth_data(B_bms, j) )); ++j) {
|
||||
if (bm_node->section == sec_node->section) {
|
||||
u_title = Unescape_html_str(bm_node->title);
|
||||
dStr_sprintf(dstr, "s%d %s %s\n",
|
||||
@ -855,7 +855,7 @@ static int Bmsrv_send_modify_page(Dsh *sh)
|
||||
if (a_Dpip_dsh_write_str(sh, 0, modifypage_sections_header))
|
||||
return 1;
|
||||
/* write sections */
|
||||
for (i = 0; (sec_node = dList_nth_data(B_secs, i)); ++i) {
|
||||
for (i = 0; (sec_node = reinterpret_cast< BmSec * >( dList_nth_data(B_secs, i) )); ++i) {
|
||||
if (i > 0) {
|
||||
if (a_Dpip_dsh_write_str(sh, 0, sections_sep))
|
||||
return 1;
|
||||
@ -875,7 +875,7 @@ static int Bmsrv_send_modify_page(Dsh *sh)
|
||||
return 1;
|
||||
|
||||
/* send bookmark cards */
|
||||
for (i = 0; (sec_node = dList_nth_data(B_secs, i)); ++i) {
|
||||
for (i = 0; (sec_node = reinterpret_cast< BmSec * >( dList_nth_data(B_secs, i) )); ++i) {
|
||||
/* send card header */
|
||||
l_title = make_one_line_str(sec_node->title);
|
||||
dStr_sprintf(dstr, modifypage_section_card_header,
|
||||
@ -885,7 +885,7 @@ static int Bmsrv_send_modify_page(Dsh *sh)
|
||||
return 1;
|
||||
|
||||
/* send section's bookmarks */
|
||||
for (j = 0; (bm_node = dList_nth_data(B_bms, j)); ++j) {
|
||||
for (j = 0; (bm_node = reinterpret_cast< BmRec * >( dList_nth_data(B_bms, j) )); ++j) {
|
||||
if (bm_node->section == sec_node->section) {
|
||||
dStr_sprintf(dstr, modifypage_section_card_item,
|
||||
bm_node->key, bm_node->url, bm_node->title);
|
||||
@ -1420,7 +1420,7 @@ static int send_bm_page(Dsh *sh)
|
||||
if (a_Dpip_dsh_write_str(sh, 0, mainpage_sections_header))
|
||||
return 1;
|
||||
/* write sections */
|
||||
for (i = 0; (sec_node = dList_nth_data(B_secs, i)); ++i) {
|
||||
for (i = 0; (sec_node = reinterpret_cast< BmSec * >( dList_nth_data(B_secs, i) )); ++i) {
|
||||
if (i > 0) {
|
||||
if (a_Dpip_dsh_write_str(sh, 0, sections_sep))
|
||||
return 1;
|
||||
@ -1440,7 +1440,7 @@ static int send_bm_page(Dsh *sh)
|
||||
return 1;
|
||||
|
||||
/* send bookmark cards */
|
||||
for (i = 0; (sec_node = dList_nth_data(B_secs, i)); ++i) {
|
||||
for (i = 0; (sec_node = reinterpret_cast< BmSec * >( dList_nth_data(B_secs, i) )); ++i) {
|
||||
/* send card header */
|
||||
l_title = make_one_line_str(sec_node->title);
|
||||
dStr_sprintf(dstr, mainpage_section_card_header,
|
||||
@ -1450,7 +1450,7 @@ static int send_bm_page(Dsh *sh)
|
||||
return 1;
|
||||
|
||||
/* send section's bookmarks */
|
||||
for (j = 0; (bm_node = dList_nth_data(B_bms, j)); ++j) {
|
||||
for (j = 0; (bm_node = reinterpret_cast< BmRec * >( dList_nth_data(B_bms, j) )); ++j) {
|
||||
if (bm_node->section == sec_node->section) {
|
||||
dStr_sprintf(dstr, mainpage_section_card_item,
|
||||
bm_node->url, bm_node->title);
|
@ -48,7 +48,7 @@ int main(void)
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <signal.h>
|
||||
#include "dpiutil.h"
|
||||
#include "dpiutil.hh"
|
||||
#include "../dpip/dpip.h"
|
||||
|
||||
|
||||
@ -65,14 +65,14 @@ int main(void)
|
||||
* (First, allocate an 'alloc_step' sized chunk, after that, double the
|
||||
* list size --to make it faster)
|
||||
*/
|
||||
#define a_List_add(list,num_items,alloc_step) \
|
||||
#define a_List_add(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))); \
|
||||
}
|
||||
|
||||
/* The maximum length of a line in the cookie file */
|
||||
@ -157,7 +157,7 @@ static int Cookies_cmp(const void *a, const void *b);
|
||||
*/
|
||||
static int Domain_node_cmp(const void *v1, const void *v2)
|
||||
{
|
||||
const DomainNode *n1 = v1, *n2 = v2;
|
||||
const DomainNode *n1 = reinterpret_cast< const DomainNode * >( v1 ), *n2 = reinterpret_cast< const DomainNode * >( v2 );
|
||||
|
||||
return dStrAsciiCasecmp(n1->domain, n2->domain);
|
||||
}
|
||||
@ -167,8 +167,8 @@ static int Domain_node_cmp(const void *v1, const void *v2)
|
||||
*/
|
||||
static int Domain_node_by_domain_cmp(const void *v1, const void *v2)
|
||||
{
|
||||
const DomainNode *node = v1;
|
||||
const char *domain = v2;
|
||||
const DomainNode *node = reinterpret_cast< const DomainNode * >( v1 );
|
||||
const char *domain = reinterpret_cast< const char * >( v2 );
|
||||
|
||||
return dStrAsciiCasecmp(node->domain, domain);
|
||||
}
|
||||
@ -410,8 +410,8 @@ static void Cookies_save_and_free(void)
|
||||
fprintf(file_stream, "%s", cookies_txt_header_str);
|
||||
|
||||
/* Iterate cookies per domain, saving and freeing */
|
||||
while ((node = dList_nth_data(domains, 0))) {
|
||||
for (i = 0; (cookie = dList_nth_data(node->cookies, i)); ++i) {
|
||||
while ((node = reinterpret_cast< DomainNode * >( dList_nth_data(domains, 0) ))) {
|
||||
for (i = 0; (cookie = reinterpret_cast< CookieData_t * >( dList_nth_data(node->cookies, i) )); ++i) {
|
||||
if (!cookie->session_only && difftime(cookie->expires_at, now) > 0) {
|
||||
int len;
|
||||
char buf[LINE_MAXLEN];
|
||||
@ -656,10 +656,10 @@ static struct tm *Cookies_parse_date(const char *date)
|
||||
static CookieData_t *Cookies_get_LRU(Dlist *cookies)
|
||||
{
|
||||
int i, n = dList_length(cookies);
|
||||
CookieData_t *lru = dList_nth_data(cookies, 0);
|
||||
CookieData_t *lru = reinterpret_cast< CookieData_t * >( dList_nth_data(cookies, 0) );
|
||||
|
||||
for (i = 1; i < n; i++) {
|
||||
CookieData_t *curr = dList_nth_data(cookies, i);
|
||||
CookieData_t *curr = reinterpret_cast< CookieData_t * >( dList_nth_data(cookies, i) );
|
||||
|
||||
if (curr->last_used < lru->last_used)
|
||||
lru = curr;
|
||||
@ -682,11 +682,11 @@ static int Cookies_rm_expired_cookies(DomainNode *node)
|
||||
time_t now = time(NULL);
|
||||
|
||||
while (i < n) {
|
||||
CookieData_t *c = dList_nth_data(cookies, i);
|
||||
CookieData_t *c = reinterpret_cast< CookieData_t * >( dList_nth_data(cookies, i) );
|
||||
|
||||
if (difftime(c->expires_at, now) < 0) {
|
||||
DomainNode *currnode = node ? node :
|
||||
dList_find_sorted(domains, c->domain, Domain_node_by_domain_cmp);
|
||||
reinterpret_cast< DomainNode * >( dList_find_sorted(domains, c->domain, Domain_node_by_domain_cmp) );
|
||||
dList_remove(currnode->cookies, c);
|
||||
if (dList_length(currnode->cookies) == 0)
|
||||
Cookies_delete_node(currnode);
|
||||
@ -713,7 +713,7 @@ static void Cookies_too_many(DomainNode *node)
|
||||
"Removing LRU cookie for \'%s\': \'%s=%s\'\n", lru->domain,
|
||||
lru->name, lru->value);
|
||||
if (!node)
|
||||
node = dList_find_sorted(domains, lru->domain,Domain_node_by_domain_cmp);
|
||||
node = reinterpret_cast< DomainNode * >( dList_find_sorted(domains, lru->domain,Domain_node_by_domain_cmp) );
|
||||
|
||||
dList_remove(node->cookies, lru);
|
||||
dList_remove_fast(all_cookies, lru);
|
||||
@ -728,12 +728,12 @@ static void Cookies_add_cookie(CookieData_t *cookie)
|
||||
CookieData_t *c;
|
||||
DomainNode *node;
|
||||
|
||||
node = dList_find_sorted(domains, cookie->domain,Domain_node_by_domain_cmp);
|
||||
node = reinterpret_cast< DomainNode * >( dList_find_sorted(domains, cookie->domain,Domain_node_by_domain_cmp) );
|
||||
domain_cookies = (node) ? node->cookies : NULL;
|
||||
|
||||
if (domain_cookies) {
|
||||
/* Remove any cookies with the same name, path, and host-only values. */
|
||||
while ((c = dList_find_custom(domain_cookies, cookie, Cookies_cmp))) {
|
||||
while ((c = reinterpret_cast< CookieData_t * >( dList_find_custom(domain_cookies, cookie, Cookies_cmp) ))) {
|
||||
dList_remove(domain_cookies, c);
|
||||
dList_remove_fast(all_cookies, c);
|
||||
Cookies_free_cookie(c);
|
||||
@ -757,8 +757,8 @@ static void Cookies_add_cookie(CookieData_t *cookie)
|
||||
Cookies_too_many(node);
|
||||
} else if (removed >= MAX_DOMAIN_COOKIES) {
|
||||
/* So many were removed that the node might have been deleted. */
|
||||
node = dList_find_sorted(domains, cookie->domain,
|
||||
Domain_node_by_domain_cmp);
|
||||
node = reinterpret_cast< DomainNode * >( dList_find_sorted(domains, cookie->domain,
|
||||
Domain_node_by_domain_cmp) );
|
||||
domain_cookies = (node) ? node->cookies : NULL;
|
||||
}
|
||||
}
|
||||
@ -767,8 +767,8 @@ static void Cookies_add_cookie(CookieData_t *cookie)
|
||||
Cookies_too_many(NULL);
|
||||
} else if (domain_cookies) {
|
||||
/* Our own node might have just been deleted. */
|
||||
node = dList_find_sorted(domains, cookie->domain,
|
||||
Domain_node_by_domain_cmp);
|
||||
node = reinterpret_cast< DomainNode * >( dList_find_sorted(domains, cookie->domain,
|
||||
Domain_node_by_domain_cmp) );
|
||||
domain_cookies = (node) ? node->cookies : NULL;
|
||||
}
|
||||
}
|
||||
@ -1013,7 +1013,7 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date)
|
||||
*/
|
||||
static int Cookies_cmp(const void *a, const void *b)
|
||||
{
|
||||
const CookieData_t *ca = a, *cb = b;
|
||||
const CookieData_t *ca = reinterpret_cast< const CookieData_t * >( a ), *cb = reinterpret_cast< const CookieData_t * >( b );
|
||||
|
||||
return (ca->host_only != cb->host_only) ||
|
||||
(strcmp(ca->name, cb->name) != 0) ||
|
||||
@ -1276,14 +1276,14 @@ static void Cookies_add_matching_cookies(const char *domain,
|
||||
Dlist *matching_cookies,
|
||||
bool_t is_tls)
|
||||
{
|
||||
DomainNode *node = dList_find_sorted(domains, domain,
|
||||
Domain_node_by_domain_cmp);
|
||||
DomainNode *node = reinterpret_cast< DomainNode * >( dList_find_sorted(domains, domain,
|
||||
Domain_node_by_domain_cmp) );
|
||||
if (node) {
|
||||
int i;
|
||||
CookieData_t *cookie;
|
||||
Dlist *domain_cookies = node->cookies;
|
||||
|
||||
for (i = 0; (cookie = dList_nth_data(domain_cookies, i)); ++i) {
|
||||
for (i = 0; (cookie = reinterpret_cast< CookieData_t * >( dList_nth_data(domain_cookies, i) )); ++i) {
|
||||
/* Remove expired cookie. */
|
||||
if (difftime(cookie->expires_at, time(NULL)) < 0) {
|
||||
_MSG("Goodbye, expired cookie %s=%s d:%s p:%s\n", cookie->name,
|
||||
@ -1303,7 +1303,7 @@ static void Cookies_add_matching_cookies(const char *domain,
|
||||
|
||||
/* Longest cookies go first */
|
||||
for (j = 0;
|
||||
(curr = dList_nth_data(matching_cookies, j)) &&
|
||||
(curr = reinterpret_cast< CookieData_t * >( dList_nth_data(matching_cookies, j) )) &&
|
||||
strlen(curr->path) >= path_length;
|
||||
j++) ;
|
||||
dList_insert_pos(matching_cookies, cookie, j);
|
||||
@ -1385,7 +1385,7 @@ static char *Cookies_get(char *url_host, char *url_path,
|
||||
|
||||
dStr_sprintfa(cookie_dstring, "Cookie: ");
|
||||
|
||||
for (i = 0; (cookie = dList_nth_data(matching_cookies, i)); ++i) {
|
||||
for (i = 0; (cookie = reinterpret_cast< CookieData_t * >( dList_nth_data(matching_cookies, i) )); ++i) {
|
||||
dStr_sprintfa(cookie_dstring, "%s=%s", cookie->name, cookie->value);
|
||||
dStr_append(cookie_dstring,
|
||||
dList_length(matching_cookies) > i + 1 ? "; " : "\r\n");
|
||||
@ -1486,7 +1486,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--) {
|
@ -19,7 +19,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "../dpip/dpip.h"
|
||||
#include "dpiutil.h"
|
||||
#include "dpiutil.hh"
|
||||
#include "../src/misc.hh"
|
||||
|
||||
/*
|
||||
@ -152,7 +152,7 @@ char *a_Url_decode_hex_str(const char *str, size_t *p_sz)
|
||||
*dest = 0;
|
||||
|
||||
*p_sz = (size_t)(dest - new_str);
|
||||
new_str = dRealloc(new_str, sizeof(char) * (dest - new_str + 1));
|
||||
new_str = reinterpret_cast< char * >( dRealloc(new_str, sizeof(char) * (dest - new_str + 1)) );
|
||||
return new_str;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include <FL/Fl_Button.H>
|
||||
|
||||
#include "config.h"
|
||||
#include "dpiutil.h"
|
||||
#include "dpiutil.hh"
|
||||
#include "../dpip/dpip.h"
|
||||
|
||||
/*
|
||||
@ -320,7 +320,7 @@ DLItem::DLItem(const char *full_filename, const char *url, const char *user_agen
|
||||
|
||||
// BUG:? test a URL with ' inside.
|
||||
/* escape "'" character for the shell. Is it necessary? */
|
||||
esc_url = Escape_uri_str(url, "'");
|
||||
esc_url = dStrdup( Escape_uri_str(url, "'").c_str() );
|
||||
/* avoid malicious SMTP relaying with FTP urls */
|
||||
if (dStrnAsciiCasecmp(esc_url, "ftp:/", 5) == 0)
|
||||
Filter_smtp_hack(esc_url);
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "dpiutil.h"
|
||||
#include "dpiutil.hh"
|
||||
|
||||
/*
|
||||
* Debugging macros
|
||||
@ -33,7 +33,7 @@
|
||||
* Escape URI characters in 'esc_set' as %XX sequences.
|
||||
* Return value: New escaped string.
|
||||
*/
|
||||
char *Escape_uri_str(const char *str, const char *p_esc_set)
|
||||
std::string Escape_uri_str(const char *str, const char *p_esc_set)
|
||||
{
|
||||
static const char *esc_set, *hex = "0123456789ABCDEF";
|
||||
char *p;
|
||||
|
@ -24,7 +24,11 @@
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
|
||||
extern "C" {
|
||||
#else
|
||||
#error DPI UTIL header is now C++
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
@ -32,7 +36,7 @@ extern "C" {
|
||||
* Escape URI characters in 'esc_set' as %XX sequences.
|
||||
* Return value: New escaped string.
|
||||
*/
|
||||
char *Escape_uri_str(const char *str, const char *p_esc_set);
|
||||
std::string Escape_uri_str(const char *str, const char *p_esc_set);
|
||||
|
||||
/*
|
||||
* Unescape %XX sequences in a string.
|
@ -35,7 +35,7 @@
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "../dpip/dpip.h"
|
||||
#include "dpiutil.h"
|
||||
#include "dpiutil.hh"
|
||||
#include "d_size.h"
|
||||
|
||||
/*
|
||||
@ -136,7 +136,7 @@ static const char *File_get_content_type_from_data(void *Data, size_t Size)
|
||||
"image/gif", "image/png", "image/jpeg",
|
||||
};
|
||||
int Type = 0;
|
||||
char *p = Data;
|
||||
char *p = reinterpret_cast< char * >( Data );
|
||||
size_t i, non_ascci;
|
||||
|
||||
_MSG("File_get_content_type_from_data:: Size = %zu\n", Size);
|
||||
@ -273,7 +273,7 @@ static void File_dillodir_free(DilloDir *Ddir)
|
||||
dReturn_if (Ddir == NULL);
|
||||
|
||||
for (i = 0; i < dList_length(Ddir->flist); ++i) {
|
||||
finfo = dList_nth_data(Ddir->flist, i);
|
||||
finfo = reinterpret_cast< FileInfo * >( dList_nth_data(Ddir->flist, i) );
|
||||
dFree(finfo->full_path);
|
||||
dFree(finfo);
|
||||
}
|
||||
@ -298,7 +298,7 @@ static void File_print_parent_dir(ClientInfo *client, const char *dirname)
|
||||
if ((p = strrchr(parent, '/')))
|
||||
*(p + 1) = '\0';
|
||||
|
||||
Uparent = Escape_uri_str(parent, NULL);
|
||||
Uparent = dStrdup( Escape_uri_str(parent, NULL).c_str() );
|
||||
HUparent = Escape_html_str(Uparent);
|
||||
a_Dpip_dsh_printf(client->sh, 0,
|
||||
"<a href='file:%s'>Parent directory</a>", HUparent);
|
||||
@ -337,7 +337,7 @@ static void File_print_mtime(ClientInfo *client, time_t mtime)
|
||||
static void File_info2html(ClientInfo *client, FileInfo *finfo, int n)
|
||||
{
|
||||
int size;
|
||||
char *sizeunits;
|
||||
const char *sizeunits;
|
||||
char namebuf[MAXNAMESIZE + 1];
|
||||
char *Uref, *HUref, *Hname;
|
||||
const char *ref, *filecont, *name = finfo->filename;
|
||||
@ -373,12 +373,12 @@ static void File_info2html(ClientInfo *client, FileInfo *finfo, int n)
|
||||
}
|
||||
|
||||
/* escape problematic filenames */
|
||||
Uref = Escape_uri_str(ref, NULL);
|
||||
Uref = dStrdup( Escape_uri_str(ref, NULL).c_str() );
|
||||
HUref = Escape_html_str(Uref);
|
||||
Hname = Escape_html_str(name);
|
||||
|
||||
if (client->old_style) {
|
||||
char *dots = ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..";
|
||||
const char *dots = ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..";
|
||||
int ndots = MAXNAMESIZE - strlen(name);
|
||||
a_Dpip_dsh_printf(client->sh, 0,
|
||||
"%s<a href='%s'>%s</a>"
|
||||
@ -425,7 +425,7 @@ static void File_send_dir(ClientInfo *client)
|
||||
/* send HTTP header and HTML top part */
|
||||
|
||||
/* Send page title */
|
||||
Udirname = Escape_uri_str(Ddir->dirname, NULL);
|
||||
Udirname = dStrdup( Escape_uri_str(Ddir->dirname, NULL).c_str() );
|
||||
HUdirname = Escape_html_str(Udirname);
|
||||
Hdirname = Escape_html_str(Ddir->dirname);
|
||||
|
||||
@ -476,7 +476,7 @@ static void File_send_dir(ClientInfo *client)
|
||||
} else if (client->state == st_http) {
|
||||
/* send directories as HTML contents */
|
||||
for (n = 0; n < dList_length(Ddir->flist); ++n) {
|
||||
File_info2html(client, dList_nth_data(Ddir->flist,n), n+1);
|
||||
File_info2html(client, reinterpret_cast< FileInfo * >( dList_nth_data(Ddir->flist,n) ), n+1);
|
||||
}
|
||||
|
||||
if (client->old_style) {
|
||||
@ -498,7 +498,7 @@ static const char *File_ext(const char *filename)
|
||||
{
|
||||
char *e;
|
||||
|
||||
if (!(e = strrchr(filename, '.')))
|
||||
if (!(e = strrchr(const_cast< char * >( filename ), '.')))
|
||||
return NULL;
|
||||
|
||||
e++;
|
||||
@ -817,7 +817,7 @@ static char *File_normalize_path(const char *orig)
|
||||
/* Expand home tilde "~" into "/home/userxyz" */
|
||||
const char *home = dGethomedir();
|
||||
/* Add separator if needed */
|
||||
char *sep = home[strlen(home) - 1] == '/' ? "" : "/";
|
||||
const char *sep = home[strlen(home) - 1] == '/' ? "" : "/";
|
||||
char *next = str + 1;
|
||||
while (*next == '/')
|
||||
next++;
|
||||
@ -899,7 +899,7 @@ static ClientInfo *File_add_client(int sock_fd)
|
||||
new_client->file_fd = -1;
|
||||
new_client->file_sz = 0;
|
||||
new_client->d_dir = NULL;
|
||||
new_client->state = 0;
|
||||
new_client->state = FileState( 0 ); // reinterpret_cast
|
||||
new_client->err_code = 0;
|
||||
new_client->flags = FILE_READ;
|
||||
new_client->old_style = OLD_STYLE;
|
||||
@ -932,7 +932,7 @@ static void File_remove_client(ClientInfo *client)
|
||||
static void File_serve_client(void *data, int f_write)
|
||||
{
|
||||
char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *path;
|
||||
ClientInfo *client = data;
|
||||
ClientInfo *client = reinterpret_cast< ClientInfo * >( data );
|
||||
int st;
|
||||
|
||||
while (1) {
|
||||
@ -1005,7 +1005,7 @@ static void File_serve_clients(void)
|
||||
int i, f_read, f_write;
|
||||
ClientInfo *client;
|
||||
|
||||
for (i = 0; (client = dList_nth_data(Clients, i)); ++i) {
|
||||
for (i = 0; (client = reinterpret_cast< ClientInfo * >( dList_nth_data(Clients, i) )); ++i) {
|
||||
f_read = FD_ISSET(client->sh->fd_in, &read_set);
|
||||
f_write = FD_ISSET(client->sh->fd_out, &write_set);
|
||||
if (!f_read && !f_write)
|
||||
@ -1034,7 +1034,7 @@ static int File_check_fds(uint_t seconds)
|
||||
FD_ZERO (&read_set);
|
||||
FD_ZERO (&write_set);
|
||||
FD_SET (STDIN_FILENO, &read_set);
|
||||
for (i = 0; (client = dList_nth_data(Clients, i)); ++i) {
|
||||
for (i = 0; (client = reinterpret_cast< ClientInfo * >( dList_nth_data(Clients, i) )); ++i) {
|
||||
if (client->flags & FILE_READ)
|
||||
FD_SET (client->sh->fd_in, &read_set);
|
||||
if (client->flags & FILE_WRITE)
|
@ -42,7 +42,7 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#include "../dpip/dpip.h"
|
||||
#include "dpiutil.h"
|
||||
#include "dpiutil.hh"
|
||||
#include "d_size.h"
|
||||
|
||||
/*
|
||||
@ -92,7 +92,7 @@ static int a_Misc_get_content_type_from_data2(void *Data, size_t Size,
|
||||
{
|
||||
int st = 1; /* default to "doubt' */
|
||||
int Type = 0; /* default to "application/octet-stream" */
|
||||
char *p = Data;
|
||||
char *p = reinterpret_cast< char * >( Data );
|
||||
uchar_t ch;
|
||||
size_t i, non_ascci;
|
||||
|
||||
@ -159,7 +159,7 @@ static void make_wget_argv(char *url)
|
||||
}
|
||||
dl_argv = dNew(char*, 10);
|
||||
|
||||
esc_url = Escape_uri_str(url, "'");
|
||||
esc_url = dStrdup( Escape_uri_str(url, "'").c_str() );
|
||||
/* avoid malicious SMTP relaying with FTP urls */
|
||||
Filter_smtp_hack(esc_url);
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "../dpip/dpip.h"
|
||||
#include "dpiutil.h"
|
||||
#include "dpiutil.hh"
|
||||
|
||||
/*
|
||||
* Debugging macros
|
@ -20,7 +20,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "../dpip/dpip.h"
|
||||
#include "dpiutil.h"
|
||||
#include "dpiutil.hh"
|
||||
|
||||
/*
|
||||
* Debugging macros
|
3
rebuild
3
rebuild
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
make distclean
|
||||
pushd ..
|
||||
./autogen.sh
|
||||
popd
|
||||
../configure --prefix=/opt/local --enable-ipv6
|
||||
make -kj9
|
||||
make -kj11
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
|
@ -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)
|
||||
|
14
src/cache.cc
14
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
14
src/form.cc
14
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).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);
|
||||
|
@ -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) {
|
||||
|
20
src/html.cc
20
src/html.cc
@ -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 {
|
||||
|
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).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);
|
||||
}
|
||||
|
26
src/nav.cc
26
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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
43
src/url.cc
43
src/url.cc
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
17
src/url.hh
17
src/url.hh
@ -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);
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user