Plumbing ownership further; some things became C++

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

View File

@ -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

View File

@ -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);

View File

@ -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--) {

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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.

View File

@ -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)

View File

@ -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);

View File

@ -19,7 +19,7 @@
#include <string.h>
#include <errno.h>
#include "../dpip/dpip.h"
#include "dpiutil.h"
#include "dpiutil.hh"
/*
* Debugging macros

View File

@ -20,7 +20,7 @@
#include <string.h>
#include <errno.h>
#include "../dpip/dpip.h"
#include "dpiutil.h"
#include "dpiutil.hh"
/*
* Debugging macros