change content get_source_data interfaces to return uint8_t and size_t

previously these interfaces returned char * and unsigned int which was
undesirable.
This commit is contained in:
Vincent Sanders 2019-05-05 22:46:40 +01:00
parent f966580d22
commit 35bc2ccbb8
34 changed files with 240 additions and 197 deletions

View File

@ -1239,27 +1239,21 @@ int content__get_available_width(struct content *c)
/* exported interface documented in content/content.h */
const char *content_get_source_data(hlcache_handle *h, unsigned long *size)
const uint8_t *content_get_source_data(hlcache_handle *h, size_t *size)
{
return content__get_source_data(hlcache_handle_get_content(h), size);
}
/* exported interface documented in content/content_protected.h */
const char *content__get_source_data(struct content *c, unsigned long *size)
const uint8_t *content__get_source_data(struct content *c, size_t *size)
{
const uint8_t *data;
size_t len;
assert(size != NULL);
/** \todo check if the content check should be an assert */
if (c == NULL)
return NULL;
data = llcache_handle_get_source_data(c->llcache, &len);
*size = (unsigned long) len;
return (const char *) data;
return llcache_handle_get_source_data(c->llcache, size);
}
/* exported interface documented in content/content.h */

View File

@ -17,8 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
* Content handling (interface).
/**
* \file
* Protected interface to Content handling.
*
* The content functions manipulate struct contents, which correspond to URLs.
*/
@ -255,7 +256,7 @@ int content__get_available_width(struct content *c);
* \param size Pointer to location to receive byte size of source.
* \return Pointer to source data.
*/
const char *content__get_source_data(struct content *c, unsigned long *size);
const uint8_t *content__get_source_data(struct content *c, size_t *size);
/**
* Invalidate content reuse data.

View File

@ -80,8 +80,6 @@ typedef struct {
* imports array */
} nscss_import_ctx;
static bool nscss_process_data(struct content *c, const char *data,
unsigned int size);
static bool nscss_convert(struct content *c);
static void nscss_destroy(struct content *c);
static nserror nscss_clone(const struct content *old, struct content **newc);
@ -245,7 +243,8 @@ static nserror nscss_create_css_data(struct content_css_data *c,
* \param size Number of bytes to process
* \return true on success, false on failure
*/
bool nscss_process_data(struct content *c, const char *data, unsigned int size)
static bool
nscss_process_data(struct content *c, const char *data, unsigned int size)
{
nscss_content *css = (nscss_content *) c;
css_error error;
@ -374,8 +373,8 @@ nserror nscss_clone(const struct content *old, struct content **newc)
{
const nscss_content *old_css = (const nscss_content *) old;
nscss_content *new_css;
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
nserror error;
new_css = calloc(1, sizeof(nscss_content));
@ -402,7 +401,9 @@ nserror nscss_clone(const struct content *old, struct content **newc)
data = content__get_source_data(&new_css->base, &size);
if (size > 0) {
if (nscss_process_data(&new_css->base, data, size) == false) {
if (nscss_process_data(&new_css->base,
(char *)data,
(unsigned int)size) == false) {
content_destroy(&new_css->base);
return NSERROR_CLONE_FAILED;
}

View File

@ -1114,8 +1114,8 @@ html_process_encoding_change(struct content *c,
dom_hubbub_parser_params parse_params;
dom_hubbub_error error;
const char *encoding;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
/* Retrieve new encoding */
encoding = dom_hubbub_parser_get_encoding(html->parser,
@ -1181,7 +1181,7 @@ html_process_encoding_change(struct content *c,
* it cannot be changed again.
*/
error = dom_hubbub_parser_parse_chunk(html->parser,
(const uint8_t *)source_data,
source_data,
source_size);
return libdom_hubbub_error_to_nserror(error);

View File

@ -42,7 +42,7 @@
#include "html/html.h"
#include "html/html_internal.h"
typedef bool (script_handler_t)(struct jscontext *jscontext, const char *data, size_t size, const char *name);
typedef bool (script_handler_t)(struct jscontext *jscontext, const uint8_t *data, size_t size, const char *name);
static script_handler_t *select_script_handler(content_type ctype)
@ -90,8 +90,8 @@ nserror html_script_exec(html_content *c, bool allow_defer)
if (content_get_status(s->data.handle) ==
CONTENT_STATUS_DONE) {
/* external script is now available */
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
data = content_get_source_data(
s->data.handle, &size );
script_handler(c->jscontext, data, size,
@ -305,8 +305,8 @@ convert_script_sync_cb(hlcache_handle *script,
script_handler = select_script_handler(content_get_type(s->data.handle));
if (script_handler != NULL && parent->jscontext != NULL) {
/* script has a handler */
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
data = content_get_source_data(s->data.handle, &size );
script_handler(parent->jscontext, data, size,
nsurl_access(hlcache_handle_get_url(s->data.handle)));
@ -532,7 +532,7 @@ exec_inline_script(html_content *c, dom_node *node, dom_string *mimetype)
if (script_handler != NULL) {
script_handler(c->jscontext,
dom_string_data(script),
(const uint8_t *)dom_string_data(script),
dom_string_byte_length(script),
"?inline script?");
}

View File

@ -122,8 +122,8 @@ static bool nsbmp_convert(struct content *c)
nsbmp_content *bmp = (nsbmp_content *) c;
bmp_result res;
uint32_t swidth;
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
char *title;
/* set the bmp data */

View File

@ -236,8 +236,8 @@ static bool nsgif_convert(struct content *c)
{
nsgif_content *gif = (nsgif_content *) c;
int res;
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
char *title;
/* Get the animation */

View File

@ -120,8 +120,8 @@ static bool nsico_convert(struct content *c)
nsico_content *ico = (nsico_content *) c;
struct bmp_image *bmp;
bmp_result res;
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
char *title;
/* set the ico data */

View File

@ -168,8 +168,8 @@ static void nsjpeg_error_exit(j_common_ptr cinfo)
static struct bitmap *
jpeg_cache_convert(struct content *c)
{
uint8_t *source_data; /* Jpeg source data */
unsigned long source_size; /* length of Jpeg source data */
const uint8_t *source_data; /* Jpeg source data */
size_t source_size; /* length of Jpeg source data */
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
jmp_buf setjmp_buffer;
@ -188,7 +188,7 @@ jpeg_cache_convert(struct content *c)
nsjpeg_term_source };
/* obtain jpeg source data and perfom minimal sanity checks */
source_data = (uint8_t *)content__get_source_data(c, &source_size);
source_data = content__get_source_data(c, &source_size);
if ((source_data == NULL) ||
(source_size < MIN_JPEG_SIZE)) {
@ -315,8 +315,8 @@ static bool nsjpeg_convert(struct content *c)
nsjpeg_skip_input_data, jpeg_resync_to_restart,
nsjpeg_term_source };
union content_msg_data msg_data;
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
char *title;
/* check image header is valid and get width/height */

View File

@ -98,8 +98,8 @@ static bool nssprite_convert(struct content *c)
struct rosprite_mem_context* ctx = NULL;
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
char *title;
data = content__get_source_data(c, &size);

View File

@ -367,8 +367,8 @@ static bool nspng_process_data(struct content *c, const char *data,
}
struct png_cache_read_data_s {
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
};
/** PNG library read fucntion to read data from a memory array
@ -551,8 +551,8 @@ static nserror nspng_clone(const struct content *old_c, struct content **new_c)
{
nspng_content *clone_png_c;
nserror error;
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
clone_png_c = calloc(1, sizeof(nspng_content));
if (clone_png_c == NULL)
@ -573,7 +573,7 @@ static nserror nspng_clone(const struct content *old_c, struct content **new_c)
data = content__get_source_data(&clone_png_c->base, &size);
if (size > 0) {
if (nspng_process_data(&clone_png_c->base, data, size) == false) {
if (nspng_process_data(&clone_png_c->base, (const char *)data, size) == false) {
content_destroy(&clone_png_c->base);
return NSERROR_NOMEM;
}

View File

@ -262,8 +262,8 @@ static nserror rsvg_clone(const struct content *old, struct content **newc)
{
rsvg_content *svg;
nserror error;
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
svg = calloc(1, sizeof(rsvg_content));
if (svg == NULL)
@ -284,7 +284,7 @@ static nserror rsvg_clone(const struct content *old, struct content **newc)
data = content__get_source_data(&svg->base, &size);
if (size > 0) {
if (rsvg_process_data(&svg->base, data, size) == false) {
if (rsvg_process_data(&svg->base, (const char *)data, size) == false) {
content_destroy(&svg->base);
return NSERROR_NOMEM;
}

View File

@ -126,8 +126,8 @@ static bool svg_convert(struct content *c)
static void svg_reformat(struct content *c, int width, int height)
{
svg_content *svg = (svg_content *) c;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
assert(svg->diagram);
@ -135,9 +135,12 @@ static void svg_reformat(struct content *c, int width, int height)
if (width != svg->current_width || height != svg->current_height) {
source_data = content__get_source_data(c, &source_size);
svgtiny_parse(svg->diagram, source_data, source_size,
nsurl_access(content_get_url(c)),
width, height);
svgtiny_parse(svg->diagram,
(const char *)source_data,
source_size,
nsurl_access(content_get_url(c)),
width,
height);
svg->current_width = width;
svg->current_height = height;
@ -222,7 +225,7 @@ svg_redraw_internal(struct content *c,
return false;
}
}
}
}
#undef BGR
@ -361,5 +364,3 @@ static const char *svg_types[] = {
CONTENT_FACTORY_REGISTER_TYPES(svg, svg_types, svg_content_handler);

View File

@ -88,7 +88,7 @@ static struct bitmap *
webp_cache_convert(struct content *c)
{
const uint8_t *source_data; /* webp source data */
unsigned long source_size; /* length of webp source data */
size_t source_size; /* length of webp source data */
VP8StatusCode webpres;
WebPBitstreamFeatures webpfeatures;
unsigned int bmap_flags;
@ -97,7 +97,7 @@ webp_cache_convert(struct content *c)
size_t rowstride;
struct bitmap *bitmap = NULL;
source_data = (uint8_t *)content__get_source_data(c, &source_size);
source_data = content__get_source_data(c, &source_size);
webpres = WebPGetFeatures(source_data, source_size, &webpfeatures);
@ -156,12 +156,12 @@ webp_cache_convert(struct content *c)
static bool webp_convert(struct content *c)
{
int res;
unsigned long data_size;
const uint8_t* data;
size_t data_size;
int width;
int height;
data = (uint8_t *)content__get_source_data(c, &data_size);
data = content__get_source_data(c, &data_size);
res = WebPGetInfo(data, data_size, &width, &height);
if (res == 0) {

View File

@ -761,10 +761,16 @@ void dukky_push_generics(duk_context *ctx, const char *generic)
/* ..., generic */
}
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen, const char *name)
/* exported interface documented in js.h */
bool
js_exec(jscontext *ctx, const uint8_t *txt, size_t txtlen, const char *name)
{
assert(ctx);
if (txt == NULL || txtlen == 0) return false;
if (txt == NULL || txtlen == 0) {
return false;
}
duk_set_top(CTX, 0);
NSLOG(dukky, DEEPDEBUG, "Running %"PRIsizet" bytes from %s", txtlen, name);
/* NSLOG(dukky, DEEPDEBUG, "\n%s\n", txt); */
@ -775,7 +781,10 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen, const char *name)
} else {
duk_push_string(CTX, "?unknown source?");
}
if (duk_pcompile_lstring_filename(CTX, DUK_COMPILE_EVAL, txt, txtlen) != 0) {
if (duk_pcompile_lstring_filename(CTX,
DUK_COMPILE_EVAL,
(const char *)txt,
txtlen) != 0) {
NSLOG(dukky, INFO, "Failed to compile JavaScript input");
goto handle_error;
}

View File

@ -67,7 +67,7 @@ void js_destroycontext(jscontext *ctx);
jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv);
/* execute some javascript in a context */
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen, const char *name);
bool js_exec(jscontext *ctx, const uint8_t *txt, size_t txtlen, const char *name);
/* fire an event at a dom node */

View File

@ -51,7 +51,7 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
return NULL;
}
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen, const char *name)
bool js_exec(jscontext *ctx, const uint8_t *txt, size_t txtlen, const char *name)
{
return true;
}

View File

@ -554,8 +554,8 @@ static nserror textplain_clone(const struct content *old, struct content **newc)
const textplain_content *old_text = (textplain_content *) old;
textplain_content *text;
nserror error;
const char *data;
unsigned long size;
const uint8_t *data;
size_t size;
text = calloc(1, sizeof(textplain_content));
if (text == NULL)
@ -576,7 +576,9 @@ static nserror textplain_clone(const struct content *old, struct content **newc)
data = content__get_source_data(&text->base, &size);
if (size > 0) {
if (textplain_process_data(&text->base, data, size) == false) {
if (textplain_process_data(&text->base,
(const char *)data,
size) == false) {
content_destroy(&text->base);
return NSERROR_NOMEM;
}

View File

@ -152,9 +152,12 @@ static bool save_complete_ctx_has_content(save_complete_ctx *ctx,
return false;
}
static bool save_complete_save_buffer(save_complete_ctx *ctx,
const char *leafname, const char *data, size_t data_len,
lwc_string *mime_type)
static bool
save_complete_save_buffer(save_complete_ctx *ctx,
const char *leafname,
const uint8_t *data,
size_t data_len,
lwc_string *mime_type)
{
nserror ret;
FILE *fp;
@ -196,14 +199,14 @@ static bool save_complete_save_buffer(save_complete_ctx *ctx,
* \param osize updated with the size of the result.
* \return converted source, or NULL on out of memory.
*/
static char *
static uint8_t *
save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx,
const char *source,
unsigned long size,
const uint8_t *source,
size_t size,
const nsurl *base,
unsigned long *osize)
size_t *osize)
{
char *rewritten;
uint8_t *rewritten;
unsigned long offset = 0;
unsigned int imports = 0;
nserror error;
@ -231,13 +234,16 @@ save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx,
offset = 0;
while (offset < size) {
const char *import_url = NULL;
const uint8_t *import_url = NULL;
char *import_url_copy;
int import_url_len = 0;
nsurl *url = NULL;
regmatch_t match[11];
int m = regexec(&save_complete_import_re, source + offset,
11, match, 0);
int m = regexec(&save_complete_import_re,
(const char *)source + offset,
11,
match,
0);
if (m)
break;
@ -259,7 +265,8 @@ save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx,
}
assert(import_url != NULL);
import_url_copy = strndup(import_url, import_url_len);
import_url_copy = strndup((const char *)import_url,
import_url_len);
if (import_url_copy == NULL) {
free(rewritten);
return NULL;
@ -315,13 +322,13 @@ save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx,
return rewritten;
}
static bool save_complete_save_stylesheet(save_complete_ctx *ctx,
hlcache_handle *css)
static bool
save_complete_save_stylesheet(save_complete_ctx *ctx, hlcache_handle *css)
{
const char *css_data;
unsigned long css_size;
char *source;
unsigned long source_len;
const uint8_t *css_data;
size_t css_size;
uint8_t *source;
size_t source_len;
struct nscss_import *imports;
uint32_t import_count;
lwc_string *type;
@ -342,8 +349,12 @@ static bool save_complete_save_stylesheet(save_complete_ctx *ctx,
return false;
css_data = content_get_source_data(css, &css_size);
source = save_complete_rewrite_stylesheet_urls(ctx, css_data, css_size,
hlcache_handle_get_url(css), &source_len);
source = save_complete_rewrite_stylesheet_urls(
ctx,
css_data,
css_size,
hlcache_handle_get_url(css),
&source_len);
if (source == NULL) {
guit->misc->warning("NoMemory", 0);
return false;
@ -408,11 +419,11 @@ static bool save_complete_save_html_stylesheets(save_complete_ctx *ctx,
return true;
}
static bool save_complete_save_html_object(save_complete_ctx *ctx,
hlcache_handle *obj)
static bool
save_complete_save_html_object(save_complete_ctx *ctx, hlcache_handle *obj)
{
const char *obj_data;
unsigned long obj_size;
const uint8_t *obj_data;
size_t obj_size;
lwc_string *type;
bool result;
char filename[32];
@ -898,13 +909,13 @@ static bool save_complete_handle_element(save_complete_ctx *ctx,
}
if (content != NULL) {
char *rewritten;
unsigned long len;
uint8_t *rewritten;
size_t len;
/* Rewrite @import rules */
rewritten = save_complete_rewrite_stylesheet_urls(
ctx,
dom_string_data(content),
(const uint8_t *)dom_string_data(content),
dom_string_byte_length(content),
ctx->base,
&len);

View File

@ -346,8 +346,6 @@ RXHOOKF(rx_open)
RXHOOKF(rx_save)
{
BPTR fh = 0;
ULONG source_size;
const char *source_data;
struct gui_window *gw = cur_gw;
cmd->ac_RC = 0;
@ -361,9 +359,13 @@ RXHOOKF(rx_save)
if((fh = FOpen((char *)cmd->ac_ArgList[0], MODE_NEWFILE, 0)))
{
const uint8_t *source_data;
size_t source_size;
struct hlcache_handle *h = browser_window_get_content(gw->bw);
if((source_data = content_get_source_data(h, &source_size)))
source_data = content_get_source_data(h, &source_size);
if (source_data != NULL) {
FWrite(fh, source_data, 1, source_size);
}
FClose(fh);
SetComment((char *)cmd->ac_ArgList[0], nsurl_access(browser_window_access_url(gw->bw)));

View File

@ -349,15 +349,22 @@ bool ami_easy_clipboard_bitmap(struct bitmap *bitmap)
#ifdef WITH_NS_SVG
bool ami_easy_clipboard_svg(struct hlcache_handle *c)
{
const char *source_data;
ULONG source_size;
const uint8_t *source_data;
size_t source_size;
if(ami_mime_compare(c, "svg") == false) return false;
if((source_data = content_get_source_data(c, &source_size)) == NULL) return false;
if (ami_mime_compare(c, "svg") == false) {
return false;
}
source_data = content_get_source_data(c, &source_size);
if (source_data == NULL) {
return false;
}
if(!(OpenIFF(iffh,IFFF_WRITE)))
{
ami_svg_to_dr2d(iffh, source_data, source_size, nsurl_access(hlcache_handle_get_url(c)));
if (!(OpenIFF(iffh,IFFF_WRITE))) {
ami_svg_to_dr2d(iffh,
(const char *)source_data,
source_size,
nsurl_access(hlcache_handle_get_url(c)));
CloseIFF(iffh);
}

View File

@ -167,15 +167,15 @@ bool amiga_dt_anim_convert(struct content *c)
amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c;
union content_msg_data msg_data;
int width, height;
const uint8 *data;
const uint8_t *data;
size_t size;
UBYTE *bm_buffer;
ULONG size;
struct BitMapHeader *bmh;
unsigned int bm_flags = BITMAP_NEW | BITMAP_OPAQUE;
struct adtFrame adt_frame;
APTR clut;
data = (uint8 *)content__get_source_data(c, &size);
data = content__get_source_data(c, &size);
if((plugin->dto = NewDTObject(NULL,
DTA_SourceType, DTST_MEMORY,

View File

@ -131,11 +131,11 @@ nserror amiga_dt_picture_create(const content_handler *handler,
static Object *amiga_dt_picture_newdtobject(struct amiga_dt_picture_content *adt)
{
const uint8 *data;
ULONG size;
const uint8_t *data;
size_t size;
if(adt->dto == NULL) {
data = (uint8 *)content__get_source_data((struct content *)adt, &size);
data = content__get_source_data((struct content *)adt, &size);
adt->dto = NewDTObject(NULL,
DTA_SourceType, DTST_MEMORY,
@ -152,12 +152,12 @@ static Object *amiga_dt_picture_newdtobject(struct amiga_dt_picture_content *adt
static char *amiga_dt_picture_datatype(struct content *c)
{
const uint8 *data;
ULONG size;
const uint8_t *data;
size_t size;
struct DataType *dt;
char *filetype = NULL;
data = (uint8 *)content__get_source_data(c, &size);
data = content__get_source_data(c, &size);
if((dt = ObtainDataType(DTST_MEMORY, NULL,
DTA_SourceAddress, data,

View File

@ -150,10 +150,10 @@ bool amiga_dt_sound_convert(struct content *c)
amiga_dt_sound_content *plugin = (amiga_dt_sound_content *) c;
int width = 50, height = 50;
const uint8 *data;
ULONG size;
const uint8_t *data;
size_t size;
data = (uint8 *)content__get_source_data(c, &size);
data = content__get_source_data(c, &size);
plugin->dto = NewDTObject(NULL,
DTA_SourceType, DTST_MEMORY,

View File

@ -146,8 +146,9 @@ void ami_file_save(int type, char *fname, struct Window *win,
struct browser_window *bw)
{
BPTR lock, fh;
const char *source_data;
ULONG source_size;
const uint8_t *source_data;
char *selection;
size_t source_size;
struct bitmap *bm;
ami_update_pointer(win, GUI_POINTER_WAIT);
@ -155,7 +156,8 @@ void ami_file_save(int type, char *fname, struct Window *win,
if(ami_download_check_overwrite(fname, win, 0)) {
switch(type) {
case AMINS_SAVE_SOURCE:
if((source_data = content_get_source_data(object, &source_size))) {
source_data = content_get_source_data(object, &source_size);
if(source_data) {
BPTR fh;
if((fh = FOpen(fname, MODE_NEWFILE,0))) {
FWrite(fh, source_data, 1, source_size);
@ -197,12 +199,17 @@ void ami_file_save(int type, char *fname, struct Window *win,
break;
case AMINS_SAVE_SELECTION:
if((source_data = browser_window_get_selection(bw))) {
if((fh = FOpen(fname, MODE_NEWFILE,0))) {
FWrite(fh, source_data, 1, strlen(source_data));
selection = browser_window_get_selection(bw);
if(selection) {
fh = FOpen(fname, MODE_NEWFILE,0);
if (fh) {
FWrite(fh,
selection,
1,
strlen(selection));
FClose(fh);
}
free((void *)source_data);
free(selection);
}
break;
}

View File

@ -310,22 +310,27 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
bool ami_save_svg(struct hlcache_handle *c,char *filename)
{
struct IFFHandle *iffh;
const char *source_data;
ULONG source_size;
const uint8_t *source_data;
size_t source_size;
if(!ami_download_check_overwrite(filename, NULL, 0)) return false;
if (!ami_download_check_overwrite(filename, NULL, 0)) return false;
if((iffh = AllocIFF())) {
if((iffh->iff_Stream = Open(filename,MODE_NEWFILE))) {
if ((iffh = AllocIFF())) {
if ((iffh->iff_Stream = Open(filename,MODE_NEWFILE))) {
InitIFFasDOS(iffh);
}
else return false;
}
if((OpenIFF(iffh,IFFF_WRITE))) return false;
if ((OpenIFF(iffh,IFFF_WRITE))) return false;
if((source_data = content_get_source_data(c, &source_size)))
ami_svg_to_dr2d(iffh, source_data, source_size, nsurl_access(hlcache_handle_get_url(c)));
source_data = content_get_source_data(c, &source_size);
if (source_data != NULL) {
ami_svg_to_dr2d(iffh,
(const char *)source_data,
source_size,
nsurl_access(hlcache_handle_get_url(c)));
}
if(iffh) CloseIFF(iffh);
if(iffh->iff_Stream) Close((BPTR)iffh->iff_Stream);

View File

@ -34,8 +34,8 @@ nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
{
nserror ret;
struct hlcache_handle *hlcontent;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
char *ndata = NULL;
size_t ndata_len;
char *filename;
@ -67,8 +67,9 @@ nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
}
sprintf(title, "Source of %s - NetSurf", nsurl_access(browser_window_access_url(bw)));
ret = utf8_from_enc(source_data,
content_get_encoding(hlcontent, CONTENT_ENCODING_NORMAL),
ret = utf8_from_enc((const char *)source_data,
content_get_encoding(hlcontent,
CONTENT_ENCODING_NORMAL),
source_size,
&ndata,
&ndata_len);

View File

@ -170,8 +170,8 @@ bool artworks_convert(struct content *c)
{
artworks_content *aw = (artworks_content *) c;
union content_msg_data msg_data;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
void *init_workspace;
void *init_routine;
os_error *error;
@ -224,7 +224,7 @@ bool artworks_convert(struct content *c)
source_data = content__get_source_data(c, &source_size);
/* initialise (convert file to new format if required) */
error = awrender_init(&source_data, &source_size,
error = awrender_init((const char **)&source_data, &source_size,
init_routine, init_workspace);
if (error) {
NSLOG(netsurf, INFO, "awrender_init: 0x%x : %s",
@ -313,8 +313,8 @@ bool artworks_redraw(struct content *c, struct content_redraw_data *data,
};
artworks_content *aw = (artworks_content *) c;
struct awinfo_block info;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
os_error *error;
os_trfm matrix;
int vals[24];
@ -389,17 +389,17 @@ bool artworks_redraw(struct content *c, struct content_redraw_data *data,
source_data = content__get_source_data(c, &source_size);
error = awrender_render(source_data,
&info,
&matrix,
vals,
&aw->block,
&aw->size,
110, /* fully anti-aliased */
0,
source_size,
aw->render_routine,
aw->render_workspace);
error = awrender_render((const char *)source_data,
&info,
&matrix,
vals,
&aw->block,
&aw->size,
110, /* fully anti-aliased */
0,
source_size,
aw->render_routine,
aw->render_workspace);
if (error) {
NSLOG(netsurf, INFO, "awrender_render: 0x%x: %s",

View File

@ -112,8 +112,8 @@ bool draw_convert(struct content *c)
{
draw_content *draw = (draw_content *) c;
union content_msg_data msg_data;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
const void *data;
os_box bbox;
os_error *error;
@ -180,8 +180,8 @@ bool draw_redraw(struct content *c, struct content_redraw_data *data,
{
draw_content *draw = (draw_content *) c;
os_trfm matrix;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
const void *src_data;
os_error *error;

View File

@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
/**
* \file
* Content for image/x-riscos-sprite (RISC OS implementation).
*
* No conversion is necessary: we can render RISC OS sprites directly under
@ -112,8 +113,8 @@ bool sprite_convert(struct content *c)
os_error *error;
int w, h;
union content_msg_data msg_data;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
const void *sprite_data;
char *title;

View File

@ -1980,8 +1980,8 @@ void ro_gui_view_source(struct hlcache_handle *c)
int objtype;
bool done = false;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
if (!c) {
ro_warn_user("MiscError", "No document source");

View File

@ -908,8 +908,8 @@ static bool ro_gui_save_object_native(struct hlcache_handle *h, char *path)
if (file_type == osfile_TYPE_SPRITE || file_type == osfile_TYPE_DRAW) {
/* Native sprite or drawfile */
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
os_error *error;
source_data = content_get_source_data(h, &source_size);
@ -960,8 +960,8 @@ static bool
ro_gui_save_content(struct hlcache_handle *h, char *path, bool force_overwrite)
{
os_error *error;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
/* does the user want to check for collisions when saving? */
if (!force_overwrite) {

View File

@ -47,8 +47,6 @@ wimp_w dialog_theme_install;
static void theme_install_close(wimp_w w);
static nserror theme_install_callback(struct hlcache_handle *handle,
const hlcache_event *event, void *pw);
static bool theme_install_read(const char *source_data,
unsigned long source_size);
/**
@ -79,6 +77,33 @@ void theme_install_start(struct hlcache_handle *c)
}
/**
* Fill in theme_install_descriptor from received theme data.
*
* \param source_data received data
* \param source_size size of data
* \return true if data is a correct theme, false on error
*
* If the data is a correct theme, theme_install_descriptor is filled in.
*/
static bool
theme_install_read(const uint8_t *source_data, size_t source_size)
{
const void *data = source_data;
if (source_size < sizeof(struct theme_file_header))
return false;
if (!ro_gui_theme_read_file_header(&theme_install_descriptor,
(struct theme_file_header *) data))
return false;
if (source_size - sizeof(struct theme_file_header) !=
theme_install_descriptor.compressed_size)
return false;
return true;
}
/**
* Callback for fetchcache() for theme install fetches.
*/
@ -90,8 +115,8 @@ nserror theme_install_callback(struct hlcache_handle *handle,
case CONTENT_MSG_DONE:
{
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
int author_indent = 0;
char buffer[256];
@ -135,30 +160,6 @@ nserror theme_install_callback(struct hlcache_handle *handle,
}
/**
* Fill in theme_install_descriptor from received theme data.
*
* \param source_data received data
* \param source_size size of data
* \return true if data is a correct theme, false on error
*
* If the data is a correct theme, theme_install_descriptor is filled in.
*/
bool theme_install_read(const char *source_data, unsigned long source_size)
{
const void *data = source_data;
if (source_size < sizeof(struct theme_file_header))
return false;
if (!ro_gui_theme_read_file_header(&theme_install_descriptor,
(struct theme_file_header *) data))
return false;
if (source_size - sizeof(struct theme_file_header) !=
theme_install_descriptor.compressed_size)
return false;
return true;
}
/**
@ -174,8 +175,8 @@ bool ro_gui_theme_install_apply(wimp_w w)
struct theme_descriptor *theme_install;
os_error *error;
char *fix;
const char *source_data;
unsigned long source_size;
const uint8_t *source_data;
size_t source_size;
assert(theme_install_content);

View File

@ -94,7 +94,7 @@ lwc_string *content_get_mime_type(struct hlcache_handle *h);
* \param size Pointer to location to receive byte size of source
* \return Pointer to source data
*/
const char *content_get_source_data(struct hlcache_handle *h, unsigned long *size);
const uint8_t *content_get_source_data(struct hlcache_handle *h, size_t *size);
/**