From aedd9b55132bb48f6d25ae4c080dc0ce71efb44d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Mon, 21 Aug 2017 02:29:58 +0200 Subject: Fix bug 0002555: "No GC" alert when resizing the window We don't need to touch the GC when invalidating anyway, so just drop those calls. --- frontends/beos/window.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp index 8acb20a37..fde818df2 100644 --- a/frontends/beos/window.cpp +++ b/frontends/beos/window.cpp @@ -1000,8 +1000,6 @@ beos_window_invalidate_area(struct gui_window *g, const struct rect *rect) return NSERROR_OK; } - nsbeos_current_gc_set(g->view); - if (rect != NULL) { //XXX +1 ?? g->view->Invalidate(BRect(rect->x0, rect->y0, @@ -1010,7 +1008,6 @@ beos_window_invalidate_area(struct gui_window *g, const struct rect *rect) g->view->Invalidate(); } - nsbeos_current_gc_set(NULL); g->view->UnlockLooper(); return NSERROR_OK; -- cgit v1.2.1 From d70beb28db6f978ae9fc674640f3101e20c05bb8 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 26 Aug 2017 15:50:03 +0100 Subject: Content API: Make content_broadcast take pointer to content_msg_data. --- content/content.c | 32 +++++++++++++++------------- content/content_protected.h | 2 +- content/handlers/css/css.c | 8 +++---- content/handlers/image/bmp.c | 6 +++--- content/handlers/image/gif.c | 8 +++---- content/handlers/image/ico.c | 6 +++--- content/handlers/image/jpeg.c | 2 +- content/handlers/image/nssprite.c | 4 ++-- content/handlers/image/png.c | 8 +++---- content/handlers/image/rsvg.c | 12 +++++------ content/handlers/image/svg.c | 2 +- frontends/amiga/dt_anim.c | 2 +- frontends/amiga/dt_picture.c | 2 +- frontends/amiga/icon.c | 8 +++---- frontends/riscos/content-handlers/artworks.c | 14 ++++++------ frontends/riscos/content-handlers/draw.c | 2 +- frontends/riscos/content-handlers/sprite.c | 4 ++-- render/html.c | 9 ++++---- render/html_interaction.c | 31 ++++++++++++++------------- render/html_object.c | 10 ++++----- render/html_script.c | 8 +++---- render/search.c | 4 ++-- render/textplain.c | 8 +++---- 23 files changed, 98 insertions(+), 94 deletions(-) diff --git a/content/content.c b/content/content.c index 7a8bb013f..b53d2cb52 100644 --- a/content/content.c +++ b/content/content.c @@ -163,7 +163,7 @@ nserror content_llcache_callback(llcache_handle *llcache, content_set_status(c, messages_get("Processing")); msg_data.explicit_status_text = NULL; - content_broadcast(c, CONTENT_MSG_STATUS, msg_data); + content_broadcast(c, CONTENT_MSG_STATUS, &msg_data); content_convert(c); } @@ -172,17 +172,17 @@ nserror content_llcache_callback(llcache_handle *llcache, /** \todo Error page? */ c->status = CONTENT_STATUS_ERROR; msg_data.error = event->data.msg; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); break; case LLCACHE_EVENT_PROGRESS: content_set_status(c, event->data.msg); msg_data.explicit_status_text = NULL; - content_broadcast(c, CONTENT_MSG_STATUS, msg_data); + content_broadcast(c, CONTENT_MSG_STATUS, &msg_data); break; case LLCACHE_EVENT_REDIRECT: msg_data.redirect.from = event->data.redirect.from; msg_data.redirect.to = event->data.redirect.to; - content_broadcast(c, CONTENT_MSG_REDIRECT, msg_data); + content_broadcast(c, CONTENT_MSG_REDIRECT, &msg_data); break; } @@ -292,8 +292,6 @@ void content_convert(struct content *c) void content_set_ready(struct content *c) { - union content_msg_data msg_data; - /* The content must be locked at this point, as it can only * become READY after conversion. */ assert(c->locked); @@ -301,7 +299,7 @@ void content_set_ready(struct content *c) c->status = CONTENT_STATUS_READY; content_update_status(c); - content_broadcast(c, CONTENT_MSG_READY, msg_data); + content_broadcast(c, CONTENT_MSG_READY, NULL); } /** @@ -310,7 +308,6 @@ void content_set_ready(struct content *c) void content_set_done(struct content *c) { - union content_msg_data msg_data; uint64_t now_ms; nsu_getmonotonic_ms(&now_ms); @@ -318,7 +315,7 @@ void content_set_done(struct content *c) c->status = CONTENT_STATUS_DONE; c->time = now_ms - c->time; content_update_status(c); - content_broadcast(c, CONTENT_MSG_DONE, msg_data); + content_broadcast(c, CONTENT_MSG_DONE, NULL); } /** @@ -363,7 +360,7 @@ void content__reformat(struct content *c, bool background, c->locked = false; data.background = background; - content_broadcast(c, CONTENT_MSG_REFORMAT, data); + content_broadcast(c, CONTENT_MSG_REFORMAT, &data); } } @@ -436,7 +433,7 @@ void content_mouse_track(hlcache_handle *h, struct browser_window *bw, } else { union content_msg_data msg_data; msg_data.pointer = BROWSER_POINTER_AUTO; - content_broadcast(c, CONTENT_MSG_POINTER, msg_data); + content_broadcast(c, CONTENT_MSG_POINTER, &msg_data); } @@ -540,7 +537,7 @@ void content__request_redraw(struct content *c, data.redraw.object_width = c->width; data.redraw.object_height = c->height; - content_broadcast(c, CONTENT_MSG_REDRAW, data); + content_broadcast(c, CONTENT_MSG_REDRAW, &data); } @@ -753,15 +750,20 @@ bool content_is_shareable(struct content *c) */ void content_broadcast(struct content *c, content_msg msg, - union content_msg_data data) + const union content_msg_data *data) { struct content_user *user, *next; + union content_msg_data d = { 0 }; assert(c); + + if (data != NULL) { + d = *data; + } // LOG("%p -> msg:%d", c, msg); for (user = c->user_list->next; user != 0; user = next) { next = user->next; /* user may be destroyed during callback */ if (user->callback != 0) - user->callback(c, msg, data, user->pw); + user->callback(c, msg, d, user->pw); } } @@ -1040,7 +1042,7 @@ bool content__add_rfc5988_link(struct content *c, /* broadcast the data */ msg_data.rfc5988_link = newlink; - content_broadcast(c, CONTENT_MSG_LINK, msg_data); + content_broadcast(c, CONTENT_MSG_LINK, &msg_data); return true; } diff --git a/content/content_protected.h b/content/content_protected.h index ef38cb12d..fe4fcdade 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -166,7 +166,7 @@ void content_set_error(struct content *c); void content_set_status(struct content *c, const char *status_message); void content_broadcast(struct content *c, content_msg msg, - union content_msg_data data); + const union content_msg_data *data); /** * Send an errorcode message to all users. */ diff --git a/content/handlers/css/css.c b/content/handlers/css/css.c index 997eb5115..a665fbdc4 100644 --- a/content/handlers/css/css.c +++ b/content/handlers/css/css.c @@ -172,7 +172,7 @@ nscss_create(const content_handler *handler, nscss_content_done, result); if (error != NSERROR_OK) { msg_data.error = messages_get("NoMemory"); - content_broadcast(&result->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&result->base, CONTENT_MSG_ERROR, &msg_data); if (charset_value != NULL) lwc_string_unref(charset_value); free(result); @@ -256,7 +256,7 @@ bool nscss_process_data(struct content *c, const char *data, unsigned int size) error = nscss_process_css_data(&css->data, data, size); if (error != CSS_OK && error != CSS_NEEDDATA) { msg_data.error = "?"; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); } return (error == CSS_OK || error == CSS_NEEDDATA); @@ -292,7 +292,7 @@ bool nscss_convert(struct content *c) error = nscss_convert_css_data(&css->data); if (error != CSS_OK) { msg_data.error = "?"; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -485,7 +485,7 @@ void nscss_content_done(struct content_css_data *css, void *pw) error = css_stylesheet_size(css->sheet, &size); if (error != CSS_OK) { msg_data.error = "?"; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); content_set_error(c); return; } diff --git a/content/handlers/image/bmp.c b/content/handlers/image/bmp.c index 271787449..47c1d0845 100644 --- a/content/handlers/image/bmp.c +++ b/content/handlers/image/bmp.c @@ -80,7 +80,7 @@ static nserror nsbmp_create_bmp_data(nsbmp_content *bmp) bmp->bmp = calloc(sizeof(struct bmp_image), 1); if (bmp->bmp == NULL) { msg_data.error = messages_get("NoMemory"); - content_broadcast(&bmp->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&bmp->base, CONTENT_MSG_ERROR, &msg_data); return NSERROR_NOMEM; } @@ -139,12 +139,12 @@ static bool nsbmp_convert(struct content *c) break; case BMP_INSUFFICIENT_MEMORY: msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; case BMP_INSUFFICIENT_DATA: case BMP_DATA_ERROR: msg_data.error = messages_get("BadBMP"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } diff --git a/content/handlers/image/gif.c b/content/handlers/image/gif.c index c4f039490..9184f31ce 100644 --- a/content/handlers/image/gif.c +++ b/content/handlers/image/gif.c @@ -86,7 +86,7 @@ static nserror nsgif_create_gif_data(nsgif_content *c) c->gif = calloc(sizeof(gif_animation), 1); if (c->gif == NULL) { msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); return NSERROR_NOMEM; } gif_create(c->gif, &gif_bitmap_callbacks); @@ -231,7 +231,7 @@ static void nsgif_animate(void *p) data.redraw.object_width = gif->base.width; data.redraw.object_height = gif->base.height; - content_broadcast(&gif->base, CONTENT_MSG_REDRAW, data); + content_broadcast(&gif->base, CONTENT_MSG_REDRAW, &data); } static bool nsgif_convert(struct content *c) @@ -261,7 +261,7 @@ static bool nsgif_convert(struct content *c) msg_data.error = messages_get("NoMemory"); break; } - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } } while (res != GIF_OK && res != GIF_INSUFFICIENT_FRAME_DATA); @@ -270,7 +270,7 @@ static bool nsgif_convert(struct content *c) if ((gif->gif->frame_count_partial == 0) || (gif->gif->width == 0) || (gif->gif->height == 0)) { msg_data.error = messages_get("BadGIF"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } diff --git a/content/handlers/image/ico.c b/content/handlers/image/ico.c index b14ea7fe1..180b20d7e 100644 --- a/content/handlers/image/ico.c +++ b/content/handlers/image/ico.c @@ -77,7 +77,7 @@ static nserror nsico_create_ico_data(nsico_content *c) c->ico = calloc(sizeof(ico_collection), 1); if (c->ico == NULL) { msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); return NSERROR_NOMEM; } ico_collection_create(c->ico, &bmp_bitmap_callbacks); @@ -138,12 +138,12 @@ static bool nsico_convert(struct content *c) break; case BMP_INSUFFICIENT_MEMORY: msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; case BMP_INSUFFICIENT_DATA: case BMP_DATA_ERROR: msg_data.error = messages_get("BadICO"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } diff --git a/content/handlers/image/jpeg.c b/content/handlers/image/jpeg.c index 5ae9e70cd..c5aca1c9b 100644 --- a/content/handlers/image/jpeg.c +++ b/content/handlers/image/jpeg.c @@ -301,7 +301,7 @@ static bool nsjpeg_convert(struct content *c) jpeg_destroy_decompress(&cinfo); msg_data.error = nsjpeg_error_buffer; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index 247574aa4..ab48978e9 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -119,13 +119,13 @@ static bool nssprite_convert(struct content *c) nssprite->bitmap = guit->bitmap->create(sprite->width, sprite->height, BITMAP_NEW); if (!nssprite->bitmap) { msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } uint32_t* imagebuf = (uint32_t *)guit->bitmap->get_buffer(nssprite->bitmap); if (!imagebuf) { msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } unsigned char *spritebuf = (unsigned char *)sprite->image; diff --git a/content/handlers/image/png.c b/content/handlers/image/png.c index 0baf411bf..136fd8f73 100644 --- a/content/handlers/image/png.c +++ b/content/handlers/image/png.c @@ -247,7 +247,7 @@ static nserror nspng_create_png_data(nspng_content *png_c) png_c->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); if (png_c->png == NULL) { msg_data.error = messages_get("NoMemory"); - content_broadcast(&png_c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&png_c->base, CONTENT_MSG_ERROR, &msg_data); return NSERROR_NOMEM; } @@ -258,7 +258,7 @@ static nserror nspng_create_png_data(nspng_content *png_c) png_destroy_read_struct(&png_c->png, &png_c->info, 0); msg_data.error = messages_get("NoMemory"); - content_broadcast(&png_c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&png_c->base, CONTENT_MSG_ERROR, &msg_data); return NSERROR_NOMEM; } @@ -269,7 +269,7 @@ static nserror nspng_create_png_data(nspng_content *png_c) png_c->info = NULL; msg_data.error = messages_get("PNGError"); - content_broadcast(&png_c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&png_c->base, CONTENT_MSG_ERROR, &msg_data); return NSERROR_NOMEM; } @@ -363,7 +363,7 @@ static bool nspng_process_data(struct content *c, const char *data, png_c->info = NULL; msg_data.error = messages_get("PNGError"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); ret = false; diff --git a/content/handlers/image/rsvg.c b/content/handlers/image/rsvg.c index 0665f217f..24819df57 100644 --- a/content/handlers/image/rsvg.c +++ b/content/handlers/image/rsvg.c @@ -72,7 +72,7 @@ static nserror rsvg_create_svg_data(rsvg_content *c) if ((c->rsvgh = rsvg_handle_new()) == NULL) { LOG("rsvg_handle_new() returned NULL."); msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); return NSERROR_NOMEM; } @@ -122,7 +122,7 @@ static bool rsvg_process_data(struct content *c, const char *data, &err) == FALSE) { LOG("rsvg_handle_write returned an error: %s", err->message); msg_data.error = err->message; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -168,7 +168,7 @@ static bool rsvg_convert(struct content *c) if (rsvg_handle_close(d->rsvgh, &err) == FALSE) { LOG("rsvg_handle_close returned an error: %s", err->message); msg_data.error = err->message; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -186,7 +186,7 @@ static bool rsvg_convert(struct content *c) BITMAP_NEW)) == NULL) { LOG("Failed to create bitmap for rsvg render."); msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -197,14 +197,14 @@ static bool rsvg_convert(struct content *c) guit->bitmap->get_rowstride(d->bitmap))) == NULL) { LOG("Failed to create Cairo image surface for rsvg render."); msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } if ((d->ct = cairo_create(d->cs)) == NULL) { LOG("Failed to create Cairo drawing context for rsvg render."); msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c index b34c6b7bb..f31ee1f8d 100644 --- a/content/handlers/image/svg.c +++ b/content/handlers/image/svg.c @@ -62,7 +62,7 @@ static nserror svg_create_svg_data(svg_content *c) no_memory: msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); return NSERROR_NOMEM; } diff --git a/frontends/amiga/dt_anim.c b/frontends/amiga/dt_anim.c index 2f998d299..2493c41ee 100644 --- a/frontends/amiga/dt_anim.c +++ b/frontends/amiga/dt_anim.c @@ -190,7 +190,7 @@ bool amiga_dt_anim_convert(struct content *c) plugin->bitmap = amiga_bitmap_create(width, height, bm_flags); if (!plugin->bitmap) { msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } diff --git a/frontends/amiga/dt_picture.c b/frontends/amiga/dt_picture.c index e7f1c9724..73f6c47c1 100644 --- a/frontends/amiga/dt_picture.c +++ b/frontends/amiga/dt_picture.c @@ -187,7 +187,7 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c) bitmap = amiga_bitmap_create(c->width, c->height, BITMAP_NEW); if (!bitmap) { msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return NULL; } diff --git a/frontends/amiga/icon.c b/frontends/amiga/icon.c index 9de040d37..582d355b6 100644 --- a/frontends/amiga/icon.c +++ b/frontends/amiga/icon.c @@ -155,7 +155,7 @@ bool amiga_icon_convert(struct content *c) if(filename == NULL) { msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -167,7 +167,7 @@ bool amiga_icon_convert(struct content *c) if(dobj == NULL) { msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -187,14 +187,14 @@ bool amiga_icon_convert(struct content *c) icon_c->bitmap = amiga_bitmap_create(width, height, BITMAP_NEW); if (!icon_c->bitmap) { msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); if(dobj) FreeDiskObject(dobj); return false; } imagebuf = (ULONG *) amiga_bitmap_get_buffer(icon_c->bitmap); if (!imagebuf) { msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); if(dobj) FreeDiskObject(dobj); return false; } diff --git a/frontends/riscos/content-handlers/artworks.c b/frontends/riscos/content-handlers/artworks.c index 7a7d79cb7..d6f6da318 100644 --- a/frontends/riscos/content-handlers/artworks.c +++ b/frontends/riscos/content-handlers/artworks.c @@ -185,7 +185,7 @@ bool artworks_convert(struct content *c) if (used >= 0) { LOG("Alias$LoadArtWorksModules not defined"); msg_data.error = messages_get("AWNotSeen"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -194,7 +194,7 @@ bool artworks_convert(struct content *c) if (error) { LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess); msg_data.error = error->errmess; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -204,7 +204,7 @@ bool artworks_convert(struct content *c) if (error) { LOG("AWRender_FileInitAddress: 0x%x: %s", error->errnum, error->errmess); msg_data.error = error->errmess; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -214,7 +214,7 @@ bool artworks_convert(struct content *c) if (error) { LOG("AWRender_RenderAddress: 0x%x: %s", error->errnum, error->errmess); msg_data.error = error->errmess; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -226,7 +226,7 @@ bool artworks_convert(struct content *c) if (error) { LOG("awrender_init: 0x%x : %s", error->errnum, error->errmess); msg_data.error = error->errmess; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -241,7 +241,7 @@ bool artworks_convert(struct content *c) if (error) { LOG("AWRender_DocBounds: 0x%x: %s", error->errnum, error->errmess); msg_data.error = error->errmess; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -255,7 +255,7 @@ bool artworks_convert(struct content *c) if (!aw->block) { LOG("failed to create block for ArtworksRenderer"); msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } diff --git a/frontends/riscos/content-handlers/draw.c b/frontends/riscos/content-handlers/draw.c index 0c84de866..4627b19c0 100644 --- a/frontends/riscos/content-handlers/draw.c +++ b/frontends/riscos/content-handlers/draw.c @@ -128,7 +128,7 @@ bool draw_convert(struct content *c) if (error) { LOG("xdrawfile_bbox: 0x%x: %s", error->errnum, error->errmess); msg_data.error = error->errmess; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } diff --git a/frontends/riscos/content-handlers/sprite.c b/frontends/riscos/content-handlers/sprite.c index 02976e48e..5cbade4e5 100644 --- a/frontends/riscos/content-handlers/sprite.c +++ b/frontends/riscos/content-handlers/sprite.c @@ -126,7 +126,7 @@ bool sprite_convert(struct content *c) /* check for bad data */ if ((int)source_size + 4 != area->used) { msg_data.error = messages_get("BadSprite"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -137,7 +137,7 @@ bool sprite_convert(struct content *c) if (error) { LOG("xosspriteop_read_sprite_info: 0x%x: %s", error->errnum, error->errmess); msg_data.error = error->errmess; - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } diff --git a/render/html.c b/render/html.c index a573ef5f5..62dec9e95 100644 --- a/render/html.c +++ b/render/html.c @@ -443,7 +443,7 @@ static nserror html_meta_refresh_process_element(html_content *c, dom_node *n) c->base.refresh = nsurl_ref( content_get_url(&c->base)); - content_broadcast(&c->base, CONTENT_MSG_REFRESH, msg_data); + content_broadcast(&c->base, CONTENT_MSG_REFRESH, &msg_data); return NSERROR_OK; } @@ -522,7 +522,8 @@ static nserror html_meta_refresh_process_element(html_content *c, dom_node *n) c->base.refresh = nsurl; - content_broadcast(&c->base, CONTENT_MSG_REFRESH, msg_data); + content_broadcast(&c->base, CONTENT_MSG_REFRESH, + &msg_data); c->refresh = true; } @@ -603,7 +604,7 @@ void html_finish_conversion(html_content *htmlc) LOG("DOM to box (%p)", htmlc); content_set_status(&htmlc->base, messages_get("Processing")); msg_data.explicit_status_text = NULL; - content_broadcast(&htmlc->base, CONTENT_MSG_STATUS, msg_data); + content_broadcast(&htmlc->base, CONTENT_MSG_STATUS, &msg_data); exc = dom_document_get_document_element(htmlc->document, (void *) &html); if ((exc != DOM_NO_ERR) || (html == NULL)) { @@ -685,7 +686,7 @@ dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw) msg_data.jscontext = &htmlc->jscontext; content_broadcast(&htmlc->base, CONTENT_MSG_GETCTX, - msg_data); + &msg_data); LOG("javascript context: %p (htmlc: %p)", htmlc->jscontext, htmlc); diff --git a/render/html_interaction.c b/render/html_interaction.c index e727a9ffc..1ae9801c6 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -368,7 +368,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, mouse, x - box_x, y - box_y); if (status != NULL) { msg_data.explicit_status_text = status; - content_broadcast(c, CONTENT_MSG_STATUS, msg_data); + content_broadcast(c, CONTENT_MSG_STATUS, &msg_data); } else { int width, height; form_select_get_dimensions(html->visible_select_menu, @@ -459,7 +459,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, } msg_data.explicit_status_text = status; - content_broadcast(c, CONTENT_MSG_STATUS, msg_data); + content_broadcast(c, CONTENT_MSG_STATUS, &msg_data); return; } @@ -678,7 +678,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, } else if (mouse & BROWSER_MOUSE_CLICK_1) { msg_data.select_menu.gadget = gadget; content_broadcast(c, CONTENT_MSG_SELECTMENU, - msg_data); + &msg_data); } break; case GADGET_CHECKBOX: @@ -768,7 +768,8 @@ void html_mouse_action(struct content *c, struct browser_window *bw, status = messages_get("FormFile"); if (mouse & BROWSER_MOUSE_CLICK_1) { msg_data.gadget_click.gadget = gadget; - content_broadcast(c, CONTENT_MSG_GADGETCLICK, msg_data); + content_broadcast(c, CONTENT_MSG_GADGETCLICK, + &msg_data); } break; case GADGET_BUTTON: @@ -782,12 +783,12 @@ void html_mouse_action(struct content *c, struct browser_window *bw, if (mouse & BROWSER_MOUSE_DRAG_2) { msg_data.dragsave.type = CONTENT_SAVE_NATIVE; msg_data.dragsave.content = object; - content_broadcast(c, CONTENT_MSG_DRAGSAVE, msg_data); + content_broadcast(c, CONTENT_MSG_DRAGSAVE, &msg_data); } else if (mouse & BROWSER_MOUSE_DRAG_1) { msg_data.dragsave.type = CONTENT_SAVE_ORIG; msg_data.dragsave.content = object; - content_broadcast(c, CONTENT_MSG_DRAGSAVE, msg_data); + content_broadcast(c, CONTENT_MSG_DRAGSAVE, &msg_data); } /* \todo should have a drag-saving object msg */ @@ -869,7 +870,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, mouse & BROWSER_MOUSE_MOD_1) { msg_data.savelink.url = url; msg_data.savelink.title = title; - content_broadcast(c, CONTENT_MSG_SAVELINK, msg_data); + content_broadcast(c, CONTENT_MSG_SAVELINK, &msg_data); } else if (mouse & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) @@ -968,7 +969,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, msg_data.dragsave.content = NULL; content_broadcast(c, CONTENT_MSG_DRAGSAVE, - msg_data); + &msg_data); } else { if (drag_candidate == NULL) { browser_window_page_drag_start( @@ -988,7 +989,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, msg_data.dragsave.content = NULL; content_broadcast(c, CONTENT_MSG_DRAGSAVE, - msg_data); + &msg_data); } else { if (drag_candidate == NULL) { browser_window_page_drag_start( @@ -1013,10 +1014,10 @@ void html_mouse_action(struct content *c, struct browser_window *bw, if (!iframe && !html_object_box) { msg_data.explicit_status_text = status; - content_broadcast(c, CONTENT_MSG_STATUS, msg_data); + content_broadcast(c, CONTENT_MSG_STATUS, &msg_data); msg_data.pointer = pointer; - content_broadcast(c, CONTENT_MSG_POINTER, msg_data); + content_broadcast(c, CONTENT_MSG_POINTER, &msg_data); } /* fire dom click event */ @@ -1217,7 +1218,7 @@ void html_overflow_scroll_callback(void *client_data, html_set_drag_type(html, drag_type, drag_owner, NULL); msg_data.pointer = BROWSER_POINTER_AUTO; - content_broadcast(data->c, CONTENT_MSG_POINTER, msg_data); + content_broadcast(data->c, CONTENT_MSG_POINTER, &msg_data); break; } } @@ -1292,7 +1293,7 @@ void html_set_drag_type(html_content *html, html_drag_type drag_type, msg_data.drag.rect = rect; /* Inform of the content's drag status change */ - content_broadcast((struct content *)html, CONTENT_MSG_DRAG, msg_data); + content_broadcast((struct content *)html, CONTENT_MSG_DRAG, &msg_data); } /* Documented in html_internal.h */ @@ -1350,7 +1351,7 @@ void html_set_focus(html_content *html, html_focus_type focus_type, } /* Inform of the content's drag status change */ - content_broadcast((struct content *)html, CONTENT_MSG_CARET, msg_data); + content_broadcast((struct content *)html, CONTENT_MSG_CARET, &msg_data); } /* Documented in html_internal.h */ @@ -1426,5 +1427,5 @@ void html_set_selection(html_content *html, html_selection_type selection_type, /* Inform of the content's selection status change */ content_broadcast((struct content *)html, CONTENT_MSG_SELECTION, - msg_data); + &msg_data); } diff --git a/render/html_object.c b/render/html_object.c index e20cd6d63..12780ca8b 100644 --- a/render/html_object.c +++ b/render/html_object.c @@ -177,7 +177,7 @@ html_object_callback(hlcache_handle *object, data.redraw.height = box->height; data.redraw.full_redraw = true; - content_broadcast(&c->base, CONTENT_MSG_REDRAW, data); + content_broadcast(&c->base, CONTENT_MSG_REDRAW, &data); } break; @@ -276,7 +276,7 @@ html_object_callback(hlcache_handle *object, data.redraw.object_y += y; content_broadcast(&c->base, - CONTENT_MSG_REDRAW, data); + CONTENT_MSG_REDRAW, &data); break; } else { @@ -315,7 +315,7 @@ html_object_callback(hlcache_handle *object, data.redraw.object_y += y + box->padding[TOP]; } - content_broadcast(&c->base, CONTENT_MSG_REDRAW, data); + content_broadcast(&c->base, CONTENT_MSG_REDRAW, &data); } break; @@ -354,7 +354,7 @@ html_object_callback(hlcache_handle *object, msg_data.dragsave.content = event->data.dragsave.content; - content_broadcast(&c->base, CONTENT_MSG_DRAGSAVE, msg_data); + content_broadcast(&c->base, CONTENT_MSG_DRAGSAVE, &msg_data); } break; @@ -364,7 +364,7 @@ html_object_callback(hlcache_handle *object, case CONTENT_MSG_GADGETCLICK: /* These messages are for browser window layer. * we're not interested, so pass them on. */ - content_broadcast(&c->base, event->type, event->data); + content_broadcast(&c->base, event->type, &event->data); break; case CONTENT_MSG_CARET: diff --git a/render/html_script.c b/render/html_script.c index 37b0564d7..c07e5a372 100644 --- a/render/html_script.c +++ b/render/html_script.c @@ -355,7 +355,7 @@ exec_src_script(html_content *c, ns_error = nsurl_join(c->base_url, dom_string_data(src), &joined); if (ns_error != NSERROR_OK) { msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); return DOM_HUBBUB_NOMEM; } @@ -411,7 +411,7 @@ exec_src_script(html_content *c, if (nscript == NULL) { nsurl_unref(joined); msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); return DOM_HUBBUB_NOMEM; } @@ -483,7 +483,7 @@ exec_inline_script(html_content *c, dom_node *node, dom_string *mimetype) dom_string_unref(script); msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); return DOM_HUBBUB_NOMEM; } @@ -526,7 +526,7 @@ html_process_script(void *ctx, dom_node *node) union content_msg_data msg_data; msg_data.jscontext = &c->jscontext; - content_broadcast(&c->base, CONTENT_MSG_GETCTX, msg_data); + content_broadcast(&c->base, CONTENT_MSG_GETCTX, &msg_data); LOG("javascript context %p ", c->jscontext); if (c->jscontext == NULL) { /* no context and it could not be created, abort */ diff --git a/render/search.c b/render/search.c index 4af6706a0..8f21d8758 100644 --- a/render/search.c +++ b/render/search.c @@ -538,7 +538,7 @@ static void search_text(const char *string, int string_len, msg_data.scroll.y0 = bounds.y0; msg_data.scroll.x1 = bounds.x1; msg_data.scroll.y1 = bounds.y1; - content_broadcast(context->c, CONTENT_MSG_SCROLL, msg_data); + content_broadcast(context->c, CONTENT_MSG_SCROLL, &msg_data); } @@ -571,7 +571,7 @@ void search_step(struct search_context *context, search_flags_t flags, msg_data.scroll.area = false; msg_data.scroll.x0 = 0; msg_data.scroll.y0 = 0; - content_broadcast(context->c, CONTENT_MSG_SCROLL, msg_data); + content_broadcast(context->c, CONTENT_MSG_SCROLL, &msg_data); return; } search_text(string, string_len, context, flags); diff --git a/render/textplain.c b/render/textplain.c index 5d28d9c54..35e3e4ba4 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -186,7 +186,7 @@ textplain_create_internal(textplain_content *c, lwc_string *encoding) no_memory: msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); return NSERROR_NOMEM; } @@ -363,7 +363,7 @@ textplain_process_data(struct content *c, const char *data, unsigned int size) no_memory: msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } @@ -647,10 +647,10 @@ textplain_mouse_action(struct content *c, } msg_data.explicit_status_text = status; - content_broadcast(c, CONTENT_MSG_STATUS, msg_data); + content_broadcast(c, CONTENT_MSG_STATUS, &msg_data); msg_data.pointer = pointer; - content_broadcast(c, CONTENT_MSG_POINTER, msg_data); + content_broadcast(c, CONTENT_MSG_POINTER, &msg_data); } -- cgit v1.2.1 From e94fe1632e743cd75f588b3a031288b92e3ecb3a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 26 Aug 2017 16:38:18 +0100 Subject: Content API: Avoid content message copy in content user callback. --- content/content.c | 32 +++++++++++++++++++------------- content/content.h | 22 ++++++++++++++++++---- content/content_protected.h | 7 +++++-- content/hlcache.c | 8 +++++--- 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/content/content.c b/content/content.c index b53d2cb52..45a4016f0 100644 --- a/content/content.c +++ b/content/content.c @@ -643,9 +643,13 @@ bool content_scaled_redraw(struct hlcache_handle *h, * called with the content. */ -bool content_add_user(struct content *c, - void (*callback)(struct content *c, content_msg msg, - union content_msg_data data, void *pw), +bool content_add_user( + struct content *c, + void (*callback)( + struct content *c, + content_msg msg, + const union content_msg_data *data, + void *pw), void *pw) { struct content_user *user; @@ -673,9 +677,13 @@ bool content_add_user(struct content *c, * content_add_user(). */ -void content_remove_user(struct content *c, - void (*callback)(struct content *c, content_msg msg, - union content_msg_data data, void *pw), +void content_remove_user( + struct content *c, + void (*callback)( + struct content *c, + content_msg msg, + const union content_msg_data *data, + void *pw), void *pw) { struct content_user *user, *next; @@ -753,17 +761,13 @@ void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data) { struct content_user *user, *next; - union content_msg_data d = { 0 }; assert(c); - if (data != NULL) { - d = *data; - } // LOG("%p -> msg:%d", c, msg); for (user = c->user_list->next; user != 0; user = next) { next = user->next; /* user may be destroyed during callback */ if (user->callback != 0) - user->callback(c, msg, d, user->pw); + user->callback(c, msg, data, user->pw); } } @@ -779,8 +783,10 @@ void content_broadcast_errorcode(struct content *c, nserror errorcode) for (user = c->user_list->next; user != 0; user = next) { next = user->next; /* user may be destroyed during callback */ - if (user->callback != 0) - user->callback(c, CONTENT_MSG_ERRORCODE, data, user->pw); + if (user->callback != 0) { + user->callback(c, CONTENT_MSG_ERRORCODE, + &data, user->pw); + } } } diff --git a/content/content.h b/content/content.h index 308b2113b..e555df269 100644 --- a/content/content.h +++ b/content/content.h @@ -200,10 +200,24 @@ union content_msg_data { void content_destroy(struct content *c); -bool content_add_user(struct content *h, void (*callback)(struct content *c, content_msg msg, union content_msg_data data, void *pw), void *pw); - - -void content_remove_user(struct content *c, void (*callback)(struct content *c, content_msg msg, union content_msg_data data, void *pw), void *pw); +bool content_add_user( + struct content *h, + void (*callback)( + struct content *c, + content_msg msg, + const union content_msg_data *data, + void *pw), + void *pw); + + +void content_remove_user( + struct content *c, + void (*callback)( + struct content *c, + content_msg msg, + const union content_msg_data *data, + void *pw), + void *pw); uint32_t content_count_users(struct content *c); diff --git a/content/content_protected.h b/content/content_protected.h index fe4fcdade..21b73a662 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -92,8 +92,11 @@ struct content_handler { /** Linked list of users of a content. */ struct content_user { - void (*callback)(struct content *c, content_msg msg, - union content_msg_data data, void *pw); + void (*callback)( + struct content *c, + content_msg msg, + const union content_msg_data *data, + void *pw); void *pw; struct content_user *next; diff --git a/content/hlcache.c b/content/hlcache.c index 731c0bbb7..38a83eae4 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -179,14 +179,16 @@ static bool hlcache_type_is_acceptable(lwc_string *mime_type, * \param pw Pointer to private data (hlcache_handle) */ static void hlcache_content_callback(struct content *c, content_msg msg, - union content_msg_data data, void *pw) + const union content_msg_data *data, void *pw) { hlcache_handle *handle = pw; - hlcache_event event; + hlcache_event event = { 0 }; nserror error = NSERROR_OK; event.type = msg; - event.data = data; + if (data != NULL) { + event.data = *data; + } if (handle->cb != NULL) error = handle->cb(handle, &event, handle->pw); -- cgit v1.2.1 From d4cdcf30675a642764b5dc32e313aa92e4849496 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 27 Aug 2017 13:05:36 +0100 Subject: CSS content handler: Convert to using content_broadcast_errorcode(). --- content/handlers/css/css.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/content/handlers/css/css.c b/content/handlers/css/css.c index a665fbdc4..0a8ffdd5a 100644 --- a/content/handlers/css/css.c +++ b/content/handlers/css/css.c @@ -136,7 +136,6 @@ nscss_create(const content_handler *handler, const char *charset = NULL; const char *xnsbase = NULL; lwc_string *charset_value = NULL; - union content_msg_data msg_data; nserror error; result = calloc(1, sizeof(nscss_content)); @@ -171,8 +170,7 @@ nscss_create(const content_handler *handler, xnsbase, charset, result->base.quirks, nscss_content_done, result); if (error != NSERROR_OK) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(&result->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&result->base, NSERROR_NOMEM); if (charset_value != NULL) lwc_string_unref(charset_value); free(result); @@ -250,13 +248,11 @@ static nserror nscss_create_css_data(struct content_css_data *c, bool nscss_process_data(struct content *c, const char *data, unsigned int size) { nscss_content *css = (nscss_content *) c; - union content_msg_data msg_data; css_error error; error = nscss_process_css_data(&css->data, data, size); if (error != CSS_OK && error != CSS_NEEDDATA) { - msg_data.error = "?"; - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_CSS); } return (error == CSS_OK || error == CSS_NEEDDATA); @@ -286,13 +282,11 @@ static css_error nscss_process_css_data(struct content_css_data *c, bool nscss_convert(struct content *c) { nscss_content *css = (nscss_content *) c; - union content_msg_data msg_data; css_error error; error = nscss_convert_css_data(&css->data); if (error != CSS_OK) { - msg_data.error = "?"; - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_CSS); return false; } @@ -475,7 +469,6 @@ content_type nscss_content_type(void) */ void nscss_content_done(struct content_css_data *css, void *pw) { - union content_msg_data msg_data; struct content *c = pw; uint32_t i; size_t size; @@ -484,8 +477,7 @@ void nscss_content_done(struct content_css_data *css, void *pw) /* Retrieve the size of this sheet */ error = css_stylesheet_size(css->sheet, &size); if (error != CSS_OK) { - msg_data.error = "?"; - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_CSS); content_set_error(c); return; } @@ -639,6 +631,7 @@ nserror nscss_import(hlcache_handle *handle, error = nscss_import_complete(ctx); break; + case CONTENT_MSG_ERRORCODE: case CONTENT_MSG_ERROR: hlcache_handle_release(handle); ctx->css->imports[ctx->index].c = NULL; -- cgit v1.2.1 From 337bd98f6c6b8ec900afaae613337fdbc5ba778a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 27 Aug 2017 13:23:23 +0100 Subject: BMP content handler: Convert to using content_broadcast_errorcode(). --- content/handlers/image/bmp.c | 13 ++++--------- utils/errors.h | 2 ++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/content/handlers/image/bmp.c b/content/handlers/image/bmp.c index 47c1d0845..48a37fb24 100644 --- a/content/handlers/image/bmp.c +++ b/content/handlers/image/bmp.c @@ -68,8 +68,7 @@ static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state) } static nserror nsbmp_create_bmp_data(nsbmp_content *bmp) -{ - union content_msg_data msg_data; +{ bmp_bitmap_callback_vt bmp_bitmap_callbacks = { .bitmap_create = nsbmp_bitmap_create, .bitmap_destroy = guit->bitmap->destroy, @@ -79,8 +78,7 @@ static nserror nsbmp_create_bmp_data(nsbmp_content *bmp) bmp->bmp = calloc(sizeof(struct bmp_image), 1); if (bmp->bmp == NULL) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(&bmp->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&bmp->base, NSERROR_NOMEM); return NSERROR_NOMEM; } @@ -123,7 +121,6 @@ static bool nsbmp_convert(struct content *c) { nsbmp_content *bmp = (nsbmp_content *) c; bmp_result res; - union content_msg_data msg_data; uint32_t swidth; const char *data; unsigned long size; @@ -138,13 +135,11 @@ static bool nsbmp_convert(struct content *c) case BMP_OK: break; case BMP_INSUFFICIENT_MEMORY: - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_NOMEM); return false; case BMP_INSUFFICIENT_DATA: case BMP_DATA_ERROR: - msg_data.error = messages_get("BadBMP"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_BMP_ERROR); return false; } diff --git a/utils/errors.h b/utils/errors.h index b9e157c66..803a55f44 100644 --- a/utils/errors.h +++ b/utils/errors.h @@ -47,6 +47,8 @@ typedef enum { NSERROR_MNG_ERROR, /**< An MNG error occurred */ + NSERROR_BMP_ERROR, /**< A BMP error occurred */ + NSERROR_BAD_ENCODING, /**< The character set is unknown */ NSERROR_NEED_DATA, /**< More data needed */ -- cgit v1.2.1 From d83f6ea3c1df8cbd1c50af622473370cb22f2461 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 27 Aug 2017 13:25:51 +0100 Subject: GIF content handler: Convert to using content_broadcast_errorcode(). --- content/handlers/image/gif.c | 15 ++++++--------- utils/errors.h | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/content/handlers/image/gif.c b/content/handlers/image/gif.c index 9184f31ce..253265caa 100644 --- a/content/handlers/image/gif.c +++ b/content/handlers/image/gif.c @@ -72,7 +72,6 @@ static void *nsgif_bitmap_create(int width, int height) static nserror nsgif_create_gif_data(nsgif_content *c) { - union content_msg_data msg_data; gif_bitmap_callback_vt gif_bitmap_callbacks = { .bitmap_create = nsgif_bitmap_create, .bitmap_destroy = guit->bitmap->destroy, @@ -85,8 +84,7 @@ static nserror nsgif_create_gif_data(nsgif_content *c) /* Initialise our data structure */ c->gif = calloc(sizeof(gif_animation), 1); if (c->gif == NULL) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&c->base, NSERROR_NOMEM); return NSERROR_NOMEM; } gif_create(c->gif, &gif_bitmap_callbacks); @@ -238,7 +236,6 @@ static bool nsgif_convert(struct content *c) { nsgif_content *gif = (nsgif_content *) c; int res; - union content_msg_data msg_data; const char *data; unsigned long size; char *title; @@ -251,17 +248,18 @@ static bool nsgif_convert(struct content *c) res = gif_initialise(gif->gif, size, (unsigned char *) data); if (res != GIF_OK && res != GIF_WORKING && res != GIF_INSUFFICIENT_FRAME_DATA) { + nserror error = NSERROR_UNKNOWN; switch (res) { case GIF_FRAME_DATA_ERROR: case GIF_INSUFFICIENT_DATA: case GIF_DATA_ERROR: - msg_data.error = messages_get("BadGIF"); + error = NSERROR_GIF_ERROR; break; case GIF_INSUFFICIENT_MEMORY: - msg_data.error = messages_get("NoMemory"); + error = NSERROR_NOMEM; break; } - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, error); return false; } } while (res != GIF_OK && res != GIF_INSUFFICIENT_FRAME_DATA); @@ -269,8 +267,7 @@ static bool nsgif_convert(struct content *c) /* Abort on bad GIFs */ if ((gif->gif->frame_count_partial == 0) || (gif->gif->width == 0) || (gif->gif->height == 0)) { - msg_data.error = messages_get("BadGIF"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_GIF_ERROR); return false; } diff --git a/utils/errors.h b/utils/errors.h index 803a55f44..1326c62d3 100644 --- a/utils/errors.h +++ b/utils/errors.h @@ -49,6 +49,8 @@ typedef enum { NSERROR_BMP_ERROR, /**< A BMP error occurred */ + NSERROR_GIF_ERROR, /**< A GIF error occurred */ + NSERROR_BAD_ENCODING, /**< The character set is unknown */ NSERROR_NEED_DATA, /**< More data needed */ -- cgit v1.2.1 From d1a493f5697e5cd29394bbad6d0183fb530a9d29 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 27 Aug 2017 13:32:53 +0100 Subject: ICO content handler: Convert to using content_broadcast_errorcode(). --- content/handlers/image/ico.c | 11 +++-------- utils/errors.h | 2 ++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/content/handlers/image/ico.c b/content/handlers/image/ico.c index 180b20d7e..d1865a3b4 100644 --- a/content/handlers/image/ico.c +++ b/content/handlers/image/ico.c @@ -66,7 +66,6 @@ static void *nsico_bitmap_create(int width, int height, unsigned int bmp_state) static nserror nsico_create_ico_data(nsico_content *c) { - union content_msg_data msg_data; bmp_bitmap_callback_vt bmp_bitmap_callbacks = { .bitmap_create = nsico_bitmap_create, .bitmap_destroy = guit->bitmap->destroy, @@ -76,8 +75,7 @@ static nserror nsico_create_ico_data(nsico_content *c) c->ico = calloc(sizeof(ico_collection), 1); if (c->ico == NULL) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&c->base, NSERROR_NOMEM); return NSERROR_NOMEM; } ico_collection_create(c->ico, &bmp_bitmap_callbacks); @@ -122,7 +120,6 @@ static bool nsico_convert(struct content *c) nsico_content *ico = (nsico_content *) c; struct bmp_image *bmp; bmp_result res; - union content_msg_data msg_data; const char *data; unsigned long size; char *title; @@ -137,13 +134,11 @@ static bool nsico_convert(struct content *c) case BMP_OK: break; case BMP_INSUFFICIENT_MEMORY: - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_NOMEM); return false; case BMP_INSUFFICIENT_DATA: case BMP_DATA_ERROR: - msg_data.error = messages_get("BadICO"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_ICO_ERROR); return false; } diff --git a/utils/errors.h b/utils/errors.h index 1326c62d3..e602b0208 100644 --- a/utils/errors.h +++ b/utils/errors.h @@ -51,6 +51,8 @@ typedef enum { NSERROR_GIF_ERROR, /**< A GIF error occurred */ + NSERROR_ICO_ERROR, /**< A ICO error occurred */ + NSERROR_BAD_ENCODING, /**< The character set is unknown */ NSERROR_NEED_DATA, /**< More data needed */ -- cgit v1.2.1 From 5a40e94df627fd913e800f7a86f6d2e5a1f5b870 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 12 Aug 2017 08:16:33 +0100 Subject: remove unecessary textarea include --- frontends/gtk/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c index de5311e2e..d32f4573a 100644 --- a/frontends/gtk/window.c +++ b/frontends/gtk/window.c @@ -42,7 +42,6 @@ #include "netsurf/plotters.h" #include "netsurf/form.h" #include "netsurf/keypress.h" -#include "desktop/textarea.h" #include "desktop/searchweb.h" #include "desktop/textinput.h" @@ -355,6 +354,7 @@ static gboolean nsgtk_window_button_press_event(GtkWidget *widget, break; case 3: /* Right button, usually. Action button, context menu. */ + /** \todo determine if hiding the caret here is necessary */ browser_window_remove_caret(g->bw, true); nsgtk_scaffolding_context_menu(g->scaffold, g->mouse.pressed_x, -- cgit v1.2.1 From cde300133e95a8db0a925879f2c9d940f2bbebdc Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 27 Aug 2017 16:01:58 +0100 Subject: initialise event struct correctly to avoid compiler warning --- content/hlcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/hlcache.c b/content/hlcache.c index 38a83eae4..249275e92 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -182,9 +182,11 @@ static void hlcache_content_callback(struct content *c, content_msg msg, const union content_msg_data *data, void *pw) { hlcache_handle *handle = pw; - hlcache_event event = { 0 }; + hlcache_event event; nserror error = NSERROR_OK; + memset(&event, 0, sizeof(event)); + event.type = msg; if (data != NULL) { event.data = *data; -- cgit v1.2.1 From 36c01fc03b0231ca61714c2610da233948a79bba Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 10:06:47 +0100 Subject: Sprite content handler: Convert to using content_broadcast_errorcode(). --- content/handlers/image/nssprite.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index ab48978e9..530c95385 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -95,7 +95,6 @@ static nserror nssprite_create(const content_handler *handler, static bool nssprite_convert(struct content *c) { nssprite_content *nssprite = (nssprite_content *) c; - union content_msg_data msg_data; struct rosprite_mem_context* ctx; @@ -118,14 +117,12 @@ static bool nssprite_convert(struct content *c) nssprite->bitmap = guit->bitmap->create(sprite->width, sprite->height, BITMAP_NEW); if (!nssprite->bitmap) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } uint32_t* imagebuf = (uint32_t *)guit->bitmap->get_buffer(nssprite->bitmap); if (!imagebuf) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } unsigned char *spritebuf = (unsigned char *)sprite->image; -- cgit v1.2.1 From cae1c44f8fe61a4df20f000d0b57ac78e5527170 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 10:14:22 +0100 Subject: PNG content handler: Convert to using content_broadcast_errorcode(). --- content/handlers/image/png.c | 15 ++++----------- utils/errors.h | 2 ++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/content/handlers/image/png.c b/content/handlers/image/png.c index 136fd8f73..288f6c3e4 100644 --- a/content/handlers/image/png.c +++ b/content/handlers/image/png.c @@ -240,14 +240,11 @@ static void end_callback(png_structp png_s, png_infop info) static nserror nspng_create_png_data(nspng_content *png_c) { - union content_msg_data msg_data; - png_c->bitmap = NULL; png_c->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); if (png_c->png == NULL) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(&png_c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&png_c->base, NSERROR_NOMEM); return NSERROR_NOMEM; } @@ -257,8 +254,7 @@ static nserror nspng_create_png_data(nspng_content *png_c) if (png_c->info == NULL) { png_destroy_read_struct(&png_c->png, &png_c->info, 0); - msg_data.error = messages_get("NoMemory"); - content_broadcast(&png_c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&png_c->base, NSERROR_NOMEM); return NSERROR_NOMEM; } @@ -268,8 +264,7 @@ static nserror nspng_create_png_data(nspng_content *png_c) png_c->png = NULL; png_c->info = NULL; - msg_data.error = messages_get("PNGError"); - content_broadcast(&png_c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&png_c->base, NSERROR_PNG_ERROR); return NSERROR_NOMEM; } @@ -323,7 +318,6 @@ static bool nspng_process_data(struct content *c, const char *data, unsigned int size) { nspng_content *png_c = (nspng_content *)c; - union content_msg_data msg_data; volatile bool ret = true; if (png_c->no_process_data) { @@ -362,8 +356,7 @@ static bool nspng_process_data(struct content *c, const char *data, png_c->png = NULL; png_c->info = NULL; - msg_data.error = messages_get("PNGError"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_PNG_ERROR); ret = false; diff --git a/utils/errors.h b/utils/errors.h index e602b0208..3ab40b2f4 100644 --- a/utils/errors.h +++ b/utils/errors.h @@ -53,6 +53,8 @@ typedef enum { NSERROR_ICO_ERROR, /**< A ICO error occurred */ + NSERROR_PNG_ERROR, /**< A PNG error occurred */ + NSERROR_BAD_ENCODING, /**< The character set is unknown */ NSERROR_NEED_DATA, /**< More data needed */ -- cgit v1.2.1 From 9e64f37846f80413cc94bf40effec8eecdeb7cf6 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 10:21:11 +0100 Subject: RSVG content handler: Convert to using content_broadcast_errorcode(). --- content/handlers/image/rsvg.c | 21 ++++++--------------- utils/errors.h | 2 ++ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/content/handlers/image/rsvg.c b/content/handlers/image/rsvg.c index 24819df57..d45a968e5 100644 --- a/content/handlers/image/rsvg.c +++ b/content/handlers/image/rsvg.c @@ -62,8 +62,6 @@ typedef struct rsvg_content { static nserror rsvg_create_svg_data(rsvg_content *c) { - union content_msg_data msg_data; - c->rsvgh = NULL; c->cs = NULL; c->ct = NULL; @@ -71,8 +69,7 @@ static nserror rsvg_create_svg_data(rsvg_content *c) if ((c->rsvgh = rsvg_handle_new()) == NULL) { LOG("rsvg_handle_new() returned NULL."); - msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&c->base, NSERROR_NOMEM); return NSERROR_NOMEM; } @@ -115,14 +112,12 @@ static bool rsvg_process_data(struct content *c, const char *data, unsigned int size) { rsvg_content *d = (rsvg_content *) c; - union content_msg_data msg_data; GError *err = NULL; if (rsvg_handle_write(d->rsvgh, (const guchar *)data, (gsize)size, &err) == FALSE) { LOG("rsvg_handle_write returned an error: %s", err->message); - msg_data.error = err->message; - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_SVG_ERROR); return false; } @@ -161,14 +156,12 @@ static inline void rsvg_argb_to_abgr(uint8_t *pixels, static bool rsvg_convert(struct content *c) { rsvg_content *d = (rsvg_content *) c; - union content_msg_data msg_data; RsvgDimensionData rsvgsize; GError *err = NULL; if (rsvg_handle_close(d->rsvgh, &err) == FALSE) { LOG("rsvg_handle_close returned an error: %s", err->message); - msg_data.error = err->message; - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_SVG_ERROR); return false; } @@ -186,7 +179,7 @@ static bool rsvg_convert(struct content *c) BITMAP_NEW)) == NULL) { LOG("Failed to create bitmap for rsvg render."); msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } @@ -196,15 +189,13 @@ static bool rsvg_convert(struct content *c) c->width, c->height, guit->bitmap->get_rowstride(d->bitmap))) == NULL) { LOG("Failed to create Cairo image surface for rsvg render."); - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } if ((d->ct = cairo_create(d->cs)) == NULL) { LOG("Failed to create Cairo drawing context for rsvg render."); - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } diff --git a/utils/errors.h b/utils/errors.h index 3ab40b2f4..cce8d6e90 100644 --- a/utils/errors.h +++ b/utils/errors.h @@ -55,6 +55,8 @@ typedef enum { NSERROR_PNG_ERROR, /**< A PNG error occurred */ + NSERROR_SVG_ERROR, /**< A SVG error occurred */ + NSERROR_BAD_ENCODING, /**< The character set is unknown */ NSERROR_NEED_DATA, /**< More data needed */ -- cgit v1.2.1 From e411c84e9bc1075b54373ce3d5eb6bbb6706ccde Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 10:24:04 +0100 Subject: SVG content handler: Convert to using content_broadcast_errorcode(). --- content/handlers/image/svg.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c index f31ee1f8d..2edc7bd08 100644 --- a/content/handlers/image/svg.c +++ b/content/handlers/image/svg.c @@ -49,8 +49,6 @@ typedef struct svg_content { static nserror svg_create_svg_data(svg_content *c) { - union content_msg_data msg_data; - c->diagram = svgtiny_create(); if (c->diagram == NULL) goto no_memory; @@ -61,8 +59,7 @@ static nserror svg_create_svg_data(svg_content *c) return NSERROR_OK; no_memory: - msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&c->base, NSERROR_NOMEM); return NSERROR_NOMEM; } -- cgit v1.2.1 From 8180116d965d12e9a5da1b5c139bbb7ee838e069 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 10:27:20 +0100 Subject: Plain text content handler: Convert to using content_broadcast_errorcode(). --- render/textplain.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/render/textplain.c b/render/textplain.c index 35e3e4ba4..2f2d757c8 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -150,7 +150,6 @@ textplain_create_internal(textplain_content *c, lwc_string *encoding) char *utf8_data; parserutils_inputstream *stream; parserutils_error error; - union content_msg_data msg_data; textplain_style.size = (nsoption_int(font_size) * FONT_SIZE_SCALE) / 10; @@ -185,8 +184,7 @@ textplain_create_internal(textplain_content *c, lwc_string *encoding) return NSERROR_OK; no_memory: - msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&c->base, NSERROR_NOMEM); return NSERROR_NOMEM; } @@ -347,7 +345,6 @@ textplain_process_data(struct content *c, const char *data, unsigned int size) { textplain_content *text = (textplain_content *) c; parserutils_inputstream *stream = text->inputstream; - union content_msg_data msg_data; parserutils_error error; error = parserutils_inputstream_append(stream, @@ -362,8 +359,7 @@ textplain_process_data(struct content *c, const char *data, unsigned int size) return true; no_memory: - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } -- cgit v1.2.1 From adc6ceb0bb64382a3b46dc3fcbe3fb621e719896 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 10:32:48 +0100 Subject: CSS content handler: Ensure fetch hlcache callback handles errorcode. --- render/html_css.c | 1 + 1 file changed, 1 insertion(+) diff --git a/render/html_css.c b/render/html_css.c index 4d5469361..47c218529 100644 --- a/render/html_css.c +++ b/render/html_css.c @@ -109,6 +109,7 @@ html_convert_css_callback(hlcache_handle *css, break; case CONTENT_MSG_ERROR: + case CONTENT_MSG_ERRORCODE: LOG("stylesheet %s failed: %s", nsurl_access(hlcache_handle_get_url(css)), event->data.error); hlcache_handle_release(css); s->sheet = NULL; -- cgit v1.2.1 From a30ae27e5ccbd0772044df768a2d6fe26ee6a8d9 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 10:53:07 +0100 Subject: HTML content handler: Ensure object fetch hlcache callback handles errorcode. --- render/html_object.c | 1 + 1 file changed, 1 insertion(+) diff --git a/render/html_object.c b/render/html_object.c index 12780ca8b..f304e91ac 100644 --- a/render/html_object.c +++ b/render/html_object.c @@ -181,6 +181,7 @@ html_object_callback(hlcache_handle *object, } break; + case CONTENT_MSG_ERRORCODE: case CONTENT_MSG_ERROR: hlcache_handle_release(object); -- cgit v1.2.1 From 830d7ec6b6d368db55233b41c26ff1744d03945c Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 10:55:03 +0100 Subject: HTML content handler: Ensure script fetch hlcache callback handles errorcode. --- render/html_script.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/render/html_script.c b/render/html_script.c index c07e5a372..05e7d9b23 100644 --- a/render/html_script.c +++ b/render/html_script.c @@ -173,6 +173,7 @@ convert_script_async_cb(hlcache_handle *script, case CONTENT_MSG_ERROR: LOG("script %s failed: %s", nsurl_access(hlcache_handle_get_url(script)), event->data.error); + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(script); s->data.handle = NULL; parent->base.active--; @@ -226,6 +227,7 @@ convert_script_defer_cb(hlcache_handle *script, case CONTENT_MSG_ERROR: LOG("script %s failed: %s", nsurl_access(hlcache_handle_get_url(script)), event->data.error); + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(script); s->data.handle = NULL; parent->base.active--; @@ -298,6 +300,7 @@ convert_script_sync_cb(hlcache_handle *script, case CONTENT_MSG_ERROR: LOG("script %s failed: %s", nsurl_access(hlcache_handle_get_url(script)), event->data.error); + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(script); s->data.handle = NULL; -- cgit v1.2.1 From 771fe0d44c924a05afe9e951669fcdfbb9d56913 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 11:01:30 +0100 Subject: HTML script handling: Convert to using content_broadcast_errorcode(). --- render/html_script.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/render/html_script.c b/render/html_script.c index 05e7d9b23..6ed74c5c4 100644 --- a/render/html_script.c +++ b/render/html_script.c @@ -346,7 +346,6 @@ exec_src_script(html_content *c, nsurl *joined; hlcache_child_context child; struct html_script *nscript; - union content_msg_data msg_data; bool async; bool defer; enum html_script_type script_type; @@ -357,8 +356,7 @@ exec_src_script(html_content *c, /* src url */ ns_error = nsurl_join(c->base_url, dom_string_data(src), &joined); if (ns_error != NSERROR_OK) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&c->base, NSERROR_NOMEM); return DOM_HUBBUB_NOMEM; } @@ -413,8 +411,7 @@ exec_src_script(html_content *c, nscript = html_process_new_script(c, mimetype, script_type); if (nscript == NULL) { nsurl_unref(joined); - msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&c->base, NSERROR_NOMEM); return DOM_HUBBUB_NOMEM; } @@ -468,7 +465,6 @@ exec_src_script(html_content *c, static dom_hubbub_error exec_inline_script(html_content *c, dom_node *node, dom_string *mimetype) { - union content_msg_data msg_data; dom_string *script; dom_exception exc; /* returned by libdom functions */ struct lwc_string_s *lwcmimetype; @@ -485,8 +481,7 @@ exec_inline_script(html_content *c, dom_node *node, dom_string *mimetype) if (nscript == NULL) { dom_string_unref(script); - msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data); + content_broadcast_errorcode(&c->base, NSERROR_NOMEM); return DOM_HUBBUB_NOMEM; } -- cgit v1.2.1 From 7385f74141248dfc738b7952fad37c024320673f Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 11:04:42 +0100 Subject: Browser favicon: Handle errorcode in the hlcache callback. --- desktop/browser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/desktop/browser.c b/desktop/browser.c index e7ff158f9..8d57a2ab5 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1094,6 +1094,7 @@ browser_window_favicon_callback(hlcache_handle *c, break; case CONTENT_MSG_ERROR: + case CONTENT_MSG_ERRORCODE: /* clean up after ourselves */ if (c == bw->favicon.loading) { -- cgit v1.2.1 From 9fd0e065010015a52e200ce3b28566782b12f4a5 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 11:08:18 +0100 Subject: Whitespace: Tidy up errorcodes. --- utils/errors.h | 75 +++++++++++++++++----------------------------------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/utils/errors.h b/utils/errors.h index cce8d6e90..55f921e48 100644 --- a/utils/errors.h +++ b/utils/errors.h @@ -27,68 +27,37 @@ * Enumeration of error codes */ typedef enum { - NSERROR_OK, /**< No error */ - - NSERROR_UNKNOWN, /**< Unknown error - DO *NOT* USE */ - - NSERROR_NOMEM, /**< Memory exhaustion */ - - NSERROR_NO_FETCH_HANDLER, /**< No fetch handler for URL scheme */ - - NSERROR_NOT_FOUND, /**< Requested item not found */ - - NSERROR_NOT_DIRECTORY, /**< Missing directory */ - - NSERROR_SAVE_FAILED, /**< Failed to save data */ - - NSERROR_CLONE_FAILED, /**< Failed to clone handle */ - - NSERROR_INIT_FAILED, /**< Initialisation failed */ - - NSERROR_MNG_ERROR, /**< An MNG error occurred */ - + NSERROR_OK, /**< No error */ + NSERROR_UNKNOWN, /**< Unknown error - DO *NOT* USE */ + NSERROR_NOMEM, /**< Memory exhaustion */ + NSERROR_NO_FETCH_HANDLER, /**< No fetch handler for URL scheme */ + NSERROR_NOT_FOUND, /**< Requested item not found */ + NSERROR_NOT_DIRECTORY, /**< Missing directory */ + NSERROR_SAVE_FAILED, /**< Failed to save data */ + NSERROR_CLONE_FAILED, /**< Failed to clone handle */ + NSERROR_INIT_FAILED, /**< Initialisation failed */ + NSERROR_MNG_ERROR, /**< An MNG error occurred */ NSERROR_BMP_ERROR, /**< A BMP error occurred */ - NSERROR_GIF_ERROR, /**< A GIF error occurred */ - NSERROR_ICO_ERROR, /**< A ICO error occurred */ - NSERROR_PNG_ERROR, /**< A PNG error occurred */ - NSERROR_SVG_ERROR, /**< A SVG error occurred */ - - NSERROR_BAD_ENCODING, /**< The character set is unknown */ - - NSERROR_NEED_DATA, /**< More data needed */ - - NSERROR_ENCODING_CHANGE, /**< The character changed */ - - NSERROR_BAD_PARAMETER, /**< Bad Parameter */ - - NSERROR_INVALID, /**< Invalid data */ - - NSERROR_BOX_CONVERT, /**< Box conversion failed */ - - NSERROR_STOPPED, /**< Content conversion stopped */ - - NSERROR_DOM, /**< DOM call returned error */ - - NSERROR_CSS, /**< CSS call returned error */ - + NSERROR_BAD_ENCODING, /**< The character set is unknown */ + NSERROR_NEED_DATA, /**< More data needed */ + NSERROR_ENCODING_CHANGE, /**< The character changed */ + NSERROR_BAD_PARAMETER, /**< Bad Parameter */ + NSERROR_INVALID, /**< Invalid data */ + NSERROR_BOX_CONVERT, /**< Box conversion failed */ + NSERROR_STOPPED, /**< Content conversion stopped */ + NSERROR_DOM, /**< DOM call returned error */ + NSERROR_CSS, /**< CSS call returned error */ NSERROR_CSS_BASE, /**< CSS base sheet failed */ - - NSERROR_BAD_URL, /**< Bad URL */ - - NSERROR_BAD_CONTENT, /**< Bad Content */ - + NSERROR_BAD_URL, /**< Bad URL */ + NSERROR_BAD_CONTENT, /**< Bad Content */ NSERROR_FRAME_DEPTH, /**< Exceeded frame depth */ - NSERROR_PERMISSION, /**< Permission error */ - - NSERROR_NOSPACE, /**< Insufficient space */ - + NSERROR_NOSPACE, /**< Insufficient space */ NSERROR_BAD_SIZE, /**< Bad size */ - NSERROR_NOT_IMPLEMENTED, /**< Functionality is not implemented */ } nserror; -- cgit v1.2.1 From 3a0e87e89f57a6082074438e038098bfbe688f2a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 11:11:40 +0100 Subject: Errorcodes: Remove redundant MNG error. --- test/messages.c | 1 - utils/errors.h | 1 - utils/messages.c | 4 ---- 3 files changed, 6 deletions(-) diff --git a/test/messages.c b/test/messages.c index d102e361c..ae82d1ede 100644 --- a/test/messages.c +++ b/test/messages.c @@ -52,7 +52,6 @@ struct message_test_vec_s message_errorcode_test_vec[] = { { NSERROR_SAVE_FAILED, "SaveFailed" }, { NSERROR_CLONE_FAILED, "CloneFailed" }, { NSERROR_INIT_FAILED, "InitFailed" }, - { NSERROR_MNG_ERROR, "Error converting MNG/PNG/JNG: %i" }, { NSERROR_BAD_ENCODING, "BadEncoding" }, { NSERROR_NEED_DATA, "NeedData" }, { NSERROR_ENCODING_CHANGE, "EncodingChanged" }, diff --git a/utils/errors.h b/utils/errors.h index 55f921e48..ad8ae429a 100644 --- a/utils/errors.h +++ b/utils/errors.h @@ -36,7 +36,6 @@ typedef enum { NSERROR_SAVE_FAILED, /**< Failed to save data */ NSERROR_CLONE_FAILED, /**< Failed to clone handle */ NSERROR_INIT_FAILED, /**< Initialisation failed */ - NSERROR_MNG_ERROR, /**< An MNG error occurred */ NSERROR_BMP_ERROR, /**< A BMP error occurred */ NSERROR_GIF_ERROR, /**< A GIF error occurred */ NSERROR_ICO_ERROR, /**< A ICO error occurred */ diff --git a/utils/messages.c b/utils/messages.c index 0c558cdfc..5f55cb964 100644 --- a/utils/messages.c +++ b/utils/messages.c @@ -350,10 +350,6 @@ const char *messages_get_errorcode(nserror code) /* Initialisation failed */ return messages_get_ctx("InitFailed", messages_hash); - case NSERROR_MNG_ERROR: - /* An MNG error occurred */ - return messages_get_ctx("MNGError", messages_hash); - case NSERROR_BAD_ENCODING: /* The character set is unknown */ return messages_get_ctx("BadEncoding", messages_hash); -- cgit v1.2.1 From cebfa6c2cc69e4fba14910b5f93c7b0e9d538197 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 11:15:06 +0100 Subject: Tests: Squash warning: "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE". --- test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 39953a3d3..64c3f39a4 100644 --- a/test/Makefile +++ b/test/Makefile @@ -134,7 +134,7 @@ endif BASE_TESTCFLAGS := -std=c99 -g \ $(COMMON_WARNFLAGS) \ - -D_BSD_SOURCE \ + -D_DEFAULT_SOURCE \ -D_POSIX_C_SOURCE=200809L \ -D_XOPEN_SOURCE=600 \ -Itest -Iinclude -Icontent/handlers -Ifrontends -I. -I.. \ -- cgit v1.2.1 From 7ba93407adde44c975b57811605451e39ace0183 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 11:39:21 +0100 Subject: Messages: Do message lookups for all errorcodes. --- utils/messages.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/utils/messages.c b/utils/messages.c index 5f55cb964..bca1b47b0 100644 --- a/utils/messages.c +++ b/utils/messages.c @@ -338,6 +338,10 @@ const char *messages_get_errorcode(nserror code) /* Requested item not found */ return messages_get_ctx("NotFound", messages_hash); + case NSERROR_NOT_DIRECTORY: + /* Missing directory */ + return messages_get_ctx("NotDirectory", messages_hash); + case NSERROR_SAVE_FAILED: /* Failed to save data */ return messages_get_ctx("SaveFailed", messages_hash); @@ -350,6 +354,26 @@ const char *messages_get_errorcode(nserror code) /* Initialisation failed */ return messages_get_ctx("InitFailed", messages_hash); + case NSERROR_BMP_ERROR: + /* A BMP error occurred */ + return messages_get_ctx("BMPError", messages_hash); + + case NSERROR_GIF_ERROR: + /* A GIF error occurred */ + return messages_get_ctx("GIFError", messages_hash); + + case NSERROR_ICO_ERROR: + /* A ICO error occurred */ + return messages_get_ctx("ICOError", messages_hash); + + case NSERROR_PNG_ERROR: + /* A PNG error occurred */ + return messages_get_ctx("PNGError", messages_hash); + + case NSERROR_SVG_ERROR: + /* A SVG error occurred */ + return messages_get_ctx("SVGError", messages_hash); + case NSERROR_BAD_ENCODING: /* The character set is unknown */ return messages_get_ctx("BadEncoding", messages_hash); @@ -394,13 +418,40 @@ const char *messages_get_errorcode(nserror code) /* Bad URL */ return messages_get_ctx("BadURL", messages_hash); - default: + case NSERROR_BAD_CONTENT: + /* Bad Content */ + return messages_get_ctx("BadContent", messages_hash); + + case NSERROR_FRAME_DEPTH: + /* Exceeded frame depth */ + return messages_get_ctx("FrameDepth", messages_hash); + + case NSERROR_PERMISSION: + /* Permission error */ + return messages_get_ctx("PermissionError", messages_hash); + + case NSERROR_BAD_SIZE: + /* Bad size */ + return messages_get_ctx("BadSize", messages_hash); + + case NSERROR_NOSPACE: + /* Insufficient space */ + return messages_get_ctx("NoSpace", messages_hash); + + case NSERROR_NOT_IMPLEMENTED: + /* Functionality is not implemented */ + return messages_get_ctx("NotImplemented", messages_hash); + case NSERROR_UNKNOWN: - break; + /* Unknown error */ + return messages_get_ctx("Unknown", messages_hash); } - /* Unknown error */ - return messages_get_ctx("Unknown", messages_hash); + /* The switch has no default, so the compiler should tell us when we + * forget to add messages for new error codes. As such, we should + * never get here. + */ + assert(0); } -- cgit v1.2.1 From 4a014fecde6a4f38c99b820297df65da4555137c Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 11:52:54 +0100 Subject: hlcache content callback: Use designated initialiser for hlcache_event. --- content/hlcache.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/content/hlcache.c b/content/hlcache.c index 249275e92..2242b73af 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -182,12 +182,11 @@ static void hlcache_content_callback(struct content *c, content_msg msg, const union content_msg_data *data, void *pw) { hlcache_handle *handle = pw; - hlcache_event event; nserror error = NSERROR_OK; + hlcache_event event = { + .type = msg, + }; - memset(&event, 0, sizeof(event)); - - event.type = msg; if (data != NULL) { event.data = *data; } -- cgit v1.2.1 From 2ad990f3d54dabbd1ea9233119d81ce8a97fa215 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 12:04:23 +0100 Subject: HTML object hlcache callback: Errorcode without box is OK. --- render/html_object.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/render/html_object.c b/render/html_object.c index f304e91ac..0daf33db9 100644 --- a/render/html_object.c +++ b/render/html_object.c @@ -125,7 +125,9 @@ html_object_callback(hlcache_handle *object, struct box *box; box = o->box; - if (box == NULL && event->type != CONTENT_MSG_ERROR) { + if (box == NULL && + event->type != CONTENT_MSG_ERROR && + event->type != CONTENT_MSG_ERRORCODE) { return NSERROR_OK; } -- cgit v1.2.1 From c0205478c076a3e118b52602c41adae1658076db Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 12:06:09 +0100 Subject: HTML object hlcache callback: Ensure final fetch completion triggers reformat. Even if the final fetch finished with ERRORCODE. --- render/html_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/render/html_object.c b/render/html_object.c index 0daf33db9..c86c57520 100644 --- a/render/html_object.c +++ b/render/html_object.c @@ -440,7 +440,8 @@ html_object_callback(hlcache_handle *object, c->base.active == 0 && (event->type == CONTENT_MSG_LOADING || event->type == CONTENT_MSG_DONE || - event->type == CONTENT_MSG_ERROR)) { + event->type == CONTENT_MSG_ERROR || + event->type == CONTENT_MSG_ERRORCODE)) { /* all objects have arrived */ content__reformat(&c->base, false, c->base.available_width, c->base.height); -- cgit v1.2.1 From b35b3c136412a3795684d969821f849035f7c570 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 12:10:27 +0100 Subject: Search web: Ensure hlcache callbacks handle errorcode. --- desktop/searchweb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop/searchweb.c b/desktop/searchweb.c index 29a998eb2..fb7ecc082 100644 --- a/desktop/searchweb.c +++ b/desktop/searchweb.c @@ -296,6 +296,7 @@ search_web_ico_callback(hlcache_handle *ico, case CONTENT_MSG_ERROR: LOG("icon %s error: %s", nsurl_access(hlcache_handle_get_url(ico)), event->data.error); + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(ico); /* clear reference to released handle */ provider->ico_handle = NULL; @@ -450,6 +451,7 @@ default_ico_callback(hlcache_handle *ico, case CONTENT_MSG_ERROR: LOG("icon %s error: %s", nsurl_access(hlcache_handle_get_url(ico)), event->data.error); + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(ico); /* clear reference to released handle */ ctx->default_ico_handle = NULL; -- cgit v1.2.1 From 8de56251939951c7069c4a84e19673be8e5edddf Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 12:12:08 +0100 Subject: HTML CSS handler: event->data.error is invalid for errorcode. --- render/html_css.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/render/html_css.c b/render/html_css.c index 47c218529..ad1470daf 100644 --- a/render/html_css.c +++ b/render/html_css.c @@ -109,8 +109,8 @@ html_convert_css_callback(hlcache_handle *css, break; case CONTENT_MSG_ERROR: - case CONTENT_MSG_ERRORCODE: LOG("stylesheet %s failed: %s", nsurl_access(hlcache_handle_get_url(css)), event->data.error); + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(css); s->sheet = NULL; parent->base.active--; -- cgit v1.2.1 From ba0283f52694447710f483c9355e9432e1e2f9e3 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 12:16:24 +0100 Subject: RSVG content handler: Remove unused assignement. --- content/handlers/image/rsvg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/content/handlers/image/rsvg.c b/content/handlers/image/rsvg.c index d45a968e5..f6732e23f 100644 --- a/content/handlers/image/rsvg.c +++ b/content/handlers/image/rsvg.c @@ -178,7 +178,6 @@ static bool rsvg_convert(struct content *c) if ((d->bitmap = guit->bitmap->create(c->width, c->height, BITMAP_NEW)) == NULL) { LOG("Failed to create bitmap for rsvg render."); - msg_data.error = messages_get("NoMemory"); content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } -- cgit v1.2.1 From 41f30992aa92308a93c46fd8bdd80971e6e5e7e0 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 28 Aug 2017 12:21:03 +0100 Subject: Messages: Return the unknown message if we get to the unhandled errorcode. We shouldn't get there though. --- utils/messages.c | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/messages.c b/utils/messages.c index bca1b47b0..0ff90b708 100644 --- a/utils/messages.c +++ b/utils/messages.c @@ -452,6 +452,7 @@ const char *messages_get_errorcode(nserror code) * never get here. */ assert(0); + return messages_get_ctx("Unknown", messages_hash); } -- cgit v1.2.1 From a9d18a8efd2ec114b1c08fc551a1347fd5befced Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 29 Aug 2017 11:55:46 +0100 Subject: Sprite content handler: Fix leaked rosprite_mem_context on rosprite_load error. --- content/handlers/image/nssprite.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index 530c95385..651714744 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -49,13 +49,13 @@ typedef struct nssprite_content { rosprite_error err = x; \ if (err == ROSPRITE_EOF) { \ LOG("Got ROSPRITE_EOF when loading sprite file"); \ - return false; \ + goto ro_sprite_error; \ } else if (err == ROSPRITE_BADMODE) { \ LOG("Got ROSPRITE_BADMODE when loading sprite file"); \ - return false; \ + goto ro_sprite_error; \ } else if (err == ROSPRITE_OK) { \ } else { \ - return false; \ + goto ro_sprite_error; \ } \ } while(0) @@ -96,7 +96,7 @@ static bool nssprite_convert(struct content *c) { nssprite_content *nssprite = (nssprite_content *) c; - struct rosprite_mem_context* ctx; + struct rosprite_mem_context* ctx = NULL; const char *data; unsigned long size; @@ -160,6 +160,13 @@ static bool nssprite_convert(struct content *c) content_set_status(c, ""); /* Done: update status bar */ return true; + +ro_sprite_error: + if (ctx != NULL) { + rosprite_destroy_mem_context(ctx); + } + + return false; } -- cgit v1.2.1 From 1670dc33afca32e0c1cc7d5ddcf508e9ca1619b2 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 29 Aug 2017 11:57:34 +0100 Subject: Sprite content handler: Ensure we broadcast error on librosprite error. --- content/handlers/image/nssprite.c | 1 + 1 file changed, 1 insertion(+) diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index 651714744..f149350fd 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -165,6 +165,7 @@ ro_sprite_error: if (ctx != NULL) { rosprite_destroy_mem_context(ctx); } + content_broadcast_errorcode(c, NSERROR_UNKNOWN); return false; } -- cgit v1.2.1 From c2ac1a713f7e47742ac6001991888f767d15d93f Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 30 Aug 2017 09:43:13 +0100 Subject: Errorcodes: Add SPRITE_ERROR and use it in sprite content handler. --- content/handlers/image/nssprite.c | 2 +- utils/errors.h | 1 + utils/messages.c | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index f149350fd..c9fe1b585 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -165,7 +165,7 @@ ro_sprite_error: if (ctx != NULL) { rosprite_destroy_mem_context(ctx); } - content_broadcast_errorcode(c, NSERROR_UNKNOWN); + content_broadcast_errorcode(c, NSERROR_SPRITE_ERROR); return false; } diff --git a/utils/errors.h b/utils/errors.h index ad8ae429a..9a0a9bc04 100644 --- a/utils/errors.h +++ b/utils/errors.h @@ -40,6 +40,7 @@ typedef enum { NSERROR_GIF_ERROR, /**< A GIF error occurred */ NSERROR_ICO_ERROR, /**< A ICO error occurred */ NSERROR_PNG_ERROR, /**< A PNG error occurred */ + NSERROR_SPRITE_ERROR, /**< A RISC OS Sprite error occurred */ NSERROR_SVG_ERROR, /**< A SVG error occurred */ NSERROR_BAD_ENCODING, /**< The character set is unknown */ NSERROR_NEED_DATA, /**< More data needed */ diff --git a/utils/messages.c b/utils/messages.c index 0ff90b708..5f9420443 100644 --- a/utils/messages.c +++ b/utils/messages.c @@ -370,6 +370,10 @@ const char *messages_get_errorcode(nserror code) /* A PNG error occurred */ return messages_get_ctx("PNGError", messages_hash); + case NSERROR_SPRITE_ERROR: + /* A SVG error occurred */ + return messages_get_ctx("SpriteError", messages_hash); + case NSERROR_SVG_ERROR: /* A SVG error occurred */ return messages_get_ctx("SVGError", messages_hash); -- cgit v1.2.1 From c6717f1ade89e969eb311d0069dd4c29859cf2c4 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 30 Aug 2017 09:47:49 +0100 Subject: Messages: Correct code comment. --- utils/messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/messages.c b/utils/messages.c index 5f9420443..be53eccd0 100644 --- a/utils/messages.c +++ b/utils/messages.c @@ -371,7 +371,7 @@ const char *messages_get_errorcode(nserror code) return messages_get_ctx("PNGError", messages_hash); case NSERROR_SPRITE_ERROR: - /* A SVG error occurred */ + /* A RISC OS Sprite error occurred */ return messages_get_ctx("SpriteError", messages_hash); case NSERROR_SVG_ERROR: -- cgit v1.2.1 From 7136b535edddc5fcb8f1a064239416e561166eda Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 30 Aug 2017 23:08:44 +0100 Subject: add dnf package management --- docs/env.sh | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/docs/env.sh b/docs/env.sh index 518123e2f..3ad3306ea 100644 --- a/docs/env.sh +++ b/docs/env.sh @@ -184,6 +184,24 @@ ns-yum-install() sudo yum -y install $(echo ${NS_DEV_RPM} ${NS_TOOL_RPM} ${NS_GTK_RPM}) } + +# DNF RPM packages for rpm based systems (tested on fedora 25) +NS_DEV_DNF_RPM="java-1.8.0-openjdk-headless gcc clang pkgconfig libcurl-devel libjpeg-devel expat-devel libpng-devel openssl-devel gperf perl-HTML-Parser" +NS_TOOL_DNF_RPM="git flex bison ccache screen" +if [ "x${NETSURF_GTK_MAJOR}" = "x3" ]; then + NS_GTK_DNF_RPM="gtk3-devel" +else + NS_GTK_DNF_RPM="gtk2-devel" +fi + +# dnf commandline to install necessary dev packages +ns-dnf-install() +{ + sudo dnf install $(echo ${NS_DEV_DNF_RPM} ${NS_TOOL_DNF_RPM} ${NS_GTK_DNF_RPM}) +} + + + # Haiku secondary arch suffix: # empty for primary (gcc2 on x86), # "_x86" for gcc4 secondary. @@ -227,19 +245,21 @@ fi ns-package-install() { if [ -x "/usr/bin/apt-get" ]; then - ns-apt-get-install + ns-apt-get-install + elif [ -x "/usr/bin/dnf" ]; then + ns-dnf-install elif [ -x "/usr/bin/yum" ]; then - ns-yum-install + ns-yum-install elif [ -x "/bin/pkgman" ]; then - ns-pkgman-install + ns-pkgman-install elif [ -x "/opt/local/bin/port" ]; then - ns-macport-install + ns-macport-install elif [ -x "/usr/sbin/pkg" ]; then - ns-freebsdpkg-install + ns-freebsdpkg-install else echo "Unable to determine OS packaging system in use." - echo "Please ensure development packages are installed for:" - echo ${NS_DEV_GEN}"," ${NS_TOOL_GEN}"," ${NS_GTK_GEN} + echo "Please ensure development packages are installed for:" + echo ${NS_DEV_GEN}"," ${NS_TOOL_GEN}"," ${NS_GTK_GEN} fi } -- cgit v1.2.1 From d1eb578ffe5abad751d0c2007e53975b7e2781a0 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 30 Aug 2017 23:09:15 +0100 Subject: add logging library to required libraries --- docs/env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/env.sh b/docs/env.sh index 3ad3306ea..13e101e6b 100644 --- a/docs/env.sh +++ b/docs/env.sh @@ -90,7 +90,7 @@ NS_GIT="git://git.netsurf-browser.org" NS_BUILDSYSTEM="buildsystem" # internal libraries all frontends require (order is important) -NS_INTERNAL_LIBS="libwapcaplet libparserutils libhubbub libdom libcss libnsgif libnsbmp libutf8proc libnsutils libnspsl" +NS_INTERNAL_LIBS="libwapcaplet libparserutils libhubbub libdom libcss libnsgif libnsbmp libutf8proc libnsutils libnspsl libnslog" # The browser itself NS_BROWSER="netsurf" -- cgit v1.2.1 From b72b9d1f1fe2bd406311b4f43ee3f370011251e7 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 30 Aug 2017 23:10:07 +0100 Subject: clean up whitespace and indentation --- docs/env.sh | 75 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/docs/env.sh b/docs/env.sh index 13e101e6b..8a82ad083 100644 --- a/docs/env.sh +++ b/docs/env.sh @@ -22,28 +22,28 @@ fi # Get the host build if unset if [ "x${HOST}" = "x" ]; then if [ "x${TARGET_ABI}" = "x" ]; then - HOST=${BUILD} + HOST=${BUILD} else - HOST=${TARGET_ABI} + HOST=${TARGET_ABI} fi else HOST_CC_LIST="${HOST}-cc ${HOST}-gcc /opt/netsurf/${HOST}/cross/bin/${HOST}-cc /opt/netsurf/${HOST}/cross/bin/${HOST}-gcc" for HOST_CC_V in $(echo ${HOST_CC_LIST});do - HOST_CC=$(/bin/which ${HOST_CC_V}) - if [ "x${HOST_CC}" != "x" ];then - break - fi + HOST_CC=$(/bin/which ${HOST_CC_V}) + if [ "x${HOST_CC}" != "x" ];then + break + fi done if [ "x${HOST_CC}" = "x" ];then - echo "Unable to execute host compiler for HOST=${HOST}. is it set correctly?" - return 1 + echo "Unable to execute host compiler for HOST=${HOST}. is it set correctly?" + return 1 fi HOST_CC_MACHINE=$(${HOST_CC} -dumpmachine 2>/dev/null) if [ "${HOST_CC_MACHINE}" != "${HOST}" ];then - echo "Compiler dumpmachine differes from HOST setting" - return 2 + echo "Compiler dumpmachine differes from HOST setting" + return 2 fi unset HOST_CC_LIST HOST_CC_V HOST_CC HOST_CC_MACHINE fi @@ -139,8 +139,8 @@ case "${HOST}" in NS_TOOLS="" # libraries required for the freebsd frontend NS_FRONTEND_LIBS="" - # select gnu make - MAKE=gmake + # select gnu make + MAKE=gmake ;; *) # default tools required to build the browser @@ -268,13 +268,13 @@ ns-package-install() # git pull in all repos parameters are passed to git pull ns-pull() { - for REPO in $(echo ${NS_BUILDSYSTEM} ${NS_INTERNAL_LIBS} ${NS_FRONTEND_LIBS} ${NS_TOOLS} ${NS_BROWSER}) ; do - echo -n " GIT: Pulling ${REPO}: " - if [ -f "${TARGET_WORKSPACE}/${REPO}/.git/config" ]; then - (cd ${TARGET_WORKSPACE}/${REPO} && git pull $*; ) - else - echo "Repository not present" - fi + for REPO in $(echo ${NS_BUILDSYSTEM} ${NS_INTERNAL_LIBS} ${NS_FRONTEND_LIBS} ${NS_TOOLS} ${NS_BROWSER}) ; do + echo -n " GIT: Pulling ${REPO}: " + if [ -f "${TARGET_WORKSPACE}/${REPO}/.git/config" ]; then + (cd ${TARGET_WORKSPACE}/${REPO} && git pull $*; ) + else + echo "Repository not present" + fi done } @@ -282,18 +282,18 @@ ns-pull() ns-clone() { mkdir -p ${TARGET_WORKSPACE} - for REPO in $(echo ${NS_BUILDSYSTEM} ${NS_INTERNAL_LIBS} ${NS_FRONTEND_LIBS} ${NS_RISCOS_LIBS} ${NS_TOOLS} ${NS_BROWSER}) ; do - echo -n " GIT: Cloning ${REPO}: " - if [ -f ${TARGET_WORKSPACE}/${REPO}/.git/config ]; then - echo "Repository already present" - else - (cd ${TARGET_WORKSPACE} && git clone ${NS_GIT}/${REPO}.git; ) - fi + for REPO in $(echo ${NS_BUILDSYSTEM} ${NS_INTERNAL_LIBS} ${NS_FRONTEND_LIBS} ${NS_RISCOS_LIBS} ${NS_TOOLS} ${NS_BROWSER}) ; do + echo -n " GIT: Cloning ${REPO}: " + if [ -f ${TARGET_WORKSPACE}/${REPO}/.git/config ]; then + echo "Repository already present" + else + (cd ${TARGET_WORKSPACE} && git clone ${NS_GIT}/${REPO}.git; ) + fi done # put current env.sh in place in workspace if [ ! -f "${TARGET_WORKSPACE}/env.sh" -a -f ${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh ]; then - cp ${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh ${TARGET_WORKSPACE}/env.sh + cp ${TARGET_WORKSPACE}/${NS_BROWSER}/docs/env.sh ${TARGET_WORKSPACE}/env.sh fi } @@ -301,19 +301,19 @@ ns-clone() ns-make-libs() { for REPO in $(echo ${NS_BUILDSYSTEM} ${NS_TOOLS}); do - echo " MAKE: make -C ${REPO} $USE_CPUS $*" - ${MAKE} -C ${TARGET_WORKSPACE}/${REPO} $USE_CPUS $* - if [ $? -ne 0 ]; then - return $? - fi + echo " MAKE: make -C ${REPO} $USE_CPUS $*" + ${MAKE} -C ${TARGET_WORKSPACE}/${REPO} $USE_CPUS $* + if [ $? -ne 0 ]; then + return $? + fi done - for REPO in $(echo ${NS_INTERNAL_LIBS} ${NS_FRONTEND_LIBS}); do - echo " MAKE: make -C ${REPO} $USE_CPUS $*" + for REPO in $(echo ${NS_INTERNAL_LIBS} ${NS_FRONTEND_LIBS}); do + echo " MAKE: make -C ${REPO} $USE_CPUS $*" ${MAKE} -C ${TARGET_WORKSPACE}/${REPO} HOST=${HOST} $USE_CPUS $* - if [ $? -ne 0 ]; then - return $? - fi + if [ $? -ne 0 ]; then + return $? + fi done } @@ -337,4 +337,3 @@ ns-make() { ${MAKE} $USE_CPUS "$@" } - -- cgit v1.2.1 From f8cdbbce19b102fb958c56f628a4f76f7f3e5052 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 30 Aug 2017 23:27:28 +0100 Subject: slightly amend how user config is included --- Makefile | 5 ++++- Makefile.defaults | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0c2933bf8..1c2f517d6 100644 --- a/Makefile +++ b/Makefile @@ -505,9 +505,12 @@ CXXWARNFLAGS := # C default warning flags CWARNFLAGS := -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -# Pull in the configuration +# Pull in the default configuration include Makefile.defaults +# Pull in the user configuration +-include Makefile.config + # libraries enabled by feature switch without pkgconfig file $(eval $(call feature_switch,JPEG,JPEG (libjpeg),-DWITH_JPEG,-ljpeg,-UWITH_JPEG,)) $(eval $(call feature_switch,HARU_PDF,PDF export (haru),-DWITH_PDF_EXPORT,-lhpdf -lpng,-UWITH_PDF_EXPORT,)) diff --git a/Makefile.defaults b/Makefile.defaults index 619b8db08..a3ccf871d 100644 --- a/Makefile.defaults +++ b/Makefile.defaults @@ -136,11 +136,9 @@ endif # ---------------------------------------------------------------------------- -# Include any local configuration +# Detect double inclusion # ---------------------------------------------------------------------------- ifneq ($(MAKEFILE_DEFAULTS_FINISHED),) $(error Makefile.defaults has been double-included. If you did something utterly brain-dead such as copying Makefile.defaults to Makefile.config then you deserve all the pain you can imagine. Do NOT do that. Why not read the comments at the top of Makefile.defaults. They are there to help you, you numpty) endif MAKEFILE_DEFAULTS_FINISHED=yes --include Makefile.config - -- cgit v1.2.1 From 8d9b2efc11529da8cb5870b39ff15249c648b10a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 31 Aug 2017 07:57:35 +0100 Subject: use nslog library for logging if available. --- Makefile | 6 + Makefile.defaults | 8 + content/handlers/javascript/duktape/dukky.h | 4 +- test/log.c | 12 +- utils/log.c | 221 +++++++++++++++++----------- utils/log.h | 42 ++++-- 6 files changed, 193 insertions(+), 100 deletions(-) diff --git a/Makefile b/Makefile index 1c2f517d6..146b2f7cb 100644 --- a/Makefile +++ b/Makefile @@ -537,6 +537,7 @@ NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG NETSURF_FEATURE_OPENSSL_CFLAGS := -DWITH_OPENSSL NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE NETSURF_FEATURE_NSPSL_CFLAGS := -DWITH_NSPSL +NETSURF_FEATURE_NSLOG_CFLAGS := -DWITH_NSLOG # libcurl and openssl ordering matters as if libcurl requires ssl it # needs to come first in link order to ensure its symbols can be @@ -557,6 +558,7 @@ $(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF)) $(eval $(call pkg_config_find_and_add_enabled,NSSVG,libsvgtiny,SVG)) $(eval $(call pkg_config_find_and_add_enabled,ROSPRITE,librosprite,Sprite)) $(eval $(call pkg_config_find_and_add_enabled,NSPSL,libnspsl,PSL)) +$(eval $(call pkg_config_find_and_add_enabled,NSLOG,libnslog,LOG)) # List of directories in which headers are searched for INCLUDE_DIRS :=. include $(OBJROOT) @@ -569,6 +571,10 @@ CXXFLAGS += -DNETSURF_UA_FORMAT_STRING=\"$(NETSURF_UA_FORMAT_STRING)\" CFLAGS += -DNETSURF_HOMEPAGE=\"$(NETSURF_HOMEPAGE)\" CXXFLAGS += -DNETSURF_HOMEPAGE=\"$(NETSURF_HOMEPAGE)\" +# set the logging level +CFLAGS += -DNETSURF_LOG_LEVEL=$(NETSURF_LOG_LEVEL) +CXXFLAGS += -DNETSURF_LOG_LEVEL=$(NETSURF_LOG_LEVEL) + # ---------------------------------------------------------------------------- # General make rules # ---------------------------------------------------------------------------- diff --git a/Makefile.defaults b/Makefile.defaults index a3ccf871d..d6637da9e 100644 --- a/Makefile.defaults +++ b/Makefile.defaults @@ -70,8 +70,16 @@ NETSURF_USE_DUKTAPE := YES NETSURF_USE_HARU_PDF := NO # Enable the use of the Public suffix library to detect supercookies +# Valid options: YES, NO, AUTO (highly recommended) NETSURF_USE_NSPSL := AUTO +# Enable use of filtered logging library +# Valid options: YES, NO, AUTO (highly recommended) +NETSURF_USE_NSLOG := AUTO +# The minimum logging level *compiled* into netsurf +# Valid options are: DEEPDEBUG, DEBUG, VERBOSE, INFO, WARNING, ERROR, CRITICAL +NETSURF_LOG_LEVEL := INFO + # Enable stripping the NetSurf binary # Valid options: YES, NO NETSURF_STRIP_BINARY := NO diff --git a/content/handlers/javascript/duktape/dukky.h b/content/handlers/javascript/duktape/dukky.h index b5809aa08..435e0c305 100644 --- a/content/handlers/javascript/duktape/dukky.h +++ b/content/handlers/javascript/duktape/dukky.h @@ -26,11 +26,13 @@ #define DUKKY_H #ifdef JS_DEBUG -# define JS_LOG(format, args...) LOG(format , ##args) +# define JS_LOG(format, args...) NSLOG(netsurf, INFO, format , ##args) #else # define JS_LOG(format, ...) ((void) 0) #endif +#define LOG(format, args...) NSLOG(netsurf, INFO, format , ##args) + duk_ret_t dukky_create_object(duk_context *ctx, const char *name, int args); duk_bool_t dukky_push_node_stacked(duk_context *ctx); duk_bool_t dukky_push_node(duk_context *ctx, struct dom_node *node); diff --git a/test/log.c b/test/log.c index 90b4379e9..fc6b6285c 100644 --- a/test/log.c +++ b/test/log.c @@ -42,13 +42,15 @@ void nslog_log(const char *file, const char *func, int ln, const char *format, . { va_list ap; - fprintf(stderr, "%s:%i %s: ", file, ln, func); + if (verbose_log) { + fprintf(stderr, "%s:%i %s: ", file, ln, func); - va_start(ap, format); + va_start(ap, format); - vfprintf(stderr, format, ap); + vfprintf(stderr, format, ap); - va_end(ap); + va_end(ap); - fputc('\n', stderr); + fputc('\n', stderr); + } } diff --git a/utils/log.c b/utils/log.c index 15a7a9e75..2f0d3b3bf 100644 --- a/utils/log.c +++ b/utils/log.c @@ -36,6 +36,116 @@ bool verbose_log = false; /** The stream to which logging is sent */ static FILE *logfile; +NSLOG_DEFINE_CATEGORY(netsurf, "NetSurf default logging"); + +/** Subtract the `struct timeval' values X and Y + * + * \param result The timeval structure to store the result in + * \param x The first value + * \param y The second value + * \return 1 if the difference is negative, otherwise 0. + */ +static int +timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y) +{ + /* Perform the carry for the later subtraction by updating y. */ + if (x->tv_usec < y->tv_usec) { + int nsec = (int)(y->tv_usec - x->tv_usec) / 1000000 + 1; + y->tv_usec -= 1000000 * nsec; + y->tv_sec += nsec; + } + if ((int)(x->tv_usec - y->tv_usec) > 1000000) { + int nsec = (int)(x->tv_usec - y->tv_usec) / 1000000; + y->tv_usec += 1000000 * nsec; + y->tv_sec -= nsec; + } + + /* Compute the time remaining to wait. + tv_usec is certainly positive. */ + result->tv_sec = x->tv_sec - y->tv_sec; + result->tv_usec = x->tv_usec - y->tv_usec; + + /* Return 1 if result is negative. */ + return x->tv_sec < y->tv_sec; +} + +/** + * Obtain a formatted string suitable for prepending to a log message + * + * \return formatted string of the time since first log call + */ +static const char *nslog_gettime(void) +{ + static struct timeval start_tv; + static char buff[32]; + + struct timeval tv; + struct timeval now_tv; + + if (!timerisset(&start_tv)) { + gettimeofday(&start_tv, NULL); + } + gettimeofday(&now_tv, NULL); + + timeval_subtract(&tv, &now_tv, &start_tv); + + snprintf(buff, sizeof(buff),"(%ld.%06ld)", + (long)tv.tv_sec, (long)tv.tv_usec); + + return buff; +} + +#ifdef WITH_NSLOG + +static void +netsurf_render_log(void *_ctx, + nslog_entry_context_t *ctx, + const char *fmt, + va_list args) +{ + + fprintf(logfile, + "%s %.*s:%i %.*s: ", + nslog_gettime(), + ctx->filenamelen, + ctx->filename, + ctx->lineno, + ctx->funcnamelen, + ctx->funcname); + + vfprintf(logfile, fmt, args); + + /* Log entries aren't newline terminated add one for clarity */ + fputc('\n', logfile); +} + +#else + +void +nslog_log(const char *file, const char *func, int ln, const char *format, ...) +{ + va_list ap; + + if (verbose_log) { + fprintf(logfile, + "%s %s:%i %s: ", + nslog_gettime(), + file, + ln, + func); + + va_start(ap, format); + + vfprintf(logfile, format, ap); + + va_end(ap); + + fputc('\n', logfile); + } +} + +#endif + nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) { struct utsname utsname; @@ -59,9 +169,9 @@ nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) /* ensure we actually show logging */ verbose_log = true; } else if (((*pargc) > 2) && - (argv[1][0] == '-') && - (argv[1][1] == 'V') && - (argv[1][2] == 0)) { + (argv[1][0] == '-') && + (argv[1][1] == 'V') && + (argv[1][2] == 0)) { int argcmv; /* verbose logging to file */ @@ -96,94 +206,35 @@ nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) verbose_log = false; } +#ifdef WITH_NSLOG + + if (nslog_set_render_callback(netsurf_render_log, NULL) != NSLOG_NO_ERROR) { + ret = NSERROR_INIT_FAILED; + verbose_log = false; + + } else if (nslog_uncork() != NSLOG_NO_ERROR) { + ret = NSERROR_INIT_FAILED; + verbose_log = false; + } + +#endif + /* sucessfull logging initialisation so log system info */ if (ret == NSERROR_OK) { - LOG("NetSurf version '%s'", netsurf_version); + NSLOG(netsurf, INFO, "NetSurf version '%s'", netsurf_version); if (uname(&utsname) < 0) { - LOG("Failed to extract machine information"); + NSLOG(netsurf, INFO, + "Failed to extract machine information"); } else { - LOG("NetSurf on <%s>, node <%s>, release <%s>, version <%s>, machine <%s>", - utsname.sysname, - utsname.nodename, - utsname.release, - utsname.version, - utsname.machine); + NSLOG(netsurf, INFO, + "NetSurf on <%s>, node <%s>, release <%s>, version <%s>, machine <%s>", + utsname.sysname, + utsname.nodename, + utsname.release, + utsname.version, + utsname.machine); } } return ret; } - -#ifndef NDEBUG - -/* Subtract the `struct timeval' values X and Y, - storing the result in RESULT. - Return 1 if the difference is negative, otherwise 0. -*/ - -static int -timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y) -{ - /* Perform the carry for the later subtraction by updating y. */ - if (x->tv_usec < y->tv_usec) { - int nsec = (int)(y->tv_usec - x->tv_usec) / 1000000 + 1; - y->tv_usec -= 1000000 * nsec; - y->tv_sec += nsec; - } - if ((int)(x->tv_usec - y->tv_usec) > 1000000) { - int nsec = (int)(x->tv_usec - y->tv_usec) / 1000000; - y->tv_usec += 1000000 * nsec; - y->tv_sec -= nsec; - } - - /* Compute the time remaining to wait. - tv_usec is certainly positive. */ - result->tv_sec = x->tv_sec - y->tv_sec; - result->tv_usec = x->tv_usec - y->tv_usec; - - /* Return 1 if result is negative. */ - return x->tv_sec < y->tv_sec; -} - -/** - * Obtain a formatted string suitable for prepending to a log message - * - * \return formatted string of the time since first log call - */ -static const char *nslog_gettime(void) -{ - static struct timeval start_tv; - static char buff[32]; - - struct timeval tv; - struct timeval now_tv; - - if (!timerisset(&start_tv)) { - gettimeofday(&start_tv, NULL); - } - gettimeofday(&now_tv, NULL); - - timeval_subtract(&tv, &now_tv, &start_tv); - - snprintf(buff, sizeof(buff),"(%ld.%06ld)", - (long)tv.tv_sec, (long)tv.tv_usec); - - return buff; -} - -void nslog_log(const char *file, const char *func, int ln, const char *format, ...) -{ - va_list ap; - - fprintf(logfile, "%s %s:%i %s: ", nslog_gettime(), file, ln, func); - - va_start(ap, format); - - vfprintf(logfile, format, ap); - - va_end(ap); - - fputc('\n', logfile); -} - -#endif diff --git a/utils/log.h b/utils/log.h index 708016b18..0e73f4d37 100644 --- a/utils/log.h +++ b/utils/log.h @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -#ifndef _NETSURF_LOG_H_ -#define _NETSURF_LOG_H_ +#ifndef NETSURF_LOG_H +#define NETSURF_LOG_H #include #include @@ -43,9 +43,31 @@ typedef bool(nslog_ensure_t)(FILE *fptr); */ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv); -#ifdef NDEBUG -# define LOG(format, ...) ((void) 0) -#else +#ifndef NETSURF_LOG_LEVEL +#define NETSURF_LOG_LEVEL INFO +#endif + +#define NSLOG_LVL(level) NSLOG_LEVEL_ ## level +#define NSLOG_EVL(level) NSLOG_LVL(level) +#define NSLOG_COMPILED_MIN_LEVEL NSLOG_EVL(NETSURF_LOG_LEVEL) + +#ifdef WITH_NSLOG + +#include + +NSLOG_DECLARE_CATEGORY(netsurf); + +#else /* WITH_NSLOG */ + +enum nslog_level { + NSLOG_LEVEL_DEEPDEBUG = 0, + NSLOG_LEVEL_DEBUG = 1, + NSLOG_LEVEL_VERBOSE = 2, + NSLOG_LEVEL_INFO = 3, + NSLOG_LEVEL_WARNING = 4, + NSLOG_LEVEL_ERROR = 5, + NSLOG_LEVEL_CRITICAL = 6 +}; extern void nslog_log(const char *file, const char *func, int ln, const char *format, ...) __attribute__ ((format (printf, 4, 5))); @@ -60,13 +82,15 @@ extern void nslog_log(const char *file, const char *func, int ln, const char *fo # define LOG_LN __LINE__ # endif -#define LOG(format, args...) \ +#define NSLOG(catname, level, logmsg, args...) \ do { \ - if (verbose_log) { \ - nslog_log(__FILE__, LOG_FN, LOG_LN, format , ##args); \ + if (NSLOG_LEVEL_##level >= NSLOG_COMPILED_MIN_LEVEL) { \ + nslog_log(__FILE__, LOG_FN, LOG_LN, logmsg , ##args); \ } \ } while(0) -#endif +#define NSLOG_DEFINE_CATEGORY(catname, description) + +#endif /* WITH_NSLOG */ #endif -- cgit v1.2.1 From 75018632a9b953aafeae6f4e8aea607fd1d89dca Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 6 Sep 2017 18:28:12 +0100 Subject: Use coccinelle to change logging macro calls in c files for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done @@ expression E; @@ -LOG(E); +NSLOG(netsurf, INFO, E); @@ expression E, E1; @@ -LOG(E, E1); +NSLOG(netsurf, INFO, E, E1); @@ expression E, E1, E2; @@ -LOG(E, E1, E2); +NSLOG(netsurf, INFO, E, E1, E2); @@ expression E, E1, E2, E3; @@ -LOG(E, E1, E2, E3); +NSLOG(netsurf, INFO, E, E1, E2, E3); @@ expression E, E1, E2, E3, E4; @@ -LOG(E, E1, E2, E3, E4); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4); @@ expression E, E1, E2, E3, E4, E5; @@ -LOG(E, E1, E2, E3, E4, E5); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5); @@ expression E, E1, E2, E3, E4, E5, E6; @@ -LOG(E, E1, E2, E3, E4, E5, E6); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6); @@ expression E, E1, E2, E3, E4, E5, E6, E7; @@ -LOG(E, E1, E2, E3, E4, E5, E6, E7); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7); --- content/content.c | 29 ++-- content/fetch.c | 15 +- content/fetchers/curl.c | 80 ++++++---- content/fetchers/data.c | 17 +- content/fetchers/resource.c | 6 +- content/fs_backing_store.c | 225 ++++++++++++++++----------- content/handlers/css/css.c | 15 +- content/handlers/css/hints.c | 2 +- content/handlers/css/select.c | 17 +- content/handlers/image/ico.c | 8 +- content/handlers/image/image_cache.c | 110 +++++++------ content/handlers/image/jpeg.c | 4 +- content/handlers/image/nssprite.c | 4 +- content/handlers/image/png.c | 15 +- content/handlers/image/rsvg.c | 17 +- content/handlers/javascript/duktape/dukky.c | 131 +++++++++------- content/hlcache.c | 19 ++- content/llcache.c | 45 +++--- content/urldb.c | 60 ++++--- desktop/browser.c | 43 +++-- desktop/browser_history.c | 7 +- desktop/cookie_manager.c | 11 +- desktop/font_haru.c | 24 ++- desktop/frames.c | 6 +- desktop/global_history.c | 15 +- desktop/hotlist.c | 27 ++-- desktop/knockout.c | 8 +- desktop/mouse.c | 2 +- desktop/netsurf.c | 30 ++-- desktop/print.c | 6 +- desktop/save_complete.c | 11 +- desktop/save_pdf.c | 43 ++--- desktop/save_text.c | 8 +- desktop/searchweb.c | 14 +- desktop/sslcert_viewer.c | 8 +- desktop/textarea.c | 29 ++-- desktop/treeview.c | 19 +-- frontends/amiga/arexx.c | 2 +- frontends/amiga/bitmap.c | 12 +- frontends/amiga/cookies.c | 2 +- frontends/amiga/corewindow.c | 5 +- frontends/amiga/drag.c | 3 +- frontends/amiga/dt_anim.c | 14 +- frontends/amiga/dt_picture.c | 6 +- frontends/amiga/dt_sound.c | 17 +- frontends/amiga/filetype.c | 8 +- frontends/amiga/font.c | 12 +- frontends/amiga/font_bullet.c | 21 ++- frontends/amiga/font_cache.c | 14 +- frontends/amiga/font_diskfont.c | 4 +- frontends/amiga/font_scan.c | 24 +-- frontends/amiga/gui.c | 79 ++++++---- frontends/amiga/gui_menu.c | 3 +- frontends/amiga/history.c | 2 +- frontends/amiga/history_local.c | 2 +- frontends/amiga/hotlist.c | 2 +- frontends/amiga/memory.c | 73 +++++---- frontends/amiga/misc.c | 2 +- frontends/amiga/os3support.c | 18 +-- frontends/amiga/plotters.c | 29 ++-- frontends/amiga/plugin_hack.c | 20 +-- frontends/amiga/schedule.c | 11 +- frontends/amiga/selectmenu.c | 3 +- frontends/amiga/sslcert.c | 2 +- frontends/atari/bitmap.c | 32 ++-- frontends/atari/certview.c | 16 +- frontends/atari/cookies.c | 15 +- frontends/atari/ctxmenu.c | 7 +- frontends/atari/deskmenu.c | 64 ++++---- frontends/atari/download.c | 14 +- frontends/atari/filetype.c | 4 +- frontends/atari/findfile.c | 18 +-- frontends/atari/gui.c | 55 ++++--- frontends/atari/history.c | 15 +- frontends/atari/hotlist.c | 21 +-- frontends/atari/osspec.c | 6 +- frontends/atari/plot/font_freetype.c | 23 ++- frontends/atari/plot/font_internal.c | 2 +- frontends/atari/plot/font_vdi.c | 2 +- frontends/atari/plot/plot.c | 5 +- frontends/atari/rootwin.c | 45 ++++-- frontends/atari/schedule.c | 25 +-- frontends/atari/search.c | 12 +- frontends/atari/settings.c | 6 +- frontends/atari/statusbar.c | 4 +- frontends/atari/toolbar.c | 15 +- frontends/atari/treeview.c | 6 +- frontends/atari/verify_ssl.c | 8 +- frontends/framebuffer/bitmap.c | 11 +- frontends/framebuffer/clipboard.c | 4 +- frontends/framebuffer/convert_font.c | 198 ++++++++++++----------- frontends/framebuffer/fbtk/event.c | 4 +- frontends/framebuffer/fbtk/fbtk.c | 22 ++- frontends/framebuffer/fbtk/scroll.c | 4 +- frontends/framebuffer/fetch.c | 2 +- frontends/framebuffer/font_freetype.c | 19 ++- frontends/framebuffer/framebuffer.c | 15 +- frontends/framebuffer/gui.c | 39 +++-- frontends/framebuffer/schedule.c | 6 +- frontends/gtk/cookies.c | 7 +- frontends/gtk/corewindow.c | 4 +- frontends/gtk/download.c | 2 +- frontends/gtk/fetch.c | 3 +- frontends/gtk/gdk.c | 2 +- frontends/gtk/global_history.c | 7 +- frontends/gtk/gui.c | 65 ++++---- frontends/gtk/hotlist.c | 7 +- frontends/gtk/layout_pango.c | 4 +- frontends/gtk/local_history.c | 2 +- frontends/gtk/login.c | 2 +- frontends/gtk/plotters.c | 4 +- frontends/gtk/preferences.c | 11 +- frontends/gtk/print.c | 28 ++-- frontends/gtk/resources.c | 50 +++--- frontends/gtk/scaffolding.c | 33 ++-- frontends/gtk/schedule.c | 14 +- frontends/gtk/ssl_cert.c | 2 +- frontends/gtk/tabs.c | 8 +- frontends/gtk/throbber.c | 6 +- frontends/gtk/toolbar.c | 5 +- frontends/gtk/viewdata.c | 23 +-- frontends/gtk/window.c | 27 ++-- frontends/monkey/browser.c | 2 +- frontends/monkey/dispatch.c | 2 +- frontends/monkey/filetype.c | 3 +- frontends/monkey/main.c | 8 +- frontends/monkey/schedule.c | 7 +- frontends/riscos/401login.c | 5 +- frontends/riscos/bitmap.c | 32 ++-- frontends/riscos/buffer.c | 36 +++-- frontends/riscos/configure.c | 32 ++-- frontends/riscos/configure/con_language.c | 6 +- frontends/riscos/configure/con_theme.c | 23 ++- frontends/riscos/content-handlers/artworks.c | 32 ++-- frontends/riscos/content-handlers/draw.c | 6 +- frontends/riscos/content-handlers/sprite.c | 5 +- frontends/riscos/cookies.c | 4 +- frontends/riscos/corewindow.c | 97 ++++++------ frontends/riscos/dialog.c | 53 +++++-- frontends/riscos/download.c | 152 ++++++++++++------ frontends/riscos/filetype.c | 37 +++-- frontends/riscos/font.c | 75 +++++---- frontends/riscos/global_history.c | 4 +- frontends/riscos/gui.c | 116 +++++++++----- frontends/riscos/gui/button_bar.c | 30 +++- frontends/riscos/gui/progress_bar.c | 18 ++- frontends/riscos/gui/status_bar.c | 62 +++++--- frontends/riscos/gui/throbber.c | 11 +- frontends/riscos/gui/url_bar.c | 48 ++++-- frontends/riscos/help.c | 22 ++- frontends/riscos/hotlist.c | 7 +- frontends/riscos/iconbar.c | 6 +- frontends/riscos/image.c | 20 ++- frontends/riscos/local_history.c | 47 +++--- frontends/riscos/menus.c | 31 ++-- frontends/riscos/message.c | 8 +- frontends/riscos/mouse.c | 5 +- frontends/riscos/plotters.c | 104 ++++++++----- frontends/riscos/print.c | 77 ++++++--- frontends/riscos/query.c | 21 ++- frontends/riscos/save.c | 116 ++++++++++---- frontends/riscos/save_draw.c | 12 +- frontends/riscos/schedule.c | 2 +- frontends/riscos/sslcert.c | 36 ++--- frontends/riscos/textarea.c | 127 ++++++++++----- frontends/riscos/textselection.c | 38 +++-- frontends/riscos/theme.c | 44 ++++-- frontends/riscos/theme_install.c | 5 +- frontends/riscos/toolbar.c | 48 ++++-- frontends/riscos/ucstables.c | 7 +- frontends/riscos/uri.c | 6 +- frontends/riscos/url_complete.c | 66 +++++--- frontends/riscos/url_protocol.c | 19 ++- frontends/riscos/wimp.c | 135 +++++++++++----- frontends/riscos/wimp_event.c | 76 ++++++--- frontends/riscos/window.c | 193 +++++++++++++++-------- frontends/windows/about.c | 8 +- frontends/windows/bitmap.c | 32 ++-- frontends/windows/corewindow.c | 10 +- frontends/windows/download.c | 8 +- frontends/windows/drawable.c | 30 ++-- frontends/windows/filetype.c | 2 +- frontends/windows/findfile.c | 4 +- frontends/windows/gui.c | 4 +- frontends/windows/main.c | 13 +- frontends/windows/plot.c | 18 +-- frontends/windows/prefs.c | 3 +- frontends/windows/schedule.c | 6 +- frontends/windows/ssl_cert.c | 11 +- frontends/windows/window.c | 84 +++++----- render/box.c | 4 +- render/box_construct.c | 2 +- render/box_normalise.c | 27 ++-- render/box_textarea.c | 4 +- render/form.c | 142 +++++++++++------ render/html.c | 71 +++++---- render/html_css.c | 40 +++-- render/html_css_fetcher.c | 11 +- render/html_interaction.c | 2 +- render/html_object.c | 17 +- render/html_script.c | 49 +++--- render/imagemap.c | 24 ++- render/layout.c | 97 ++++++++---- render/table.c | 7 +- render/textplain.c | 4 +- test/urldbtest.c | 13 +- utils/filename.c | 32 ++-- utils/hashtable.c | 10 +- utils/idna.c | 38 +++-- utils/messages.c | 25 +-- utils/nsoption.c | 10 +- utils/nsurl/nsurl.c | 6 +- utils/nsurl/parse.c | 27 ++-- utils/useragent.c | 3 +- utils/utf8.c | 5 +- 215 files changed, 3497 insertions(+), 2170 deletions(-) diff --git a/content/content.c b/content/content.c index 45a4016f0..8ed5c1ba8 100644 --- a/content/content.c +++ b/content/content.c @@ -73,7 +73,8 @@ nserror content__init(struct content *c, const content_handler *handler, struct content_user *user_sentinel; nserror error; - LOG("url "URL_FMT_SPC" -> %p", nsurl_access(llcache_handle_get_url(llcache)), c); + NSLOG(netsurf, INFO, "url "URL_FMT_SPC" -> %p", + nsurl_access(llcache_handle_get_url(llcache)), c); user_sentinel = calloc(1, sizeof(struct content_user)); if (user_sentinel == NULL) { @@ -272,7 +273,8 @@ void content_convert(struct content *c) if (c->locked == true) return; - LOG("content "URL_FMT_SPC" (%p)", nsurl_access(llcache_handle_get_url(c->llcache)), c); + NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p)", + nsurl_access(llcache_handle_get_url(c->llcache)), c); if (c->handler->data_complete != NULL) { c->locked = true; @@ -376,7 +378,8 @@ void content_destroy(struct content *c) struct content_rfc5988_link *link; assert(c); - LOG("content %p %s", c, nsurl_access(llcache_handle_get_url(c->llcache))); + NSLOG(netsurf, INFO, "content %p %s", c, + nsurl_access(llcache_handle_get_url(c->llcache))); assert(c->locked == false); if (c->handler->destroy != NULL) @@ -585,7 +588,7 @@ bool content_scaled_redraw(struct hlcache_handle *h, return true; } - LOG("Content %p %dx%d ctx:%p", c, width, height, ctx); + NSLOG(netsurf, INFO, "Content %p %dx%d ctx:%p", c, width, height, ctx); if (ctx->plot->option_knockout) { knockout_plot_start(ctx, &new_ctx); @@ -654,7 +657,9 @@ bool content_add_user( { struct content_user *user; - LOG("content "URL_FMT_SPC" (%p), user %p %p", nsurl_access(llcache_handle_get_url(c->llcache)), c, callback, pw); + NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p), user %p %p", + nsurl_access(llcache_handle_get_url(c->llcache)), c, callback, + pw); user = malloc(sizeof(struct content_user)); if (!user) return false; @@ -687,7 +692,9 @@ void content_remove_user( void *pw) { struct content_user *user, *next; - LOG("content "URL_FMT_SPC" (%p), user %p %p", nsurl_access(llcache_handle_get_url(c->llcache)), c, callback, pw); + NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p), user %p %p", + nsurl_access(llcache_handle_get_url(c->llcache)), c, callback, + pw); /* user_list starts with a sentinel */ for (user = c->user_list; user->next != 0 && @@ -695,7 +702,7 @@ void content_remove_user( user->next->pw == pw); user = user->next) ; if (user->next == 0) { - LOG("user not found in list"); + NSLOG(netsurf, INFO, "user not found in list"); assert(0); return; } @@ -808,7 +815,8 @@ void content_open(hlcache_handle *h, struct browser_window *bw, { struct content *c = hlcache_handle_get_content(h); assert(c != 0); - LOG("content %p %s", c, nsurl_access(llcache_handle_get_url(c->llcache))); + NSLOG(netsurf, INFO, "content %p %s", c, + nsurl_access(llcache_handle_get_url(c->llcache))); if (c->handler->open != NULL) c->handler->open(c, bw, page, params); } @@ -824,7 +832,8 @@ void content_close(hlcache_handle *h) { struct content *c = hlcache_handle_get_content(h); assert(c != 0); - LOG("content %p %s", c, nsurl_access(llcache_handle_get_url(c->llcache))); + NSLOG(netsurf, INFO, "content %p %s", c, + nsurl_access(llcache_handle_get_url(c->llcache))); if (c->handler->close != NULL) c->handler->close(c); } @@ -1472,7 +1481,7 @@ nserror content__clone(const struct content *c, struct content *nc) */ nserror content_abort(struct content *c) { - LOG("Aborting %p", c); + NSLOG(netsurf, INFO, "Aborting %p", c); if (c->handler->stop != NULL) c->handler->stop(c); diff --git a/content/fetch.c b/content/fetch.c index a69d3e4cf..fc72d13f9 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -217,14 +217,16 @@ static void dump_rings(void) q = queue_ring; if (q) { do { - LOG("queue_ring: %s", nsurl_access(q->url)); + NSLOG(netsurf, INFO, "queue_ring: %s", + nsurl_access(q->url)); q = q->r_next; } while (q != queue_ring); } f = fetch_ring; if (f) { do { - LOG("fetch_ring: %s", nsurl_access(f->url)); + NSLOG(netsurf, INFO, "fetch_ring: %s", + nsurl_access(f->url)); f = f->r_next; } while (f != fetch_ring); } @@ -341,7 +343,10 @@ void fetcher_quit(void) * the reference count to allow the fetcher to * be stopped. */ - LOG("Fetcher for scheme %s still has %d active users at quit.", lwc_string_data(fetchers[fetcherd].scheme), fetchers[fetcherd].refcount); + NSLOG(netsurf, INFO, + "Fetcher for scheme %s still has %d active users at quit.", + lwc_string_data(fetchers[fetcherd].scheme), + fetchers[fetcherd].refcount); fetchers[fetcherd].refcount = 1; } @@ -753,9 +758,9 @@ void fetch_remove_from_queues(struct fetch *fetch) RING_GETSIZE(struct fetch, fetch_ring, all_active); RING_GETSIZE(struct fetch, queue_ring, all_queued); - LOG("Fetch ring is now %d elements.", all_active); + NSLOG(netsurf, INFO, "Fetch ring is now %d elements.", all_active); - LOG("Queue ring is now %d elements.", all_queued); + NSLOG(netsurf, INFO, "Queue ring is now %d elements.", all_queued); #endif } diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c index 7d0e40c24..a6146edb3 100644 --- a/content/fetchers/curl.c +++ b/content/fetchers/curl.c @@ -155,7 +155,8 @@ static void ns_X509_free(X509 *cert) */ static bool fetch_curl_initialise(lwc_string *scheme) { - LOG("Initialise cURL fetcher for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "Initialise cURL fetcher for %s", + lwc_string_data(scheme)); curl_fetchers_registered++; return true; /* Always succeeds */ } @@ -171,17 +172,20 @@ static void fetch_curl_finalise(lwc_string *scheme) struct cache_handle *h; curl_fetchers_registered--; - LOG("Finalise cURL fetcher %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "Finalise cURL fetcher %s", + lwc_string_data(scheme)); if (curl_fetchers_registered == 0) { CURLMcode codem; /* All the fetchers have been finalised. */ - LOG("All cURL fetchers finalised, closing down cURL"); + NSLOG(netsurf, INFO, + "All cURL fetchers finalised, closing down cURL"); curl_easy_cleanup(fetch_blank_curl); codem = curl_multi_cleanup(fetch_curl_multi); if (codem != CURLM_OK) - LOG("curl_multi_cleanup failed: ignoring"); + NSLOG(netsurf, INFO, + "curl_multi_cleanup failed: ignoring"); curl_global_cleanup(); } @@ -251,7 +255,9 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control) "application/octet-stream", CURLFORM_END); if (code != CURL_FORMADD_OK) - LOG("curl_formadd: %d (%s)", code, control->name); + NSLOG(netsurf, INFO, + "curl_formadd: %d (%s)", code, + control->name); } else { char *mimetype = guit->fetch->mimetype(control->value); code = curl_formadd(&post, &last, @@ -262,7 +268,11 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control) (mimetype != 0 ? mimetype : "text/plain"), CURLFORM_END); if (code != CURL_FORMADD_OK) - LOG("curl_formadd: %d (%s=%s)", code, control->name, control->value); + NSLOG(netsurf, INFO, + "curl_formadd: %d (%s=%s)", + code, + control->name, + control->value); free(mimetype); } free(leafname); @@ -273,7 +283,9 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control) CURLFORM_COPYCONTENTS, control->value, CURLFORM_END); if (code != CURL_FORMADD_OK) - LOG("curl_formadd: %d (%s=%s)", code, control->name, control->value); + NSLOG(netsurf, INFO, + "curl_formadd: %d (%s=%s)", code, + control->name, control->value); } } @@ -321,7 +333,7 @@ fetch_curl_setup(struct fetch *parent_fetch, fetch->fetch_handle = parent_fetch; - LOG("fetch %p, url '%s'", fetch, nsurl_access(url)); + NSLOG(netsurf, INFO, "fetch %p, url '%s'", fetch, nsurl_access(url)); /* construct a new fetch structure */ fetch->curl_handle = NULL; @@ -776,7 +788,7 @@ static void fetch_curl_abort(void *vf) { struct curl_fetch_info *f = (struct curl_fetch_info *)vf; assert(f); - LOG("fetch %p, url '%s'", f, nsurl_access(f->url)); + NSLOG(netsurf, INFO, "fetch %p, url '%s'", f, nsurl_access(f->url)); if (f->curl_handle) { f->abort = true; } else { @@ -796,7 +808,7 @@ static void fetch_curl_stop(struct curl_fetch_info *f) CURLMcode codem; assert(f); - LOG("fetch %p, url '%s'", f, nsurl_access(f->url)); + NSLOG(netsurf, INFO, "fetch %p, url '%s'", f, nsurl_access(f->url)); if (f->curl_handle) { /* remove from curl multi handle */ @@ -864,7 +876,7 @@ static bool fetch_curl_process_headers(struct curl_fetch_info *f) assert(code == CURLE_OK); } http_code = f->http_code; - LOG("HTTP status code %li", http_code); + NSLOG(netsurf, INFO, "HTTP status code %li", http_code); if (http_code == 304 && !f->post_urlenc && !f->post_multipart) { /* Not Modified && GET request */ @@ -875,7 +887,7 @@ static bool fetch_curl_process_headers(struct curl_fetch_info *f) /* handle HTTP redirects (3xx response codes) */ if (300 <= http_code && http_code < 400 && f->location != 0) { - LOG("FETCH_REDIRECT, '%s'", f->location); + NSLOG(netsurf, INFO, "FETCH_REDIRECT, '%s'", f->location); msg.type = FETCH_REDIRECT; msg.data.redirect = f->location; fetch_send_callback(&msg, f->fetch_handle); @@ -1037,7 +1049,7 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result) assert(code == CURLE_OK); abort_fetch = f->abort; - LOG("done %s", nsurl_access(f->url)); + NSLOG(netsurf, INFO, "done %s", nsurl_access(f->url)); if ((abort_fetch == false) && (result == CURLE_OK || @@ -1082,7 +1094,7 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result) memset(f->cert_data, 0, sizeof(f->cert_data)); cert = true; } else { - LOG("Unknown cURL response code %d", result); + NSLOG(netsurf, INFO, "Unknown cURL response code %d", result); error = true; } @@ -1146,7 +1158,8 @@ static void fetch_curl_poll(lwc_string *scheme_ignored) &exc_fd_set, &max_fd); assert(codem == CURLM_OK); - LOG("Curl file descriptor states (maxfd=%i):", max_fd); + NSLOG(netsurf, INFO, + "Curl file descriptor states (maxfd=%i):", max_fd); for (i = 0; i <= max_fd; i++) { bool read = false; bool write = false; @@ -1162,10 +1175,10 @@ static void fetch_curl_poll(lwc_string *scheme_ignored) error = true; } if (read || write || error) { - LOG(" fd %i: %s %s %s", i, - read ? "read" : " ", - write ? "write" : " ", - error ? "error" : " "); + NSLOG(netsurf, INFO, " fd %i: %s %s %s", i, + read ? "read" : " ", + write ? "write" : " ", + error ? "error" : " "); } } } @@ -1174,7 +1187,8 @@ static void fetch_curl_poll(lwc_string *scheme_ignored) do { codem = curl_multi_perform(fetch_curl_multi, &running); if (codem != CURLM_OK && codem != CURLM_CALL_MULTI_PERFORM) { - LOG("curl_multi_perform: %i %s", codem, curl_multi_strerror(codem)); + NSLOG(netsurf, INFO, "curl_multi_perform: %i %s", + codem, curl_multi_strerror(codem)); guit->misc->warning("MiscError", curl_multi_strerror(codem)); return; } @@ -1336,7 +1350,7 @@ fetch_curl_header(char *data, size_t size, size_t nmemb, void *_f) free(f->location); f->location = malloc(size); if (!f->location) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); return size; } SKIP_ST(9); @@ -1427,17 +1441,17 @@ nserror fetch_curl_register(void) .finalise = fetch_curl_finalise }; - LOG("curl_version %s", curl_version()); + NSLOG(netsurf, INFO, "curl_version %s", curl_version()); code = curl_global_init(CURL_GLOBAL_ALL); if (code != CURLE_OK) { - LOG("curl_global_init failed."); + NSLOG(netsurf, INFO, "curl_global_init failed."); return NSERROR_INIT_FAILED; } fetch_curl_multi = curl_multi_init(); if (!fetch_curl_multi) { - LOG("curl_multi_init failed."); + NSLOG(netsurf, INFO, "curl_multi_init failed."); return NSERROR_INIT_FAILED; } @@ -1465,7 +1479,7 @@ nserror fetch_curl_register(void) */ fetch_blank_curl = curl_easy_init(); if (!fetch_blank_curl) { - LOG("curl_easy_init failed"); + NSLOG(netsurf, INFO, "curl_easy_init failed"); return NSERROR_INIT_FAILED; } @@ -1497,11 +1511,12 @@ nserror fetch_curl_register(void) if (nsoption_charp(ca_bundle) && strcmp(nsoption_charp(ca_bundle), "")) { - LOG("ca_bundle: '%s'", nsoption_charp(ca_bundle)); + NSLOG(netsurf, INFO, "ca_bundle: '%s'", + nsoption_charp(ca_bundle)); SETOPT(CURLOPT_CAINFO, nsoption_charp(ca_bundle)); } if (nsoption_charp(ca_path) && strcmp(nsoption_charp(ca_path), "")) { - LOG("ca_path: '%s'", nsoption_charp(ca_path)); + NSLOG(netsurf, INFO, "ca_path: '%s'", nsoption_charp(ca_path)); SETOPT(CURLOPT_CAPATH, nsoption_charp(ca_path)); } @@ -1513,7 +1528,8 @@ nserror fetch_curl_register(void) curl_with_openssl = false; } - LOG("cURL %slinked against openssl", curl_with_openssl ? "" : "not "); + NSLOG(netsurf, INFO, "cURL %slinked against openssl", + curl_with_openssl ? "" : "not "); /* cURL initialised okay, register the fetchers */ @@ -1532,19 +1548,21 @@ nserror fetch_curl_register(void) } if (fetcher_add(scheme, &fetcher_ops) != NSERROR_OK) { - LOG("Unable to register cURL fetcher for %s", data->protocols[i]); + NSLOG(netsurf, INFO, + "Unable to register cURL fetcher for %s", + data->protocols[i]); } } return NSERROR_OK; curl_easy_setopt_failed: - LOG("curl_easy_setopt failed."); + NSLOG(netsurf, INFO, "curl_easy_setopt failed."); return NSERROR_INIT_FAILED; #if LIBCURL_VERSION_NUM >= 0x071e00 curl_multi_setopt_failed: - LOG("curl_multi_setopt failed."); + NSLOG(netsurf, INFO, "curl_multi_setopt failed."); return NSERROR_INIT_FAILED; #endif } diff --git a/content/fetchers/data.c b/content/fetchers/data.c index cb99e6ff2..5ba021fd3 100644 --- a/content/fetchers/data.c +++ b/content/fetchers/data.c @@ -57,14 +57,16 @@ static struct fetch_data_context *ring = NULL; static bool fetch_data_initialise(lwc_string *scheme) { - LOG("fetch_data_initialise called for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "fetch_data_initialise called for %s", + lwc_string_data(scheme)); return true; } static void fetch_data_finalise(lwc_string *scheme) { - LOG("fetch_data_finalise called for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "fetch_data_finalise called for %s", + lwc_string_data(scheme)); } static bool fetch_data_can_fetch(const nsurl *url) @@ -147,7 +149,7 @@ static bool fetch_data_process(struct fetch_data_context *c) * data must still be there. */ - LOG("url: %.140s", c->url); + NSLOG(netsurf, INFO, "url: %.140s", c->url); if (strlen(c->url) < 6) { /* 6 is the minimum possible length (data:,) */ @@ -259,8 +261,10 @@ static void fetch_data_poll(lwc_string *scheme) char header[64]; fetch_set_http_code(c->parent_fetch, 200); - LOG("setting data: MIME type to %s, length to %" PRIsizet, - c->mimetype, c->datalen); + NSLOG(netsurf, INFO, + "setting data: MIME type to %s, length to %"PRIsizet, + c->mimetype, + c->datalen); /* Any callback can result in the fetch being aborted. * Therefore, we _must_ check for this after _every_ * call to fetch_data_send_callback(). @@ -296,7 +300,8 @@ static void fetch_data_poll(lwc_string *scheme) fetch_data_send_callback(&msg, c); } } else { - LOG("Processing of %s failed!", c->url); + NSLOG(netsurf, INFO, "Processing of %s failed!", + c->url); /* Ensure that we're unlocked here. If we aren't, * then fetch_data_process() is broken. diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c index b8b4b191f..78757733e 100644 --- a/content/fetchers/resource.c +++ b/content/fetchers/resource.c @@ -276,14 +276,16 @@ static bool fetch_resource_initialise(lwc_string *scheme) &e->data, &e->data_len); if (res == NSERROR_OK) { - LOG("direct data for %s", fetch_resource_paths[i]); + NSLOG(netsurf, INFO, "direct data for %s", + fetch_resource_paths[i]); fetch_resource_path_count++; } else { e->redirect_url = guit->fetch->get_resource_url(fetch_resource_paths[i]); if (e->redirect_url == NULL) { lwc_string_unref(e->path); } else { - LOG("redirect url for %s", fetch_resource_paths[i]); + NSLOG(netsurf, INFO, "redirect url for %s", + fetch_resource_paths[i]); fetch_resource_path_count++; } } diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c index 9d410654b..648565088 100644 --- a/content/fs_backing_store.c +++ b/content/fs_backing_store.c @@ -519,11 +519,12 @@ invalidate_entry(struct store_state *state, struct store_entry *bse) * This entry cannot be immediately removed as it has * associated allocation so wait for allocation release. */ - LOG("invalidating entry with referenced allocation"); + NSLOG(netsurf, INFO, + "invalidating entry with referenced allocation"); return NSERROR_OK; } - LOG("Removing entry for %p", bse); + NSLOG(netsurf, INFO, "Removing entry for %p", bse); /* remove the entry from the index */ ret = remove_store_entry(state, &bse); @@ -533,12 +534,12 @@ invalidate_entry(struct store_state *state, struct store_entry *bse) ret = invalidate_element(state, bse, ENTRY_ELEM_META); if (ret != NSERROR_OK) { - LOG("Error invalidating metadata element"); + NSLOG(netsurf, INFO, "Error invalidating metadata element"); } ret = invalidate_element(state, bse, ENTRY_ELEM_DATA); if (ret != NSERROR_OK) { - LOG("Error invalidating data element"); + NSLOG(netsurf, INFO, "Error invalidating data element"); } return NSERROR_OK; @@ -620,8 +621,10 @@ static nserror store_evict(struct store_state *state) return NSERROR_OK; } - LOG("Evicting entries to reduce %"PRIu64" by %"PRIsizet, - state->total_alloc, state->hysteresis); + NSLOG(netsurf, INFO, + "Evicting entries to reduce %"PRIu64" by %"PRIsizet, + state->total_alloc, + state->hysteresis); /* allocate storage for the list */ elist = malloc(sizeof(entry_ident_t) * state->last_entry); @@ -658,7 +661,8 @@ static nserror store_evict(struct store_state *state) free(elist); - LOG("removed %"PRIsizet" in %d entries", removed, ent); + NSLOG(netsurf, INFO, "removed %"PRIsizet" in %d entries", removed, + ent); return ret; } @@ -773,7 +777,10 @@ static nserror write_blocks(struct store_state *state) &state->blocks[elem_idx][bfidx].use_map[0], BLOCK_USE_MAP_SIZE); if (wr != BLOCK_USE_MAP_SIZE) { - LOG("writing block file %d use index on file number %d failed", elem_idx, bfidx); + NSLOG(netsurf, INFO, + "writing block file %d use index on file number %d failed", + elem_idx, + bfidx); goto wr_err; } written += wr; @@ -829,19 +836,21 @@ static nserror set_block_extents(struct store_state *state) return NSERROR_OK; } - LOG("Starting"); + NSLOG(netsurf, INFO, "Starting"); for (elem_idx = 0; elem_idx < ENTRY_ELEM_COUNT; elem_idx++) { for (bfidx = 0; bfidx < BLOCK_FILE_COUNT; bfidx++) { if (state->blocks[elem_idx][bfidx].fd != -1) { /* ensure block file is correct extent */ ftr = ftruncate(state->blocks[elem_idx][bfidx].fd, 1U << (log2_block_size[elem_idx] + BLOCK_ENTRY_COUNT)); if (ftr == -1) { - LOG("Truncate failed errno:%d", errno); + NSLOG(netsurf, INFO, + "Truncate failed errno:%d", + errno); } } } } - LOG("Complete"); + NSLOG(netsurf, INFO, "Complete"); state->blocks_opened = false; @@ -886,7 +895,7 @@ get_store_entry(struct store_state *state, nsurl *url, struct store_entry **bse) entry_ident_t ident; unsigned int sei; /* store entry index */ - LOG("url:%s", nsurl_access(url)); + NSLOG(netsurf, INFO, "url:%s", nsurl_access(url)); /* use the url hash as the entry identifier */ ident = nsurl_hash(url); @@ -894,13 +903,14 @@ get_store_entry(struct store_state *state, nsurl *url, struct store_entry **bse) sei = BS_ENTRY_INDEX(ident, state); if (sei == 0) { - LOG("Failed to find ident 0x%x in index", ident); + NSLOG(netsurf, INFO, "Failed to find ident 0x%x in index", + ident); return NSERROR_NOT_FOUND; } if (state->entries[sei].ident != ident) { /* entry ident did not match */ - LOG("ident did not match entry"); + NSLOG(netsurf, INFO, "ident did not match entry"); return NSERROR_NOT_FOUND; } @@ -975,7 +985,7 @@ set_store_entry(struct store_state *state, nserror ret; struct store_entry_element *elem; - LOG("url:%s", nsurl_access(url)); + NSLOG(netsurf, INFO, "url:%s", nsurl_access(url)); /* evict entries as required and ensure there is at least one * new entry available. @@ -1013,7 +1023,10 @@ set_store_entry(struct store_state *state, * to see if the old entry is in use and if * not prefer the newly stored entry instead? */ - LOG("Entry index collision trying to replace %x with %x", se->ident, ident); + NSLOG(netsurf, INFO, + "Entry index collision trying to replace %x with %x", + se->ident, + ident); return NSERROR_PERMISSION; } } @@ -1026,7 +1039,8 @@ set_store_entry(struct store_state *state, /* this entry cannot be removed as it has associated * allocation. */ - LOG("attempt to overwrite entry with in use data"); + NSLOG(netsurf, INFO, + "attempt to overwrite entry with in use data"); return NSERROR_PERMISSION; } @@ -1085,7 +1099,7 @@ store_open(struct store_state *state, fname = store_fname(state, ident, elem_idx); if (fname == NULL) { - LOG("filename error"); + NSLOG(netsurf, INFO, "filename error"); return -1; } @@ -1093,13 +1107,14 @@ store_open(struct store_state *state, if (openflags & O_CREAT) { ret = netsurf_mkdir_all(fname); if (ret != NSERROR_OK) { - LOG("file path \"%s\" could not be created", fname); + NSLOG(netsurf, INFO, + "file path \"%s\" could not be created", fname); free(fname); return -1; } } - LOG("opening %s", fname); + NSLOG(netsurf, INFO, "opening %s", fname); fd = open(fname, openflags, S_IRUSR | S_IWUSR); free(fname); @@ -1126,9 +1141,9 @@ build_entrymap(struct store_state *state) { unsigned int eloop; - LOG("Allocating %ld bytes for max of %d buckets", - (1 << state->ident_bits) * sizeof(entry_index_t), - 1 << state->ident_bits); + NSLOG(netsurf, INFO, "Allocating %ld bytes for max of %d buckets", + (1 << state->ident_bits) * sizeof(entry_index_t), + 1 << state->ident_bits); state->addrmap = calloc(1 << state->ident_bits, sizeof(entry_index_t)); if (state->addrmap == NULL) { @@ -1204,10 +1219,12 @@ read_entries(struct store_state *state) entries_size = (1 << state->entry_bits) * sizeof(struct store_entry); - LOG("Allocating %"PRIsizet" bytes for max of %d entries of %ld length elements %ld length", - entries_size, 1 << state->entry_bits, - sizeof(struct store_entry), - sizeof(struct store_entry_element)); + NSLOG(netsurf, INFO, + "Allocating %"PRIsizet" bytes for max of %d entries of %ld length elements %ld length", + entries_size, + 1 << state->entry_bits, + sizeof(struct store_entry), + sizeof(struct store_entry_element)); state->entries = calloc(1, entries_size); if (state->entries == NULL) { @@ -1222,7 +1239,8 @@ read_entries(struct store_state *state) close(fd); if (rd > 0) { state->last_entry = rd / sizeof(struct store_entry); - LOG("Read %d entries", state->last_entry); + NSLOG(netsurf, INFO, "Read %d entries", + state->last_entry); } } else { /* could rebuild entries from fs */ @@ -1253,7 +1271,7 @@ read_blocks(struct store_state *state) return ret; } - LOG("Initialising block use map from %s", fname); + NSLOG(netsurf, INFO, "Initialising block use map from %s", fname); fd = open(fname, O_RDWR); free(fname); @@ -1265,7 +1283,10 @@ read_blocks(struct store_state *state) &state->blocks[elem_idx][bfidx].use_map[0], BLOCK_USE_MAP_SIZE); if (rd <= 0) { - LOG("reading block file %d use index on file number %d failed", elem_idx, bfidx); + NSLOG(netsurf, INFO, + "reading block file %d use index on file number %d failed", + elem_idx, + bfidx); goto rd_err; } } @@ -1274,7 +1295,7 @@ read_blocks(struct store_state *state) close(fd); } else { - LOG("Initialising block use map to defaults"); + NSLOG(netsurf, INFO, "Initialising block use map to defaults"); /* ensure block 0 (invalid sentinel) is skipped */ state->blocks[ENTRY_ELEM_DATA][0].use_map[0] = 1; state->blocks[ENTRY_ELEM_META][0].use_map[0] = 1; @@ -1344,7 +1365,7 @@ write_control(struct store_state *state) return ret; } - LOG("writing control file \"%s\"", fname); + NSLOG(netsurf, INFO, "writing control file \"%s\"", fname); ret = netsurf_mkdir_all(fname); if (ret != NSERROR_OK) { @@ -1392,7 +1413,7 @@ read_control(struct store_state *state) return ret; } - LOG("opening control file \"%s\"", fname); + NSLOG(netsurf, INFO, "opening control file \"%s\"", fname); fcontrol = fopen(fname, "rb"); @@ -1509,7 +1530,8 @@ initialise(const struct llcache_store_parameters *parameters) /* read store control and create new if required */ ret = read_control(newstate); if (ret != NSERROR_OK) { - LOG("read control failed %s", messages_get_errorcode(ret)); + NSLOG(netsurf, INFO, "read control failed %s", + messages_get_errorcode(ret)); ret = write_control(newstate); if (ret == NSERROR_OK) { unlink_entries(newstate); @@ -1558,15 +1580,17 @@ initialise(const struct llcache_store_parameters *parameters) storestate = newstate; - LOG("FS backing store init successful"); + NSLOG(netsurf, INFO, "FS backing store init successful"); - LOG("path:%s limit:%"PRIsizet" hyst:%"PRIsizet" addr:%d entries:%d", - newstate->path, - newstate->limit, - newstate->hysteresis, - newstate->ident_bits, - newstate->entry_bits); - LOG("Using %"PRIu64"/%"PRIsizet, newstate->total_alloc, newstate->limit); + NSLOG(netsurf, INFO, + "path:%s limit:%"PRIsizet" hyst:%"PRIsizet" addr:%d entries:%d", + newstate->path, + newstate->limit, + newstate->hysteresis, + newstate->ident_bits, + newstate->entry_bits); + NSLOG(netsurf, INFO, "Using %"PRIu64"/%"PRIsizet, + newstate->total_alloc, newstate->limit); return NSERROR_OK; } @@ -1605,14 +1629,15 @@ finalise(void) /* avoid division by zero */ if (op_count > 0) { - LOG("Cache total/hit/miss/fail (counts) %d/%"PRIsizet"/%"PRIsizet"/%d (100%%/%"PRIsizet"%%/%"PRIsizet"%%/%d%%)", - op_count, - storestate->hit_count, - storestate->miss_count, - 0, - (storestate->hit_count * 100) / op_count, - (storestate->miss_count * 100) / op_count, - 0); + NSLOG(netsurf, INFO, + "Cache total/hit/miss/fail (counts) %d/%"PRIsizet"/%"PRIsizet"/%d (100%%/%"PRIsizet"%%/%"PRIsizet"%%/%d%%)", + op_count, + storestate->hit_count, + storestate->miss_count, + 0, + (storestate->hit_count * 100) / op_count, + (storestate->miss_count * 100) / op_count, + 0); } free(storestate->path); @@ -1646,7 +1671,7 @@ static nserror store_write_block(struct store_state *state, state->blocks[elem_idx][bf].fd = store_open(state, bf, elem_idx + ENTRY_ELEM_COUNT, O_CREAT | O_RDWR); if (state->blocks[elem_idx][bf].fd == -1) { - LOG("Open failed errno %d", errno); + NSLOG(netsurf, INFO, "Open failed errno %d", errno); return NSERROR_SAVE_FAILED; } @@ -1661,21 +1686,21 @@ static nserror store_write_block(struct store_state *state, bse->elem[elem_idx].size, offst); if (wr != (ssize_t)bse->elem[elem_idx].size) { - LOG("Write failed %"PRIssizet" of %d bytes from %p at 0x%jx block %d errno %d", - wr, - bse->elem[elem_idx].size, - bse->elem[elem_idx].data, - (uintmax_t)offst, - bse->elem[elem_idx].block, - errno); + NSLOG(netsurf, INFO, + "Write failed %"PRIssizet" of %d bytes from %p at 0x%jx block %d errno %d", + wr, + bse->elem[elem_idx].size, + bse->elem[elem_idx].data, + (uintmax_t)offst, + bse->elem[elem_idx].block, + errno); return NSERROR_SAVE_FAILED; } - LOG("Wrote %"PRIssizet" bytes from %p at 0x%jx block %d", - wr, - bse->elem[elem_idx].data, - (uintmax_t)offst, - bse->elem[elem_idx].block); + NSLOG(netsurf, INFO, + "Wrote %"PRIssizet" bytes from %p at 0x%jx block %d", wr, + bse->elem[elem_idx].data, (uintmax_t)offst, + bse->elem[elem_idx].block); return NSERROR_OK; } @@ -1699,7 +1724,7 @@ static nserror store_write_file(struct store_state *state, fd = store_open(state, bse->ident, elem_idx, O_CREAT | O_WRONLY); if (fd < 0) { perror(""); - LOG("Open failed %d errno %d", fd, errno); + NSLOG(netsurf, INFO, "Open failed %d errno %d", fd, errno); return NSERROR_SAVE_FAILED; } @@ -1708,17 +1733,19 @@ static nserror store_write_file(struct store_state *state, close(fd); if (wr != (ssize_t)bse->elem[elem_idx].size) { - LOG("Write failed %"PRIssizet" of %d bytes from %p errno %d", - wr, - bse->elem[elem_idx].size, - bse->elem[elem_idx].data, - err); + NSLOG(netsurf, INFO, + "Write failed %"PRIssizet" of %d bytes from %p errno %d", + wr, + bse->elem[elem_idx].size, + bse->elem[elem_idx].data, + err); /** @todo Delete the file? */ return NSERROR_SAVE_FAILED; } - LOG("Wrote %"PRIssizet" bytes from %p", wr, bse->elem[elem_idx].data); + NSLOG(netsurf, INFO, "Wrote %"PRIssizet" bytes from %p", wr, + bse->elem[elem_idx].data); return NSERROR_OK; } @@ -1759,7 +1786,7 @@ store(nsurl *url, /* set the store entry up */ ret = set_store_entry(storestate, url, elem_idx, data, datalen, &bse); if (ret != NSERROR_OK) { - LOG("store entry setting failed"); + NSLOG(netsurf, INFO, "store entry setting failed"); return ret; } @@ -1782,7 +1809,7 @@ static nserror entry_release_alloc(struct store_entry_element *elem) if ((elem->flags & ENTRY_ELEM_FLAG_HEAP) != 0) { elem->ref--; if (elem->ref == 0) { - LOG("freeing %p", elem->data); + NSLOG(netsurf, INFO, "freeing %p", elem->data); free(elem->data); elem->flags &= ~ENTRY_ELEM_FLAG_HEAP; } @@ -1814,7 +1841,7 @@ static nserror store_read_block(struct store_state *state, state->blocks[elem_idx][bf].fd = store_open(state, bf, elem_idx + ENTRY_ELEM_COUNT, O_CREAT | O_RDWR); if (state->blocks[elem_idx][bf].fd == -1) { - LOG("Open failed errno %d", errno); + NSLOG(netsurf, INFO, "Open failed errno %d", errno); return NSERROR_SAVE_FAILED; } @@ -1829,21 +1856,21 @@ static nserror store_read_block(struct store_state *state, bse->elem[elem_idx].size, offst); if (rd != (ssize_t)bse->elem[elem_idx].size) { - LOG("Failed reading %"PRIssizet" of %d bytes into %p from 0x%jx block %d errno %d", - rd, - bse->elem[elem_idx].size, - bse->elem[elem_idx].data, - (uintmax_t)offst, - bse->elem[elem_idx].block, - errno); + NSLOG(netsurf, INFO, + "Failed reading %"PRIssizet" of %d bytes into %p from 0x%jx block %d errno %d", + rd, + bse->elem[elem_idx].size, + bse->elem[elem_idx].data, + (uintmax_t)offst, + bse->elem[elem_idx].block, + errno); return NSERROR_SAVE_FAILED; } - LOG("Read %"PRIssizet" bytes into %p from 0x%jx block %d", - rd, - bse->elem[elem_idx].data, - (uintmax_t)offst, - bse->elem[elem_idx].block); + NSLOG(netsurf, INFO, + "Read %"PRIssizet" bytes into %p from 0x%jx block %d", rd, + bse->elem[elem_idx].data, (uintmax_t)offst, + bse->elem[elem_idx].block); return NSERROR_OK; } @@ -1868,7 +1895,7 @@ static nserror store_read_file(struct store_state *state, /* separate file in backing store */ fd = store_open(storestate, bse->ident, elem_idx, O_RDONLY); if (fd < 0) { - LOG("Open failed %d errno %d", fd, errno); + NSLOG(netsurf, INFO, "Open failed %d errno %d", fd, errno); /** @todo should this invalidate the entry? */ return NSERROR_NOT_FOUND; } @@ -1878,8 +1905,10 @@ static nserror store_read_file(struct store_state *state, bse->elem[elem_idx].data + tot, bse->elem[elem_idx].size - tot); if (rd <= 0) { - LOG("read error returned %"PRIssizet" errno %d", - rd, errno); + NSLOG(netsurf, INFO, + "read error returned %"PRIssizet" errno %d", + rd, + errno); ret = NSERROR_NOT_FOUND; break; } @@ -1888,7 +1917,8 @@ static nserror store_read_file(struct store_state *state, close(fd); - LOG("Read %"PRIsizet" bytes into %p", tot, bse->elem[elem_idx].data); + NSLOG(netsurf, INFO, "Read %"PRIsizet" bytes into %p", tot, + bse->elem[elem_idx].data); return ret; } @@ -1921,13 +1951,14 @@ fetch(nsurl *url, /* fetch store entry */ ret = get_store_entry(storestate, url, &bse); if (ret != NSERROR_OK) { - LOG("entry not found"); + NSLOG(netsurf, INFO, "entry not found"); storestate->miss_count++; return ret; } storestate->hit_count++; - LOG("retrieving cache data for url:%s", nsurl_access(url)); + NSLOG(netsurf, INFO, "retrieving cache data for url:%s", + nsurl_access(url)); /* calculate the entry element index */ if ((bsflags & BACKING_STORE_META) != 0) { @@ -1942,16 +1973,20 @@ fetch(nsurl *url, /* use the existing allocation and bump the ref count. */ elem->ref++; - LOG("Using existing entry (%p) allocation %p refs:%d", bse, elem->data, elem->ref); + NSLOG(netsurf, INFO, + "Using existing entry (%p) allocation %p refs:%d", bse, + elem->data, elem->ref); } else { /* allocate from the heap */ elem->data = malloc(elem->size); if (elem->data == NULL) { - LOG("Failed to create new heap allocation"); + NSLOG(netsurf, INFO, + "Failed to create new heap allocation"); return NSERROR_NOMEM; } - LOG("Created new heap allocation %p", elem->data); + NSLOG(netsurf, INFO, "Created new heap allocation %p", + elem->data); /* mark the entry as having a valid heap allocation */ elem->flags |= ENTRY_ELEM_FLAG_HEAP; @@ -2000,7 +2035,7 @@ static nserror release(nsurl *url, enum backing_store_flags bsflags) ret = get_store_entry(storestate, url, &bse); if (ret != NSERROR_OK) { - LOG("entry not found"); + NSLOG(netsurf, INFO, "entry not found"); return ret; } diff --git a/content/handlers/css/css.c b/content/handlers/css/css.c index 0a8ffdd5a..93efd6a1b 100644 --- a/content/handlers/css/css.c +++ b/content/handlers/css/css.c @@ -321,9 +321,11 @@ static css_error nscss_convert_css_data(struct content_css_data *c) const char *url; if (css_stylesheet_get_url(c->sheet, &url) == CSS_OK) { - LOG("Failed converting %p %s (%d)", c, url, error); + NSLOG(netsurf, INFO, "Failed converting %p %s (%d)", + c, url, error); } else { - LOG("Failed converting %p (%d)", c, error); + NSLOG(netsurf, INFO, "Failed converting %p (%d)", c, + error); } } @@ -598,7 +600,9 @@ css_error nscss_handle_import(void *pw, css_stylesheet *parent, nsurl_unref(ns_ref); #ifdef NSCSS_IMPORT_TRACE - LOG("Import %d '%s' -> (handle: %p ctx: %p)", c->import_count, lwc_string_data(url), c->imports[c->import_count].c, ctx); + NSLOG(netsurf, INFO, "Import %d '%s' -> (handle: %p ctx: %p)", + c->import_count, lwc_string_data(url), + c->imports[c->import_count].c, ctx); #endif c->import_count++; @@ -621,7 +625,7 @@ nserror nscss_import(hlcache_handle *handle, css_error error = CSS_OK; #ifdef NSCSS_IMPORT_TRACE - LOG("Event %d for %p (%p)", event->type, handle, ctx); + NSLOG(netsurf, INFO, "Event %d for %p (%p)", event->type, handle, ctx); #endif assert(ctx->css->imports[ctx->index].c == handle); @@ -663,7 +667,8 @@ css_error nscss_import_complete(nscss_import_ctx *ctx) error = nscss_register_imports(ctx->css); #ifdef NSCSS_IMPORT_TRACE - LOG("Destroying import context %p for %d", ctx, ctx->index); + NSLOG(netsurf, INFO, "Destroying import context %p for %d", ctx, + ctx->index); #endif /* No longer need import context */ diff --git a/content/handlers/css/hints.c b/content/handlers/css/hints.c index 9dfcf402b..08fe438c1 100644 --- a/content/handlers/css/hints.c +++ b/content/handlers/css/hints.c @@ -1615,7 +1615,7 @@ css_error node_presentational_hint(void *pw, void *node, } #ifdef LOG_STATS - LOG("Properties with hints: %i", hint_ctx.len); + NSLOG(netsurf, INFO, "Properties with hints: %i", hint_ctx.len); #endif css_hint_get_hints(hints, nhints); diff --git a/content/handlers/css/select.c b/content/handlers/css/select.c index daa3b4087..328d6a711 100644 --- a/content/handlers/css/select.c +++ b/content/handlers/css/select.c @@ -175,20 +175,20 @@ css_stylesheet *nscss_create_inline_style(const uint8_t *data, size_t len, error = css_stylesheet_create(¶ms, &sheet); if (error != CSS_OK) { - LOG("Failed creating sheet: %d", error); + NSLOG(netsurf, INFO, "Failed creating sheet: %d", error); return NULL; } error = css_stylesheet_append_data(sheet, data, len); if (error != CSS_OK && error != CSS_NEEDDATA) { - LOG("failed appending data: %d", error); + NSLOG(netsurf, INFO, "failed appending data: %d", error); css_stylesheet_destroy(sheet); return NULL; } error = css_stylesheet_data_done(sheet); if (error != CSS_OK) { - LOG("failed completing parse: %d", error); + NSLOG(netsurf, INFO, "failed completing parse: %d", error); css_stylesheet_destroy(sheet); return NULL; } @@ -214,7 +214,8 @@ static void nscss_dom_user_data_handler(dom_node_operation operation, CSS_NODE_CLONED, NULL, src, dst, data); if (error != CSS_OK) - LOG("Failed to clone libcss_node_data."); + NSLOG(netsurf, INFO, + "Failed to clone libcss_node_data."); break; case DOM_NODE_RENAMED: @@ -222,7 +223,8 @@ static void nscss_dom_user_data_handler(dom_node_operation operation, CSS_NODE_MODIFIED, NULL, src, NULL, data); if (error != CSS_OK) - LOG("Failed to update libcss_node_data."); + NSLOG(netsurf, INFO, + "Failed to update libcss_node_data."); break; case DOM_NODE_IMPORTED: @@ -232,11 +234,12 @@ static void nscss_dom_user_data_handler(dom_node_operation operation, CSS_NODE_DELETED, NULL, src, NULL, data); if (error != CSS_OK) - LOG("Failed to delete libcss_node_data."); + NSLOG(netsurf, INFO, + "Failed to delete libcss_node_data."); break; default: - LOG("User data operation not handled."); + NSLOG(netsurf, INFO, "User data operation not handled."); assert(0); } } diff --git a/content/handlers/image/ico.c b/content/handlers/image/ico.c index d1865a3b4..85aab9f64 100644 --- a/content/handlers/image/ico.c +++ b/content/handlers/image/ico.c @@ -160,7 +160,7 @@ static bool nsico_convert(struct content *c) bmp = ico_find(ico->ico, 255, 255); if (bmp == NULL) { /* return error */ - LOG("Failed to select icon"); + NSLOG(netsurf, INFO, "Failed to select icon"); return false; } @@ -183,7 +183,7 @@ static bool nsico_redraw(struct content *c, struct content_redraw_data *data, bmp = ico_find(ico->ico, data->width, data->height); if (bmp == NULL) { /* return error */ - LOG("Failed to select icon"); + NSLOG(netsurf, INFO, "Failed to select icon"); return false; } @@ -192,7 +192,7 @@ static bool nsico_redraw(struct content *c, struct content_redraw_data *data, if (bmp_decode(bmp) != BMP_OK) { return false; } else { - LOG("Decoding bitmap"); + NSLOG(netsurf, INFO, "Decoding bitmap"); guit->bitmap->modified(bmp->bitmap); } @@ -255,7 +255,7 @@ static void *nsico_get_internal(const struct content *c, void *context) bmp = ico_find(ico->ico, 16, 16); if (bmp == NULL) { /* return error */ - LOG("Failed to select icon"); + NSLOG(netsurf, INFO, "Failed to select icon"); return NULL; } diff --git a/content/handlers/image/image_cache.c b/content/handlers/image/image_cache.c index 02107f75f..7fba11fb9 100644 --- a/content/handlers/image/image_cache.c +++ b/content/handlers/image/image_cache.c @@ -256,11 +256,12 @@ static void image_cache__free_bitmap(struct image_cache_entry_s *centry) { if (centry->bitmap != NULL) { #ifdef IMAGE_CACHE_VERBOSE - LOG("Freeing bitmap %p size %d age %d redraw count %d", - centry->bitmap, - centry->bitmap_size, - image_cache->current_age - centry->bitmap_age, - centry->redraw_count); + NSLOG(netsurf, INFO, + "Freeing bitmap %p size %d age %d redraw count %d", + centry->bitmap, + centry->bitmap_size, + image_cache->current_age - centry->bitmap_age, + centry->redraw_count); #endif guit->bitmap->destroy(centry->bitmap); centry->bitmap = NULL; @@ -281,7 +282,7 @@ static void image_cache__free_bitmap(struct image_cache_entry_s *centry) static void image_cache__free_entry(struct image_cache_entry_s *centry) { #ifdef IMAGE_CACHE_VERBOSE - LOG("freeing %p ", centry); + NSLOG(netsurf, INFO, "freeing %p ", centry); #endif if (centry->redraw_count == 0) { @@ -331,7 +332,7 @@ static void image_cache__background_update(void *p) icache->current_age += icache->params.bg_clean_time; #ifdef IMAGE_CACHE_VERBOSE - LOG("Cache age %ds", icache->current_age / 1000); + NSLOG(netsurf, INFO, "Cache age %ds", icache->current_age / 1000); #endif image_cache__clean(icache); @@ -383,13 +384,16 @@ bool image_cache_speculate(struct content *c) if ((image_cache->total_bitmap_size < image_cache->params.limit) && (c->size <= image_cache->params.speculative_small)) { #ifdef IMAGE_CACHE_VERBOSE - LOG("content size (%d) is smaller than minimum (%d)", c->size, SPECULATE_SMALL); + NSLOG(netsurf, INFO, + "content size (%d) is smaller than minimum (%d)", + c->size, + SPECULATE_SMALL); #endif decision = true; } #ifdef IMAGE_CACHE_VERBOSE - LOG("returning %d", decision); + NSLOG(netsurf, INFO, "returning %d", decision); #endif return decision; } @@ -422,8 +426,10 @@ image_cache_init(const struct image_cache_parameters *image_cache_parameters) image_cache__background_update, image_cache); - LOG("Image cache initialised with a limit of %" PRIsizet " hysteresis of %"PRIsizet, - image_cache->params.limit, image_cache->params.hysteresis); + NSLOG(netsurf, INFO, + "Image cache initialised with a limit of %"PRIsizet" hysteresis of %"PRIsizet, + image_cache->params.limit, + image_cache->params.hysteresis); return NSERROR_OK; } @@ -435,8 +441,8 @@ nserror image_cache_fini(void) guit->misc->schedule(-1, image_cache__background_update, image_cache); - LOG("Size at finish %" PRIsizet " (in %d)", - image_cache->total_bitmap_size, image_cache->bitmap_count); + NSLOG(netsurf, INFO, "Size at finish %"PRIsizet" (in %d)", + image_cache->total_bitmap_size, image_cache->bitmap_count); while (image_cache->entries != NULL) { image_cache__free_entry(image_cache->entries); @@ -446,11 +452,13 @@ nserror image_cache_fini(void) image_cache->miss_count + image_cache->fail_count; - LOG("Age %ds", image_cache->current_age / 1000); - LOG("Peak size %" PRIsizet " (in %d)", - image_cache->max_bitmap_size, image_cache->max_bitmap_size_count); - LOG("Peak image count %d (size %" PRIsizet ")", - image_cache->max_bitmap_count, image_cache->max_bitmap_count_size); + NSLOG(netsurf, INFO, "Age %ds", image_cache->current_age / 1000); + NSLOG(netsurf, INFO, "Peak size %"PRIsizet" (in %d)", + image_cache->max_bitmap_size, + image_cache->max_bitmap_size_count); + NSLOG(netsurf, INFO, "Peak image count %d (size %"PRIsizet")", + image_cache->max_bitmap_count, + image_cache->max_bitmap_count_size); if (op_count > 0) { uint64_t op_size; @@ -459,35 +467,39 @@ nserror image_cache_fini(void) image_cache->miss_size + image_cache->fail_size; - LOG("Cache total/hit/miss/fail (counts) %d/%d/%d/%d (100%%/%d%%/%d%%/%d%%)", - op_count, - image_cache->hit_count, - image_cache->miss_count, - image_cache->fail_count, - (image_cache->hit_count * 100) / op_count, - (image_cache->miss_count * 100) / op_count, - (image_cache->fail_count * 100) / op_count); - LOG("Cache total/hit/miss/fail (size) %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64" (100%%/%"PRId64"%%/%"PRId64"%%/%"PRId64"%%)", - op_size, - image_cache->hit_size, - image_cache->miss_size, - image_cache->fail_size, - (image_cache->hit_size * 100) / op_size, - (image_cache->miss_size * 100) / op_size, - (image_cache->fail_size * 100) / op_size); + NSLOG(netsurf, INFO, + "Cache total/hit/miss/fail (counts) %d/%d/%d/%d (100%%/%d%%/%d%%/%d%%)", + op_count, + image_cache->hit_count, + image_cache->miss_count, + image_cache->fail_count, + (image_cache->hit_count * 100) / op_count, + (image_cache->miss_count * 100) / op_count, + (image_cache->fail_count * 100) / op_count); + NSLOG(netsurf, INFO, + "Cache total/hit/miss/fail (size) %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64" (100%%/%"PRId64"%%/%"PRId64"%%/%"PRId64"%%)", + op_size, + image_cache->hit_size, + image_cache->miss_size, + image_cache->fail_size, + (image_cache->hit_size * 100) / op_size, + (image_cache->miss_size * 100) / op_size, + (image_cache->fail_size * 100) / op_size); } - LOG("Total images never rendered: %d (includes %d that were converted)", - image_cache->total_unrendered, - image_cache->specultive_miss_count); + NSLOG(netsurf, INFO, + "Total images never rendered: %d (includes %d that were converted)", + image_cache->total_unrendered, + image_cache->specultive_miss_count); - LOG("Total number of excessive conversions: %d (from %d images converted more than once)", - image_cache->total_extra_conversions, - image_cache->total_extra_conversions_count); + NSLOG(netsurf, INFO, + "Total number of excessive conversions: %d (from %d images converted more than once)", + image_cache->total_extra_conversions, + image_cache->total_extra_conversions_count); - LOG("Bitmap of size %d had most (%d) conversions", - image_cache->peak_conversions_size, - image_cache->peak_conversions); + NSLOG(netsurf, INFO, "Bitmap of size %d had most (%d) conversions", + image_cache->peak_conversions_size, + image_cache->peak_conversions); free(image_cache); @@ -519,7 +531,8 @@ nserror image_cache_add(struct content *content, centry->bitmap_size = content->width * content->height * 4; } - LOG("centry %p, content %p, bitmap %p", centry, content, bitmap); + NSLOG(netsurf, INFO, "centry %p, content %p, bitmap %p", centry, + content, bitmap); centry->convert = convert; @@ -558,7 +571,8 @@ nserror image_cache_remove(struct content *content) /* get the cache entry */ centry = image_cache__find(content); if (centry == NULL) { - LOG("Could not find cache entry for content (%p)", content); + NSLOG(netsurf, INFO, + "Could not find cache entry for content (%p)", content); return NSERROR_NOT_FOUND; } @@ -788,7 +802,8 @@ bool image_cache_redraw(struct content *c, /* get the cache entry */ centry = image_cache__find(c); if (centry == NULL) { - LOG("Could not find cache entry for content (%p)", c); + NSLOG(netsurf, INFO, + "Could not find cache entry for content (%p)", c); return false; } @@ -827,7 +842,8 @@ void image_cache_destroy(struct content *content) /* get the cache entry */ centry = image_cache__find(content); if (centry == NULL) { - LOG("Could not find cache entry for content (%p)", content); + NSLOG(netsurf, INFO, + "Could not find cache entry for content (%p)", content); } else { image_cache__free_entry(centry); } diff --git a/content/handlers/image/jpeg.c b/content/handlers/image/jpeg.c index c5aca1c9b..44b1c5271 100644 --- a/content/handlers/image/jpeg.c +++ b/content/handlers/image/jpeg.c @@ -142,7 +142,7 @@ static void nsjpeg_term_source(j_decompress_ptr cinfo) static void nsjpeg_error_log(j_common_ptr cinfo) { cinfo->err->format_message(cinfo, nsjpeg_error_buffer); - LOG("%s", nsjpeg_error_buffer); + NSLOG(netsurf, INFO, "%s", nsjpeg_error_buffer); } @@ -156,7 +156,7 @@ static void nsjpeg_error_exit(j_common_ptr cinfo) jmp_buf *setjmp_buffer = (jmp_buf *) cinfo->client_data; cinfo->err->format_message(cinfo, nsjpeg_error_buffer); - LOG("%s", nsjpeg_error_buffer); + NSLOG(netsurf, INFO, "%s", nsjpeg_error_buffer); longjmp(*setjmp_buffer, 1); } diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index c9fe1b585..269c24356 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -48,10 +48,10 @@ typedef struct nssprite_content { #define ERRCHK(x) do { \ rosprite_error err = x; \ if (err == ROSPRITE_EOF) { \ - LOG("Got ROSPRITE_EOF when loading sprite file"); \ + NSLOG(netsurf, INFO, "Got ROSPRITE_EOF when loading sprite file"); \ goto ro_sprite_error; \ } else if (err == ROSPRITE_BADMODE) { \ - LOG("Got ROSPRITE_BADMODE when loading sprite file"); \ + NSLOG(netsurf, INFO, "Got ROSPRITE_BADMODE when loading sprite file"); \ goto ro_sprite_error; \ } else if (err == ROSPRITE_OK) { \ } else { \ diff --git a/content/handlers/image/png.c b/content/handlers/image/png.c index 288f6c3e4..7a4ce3010 100644 --- a/content/handlers/image/png.c +++ b/content/handlers/image/png.c @@ -74,7 +74,7 @@ enum nspng_cberr { */ static void nspng_warning(png_structp png_ptr, png_const_charp warning_message) { - LOG("%s", warning_message); + NSLOG(netsurf, INFO, "%s", warning_message); } /** @@ -82,7 +82,7 @@ static void nspng_warning(png_structp png_ptr, png_const_charp warning_message) */ static void nspng_error(png_structp png_ptr, png_const_charp error_message) { - LOG("%s", error_message); + NSLOG(netsurf, INFO, "%s", error_message); longjmp(png_jmpbuf(png_ptr), CBERR_LIBPNG); } @@ -175,10 +175,8 @@ static void info_callback(png_structp png_s, png_infop info) png_c->rowbytes = png_get_rowbytes(png_s, info); png_c->interlace = (interlace == PNG_INTERLACE_ADAM7); - LOG("size %li * %li, rowbytes %" PRIsizet, - (unsigned long)width, - (unsigned long)height, - png_c->rowbytes); + NSLOG(netsurf, INFO, "size %li * %li, rowbytes %"PRIsizet, + (unsigned long)width, (unsigned long)height, png_c->rowbytes); } static void row_callback(png_structp png_s, png_bytep new_row, @@ -260,7 +258,7 @@ static nserror nspng_create_png_data(nspng_content *png_c) if (setjmp(png_jmpbuf(png_c->png))) { png_destroy_read_struct(&png_c->png, &png_c->info, 0); - LOG("Failed to set callbacks"); + NSLOG(netsurf, INFO, "Failed to set callbacks"); png_c->png = NULL; png_c->info = NULL; @@ -350,7 +348,8 @@ static bool nspng_process_data(struct content *c, const char *data, * up png conversion and signal the content * error */ - LOG("Fatal PNG error during header, error content"); + NSLOG(netsurf, INFO, + "Fatal PNG error during header, error content"); png_destroy_read_struct(&png_c->png, &png_c->info, 0); png_c->png = NULL; diff --git a/content/handlers/image/rsvg.c b/content/handlers/image/rsvg.c index f6732e23f..ca2d81eeb 100644 --- a/content/handlers/image/rsvg.c +++ b/content/handlers/image/rsvg.c @@ -68,7 +68,7 @@ static nserror rsvg_create_svg_data(rsvg_content *c) c->bitmap = NULL; if ((c->rsvgh = rsvg_handle_new()) == NULL) { - LOG("rsvg_handle_new() returned NULL."); + NSLOG(netsurf, INFO, "rsvg_handle_new() returned NULL."); content_broadcast_errorcode(&c->base, NSERROR_NOMEM); return NSERROR_NOMEM; } @@ -116,7 +116,8 @@ static bool rsvg_process_data(struct content *c, const char *data, if (rsvg_handle_write(d->rsvgh, (const guchar *)data, (gsize)size, &err) == FALSE) { - LOG("rsvg_handle_write returned an error: %s", err->message); + NSLOG(netsurf, INFO, + "rsvg_handle_write returned an error: %s", err->message); content_broadcast_errorcode(c, NSERROR_SVG_ERROR); return false; } @@ -160,7 +161,8 @@ static bool rsvg_convert(struct content *c) GError *err = NULL; if (rsvg_handle_close(d->rsvgh, &err) == FALSE) { - LOG("rsvg_handle_close returned an error: %s", err->message); + NSLOG(netsurf, INFO, + "rsvg_handle_close returned an error: %s", err->message); content_broadcast_errorcode(c, NSERROR_SVG_ERROR); return false; } @@ -177,7 +179,8 @@ static bool rsvg_convert(struct content *c) if ((d->bitmap = guit->bitmap->create(c->width, c->height, BITMAP_NEW)) == NULL) { - LOG("Failed to create bitmap for rsvg render."); + NSLOG(netsurf, INFO, + "Failed to create bitmap for rsvg render."); content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } @@ -187,13 +190,15 @@ static bool rsvg_convert(struct content *c) CAIRO_FORMAT_ARGB32, c->width, c->height, guit->bitmap->get_rowstride(d->bitmap))) == NULL) { - LOG("Failed to create Cairo image surface for rsvg render."); + NSLOG(netsurf, INFO, + "Failed to create Cairo image surface for rsvg render."); content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } if ((d->ct = cairo_create(d->cs)) == NULL) { - LOG("Failed to create Cairo drawing context for rsvg render."); + NSLOG(netsurf, INFO, + "Failed to create Cairo drawing context for rsvg render."); content_broadcast_errorcode(c, NSERROR_NOMEM); return false; } diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c index dd4378b7a..8cfeb3985 100644 --- a/content/handlers/javascript/duktape/dukky.c +++ b/content/handlers/javascript/duktape/dukky.c @@ -61,7 +61,8 @@ static duk_ret_t dukky_populate_object(duk_context *ctx, void *udata) duk_get_prop(ctx, -2); /* ... obj args prototab {proto/undefined} */ if (duk_is_undefined(ctx, -1)) { - LOG("RuhRoh, couldn't find a prototype, HTMLUnknownElement it is"); + NSLOG(netsurf, INFO, + "RuhRoh, couldn't find a prototype, HTMLUnknownElement it is"); duk_pop(ctx); duk_push_string(ctx, PROTO_NAME(HTMLUNKNOWNELEMENT)); duk_get_prop(ctx, -2); @@ -77,7 +78,7 @@ static duk_ret_t dukky_populate_object(duk_context *ctx, void *udata) /* ... initfn obj[proto] args prototab proto */ duk_pop_2(ctx); /* ... initfn obj[proto] args */ - LOG("Call the init function"); + NSLOG(netsurf, INFO, "Call the init function"); duk_call(ctx, nargs + 1); return 1; /* The object */ } @@ -85,7 +86,7 @@ static duk_ret_t dukky_populate_object(duk_context *ctx, void *udata) duk_ret_t dukky_create_object(duk_context *ctx, const char *name, int args) { duk_ret_t ret; - LOG("name=%s nargs=%d", name+2, args); + NSLOG(netsurf, INFO, "name=%s nargs=%d", name + 2, args); /* ... args */ duk_push_object(ctx); /* ... args obj */ @@ -106,7 +107,7 @@ duk_ret_t dukky_create_object(duk_context *ctx, const char *name, int args) if ((ret = duk_safe_call(ctx, dukky_populate_object, NULL, args + 3, 1)) != DUK_EXEC_SUCCESS) return ret; - LOG("created"); + NSLOG(netsurf, INFO, "created"); return DUK_EXEC_SUCCESS; } @@ -146,7 +147,7 @@ dukky_push_node_stacked(duk_context *ctx) if (duk_safe_call(ctx, dukky_populate_object, NULL, 4, 1) != DUK_EXEC_SUCCESS) { duk_set_top(ctx, top_at_fail); - LOG("Boo and also hiss"); + NSLOG(netsurf, INFO, "Boo and also hiss"); return false; } /* ... nodeptr klass nodes node */ @@ -384,13 +385,14 @@ dukky_push_node_klass(duk_context *ctx, struct dom_node *node) err = dom_node_get_namespace(node, &namespace); if (err != DOM_NO_ERR) { /* Feck it, element */ - LOG("dom_node_get_namespace() failed"); + NSLOG(netsurf, INFO, + "dom_node_get_namespace() failed"); duk_push_string(ctx, PROTO_NAME(ELEMENT)); break; } if (namespace == NULL) { /* No namespace, -> element */ - LOG("no namespace"); + NSLOG(netsurf, INFO, "no namespace"); duk_push_string(ctx, PROTO_NAME(ELEMENT)); break; } @@ -561,7 +563,7 @@ nserror js_newcontext(int timeout, jscallback *cb, void *cbctx, duk_context *ctx; jscontext *ret = calloc(1, sizeof(*ret)); *jsctx = NULL; - LOG("Creating new duktape javascript context"); + NSLOG(netsurf, INFO, "Creating new duktape javascript context"); if (ret == NULL) return NSERROR_NOMEM; ctx = ret->ctx = duk_create_heap( dukky_alloc_function, @@ -584,7 +586,7 @@ nserror js_newcontext(int timeout, jscallback *cb, void *cbctx, void js_destroycontext(jscontext *ctx) { - LOG("Destroying duktape javascript context"); + NSLOG(netsurf, INFO, "Destroying duktape javascript context"); duk_destroy_heap(ctx->ctx); free(ctx); } @@ -593,7 +595,9 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv) { assert(ctx != NULL); /* Pop any active thread off */ - LOG("Yay, new compartment, win_priv=%p, doc_priv=%p", win_priv, doc_priv); + NSLOG(netsurf, INFO, + "Yay, new compartment, win_priv=%p, doc_priv=%p", win_priv, + doc_priv); duk_set_top(ctx->ctx, 0); duk_push_thread(ctx->ctx); ctx->thread = duk_require_context(ctx->ctx, -1); @@ -659,15 +663,17 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen) duk_get_prop_string(CTX, 0, "fileName"); duk_get_prop_string(CTX, 0, "lineNumber"); duk_get_prop_string(CTX, 0, "stack"); - LOG("Uncaught error in JS: %s: %s", duk_safe_to_string(CTX, 1), - duk_safe_to_string(CTX, 2)); - LOG(" was at: %s line %s", duk_safe_to_string(CTX, 3), - duk_safe_to_string(CTX, 4)); - LOG(" Stack trace: %s", duk_safe_to_string(CTX, 5)); + NSLOG(netsurf, INFO, "Uncaught error in JS: %s: %s", + duk_safe_to_string(CTX, 1), duk_safe_to_string(CTX, 2)); + NSLOG(netsurf, INFO, " was at: %s line %s", + duk_safe_to_string(CTX, 3), duk_safe_to_string(CTX, 4)); + NSLOG(netsurf, INFO, " Stack trace: %s", + duk_safe_to_string(CTX, 5)); return false; } if (duk_get_top(CTX) == 0) duk_push_boolean(CTX, false); - LOG("Returning %s", duk_get_boolean(CTX, 0) ? "true" : "false"); + NSLOG(netsurf, INFO, "Returning %s", + duk_get_boolean(CTX, 0) ? "true" : "false"); return duk_get_boolean(CTX, 0); } @@ -782,7 +788,8 @@ bool dukky_get_current_value_of_event_handler(duk_context *ctx, /* ... node fullhandlersrc filename */ if (duk_pcompile(ctx, DUK_COMPILE_FUNCTION) != 0) { /* ... node err */ - LOG("Unable to proceed with handler, could not compile"); + NSLOG(netsurf, INFO, + "Unable to proceed with handler, could not compile"); duk_pop_2(ctx); return false; } @@ -816,29 +823,27 @@ static void dukky_generic_event_handler(dom_event *evt, void *pw) duk_get_memory_functions(ctx, &funcs); jsctx = funcs.udata; - LOG("WOOP WOOP, An event:"); + NSLOG(netsurf, INFO, "WOOP WOOP, An event:"); exc = dom_event_get_type(evt, &name); if (exc != DOM_NO_ERR) { - LOG("Unable to find the event name"); + NSLOG(netsurf, INFO, "Unable to find the event name"); return; } - LOG("Event's name is %*s", - dom_string_length(name), dom_string_data(name)); + NSLOG(netsurf, INFO, "Event's name is %*s", dom_string_length(name), + dom_string_data(name)); exc = dom_event_get_event_phase(evt, &phase); if (exc != DOM_NO_ERR) { - LOG("Unable to get event phase"); + NSLOG(netsurf, INFO, "Unable to get event phase"); return; } - LOG("Event phase is: %s (%d)", - phase == DOM_CAPTURING_PHASE ? "capturing" : - phase == DOM_AT_TARGET ? "at-target" : - phase == DOM_BUBBLING_PHASE ? "bubbling" : - "unknown", (int)phase); + NSLOG(netsurf, INFO, "Event phase is: %s (%d)", + phase == DOM_CAPTURING_PHASE ? "capturing" : phase == DOM_AT_TARGET ? "at-target" : phase == DOM_BUBBLING_PHASE ? "bubbling" : "unknown", + (int)phase); exc = dom_event_get_current_target(evt, &targ); if (exc != DOM_NO_ERR) { dom_string_unref(name); - LOG("Unable to find the event target"); + NSLOG(netsurf, INFO, "Unable to find the event target"); return; } @@ -852,7 +857,8 @@ static void dukky_generic_event_handler(dom_event *evt, void *pw) if (dukky_push_node(ctx, (dom_node *)targ) == false) { dom_string_unref(name); dom_node_unref(targ); - LOG("Unable to push JS node representation?!"); + NSLOG(netsurf, INFO, + "Unable to push JS node representation?!"); return; } /* ... node */ @@ -868,21 +874,26 @@ static void dukky_generic_event_handler(dom_event *evt, void *pw) if (duk_pcall_method(ctx, 1) != 0) { /* Failed to run the method */ /* ... err */ - LOG("OH NOES! An error running a callback. Meh."); + NSLOG(netsurf, INFO, + "OH NOES! An error running a callback. Meh."); exc = dom_event_stop_immediate_propagation(evt); if (exc != DOM_NO_ERR) - LOG("WORSE! could not stop propagation"); + NSLOG(netsurf, INFO, + "WORSE! could not stop propagation"); duk_get_prop_string(ctx, -1, "name"); duk_get_prop_string(ctx, -2, "message"); duk_get_prop_string(ctx, -3, "fileName"); duk_get_prop_string(ctx, -4, "lineNumber"); duk_get_prop_string(ctx, -5, "stack"); /* ... err name message fileName lineNumber stack */ - LOG("Uncaught error in JS: %s: %s", duk_safe_to_string(ctx, -5), - duk_safe_to_string(ctx, -4)); - LOG(" was at: %s line %s", duk_safe_to_string(ctx, -3), - duk_safe_to_string(ctx, -2)); - LOG(" Stack trace: %s", duk_safe_to_string(ctx, -1)); + NSLOG(netsurf, INFO, "Uncaught error in JS: %s: %s", + duk_safe_to_string(ctx, -5), + duk_safe_to_string(ctx, -4)); + NSLOG(netsurf, INFO, " was at: %s line %s", + duk_safe_to_string(ctx, -3), + duk_safe_to_string(ctx, -2)); + NSLOG(netsurf, INFO, " Stack trace: %s", + duk_safe_to_string(ctx, -1)); duk_pop_n(ctx, 6); /* ... */ @@ -962,21 +973,27 @@ handle_extras: if (duk_pcall_method(ctx, 1) != 0) { /* Failed to run the method */ /* ... copy handler err */ - LOG("OH NOES! An error running a callback. Meh."); + NSLOG(netsurf, INFO, + "OH NOES! An error running a callback. Meh."); exc = dom_event_stop_immediate_propagation(evt); if (exc != DOM_NO_ERR) - LOG("WORSE! could not stop propagation"); + NSLOG(netsurf, INFO, + "WORSE! could not stop propagation"); duk_get_prop_string(ctx, -1, "name"); duk_get_prop_string(ctx, -2, "message"); duk_get_prop_string(ctx, -3, "fileName"); duk_get_prop_string(ctx, -4, "lineNumber"); duk_get_prop_string(ctx, -5, "stack"); /* ... err name message fileName lineNumber stack */ - LOG("Uncaught error in JS: %s: %s", duk_safe_to_string(ctx, -5), - duk_safe_to_string(ctx, -4)); - LOG(" was at: %s line %s", duk_safe_to_string(ctx, -3), - duk_safe_to_string(ctx, -2)); - LOG(" Stack trace: %s", duk_safe_to_string(ctx, -1)); + NSLOG(netsurf, INFO, "Uncaught error in JS: %s: %s", + duk_safe_to_string(ctx, -5), + duk_safe_to_string(ctx, -4)); + NSLOG(netsurf, INFO, + " was at: %s line %s", + duk_safe_to_string(ctx, -3), + duk_safe_to_string(ctx, -2)); + NSLOG(netsurf, INFO, " Stack trace: %s", + duk_safe_to_string(ctx, -1)); duk_pop_n(ctx, 7); /* ... copy */ @@ -1034,11 +1051,12 @@ void dukky_register_event_listener_for(duk_context *ctx, exc = dom_event_target_add_event_listener( ele, name, listen, capture); if (exc != DOM_NO_ERR) { - LOG("Unable to register listener for %p.%*s", - ele, dom_string_length(name), dom_string_data(name)); + NSLOG(netsurf, INFO, + "Unable to register listener for %p.%*s", ele, + dom_string_length(name), dom_string_data(name)); } else { - LOG("have registered listener for %p.%*s", - ele, dom_string_length(name), dom_string_data(name)); + NSLOG(netsurf, INFO, "have registered listener for %p.%*s", + ele, dom_string_length(name), dom_string_data(name)); } dom_event_listener_unref(listen); } @@ -1205,7 +1223,8 @@ bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, s dom_event *evt; dom_event_target *body; - LOG("Event: %s (doc=%p, target=%p)", type, doc, target); + NSLOG(netsurf, INFO, "Event: %s (doc=%p, target=%p)", type, doc, + target); /** @todo Make this more generic, this only handles load and only * targetting the window, so that we actually stand a chance of @@ -1276,18 +1295,22 @@ bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, s if (duk_pcall_method(CTX, 1) != 0) { /* Failed to run the handler */ /* ... err */ - LOG("OH NOES! An error running a handler. Meh."); + NSLOG(netsurf, INFO, + "OH NOES! An error running a handler. Meh."); duk_get_prop_string(CTX, -1, "name"); duk_get_prop_string(CTX, -2, "message"); duk_get_prop_string(CTX, -3, "fileName"); duk_get_prop_string(CTX, -4, "lineNumber"); duk_get_prop_string(CTX, -5, "stack"); /* ... err name message fileName lineNumber stack */ - LOG("Uncaught error in JS: %s: %s", duk_safe_to_string(CTX, -5), - duk_safe_to_string(CTX, -4)); - LOG(" was at: %s line %s", duk_safe_to_string(CTX, -3), - duk_safe_to_string(CTX, -2)); - LOG(" Stack trace: %s", duk_safe_to_string(CTX, -1)); + NSLOG(netsurf, INFO, "Uncaught error in JS: %s: %s", + duk_safe_to_string(CTX, -5), + duk_safe_to_string(CTX, -4)); + NSLOG(netsurf, INFO, " was at: %s line %s", + duk_safe_to_string(CTX, -3), + duk_safe_to_string(CTX, -2)); + NSLOG(netsurf, INFO, " Stack trace: %s", + duk_safe_to_string(CTX, -1)); duk_pop_n(CTX, 6); /* ... */ diff --git a/content/hlcache.c b/content/hlcache.c index 2242b73af..33436f7ed 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -195,7 +195,7 @@ static void hlcache_content_callback(struct content *c, content_msg msg, error = handle->cb(handle, &event, handle->pw); if (error != NSERROR_OK) - LOG("Error in callback: %d", error); + NSLOG(netsurf, INFO, "Error in callback: %d", error); } /** @@ -566,7 +566,8 @@ void hlcache_finalise(void) num_contents++; } - LOG("%d contents remain before cache drain", num_contents); + NSLOG(netsurf, INFO, "%d contents remain before cache drain", + num_contents); /* Drain cache */ do { @@ -580,14 +581,17 @@ void hlcache_finalise(void) } } while (num_contents > 0 && num_contents != prev_contents); - LOG("%d contents remaining:", num_contents); + NSLOG(netsurf, INFO, "%d contents remaining:", num_contents); for (entry = hlcache->content_list; entry != NULL; entry = entry->next) { hlcache_handle entry_handle = { entry, NULL, NULL }; if (entry->content != NULL) { - LOG(" %p : %s (%d users)", entry, nsurl_access(hlcache_handle_get_url(&entry_handle)), content_count_users(entry->content)); + NSLOG(netsurf, INFO, " %p : %s (%d users)", + entry, + nsurl_access(hlcache_handle_get_url(&entry_handle)), + content_count_users(entry->content)); } else { - LOG(" %p", entry); + NSLOG(netsurf, INFO, " %p", entry); } } @@ -615,12 +619,13 @@ void hlcache_finalise(void) hlcache->retrieval_ctx_ring = NULL; } - LOG("hit/miss %d/%d", hlcache->hit_count, hlcache->miss_count); + NSLOG(netsurf, INFO, "hit/miss %d/%d", hlcache->hit_count, + hlcache->miss_count); free(hlcache); hlcache = NULL; - LOG("Finalising low-level cache"); + NSLOG(netsurf, INFO, "Finalising low-level cache"); llcache_finalise(); } diff --git a/content/llcache.c b/content/llcache.c index eb300534d..b81aba84f 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -1331,13 +1331,13 @@ llcache_serialise_metadata(llcache_object *object, overflow: /* somehow we overflowed the buffer - hth? */ - LOG("Overflowed metadata buffer"); + NSLOG(netsurf, INFO, "Overflowed metadata buffer"); free(data); return NSERROR_INVALID; operror: /* output error */ - LOG("Output error"); + NSLOG(netsurf, INFO, "Output error"); free(data); return NSERROR_INVALID; } @@ -1374,7 +1374,7 @@ llcache_process_metadata(llcache_object *object) size_t num_headers; size_t hloop; - LOG("Retrieving metadata"); + NSLOG(netsurf, INFO, "Retrieving metadata"); /* attempt to retrieve object metadata from the backing store */ res = guit->llcache->fetch(object->url, @@ -1385,7 +1385,7 @@ llcache_process_metadata(llcache_object *object) return res; } - LOG("Processing retrieved data"); + NSLOG(netsurf, INFO, "Processing retrieved data"); /* metadata line 1 is the url the metadata referrs to */ line = 1; @@ -1408,8 +1408,8 @@ llcache_process_metadata(llcache_object *object) * by simply skipping caching of this object. */ - LOG("Got metadata for %s instead of %s", - nsurl_access(metadataurl), nsurl_access(object->url)); + NSLOG(netsurf, INFO, "Got metadata for %s instead of %s", + nsurl_access(metadataurl), nsurl_access(object->url)); nsurl_unref(metadataurl); @@ -1502,7 +1502,8 @@ llcache_process_metadata(llcache_object *object) return NSERROR_OK; format_error: - LOG("metadata error on line %d error code %d\n", line, res); + NSLOG(netsurf, INFO, "metadata error on line %d error code %d\n", + line, res); guit->llcache->release(object->url, BACKING_STORE_META); return res; @@ -1898,7 +1899,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, /* Forcibly stop redirecting if we've followed too many redirects */ #define REDIRECT_LIMIT 10 if (object->fetch.redirect_count > REDIRECT_LIMIT) { - LOG("Too many nested redirects"); + NSLOG(netsurf, INFO, "Too many nested redirects"); event.type = LLCACHE_EVENT_ERROR; event.data.msg = messages_get("BadRedirect"); @@ -2493,8 +2494,10 @@ static void llcache_persist_slowcheck(void *p) total_bandwidth = (llcache->total_written * 1000) / llcache->total_elapsed; if (total_bandwidth < llcache->minimum_bandwidth) { - LOG("Current bandwidth %" PRIu64 " less than minimum %" PRIsizet, - total_bandwidth, llcache->minimum_bandwidth); + NSLOG(netsurf, INFO, + "Current bandwidth %"PRIu64" less than minimum %"PRIsizet, + total_bandwidth, + llcache->minimum_bandwidth); guit->llcache->finalise(); } } @@ -2550,7 +2553,7 @@ static void llcache_persist(void *p) * (bandwidth) for this run being exceeded. */ if (total_elapsed > llcache->time_quantum) { - LOG("Overran timeslot"); + NSLOG(netsurf, INFO, "Overran timeslot"); /* writeout has exhausted the available time. * Either the writeout is slow or the last * object was very large. @@ -2920,12 +2923,14 @@ static nserror llcache_object_notify_users(llcache_object *object) #ifdef LLCACHE_TRACE if (handle->state != objstate) { if (emitted_notify == false) { - LOG("Notifying users of %p", object); + NSLOG(netsurf, INFO, "Notifying users of %p", + object); emitted_notify = true; } - LOG("User %p state: %d Object state: %d", user, - handle->state, objstate); + NSLOG(netsurf, INFO, + "User %p state: %d Object state: %d", user, + handle->state, objstate); } #endif @@ -3364,7 +3369,8 @@ llcache_initialise(const struct llcache_parameters *prm) llcache->fetch_attempts = prm->fetch_attempts; llcache->all_caught_up = true; - LOG("llcache initialising with a limit of %d bytes", llcache->limit); + NSLOG(netsurf, INFO, "llcache initialising with a limit of %d bytes", + llcache->limit); /* backing store initialisation */ return guit->llcache->initialise(&prm->store); @@ -3427,10 +3433,11 @@ void llcache_finalise(void) llcache->total_elapsed; } - LOG("Backing store wrote %"PRIu64" bytes in %"PRIu64" ms " - "(average %"PRIu64" bytes/second)", - llcache->total_written, llcache->total_elapsed, - total_bandwidth); + NSLOG(netsurf, INFO, + "Backing store wrote %"PRIu64" bytes in %"PRIu64" ms ""(average %"PRIu64" bytes/second)", + llcache->total_written, + llcache->total_elapsed, + total_bandwidth); free(llcache); llcache = NULL; diff --git a/content/urldb.c b/content/urldb.c index 313ec316d..add2a1d80 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -662,7 +662,8 @@ static bool urldb__host_is_ip_address(const char *host) c[slash - host] = '\0'; sane_host = c; host_len = slash - host; - LOG("WARNING: called with non-host '%s'", host); + NSLOG(netsurf, INFO, "WARNING: called with non-host '%s'", + host); } if (strspn(sane_host, "0123456789abcdefABCDEF[].:") < host_len) @@ -1292,7 +1293,7 @@ urldb_match_path(const struct path_data *parent, assert(parent->segment == NULL); if (path[0] != '/') { - LOG("path is %s", path); + NSLOG(netsurf, INFO, "path is %s", path); } assert(path[0] == '/'); @@ -1422,12 +1423,14 @@ static void urldb_dump_paths(struct path_data *parent) do { if (p->segment != NULL) { - LOG("\t%s : %u", lwc_string_data(p->scheme), p->port); + NSLOG(netsurf, INFO, "\t%s : %u", + lwc_string_data(p->scheme), p->port); - LOG("\t\t'%s'", p->segment); + NSLOG(netsurf, INFO, "\t\t'%s'", p->segment); for (i = 0; i != p->frag_cnt; i++) { - LOG("\t\t\t#%s", p->fragment[i]); + NSLOG(netsurf, INFO, "\t\t\t#%s", + p->fragment[i]); } } @@ -1457,10 +1460,10 @@ static void urldb_dump_hosts(struct host_part *parent) struct host_part *h; if (parent->part) { - LOG("%s", parent->part); + NSLOG(netsurf, INFO, "%s", parent->part); - LOG("\t%s invalid SSL certs", - parent->permit_invalid_certs ? "Permits" : "Denies"); + NSLOG(netsurf, INFO, "\t%s invalid SSL certs", + parent->permit_invalid_certs ? "Permits" : "Denies"); } /* Dump path data */ @@ -1512,7 +1515,7 @@ static void urldb_dump_search(struct search_node *parent, int depth) } s[i]= 0; - LOG("%s", s); + NSLOG(netsurf, INFO, "%s", s); urldb_dump_search(parent->right, depth + 1); } @@ -2866,14 +2869,15 @@ nserror urldb_load(const char *filename) assert(filename); - LOG("Loading URL file %s", filename); + NSLOG(netsurf, INFO, "Loading URL file %s", filename); if (url_bloom == NULL) url_bloom = bloom_create(BLOOM_SIZE); fp = fopen(filename, "r"); if (!fp) { - LOG("Failed to open file '%s' for reading", filename); + NSLOG(netsurf, INFO, "Failed to open file '%s' for reading", + filename); return NSERROR_NOT_FOUND; } @@ -2884,12 +2888,12 @@ nserror urldb_load(const char *filename) version = atoi(s); if (version < MIN_URL_FILE_VERSION) { - LOG("Unsupported URL file version."); + NSLOG(netsurf, INFO, "Unsupported URL file version."); fclose(fp); return NSERROR_INVALID; } if (version > URL_FILE_VERSION) { - LOG("Unknown URL file version."); + NSLOG(netsurf, INFO, "Unknown URL file version."); fclose(fp); return NSERROR_INVALID; } @@ -2919,13 +2923,13 @@ nserror urldb_load(const char *filename) /* no URLs => try next host */ if (urls == 0) { - LOG("No URLs for '%s'", host); + NSLOG(netsurf, INFO, "No URLs for '%s'", host); continue; } h = urldb_add_host(host); if (!h) { - LOG("Failed adding host: '%s'", host); + NSLOG(netsurf, INFO, "Failed adding host: '%s'", host); fclose(fp); return NSERROR_NOMEM; } @@ -2976,7 +2980,8 @@ nserror urldb_load(const char *filename) * Need a nsurl_save too. */ if (nsurl_create(url, &nsurl) != NSERROR_OK) { - LOG("Failed inserting '%s'", url); + NSLOG(netsurf, INFO, "Failed inserting '%s'", + url); fclose(fp); return NSERROR_NOMEM; } @@ -2989,7 +2994,8 @@ nserror urldb_load(const char *filename) /* Copy and merge path/query strings */ if (nsurl_get(nsurl, NSURL_PATH | NSURL_QUERY, &path_query, &len) != NSERROR_OK) { - LOG("Failed inserting '%s'", url); + NSLOG(netsurf, INFO, "Failed inserting '%s'", + url); fclose(fp); return NSERROR_NOMEM; } @@ -3000,7 +3006,8 @@ nserror urldb_load(const char *filename) p = urldb_add_path(scheme_lwc, port, h, path_query, fragment_lwc, nsurl); if (!p) { - LOG("Failed inserting '%s'", url); + NSLOG(netsurf, INFO, "Failed inserting '%s'", + url); fclose(fp); return NSERROR_NOMEM; } @@ -3044,7 +3051,7 @@ nserror urldb_load(const char *filename) } fclose(fp); - LOG("Successfully loaded URL file"); + NSLOG(netsurf, INFO, "Successfully loaded URL file"); #undef MAXIMUM_URL_LENGTH return NSERROR_OK; @@ -3060,7 +3067,8 @@ nserror urldb_save(const char *filename) fp = fopen(filename, "w"); if (!fp) { - LOG("Failed to open file '%s' for writing", filename); + NSLOG(netsurf, INFO, "Failed to open file '%s' for writing", + filename); return NSERROR_SAVE_FAILED; } @@ -3472,7 +3480,7 @@ bool urldb_set_thumbnail(nsurl *url, struct bitmap *bitmap) return false; } - LOG("Setting bitmap on %s", nsurl_access(url)); + NSLOG(netsurf, INFO, "Setting bitmap on %s", nsurl_access(url)); if ((p->thumb) && (p->thumb != bitmap)) { guit->bitmap->destroy(p->thumb); @@ -3754,7 +3762,8 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer) } suffix = nspsl_getpublicsuffix(dot); if (suffix == NULL) { - LOG("domain %s was a public suffix domain", dot); + NSLOG(netsurf, INFO, + "domain %s was a public suffix domain", dot); urldb_free_cookie(c); goto error; } @@ -4161,7 +4170,7 @@ void urldb_load_cookies(const char *filename) for (; *p && *p != '\t'; p++) \ ; /* do nothing */ \ if (p >= end) { \ - LOG("Overran input"); \ + NSLOG(netsurf, INFO, "Overran input"); \ continue; \ } \ *p++ = '\0'; \ @@ -4171,7 +4180,7 @@ void urldb_load_cookies(const char *filename) for (; *p && *p == '\t'; p++) \ ; /* do nothing */ \ if (p >= end) { \ - LOG("Overran input"); \ + NSLOG(netsurf, INFO, "Overran input"); \ continue; \ } \ } @@ -4200,7 +4209,8 @@ void urldb_load_cookies(const char *filename) if (loaded_cookie_file_version < MIN_COOKIE_FILE_VERSION) { - LOG("Unsupported Cookie file version"); + NSLOG(netsurf, INFO, + "Unsupported Cookie file version"); break; } diff --git a/desktop/browser.c b/desktop/browser.c index 8d57a2ab5..6cadc54ac 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -171,7 +171,7 @@ browser_window_redraw(struct browser_window *bw, nserror res; if (bw == NULL) { - LOG("NULL browser window"); + NSLOG(netsurf, INFO, "NULL browser window"); return false; } @@ -336,7 +336,7 @@ browser_window_redraw(struct browser_window *bw, bool browser_window_redraw_ready(struct browser_window *bw) { if (bw == NULL) { - LOG("NULL browser window"); + NSLOG(netsurf, INFO, "NULL browser window"); return false; } else if (bw->current_content != NULL) { /* Can't render locked contents */ @@ -415,7 +415,8 @@ void browser_window_set_position(struct browser_window *bw, int x, int y) bw->x = x; bw->y = y; } else { - LOG("Asked to set position of front end window."); + NSLOG(netsurf, INFO, + "Asked to set position of front end window."); assert(0); } } @@ -811,7 +812,7 @@ nserror browser_window_debug(struct browser_window *bw, enum content_debug op) static bool slow_script(void *ctx) { static int count = 0; - LOG("Continuing execution %d", count); + NSLOG(netsurf, INFO, "Continuing execution %d", count); count++; if (count > 1) { count = 0; @@ -982,11 +983,12 @@ browser_window_download(struct browser_window *bw, /* no internal handler for this type, call out to frontend */ error = guit->misc->launch_url(url); } else if (error != NSERROR_OK) { - LOG("Failed to fetch download: %d", error); + NSLOG(netsurf, INFO, "Failed to fetch download: %d", error); } else { error = download_context_create(l, root->window); if (error != NSERROR_OK) { - LOG("Failed creating download context: %d", error); + NSLOG(netsurf, INFO, + "Failed creating download context: %d", error); llcache_handle_abort(l); llcache_handle_release(l); } @@ -1114,7 +1116,8 @@ browser_window_favicon_callback(hlcache_handle *c, error = nsurl_create("resource:favicon.ico", &nsurl); if (error != NSERROR_OK) { - LOG("Unable to create default location url"); + NSLOG(netsurf, INFO, + "Unable to create default location url"); } else { hlcache_handle_retrieve(nsurl, HLCACHE_RETRIEVE_SNIFF_TYPE, @@ -1204,7 +1207,8 @@ browser_window_update_favicon(hlcache_handle *c, error = nsurl_create("resource:favicon.ico", &nsurl); } if (error != NSERROR_OK) { - LOG("Unable to create default location url"); + NSLOG(netsurf, INFO, + "Unable to create default location url"); return; } } else { @@ -1212,9 +1216,11 @@ browser_window_update_favicon(hlcache_handle *c, } if (link == NULL) { - LOG("fetching general favicon from '%s'", nsurl_access(nsurl)); + NSLOG(netsurf, INFO, "fetching general favicon from '%s'", + nsurl_access(nsurl)); } else { - LOG("fetching favicon rel:%s '%s'", lwc_string_data(link->rel), nsurl_access(nsurl)); + NSLOG(netsurf, INFO, "fetching favicon rel:%s '%s'", + lwc_string_data(link->rel), nsurl_access(nsurl)); } hlcache_handle_retrieve(nsurl, HLCACHE_RETRIEVE_SNIFF_TYPE, @@ -1811,7 +1817,7 @@ static void browser_window_destroy_internal(struct browser_window *bw) { assert(bw); - LOG("Destroying window"); + NSLOG(netsurf, INFO, "Destroying window"); if (bw->children != NULL || bw->iframes != NULL) { browser_window_destroy_children(bw); @@ -1831,7 +1837,8 @@ static void browser_window_destroy_internal(struct browser_window *bw) /* The ugly cast here is so the reformat function can be * passed a gui window pointer in its API rather than void* */ - LOG("Clearing reformat schedule for browser window %p", bw); + NSLOG(netsurf, INFO, + "Clearing reformat schedule for browser window %p", bw); guit->misc->schedule(-1, scheduled_reformat, bw); /* If this brower window is not the root window, and has focus, unset @@ -1911,7 +1918,8 @@ static void browser_window_destroy_internal(struct browser_window *bw) free(bw->name); free(bw->status.text); bw->status.text = NULL; - LOG("Status text cache match:miss %d:%d", bw->status.match, bw->status.miss); + NSLOG(netsurf, INFO, "Status text cache match:miss %d:%d", + bw->status.match, bw->status.miss); } /** @@ -2004,14 +2012,14 @@ browser_window_navigate(struct browser_window *bw, assert(bw); assert(url); - LOG("bw %p, url %s", bw, nsurl_access(url)); + NSLOG(netsurf, INFO, "bw %p, url %s", bw, nsurl_access(url)); /* don't allow massively nested framesets */ for (cur = bw; cur->parent; cur = cur->parent) { depth++; } if (depth > FRAME_DEPTH) { - LOG("frame depth too high."); + NSLOG(netsurf, INFO, "frame depth too high."); return NSERROR_FRAME_DEPTH; } @@ -2103,7 +2111,7 @@ browser_window_navigate(struct browser_window *bw, browser_window_remove_caret(bw, false); browser_window_destroy_children(bw); - LOG("Loading '%s'", nsurl_access(url)); + NSLOG(netsurf, INFO, "Loading '%s'", nsurl_access(url)); browser_window_set_status(bw, messages_get("Loading")); bw->history_add = (flags & BW_NAVIGATE_HISTORY); @@ -2319,7 +2327,8 @@ void browser_window_set_dimensions(struct browser_window *bw, bw->width = width; bw->height = height; } else { - LOG("Asked to set dimensions of front end window."); + NSLOG(netsurf, INFO, + "Asked to set dimensions of front end window."); assert(0); } } diff --git a/desktop/browser_history.c b/desktop/browser_history.c index dbbc67daf..c7d010419 100644 --- a/desktop/browser_history.c +++ b/desktop/browser_history.c @@ -286,7 +286,7 @@ nserror browser_window_history_clone(const struct browser_window *existing, new_history->start = browser_window_history__clone_entry(new_history, new_history->start); if (!new_history->start) { - LOG("Insufficient memory to clone history"); + NSLOG(netsurf, INFO, "Insufficient memory to clone history"); browser_window_history_destroy(clone); clone->history = NULL; return NSERROR_NOMEM; @@ -351,7 +351,8 @@ nserror browser_window_history_add(struct browser_window *bw, * loading */ bitmap = urldb_get_thumbnail(nsurl); if (bitmap == NULL) { - LOG("Creating thumbnail for %s", nsurl_access(nsurl)); + NSLOG(netsurf, INFO, "Creating thumbnail for %s", + nsurl_access(nsurl)); bitmap = guit->bitmap->create(WIDTH, HEIGHT, BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE); @@ -366,7 +367,7 @@ nserror browser_window_history_add(struct browser_window *bw, /* Thumbnailing failed. Ignore it * silently but clean up bitmap. */ - LOG("Thumbnail renderfailed"); + NSLOG(netsurf, INFO, "Thumbnail renderfailed"); guit->bitmap->destroy(bitmap); bitmap = NULL; } diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c index 5429f6864..987a85c0c 100644 --- a/desktop/cookie_manager.c +++ b/desktop/cookie_manager.c @@ -718,7 +718,8 @@ static void cookie_manager_delete_entry(struct cookie_manager_entry *e) urldb_delete_cookie(domain, path, name); } else { - LOG("Delete cookie fail: ""need domain, path, and name."); + NSLOG(netsurf, INFO, + "Delete cookie fail: ""need domain, path, and name."); } } @@ -788,7 +789,7 @@ nserror cookie_manager_init(struct core_window_callback_table *cw_t, return err; } - LOG("Generating cookie manager data"); + NSLOG(netsurf, INFO, "Generating cookie manager data"); /* Init. cookie manager treeview entry fields */ err = cookie_manager_init_entry_fields(); @@ -825,7 +826,7 @@ nserror cookie_manager_init(struct core_window_callback_table *cw_t, /* Inform client of window height */ treeview_get_height(cm_ctx.tree); - LOG("Generated cookie manager data"); + NSLOG(netsurf, INFO, "Generated cookie manager data"); return NSERROR_OK; } @@ -837,7 +838,7 @@ nserror cookie_manager_fini(void) int i; nserror err; - LOG("Finalising cookie manager"); + NSLOG(netsurf, INFO, "Finalising cookie manager"); cm_ctx.built = false; @@ -860,7 +861,7 @@ nserror cookie_manager_fini(void) return err; } - LOG("Finalised cookie manager"); + NSLOG(netsurf, INFO, "Finalised cookie manager"); return err; } diff --git a/desktop/font_haru.c b/desktop/font_haru.c index caa751bcb..f92d89197 100644 --- a/desktop/font_haru.c +++ b/desktop/font_haru.c @@ -74,7 +74,10 @@ const struct font_functions haru_nsfont = { static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void *user_data) { - LOG("ERROR: in font_haru \n\terror_no=%x\n\tdetail_no=%d\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no); + NSLOG(netsurf, INFO, + "ERROR: in font_haru \n\terror_no=%x\n\tdetail_no=%d\n", + (HPDF_UINT)error_no, + (HPDF_UINT)detail_no); #ifdef FONT_HARU_DEBUG exit(1); #endif @@ -143,7 +146,9 @@ bool haru_nsfont_width(const plot_font_style_t *fstyle, *width = width_real; #ifdef FONT_HARU_DEBUG - LOG("Measuring string: %s ; Calculated width: %f %i", string_nt, width_real, *width); + NSLOG(netsurf, INFO, + "Measuring string: %s ; Calculated width: %f %i", string_nt, + width_real, *width); #endif free(string_nt); HPDF_Free(pdf); @@ -201,7 +206,11 @@ bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle, *actual_x = real_width; #ifdef FONT_HARU_DEBUG - LOG("Position in string: %s at x: %i; Calculated position: %i", string_nt, x, *char_offset); + NSLOG(netsurf, INFO, + "Position in string: %s at x: %i; Calculated position: %i", + string_nt, + x, + *char_offset); #endif free(string_nt); HPDF_Free(pdf); @@ -246,7 +255,12 @@ bool haru_nsfont_split(const plot_font_style_t *fstyle, HPDF_TRUE, &real_width); #ifdef FONT_HARU_DEBUG - LOG("Splitting string: %s for width: %i ; Calculated position: %i Calculated real_width: %f", string_nt, x, *char_offset, real_width); + NSLOG(netsurf, INFO, + "Splitting string: %s for width: %i ; Calculated position: %i Calculated real_width: %f", + string_nt, + x, + *char_offset, + real_width); #endif *char_offset = offset - 1; @@ -327,7 +341,7 @@ bool haru_nsfont_apply_style(const plot_font_style_t *fstyle, strcat(font_name, "-Roman"); #ifdef FONT_HARU_DEBUG - LOG("Setting font: %s", font_name); + NSLOG(netsurf, INFO, "Setting font: %s", font_name); #endif size = fstyle->size; diff --git a/desktop/frames.c b/desktop/frames.c index 9eefefe02..e22287630 100644 --- a/desktop/frames.c +++ b/desktop/frames.c @@ -354,9 +354,11 @@ nserror browser_window_create_frameset(struct browser_window *bw, window->parent = bw; if (window->name) - LOG("Created frame '%s'", window->name); + NSLOG(netsurf, INFO, "Created frame '%s'", + window->name); else - LOG("Created frame (unnamed)"); + NSLOG(netsurf, INFO, + "Created frame (unnamed)"); } } diff --git a/desktop/global_history.c b/desktop/global_history.c index a19349f51..e6993212c 100644 --- a/desktop/global_history.c +++ b/desktop/global_history.c @@ -596,7 +596,7 @@ static nserror global_history_initialise_time(void) /* get the current time */ t = time(NULL); if (t == -1) { - LOG("time info unaviable"); + NSLOG(netsurf, INFO, "time info unaviable"); return NSERROR_UNKNOWN; } @@ -607,7 +607,7 @@ static nserror global_history_initialise_time(void) full_time->tm_hour = 0; t = mktime(full_time); if (t == -1) { - LOG("mktime failed"); + NSLOG(netsurf, INFO, "mktime failed"); return NSERROR_UNKNOWN; } @@ -729,7 +729,7 @@ nserror global_history_init(struct core_window_callback_table *cw_t, return err; } - LOG("Loading global history"); + NSLOG(netsurf, INFO, "Loading global history"); /* Init. global history treeview time */ err = global_history_initialise_time(); @@ -785,7 +785,7 @@ nserror global_history_init(struct core_window_callback_table *cw_t, /* Inform client of window height */ treeview_get_height(gh_ctx.tree); - LOG("Loaded global history"); + NSLOG(netsurf, INFO, "Loaded global history"); return NSERROR_OK; } @@ -797,7 +797,7 @@ nserror global_history_fini(void) int i; nserror err; - LOG("Finalising global history"); + NSLOG(netsurf, INFO, "Finalising global history"); gh_ctx.built = false; @@ -815,7 +815,7 @@ nserror global_history_fini(void) return err; } - LOG("Finalised global history"); + NSLOG(netsurf, INFO, "Finalised global history"); return err; } @@ -832,7 +832,8 @@ nserror global_history_add(nsurl *url) data = urldb_get_url_data(url); if (data == NULL) { - LOG("Can't add URL to history that's not present in urldb."); + NSLOG(netsurf, INFO, + "Can't add URL to history that's not present in urldb."); return NSERROR_BAD_PARAMETER; } diff --git a/desktop/hotlist.c b/desktop/hotlist.c index 0f5be77c9..13a52d0da 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -138,7 +138,8 @@ static nserror hotlist_save(const char *path) /* Replace any old hotlist file with the one we just saved */ if (rename(temp_path, path) != 0) { res = NSERROR_SAVE_FAILED; - LOG("Error renaming hotlist: %s.", strerror(errno)); + NSLOG(netsurf, INFO, "Error renaming hotlist: %s.", + strerror(errno)); goto cleanup; } @@ -652,20 +653,20 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx) /* The li must contain an "a" element */ a = libdom_find_first_element(li, corestring_lwc_a); if (a == NULL) { - LOG("Missing in
  • "); + NSLOG(netsurf, INFO, "Missing in
  • "); return NSERROR_INVALID; } derror = dom_node_get_text_content(a, &title1); if (derror != DOM_NO_ERR) { - LOG("No title"); + NSLOG(netsurf, INFO, "No title"); dom_node_unref(a); return NSERROR_INVALID; } derror = dom_element_get_attribute(a, corestring_dom_href, &url1); if (derror != DOM_NO_ERR || url1 == NULL) { - LOG("No URL"); + NSLOG(netsurf, INFO, "No URL"); dom_string_unref(title1); dom_node_unref(a); return NSERROR_INVALID; @@ -683,7 +684,8 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx) dom_string_unref(url1); if (err != NSERROR_OK) { - LOG("Failed normalising '%s'", dom_string_data(url1)); + NSLOG(netsurf, INFO, "Failed normalising '%s'", + dom_string_data(url1)); if (title1 != NULL) { dom_string_unref(title1); @@ -763,7 +765,8 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx) error = dom_node_get_text_content(node, &title); if (error != DOM_NO_ERR || title == NULL) { - LOG("Empty

    or memory exhausted."); + NSLOG(netsurf, INFO, + "Empty

    or memory exhausted."); dom_string_unref(name); return NSERROR_DOM; } @@ -861,7 +864,7 @@ static nserror hotlist_load(const char *path, bool *loaded) /* Handle no path */ if (path == NULL) { - LOG("No hotlist file path provided."); + NSLOG(netsurf, INFO, "No hotlist file path provided."); return NSERROR_OK; } @@ -1283,7 +1286,7 @@ nserror hotlist_init( return err; } - LOG("Loading hotlist"); + NSLOG(netsurf, INFO, "Loading hotlist"); hl_ctx.tree = NULL; hl_ctx.built = false; @@ -1329,7 +1332,7 @@ nserror hotlist_init( * the treeview is built. */ hl_ctx.built = true; - LOG("Loaded hotlist"); + NSLOG(netsurf, INFO, "Loaded hotlist"); return NSERROR_OK; } @@ -1375,7 +1378,7 @@ nserror hotlist_fini(void) int i; nserror err; - LOG("Finalising hotlist"); + NSLOG(netsurf, INFO, "Finalising hotlist"); /* Remove any existing scheduled save callback */ guit->misc->schedule(-1, hotlist_schedule_save_cb, NULL); @@ -1384,7 +1387,7 @@ nserror hotlist_fini(void) /* Save the hotlist */ err = hotlist_save(hl_ctx.save_path); if (err != NSERROR_OK) { - LOG("Problem saving the hotlist."); + NSLOG(netsurf, INFO, "Problem saving the hotlist."); } free(hl_ctx.save_path); @@ -1403,7 +1406,7 @@ nserror hotlist_fini(void) return err; } - LOG("Finalised hotlist"); + NSLOG(netsurf, INFO, "Finalised hotlist"); return err; } diff --git a/desktop/knockout.c b/desktop/knockout.c index 7e964fc84..6dbf4ebcf 100644 --- a/desktop/knockout.c +++ b/desktop/knockout.c @@ -267,7 +267,9 @@ static nserror knockout_plot_flush(const struct redraw_context *ctx) /* debugging information */ #ifdef KNOCKOUT_DEBUG - LOG("Entries are %i/%i, %i/%i, %i/%i", knockout_entry_cur, KNOCKOUT_ENTRIES, knockout_box_cur, KNOCKOUT_BOXES, knockout_polygon_cur, KNOCKOUT_POLYGONS); + NSLOG(netsurf, INFO, "Entries are %i/%i, %i/%i, %i/%i", + knockout_entry_cur, KNOCKOUT_ENTRIES, knockout_box_cur, + KNOCKOUT_BOXES, knockout_polygon_cur, KNOCKOUT_POLYGONS); #endif for (i = 0; i < knockout_entry_cur; i++) { @@ -702,8 +704,8 @@ knockout_plot_clip(const struct redraw_context *ctx, const struct rect *clip) if (clip->x1 < clip->x0 || clip->y0 > clip->y1) { #ifdef KNOCKOUT_DEBUG - LOG("bad clip rectangle %i %i %i %i", - clip->x0, clip->y0, clip->x1, clip->y1); + NSLOG(netsurf, INFO, "bad clip rectangle %i %i %i %i", + clip->x0, clip->y0, clip->x1, clip->y1); #endif return NSERROR_BAD_SIZE; } diff --git a/desktop/mouse.c b/desktop/mouse.c index 6d22fd461..d22910582 100644 --- a/desktop/mouse.c +++ b/desktop/mouse.c @@ -30,5 +30,5 @@ */ void browser_mouse_state_dump(browser_mouse_state mouse) { - LOG("mouse state: %s %s %s %s %s %s %s %s %s %s %s %s %s %s", mouse & BROWSER_MOUSE_PRESS_1 ? "P1" : " ", mouse & BROWSER_MOUSE_PRESS_2 ? "P2" : " ", mouse & BROWSER_MOUSE_CLICK_1 ? "C1" : " ", mouse & BROWSER_MOUSE_CLICK_2 ? "C2" : " ", mouse & BROWSER_MOUSE_DOUBLE_CLICK ? "DC" : " ", mouse & BROWSER_MOUSE_TRIPLE_CLICK ? "TC" : " ", mouse & BROWSER_MOUSE_DRAG_1 ? "D1" : " ", mouse & BROWSER_MOUSE_DRAG_2 ? "D2" : " ", mouse & BROWSER_MOUSE_DRAG_ON ? "DO" : " ", mouse & BROWSER_MOUSE_HOLDING_1 ? "H1" : " ", mouse & BROWSER_MOUSE_HOLDING_2 ? "H2" : " ", mouse & BROWSER_MOUSE_MOD_1 ? "M1" : " ", mouse & BROWSER_MOUSE_MOD_2 ? "M2" : " ", mouse & BROWSER_MOUSE_MOD_3 ? "M3" : " "); + NSLOG(netsurf, INFO, "mouse state: %s %s %s %s %s %s %s %s %s %s %s %s %s %s", mouse & BROWSER_MOUSE_PRESS_1 ? "P1" : " ", mouse & BROWSER_MOUSE_PRESS_2 ? "P2" : " ", mouse & BROWSER_MOUSE_CLICK_1 ? "C1" : " ", mouse & BROWSER_MOUSE_CLICK_2 ? "C2" : " ", mouse & BROWSER_MOUSE_DOUBLE_CLICK ? "DC" : " ", mouse & BROWSER_MOUSE_TRIPLE_CLICK ? "TC" : " ", mouse & BROWSER_MOUSE_DRAG_1 ? "D1" : " ", mouse & BROWSER_MOUSE_DRAG_2 ? "D2" : " ", mouse & BROWSER_MOUSE_DRAG_ON ? "DO" : " ", mouse & BROWSER_MOUSE_HOLDING_1 ? "H1" : " ", mouse & BROWSER_MOUSE_HOLDING_2 ? "H2" : " ", mouse & BROWSER_MOUSE_MOD_1 ? "M1" : " ", mouse & BROWSER_MOUSE_MOD_2 ? "M2" : " ", mouse & BROWSER_MOUSE_MOD_3 ? "M3" : " "); } diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 3baa936f3..8aa949a5a 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -89,7 +89,8 @@ static void netsurf_lwc_iterator(lwc_string *str, void *pw) { - LOG("[%3u] %.*s", str->refcnt, (int)lwc_string_length(str), lwc_string_data(str)); + NSLOG(netsurf, INFO, "[%3u] %.*s", str->refcnt, + (int)lwc_string_length(str), lwc_string_data(str)); } /** @@ -165,8 +166,9 @@ nserror netsurf_init(const char *store_path) if (hlcache_parameters.llcache.limit < MINIMUM_MEMORY_CACHE_SIZE) { hlcache_parameters.llcache.limit = MINIMUM_MEMORY_CACHE_SIZE; - LOG("Setting minimum memory cache size %" PRIsizet, - hlcache_parameters.llcache.limit); + NSLOG(netsurf, INFO, + "Setting minimum memory cache size %"PRIsizet, + hlcache_parameters.llcache.limit); } /* Set up the max attempts made to fetch a timing out resource */ @@ -243,19 +245,19 @@ void netsurf_exit(void) { hlcache_stop(); - LOG("Closing GUI"); + NSLOG(netsurf, INFO, "Closing GUI"); guit->misc->quit(); - LOG("Finalising JavaScript"); + NSLOG(netsurf, INFO, "Finalising JavaScript"); js_finalise(); - LOG("Finalising Web Search"); + NSLOG(netsurf, INFO, "Finalising Web Search"); search_web_finalise(); - LOG("Finalising high-level cache"); + NSLOG(netsurf, INFO, "Finalising high-level cache"); hlcache_finalise(); - LOG("Closing fetches"); + NSLOG(netsurf, INFO, "Closing fetches"); fetcher_quit(); /* dump any remaining cache entries */ @@ -264,21 +266,21 @@ void netsurf_exit(void) /* Clean up after content handlers */ content_factory_fini(); - LOG("Closing utf8"); + NSLOG(netsurf, INFO, "Closing utf8"); utf8_finalise(); - LOG("Destroying URLdb"); + NSLOG(netsurf, INFO, "Destroying URLdb"); urldb_destroy(); - LOG("Destroying System colours"); + NSLOG(netsurf, INFO, "Destroying System colours"); ns_system_colour_finalize(); - LOG("Destroying Messages"); + NSLOG(netsurf, INFO, "Destroying Messages"); messages_destroy(); corestrings_fini(); - LOG("Remaining lwc strings:"); + NSLOG(netsurf, INFO, "Remaining lwc strings:"); lwc_iterate_strings(netsurf_lwc_iterator, NULL); - LOG("Exited successfully"); + NSLOG(netsurf, INFO, "Exited successfully"); } diff --git a/desktop/print.c b/desktop/print.c index 37172b7c1..54cc5451a 100644 --- a/desktop/print.c +++ b/desktop/print.c @@ -126,8 +126,10 @@ print_apply_settings(hlcache_handle *content, struct print_settings *settings) content_reformat(content, false, page_content_width, 0); - LOG("New layout applied.New height = %d ; New width = %d ", - content_get_height(content), content_get_width(content)); + NSLOG(netsurf, INFO, + "New layout applied.New height = %d ; New width = %d ", + content_get_height(content), + content_get_width(content)); return true; } diff --git a/desktop/save_complete.c b/desktop/save_complete.c index d6fb2feb1..cd1ac53b4 100644 --- a/desktop/save_complete.c +++ b/desktop/save_complete.c @@ -168,7 +168,7 @@ static bool save_complete_save_buffer(save_complete_ctx *ctx, fp = fopen(fname, "wb"); if (fp == NULL) { free(fname); - LOG("fopen(): errno = %i", errno); + NSLOG(netsurf, INFO, "fopen(): errno = %i", errno); guit->misc->warning("SaveError", strerror(errno)); return false; } @@ -1044,7 +1044,7 @@ static bool save_complete_node_handler(dom_node *node, } else if (type == DOM_DOCUMENT_NODE) { /* Do nothing */ } else { - LOG("Unhandled node type: %d", type); + NSLOG(netsurf, INFO, "Unhandled node type: %d", type); } return true; @@ -1075,7 +1075,7 @@ static bool save_complete_save_html_document(save_complete_ctx *ctx, fp = fopen(fname, "wb"); if (fp == NULL) { free(fname); - LOG("fopen(): errno = %i", errno); + NSLOG(netsurf, INFO, "fopen(): errno = %i", errno); guit->misc->warning("SaveError", strerror(errno)); return false; } @@ -1154,7 +1154,7 @@ static bool save_complete_inventory(save_complete_ctx *ctx) fp = fopen(fname, "w"); free(fname); if (fp == NULL) { - LOG("fopen(): errno = %i", errno); + NSLOG(netsurf, INFO, "fopen(): errno = %i", errno); guit->misc->warning("SaveError", strerror(errno)); return false; } @@ -1182,7 +1182,8 @@ static nserror regcomp_wrapper(regex_t *preg, const char *regex, int cflags) if (r) { char errbuf[200]; regerror(r, preg, errbuf, sizeof errbuf); - LOG("Failed to compile regexp '%s': %s\n", regex, errbuf); + NSLOG(netsurf, INFO, "Failed to compile regexp '%s': %s\n", + regex, errbuf); return NSERROR_INIT_FAILED; } return NSERROR_OK; diff --git a/desktop/save_pdf.c b/desktop/save_pdf.c index d303eca7c..83e3d4f31 100644 --- a/desktop/save_pdf.c +++ b/desktop/save_pdf.c @@ -171,7 +171,8 @@ bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *psty { DashPattern_e dash; #ifdef PDF_DEBUG - LOG("%d %d %d %d %f %X", x0, y0, x1, y1, page_height - y0, pstyle->fill_colour); + NSLOG(netsurf, INFO, "%d %d %d %d %f %X", x0, y0, x1, y1, + page_height - y0, pstyle->fill_colour); #endif if (pstyle->fill_type != PLOT_OP_TYPE_NONE) { @@ -262,7 +263,7 @@ bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style) #ifdef PDF_DEBUG int pmaxx = p[0], pmaxy = p[1]; int pminx = p[0], pminy = p[1]; - LOG("."); + NSLOG(netsurf, INFO, "."); #endif if (n == 0) return true; @@ -281,7 +282,8 @@ bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style) } #ifdef PDF_DEBUG - LOG("%d %d %d %d %f", pminx, pminy, pmaxx, pmaxy, page_height - pminy); + NSLOG(netsurf, INFO, "%d %d %d %d %f", pminx, pminy, pmaxx, pmaxy, + page_height - pminy); #endif HPDF_Page_Fill(pdf_page); @@ -294,7 +296,8 @@ bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style) bool pdf_plot_clip(const struct rect *clip) { #ifdef PDF_DEBUG - LOG("%d %d %d %d", clip->x0, clip->y0, clip->x1, clip->y1); + NSLOG(netsurf, INFO, "%d %d %d %d", clip->x0, clip->y0, clip->x1, + clip->y1); #endif /*Normalize cllipping area - to prevent overflows. @@ -314,7 +317,7 @@ bool pdf_plot_text(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle) { #ifdef PDF_DEBUG - LOG(". %d %d %.*s", x, y, (int)length, text); + NSLOG(netsurf, INFO, ". %d %d %.*s", x, y, (int)length, text); #endif char *word; HPDF_Font pdf_font; @@ -347,7 +350,7 @@ bool pdf_plot_text(int x, int y, const char *text, size_t length, bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style) { #ifdef PDF_DEBUG - LOG("."); + NSLOG(netsurf, INFO, "."); #endif if (style->fill_type != PLOT_OP_TYPE_NONE) { apply_clip_and_mode(false, @@ -378,7 +381,8 @@ bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style) bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style) { #ifdef PDF_DEBUG - LOG("%d %d %d %d %d %X", x, y, radius, angle1, angle2, style->stroke_colour); + NSLOG(netsurf, INFO, "%d %d %d %d %d %X", x, y, radius, angle1, + angle2, style->stroke_colour); #endif /* FIXME: line width 1 is ok ? */ @@ -406,7 +410,8 @@ bool pdf_plot_bitmap_tile(int x, int y, int width, int height, HPDF_REAL max_width, max_height; #ifdef PDF_DEBUG - LOG("%d %d %d %d %p 0x%x", x, y, width, height, bitmap, bg); + NSLOG(netsurf, INFO, "%d %d %d %d %p 0x%x", x, y, width, height, + bitmap, bg); #endif if (width == 0 || height == 0) return true; @@ -483,7 +488,8 @@ HPDF_Image pdf_extract_image(struct bitmap *bitmap) rgb_buffer = (unsigned char *)malloc(3 * img_width * img_height); alpha_buffer = (unsigned char *)malloc(img_width * img_height); if (rgb_buffer == NULL || alpha_buffer == NULL) { - LOG("Not enough memory to create RGB buffer"); + NSLOG(netsurf, INFO, + "Not enough memory to create RGB buffer"); free(rgb_buffer); free(alpha_buffer); return NULL; @@ -607,7 +613,7 @@ bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width, bool empty_path; #ifdef PDF_DEBUG - LOG("."); + NSLOG(netsurf, INFO, "."); #endif if (n == 0) @@ -649,7 +655,7 @@ bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width, i += 7; empty_path = false; } else { - LOG("bad path command %f", p[i]); + NSLOG(netsurf, INFO, "bad path command %f", p[i]); return false; } } @@ -685,7 +691,7 @@ bool pdf_begin(struct print_settings *print_settings) HPDF_Free(pdf_doc); pdf_doc = HPDF_New(error_handler, NULL); if (!pdf_doc) { - LOG("Error creating pdf_doc"); + NSLOG(netsurf, INFO, "Error creating pdf_doc"); return false; } @@ -708,7 +714,7 @@ bool pdf_begin(struct print_settings *print_settings) pdf_page = NULL; #ifdef PDF_DEBUG - LOG("pdf_begin finishes"); + NSLOG(netsurf, INFO, "pdf_begin finishes"); #endif return true; } @@ -717,7 +723,7 @@ bool pdf_begin(struct print_settings *print_settings) bool pdf_next_page(void) { #ifdef PDF_DEBUG - LOG("pdf_next_page begins"); + NSLOG(netsurf, INFO, "pdf_next_page begins"); #endif clip_update_needed = false; if (pdf_page != NULL) { @@ -745,7 +751,7 @@ bool pdf_next_page(void) pdfw_gs_save(pdf_page); #ifdef PDF_DEBUG - LOG("%f %f", page_width, page_height); + NSLOG(netsurf, INFO, "%f %f", page_width, page_height); #endif return true; @@ -755,7 +761,7 @@ bool pdf_next_page(void) void pdf_end(void) { #ifdef PDF_DEBUG - LOG("pdf_end begins"); + NSLOG(netsurf, INFO, "pdf_end begins"); #endif clip_update_needed = false; if (pdf_page != NULL) { @@ -780,7 +786,7 @@ void pdf_end(void) else save_pdf(settings->output); #ifdef PDF_DEBUG - LOG("pdf_end finishes"); + NSLOG(netsurf, INFO, "pdf_end finishes"); #endif } @@ -819,7 +825,8 @@ nserror save_pdf(const char *path) static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void *user_data) { - LOG("ERROR:\n\terror_no=%x\n\tdetail_no=%d\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no); + NSLOG(netsurf, INFO, "ERROR:\n\terror_no=%x\n\tdetail_no=%d\n", + (HPDF_UINT)error_no, (HPDF_UINT)detail_no); #ifdef PDF_DEBUG exit(1); #endif diff --git a/desktop/save_text.c b/desktop/save_text.c index e63c96eb9..791ae9201 100644 --- a/desktop/save_text.c +++ b/desktop/save_text.c @@ -75,7 +75,8 @@ void save_as_text(struct hlcache_handle *c, char *path) free(save.block); if (ret != NSERROR_OK) { - LOG("failed to convert to local encoding, return %d", ret); + NSLOG(netsurf, INFO, + "failed to convert to local encoding, return %d", ret); return; } @@ -84,12 +85,13 @@ void save_as_text(struct hlcache_handle *c, char *path) int res = fputs(result, out); if (res < 0) { - LOG("Warning: write failed"); + NSLOG(netsurf, INFO, "Warning: write failed"); } res = fputs("\n", out); if (res < 0) { - LOG("Warning: failed writing trailing newline"); + NSLOG(netsurf, INFO, + "Warning: failed writing trailing newline"); } fclose(out); diff --git a/desktop/searchweb.c b/desktop/searchweb.c index fb7ecc082..8933fc9fa 100644 --- a/desktop/searchweb.c +++ b/desktop/searchweb.c @@ -289,13 +289,16 @@ search_web_ico_callback(hlcache_handle *ico, switch (event->type) { case CONTENT_MSG_DONE: - LOG("icon '%s' retrieved", nsurl_access(hlcache_handle_get_url(ico))); + NSLOG(netsurf, INFO, "icon '%s' retrieved", + nsurl_access(hlcache_handle_get_url(ico))); guit->search_web->provider_update(provider->name, content_get_bitmap(ico)); break; case CONTENT_MSG_ERROR: - LOG("icon %s error: %s", nsurl_access(hlcache_handle_get_url(ico)), event->data.error); + NSLOG(netsurf, INFO, "icon %s error: %s", + nsurl_access(hlcache_handle_get_url(ico)), + event->data.error); case CONTENT_MSG_ERRORCODE: hlcache_handle_release(ico); /* clear reference to released handle */ @@ -439,7 +442,8 @@ default_ico_callback(hlcache_handle *ico, switch (event->type) { case CONTENT_MSG_DONE: - LOG("default icon '%s' retrieved", nsurl_access(hlcache_handle_get_url(ico))); + NSLOG(netsurf, INFO, "default icon '%s' retrieved", + nsurl_access(hlcache_handle_get_url(ico))); /* only set to default icon if providers icon has no handle */ if (ctx->providers[search_web_ctx.current].ico_handle == NULL) { @@ -450,7 +454,9 @@ default_ico_callback(hlcache_handle *ico, break; case CONTENT_MSG_ERROR: - LOG("icon %s error: %s", nsurl_access(hlcache_handle_get_url(ico)), event->data.error); + NSLOG(netsurf, INFO, "icon %s error: %s", + nsurl_access(hlcache_handle_get_url(ico)), + event->data.error); case CONTENT_MSG_ERRORCODE: hlcache_handle_release(ico); /* clear reference to released handle */ diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c index e7f87bd9d..f40af5968 100644 --- a/desktop/sslcert_viewer.c +++ b/desktop/sslcert_viewer.c @@ -391,7 +391,7 @@ sslcert_viewer_init(struct core_window_callback_table *cw_t, return err; } - LOG("Building certificate viewer"); + NSLOG(netsurf, INFO, "Building certificate viewer"); /* Init. certificate chain treeview entry fields */ err = sslcert_init_entry_fields(ssl_d); @@ -417,7 +417,7 @@ sslcert_viewer_init(struct core_window_callback_table *cw_t, } } - LOG("Built certificate viewer"); + NSLOG(netsurf, INFO, "Built certificate viewer"); return NSERROR_OK; } @@ -452,7 +452,7 @@ nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d) int i; nserror err; - LOG("Finalising ssl certificate viewer"); + NSLOG(netsurf, INFO, "Finalising ssl certificate viewer"); /* Destroy the treeview */ err = treeview_destroy(ssl_d->tree); @@ -470,7 +470,7 @@ nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d) return err; } - LOG("Finalised ssl certificate viewer"); + NSLOG(netsurf, INFO, "Finalised ssl certificate viewer"); return err; } diff --git a/desktop/textarea.c b/desktop/textarea.c index 65ee8b82f..1cbb767f6 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -828,7 +828,7 @@ static bool textarea_reflow_singleline(struct textarea *ta, size_t b_off, ta->lines = malloc(LINE_CHUNK_SIZE * sizeof(struct line_info)); if (ta->lines == NULL) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); return false; } ta->lines_alloc_size = LINE_CHUNK_SIZE; @@ -852,7 +852,7 @@ static bool textarea_reflow_singleline(struct textarea *ta, size_t b_off, char *temp = realloc(ta->password.data, b_len + TA_ALLOC_STEP); if (temp == NULL) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return false; } @@ -936,7 +936,8 @@ static bool textarea_reflow_multiline(struct textarea *ta, if (ta->lines == NULL) { ta->lines = calloc(sizeof(struct line_info), LINE_CHUNK_SIZE); if (ta->lines == NULL) { - LOG("Failed to allocate memory for textarea lines"); + NSLOG(netsurf, INFO, + "Failed to allocate memory for textarea lines"); return false; } ta->lines_alloc_size = LINE_CHUNK_SIZE; @@ -1053,7 +1054,7 @@ static bool textarea_reflow_multiline(struct textarea *ta, (line + 2 + LINE_CHUNK_SIZE) * sizeof(struct line_info)); if (temp == NULL) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return false; } @@ -1334,7 +1335,7 @@ static bool textarea_insert_text(struct textarea *ta, const char *text, char *temp = realloc(ta->text.data, b_len + ta->text.len + TA_ALLOC_STEP); if (temp == NULL) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return false; } @@ -1484,7 +1485,7 @@ static bool textarea_replace_text_internal(struct textarea *ta, size_t b_start, rep_len + ta->text.len - (b_end - b_start) + TA_ALLOC_STEP); if (temp == NULL) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return false; } @@ -1561,7 +1562,7 @@ static bool textarea_copy_to_undo_buffer(struct textarea *ta, char *temp = realloc(undo->text.data, b_offset + len + TA_ALLOC_STEP); if (temp == NULL) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return false; } @@ -1575,7 +1576,7 @@ static bool textarea_copy_to_undo_buffer(struct textarea *ta, (undo->next_detail + 128) * sizeof(struct textarea_undo_detail)); if (temp == NULL) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return false; } @@ -1835,13 +1836,13 @@ struct textarea *textarea_create(const textarea_flags flags, flags & TEXTAREA_PASSWORD)); if (callback == NULL) { - LOG("no callback provided"); + NSLOG(netsurf, INFO, "no callback provided"); return NULL; } ret = malloc(sizeof(struct textarea)); if (ret == NULL) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); return NULL; } @@ -1888,7 +1889,7 @@ struct textarea *textarea_create(const textarea_flags flags, ret->text.data = malloc(TA_ALLOC_STEP); if (ret->text.data == NULL) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); free(ret); return NULL; } @@ -1900,7 +1901,7 @@ struct textarea *textarea_create(const textarea_flags flags, if (flags & TEXTAREA_PASSWORD) { ret->password.data = malloc(TA_ALLOC_STEP); if (ret->password.data == NULL) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); free(ret->text.data); free(ret); return NULL; @@ -1975,7 +1976,7 @@ bool textarea_set_text(struct textarea *ta, const char *text) if (len >= ta->text.alloc) { char *temp = realloc(ta->text.data, len + TA_ALLOC_STEP); if (temp == NULL) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return false; } ta->text.data = temp; @@ -2062,7 +2063,7 @@ int textarea_get_text(struct textarea *ta, char *buf, unsigned int len) } if (len < ta->text.len) { - LOG("buffer too small"); + NSLOG(netsurf, INFO, "buffer too small"); return -1; } diff --git a/desktop/treeview.c b/desktop/treeview.c index fe3aa94c3..259ec0590 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -1601,7 +1601,7 @@ treeview_cw_attach(treeview *tree, assert(cw != NULL); if (tree->cw_t != NULL || tree->cw_h != NULL) { - LOG("Treeview already attached."); + NSLOG(netsurf, INFO, "Treeview already attached."); return NSERROR_UNKNOWN; } tree->cw_t = cw_t; @@ -1666,7 +1666,7 @@ treeview_node_expand_internal(treeview *tree, treeview_node *node) if (node->flags & TV_NFLAGS_EXPANDED) { /* What madness is this? */ - LOG("Tried to expand an expanded node."); + NSLOG(netsurf, INFO, "Tried to expand an expanded node."); return NSERROR_OK; } @@ -1824,7 +1824,7 @@ treeview_node_contract_internal(treeview *tree, treeview_node *node) if ((node->flags & TV_NFLAGS_EXPANDED) == false) { /* What madness is this? */ - LOG("Tried to contract a contracted node."); + NSLOG(netsurf, INFO, "Tried to contract a contracted node."); return NSERROR_OK; } @@ -2771,7 +2771,7 @@ static nserror treeview_move_selection(treeview *tree, struct rect *rect) break; default: - LOG("Bad drop target for move."); + NSLOG(netsurf, INFO, "Bad drop target for move."); return NSERROR_BAD_PARAMETER; } @@ -4403,7 +4403,7 @@ nserror treeview_init(void) return NSERROR_OK; } - LOG("Initialising treeview module"); + NSLOG(netsurf, INFO, "Initialising treeview module"); font_pt_size = nsoption_int(treeview_font_size); if (font_pt_size <= 0) { @@ -4434,7 +4434,7 @@ nserror treeview_init(void) tree_g.initialised++; - LOG("Initialised treeview module"); + NSLOG(netsurf, INFO, "Initialised treeview module"); return NSERROR_OK; } @@ -4450,11 +4450,12 @@ nserror treeview_fini(void) return NSERROR_OK; } else if (tree_g.initialised == 0) { - LOG("Warning: tried to finalise uninitialised treeview module"); + NSLOG(netsurf, INFO, + "Warning: tried to finalise uninitialised treeview module"); return NSERROR_OK; } - LOG("Finalising treeview module"); + NSLOG(netsurf, INFO, "Finalising treeview module"); for (i = 0; i < TREE_RES_LAST; i++) { hlcache_handle_release(treeview_res[i].c); @@ -4471,7 +4472,7 @@ nserror treeview_fini(void) tree_g.initialised--; - LOG("Finalised treeview module"); + NSLOG(netsurf, INFO, "Finalised treeview module"); return NSERROR_OK; } diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c index 7bb2f5882..9484ee92b 100644 --- a/frontends/amiga/arexx.c +++ b/frontends/amiga/arexx.c @@ -173,7 +173,7 @@ void ami_arexx_execute(char *script) if((lock = Lock(script, ACCESS_READ))) { DevNameFromLock(lock, full_script_path, 1024, DN_FULLPATH); - LOG("Executing script: %s", full_script_path); + NSLOG(netsurf, INFO, "Executing script: %s", full_script_path); ami_arexx_command(full_script_path, NULL); UnLock(lock); } diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c index 533b416fa..757b55965 100644 --- a/frontends/amiga/bitmap.c +++ b/frontends/amiga/bitmap.c @@ -161,7 +161,10 @@ static void amiga_bitmap_unmap_buffer(void *p) struct bitmap *bm = p; if((nsoption_bool(use_extmem) == true) && (bm->pixdata != NULL)) { - LOG("Unmapping ExtMem object %p for bitmap %p", bm->iextmem, bm); + NSLOG(netsurf, INFO, + "Unmapping ExtMem object %p for bitmap %p", + bm->iextmem, + bm); bm->iextmem->Unmap(bm->pixdata, bm->size); bm->pixdata = NULL; } @@ -176,7 +179,10 @@ unsigned char *amiga_bitmap_get_buffer(void *bitmap) #ifdef __amigaos4__ if(nsoption_bool(use_extmem) == true) { if(bm->pixdata == NULL) { - LOG("Mapping ExtMem object %p for bitmap %p", bm->iextmem, bm); + NSLOG(netsurf, INFO, + "Mapping ExtMem object %p for bitmap %p", + bm->iextmem, + bm); bm->pixdata = bm->iextmem->Map(NULL, bm->size, 0LL, 0); } @@ -723,7 +729,7 @@ void ami_bitmap_fini(void) static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content) { #ifdef __amigaos4__ - LOG("Entering bitmap_render"); + NSLOG(netsurf, INFO, "Entering bitmap_render"); int plot_width; int plot_height; diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c index fd71a9c2a..45e883fde 100644 --- a/frontends/amiga/cookies.c +++ b/frontends/amiga/cookies.c @@ -364,7 +364,7 @@ nserror ami_cookies_present(void) res = ami_cookies_create_window(ncwin); if (res != NSERROR_OK) { - LOG("SSL UI builder init failed"); + NSLOG(netsurf, INFO, "SSL UI builder init failed"); ami_utf8_free(ncwin->core.wintitle); free(ncwin); return res; diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c index 1a94dd3b2..243146a3a 100644 --- a/frontends/amiga/corewindow.c +++ b/frontends/amiga/corewindow.c @@ -315,7 +315,7 @@ static void ami_cw_redraw_queue(struct ami_corewindow *ami_cw, bool draw) if(IsMinListEmpty(ami_cw->deferred_rects)) return; if(draw == false) { - LOG("Ignoring deferred box redraw queue"); + NSLOG(netsurf, INFO, "Ignoring deferred box redraw queue"); } // else should probably show busy pointer node = (struct nsObject *)GetHead((struct List *)ami_cw->deferred_rects); @@ -378,7 +378,8 @@ ami_cw_redraw(struct ami_corewindow *ami_cw, const struct rect *restrict r) nsobj = AddObject(ami_cw->deferred_rects, AMINS_RECT); nsobj->objstruct = deferred_rect; } else { - LOG("Ignoring duplicate or subset of queued box redraw"); + NSLOG(netsurf, INFO, + "Ignoring duplicate or subset of queued box redraw"); } ami_schedule(1, ami_cw_redraw_cb, ami_cw); } diff --git a/frontends/amiga/drag.c b/frontends/amiga/drag.c index a8d3aa9f9..ec0ee3c6a 100644 --- a/frontends/amiga/drag.c +++ b/frontends/amiga/drag.c @@ -188,7 +188,8 @@ void ami_drag_save(struct Window *win) break; default: - LOG("Unsupported drag save operation %d", drag_save); + NSLOG(netsurf, INFO, + "Unsupported drag save operation %d", drag_save); break; } diff --git a/frontends/amiga/dt_anim.c b/frontends/amiga/dt_anim.c index 2493c41ee..bd049206c 100644 --- a/frontends/amiga/dt_anim.c +++ b/frontends/amiga/dt_anim.c @@ -162,7 +162,7 @@ nserror amiga_dt_anim_create(const content_handler *handler, bool amiga_dt_anim_convert(struct content *c) { - LOG("amiga_dt_anim_convert"); + NSLOG(netsurf, INFO, "amiga_dt_anim_convert"); amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c; union content_msg_data msg_data; @@ -246,7 +246,7 @@ void amiga_dt_anim_destroy(struct content *c) { amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c; - LOG("amiga_dt_anim_destroy"); + NSLOG(netsurf, INFO, "amiga_dt_anim_destroy"); if (plugin->bitmap != NULL) amiga_bitmap_destroy(plugin->bitmap); @@ -263,7 +263,7 @@ bool amiga_dt_anim_redraw(struct content *c, amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c; bitmap_flags_t flags = BITMAPF_NONE; - LOG("amiga_dt_anim_redraw"); + NSLOG(netsurf, INFO, "amiga_dt_anim_redraw"); if (data->repeat_x) flags |= BITMAPF_REPEAT_X; @@ -290,20 +290,20 @@ bool amiga_dt_anim_redraw(struct content *c, void amiga_dt_anim_open(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params) { - LOG("amiga_dt_anim_open"); + NSLOG(netsurf, INFO, "amiga_dt_anim_open"); return; } void amiga_dt_anim_close(struct content *c) { - LOG("amiga_dt_anim_close"); + NSLOG(netsurf, INFO, "amiga_dt_anim_close"); return; } void amiga_dt_anim_reformat(struct content *c, int width, int height) { - LOG("amiga_dt_anim_reformat"); + NSLOG(netsurf, INFO, "amiga_dt_anim_reformat"); return; } @@ -312,7 +312,7 @@ nserror amiga_dt_anim_clone(const struct content *old, struct content **newc) amiga_dt_anim_content *plugin; nserror error; - LOG("amiga_dt_anim_clone"); + NSLOG(netsurf, INFO, "amiga_dt_anim_clone"); plugin = calloc(1, sizeof(amiga_dt_anim_content)); if (plugin == NULL) diff --git a/frontends/amiga/dt_picture.c b/frontends/amiga/dt_picture.c index 73f6c47c1..88ce1c834 100644 --- a/frontends/amiga/dt_picture.c +++ b/frontends/amiga/dt_picture.c @@ -174,7 +174,7 @@ static char *amiga_dt_picture_datatype(struct content *c) static struct bitmap *amiga_dt_picture_cache_convert(struct content *c) { - LOG("amiga_dt_picture_cache_convert"); + NSLOG(netsurf, INFO, "amiga_dt_picture_cache_convert"); union content_msg_data msg_data; UBYTE *bm_buffer; @@ -210,7 +210,7 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c) bool amiga_dt_picture_convert(struct content *c) { - LOG("amiga_dt_picture_convert"); + NSLOG(netsurf, INFO, "amiga_dt_picture_convert"); int width, height; char *title; @@ -256,7 +256,7 @@ nserror amiga_dt_picture_clone(const struct content *old, struct content **newc) struct content *adt; nserror error; - LOG("amiga_dt_picture_clone"); + NSLOG(netsurf, INFO, "amiga_dt_picture_clone"); adt = calloc(1, sizeof(struct content)); if (adt == NULL) diff --git a/frontends/amiga/dt_sound.c b/frontends/amiga/dt_sound.c index eda60edc1..e0f48da83 100644 --- a/frontends/amiga/dt_sound.c +++ b/frontends/amiga/dt_sound.c @@ -76,7 +76,7 @@ static const content_handler amiga_dt_sound_content_handler = { static void amiga_dt_sound_play(Object *dto) { - LOG("Playing..."); + NSLOG(netsurf, INFO, "Playing..."); IDoMethod(dto, DTM_TRIGGER, NULL, STM_PLAY, NULL); } @@ -126,7 +126,7 @@ nserror amiga_dt_sound_create(const content_handler *handler, amiga_dt_sound_content *plugin; nserror error; - LOG("amiga_dt_sound_create"); + NSLOG(netsurf, INFO, "amiga_dt_sound_create"); plugin = calloc(1, sizeof(amiga_dt_sound_content)); if (plugin == NULL) @@ -146,7 +146,7 @@ nserror amiga_dt_sound_create(const content_handler *handler, bool amiga_dt_sound_convert(struct content *c) { - LOG("amiga_dt_sound_convert"); + NSLOG(netsurf, INFO, "amiga_dt_sound_convert"); amiga_dt_sound_content *plugin = (amiga_dt_sound_content *) c; int width = 50, height = 50; @@ -180,7 +180,7 @@ void amiga_dt_sound_destroy(struct content *c) { amiga_dt_sound_content *plugin = (amiga_dt_sound_content *) c; - LOG("amiga_dt_sound_destroy"); + NSLOG(netsurf, INFO, "amiga_dt_sound_destroy"); DisposeDTObject(plugin->dto); @@ -199,7 +199,7 @@ bool amiga_dt_sound_redraw(struct content *c, }; struct rect rect; - LOG("amiga_dt_sound_redraw"); + NSLOG(netsurf, INFO, "amiga_dt_sound_redraw"); rect.x0 = data->x; rect.y0 = data->y; @@ -226,7 +226,7 @@ void amiga_dt_sound_open(struct content *c, struct browser_window *bw, amiga_dt_sound_content *plugin = (amiga_dt_sound_content *) c; struct object_param *param; - LOG("amiga_dt_sound_open"); + NSLOG(netsurf, INFO, "amiga_dt_sound_open"); plugin->immediate = false; @@ -234,7 +234,8 @@ void amiga_dt_sound_open(struct content *c, struct browser_window *bw, { do { - LOG("%s = %s", param->name, param->value); + NSLOG(netsurf, INFO, "%s = %s", param->name, + param->value); if((strcmp(param->name, "autoplay") == 0) && (strcmp(param->value, "true") == 0)) plugin->immediate = true; if((strcmp(param->name, "autoStart") == 0) && @@ -255,7 +256,7 @@ nserror amiga_dt_sound_clone(const struct content *old, struct content **newc) amiga_dt_sound_content *plugin; nserror error; - LOG("amiga_dt_sound_clone"); + NSLOG(netsurf, INFO, "amiga_dt_sound_clone"); plugin = calloc(1, sizeof(amiga_dt_sound_content)); if (plugin == NULL) diff --git a/frontends/amiga/filetype.c b/frontends/amiga/filetype.c index a0449d848..0e535de07 100644 --- a/frontends/amiga/filetype.c +++ b/frontends/amiga/filetype.c @@ -185,7 +185,7 @@ nserror ami_mime_init(const char *mimefile) struct nsObject *node; struct ami_mime_entry *mimeentry; - LOG("mimetypes file: %s", mimefile); + NSLOG(netsurf, INFO, "mimetypes file: %s", mimefile); if(ami_mime_list == NULL) ami_mime_list = NewObjList(); @@ -642,6 +642,10 @@ void ami_mime_dump(void) struct ami_mime_entry *mimeentry; while((mimeentry = ami_mime_entry_locate(NULL, AMI_MIME_MIMETYPE, &node))) { - LOG("%s DT=\"%s\" TYPE=\"%s\" CMD=\"%s\"", mimeentry->mimetype ? lwc_string_data(mimeentry->mimetype) : "", mimeentry->datatype ? lwc_string_data(mimeentry->datatype) : "", mimeentry->filetype ? lwc_string_data(mimeentry->filetype) : "", mimeentry->plugincmd ? lwc_string_data(mimeentry->plugincmd) : ""); + NSLOG(netsurf, INFO, "%s DT=\"%s\" TYPE=\"%s\" CMD=\"%s\"", + mimeentry->mimetype ? lwc_string_data(mimeentry->mimetype) : "", + mimeentry->datatype ? lwc_string_data(mimeentry->datatype) : "", + mimeentry->filetype ? lwc_string_data(mimeentry->filetype) : "", + mimeentry->plugincmd ? lwc_string_data(mimeentry->plugincmd) : ""); }; } diff --git a/frontends/amiga/font.c b/frontends/amiga/font.c index 22a0f4a4a..63172623f 100644 --- a/frontends/amiga/font.c +++ b/frontends/amiga/font.c @@ -51,7 +51,8 @@ void ami_font_setdevicedpi(int id) struct DisplayInfo dinfo; if(nsoption_bool(bitmap_fonts) == true) { - LOG("WARNING: Using diskfont.library for text. Forcing DPI to 72."); + NSLOG(netsurf, INFO, + "WARNING: Using diskfont.library for text. Forcing DPI to 72."); nsoption_set_int(screen_ydpi, 72); } @@ -79,7 +80,14 @@ void ami_font_setdevicedpi(int id) xdpi = (yres * ydpi) / xres; - LOG("XDPI = %ld, YDPI = %ld (DisplayInfo resolution %d x %d, corrected %d x %d)", xdpi, ydpi, dinfo.Resolution.x, dinfo.Resolution.y, xres, yres); + NSLOG(netsurf, INFO, + "XDPI = %ld, YDPI = %ld (DisplayInfo resolution %d x %d, corrected %d x %d)", + xdpi, + ydpi, + dinfo.Resolution.x, + dinfo.Resolution.y, + xres, + yres); } } } diff --git a/frontends/amiga/font_bullet.c b/frontends/amiga/font_bullet.c index fd41c29a2..c8ad34c04 100644 --- a/frontends/amiga/font_bullet.c +++ b/frontends/amiga/font_bullet.c @@ -361,7 +361,7 @@ static struct ami_font_cache_node *ami_font_open(const char *font, bool critical if(!nodedata->font) { - LOG("Requested font not found: %s", font); + NSLOG(netsurf, INFO, "Requested font not found: %s", font); if(critical == true) amiga_warn_user("CompError", font); free(nodedata); return NULL; @@ -369,21 +369,28 @@ static struct ami_font_cache_node *ami_font_open(const char *font, bool critical nodedata->bold = (char *)GetTagData(OT_BName, 0, nodedata->font->olf_OTagList); if(nodedata->bold) - LOG("Bold font defined for %s is %s", font, nodedata->bold); + NSLOG(netsurf, INFO, "Bold font defined for %s is %s", font, + nodedata->bold); else - LOG("Warning: No designed bold font defined for %s", font); + NSLOG(netsurf, INFO, + "Warning: No designed bold font defined for %s", font); nodedata->italic = (char *)GetTagData(OT_IName, 0, nodedata->font->olf_OTagList); if(nodedata->italic) - LOG("Italic font defined for %s is %s", font, nodedata->italic); + NSLOG(netsurf, INFO, "Italic font defined for %s is %s", + font, nodedata->italic); else - LOG("Warning: No designed italic font defined for %s", font); + NSLOG(netsurf, INFO, + "Warning: No designed italic font defined for %s", font); nodedata->bolditalic = (char *)GetTagData(OT_BIName, 0, nodedata->font->olf_OTagList); if(nodedata->bolditalic) - LOG("Bold-italic font defined for %s is %s", font, nodedata->bolditalic); + NSLOG(netsurf, INFO, "Bold-italic font defined for %s is %s", + font, nodedata->bolditalic); else - LOG("Warning: No designed bold-italic font defined for %s", font); + NSLOG(netsurf, INFO, + "Warning: No designed bold-italic font defined for %s", + font); ami_font_cache_insert(nodedata, font); return nodedata; diff --git a/frontends/amiga/font_cache.c b/frontends/amiga/font_cache.c index 3d8330979..86e2381c0 100644 --- a/frontends/amiga/font_cache.c +++ b/frontends/amiga/font_cache.c @@ -69,7 +69,10 @@ static void ami_font_cache_cleanup(struct SkipList *skiplist) SubTime(&curtime, &node->lastused); if(curtime.Seconds > 300) { - LOG("Freeing font %p not used for %ld seconds", node->skip_node.sn_Key, curtime.Seconds); + NSLOG(netsurf, INFO, + "Freeing font %p not used for %ld seconds", + node->skip_node.sn_Key, + curtime.Seconds); ami_font_bullet_close(node); RemoveSkipNode(skiplist, node->skip_node.sn_Key); } @@ -98,7 +101,10 @@ static void ami_font_cache_cleanup(struct MinList *ami_font_cache_list) SubTime(&curtime, &fnode->lastused); if(curtime.Seconds > 300) { - LOG("Freeing %s not used for %ld seconds", node->dtz_Node.ln_Name, curtime.Seconds); + NSLOG(netsurf, INFO, + "Freeing %s not used for %ld seconds", + node->dtz_Node.ln_Name, + curtime.Seconds); DelObject(node); } } while((node=nnode)); @@ -146,7 +152,7 @@ struct ami_font_cache_node *ami_font_cache_locate(const char *font) return nodedata; } - LOG("Font cache miss: %s (%lx)", font, hash); + NSLOG(netsurf, INFO, "Font cache miss: %s (%lx)", font, hash); return NULL; } @@ -180,7 +186,7 @@ void ami_font_cache_insert(struct ami_font_cache_node *nodedata, const char *fon void ami_font_cache_fini(void) { - LOG("Cleaning up font cache"); + NSLOG(netsurf, INFO, "Cleaning up font cache"); ami_schedule(-1, (void *)ami_font_cache_cleanup, ami_font_cache_list); #ifdef __amigaos4__ ami_font_cache_del_skiplist(ami_font_cache_list); diff --git a/frontends/amiga/font_diskfont.c b/frontends/amiga/font_diskfont.c index 7abc4379b..658829237 100644 --- a/frontends/amiga/font_diskfont.c +++ b/frontends/amiga/font_diskfont.c @@ -55,7 +55,7 @@ static struct TextFont *ami_font_bm_open(struct RastPort *rp, const plot_font_st (fstyle->size == prev_fstyle->size) && (fstyle->flags == prev_fstyle->flags) && (fstyle->weight == prev_fstyle->weight)) { - LOG("(using current font)"); + NSLOG(netsurf, INFO, "(using current font)"); return prev_font; } @@ -99,7 +99,7 @@ static struct TextFont *ami_font_bm_open(struct RastPort *rp, const plot_font_st snprintf(font, MAX_FONT_NAME_SIZE, "%s.font", fontname); tattr.ta_Name = font; tattr.ta_YSize = fstyle->size / FONT_SIZE_SCALE; - LOG("font: %s/%d", tattr.ta_Name, tattr.ta_YSize); + NSLOG(netsurf, INFO, "font: %s/%d", tattr.ta_Name, tattr.ta_YSize); if(prev_font != NULL) CloseFont(prev_font); diff --git a/frontends/amiga/font_scan.c b/frontends/amiga/font_scan.c index 932179e3e..cb37f97fa 100644 --- a/frontends/amiga/font_scan.c +++ b/frontends/amiga/font_scan.c @@ -255,7 +255,8 @@ static ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray) #ifdef __amigaos4__ if(EObtainInfo(AMI_OFONT_ENGINE, OT_UnicodeRanges, &unicoderanges, TAG_END) == 0) { if(unicoderanges & UCR_SURROGATES) { - LOG("%s supports UTF-16 surrogates", fontname); + NSLOG(netsurf, INFO, "%s supports UTF-16 surrogates", + fontname); if (nsoption_charp(font_surrogate) == NULL) { nsoption_set_charp(font_surrogate, (char *)strdup(fontname)); } @@ -292,10 +293,11 @@ static ULONG ami_font_scan_fonts(struct MinList *list, do { nnode = (struct nsObject *)GetSucc((struct Node *)node); ami_font_scan_gui_update(win, node->dtz_Node.ln_Name, font_num, total); - LOG("Scanning %s", node->dtz_Node.ln_Name); + NSLOG(netsurf, INFO, "Scanning %s", node->dtz_Node.ln_Name); found = ami_font_scan_font(node->dtz_Node.ln_Name, glypharray); total += found; - LOG("Found %ld new glyphs (total = %ld)", found, total); + NSLOG(netsurf, INFO, "Found %ld new glyphs (total = %ld)", + found, total); font_num++; } while((node = nnode)); @@ -344,7 +346,9 @@ static ULONG ami_font_scan_list(struct MinList *list) if(node) { node->dtz_Node.ln_Name = strdup(af[i].af_Attr.ta_Name); found++; - LOG("Added %s", af[i].af_Attr.ta_Name); + NSLOG(netsurf, INFO, + "Added %s", + af[i].af_Attr.ta_Name); } } } @@ -382,7 +386,8 @@ static ULONG ami_font_scan_load(const char *filename, lwc_string **glypharray) rargs = AllocDosObjectTags(DOS_RDARGS, TAG_DONE); if((fh = FOpen(filename, MODE_OLDFILE, 0))) { - LOG("Loading font glyph cache from %s", filename); + NSLOG(netsurf, INFO, "Loading font glyph cache from %s", + filename); while(FGets(fh, (STRPTR)&buffer, 256) != 0) { @@ -423,7 +428,8 @@ void ami_font_scan_save(const char *filename, lwc_string **glypharray) BPTR fh = 0; if((fh = FOpen(filename, MODE_NEWFILE, 0))) { - LOG("Writing font glyph cache to %s", filename); + NSLOG(netsurf, INFO, "Writing font glyph cache to %s", + filename); FPrintf(fh, "; This file is auto-generated. To re-create the cache, delete this file.\n"); FPrintf(fh, "; This file is parsed using ReadArgs() with the following template:\n"); FPrintf(fh, "; CODE/A,FONT/A\n;\n"); @@ -482,7 +488,7 @@ void ami_font_scan_init(const char *filename, bool force_scan, bool save, found = ami_font_scan_load(filename, glypharray); if(found == 0) { - LOG("Creating new font glyph cache"); + NSLOG(netsurf, INFO, "Creating new font glyph cache"); if((list = NewObjList())) { /* add preferred fonts list */ @@ -504,7 +510,7 @@ void ami_font_scan_init(const char *filename, bool force_scan, bool save, if(nsoption_bool(font_unicode_only) == false) entries += ami_font_scan_list(list); - LOG("Found %ld fonts", entries); + NSLOG(netsurf, INFO, "Found %ld fonts", entries); win = ami_font_scan_gui_open(entries); found = ami_font_scan_fonts(list, win, glypharray); @@ -517,6 +523,6 @@ void ami_font_scan_init(const char *filename, bool force_scan, bool save, } } - LOG("Initialised with %ld glyphs", found); + NSLOG(netsurf, INFO, "Initialised with %ld glyphs", found); } diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index 44bba2d90..387c2151c 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -342,7 +342,9 @@ bool ami_gui_map_filename(char **remapped, const char *restrict path, } if(found == false) *remapped = strdup(file); - else LOG("Remapped %s to %s in path %s using %s", file, *remapped, path, map); + else NSLOG(netsurf, INFO, + "Remapped %s to %s in path %s using %s", file, + *remapped, path, map); free(mapfile); @@ -365,7 +367,7 @@ static bool ami_gui_check_resource(char *fullpath, const char *file) found = true; } - if(found) LOG("Found %s", fullpath); + if(found) NSLOG(netsurf, INFO, "Found %s", fullpath); free(remapped); return found; @@ -842,7 +844,7 @@ static void ami_openscreen(void) } if(screen_signal == -1) screen_signal = AllocSignal(-1); - LOG("Screen signal %d", screen_signal); + NSLOG(netsurf, INFO, "Screen signal %d", screen_signal); scrn = OpenScreenTags(NULL, /**\todo specify screen depth */ SA_DisplayID, id, @@ -918,19 +920,22 @@ static struct RDArgs *ami_gui_commandline(int *restrict argc, char ** argv, if((args = ReadArgs(template, rarray, NULL))) { if(rarray[A_URL]) { - LOG("URL %s specified on command line", - (char *)rarray[A_URL]); + NSLOG(netsurf, INFO, + "URL %s specified on command line", + (char *)rarray[A_URL]); temp_homepage_url = strdup((char *)rarray[A_URL]); /**\todo allow IDNs */ } if(rarray[A_USERSDIR]) { - LOG("USERSDIR %s specified on command line", - (char *)rarray[A_USERSDIR]); + NSLOG(netsurf, INFO, + "USERSDIR %s specified on command line", + (char *)rarray[A_USERSDIR]); users_dir = ASPrintf("%s", rarray[A_USERSDIR]); } if(rarray[A_FORCE]) { - LOG("FORCE specified on command line"); + NSLOG(netsurf, INFO, + "FORCE specified on command line"); cli_force = true; } @@ -950,7 +955,7 @@ static struct RDArgs *ami_gui_commandline(int *restrict argc, char ** argv, */ } } else { - LOG("ReadArgs failed to parse command line"); + NSLOG(netsurf, INFO, "ReadArgs failed to parse command line"); } FreeArgs(args); @@ -2790,7 +2795,9 @@ static void ami_handle_applib(void) { struct ApplicationCustomMsg *applibcustmsg = (struct ApplicationCustomMsg *)applibmsg; - LOG("Ringhio BackMsg received: %s", applibcustmsg->customMsg); + NSLOG(netsurf, INFO, + "Ringhio BackMsg received: %s", + applibcustmsg->customMsg); ami_download_parse_backmsg(applibcustmsg->customMsg); } @@ -2826,7 +2833,7 @@ void ami_get_msg(void) NULL, (unsigned int *)&signalmask) != -1) { signal = signalmask; } else { - LOG("waitselect() returned error"); + NSLOG(netsurf, INFO, "waitselect() returned error"); /* \todo Fix Ctrl-C handling. * WaitSelect() from bsdsocket.library returns -1 if the task was * signalled with a Ctrl-C. waitselect() from newlib.library does not. @@ -3035,11 +3042,13 @@ static void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen, BOOL d if(donotwait == TRUE) return; ULONG scrnsig = 1 << screen_signal; - LOG("Waiting for visitor windows to close... (signal)"); + NSLOG(netsurf, INFO, + "Waiting for visitor windows to close... (signal)"); Wait(scrnsig); while (CloseScreen(scrn) == FALSE) { - LOG("Waiting for visitor windows to close... (polling)"); + NSLOG(netsurf, INFO, + "Waiting for visitor windows to close... (polling)"); Delay(50); } @@ -3081,11 +3090,11 @@ static void gui_quit(void) ami_font_fini(); ami_help_free(); - LOG("Freeing menu items"); + NSLOG(netsurf, INFO, "Freeing menu items"); ami_ctxmenu_free(); ami_menu_free_glyphs(); - LOG("Freeing mouse pointers"); + NSLOG(netsurf, INFO, "Freeing mouse pointers"); ami_mouse_pointers_free(); ami_file_req_free(); @@ -3099,7 +3108,7 @@ static void gui_quit(void) ami_clipboard_free(); ami_gui_resources_free(); - LOG("Closing screen"); + NSLOG(netsurf, INFO, "Closing screen"); ami_gui_close_screen(scrn, locked_screen, FALSE); if(nsscreentitle) FreeVec(nsscreentitle); } @@ -3109,7 +3118,7 @@ char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail) STRPTR filename = NULL; if ((filename = ASPrintf("%s/%x", current_user_faviconcache, nsurl_hash(url)))) { - LOG("favicon cache location: %s", filename); + NSLOG(netsurf, INFO, "favicon cache location: %s", filename); if (only_if_avail == true) { BPTR lock = 0; @@ -3723,7 +3732,8 @@ static nserror amiga_window_invalidate_area(struct gui_window *g, nsobj = AddObject(g->deferred_rects, AMINS_RECT); nsobj->objstruct = deferred_rect; } else { - LOG("Ignoring duplicate or subset of queued box redraw"); + NSLOG(netsurf, INFO, + "Ignoring duplicate or subset of queued box redraw"); } } ami_schedule_redraw(g->shared, false); @@ -3912,7 +3922,7 @@ gui_window_create(struct browser_window *bw, ULONG defer_layout = TRUE; ULONG idcmp_sizeverify = IDCMP_SIZEVERIFY; - LOG("Creating window"); + NSLOG(netsurf, INFO, "Creating window"); if (!scrn) ami_openscreenfirst(); @@ -4056,7 +4066,7 @@ gui_window_create(struct browser_window *bw, (strcmp(nsoption_charp(pubscreen_name), "Workbench") == 0)) iconifygadget = TRUE; - LOG("Creating menu"); + NSLOG(netsurf, INFO, "Creating menu"); struct Menu *menu = ami_gui_menu_create(g->shared); NewList(&g->shared->tab_list); @@ -4178,7 +4188,7 @@ gui_window_create(struct browser_window *bw, BitMapEnd; } - LOG("Creating window object"); + NSLOG(netsurf, INFO, "Creating window object"); g->shared->objects[OID_MAIN] = WindowObj, WA_ScreenTitle, ami_gui_get_screen_title(), @@ -4456,11 +4466,11 @@ gui_window_create(struct browser_window *bw, EndWindow; } - LOG("Opening window"); + NSLOG(netsurf, INFO, "Opening window"); g->shared->win = (struct Window *)RA_OpenWindow(g->shared->objects[OID_MAIN]); - LOG("Window opened, adding border gadgets"); + NSLOG(netsurf, INFO, "Window opened, adding border gadgets"); if(!g->shared->win) { @@ -4796,7 +4806,7 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw) if(draw == true) { ami_set_pointer(g->shared, GUI_POINTER_WAIT, false); } else { - LOG("Ignoring deferred box redraw queue"); + NSLOG(netsurf, INFO, "Ignoring deferred box redraw queue"); } node = (struct nsObject *)GetHead((struct List *)g->deferred_rects); @@ -4841,7 +4851,8 @@ bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects, (new_rect->y0 <= rect->y0) && (new_rect->x1 >= rect->x1) && (new_rect->y1 >= rect->y1)) { - LOG("Removing queued redraw that is a subset of new box redraw"); + NSLOG(netsurf, INFO, + "Removing queued redraw that is a subset of new box redraw"); ami_memory_itempool_free(mempool, node->objstruct, sizeof(struct rect)); DelObjectNoFree(node); /* Don't return - we might find more */ @@ -5414,20 +5425,20 @@ Object *ami_gui_splash_open(void) EndWindow; if(win_obj == NULL) { - LOG("Splash window object not created"); + NSLOG(netsurf, INFO, "Splash window object not created"); return NULL; } - LOG("Attempting to open splash window..."); + NSLOG(netsurf, INFO, "Attempting to open splash window..."); win = RA_OpenWindow(win_obj); if(win == NULL) { - LOG("Splash window did not open"); + NSLOG(netsurf, INFO, "Splash window did not open"); return NULL; } if(bm_obj == NULL) { - LOG("BitMap object not created"); + NSLOG(netsurf, INFO, "BitMap object not created"); return NULL; } @@ -5489,14 +5500,14 @@ void ami_gui_splash_close(Object *win_obj) { if(win_obj == NULL) return; - LOG("Closing splash window"); + NSLOG(netsurf, INFO, "Closing splash window"); DisposeObject(win_obj); } static void gui_file_gadget_open(struct gui_window *g, struct hlcache_handle *hl, struct form_control *gadget) { - LOG("File open dialog request for %p/%p", g, gadget); + NSLOG(netsurf, INFO, "File open dialog request for %p/%p", g, gadget); if(AslRequestTags(filereq, ASLFR_Window, g->shared->win, @@ -5531,7 +5542,7 @@ static char *ami_gui_get_user_dir(STRPTR current_user) user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY); current_user = ASPrintf("%s", (user == -1) ? "Default" : temp); } - LOG("User: %s", current_user); + NSLOG(netsurf, INFO, "User: %s", current_user); if(users_dir == NULL) { users_dir = ASPrintf("%s", USERS_DIR); @@ -5583,7 +5594,7 @@ static char *ami_gui_get_user_dir(STRPTR current_user) FreeVec(users_dir); FreeVec(current_user); - LOG("User dir: %s", current_user_dir); + NSLOG(netsurf, INFO, "User dir: %s", current_user_dir); if((lock = CreateDirTree(current_user_dir))) UnLock(lock); @@ -5810,7 +5821,7 @@ int main(int argc, char** argv) AddPart(script, nsoption_charp(arexx_startup), 1024); ami_arexx_execute(script); - LOG("Entering main loop"); + NSLOG(netsurf, INFO, "Entering main loop"); while (!ami_quit) { ami_get_msg(); diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c index 6ee0800f8..756f5e66c 100644 --- a/frontends/amiga/gui_menu.c +++ b/frontends/amiga/gui_menu.c @@ -584,7 +584,8 @@ ULONG ami_gui_menu_number(int item) break; default: - LOG("WARNING: Unrecognised menu item %d", item); + NSLOG(netsurf, INFO, + "WARNING: Unrecognised menu item %d", item); menu_num = 0; break; } diff --git a/frontends/amiga/history.c b/frontends/amiga/history.c index 7fc1ec333..e724f3e70 100644 --- a/frontends/amiga/history.c +++ b/frontends/amiga/history.c @@ -438,7 +438,7 @@ nserror ami_history_global_present(void) res = ami_history_global_create_window(ncwin); if (res != NSERROR_OK) { - LOG("SSL UI builder init failed"); + NSLOG(netsurf, INFO, "SSL UI builder init failed"); ami_utf8_free(ncwin->core.wintitle); free(ncwin); return res; diff --git a/frontends/amiga/history_local.c b/frontends/amiga/history_local.c index c293f5909..0ae9cc040 100644 --- a/frontends/amiga/history_local.c +++ b/frontends/amiga/history_local.c @@ -261,7 +261,7 @@ nserror ami_history_local_present(struct gui_window *gw) res = ami_history_local_create_window(ncwin); if (res != NSERROR_OK) { - LOG("SSL UI builder init failed"); + NSLOG(netsurf, INFO, "SSL UI builder init failed"); ami_utf8_free(ncwin->core.wintitle); free(ncwin); return res; diff --git a/frontends/amiga/hotlist.c b/frontends/amiga/hotlist.c index c0a6b6f58..c7efe9148 100644 --- a/frontends/amiga/hotlist.c +++ b/frontends/amiga/hotlist.c @@ -563,7 +563,7 @@ nserror ami_hotlist_present(void) res = ami_hotlist_create_window(ncwin); if (res != NSERROR_OK) { - LOG("SSL UI builder init failed"); + NSLOG(netsurf, INFO, "SSL UI builder init failed"); ami_utf8_free(ncwin->core.wintitle); free(ncwin); return res; diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c index d371d2585..35ca9697f 100755 --- a/frontends/amiga/memory.c +++ b/frontends/amiga/memory.c @@ -50,23 +50,38 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value) static int ami_memory_slab_usage_cb(const struct __slab_usage_information * sui) { if(sui->sui_slab_index <= 1) { - LOG("clib2 slab usage:"); - LOG(" The size of all slabs, in bytes: %ld", sui->sui_slab_size); - LOG(" Number of allocations which are not managed by slabs: %ld", - sui->sui_num_single_allocations); - LOG(" Total number of bytes allocated for memory not managed by slabs: %ld", - sui->sui_total_single_allocation_size); - LOG(" Number of slabs currently in play: %ld", sui->sui_num_slabs); - LOG(" Number of currently unused slabs: %ld", sui->sui_num_empty_slabs); - LOG(" Number of slabs in use which are completely filled with data: %ld", - sui->sui_num_full_slabs); - LOG(" Total number of bytes allocated for all slabs: %ld", - sui->sui_total_slab_allocation_size); + NSLOG(netsurf, INFO, "clib2 slab usage:"); + NSLOG(netsurf, INFO, + " The size of all slabs, in bytes: %ld", + sui->sui_slab_size); + NSLOG(netsurf, INFO, + " Number of allocations which are not managed by slabs: %ld", + sui->sui_num_single_allocations); + NSLOG(netsurf, INFO, + " Total number of bytes allocated for memory not managed by slabs: %ld", + sui->sui_total_single_allocation_size); + NSLOG(netsurf, INFO, + " Number of slabs currently in play: %ld", + sui->sui_num_slabs); + NSLOG(netsurf, INFO, + " Number of currently unused slabs: %ld", + sui->sui_num_empty_slabs); + NSLOG(netsurf, INFO, + " Number of slabs in use which are completely filled with data: %ld", + sui->sui_num_full_slabs); + NSLOG(netsurf, INFO, + " Total number of bytes allocated for all slabs: %ld", + sui->sui_total_slab_allocation_size); } - LOG("Slab %d", sui->sui_slab_index); - LOG(" Memory chunk size managed by this slab: %ld", sui->sui_chunk_size); - LOG(" Number of memory chunks that fit in this slab: %ld", sui->sui_num_chunks); - LOG(" Number of memory chunks used in this slab: %ld", sui->sui_num_chunks_used); + NSLOG(netsurf, INFO, "Slab %d", sui->sui_slab_index); + NSLOG(netsurf, INFO, " Memory chunk size managed by this slab: %ld", + sui->sui_chunk_size); + NSLOG(netsurf, INFO, + " Number of memory chunks that fit in this slab: %ld", + sui->sui_num_chunks); + NSLOG(netsurf, INFO, + " Number of memory chunks used in this slab: %ld", + sui->sui_num_chunks_used); return 0; } @@ -74,16 +89,20 @@ static int ami_memory_slab_usage_cb(const struct __slab_usage_information * sui) static int ami_memory_slab_alloc_cb(const struct __slab_allocation_information *sai) { if(sai->sai_allocation_index <= 1) { - LOG("clib2 allocation usage:"); - LOG(" Number of allocations which are not managed by slabs: %ld", - sai->sai_num_single_allocations); - LOG(" Total number of bytes allocated for memory not managed by slabs: %ld", - sai->sai_total_single_allocation_size); + NSLOG(netsurf, INFO, "clib2 allocation usage:"); + NSLOG(netsurf, INFO, + " Number of allocations which are not managed by slabs: %ld", + sai->sai_num_single_allocations); + NSLOG(netsurf, INFO, + " Total number of bytes allocated for memory not managed by slabs: %ld", + sai->sai_total_single_allocation_size); } - LOG("Alloc %d", sai->sai_allocation_index); - LOG(" Size of this allocation, as requested: %ld", sai->sai_allocation_size); - LOG(" Total size of this allocation, including management data: %ld", - sai->sai_total_allocation_size); + NSLOG(netsurf, INFO, "Alloc %d", sai->sai_allocation_index); + NSLOG(netsurf, INFO, " Size of this allocation, as requested: %ld", + sai->sai_allocation_size); + NSLOG(netsurf, INFO, + " Total size of this allocation, including management data: %ld", + sai->sai_total_allocation_size); return 0; } @@ -111,13 +130,13 @@ void ami_memory_slab_dump(BPTR fh) static void ami_memory_low_mem_handler(void *p) { if(low_mem_status == PURGE_STEP1) { - LOG("Purging llcache"); + NSLOG(netsurf, INFO, "Purging llcache"); llcache_clean(true); low_mem_status = PURGE_DONE_STEP1; } if(low_mem_status == PURGE_STEP2) { - LOG("Purging unused slabs"); + NSLOG(netsurf, INFO, "Purging unused slabs"); __free_unused_slabs(); low_mem_status = PURGE_DONE_STEP2; } diff --git a/frontends/amiga/misc.c b/frontends/amiga/misc.c index 5ca4f906a..532d2f182 100755 --- a/frontends/amiga/misc.c +++ b/frontends/amiga/misc.c @@ -46,7 +46,7 @@ static LONG ami_misc_req(const char *message, uint32 type) { LONG ret = 0; - LOG("%s", message); + NSLOG(netsurf, INFO, "%s", message); #ifdef __amigaos4__ ret = TimedDosRequesterTags( TDR_TitleString, messages_get("NetSurf"), diff --git a/frontends/amiga/os3support.c b/frontends/amiga/os3support.c index 6dc95795f..378bc04cc 100644 --- a/frontends/amiga/os3support.c +++ b/frontends/amiga/os3support.c @@ -216,13 +216,13 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl fh = Open(fontpath, MODE_OLDFILE); if(fh == 0) { - LOG("Unable to open FONT %s", fontpath); + NSLOG(netsurf, INFO, "Unable to open FONT %s", fontpath); FreeVec(fontpath); return NULL; } if(Read(fh, &fch, sizeof(struct FontContentsHeader)) != sizeof(struct FontContentsHeader)) { - LOG("Unable to read FONT %s", fontpath); + NSLOG(netsurf, INFO, "Unable to read FONT %s", fontpath); FreeVec(fontpath); Close(fh); return NULL; @@ -231,7 +231,7 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl Close(fh); if(fch.fch_FileID != OFCH_ID) { - LOG("%s is not an outline font!", fontpath); + NSLOG(netsurf, INFO, "%s is not an outline font!", fontpath); FreeVec(fontpath); return NULL; } @@ -242,7 +242,7 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl if(p) *p = '.'; if(fh == 0) { - LOG("Unable to open OTAG %s", otagpath); + NSLOG(netsurf, INFO, "Unable to open OTAG %s", otagpath); FreeVec(otagpath); return NULL; } @@ -250,7 +250,7 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl size = GetFileSize(fh); buffer = (UBYTE *)malloc(size); if(buffer == NULL) { - LOG("Unable to allocate memory"); + NSLOG(netsurf, INFO, "Unable to allocate memory"); Close(fh); FreeVec(otagpath); return NULL; @@ -262,7 +262,7 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl /* The first tag is supposed to be OT_FileIdent and should equal 'size' */ struct TagItem *tag = (struct TagItem *)buffer; if((tag->ti_Tag != OT_FileIdent) || (tag->ti_Data != (ULONG)size)) { - LOG("Invalid OTAG file"); + NSLOG(netsurf, INFO, "Invalid OTAG file"); free(buffer); FreeVec(otagpath); return NULL; @@ -277,10 +277,10 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl /* Find OT_Engine and open the font engine */ if(ti = FindTagItem(OT_Engine, buffer)) { - LOG("Using font engine %s", ti->ti_Data); + NSLOG(netsurf, INFO, "Using font engine %s", ti->ti_Data); fname = ASPrintf("%s.library", ti->ti_Data); } else { - LOG("Cannot find OT_Engine tag"); + NSLOG(netsurf, INFO, "Cannot find OT_Engine tag"); free(buffer); FreeVec(otagpath); return NULL; @@ -289,7 +289,7 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl BulletBase = (struct BulletBase *)OpenLibrary(fname, 0L); if(BulletBase == NULL) { - LOG("Unable to open font engine %s", fname); + NSLOG(netsurf, INFO, "Unable to open font engine %s", fname); free(buffer); FreeVec(fname); FreeVec(otagpath); diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c index e31d470a6..dc2c16724 100644 --- a/frontends/amiga/plotters.c +++ b/frontends/amiga/plotters.c @@ -131,7 +131,7 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit struct gui_globals *gg = malloc(sizeof(struct gui_globals)); if(force32bit == false) depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH); - LOG("Screen depth = %d", depth); + NSLOG(netsurf, INFO, "Screen depth = %d", depth); #ifdef __amigaos4__ if(depth < 16) { @@ -241,7 +241,8 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit gg->open_num = -1; init_layers_count++; - LOG("Layer initialised (total: %d)", init_layers_count); + NSLOG(netsurf, INFO, "Layer initialised (total: %d)", + init_layers_count); return gg; } @@ -328,7 +329,8 @@ static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr) (colr & 0x00ff0000) << 8, NULL); - if(pen == -1) LOG("WARNING: Cannot allocate pen for ABGR:%lx", colr); + if(pen == -1) NSLOG(netsurf, INFO, + "WARNING: Cannot allocate pen for ABGR:%lx", colr); if((shared_pens != NULL) && (pool_pens != NULL)) { if((node = (struct ami_plot_pen *)ami_memory_itempool_alloc(pool_pens, sizeof(struct ami_plot_pen)))) { @@ -849,17 +851,17 @@ ami_polygon(const struct redraw_context *ctx, ami_plot_setapen(glob, glob->rp, style->fill_colour); if (AreaMove(glob->rp,p[0],p[1]) == -1) { - LOG("AreaMove: vector list full"); + NSLOG(netsurf, INFO, "AreaMove: vector list full"); } for (uint32 k = 1; k < n; k++) { if (AreaDraw(glob->rp,p[k*2],p[(k*2)+1]) == -1) { - LOG("AreaDraw: vector list full"); + NSLOG(netsurf, INFO, "AreaDraw: vector list full"); } } if (AreaEnd(glob->rp) == -1) { - LOG("AreaEnd: error"); + NSLOG(netsurf, INFO, "AreaEnd: error"); } return NSERROR_OK; @@ -900,7 +902,7 @@ ami_path(const struct redraw_context *ctx, } if (p[0] != PLOTTER_PATH_MOVE) { - LOG("Path does not start with move"); + NSLOG(netsurf, INFO, "Path does not start with move"); return NSERROR_INVALID; } @@ -922,7 +924,8 @@ ami_path(const struct redraw_context *ctx, if (p[i] == PLOTTER_PATH_MOVE) { if (pstyle->fill_colour != NS_TRANSPARENT) { if (AreaMove(glob->rp, p[i+1], p[i+2]) == -1) { - LOG("AreaMove: vector list full"); + NSLOG(netsurf, INFO, + "AreaMove: vector list full"); } } else { Move(glob->rp, p[i+1], p[i+2]); @@ -936,7 +939,7 @@ ami_path(const struct redraw_context *ctx, } else if (p[i] == PLOTTER_PATH_CLOSE) { if (pstyle->fill_colour != NS_TRANSPARENT) { if (AreaEnd(glob->rp) == -1) { - LOG("AreaEnd: error"); + NSLOG(netsurf, INFO, "AreaEnd: error"); } } else { Draw(glob->rp, start_p.x, start_p.y); @@ -945,7 +948,8 @@ ami_path(const struct redraw_context *ctx, } else if (p[i] == PLOTTER_PATH_LINE) { if (pstyle->fill_colour != NS_TRANSPARENT) { if (AreaDraw(glob->rp, p[i+1], p[i+2]) == -1) { - LOG("AreaDraw: vector list full"); + NSLOG(netsurf, INFO, + "AreaDraw: vector list full"); } } else { Draw(glob->rp, p[i+1], p[i+2]); @@ -965,7 +969,8 @@ ami_path(const struct redraw_context *ctx, ami_bezier(&cur_p, &p_a, &p_b, &p_c, t, &p_r); if (pstyle->fill_colour != NS_TRANSPARENT) { if (AreaDraw(glob->rp, p_r.x, p_r.y) == -1) { - LOG("AreaDraw: vector list full"); + NSLOG(netsurf, INFO, + "AreaDraw: vector list full"); } } else { Draw(glob->rp, p_r.x, p_r.y); @@ -975,7 +980,7 @@ ami_path(const struct redraw_context *ctx, cur_p.y = p_c.y; i += 7; } else { - LOG("bad path command %f", p[i]); + NSLOG(netsurf, INFO, "bad path command %f", p[i]); /* End path for safety if using Area commands */ if (pstyle->fill_colour != NS_TRANSPARENT) { AreaEnd(glob->rp); diff --git a/frontends/amiga/plugin_hack.c b/frontends/amiga/plugin_hack.c index 2327f9190..4fd1f03f7 100644 --- a/frontends/amiga/plugin_hack.c +++ b/frontends/amiga/plugin_hack.c @@ -82,7 +82,8 @@ nserror amiga_plugin_hack_init(void) if(node) { - LOG("plugin_hack registered %s", lwc_string_data(type)); + NSLOG(netsurf, INFO, "plugin_hack registered %s", + lwc_string_data(type)); error = content_factory_register_handler( lwc_string_data(type), @@ -123,7 +124,7 @@ nserror amiga_plugin_hack_create(const content_handler *handler, bool amiga_plugin_hack_convert(struct content *c) { - LOG("amiga_plugin_hack_convert"); + NSLOG(netsurf, INFO, "amiga_plugin_hack_convert"); content_set_ready(c); content_set_done(c); @@ -137,7 +138,7 @@ void amiga_plugin_hack_destroy(struct content *c) { amiga_plugin_hack_content *plugin = (amiga_plugin_hack_content *) c; - LOG("amiga_plugin_hack_destroy %p", plugin); + NSLOG(netsurf, INFO, "amiga_plugin_hack_destroy %p", plugin); return; } @@ -155,7 +156,7 @@ bool amiga_plugin_hack_redraw(struct content *c, struct rect rect; nserror res; - LOG("amiga_plugin_hack_redraw"); + NSLOG(netsurf, INFO, "amiga_plugin_hack_redraw"); rect.x0 = data->x; rect.y0 = data->y; @@ -187,7 +188,8 @@ bool amiga_plugin_hack_redraw(struct content *c, void amiga_plugin_hack_open(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params) { - LOG("amiga_plugin_hack_open %s", nsurl_access(content_get_url(c))); + NSLOG(netsurf, INFO, "amiga_plugin_hack_open %s", + nsurl_access(content_get_url(c))); if(c) { @@ -201,13 +203,13 @@ void amiga_plugin_hack_open(struct content *c, struct browser_window *bw, void amiga_plugin_hack_close(struct content *c) { - LOG("amiga_plugin_hack_close"); + NSLOG(netsurf, INFO, "amiga_plugin_hack_close"); return; } void amiga_plugin_hack_reformat(struct content *c, int width, int height) { - LOG("amiga_plugin_hack_reformat"); + NSLOG(netsurf, INFO, "amiga_plugin_hack_reformat"); c->width = width; c->height = height; @@ -220,7 +222,7 @@ nserror amiga_plugin_hack_clone(const struct content *old, struct content **newc amiga_plugin_hack_content *plugin; nserror error; - LOG("amiga_plugin_hack_clone"); + NSLOG(netsurf, INFO, "amiga_plugin_hack_clone"); plugin = calloc(1, sizeof(amiga_plugin_hack_content)); if (plugin == NULL) @@ -267,7 +269,7 @@ void amiga_plugin_hack_execute(struct hlcache_handle *c) if(full_cmd) { #ifdef __amigaos4__ - LOG("Attempting to execute %s", full_cmd); + NSLOG(netsurf, INFO, "Attempting to execute %s", full_cmd); in = Open("NIL:", MODE_OLDFILE); out = Open("NIL:", MODE_NEWFILE); diff --git a/frontends/amiga/schedule.c b/frontends/amiga/schedule.c index bfafe9c88..30a36815c 100644 --- a/frontends/amiga/schedule.c +++ b/frontends/amiga/schedule.c @@ -218,9 +218,10 @@ static void ami_schedule_dump(void) GetSysTime(&tv); Amiga2Date(tv.Seconds, &clockdata); - LOG("Current time = %d-%d-%d %d:%d:%d.%d", clockdata.mday, clockdata.month, clockdata.year, - clockdata.hour, clockdata.min, clockdata.sec, tv.Microseconds); - LOG("Events remaining in queue:"); + NSLOG(netsurf, INFO, "Current time = %d-%d-%d %d:%d:%d.%d", + clockdata.mday, clockdata.month, clockdata.year, + clockdata.hour, clockdata.min, clockdata.sec, tv.Microseconds); + NSLOG(netsurf, INFO, "Events remaining in queue:"); iterator = pblHeapIterator(schedule_list); @@ -231,9 +232,9 @@ static void ami_schedule_dump(void) nscb, clockdata.mday, clockdata.month, clockdata.year, clockdata.hour, clockdata.min, clockdata.sec, nscb->tv.Microseconds, nscb->callback, nscb->p); if(CheckIO((struct IORequest *)nscb) == NULL) { - LOG("-> ACTIVE"); + NSLOG(netsurf, INFO, "-> ACTIVE"); } else { - LOG("-> COMPLETE"); + NSLOG(netsurf, INFO, "-> COMPLETE"); } }; diff --git a/frontends/amiga/selectmenu.c b/frontends/amiga/selectmenu.c index f3a11b67a..8a8614136 100644 --- a/frontends/amiga/selectmenu.c +++ b/frontends/amiga/selectmenu.c @@ -58,7 +58,8 @@ BOOL ami_selectmenu_is_safe(void) BOOL popupmenu_lib_ok = FALSE; if((PopupMenuBase = OpenLibrary("popupmenu.library", 53))) { - LOG("popupmenu.library v%d.%d", PopupMenuBase->lib_Version, PopupMenuBase->lib_Revision); + NSLOG(netsurf, INFO, "popupmenu.library v%d.%d", + PopupMenuBase->lib_Version, PopupMenuBase->lib_Revision); if(LIB_IS_AT_LEAST((struct Library *)PopupMenuBase, 53, 11)) popupmenu_lib_ok = TRUE; CloseLibrary(PopupMenuBase); diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c index eeb34108a..136b918fc 100644 --- a/frontends/amiga/sslcert.c +++ b/frontends/amiga/sslcert.c @@ -317,7 +317,7 @@ nserror ami_cert_verify(struct nsurl *url, res = ami_crtvrfy_create_window(ncwin); if (res != NSERROR_OK) { - LOG("SSL UI builder init failed"); + NSLOG(netsurf, INFO, "SSL UI builder init failed"); ami_utf8_free(ncwin->core.wintitle); ami_utf8_free(ncwin->sslerr); ami_utf8_free(ncwin->sslaccept); diff --git a/frontends/atari/bitmap.c b/frontends/atari/bitmap.c index cbb719586..ae42da837 100644 --- a/frontends/atari/bitmap.c +++ b/frontends/atari/bitmap.c @@ -81,7 +81,9 @@ static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, uns { struct bitmap * bitmap; - LOG("width %d (rowstride: %d, bpp: %d), height %d, state %u", w, rowstride, bpp, h, state); + NSLOG(netsurf, INFO, + "width %d (rowstride: %d, bpp: %d), height %d, state %u", w, + rowstride, bpp, h, state); if( rowstride == 0) { rowstride = bpp * w; @@ -107,10 +109,10 @@ static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, uns } else { free(bitmap); bitmap=NULL; - LOG("Out of memory!"); + NSLOG(netsurf, INFO, "Out of memory!"); } } - LOG("bitmap %p", bitmap); + NSLOG(netsurf, INFO, "bitmap %p", bitmap); return bitmap; } @@ -194,7 +196,7 @@ static unsigned char *bitmap_get_buffer(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return NULL; } @@ -218,7 +220,7 @@ size_t atari_bitmap_get_rowstride(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } return bm->rowstride; @@ -231,7 +233,7 @@ void atari_bitmap_destroy(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return; } @@ -272,11 +274,12 @@ static void bitmap_set_opaque(void *bitmap, bool opaque) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return; } - LOG("setting bitmap %p to %s", bm, opaque ? "opaque" : "transparent"); + NSLOG(netsurf, INFO, "setting bitmap %p to %s", bm, + opaque ? "opaque" : "transparent"); bm->opaque = opaque; } @@ -293,7 +296,7 @@ static bool bitmap_test_opaque(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return false; } @@ -305,11 +308,12 @@ static bool bitmap_test_opaque(void *bitmap) while (tst-- > 0) { if (bm->pixdata[(tst << 2) + 3] != 0xff) { - LOG("bitmap %p has transparency", bm); + NSLOG(netsurf, INFO, + "bitmap %p has transparency", bm); return false; } } - LOG("bitmap %p is opaque", bm); + NSLOG(netsurf, INFO, "bitmap %p is opaque", bm); return true; } @@ -320,7 +324,7 @@ bool atari_bitmap_get_opaque(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return false; } @@ -334,7 +338,7 @@ int atari_bitmap_get_width(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } @@ -348,7 +352,7 @@ int atari_bitmap_get_height(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } return(bm->height); diff --git a/frontends/atari/certview.c b/frontends/atari/certview.c index 6950d31f8..80d18a059 100644 --- a/frontends/atari/certview.c +++ b/frontends/atari/certview.c @@ -81,7 +81,7 @@ static nserror atari_sslcert_viewer_init_phase2(struct core_window *cw, assert(ssl_d); - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); return(sslcert_viewer_init(cb_t, cw, ssl_d)); } @@ -97,7 +97,7 @@ static void atari_sslcert_viewer_finish(struct core_window *cw) /* This will also free the session data: */ sslcert_viewer_fini(cvwin->ssl_session_data); - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); } static void atari_sslcert_viewer_draw(struct core_window *cw, int x, @@ -123,7 +123,7 @@ static void atari_sslcert_viewer_keypress(struct core_window *cw, uint32_t ucs4) cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw); - LOG("ucs4: %"PRIu32, ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); sslcert_viewer_keypress(cvwin->ssl_session_data, ucs4); } @@ -150,14 +150,14 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) short retval = 0; OBJECT *toolbar; - LOG("win %p", win); + NSLOG(netsurf, INFO, "win %p", win); if(ev_out->emo_events & MU_MESAG){ switch (msg[0]) { case WM_TOOLBAR: toolbar = gemtk_obj_get_tree(TOOLBAR_SSL_CERT); - LOG("CERTVIEWER WM_TOOLBAR"); + NSLOG(netsurf, INFO, "CERTVIEWER WM_TOOLBAR"); tv = (struct core_window*) gemtk_wm_get_user_data(win); assert(tv); cvwin = (struct atari_sslcert_viewer_s *) @@ -238,7 +238,7 @@ static void atari_sslcert_viewer_init(struct atari_sslcert_viewer_s * cvwin, if (cvwin->tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, "Failed to allocate treeview"); return; } @@ -280,7 +280,7 @@ static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin) assert(cvwin->init); assert(cvwin->window); - LOG("cvwin %p", cvwin); + NSLOG(netsurf, INFO, "cvwin %p", cvwin); if (atari_treeview_is_open(cvwin->tv)) atari_treeview_close(cvwin->tv); @@ -289,5 +289,5 @@ static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin) cvwin->window = NULL; atari_treeview_delete(cvwin->tv); free(cvwin); - LOG("done"); + NSLOG(netsurf, INFO, "done"); } diff --git a/frontends/atari/cookies.c b/frontends/atari/cookies.c index 9045009fc..df2de0d4c 100644 --- a/frontends/atari/cookies.c +++ b/frontends/atari/cookies.c @@ -63,7 +63,7 @@ static nserror atari_cookie_manager_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t) { - LOG("cw %p",cw); + NSLOG(netsurf, INFO, "cw %p", cw); return(cookie_manager_init(cb_t, cw)); } @@ -71,7 +71,7 @@ atari_cookie_manager_init_phase2(struct core_window *cw, static void atari_cookie_manager_finish(struct core_window *cw) { - LOG("cw %p",cw); + NSLOG(netsurf, INFO, "cw %p", cw); cookie_manager_fini(); } @@ -89,7 +89,7 @@ atari_cookie_manager_draw(struct core_window *cw, static void atari_cookie_manager_keypress(struct core_window *cw, uint32_t ucs4) { - LOG("ucs4: %"PRIu32, ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); cookie_manager_keypress(ucs4); } @@ -108,13 +108,13 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) { short retval = 0; - LOG("win %p", win); + NSLOG(netsurf, INFO, "win %p", win); if (ev_out->emo_events & MU_MESAG) { switch (msg[0]) { case WM_TOOLBAR: - LOG("WM_TOOLBAR"); + NSLOG(netsurf, INFO, "WM_TOOLBAR"); break; case WM_CLOSED: @@ -158,7 +158,8 @@ void atari_cookie_manager_init(void) if (atari_cookie_manager.tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, + "Failed to allocate treeview"); return; } @@ -209,7 +210,7 @@ void atari_cookie_manager_destroy(void) atari_treeview_delete(atari_cookie_manager.tv); atari_cookie_manager.init = false; } - LOG("done"); + NSLOG(netsurf, INFO, "done"); } diff --git a/frontends/atari/ctxmenu.c b/frontends/atari/ctxmenu.c index e25d8e522..ef4f01ae2 100644 --- a/frontends/atari/ctxmenu.c +++ b/frontends/atari/ctxmenu.c @@ -288,7 +288,9 @@ void context_popup(struct gui_window * gw, short x, short y) /* the GEMDOS cmdline contains the length of the commandline in the first byte: */ cmdline[0] = (unsigned char)strlen(tempfile); - LOG("Creating temporay source file: %s\n", tempfile); + NSLOG(netsurf, INFO, + "Creating temporay source file: %s\n", + tempfile); fp_tmpfile = fopen(tempfile, "w"); if (fp_tmpfile != NULL){ fwrite(data, size, 1, fp_tmpfile); @@ -306,7 +308,8 @@ void context_popup(struct gui_window * gw, short x, short y) } } else { - LOG("Invalid content!"); + NSLOG(netsurf, INFO, + "Invalid content!"); } } else { form_alert(0, "[1][Set option \"atari_editor\".][OK]"); diff --git a/frontends/atari/deskmenu.c b/frontends/atari/deskmenu.c index addba2764..32dfd7084 100644 --- a/frontends/atari/deskmenu.c +++ b/frontends/atari/deskmenu.c @@ -208,7 +208,7 @@ static void __CDECL menu_new_win(short item, short title, void *data) nserror error; const char *addr; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (nsoption_charp(homepage_url) != NULL) { addr = nsoption_charp(homepage_url); @@ -236,7 +236,7 @@ static void __CDECL menu_open_url(short item, short title, void *data) { struct gui_window * gw; struct browser_window * bw ; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); gw = input_window; if( gw == NULL ) { @@ -251,7 +251,7 @@ static void __CDECL menu_open_url(short item, short title, void *data) static void __CDECL menu_open_file(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); const char * filename = file_select(messages_get("OpenFile"), ""); if( filename != NULL ){ @@ -280,7 +280,7 @@ static void __CDECL menu_open_file(short item, short title, void *data) static void __CDECL menu_close_win(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; gui_window_destroy( input_window ); @@ -288,7 +288,7 @@ static void __CDECL menu_close_win(short item, short title, void *data) static void __CDECL menu_save_page(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); static bool init = true; bool is_folder=false; const char * path; @@ -319,7 +319,7 @@ static void __CDECL menu_quit(short item, short title, void *data) { short buff[8]; memset( &buff, 0, sizeof(short)*8 ); - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); gemtk_wm_send_msg(NULL, AP_TERM, 0, 0, 0, 0); } @@ -331,21 +331,21 @@ static void __CDECL menu_cut(short item, short title, void *data) static void __CDECL menu_copy(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window != NULL ) browser_window_key_press( input_window->browser->bw, NS_KEY_COPY_SELECTION); } static void __CDECL menu_paste(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window != NULL ) browser_window_key_press( input_window->browser->bw, NS_KEY_PASTE); } static void __CDECL menu_find(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (input_window != NULL) { if (input_window->search) { window_close_search(input_window->root); @@ -358,13 +358,13 @@ static void __CDECL menu_find(short item, short title, void *data) static void __CDECL menu_choices(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); open_settings(); } static void __CDECL menu_stop(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; @@ -378,7 +378,7 @@ static void __CDECL menu_reload(short item, short title, void *data) if(input_window == NULL) return; toolbar_reload_click(input_window->root->toolbar); - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); } @@ -408,7 +408,7 @@ static void __CDECL menu_dec_scale(short item, short title, void *data) static void __CDECL menu_toolbars(short item, short title, void *data) { static int state = 0; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window != null && input_window->root->toolbar != null ){ state = !state; // TODO: implement toolbar hide @@ -418,7 +418,7 @@ static void __CDECL menu_toolbars(short item, short title, void *data) static void __CDECL menu_savewin(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (input_window && input_window->browser) { GRECT rect; wind_get_grect(gemtk_wm_get_handle(input_window->root->win), WF_CURRXYWH, @@ -438,7 +438,7 @@ static void __CDECL menu_savewin(short item, short title, void *data) static void __CDECL menu_debug_render(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); html_redraw_debug = !html_redraw_debug; if( input_window != NULL ) { if ( input_window->browser != NULL @@ -469,7 +469,7 @@ static void __CDECL menu_bg_images(short item, short title, void *data) static void __CDECL menu_back(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; toolbar_back_click(input_window->root->toolbar); @@ -477,7 +477,7 @@ static void __CDECL menu_back(short item, short title, void *data) static void __CDECL menu_forward(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; toolbar_forward_click(input_window->root->toolbar); @@ -485,7 +485,7 @@ static void __CDECL menu_forward(short item, short title, void *data) static void __CDECL menu_home(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; toolbar_home_click(input_window->root->toolbar); @@ -493,20 +493,20 @@ static void __CDECL menu_home(short item, short title, void *data) static void __CDECL menu_lhistory(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; } static void __CDECL menu_ghistory(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); atari_global_history_open(); } static void __CDECL menu_add_bookmark(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (input_window) { if( browser_window_has_content(input_window->browser->bw) ){ atari_hotlist_add_page( @@ -519,26 +519,26 @@ static void __CDECL menu_add_bookmark(short item, short title, void *data) static void __CDECL menu_bookmarks(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); atari_hotlist_open(); } static void __CDECL menu_cookies(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); atari_cookie_manager_open(); } static void __CDECL menu_vlog(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); verbose_log = !verbose_log; menu_icheck(h_gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0); } static void __CDECL menu_help_content(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); } /* @@ -580,14 +580,16 @@ static void register_menu_str( struct s_menu_item_evnt * mi ) while (i > 2) { if ((strncmp(" ", &str[i], 2) == 0) && (strlen(&str[i]) > 2)) { // "Standard" Keyboard Shortcut Element found: - LOG("Standard Keyboard Shortcut: \"%s\"\n", &str[i]); + NSLOG(netsurf, INFO, + "Standard Keyboard Shortcut: \"%s\"\n", &str[i]); x = i+2; is_std_shortcut = true; break; } if( str[i] == '['){ - LOG("Keyboard Shortcut: \"%s\"\n", &str[i]); + NSLOG(netsurf, INFO, "Keyboard Shortcut: \"%s\"\n", + &str[i]); // "Custom" Keyboard Shortcut Element found (identified by [): x = i; break; @@ -662,8 +664,12 @@ static void register_menu_str( struct s_menu_item_evnt * mi ) } } - LOG("Registered keyboard shortcut for \"%s\" => mod: %d, ""keycode: %ld, ascii: %c\n", - str, accel->mod, accel->keycode, accel->ascii); + NSLOG(netsurf, INFO, + "Registered keyboard shortcut for \"%s\" => mod: %d, ""keycode: %ld, ascii: %c\n", + str, + accel->mod, + accel->keycode, + accel->ascii); } } diff --git a/frontends/atari/download.c b/frontends/atari/download.c index d756e6694..7a1c7d2b7 100644 --- a/frontends/atari/download.c +++ b/frontends/atari/download.c @@ -194,7 +194,7 @@ static void on_close(struct gui_download_window * dw) static void gui_download_window_destroy( struct gui_download_window * gdw) { - LOG("gdw %p", gdw); + NSLOG(netsurf, INFO, "gdw %p", gdw); if (gdw->status == NSATARI_DOWNLOAD_WORKING) { download_context_abort(gdw->ctx); @@ -253,7 +253,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent) char alert[200]; - LOG("Creating download window for gui window: %p", parent); + NSLOG(netsurf, INFO, "Creating download window for gui window: %p", + parent); /* TODO: Implement real form and use messages file strings! */ @@ -330,7 +331,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent) gemtk_wm_set_toolbar_redraw_func(gdw->guiwin, toolbar_redraw_cb); strncpy((char*)&gdw->lbl_file, filename, MAX_SLEN_LBL_FILE-1); - LOG("created download: %s (total size: %d)", gdw->destination, gdw->size_total); + NSLOG(netsurf, INFO, "created download: %s (total size: %d)", + gdw->destination, gdw->size_total); GRECT work, curr; work.g_x = 0; @@ -357,7 +359,7 @@ static nserror gui_download_window_data(struct gui_download_window *dw, uint32_t tnow = clck / (CLOCKS_PER_SEC>>3); uint32_t sdiff = (clck / (CLOCKS_PER_SEC)) - dw->start; - LOG("dw %p",dw); + NSLOG(netsurf, INFO, "dw %p", dw); if (dw->abort == true){ dw->status = NSATARI_DOWNLOAD_CANCELED; @@ -405,7 +407,7 @@ static nserror gui_download_window_data(struct gui_download_window *dw, static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { - LOG("%s", error_msg); + NSLOG(netsurf, INFO, "%s", error_msg); strncpy((char*)&dw->lbl_file, error_msg, MAX_SLEN_LBL_FILE-1); dw->status = NSATARI_DOWNLOAD_ERROR; @@ -416,7 +418,7 @@ static void gui_download_window_error(struct gui_download_window *dw, static void gui_download_window_done(struct gui_download_window *dw) { - LOG("dw %p", dw); + NSLOG(netsurf, INFO, "dw %p", dw); // TODO: change abort to close dw->status = NSATARI_DOWNLOAD_COMPLETE; diff --git a/frontends/atari/filetype.c b/frontends/atari/filetype.c index d27076e9c..706347137 100644 --- a/frontends/atari/filetype.c +++ b/frontends/atari/filetype.c @@ -36,7 +36,7 @@ const char *fetch_filetype(const char *unix_path) char * res = (char*)"text/html"; l = strlen(unix_path); - LOG("unix path: %s", unix_path); + NSLOG(netsurf, INFO, "unix path: %s", unix_path); /* This line is added for devlopment versions running from the root dir: */ if( strchr( unix_path, (int)'.' ) ){ @@ -85,6 +85,6 @@ const char *fetch_filetype(const char *unix_path) } } - LOG("mime type: %s", res); + NSLOG(netsurf, INFO, "mime type: %s", res); return( res ); } diff --git a/frontends/atari/findfile.c b/frontends/atari/findfile.c index 45ca6d916..8784727bc 100644 --- a/frontends/atari/findfile.c +++ b/frontends/atari/findfile.c @@ -31,7 +31,7 @@ char * local_file_to_url( const char * filename ) #define BACKSLASH 0x5C char * url; - LOG("in: %s", filename); + NSLOG(netsurf, INFO, "in: %s", filename); if( strlen(filename) <= 2){ return( NULL ); @@ -55,7 +55,7 @@ char * local_file_to_url( const char * filename ) free(fname_local); - LOG("out: %s", url); + NSLOG(netsurf, INFO, "out: %s", url); return( url ); #undef BACKSLASH @@ -81,10 +81,10 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) { char *cdir = NULL; char t[PATH_MAX]; - LOG("%s (def: %s)", filename, def); + NSLOG(netsurf, INFO, "%s (def: %s)", filename, def); strcpy(t, NETSURF_GEM_RESPATH); strcat(t, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) != NULL) { if (access(buf, R_OK) == 0) { return buf; @@ -92,7 +92,7 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) } strcpy(t, "./"); strcat(t, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) != NULL) { if (access(buf, R_OK) == 0) { return buf; @@ -104,7 +104,7 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) strcpy(t, cdir); strcat(t, "/.netsurf/"); strcat(t, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) != NULL) { if (access(buf, R_OK) == 0) return buf; @@ -116,19 +116,19 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) if (gemdos_realpath(cdir, buf) != NULL) { strcat(buf, "/"); strcat(buf, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (access(buf, R_OK) == 0) return buf; } } if (def[0] == '~') { snprintf(t, PATH_MAX, "%s%s", getenv("HOME"), def + 1); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) == NULL) { strcpy(buf, t); } } else { - LOG("checking %s", (char *)def); + NSLOG(netsurf, INFO, "checking %s", (char *)def); if (gemdos_realpath(def, buf) == NULL) { strcpy(buf, def); } diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c index 4876d3106..a400285d3 100644 --- a/frontends/atari/gui.c +++ b/frontends/atari/gui.c @@ -139,11 +139,11 @@ static void atari_poll(void) evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out); if(gemtk_wm_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out) == 0) { if( (aes_event_out.emo_events & MU_MESAG) != 0 ) { - LOG("WM: %d\n", aes_msg_out[0]); + NSLOG(netsurf, INFO, "WM: %d\n", aes_msg_out[0]); switch(aes_msg_out[0]) { case MN_SELECTED: - LOG("Menu Item: %d\n", aes_msg_out[4]); + NSLOG(netsurf, INFO, "Menu Item: %d\n", aes_msg_out[4]); deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]); break; @@ -195,13 +195,14 @@ gui_window_create(struct browser_window *bw, gui_window_create_flags flags) { struct gui_window *gw=NULL; - LOG("gw: %p, BW: %p, existing %p, flags: %d\n", gw, bw, existing, (int)flags); + NSLOG(netsurf, INFO, "gw: %p, BW: %p, existing %p, flags: %d\n", gw, bw, + existing, (int)flags); gw = calloc(1, sizeof(struct gui_window)); if (gw == NULL) return NULL; - LOG("new window: %p, bw: %p\n", gw, bw); + NSLOG(netsurf, INFO, "new window: %p, bw: %p\n", gw, bw); window_create(gw, bw, existing, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\ |WIDGET_SCROLL); if (gw->root->win) { @@ -253,7 +254,7 @@ void gui_window_destroy(struct gui_window *gw) if (gw == NULL) return; - LOG("%s\n", __FUNCTION__); + NSLOG(netsurf, INFO, "%s\n", __FUNCTION__); if (input_window == gw) { gui_set_input_gui_window(NULL); @@ -444,7 +445,8 @@ gui_window_set_scroll(struct gui_window *gw, const struct rect *rect) return NSERROR_BAD_PARAMETER; } - LOG("scroll (gui_window: %p) %d, %d\n", gw, rect->x0, rect->y0); + NSLOG(netsurf, INFO, "scroll (gui_window: %p) %d, %d\n", gw, rect->x0, + rect->y0); window_scroll_by(gw->root, rect->x0, rect->y0); return NSERROR_OK; @@ -771,7 +773,8 @@ static void gui_401login_open(nsurl *url, const char *realm, char * out = NULL; bres = login_form_do( url, (char*)realm, &out); if (bres) { - LOG("url: %s, realm: %s, auth: %s\n", nsurl_access(url), realm, out); + NSLOG(netsurf, INFO, "url: %s, realm: %s, auth: %s\n", + nsurl_access(url), realm, out); urldb_set_auth_details(url, realm, out); } if (out != NULL) { @@ -789,7 +792,7 @@ gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, void *cbpw) { struct sslcert_session_data *data; - LOG("url %s", nsurl_access(url)); + NSLOG(netsurf, INFO, "url %s", nsurl_access(url)); // TODO: localize string int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort|Details...]"); @@ -812,7 +815,8 @@ gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, void gui_set_input_gui_window(struct gui_window *gw) { - LOG("Setting input window from: %p to %p\n", input_window, gw); + NSLOG(netsurf, INFO, "Setting input window from: %p to %p\n", + input_window, gw); input_window = gw; } @@ -823,7 +827,7 @@ struct gui_window * gui_get_input_window(void) static void gui_quit(void) { - LOG("quitting"); + NSLOG(netsurf, INFO, "quitting"); struct gui_window *gw = window_list; struct gui_window *tmp = window_list; @@ -852,9 +856,9 @@ static void gui_quit(void) rsrc_free(); - LOG("Shutting down plotter"); + NSLOG(netsurf, INFO, "Shutting down plotter"); plot_finalise(); - LOG("done"); + NSLOG(netsurf, INFO, "done"); } /** @@ -866,7 +870,7 @@ process_cmdline(int argc, char** argv) int opt; bool set_default_dimensions = true; - LOG("argc %d, argv %p", argc, argv); + NSLOG(netsurf, INFO, "argc %d, argv %p", argc, argv); if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) { @@ -959,7 +963,7 @@ static nserror set_defaults(struct nsoption_s *defaults) /* Set defaults for absent option strings */ nsoption_setnull_charp(cookie_file, strdup("cookies")); if (nsoption_charp(cookie_file) == NULL) { - LOG("Failed initialising string options"); + NSLOG(netsurf, INFO, "Failed initialising string options"); return NSERROR_BAD_PARAMETER; } return NSERROR_OK; @@ -976,7 +980,7 @@ static void gui_init(int argc, char** argv) OBJECT * cursors; atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc"); - LOG("Using RSC file: %s ", (char *)&buf); + NSLOG(netsurf, INFO, "Using RSC file: %s ", (char *)&buf); if (rsrc_load(buf)==0) { char msg[1024]; @@ -1012,15 +1016,16 @@ static void gui_init(int argc, char** argv) create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_HELP, cursors, &gem_cursors.help); - LOG("Enabling core select menu"); + NSLOG(netsurf, INFO, "Enabling core select menu"); nsoption_set_bool(core_select_menu, true); - LOG("Loading url.db from: %s", nsoption_charp(url_file)); + NSLOG(netsurf, INFO, "Loading url.db from: %s", nsoption_charp(url_file)); if( strlen(nsoption_charp(url_file)) ) { urldb_load(nsoption_charp(url_file)); } - LOG("Loading cookies from: %s", nsoption_charp(cookie_file)); + NSLOG(netsurf, INFO, "Loading cookies from: %s", + nsoption_charp(cookie_file)); if( strlen(nsoption_charp(cookie_file)) ) { urldb_load_cookies(nsoption_charp(cookie_file)); } @@ -1028,10 +1033,10 @@ static void gui_init(int argc, char** argv) if (process_cmdline(argc,argv) != true) die("unable to process command line.\n"); - LOG("Initializing NKC..."); + NSLOG(netsurf, INFO, "Initializing NKC..."); nkc_init(); - LOG("Initializing plotters..."); + NSLOG(netsurf, INFO, "Initializing plotters..."); struct redraw_context ctx = { .interactive = true, .background_images = true, @@ -1172,18 +1177,18 @@ int main(int argc, char** argv) ret = messages_add_from_file(messages); /* common initialisation */ - LOG("Initialising core..."); + NSLOG(netsurf, INFO, "Initialising core..."); ret = netsurf_init(store); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); } - LOG("Initializing GUI..."); + NSLOG(netsurf, INFO, "Initializing GUI..."); gui_init(argc, argv); graf_mouse( ARROW , NULL); - LOG("Creating initial browser window..."); + NSLOG(netsurf, INFO, "Creating initial browser window..."); addr = option_homepage_url; if (strncmp(addr, "file://", 7) && strncmp(addr, "http://", 7)) { if (stat(addr, &stat_buf) == 0) { @@ -1205,7 +1210,7 @@ int main(int argc, char** argv) if (ret != NSERROR_OK) { atari_warn_user(messages_get_errorcode(ret), 0); } else { - LOG("Entering Atari event mainloop..."); + NSLOG(netsurf, INFO, "Entering Atari event mainloop..."); while (!atari_quit) { atari_poll(); } @@ -1219,7 +1224,7 @@ int main(int argc, char** argv) fclose(stdout); fclose(stderr); #endif - LOG("exit_gem"); + NSLOG(netsurf, INFO, "exit_gem"); exit_gem(); return 0; diff --git a/frontends/atari/history.c b/frontends/atari/history.c index 56aafd056..ec602684f 100644 --- a/frontends/atari/history.c +++ b/frontends/atari/history.c @@ -39,13 +39,13 @@ static nserror atari_global_history_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t) { - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); return(global_history_init(cb_t, cw)); } static void atari_global_history_finish(struct core_window *cw) { - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); global_history_fini(); } @@ -58,7 +58,7 @@ static void atari_global_history_draw(struct core_window *cw, int x, static void atari_global_history_keypress(struct core_window *cw, uint32_t ucs4) { - LOG("ucs4: %"PRIu32, ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); global_history_keypress(ucs4); } @@ -67,7 +67,7 @@ atari_global_history_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y) { - LOG("x: %d, y: %d\n", x, y); + NSLOG(netsurf, INFO, "x: %d, y: %d\n", x, y); global_history_mouse_action(mouse, x, y); } @@ -82,7 +82,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) { short retval = 0; - LOG("win %p", win); + NSLOG(netsurf, INFO, "win %p", win); if (ev_out->emo_events & MU_MESAG) { switch (msg[0]) { @@ -134,7 +134,8 @@ void atari_global_history_init(void) if (atari_global_history.tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, + "Failed to allocate treeview"); return; } } @@ -181,7 +182,7 @@ void atari_global_history_destroy(void) atari_treeview_delete(atari_global_history.tv); atari_global_history.init = false; } - LOG("done"); + NSLOG(netsurf, INFO, "done"); } void atari_global_history_redraw(void) diff --git a/frontends/atari/hotlist.c b/frontends/atari/hotlist.c index 659b3a562..3a54c98eb 100644 --- a/frontends/atari/hotlist.c +++ b/frontends/atari/hotlist.c @@ -72,13 +72,13 @@ static struct atari_treeview_callbacks atari_hotlist_treeview_callbacks = { static nserror atari_hotlist_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t) { - LOG("cw:%p", cw); + NSLOG(netsurf, INFO, "cw:%p", cw); return hotlist_manager_init(cb_t, cw); } static void atari_hotlist_finish(struct core_window *cw) { - LOG("cw:%p", cw); + NSLOG(netsurf, INFO, "cw:%p", cw); hotlist_fini(); } @@ -93,7 +93,7 @@ static void atari_hotlist_keypress(struct core_window *cw, uint32_t ucs4) { //GUIWIN *gemtk_win; //GRECT area; - LOG("ucs4: %"PRIu32 , ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); hotlist_keypress(ucs4); //gemtk_win = atari_treeview_get_gemtk_window(cw); //atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &area); @@ -104,7 +104,7 @@ static void atari_hotlist_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y) { - LOG("x: %d, y: %d\n", x, y); + NSLOG(netsurf, INFO, "x: %d, y: %d\n", x, y); hotlist_mouse_action(mouse, x, y); } @@ -123,7 +123,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) GRECT tb_area; GUIWIN * gemtk_win; - LOG("gw:%p", win); + NSLOG(netsurf, INFO, "gw:%p", win); tv = (struct atari_treeview_window*) gemtk_wm_get_user_data(win); cw = (struct core_window *)tv; @@ -132,7 +132,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) switch (msg[0]) { case WM_TOOLBAR: - LOG("WM_TOOLBAR"); + NSLOG(netsurf, INFO, "WM_TOOLBAR"); toolbar = gemtk_obj_get_tree(TOOLBAR_HOTLIST); @@ -198,7 +198,7 @@ void atari_hotlist_init(void) strncpy( (char*)&hl.path, nsoption_charp(hotlist_file), PATH_MAX-1 ); } - LOG("Hotlist: %s", (char *)&hl.path); + NSLOG(netsurf, INFO, "Hotlist: %s", (char *)&hl.path); hotlist_init(hl.path, hl.path); if( hl.window == NULL ){ @@ -224,7 +224,8 @@ void atari_hotlist_init(void) if (hl.tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, + "Failed to allocate treeview"); return; } @@ -276,7 +277,7 @@ void atari_hotlist_destroy(void) atari_treeview_delete(hl.tv); hl.init = false; } - LOG("done"); + NSLOG(netsurf, INFO, "done"); } void atari_hotlist_redraw(void) @@ -299,7 +300,7 @@ void atari_hotlist_add_page( const char * url, const char * title ) return; if (hotlist_has_url(nsurl)) { - LOG("URL already added as Bookmark"); + NSLOG(netsurf, INFO, "URL already added as Bookmark"); nsurl_unref(nsurl); return; } diff --git a/frontends/atari/osspec.c b/frontends/atari/osspec.c index f64402e8d..ca042f164 100644 --- a/frontends/atari/osspec.c +++ b/frontends/atari/osspec.c @@ -119,14 +119,14 @@ char *gemdos_realpath(const char * path, char * rpath) return(rpath); } - LOG("realpath in: %s\n", path); + NSLOG(netsurf, INFO, "realpath in: %s\n", path); r = realpath(path, work); if (r != NULL) { unx2dos((const char *)r, rpath); - LOG("realpath out: %s\n", rpath); + NSLOG(netsurf, INFO, "realpath out: %s\n", rpath); return(rpath); } else { - LOG("realpath out: NULL!\n"); + NSLOG(netsurf, INFO, "realpath out: NULL!\n"); } return (NULL); } diff --git a/frontends/atari/plot/font_freetype.c b/frontends/atari/plot/font_freetype.c index 17d3c3bfd..1688e978b 100644 --- a/frontends/atari/plot/font_freetype.c +++ b/frontends/atari/plot/font_freetype.c @@ -154,11 +154,12 @@ static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Po error = FT_New_Face(library, ft_face->fontfile, ft_face->index, face); if (error) { - LOG("Could not find font (code %d)\n", error); + NSLOG(netsurf, INFO, "Could not find font (code %d)\n", error); } else { error = FT_Select_Charmap(*face, FT_ENCODING_UNICODE); if (error) { - LOG("Could not select charmap (code %d)\n", error); + NSLOG(netsurf, INFO, + "Could not select charmap (code %d)\n", error); } else { for (cidx = 0; cidx < (*face)->num_charmaps; cidx++) { if ((*face)->charmap == (*face)->charmaps[cidx]) { @@ -168,7 +169,7 @@ static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Po } } } - LOG("Loaded face from %s\n", ft_face->fontfile); + NSLOG(netsurf, INFO, "Loaded face from %s\n", ft_face->fontfile); return error; } @@ -190,7 +191,9 @@ ft_new_face(const char *option, const char *resname, const char *fontfile) } error = FTC_Manager_LookupFace(ft_cmanager, (FTC_FaceID)newf, &aface); if (error) { - LOG("Could not find font face %s (code %d)\n", fontfile, error); + NSLOG(netsurf, INFO, + "Could not find font face %s (code %d)\n", fontfile, + error); free(newf); newf = font_faces[FONT_FACE_DEFAULT]; /* use default */ } @@ -292,7 +295,8 @@ static bool ft_font_init(void) /* freetype library initialise */ error = FT_Init_FreeType( &library ); if (error) { - LOG("Freetype could not initialised (code %d)\n", error); + NSLOG(netsurf, INFO, + "Freetype could not initialised (code %d)\n", error); return false; } @@ -311,7 +315,9 @@ static bool ft_font_init(void) NULL, &ft_cmanager); if (error) { - LOG("Freetype could not initialise cache manager (code %d)\n", error); + NSLOG(netsurf, INFO, + "Freetype could not initialise cache manager (code %d)\n", + error); FT_Done_FreeType(library); return false; } @@ -330,7 +336,8 @@ static bool ft_font_init(void) FONT_PKG_PATH FONT_FILE_SANS ); if (font_faces[FONT_FACE_SANS_SERIF] == NULL) { - LOG("Could not find default font (code %d)\n", error); + NSLOG(netsurf, INFO, + "Could not find default font (code %d)\n", error); FTC_Manager_Done(ft_cmanager); FT_Done_FreeType(library); return false; @@ -688,7 +695,7 @@ int ctor_font_plotter_freetype( FONT_PLOTTER self ) self->draw_glyph = draw_glyph8; } - LOG("%s: %s\n", (char *)__FILE__, __FUNCTION__); + NSLOG(netsurf, INFO, "%s: %s\n", (char *)__FILE__, __FUNCTION__); if( !init ) { ft_font_init(); fontbmp = atari_bitmap_create(48, 48, 0); diff --git a/frontends/atari/plot/font_internal.c b/frontends/atari/plot/font_internal.c index 3575bc3e1..709697f74 100644 --- a/frontends/atari/plot/font_internal.c +++ b/frontends/atari/plot/font_internal.c @@ -96,7 +96,7 @@ int ctor_font_plotter_internal( FONT_PLOTTER self ) self->str_split = str_split; self->pixel_pos = pixel_pos; self->text = text; - LOG("%s: %s\n", (char *)__FILE__, __FUNCTION__); + NSLOG(netsurf, INFO, "%s: %s\n", (char *)__FILE__, __FUNCTION__); if( !init ) { vdih = self->vdi_handle; fontbmp = atari_bitmap_create(48, 48, 0); diff --git a/frontends/atari/plot/font_vdi.c b/frontends/atari/plot/font_vdi.c index ef5499207..7cd82ddc9 100644 --- a/frontends/atari/plot/font_vdi.c +++ b/frontends/atari/plot/font_vdi.c @@ -70,7 +70,7 @@ int ctor_font_plotter_vdi( FONT_PLOTTER self ) self->str_split = str_split; self->pixel_pos = pixel_pos; self->text = text; - LOG("%s: %s\n", (char *)__FILE__, __FUNCTION__); + NSLOG(netsurf, INFO, "%s: %s\n", (char *)__FILE__, __FUNCTION__); if( !init ) { vdih = self->vdi_handle; } diff --git a/frontends/atari/plot/plot.c b/frontends/atari/plot/plot.c index 2324f82d9..14c670352 100644 --- a/frontends/atari/plot/plot.c +++ b/frontends/atari/plot/plot.c @@ -1628,7 +1628,7 @@ int plot_init(const struct redraw_context *ctx, char *fdrvrname) short work_out[57]; atari_plot_vdi_handle=graf_handle(&dummy, &dummy, &dummy, &dummy); v_opnvwk(work_in, &atari_plot_vdi_handle, work_out); - LOG("Plot VDI handle: %d", atari_plot_vdi_handle); + NSLOG(netsurf, INFO, "Plot VDI handle: %d", atari_plot_vdi_handle); } read_vdi_sysinfo(atari_plot_vdi_handle, &vdi_sysinfo); if(verbose_log) { @@ -1640,7 +1640,8 @@ int plot_init(const struct redraw_context *ctx, char *fdrvrname) atari_font_flags, &err); if (err) { const char * desc = plot_err_str(err); - LOG("Unable to load font plotter %s -> %s", fdrvrname, desc ); + NSLOG(netsurf, INFO, "Unable to load font plotter %s -> %s", + fdrvrname, desc); die("font plotter"); } diff --git a/frontends/atari/rootwin.c b/frontends/atari/rootwin.c index 0b77cbba5..6576eac77 100644 --- a/frontends/atari/rootwin.c +++ b/frontends/atari/rootwin.c @@ -105,7 +105,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) switch (msg[0]) { case WM_REDRAW: - LOG("WM_REDRAW"); + NSLOG(netsurf, INFO, "WM_REDRAW"); on_redraw(data->rootwin, msg); break; @@ -113,7 +113,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) case WM_SIZED: case WM_MOVED: case WM_FULLED: - LOG("WM_SIZED"); + NSLOG(netsurf, INFO, "WM_SIZED"); on_resized(data->rootwin); break; @@ -132,7 +132,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) case WM_TOPPED: case WM_NEWTOP: case WM_UNICONIFY: - LOG("WM_TOPPED"); + NSLOG(netsurf, INFO, "WM_TOPPED"); gui_set_input_gui_window(data->rootwin->active_gui_window); //window_restore_active_gui_window(data->rootwin); // TODO: use something like "restore_active_gui_window_state()" @@ -143,7 +143,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) // TODO: this needs to iterate through all gui windows and // check if the rootwin is this window... if (data->rootwin->active_gui_window != NULL) { - LOG("WM_CLOSED initiated destroy for bw %p", data->rootwin->active_gui_window->browser->bw); + NSLOG(netsurf, INFO, "WM_CLOSED initiated destroy for bw %p", + data->rootwin->active_gui_window->browser->bw); browser_window_destroy( data->rootwin->active_gui_window->browser->bw); } @@ -166,13 +167,16 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) // handle key uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta, (short)ev_out->emo_kreturn); - LOG("rootwin MU_KEYBD input, nkc: %x\n", nkc); + NSLOG(netsurf, INFO, "rootwin MU_KEYBD input, nkc: %x\n", nkc); retval = on_window_key_input(data->rootwin, nkc); // printf("on_window_key_input: %d\n", retval); } if ((ev_out->emo_events & MU_BUTTON) != 0) { - LOG("rootwin MU_BUTTON input, x: %d, y: %d\n", ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_x); + NSLOG(netsurf, INFO, + "rootwin MU_BUTTON input, x: %d, y: %d\n", + ev_out->emo_mouse.p_x, + ev_out->emo_mouse.p_x); window_get_grect(data->rootwin, BROWSER_AREA_CONTENT, &area); if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y, @@ -312,13 +316,13 @@ void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw) struct gui_window *w; input_window = NULL; - LOG("window: %p, gui_window: %p", rootwin, gw); + NSLOG(netsurf, INFO, "window: %p, gui_window: %p", rootwin, gw); w = window_list; // find the next active tab: while( w != NULL ) { if(w->root == rootwin && w != gw) { - LOG("activating next tab %p", w); + NSLOG(netsurf, INFO, "activating next tab %p", w); gui_set_input_gui_window(w); break; } @@ -338,7 +342,7 @@ int window_destroy(ROOTWIN *rootwin) assert(rootwin != NULL); - LOG("%p", rootwin); + NSLOG(netsurf, INFO, "%p", rootwin); if (gemtk_wm_get_user_data(rootwin->win) != NULL) { free(gemtk_wm_get_user_data(rootwin->win)); @@ -404,7 +408,7 @@ void window_restore_active_gui_window(ROOTWIN *rootwin) GRECT tb_area; struct gui_window *gw; - LOG("rootwin %p", rootwin); + NSLOG(netsurf, INFO, "rootwin %p", rootwin); assert(rootwin->active_gui_window); @@ -499,7 +503,7 @@ void window_set_focus(struct s_gui_win_root *rootwin, assert(rootwin != NULL); if (rootwin->focus.type != type || rootwin->focus.element != element) { - LOG("Set focus: %p (%d)\n", element, type); + NSLOG(netsurf, INFO, "Set focus: %p (%d)\n", element, type); rootwin->focus.type = type; rootwin->focus.element = element; switch( type ) { @@ -563,11 +567,11 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw) { struct gui_window *old_gw = rootwin->active_gui_window; - LOG("gw %p",gw); + NSLOG(netsurf, INFO, "gw %p", gw); if (rootwin->active_gui_window != NULL) { if(rootwin->active_gui_window == gw) { - LOG("nothing to do..."); + NSLOG(netsurf, INFO, "nothing to do..."); return; } } @@ -576,7 +580,7 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw) rootwin->active_gui_window = gw; if (old_gw != NULL) { - LOG("restoring window..."); + NSLOG(netsurf, INFO, "restoring window..."); window_restore_active_gui_window(rootwin); } } @@ -651,7 +655,7 @@ void window_open_search(ROOTWIN *rootwin, bool reformat) GRECT area; OBJECT *obj; - LOG("rootwin %p", rootwin); + NSLOG(netsurf, INFO, "rootwin %p", rootwin); gw = rootwin->active_gui_window; bw = gw->browser->bw; @@ -1478,7 +1482,13 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8]) buff[size] = 0; - LOG("file: %s, ext: %s, size: %ld dropped at: %d,%d\n", (char *)buff, (char *)&ext, size, mx, my); + NSLOG(netsurf, INFO, + "file: %s, ext: %s, size: %ld dropped at: %d,%d\n", + (char *)buff, + (char *)&ext, + size, + mx, + my); gui_window_get_scroll(gw, &sx, &sy); @@ -1500,7 +1510,8 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8]) if (ret != NSERROR_OK) { free(buff); /* A bad encoding should never happen */ - LOG("utf8_from_local_encoding failed"); + NSLOG(netsurf, INFO, + "utf8_from_local_encoding failed"); assert(ret != NSERROR_BAD_ENCODING); /* no memory */ goto error; diff --git a/frontends/atari/schedule.c b/frontends/atari/schedule.c index 48980426d..a8d06e499 100644 --- a/frontends/atari/schedule.c +++ b/frontends/atari/schedule.c @@ -71,7 +71,7 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) return NSERROR_OK; } - LOG("removing %p, %p", callback, p); + NSLOG(netsurf, INFO, "removing %p, %p", callback, p); cur_nscb = schedule_list; prev_nscb = NULL; @@ -80,7 +80,9 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) if ((cur_nscb->callback == callback) && (cur_nscb->p == p)) { /* item to remove */ - LOG("callback entry %p removing %p(%p)", cur_nscb, cur_nscb->callback, cur_nscb->p); + NSLOG(netsurf, INFO, + "callback entry %p removing %p(%p)", cur_nscb, + cur_nscb->callback, cur_nscb->p); /* remove callback */ unlnk_nscb = cur_nscb; @@ -118,7 +120,8 @@ nserror atari_schedule(int ival, void (*callback)(void *p), void *p) nscb->timeout = MS_NOW() + ival; - LOG("adding callback %p for %p(%p) at %d ms", nscb, callback, p, nscb->timeout); + NSLOG(netsurf, INFO, "adding callback %p for %p(%p) at %d ms", nscb, + callback, p, nscb->timeout); nscb->callback = callback; nscb->p = p; @@ -164,7 +167,9 @@ int schedule_run(void) prev_nscb->next = unlnk_nscb->next; } - LOG("callback entry %p running %p(%p)", unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p); + NSLOG(netsurf, INFO, + "callback entry %p running %p(%p)", unlnk_nscb, + unlnk_nscb->callback, unlnk_nscb->p); /* call callback */ unlnk_nscb->callback(unlnk_nscb->p); @@ -173,7 +178,7 @@ int schedule_run(void) /* need to deal with callback modifying the list. */ if (schedule_list == NULL) { - LOG("schedule_list == NULL"); + NSLOG(netsurf, INFO, "schedule_list == NULL"); return -1; /* no more callbacks scheduled */ } @@ -198,7 +203,8 @@ int schedule_run(void) /* make rettime relative to now and convert to ms */ nexttime = nexttime - now; - LOG("returning time to next event as %ldms", nexttime); + NSLOG(netsurf, INFO, "returning time to next event as %ldms", + nexttime); /*return next event time in milliseconds (24days max wait) */ return nexttime; @@ -210,14 +216,15 @@ void list_schedule(void) { struct nscallback *cur_nscb; - LOG("schedule list at ms clock %ld", MS_NOW()); + NSLOG(netsurf, INFO, "schedule list at ms clock %ld", MS_NOW()); cur_nscb = schedule_list; while (cur_nscb != NULL) { - LOG("Schedule %p at %ld", cur_nscb, cur_nscb->timeout); + NSLOG(netsurf, INFO, "Schedule %p at %ld", cur_nscb, + cur_nscb->timeout); cur_nscb = cur_nscb->next; } - LOG("Maxmium callbacks scheduled: %d", max_scheduled); + NSLOG(netsurf, INFO, "Maxmium callbacks scheduled: %d", max_scheduled); } diff --git a/frontends/atari/search.c b/frontends/atari/search.c index 4da7f16a3..8df4ad676 100644 --- a/frontends/atari/search.c +++ b/frontends/atari/search.c @@ -67,7 +67,7 @@ struct gui_search_table *atari_search_table = &search_table; */ void nsatari_search_set_status(bool found, void *p) { - LOG("%p set status: %d\n", p, found); + NSLOG(netsurf, INFO, "%p set status: %d\n", p, found); // TODO: maybe update GUI } @@ -80,7 +80,7 @@ void nsatari_search_set_status(bool found, void *p) void nsatari_search_set_hourglass(bool active, void *p) { SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p; - LOG("active: %d, session: %p", active, p); + NSLOG(netsurf, INFO, "active: %d, session: %p", active, p); if (active) { gui_window_set_pointer(s->g, GUI_POINTER_PROGRESS); } else { @@ -99,7 +99,7 @@ void nsatari_search_set_hourglass(bool active, void *p) */ void nsatari_search_add_recent(const char *string, void *p) { - LOG("%p add recent: %s\n", p, string); + NSLOG(netsurf, INFO, "%p add recent: %s\n", p, string); } @@ -115,7 +115,7 @@ void nsatari_search_set_forward_state(bool active, void *p) GRECT area; SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p; /* deactivate back cb */ - LOG("%p: set forward state: %d\n", p, active); + NSLOG(netsurf, INFO, "%p: set forward state: %d\n", p, active); gw = s->g; @@ -142,7 +142,7 @@ void nsatari_search_set_back_state(bool active, void *p) GRECT area; SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p; /* deactivate back cb */ - LOG("%p: set back state: %d\n", p, active); + NSLOG(netsurf, INFO, "%p: set back state: %d\n", p, active); s->state.back_avail = active; gw = s->g; @@ -224,7 +224,7 @@ void nsatari_search_restore_form( struct s_search_form_session *s, OBJECT *obj) void nsatari_search_session_destroy(struct s_search_form_session *s) { if (s != NULL) { - LOG("session %p", s); + NSLOG(netsurf, INFO, "session %p", s); browser_window_search_clear(s->g->browser->bw); free(s); } diff --git a/frontends/atari/settings.c b/frontends/atari/settings.c index ed1fb2e45..ac4afa315 100644 --- a/frontends/atari/settings.c +++ b/frontends/atari/settings.c @@ -172,7 +172,7 @@ static char **read_locales(void) atari_warn_user("Failed to load locales: %s",buf); return(NULL); } else { - LOG("Reading locales from: %s...", buf); + NSLOG(netsurf, INFO, "Reading locales from: %s...", buf); } /* Count items: */ @@ -980,12 +980,12 @@ void open_settings(void) void close_settings(void) { - LOG("closing"); + NSLOG(netsurf, INFO, "closing"); gemtk_wm_remove(settings_guiwin); settings_guiwin = NULL; wind_close(h_aes_win); wind_delete(h_aes_win); h_aes_win = 0; - LOG("Done"); + NSLOG(netsurf, INFO, "Done"); } diff --git a/frontends/atari/statusbar.c b/frontends/atari/statusbar.c index 3a216f9a8..fe2008c82 100644 --- a/frontends/atari/statusbar.c +++ b/frontends/atari/statusbar.c @@ -166,7 +166,7 @@ CMP_STATUSBAR sb_create( struct gui_window * gw ) void sb_destroy( CMP_STATUSBAR s ) { - LOG("%s\n", __FUNCTION__); + NSLOG(netsurf, INFO, "%s\n", __FUNCTION__); if( s ) { if( s->comp ){ mt_CompDelete( &app, s->comp ); @@ -206,7 +206,7 @@ CMP_STATUSBAR sb_create( struct gui_window * gw ) void sb_destroy( CMP_STATUSBAR s ) { - LOG("%s\n", __FUNCTION__); + NSLOG(netsurf, INFO, "%s\n", __FUNCTION__); if( s ) { free( s ); } diff --git a/frontends/atari/toolbar.c b/frontends/atari/toolbar.c index 1b9371763..fdfedcbee 100644 --- a/frontends/atari/toolbar.c +++ b/frontends/atari/toolbar.c @@ -269,7 +269,7 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner) int i; struct s_toolbar *t; - LOG("owner %p", owner); + NSLOG(netsurf, INFO, "owner %p", owner); assert(init == true); @@ -327,8 +327,9 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner) t->throbber.max_index = THROBBER_MAX_INDEX; t->throbber.running = false; - LOG("created toolbar: %p, root: %p, textarea: %p, throbber: %p", - t, owner, t->url.textarea, &t->throbber); + NSLOG(netsurf, INFO, + "created toolbar: %p, root: %p, textarea: %p, throbber: %p", t, + owner, t->url.textarea, &t->throbber); return( t ); } @@ -458,7 +459,7 @@ toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw, short button) { - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); struct s_tb_button * bt; bool enable = false; @@ -582,7 +583,7 @@ void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area) void toolbar_set_url(struct s_toolbar *tb, const char *text) { - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); textarea_set_text(tb->url.textarea, text); @@ -668,7 +669,7 @@ bool toolbar_text_input(struct s_toolbar *tb, char *text) { bool handled = true; - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); return(handled); } @@ -757,7 +758,7 @@ void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button) short mx, my, mb, kstat; struct gui_window * gw; - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); if (obj==TOOLBAR_AREA_URL) { diff --git a/frontends/atari/treeview.c b/frontends/atari/treeview.c index abc1fa780..23db41309 100644 --- a/frontends/atari/treeview.c +++ b/frontends/atari/treeview.c @@ -362,8 +362,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) on_keybd_event(cw, ev_out, msg); } if ((ev_out->emo_events & MU_BUTTON) != 0 ) { - LOG("Treeview click at: %d,%d\n", - ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y); + NSLOG(netsurf, INFO, "Treeview click at: %d,%d\n", + ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y); on_mbutton_event(cw, ev_out, msg); } @@ -541,7 +541,7 @@ atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks, tv = calloc(1, sizeof(struct atari_treeview_window)); if (tv == NULL) { - LOG("calloc failed"); + NSLOG(netsurf, INFO, "calloc failed"); atari_warn_user(messages_get_errorcode(NSERROR_NOMEM), 0); return NULL; } diff --git a/frontends/atari/verify_ssl.c b/frontends/atari/verify_ssl.c index 33136eebd..b099fe488 100644 --- a/frontends/atari/verify_ssl.c +++ b/frontends/atari/verify_ssl.c @@ -80,7 +80,9 @@ static void __CDECL cert_info_draw( WINDOW * win, short buf[8], void * data) if( line == NULL ) return; - LOG("Cert info draw, win: %p, data: %p, scrollx: %d", win, data, dp->scrollx ); + NSLOG(netsurf, INFO, + "Cert info draw, win: %p, data: %p, scrollx: %d", win, data, + dp->scrollx); WindGet( win, WF_WORKXYWH, &x, &y, &w, &h ); /*using static values here, as RsrcUserDraw has mem leaks & a very small stack */ @@ -158,7 +160,7 @@ static void do_popup( WINDOW *win, int index, int mode, void *data) char * items[dp->num_certs]; short x, y; unsigned int i; - LOG("do_popup: num certs: %d", dp->num_certs); + NSLOG(netsurf, INFO, "do_popup: num certs: %d", dp->num_certs); for( i = 0; inum_certs; i++) { items[i] = malloc( 48 ); strncpy(items[i], (char*)&dp->cert_infos_n[i].issuer, 46 ); @@ -246,7 +248,7 @@ verify_ssl_form_do(const char * url, break; case VERIFY_BT_SCROLL_R: - LOG("scroll r!"); + NSLOG(netsurf, INFO, "scroll r!"); cont = true; dp.scrollx += 1; if( dp.scrollx > (dp.cols - (272 / 8 )) ) diff --git a/frontends/framebuffer/bitmap.c b/frontends/framebuffer/bitmap.c index 027e0122b..59f68bba5 100644 --- a/frontends/framebuffer/bitmap.c +++ b/frontends/framebuffer/bitmap.c @@ -51,7 +51,8 @@ static void *bitmap_create(int width, int height, unsigned int state) { nsfb_t *bm; - LOG("width %d, height %d, state %u", width, height, state); + NSLOG(netsurf, INFO, "width %d, height %d, state %u", width, height, + state); bm = nsfb_new(NSFB_SURFACE_RAM); if (bm == NULL) { @@ -69,7 +70,7 @@ static void *bitmap_create(int width, int height, unsigned int state) return NULL; } - LOG("bitmap %p", bm); + NSLOG(netsurf, INFO, "bitmap %p", bm); return bm; } @@ -197,11 +198,11 @@ static bool bitmap_test_opaque(void *bitmap) while (tst-- > 0) { if (bmpptr[(tst << 2) + 3] != 0xff) { - LOG("bitmap %p has transparency", bm); + NSLOG(netsurf, INFO, "bitmap %p has transparency", bm); return false; } } - LOG("bitmap %p is opaque", bm); + NSLOG(netsurf, INFO, "bitmap %p is opaque", bm); return true; } @@ -282,7 +283,7 @@ bitmap_render(struct bitmap *bitmap, nsfb_get_geometry(tbm, &width, &height, NULL); - LOG("width %d, height %d", width, height); + NSLOG(netsurf, INFO, "width %d, height %d", width, height); /* Calculate size of buffer to render the content into */ /* We get the width from the content width, unless it exceeds 1024, diff --git a/frontends/framebuffer/clipboard.c b/frontends/framebuffer/clipboard.c index 1254c36f3..20a00e038 100644 --- a/frontends/framebuffer/clipboard.c +++ b/frontends/framebuffer/clipboard.c @@ -53,8 +53,8 @@ static void gui_get_clipboard(char **buffer, size_t *length) if (gui_clipboard.length > 0) { assert(gui_clipboard.buffer != NULL); - LOG("Pasting %zd bytes: \"%s\"\n", - gui_clipboard.length, gui_clipboard.buffer); + NSLOG(netsurf, INFO, "Pasting %zd bytes: \"%s\"\n", + gui_clipboard.length, gui_clipboard.buffer); *buffer = malloc(gui_clipboard.length); diff --git a/frontends/framebuffer/convert_font.c b/frontends/framebuffer/convert_font.c index 010af857a..6d7c4d44e 100644 --- a/frontends/framebuffer/convert_font.c +++ b/frontends/framebuffer/convert_font.c @@ -278,7 +278,8 @@ bool generate_font_header(const char *path, struct font_data *data) fp = fopen(path, "wb"); if (fp == NULL) { - LOG(LOG_ERROR, "Couldn't open header file \"%s\"\n", path); + NSLOG(netsurf, INFO, LOG_ERROR, + "Couldn't open header file \"%s\"\n", path); return false; } @@ -315,7 +316,8 @@ bool generate_font_source(const char *path, struct font_data *data) fp = fopen(path, "wb"); if (fp == NULL) { - LOG(LOG_ERROR, "Couldn't open output file \"%s\"\n", path); + NSLOG(netsurf, INFO, LOG_ERROR, + "Couldn't open output file \"%s\"\n", path); return false; } @@ -413,14 +415,14 @@ static bool add_glyph_to_data(glyph_entry *add, int id, int style, d->e[d->glyphs++] = e; e->index = d->glyphs; if (d->glyphs >= 0xfffd) { - LOG(LOG_ERROR, " Too many glyphs for internal data " - "representation\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + " Too many glyphs for internal data ""representation\n"); return false; } } else { /* Duplicate glyph */ - LOG(LOG_DEBUG, " U+%.4X (%s) is duplicate\n", - id, short_labels[style]); + NSLOG(netsurf, INFO, LOG_DEBUG, + " U+%.4X (%s) is duplicate\n", id, short_labels[style]); } /* Find glyph's section */ @@ -432,8 +434,8 @@ static bool add_glyph_to_data(glyph_entry *add, int id, int style, size_t size = (d->sec_count[style] + 1) * SECTION_SIZE; uint16_t *temp = realloc(d->sections[style], size); if (temp == NULL) { - LOG(LOG_ERROR, " Couldn't increase sections " - "allocation\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + " Couldn't increase sections ""allocation\n"); return false; } memset(temp + d->sec_count[style] * 256, 0, @@ -456,47 +458,50 @@ static bool check_glyph_data_valid(int pos, char c) if (pos == 44) { if (c != '\n') { - LOG(LOG_ERROR, " Invalid glyph data: " - "expecting '\\n', got '%c' (%i)\n", - c, c); + NSLOG(netsurf, INFO, LOG_ERROR, + " Invalid glyph data: ""expecting '\\n', got '%c' (%i)\n", + c, + c); return false; } else { return true; } } else if (pos < 3) { if (c != ' ') { - LOG(LOG_ERROR, " Invalid glyph data: " - "expecting ' ', got '%c' (%i)\n", - c, c); + NSLOG(netsurf, INFO, LOG_ERROR, + " Invalid glyph data: ""expecting ' ', got '%c' (%i)\n", + c, + c); return false; } else { return true; } } else if (offset == 0) { if (c != '\n' && c != ' ') { - LOG(LOG_ERROR, " Invalid glyph data: " - "expecting '\\n' or ' ', " - "got '%c' (%i)\n", - c, c); + NSLOG(netsurf, INFO, LOG_ERROR, + " Invalid glyph data: ""expecting '\\n' or ' ', ""got '%c' (%i)\n", + c, + c); return false; } else { return true; } } else if (offset < 3) { if (c != ' ') { - LOG(LOG_ERROR, " Invalid glyph data: " - "expecting ' ', got '%c' (%i)\n", - c, c); + NSLOG(netsurf, INFO, LOG_ERROR, + " Invalid glyph data: ""expecting ' ', got '%c' (%i)\n", + c, + c); return false; } else { return true; } } else if (offset >= 3 && pos < 11) { if (c != '.' && c != '#') { - LOG(LOG_ERROR, " Invalid glyph data: " - "expecting '.' or '#', " - "got '%c' (%i)\n", - c, c); + NSLOG(netsurf, INFO, LOG_ERROR, + " Invalid glyph data: ""expecting '.' or '#', ""got '%c' (%i)\n", + c, + c); return false; } else { return true; @@ -505,10 +510,10 @@ static bool check_glyph_data_valid(int pos, char c) /* offset must be >=3 */ if (c != '.' && c != '#' && c != ' ') { - LOG(LOG_ERROR, " Invalid glyph data: " - "expecting '.', '#', or ' ', " - "got '%c' (%i)\n", - c, c); + NSLOG(netsurf, INFO, LOG_ERROR, + " Invalid glyph data: ""expecting '.', '#', or ' ', ""got '%c' (%i)\n", + c, + c); return false; } @@ -697,11 +702,11 @@ static bool parse_glyph_data(struct parse_context *ctx, char c, /* Check that character is valid */ if (check_glyph_data_valid(ctx->data.in_gd.pos, c) == false) { - LOG(LOG_ERROR, " Error in U+%.4X data: " - "glyph line: %i, pos: %i\n", - ctx->id, - ctx->data.in_gd.line, - ctx->data.in_gd.pos); + NSLOG(netsurf, INFO, LOG_ERROR, + " Error in U+%.4X data: ""glyph line: %i, pos: %i\n", + ctx->id, + ctx->data.in_gd.line, + ctx->data.in_gd.pos); goto error; } @@ -712,8 +717,8 @@ static bool parse_glyph_data(struct parse_context *ctx, char c, ctx->data.in_gd.e[glyph] = calloc(sizeof(struct glyph_entry), 1); if (ctx->data.in_gd.e[glyph] == NULL) { - LOG(LOG_ERROR, " Couldn't allocate memory for " - "glyph entry\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + " Couldn't allocate memory for ""glyph entry\n"); goto error; } @@ -735,18 +740,17 @@ static bool parse_glyph_data(struct parse_context *ctx, char c, if (c == '\n') { if (ctx->data.in_gd.line == 0) { if (ctx->data.in_gd.e[0] == NULL) { - LOG(LOG_ERROR, " Error in U+%.4X data: " - "\"Regular\" glyph style must " - "be present\n", ctx->id); + NSLOG(netsurf, INFO, LOG_ERROR, + " Error in U+%.4X data: ""\"Regular\" glyph style must ""be present\n", + ctx->id); goto error; } } else if (ctx->data.in_gd.styles != ctx->data.in_gd.line_styles) { - LOG(LOG_ERROR, " Error in U+%.4X data: " - "glyph line: %i " - "styles don't match first line\n", - ctx->id, - ctx->data.in_gd.line); + NSLOG(netsurf, INFO, LOG_ERROR, + " Error in U+%.4X data: ""glyph line: %i ""styles don't match first line\n", + ctx->id, + ctx->data.in_gd.line); goto error; } @@ -764,10 +768,10 @@ static bool parse_glyph_data(struct parse_context *ctx, char c, ctx->count[i] += 1; if (glyph_is_codepoint(ctx->data.in_gd.e[i], ctx->id, i)) { - LOG(LOG_DEBUG, " U+%.4X (%s) is " - "codepoint\n", - ctx->id, - short_labels[i]); + NSLOG(netsurf, INFO, LOG_DEBUG, + " U+%.4X (%s) is ""codepoint\n", + ctx->id, + short_labels[i]); ctx->codepoints += 1; free(ctx->data.in_gd.e[i]); ctx->data.in_gd.e[i] = NULL; @@ -810,7 +814,8 @@ static bool get_hex_digit_value(char c, int *v) else if (c >= 'A' && c <= 'F') *v = (10 + c - 'A'); else { - LOG(LOG_ERROR, "Invalid hex digit '%c' (%i)\n", c, c); + NSLOG(netsurf, INFO, LOG_ERROR, + "Invalid hex digit '%c' (%i)\n", c, c); return false; } @@ -847,14 +852,16 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, while (pos < end) { if (*pos == '\r') { - LOG(LOG_ERROR, "Detected \'\\r\': Bad line ending\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + "Detected \'\\r\': Bad line ending\n"); return false; } switch (ctx->state) { case START: if (*pos != '*') { - LOG(LOG_ERROR, "First character must be '*'\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + "First character must be '*'\n"); printf("Got: %c (%i)\n", *pos, *pos); return false; } @@ -866,12 +873,13 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, case IN_HEADER: if (ctx->data.in_header.new_line == true) { if (*pos != '*') { - LOG(LOG_INFO, " Got header " - "(%i bytes)\n", - d->header_len); - LOG(LOG_DEBUG, " Header:\n\n%.*s\n", - d->header_len, - d->header); + NSLOG(netsurf, INFO, LOG_INFO, + " Got header ""(%i bytes)\n", + d->header_len); + NSLOG(netsurf, INFO, LOG_DEBUG, + " Header:\n\n%.*s\n", + d->header_len, + d->header); ctx->data.before_id.new_line = false; ctx->data.before_id.u = false; ctx->state = BEFORE_ID; @@ -886,9 +894,9 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, } if (d->header_len == HEADER_MAX) { - LOG(LOG_ERROR, " Header too long " - "(>%i bytes)\n", - d->header_len); + NSLOG(netsurf, INFO, LOG_ERROR, + " Header too long ""(>%i bytes)\n", + d->header_len); return false; } @@ -922,7 +930,8 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, ok = assemble_codepoint(pos, ctx->data.g_id.c++, &ctx->id); if (!ok) { - LOG(LOG_ERROR, " Invalid glyph ID\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + " Invalid glyph ID\n"); return false; } @@ -994,8 +1003,8 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, } for (i = 0; i < 4; i++) { - LOG(LOG_DEBUG, " %s: %i gylphs\n", labels[i], - ctx->count[i] - count[i]); + NSLOG(netsurf, INFO, LOG_DEBUG, " %s: %i gylphs\n", + labels[i], ctx->count[i] - count[i]); } return true; @@ -1019,13 +1028,15 @@ bool load_font(const char *path, struct font_data **data) fp = fopen(path, "rb"); if (fp == NULL) { - LOG(LOG_ERROR, "Couldn't open font data file\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + "Couldn't open font data file\n"); return false; } d = calloc(sizeof(struct font_data), 1); if (d == NULL) { - LOG(LOG_ERROR, "Couldn't allocate memory for font data\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + "Couldn't allocate memory for font data\n"); fclose(fp); return false; } @@ -1034,18 +1045,19 @@ bool load_font(const char *path, struct font_data **data) fseek(fp, 0L, SEEK_END); file_len = ftell(fp); if (file_len == -1) { - LOG(LOG_ERROR, "Could not size input file\n"); + NSLOG(netsurf, INFO, LOG_ERROR, "Could not size input file\n"); free(d); fclose(fp); return false; } fseek(fp, 0L, SEEK_SET); - LOG(LOG_DEBUG, "Input size: %zu bytes\n", file_len); + NSLOG(netsurf, INFO, LOG_DEBUG, "Input size: %zu bytes\n", file_len); /* Allocate buffer for data chunks */ buf = malloc(CHUNK_SIZE); if (buf == NULL) { - LOG(LOG_ERROR, "Couldn't allocate memory for input buffer\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + "Couldn't allocate memory for input buffer\n"); free(d); fclose(fp); return false; @@ -1054,20 +1066,24 @@ bool load_font(const char *path, struct font_data **data) /* Initialise parser */ parse_init(&ctx); - LOG(LOG_DEBUG, "Using chunk size of %i bytes\n", CHUNK_SIZE); + NSLOG(netsurf, INFO, LOG_DEBUG, "Using chunk size of %i bytes\n", + CHUNK_SIZE); /* Parse the input file in chunks */ for (done = 0; done < file_len; done += CHUNK_SIZE) { - LOG(LOG_INFO, "Parsing input chunk %zu\n", done / CHUNK_SIZE); + NSLOG(netsurf, INFO, LOG_INFO, "Parsing input chunk %zu\n", + done / CHUNK_SIZE); /* Read chunk */ len = fread(buf, 1, CHUNK_SIZE, fp); if (file_len - done < CHUNK_SIZE && len != file_len - done) { - LOG(LOG_WARNING, "Last chunk has suspicious size\n"); + NSLOG(netsurf, INFO, LOG_WARNING, + "Last chunk has suspicious size\n"); } else if (file_len - done >= CHUNK_SIZE && len != CHUNK_SIZE) { - LOG(LOG_ERROR, "Problem reading file\n"); + NSLOG(netsurf, INFO, LOG_ERROR, + "Problem reading file\n"); free(buf); free(d); fclose(fp); @@ -1082,29 +1098,33 @@ bool load_font(const char *path, struct font_data **data) fclose(fp); return false; } - LOG(LOG_DEBUG, "Parsed %zu bytes\n", done + len); + NSLOG(netsurf, INFO, LOG_DEBUG, "Parsed %zu bytes\n", + done + len); } fclose(fp); if (ctx.state != BEFORE_ID) { - LOG(LOG_ERROR, "Unexpected end of file\n"); + NSLOG(netsurf, INFO, LOG_ERROR, "Unexpected end of file\n"); free(buf); free(d); return false; } - LOG(LOG_INFO, "Parsing complete:\n"); + NSLOG(netsurf, INFO, LOG_INFO, "Parsing complete:\n"); count = 0; for (i = 0; i < 4; i++) { - LOG(LOG_INFO, " %s: %i gylphs\n", labels[i], ctx.count[i]); + NSLOG(netsurf, INFO, LOG_INFO, " %s: %i gylphs\n", + labels[i], ctx.count[i]); count += ctx.count[i]; } - LOG(LOG_RESULT, " Total %i gylphs " - "(of which %i unique, %i codepoints, %i duplicates)\n", - count, d->glyphs, ctx.codepoints, - count - d->glyphs - ctx.codepoints); + NSLOG(netsurf, INFO, LOG_RESULT, + " Total %i gylphs ""(of which %i unique, %i codepoints, %i duplicates)\n", + count, + d->glyphs, + ctx.codepoints, + count - d->glyphs - ctx.codepoints); free(buf); @@ -1115,16 +1135,9 @@ bool load_font(const char *path, struct font_data **data) static void log_usage(const char *argv0) { level = LOG_INFO; - LOG(LOG_INFO, - "Usage:\n" - "\t%s [options] \n" - "\n" - "Options:\n" - "\t--help -h Display this text\n" - "\t--quiet -q Don't show warnings\n" - "\t--verbose -v Verbose output\n" - "\t--debug -d Full debug output\n", - argv0); + NSLOG(netsurf, INFO, LOG_INFO, + "Usage:\n""\t%s [options] \n""\n""Options:\n""\t--help -h Display this text\n""\t--quiet -q Don't show warnings\n""\t--verbose -v Verbose output\n""\t--debug -d Full debug output\n", + argv0); } int main(int argc, char** argv) @@ -1187,8 +1200,9 @@ int main(int argc, char** argv) in_path = argv[optind]; out_path = argv[optind + 1]; - LOG(LOG_DEBUG, "Using input path: \"%s\"\n", in_path); - LOG(LOG_DEBUG, "Using output path: \"%s\"\n", out_path); + NSLOG(netsurf, INFO, LOG_DEBUG, "Using input path: \"%s\"\n", in_path); + NSLOG(netsurf, INFO, LOG_DEBUG, "Using output path: \"%s\"\n", + out_path); ok = load_font(in_path, &data); if (!ok) { diff --git a/frontends/framebuffer/fbtk/event.c b/frontends/framebuffer/fbtk/event.c index a48e63809..84c6c3791 100644 --- a/frontends/framebuffer/fbtk/event.c +++ b/frontends/framebuffer/fbtk/event.c @@ -51,7 +51,7 @@ fbtk_input(fbtk_widget_t *root, nsfb_event_t *event) /* obtain widget with input focus */ input = root->u.root.input; if (input == NULL) { - LOG("No widget has input focus."); + NSLOG(netsurf, INFO, "No widget has input focus."); return; /* no widget with input */ } @@ -84,7 +84,7 @@ fbtk_click(fbtk_widget_t *widget, nsfb_event_t *event) x = fbtk_get_absx(clicked); y = fbtk_get_absy(clicked); - LOG("clicked %p at %d,%d", clicked, x, y); + NSLOG(netsurf, INFO, "clicked %p at %d,%d", clicked, x, y); /* post the click */ fbtk_post_callback(clicked, FBTK_CBT_CLICK, event, cloc.x0 - x, cloc.y0 - y); diff --git a/frontends/framebuffer/fbtk/fbtk.c b/frontends/framebuffer/fbtk/fbtk.c index c63a6d8c9..a0b0f6660 100644 --- a/frontends/framebuffer/fbtk/fbtk.c +++ b/frontends/framebuffer/fbtk/fbtk.c @@ -53,7 +53,7 @@ dump_tk_tree(fbtk_widget_t *widget) int indent = 0; while (widget != NULL) { - LOG("%*s%p", indent, "", widget); + NSLOG(netsurf, INFO, "%*s%p", indent, "", widget); if (widget->first_child != NULL) { widget = widget->first_child; indent += 6; @@ -101,7 +101,9 @@ fbtk_request_redraw(fbtk_widget_t *widget) widget->redraw.height = widget->height; #ifdef FBTK_LOGGING - LOG("redrawing %p %d,%d %d,%d", widget, widget->redraw.x, widget->redraw.y, widget->redraw.width, widget->redraw.height); + NSLOG(netsurf, INFO, "redrawing %p %d,%d %d,%d", widget, + widget->redraw.x, widget->redraw.y, widget->redraw.width, + widget->redraw.height); #endif cwidget = widget->last_child; @@ -122,7 +124,7 @@ fbtk_request_redraw(fbtk_widget_t *widget) int fbtk_set_mapping(fbtk_widget_t *widget, bool map) { - LOG("setting mapping on %p to %d", widget, map); + NSLOG(netsurf, INFO, "setting mapping on %p to %d", widget, map); widget->mapped = map; if (map) { fbtk_request_redraw(widget); @@ -145,7 +147,7 @@ swap_siblings(fbtk_widget_t *lw) assert(rw != NULL); - LOG("Swapping %p with %p", lw, rw); + NSLOG(netsurf, INFO, "Swapping %p with %p", lw, rw); before = lw->prev; after = rw->next; @@ -411,7 +413,8 @@ fbtk_get_root_widget(fbtk_widget_t *widget) /* check root widget was found */ if (widget->type != FB_WIDGET_TYPE_ROOT) { - LOG("Widget with null parent that is not the root widget!"); + NSLOG(netsurf, INFO, + "Widget with null parent that is not the root widget!"); return NULL; } @@ -552,7 +555,8 @@ fbtk_widget_new(fbtk_widget_t *parent, return NULL; #ifdef FBTK_LOGGING - LOG("creating %p %d,%d %d,%d", neww, x, y, width, height); + NSLOG(netsurf, INFO, "creating %p %d,%d %d,%d", neww, x, y, width, + height); #endif /* make new window fit inside parent */ @@ -575,7 +579,8 @@ fbtk_widget_new(fbtk_widget_t *parent, } #ifdef FBTK_LOGGING - LOG("using %p %d,%d %d,%d", neww, x, y, width, height); + NSLOG(netsurf, INFO, "using %p %d,%d %d,%d", neww, x, y, width, + height); #endif /* set values */ neww->type = type; @@ -635,7 +640,8 @@ do_redraw(nsfb_t *nsfb, fbtk_widget_t *widget) plot_ctx.y1 = plot_ctx.y0 + widget->redraw.height; #ifdef FBTK_LOGGING - LOG("clipping %p %d,%d %d,%d", widget, plot_ctx.x0, plot_ctx.y0, plot_ctx.x1, plot_ctx.y1); + NSLOG(netsurf, INFO, "clipping %p %d,%d %d,%d", widget, + plot_ctx.x0, plot_ctx.y0, plot_ctx.x1, plot_ctx.y1); #endif if (nsfb_plot_set_clip(nsfb, &plot_ctx) == true) { fbtk_post_callback(widget, FBTK_CBT_REDRAW); diff --git a/frontends/framebuffer/fbtk/scroll.c b/frontends/framebuffer/fbtk/scroll.c index cc98fb2dd..b056ac81f 100644 --- a/frontends/framebuffer/fbtk/scroll.c +++ b/frontends/framebuffer/fbtk/scroll.c @@ -334,7 +334,7 @@ hscroll_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi) hpos = 0; } - LOG("hscroll %d", hscroll); + NSLOG(netsurf, INFO, "hscroll %d", hscroll); rect.x0 = bbox.x0 + 3 + hpos; rect.y0 = bbox.y0 + 5; @@ -362,7 +362,7 @@ hscrolll_click(fbtk_widget_t *widget, fbtk_callback_info *cbi) newpos = scrollw->u.scroll.minimum; if (newpos == scrollw->u.scroll.position) { - LOG("horiz scroll was the same %d", newpos); + NSLOG(netsurf, INFO, "horiz scroll was the same %d", newpos); return 0; } diff --git a/frontends/framebuffer/fetch.c b/frontends/framebuffer/fetch.c index 801b87a74..23cbb4f21 100644 --- a/frontends/framebuffer/fetch.c +++ b/frontends/framebuffer/fetch.c @@ -65,7 +65,7 @@ static nsurl *get_resource_url(const char *path) static const char *fetch_filetype(const char *unix_path) { int l; - LOG("unix path %s", unix_path); + NSLOG(netsurf, INFO, "unix path %s", unix_path); l = strlen(unix_path); if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0) return "text/css"; diff --git a/frontends/framebuffer/font_freetype.c b/frontends/framebuffer/font_freetype.c index e7c07f5ff..9e47e4b99 100644 --- a/frontends/framebuffer/font_freetype.c +++ b/frontends/framebuffer/font_freetype.c @@ -90,12 +90,13 @@ ft_face_requester(FTC_FaceID face_id, error = FT_New_Face(library, fb_face->fontfile, fb_face->index, face); if (error) { - LOG("Could not find font (code %d)", error); + NSLOG(netsurf, INFO, "Could not find font (code %d)", error); } else { error = FT_Select_Charmap(*face, FT_ENCODING_UNICODE); if (error) { - LOG("Could not select charmap (code %d)", error); + NSLOG(netsurf, INFO, + "Could not select charmap (code %d)", error); } else { for (cidx = 0; cidx < (*face)->num_charmaps; cidx++) { if ((*face)->charmap == (*face)->charmaps[cidx]) { @@ -105,7 +106,7 @@ ft_face_requester(FTC_FaceID face_id, } } } - LOG("Loaded face from %s", fb_face->fontfile); + NSLOG(netsurf, INFO, "Loaded face from %s", fb_face->fontfile); return error; } @@ -132,7 +133,8 @@ fb_new_face(const char *option, const char *resname, const char *fontname) error = FTC_Manager_LookupFace(ft_cmanager, (FTC_FaceID)newf, &aface); if (error) { - LOG("Could not find font face %s (code %d)", fontname, error); + NSLOG(netsurf, INFO, "Could not find font face %s (code %d)", + fontname, error); free(newf->fontfile); free(newf); newf = NULL; @@ -152,7 +154,8 @@ bool fb_font_init(void) /* freetype library initialise */ error = FT_Init_FreeType( &library ); if (error) { - LOG("Freetype could not initialised (code %d)", error); + NSLOG(netsurf, INFO, + "Freetype could not initialised (code %d)", error); return false; } @@ -172,7 +175,9 @@ bool fb_font_init(void) NULL, &ft_cmanager); if (error) { - LOG("Freetype could not initialise cache manager (code %d)", error); + NSLOG(netsurf, INFO, + "Freetype could not initialise cache manager (code %d)", + error); FT_Done_FreeType(library); return false; } @@ -189,7 +194,7 @@ bool fb_font_init(void) NETSURF_FB_FONT_SANS_SERIF); if (fb_face == NULL) { /* The sans serif font is the default and must be found. */ - LOG("Could not find the default font"); + NSLOG(netsurf, INFO, "Could not find the default font"); FTC_Manager_Done(ft_cmanager); FT_Done_FreeType(library); return false; diff --git a/frontends/framebuffer/framebuffer.c b/frontends/framebuffer/framebuffer.c index de8a3695d..2ccc75062 100644 --- a/frontends/framebuffer/framebuffer.c +++ b/frontends/framebuffer/framebuffer.c @@ -271,7 +271,7 @@ framebuffer_plot_path(const struct redraw_context *ctx, float width, const float transform[6]) { - LOG("path unimplemented"); + NSLOG(netsurf, INFO, "path unimplemented"); return NSERROR_OK; } @@ -564,7 +564,7 @@ static bool framebuffer_format_from_bpp(int bpp, enum nsfb_format_e *fmt) break; default: - LOG("Bad bits per pixel (%d)\n", bpp); + NSLOG(netsurf, INFO, "Bad bits per pixel (%d)\n", bpp); return false; } @@ -586,18 +586,19 @@ framebuffer_initialise(const char *fename, int width, int height, int bpp) fbtype = nsfb_type_from_name(fename); if (fbtype == NSFB_SURFACE_NONE) { - LOG("The %s surface is not available from libnsfb\n", fename); + NSLOG(netsurf, INFO, + "The %s surface is not available from libnsfb\n", fename); return NULL; } nsfb = nsfb_new(fbtype); if (nsfb == NULL) { - LOG("Unable to create %s fb surface\n", fename); + NSLOG(netsurf, INFO, "Unable to create %s fb surface\n", fename); return NULL; } if (nsfb_set_geometry(nsfb, width, height, fbfmt) == -1) { - LOG("Unable to set surface geometry\n"); + NSLOG(netsurf, INFO, "Unable to set surface geometry\n"); nsfb_free(nsfb); return NULL; } @@ -605,7 +606,7 @@ framebuffer_initialise(const char *fename, int width, int height, int bpp) nsfb_cursor_init(nsfb); if (nsfb_init(nsfb) == -1) { - LOG("Unable to initialise nsfb surface\n"); + NSLOG(netsurf, INFO, "Unable to initialise nsfb surface\n"); nsfb_free(nsfb); return NULL; } @@ -625,7 +626,7 @@ framebuffer_resize(nsfb_t *nsfb, int width, int height, int bpp) } if (nsfb_set_geometry(nsfb, width, height, fbfmt) == -1) { - LOG("Unable to change surface geometry\n"); + NSLOG(netsurf, INFO, "Unable to change surface geometry\n"); return false; } diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c index 1460c77f6..ebd0b7b66 100644 --- a/frontends/framebuffer/gui.c +++ b/frontends/framebuffer/gui.c @@ -120,7 +120,7 @@ static void die(const char *error) */ static nserror fb_warn_user(const char *warning, const char *detail) { - LOG("%s %s", warning, detail); + NSLOG(netsurf, INFO, "%s %s", warning, detail); return NSERROR_OK; } @@ -153,7 +153,7 @@ widget_scroll_y(struct gui_window *gw, int y, bool abs) int content_width, content_height; int height; - LOG("window scroll"); + NSLOG(netsurf, INFO, "window scroll"); if (abs) { bwidget->pany = y - bwidget->scrolly; } else { @@ -237,7 +237,7 @@ fb_pan(fbtk_widget_t *widget, height = fbtk_get_height(widget); width = fbtk_get_width(widget); - LOG("panning %d, %d", bwidget->panx, bwidget->pany); + NSLOG(netsurf, INFO, "panning %d, %d", bwidget->panx, bwidget->pany); x = fbtk_get_absx(widget); y = fbtk_get_absy(widget); @@ -413,7 +413,8 @@ fb_browser_window_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi) bwidget = fbtk_get_userpw(widget); if (bwidget == NULL) { - LOG("browser widget from widget %p was null", widget); + NSLOG(netsurf, INFO, + "browser widget from widget %p was null", widget); return -1; } @@ -465,7 +466,7 @@ process_cmdline(int argc, char** argv) {0, 0, 0, 0 } }; /* no long options */ - LOG("argc %d, argv %p", argc, argv); + NSLOG(netsurf, INFO, "argc %d, argv %p", argc, argv); fename = "sdl"; febpp = 32; @@ -534,7 +535,7 @@ static nserror set_defaults(struct nsoption_s *defaults) if (nsoption_charp(cookie_file) == NULL || nsoption_charp(cookie_jar) == NULL) { - LOG("Failed initialising cookie options"); + NSLOG(netsurf, INFO, "Failed initialising cookie options"); return NSERROR_BAD_PARAMETER; } @@ -612,7 +613,7 @@ static void framebuffer_run(void) static void gui_quit(void) { - LOG("gui_quit"); + NSLOG(netsurf, INFO, "gui_quit"); urldb_save_cookies(nsoption_charp(cookie_jar)); @@ -639,7 +640,8 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi) cbi->event->type != NSFB_EVENT_KEY_UP) return 0; - LOG("browser window clicked at %d,%d", cbi->x, cbi->y); + NSLOG(netsurf, INFO, "browser window clicked at %d,%d", cbi->x, + cbi->y); switch (cbi->event->type) { case NSFB_EVENT_KEY_DOWN: @@ -824,7 +826,7 @@ fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi) static fbtk_modifier_type modifier = FBTK_MOD_CLEAR; int ucs4 = -1; - LOG("got value %d", cbi->event->value.keycode); + NSLOG(netsurf, INFO, "got value %d", cbi->event->value.keycode); switch (cbi->event->type) { case NSFB_EVENT_KEY_DOWN: @@ -1200,7 +1202,7 @@ create_toolbar(struct gui_window *gw, toolbar_layout = NSFB_TOOLBAR_DEFAULT_LAYOUT; } - LOG("Using toolbar layout %s", toolbar_layout); + NSLOG(netsurf, INFO, "Using toolbar layout %s", toolbar_layout); itmtype = toolbar_layout; @@ -1234,7 +1236,7 @@ create_toolbar(struct gui_window *gw, (*itmtype != 0) && (xdir !=0)) { - LOG("toolbar adding %c", *itmtype); + NSLOG(netsurf, INFO, "toolbar adding %c", *itmtype); switch (*itmtype) { @@ -1376,7 +1378,9 @@ create_toolbar(struct gui_window *gw, default: widget = NULL; xdir = 0; - LOG("Unknown element %c in toolbar layout", *itmtype); + NSLOG(netsurf, INFO, + "Unknown element %c in toolbar layout", + *itmtype); break; } @@ -1385,7 +1389,7 @@ create_toolbar(struct gui_window *gw, xpos += (xdir * (fbtk_get_width(widget) + padding)); } - LOG("xpos is %d", xpos); + NSLOG(netsurf, INFO, "xpos is %d", xpos); itmtype += xdir; } @@ -1595,7 +1599,7 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width) int statusbar_width = 0; int toolbar_height = nsoption_int(fb_toolbar_size); - LOG("Normal window"); + NSLOG(netsurf, INFO, "Normal window"); gw->window = fbtk_create_window(fbtk, 0, 0, 0, 0, 0); @@ -1626,7 +1630,8 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width) false); fbtk_set_handler(gw->status, FBTK_CBT_POINTERENTER, set_ptr_default_move, NULL); - LOG("status bar %p at %d,%d", gw->status, fbtk_get_absx(gw->status), fbtk_get_absy(gw->status)); + NSLOG(netsurf, INFO, "status bar %p at %d,%d", gw->status, + fbtk_get_absx(gw->status), fbtk_get_absy(gw->status)); /* create horizontal scrollbar */ gw->hscroll = fbtk_create_hscroll(gw->window, @@ -2183,7 +2188,7 @@ main(int argc, char** argv) /* create an initial browser window */ - LOG("calling browser_window_create"); + NSLOG(netsurf, INFO, "calling browser_window_create"); ret = nsurl_create(feurl, &url); if (ret == NSERROR_OK) { @@ -2205,7 +2210,7 @@ main(int argc, char** argv) netsurf_exit(); if (fb_font_finalise() == false) - LOG("Font finalisation failed."); + NSLOG(netsurf, INFO, "Font finalisation failed."); /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); diff --git a/frontends/framebuffer/schedule.c b/frontends/framebuffer/schedule.c index 581ad72f1..c94cead44 100644 --- a/frontends/framebuffer/schedule.c +++ b/frontends/framebuffer/schedule.c @@ -203,12 +203,14 @@ void list_schedule(void) gettimeofday(&tv, NULL); - LOG("schedule list at %ld:%ld", tv.tv_sec, tv.tv_usec); + NSLOG(netsurf, INFO, "schedule list at %ld:%ld", tv.tv_sec, + tv.tv_usec); cur_nscb = schedule_list; while (cur_nscb != NULL) { - LOG("Schedule %p at %ld:%ld", cur_nscb, cur_nscb->tv.tv_sec, cur_nscb->tv.tv_usec); + NSLOG(netsurf, INFO, "Schedule %p at %ld:%ld", cur_nscb, + cur_nscb->tv.tv_sec, cur_nscb->tv.tv_usec); cur_nscb = cur_nscb->next; } } diff --git a/frontends/gtk/cookies.c b/frontends/gtk/cookies.c index 500cd07f6..1f7833cca 100644 --- a/frontends/gtk/cookies.c +++ b/frontends/gtk/cookies.c @@ -164,8 +164,9 @@ static void nsgtk_cookies_init_menu(struct nsgtk_cookie_window *ncwin) w = GTK_WIDGET(gtk_builder_get_object(ncwin->builder, event->widget)); if (w == NULL) { - LOG("Unable to connect menu widget ""%s""", - event->widget); + NSLOG(netsurf, INFO, + "Unable to connect menu widget ""%s""", + event->widget); } else { g_signal_connect(G_OBJECT(w), "activate", @@ -253,7 +254,7 @@ static nserror nsgtk_cookies_init(void) res = nsgtk_builder_new_from_resname("cookies", &ncwin->builder); if (res != NSERROR_OK) { - LOG("Cookie UI builder init failed"); + NSLOG(netsurf, INFO, "Cookie UI builder init failed"); free(ncwin); return res; } diff --git a/frontends/gtk/corewindow.c b/frontends/gtk/corewindow.c index ddc61c717..53ee17333 100644 --- a/frontends/gtk/corewindow.c +++ b/frontends/gtk/corewindow.c @@ -413,14 +413,14 @@ nsgtk_cw_keypress_event(GtkWidget *widget, GdkEventKey *event, gpointer g) if (res == NSERROR_OK) { return TRUE; } else if (res != NSERROR_NOT_IMPLEMENTED) { - LOG("%s", messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "%s", messages_get_errorcode(res)); return FALSE; } /* deal with unprocessed keypress */ res = nsgtk_cw_key(nsgtk_cw, nskey); if (res != NSERROR_OK) { - LOG("%s", messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "%s", messages_get_errorcode(res)); return FALSE; } return TRUE; diff --git a/frontends/gtk/download.c b/frontends/gtk/download.c index 8c8161459..576960271 100644 --- a/frontends/gtk/download.c +++ b/frontends/gtk/download.c @@ -475,7 +475,7 @@ nserror nsgtk_download_init(void) res = nsgtk_builder_new_from_resname("downloads", &builder); if (res != NSERROR_OK) { - LOG("Download UI builder init failed"); + NSLOG(netsurf, INFO, "Download UI builder init failed"); return res; } diff --git a/frontends/gtk/fetch.c b/frontends/gtk/fetch.c index 154f43708..7286aec34 100644 --- a/frontends/gtk/fetch.c +++ b/frontends/gtk/fetch.c @@ -90,7 +90,8 @@ void gtk_fetch_filetype_init(const char *mimefile) fh = fopen(mimefile, "r"); if (fh == NULL) { - LOG("Unable to open a mime.types file, so using a minimal one for you."); + NSLOG(netsurf, INFO, + "Unable to open a mime.types file, so using a minimal one for you."); return; } diff --git a/frontends/gtk/gdk.c b/frontends/gtk/gdk.c index 9ed90bd8e..fd82af5b2 100644 --- a/frontends/gtk/gdk.c +++ b/frontends/gtk/gdk.c @@ -86,7 +86,7 @@ nsgdk_pixbuf_get_from_surface(cairo_surface_t *surface, int scwidth, int scheigh if (cairo_surface_status(scsurface) != CAIRO_STATUS_SUCCESS) { cairo_surface_destroy(scsurface); g_object_unref(pixbuf); - LOG("Surface creation failed"); + NSLOG(netsurf, INFO, "Surface creation failed"); return NULL; } diff --git a/frontends/gtk/global_history.c b/frontends/gtk/global_history.c index 360eb4e1a..f204168d0 100644 --- a/frontends/gtk/global_history.c +++ b/frontends/gtk/global_history.c @@ -214,8 +214,9 @@ nsgtk_global_history_init_menu(struct nsgtk_global_history_window *ghwin) w = GTK_WIDGET(gtk_builder_get_object(ghwin->builder, event->widget)); if (w == NULL) { - LOG("Unable to connect menu widget ""%s""", - event->widget); + NSLOG(netsurf, INFO, + "Unable to connect menu widget ""%s""", + event->widget); } else { g_signal_connect(G_OBJECT(w), "activate", @@ -306,7 +307,7 @@ static nserror nsgtk_global_history_init(void) res = nsgtk_builder_new_from_resname("globalhistory", &ncwin->builder); if (res != NSERROR_OK) { - LOG("History UI builder init failed"); + NSLOG(netsurf, INFO, "History UI builder init failed"); free(ncwin); return res; } diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c index a183e521f..6a61b3d06 100644 --- a/frontends/gtk/gui.c +++ b/frontends/gtk/gui.c @@ -208,7 +208,8 @@ static nserror set_defaults(struct nsoption_s *defaults) (nsoption_charp(hotlist_path) == NULL) || (nsoption_charp(downloads_directory) == NULL) || (nsoption_charp(ca_path) == NULL)) { - LOG("Failed initialising default resource paths"); + NSLOG(netsurf, INFO, + "Failed initialising default resource paths"); return NSERROR_BAD_PARAMETER; } @@ -238,7 +239,7 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) error = nsgtk_builder_new_from_resname("warning", &warning_builder); if (error != NSERROR_OK) { - LOG("Unable to initialise warning dialog"); + NSLOG(netsurf, INFO, "Unable to initialise warning dialog"); return error; } @@ -248,7 +249,7 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) error = nsgdk_pixbuf_new_from_resname("netsurf.xpm", &win_default_icon_pixbuf); if (error == NSERROR_OK) { - LOG("Seting default window icon"); + NSLOG(netsurf, INFO, "Seting default window icon"); gtk_window_set_default_icon(win_default_icon_pixbuf); } @@ -256,7 +257,8 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) resource_filename = filepath_find(respath, "SearchEngines"); search_web_init(resource_filename); if (resource_filename != NULL) { - LOG("Using '%s' as Search Engines file", resource_filename); + NSLOG(netsurf, INFO, "Using '%s' as Search Engines file", + resource_filename); free(resource_filename); } @@ -278,7 +280,7 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) /* initialise throbber */ error = nsgtk_throbber_init(); if (error != NSERROR_OK) { - LOG("Unable to initialise throbber."); + NSLOG(netsurf, INFO, "Unable to initialise throbber."); return error; } @@ -300,12 +302,12 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) * window. */ browser_set_dpi(gdk_screen_get_resolution(gdk_screen_get_default())); - LOG("Set CSS DPI to %d", browser_get_dpi()); + NSLOG(netsurf, INFO, "Set CSS DPI to %d", browser_get_dpi()); /* Initialise top level UI elements */ error = nsgtk_download_init(); if (error != NSERROR_OK) { - LOG("Unable to initialise download window."); + NSLOG(netsurf, INFO, "Unable to initialise download window."); return error; } @@ -426,7 +428,7 @@ static void gui_quit(void) { nserror res; - LOG("Quitting GUI"); + NSLOG(netsurf, INFO, "Quitting GUI"); /* Ensure all scaffoldings are destroyed before we go into exit */ nsgtk_download_destroy(); @@ -435,32 +437,34 @@ static void gui_quit(void) res = nsgtk_cookies_destroy(); if (res != NSERROR_OK) { - LOG("Error finalising cookie viewer: %s", - messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "Error finalising cookie viewer: %s", + messages_get_errorcode(res)); } res = nsgtk_local_history_destroy(); if (res != NSERROR_OK) { - LOG("Error finalising local history viewer: %s", - messages_get_errorcode(res)); + NSLOG(netsurf, INFO, + "Error finalising local history viewer: %s", + messages_get_errorcode(res)); } res = nsgtk_global_history_destroy(); if (res != NSERROR_OK) { - LOG("Error finalising global history viewer: %s", - messages_get_errorcode(res)); + NSLOG(netsurf, INFO, + "Error finalising global history viewer: %s", + messages_get_errorcode(res)); } res = nsgtk_hotlist_destroy(); if (res != NSERROR_OK) { - LOG("Error finalising hotlist viewer: %s", - messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "Error finalising hotlist viewer: %s", + messages_get_errorcode(res)); } res = hotlist_fini(); if (res != NSERROR_OK) { - LOG("Error finalising hotlist: %s", - messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "Error finalising hotlist: %s", + messages_get_errorcode(res)); } free(nsgtk_config_home); @@ -492,7 +496,7 @@ nserror nsgtk_warning(const char *warning, const char *detail) static GtkWindow *nsgtk_warning_window; GtkLabel *WarningLabel; - LOG("%s %s", warning, detail ? detail : ""); + NSLOG(netsurf, INFO, "%s %s", warning, detail ? detail : ""); fflush(stdout); nsgtk_warning_window = GTK_WINDOW(gtk_builder_get_object(warning_builder, "wndWarning")); @@ -600,7 +604,7 @@ static void nsgtk_pdf_password(char **owner_pass, char **user_pass, char *path) res = nsgtk_builder_new_from_resname("password", &password_builder); if (res != NSERROR_OK) { - LOG("Password UI builder init failed"); + NSLOG(netsurf, INFO, "Password UI builder init failed"); return; } @@ -821,7 +825,7 @@ static nserror get_config_home(char **config_home_out) if (home_dir != NULL) { ret = check_dirname(home_dir, ".netsurf", &config_home); if (ret == NSERROR_OK) { - LOG("\"%s\"", config_home); + NSLOG(netsurf, INFO, "\"%s\"", config_home); *config_home_out = config_home; return ret; } @@ -861,7 +865,7 @@ static nserror get_config_home(char **config_home_out) } } - LOG("\"%s\"", config_home); + NSLOG(netsurf, INFO, "\"%s\"", config_home); *config_home_out = config_home; return NSERROR_OK; @@ -874,7 +878,7 @@ static nserror create_config_home(char **config_home_out) char *xdg_config_dir; nserror ret; - LOG("Attempting to create configuration directory"); + NSLOG(netsurf, INFO, "Attempting to create configuration directory"); /* $XDG_CONFIG_HOME defines the base directory * relative to which user specific configuration files @@ -910,7 +914,7 @@ static nserror create_config_home(char **config_home_out) /* strip the trailing separator */ config_home[strlen(config_home) - 1] = 0; - LOG("\"%s\"", config_home); + NSLOG(netsurf, INFO, "\"%s\"", config_home); *config_home_out = config_home; @@ -959,7 +963,7 @@ static nserror get_cache_home(char **cache_home_out) } } - LOG("\"%s\"", cache_home); + NSLOG(netsurf, INFO, "\"%s\"", cache_home); *cache_home_out = cache_home; return NSERROR_OK; @@ -972,7 +976,7 @@ static nserror create_cache_home(char **cache_home_out) char *xdg_cache_dir; nserror ret; - LOG("Attempting to create configuration directory"); + NSLOG(netsurf, INFO, "Attempting to create configuration directory"); /* $XDG_CACHE_HOME defines the base directory * relative to which user specific cache files @@ -1008,7 +1012,7 @@ static nserror create_cache_home(char **cache_home_out) /* strip the trailing separator */ cache_home[strlen(cache_home) - 1] = 0; - LOG("\"%s\"", cache_home); + NSLOG(netsurf, INFO, "\"%s\"", cache_home); *cache_home_out = cache_home; @@ -1115,7 +1119,8 @@ int main(int argc, char** argv) ret = create_config_home(&nsgtk_config_home); } if (ret != NSERROR_OK) { - LOG("Unable to locate a configuration directory."); + NSLOG(netsurf, INFO, + "Unable to locate a configuration directory."); nsgtk_config_home = NULL; } @@ -1155,7 +1160,7 @@ int main(int argc, char** argv) if (ret != NSERROR_OK) { fprintf(stderr, "Unable to load translated messages (%s)\n", messages_get_errorcode(ret)); - LOG("Unable to load translated messages"); + NSLOG(netsurf, INFO, "Unable to load translated messages"); /** \todo decide if message load faliure should be fatal */ } @@ -1166,7 +1171,7 @@ int main(int argc, char** argv) ret = create_cache_home(&cache_home); } if (ret != NSERROR_OK) { - LOG("Unable to locate a cache directory."); + NSLOG(netsurf, INFO, "Unable to locate a cache directory."); } /* core initialisation */ diff --git a/frontends/gtk/hotlist.c b/frontends/gtk/hotlist.c index 936573a0b..843e47736 100644 --- a/frontends/gtk/hotlist.c +++ b/frontends/gtk/hotlist.c @@ -236,8 +236,9 @@ static void nsgtk_hotlist_init_menu(struct nsgtk_hotlist_window *hlwin) w = GTK_WIDGET(gtk_builder_get_object(hlwin->builder, event->widget)); if (w == NULL) { - LOG("Unable to connect menu widget ""%s""", - event->widget); + NSLOG(netsurf, INFO, + "Unable to connect menu widget ""%s""", + event->widget); } else { g_signal_connect(G_OBJECT(w), "activate", @@ -326,7 +327,7 @@ static nserror nsgtk_hotlist_init(void) res = nsgtk_builder_new_from_resname("hotlist", &ncwin->builder); if (res != NSERROR_OK) { - LOG("Hotlist UI builder init failed"); + NSLOG(netsurf, INFO, "Hotlist UI builder init failed"); free(ncwin); return res; } diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c index fb065b127..300278648 100644 --- a/frontends/gtk/layout_pango.c +++ b/frontends/gtk/layout_pango.c @@ -42,12 +42,12 @@ static PangoLayout *nsfont_pango_layout = NULL; static inline void nsfont_pango_check(void) { if (nsfont_pango_context == NULL) { - LOG("Creating nsfont_pango_context."); + NSLOG(netsurf, INFO, "Creating nsfont_pango_context."); nsfont_pango_context = gdk_pango_context_get(); } if (nsfont_pango_layout == NULL) { - LOG("Creating nsfont_pango_layout."); + NSLOG(netsurf, INFO, "Creating nsfont_pango_layout."); nsfont_pango_layout = pango_layout_new(nsfont_pango_context); } } diff --git a/frontends/gtk/local_history.c b/frontends/gtk/local_history.c index cc9580130..35b7a4ad6 100644 --- a/frontends/gtk/local_history.c +++ b/frontends/gtk/local_history.c @@ -148,7 +148,7 @@ nsgtk_local_history_init(struct browser_window *bw, res = nsgtk_builder_new_from_resname("localhistory", &ncwin->builder); if (res != NSERROR_OK) { - LOG("Local history UI builder init failed"); + NSLOG(netsurf, INFO, "Local history UI builder init failed"); free(ncwin); return res; } diff --git a/frontends/gtk/login.c b/frontends/gtk/login.c index 3e29903fe..91d8b37f0 100644 --- a/frontends/gtk/login.c +++ b/frontends/gtk/login.c @@ -222,7 +222,7 @@ void gui_401login_open(nsurl *url, res = create_login_window(url, host, realm, cb, cbpw); if (res != NSERROR_OK) { - LOG("Login init failed"); + NSLOG(netsurf, INFO, "Login init failed"); /* creating login failed so cancel navigation */ cb(false, cbpw); diff --git a/frontends/gtk/plotters.c b/frontends/gtk/plotters.c index c57b03294..88e7760c6 100644 --- a/frontends/gtk/plotters.c +++ b/frontends/gtk/plotters.c @@ -413,7 +413,7 @@ nsgtk_plot_path(const struct redraw_context *ctx, return NSERROR_OK; if (p[0] != PLOTTER_PATH_MOVE) { - LOG("Path does not start with move"); + NSLOG(netsurf, INFO, "Path does not start with move"); return NSERROR_INVALID; } @@ -451,7 +451,7 @@ nsgtk_plot_path(const struct redraw_context *ctx, p[i+5], p[i+6]); i += 7; } else { - LOG("bad path command %f", p[i]); + NSLOG(netsurf, INFO, "bad path command %f", p[i]); /* Reset matrix for safety */ cairo_set_matrix(current_cr, &old_ctm); return NSERROR_INVALID; diff --git a/frontends/gtk/preferences.c b/frontends/gtk/preferences.c index e51e77014..65f41ed27 100644 --- a/frontends/gtk/preferences.c +++ b/frontends/gtk/preferences.c @@ -621,7 +621,7 @@ comboboxLanguage_add_from_file(GtkListStore *liststore, gtk_list_store_clear(liststore); - LOG("Used %s for languages", file_location); + NSLOG(netsurf, INFO, "Used %s for languages", file_location); while (fgets(buf, sizeof(buf), fp)) { /* Ignore blank lines */ if (buf[0] == '\0') @@ -668,7 +668,7 @@ nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget, const char *accept_language; if (priv->content_language == NULL) { - LOG("content language list store unavailable"); + NSLOG(netsurf, INFO, "content language list store unavailable"); return; } @@ -697,7 +697,7 @@ nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget, } } if (res != NSERROR_OK) { - LOG("error populatiung languages combo"); + NSLOG(netsurf, INFO, "error populatiung languages combo"); } } @@ -989,14 +989,15 @@ GtkWidget* nsgtk_preferences(struct browser_window *bw, GtkWindow *parent) res = nsgtk_builder_new_from_resname("options", &preferences_builder); if (res != NSERROR_OK) { - LOG("Preferences UI builder init failed"); + NSLOG(netsurf, INFO, "Preferences UI builder init failed"); return NULL; } priv->dialog = gtk_builder_get_object(preferences_builder, "dialogPreferences"); if (priv->dialog == NULL) { - LOG("Unable to get object for preferences dialog"); + NSLOG(netsurf, INFO, + "Unable to get object for preferences dialog"); /* release builder as were done with it */ g_object_unref(G_OBJECT(preferences_builder)); return NULL; diff --git a/frontends/gtk/print.c b/frontends/gtk/print.c index 54edeee61..8f71230a6 100644 --- a/frontends/gtk/print.c +++ b/frontends/gtk/print.c @@ -145,8 +145,9 @@ static inline void nsgtk_print_set_dashed(void) static nserror nsgtk_print_plot_clip(const struct redraw_context *ctx, const struct rect *clip) { - LOG("Clipping. x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", - clip->x0, clip->y0, clip->x1, clip->y1); + NSLOG(netsurf, INFO, + "Clipping. x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", clip->x0, + clip->y0, clip->x1, clip->y1); /* Normalize cllipping area - to prevent overflows. * See comment in pdf_plot_fill. */ @@ -324,8 +325,8 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect) { - LOG("x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", - rect->x0, rect->y0, rect->x1, rect->y1); + NSLOG(netsurf, INFO, "x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", + rect->x0, rect->y0, rect->x1, rect->y1); if (style->fill_type != PLOT_OP_TYPE_NONE) { int x0,y0,x1,y1; @@ -395,7 +396,7 @@ nsgtk_print_plot_polygon(const struct redraw_context *ctx, { unsigned int i; - LOG("Plotting polygon."); + NSLOG(netsurf, INFO, "Plotting polygon."); nsgtk_print_set_colour(style->fill_colour); nsgtk_print_set_solid(); @@ -403,11 +404,12 @@ nsgtk_print_plot_polygon(const struct redraw_context *ctx, cairo_set_line_width(gtk_print_current_cr, 0); cairo_move_to(gtk_print_current_cr, p[0], p[1]); - LOG("Starting line at: %i\t%i", p[0], p[1]); + NSLOG(netsurf, INFO, "Starting line at: %i\t%i", p[0], p[1]); for (i = 1; i != n; i++) { cairo_line_to(gtk_print_current_cr, p[i * 2], p[i * 2 + 1]); - LOG("Drawing line to: %i\t%i", p[i * 2], p[i * 2 + 1]); + NSLOG(netsurf, INFO, "Drawing line to: %i\t%i", p[i * 2], + p[i * 2 + 1]); } cairo_fill(gtk_print_current_cr); @@ -700,7 +702,7 @@ void gtk_print_signal_begin_print (GtkPrintOperation *operation, int page_number; double height_on_page, height_to_print; - LOG("Begin print"); + NSLOG(netsurf, INFO, "Begin print"); settings = user_data; @@ -719,7 +721,11 @@ void gtk_print_signal_begin_print (GtkPrintOperation *operation, } else { - LOG("page_width: %f ;page_height: %f; content height: %lf", settings->page_width, settings->page_height, height_to_print); + NSLOG(netsurf, INFO, + "page_width: %f ;page_height: %f; content height: %lf", + settings->page_width, + settings->page_height, + height_to_print); height_on_page = settings->page_height; height_on_page = height_on_page - @@ -743,7 +749,7 @@ void gtk_print_signal_begin_print (GtkPrintOperation *operation, void gtk_print_signal_draw_page(GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr, gpointer user_data) { - LOG("Draw Page"); + NSLOG(netsurf, INFO, "Draw Page"); gtk_print_current_cr = gtk_print_context_get_cairo_context(context); print_draw_next_page(>k_printer, settings); } @@ -755,7 +761,7 @@ void gtk_print_signal_draw_page(GtkPrintOperation *operation, void gtk_print_signal_end_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data) { - LOG("End print"); + NSLOG(netsurf, INFO, "End print"); print_cleanup(content_to_print, >k_printer, user_data); } diff --git a/frontends/gtk/resources.c b/frontends/gtk/resources.c index 4f9afb034..c07548b01 100644 --- a/frontends/gtk/resources.c +++ b/frontends/gtk/resources.c @@ -198,7 +198,8 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) /* found an entry in the resources */ resource->path = resname; resource->type = NSGTK_RESOURCE_GLIB; - LOG("Found gresource path %s", resource->path); + NSLOG(netsurf, INFO, "Found gresource path %s", + resource->path); return NSERROR_OK; } /*LOG("gresource \"%s\" not found", resname);*/ @@ -221,7 +222,8 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) /* found an entry in the resources */ resource->path = resname; resource->type = NSGTK_RESOURCE_GLIB; - LOG("Found gresource path %s", resource->path); + NSLOG(netsurf, INFO, "Found gresource path %s", + resource->path); return NSERROR_OK; } /*LOG("gresource \"%s\" not found", resname);*/ @@ -231,8 +233,9 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) resname = filepath_find(respath, resource->name); if (resname == NULL) { - LOG("Unable to find resource %s on resource path", - resource->name); + NSLOG(netsurf, INFO, + "Unable to find resource %s on resource path", + resource->name); return NSERROR_NOT_FOUND; } @@ -240,7 +243,7 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) resource->path = resname; resource->type = NSGTK_RESOURCE_FILE; - LOG("Found file resource path %s", resource->path); + NSLOG(netsurf, INFO, "Found file resource path %s", resource->path); return NSERROR_OK; } @@ -295,21 +298,21 @@ init_pixbuf_resource(char **respath, struct nsgtk_resource_s *resource) if (strncmp(resource->name, "menu_cursor.png", resource->len) == 0) { resource->path = (char *)&menu_cursor_pixdata[0]; resource->type = NSGTK_RESOURCE_INLINE; - LOG("Found builtin for %s", resource->name); + NSLOG(netsurf, INFO, "Found builtin for %s", resource->name); return NSERROR_OK; } if (strncmp(resource->name, "netsurf.xpm", resource->len) == 0) { resource->path = (char *)&netsurf_pixdata[0]; resource->type = NSGTK_RESOURCE_INLINE; - LOG("Found builtin for %s", resource->name); + NSLOG(netsurf, INFO, "Found builtin for %s", resource->name); return NSERROR_OK; } if (strncmp(resource->name, "favicon.png", resource->len) == 0) { resource->path = (char *)&favicon_pixdata[0]; resource->type = NSGTK_RESOURCE_INLINE; - LOG("Found builtin for %s", resource->name); + NSLOG(netsurf, INFO, "Found builtin for %s", resource->name); return NSERROR_OK; } #endif @@ -389,13 +392,13 @@ static void list_gresource(void) G_RESOURCE_LOOKUP_FLAGS_NONE, &gerror); if (gerror) { - LOG("gerror %s", gerror->message); + NSLOG(netsurf, INFO, "gerror %s", gerror->message); g_error_free(gerror); } else { cur = reslist; while (cur != NULL && *cur != NULL) { - LOG("gres %s", *cur); + NSLOG(netsurf, INFO, "gres %s", *cur); cur++; } g_strfreev(reslist); @@ -488,12 +491,17 @@ nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out) if (new_pixbuf == NULL) { if (error != NULL) { - LOG("Unable to create pixbuf from file for %s with path %s \"%s\"", - resource->name, resource->path, error->message); + NSLOG(netsurf, INFO, + "Unable to create pixbuf from file for %s with path %s \"%s\"", + resource->name, + resource->path, + error->message); g_error_free(error); } else { - LOG("Unable to create pixbuf from file for %s with path %s", - resource->name, resource->path); + NSLOG(netsurf, INFO, + "Unable to create pixbuf from file for %s with path %s", + resource->name, + resource->path); } return NSERROR_INIT_FAILED; } @@ -521,8 +529,11 @@ nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out) if (!gtk_builder_add_from_file(new_builder, ui_res->path, &error)) { - LOG("Unable to add UI builder from file for %s with path %s \"%s\"", - ui_res->name, ui_res->path, error->message); + NSLOG(netsurf, INFO, + "Unable to add UI builder from file for %s with path %s \"%s\"", + ui_res->name, + ui_res->path, + error->message); g_error_free(error); g_object_unref(G_OBJECT(new_builder)); return NSERROR_INIT_FAILED; @@ -531,8 +542,11 @@ nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out) if (!nsgtk_builder_add_from_resource(new_builder, ui_res->path, &error)) { - LOG("Unable to add UI builder from resource for %s with path %s \"%s\"", - ui_res->name, ui_res->path, error->message); + NSLOG(netsurf, INFO, + "Unable to add UI builder from resource for %s with path %s \"%s\"", + ui_res->name, + ui_res->path, + error->message); g_error_free(error); g_object_unref(G_OBJECT(new_builder)); return NSERROR_INIT_FAILED; diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c index 25f36c5d3..cbc46cbc5 100644 --- a/frontends/gtk/scaffolding.c +++ b/frontends/gtk/scaffolding.c @@ -269,7 +269,7 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data) { struct nsgtk_scaffolding *gs = data; - LOG("scaffold:%p", gs); + NSLOG(netsurf, INFO, "scaffold:%p", gs); nsgtk_local_history_hide(); @@ -282,7 +282,7 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data) gs->next->prev = gs->prev; } - LOG("scaffold list head: %p", scaf_list); + NSLOG(netsurf, INFO, "scaffold list head: %p", scaf_list); if (scaf_list == NULL) { /* no more open windows - stop the browser */ @@ -805,7 +805,10 @@ MULTIHANDLER(savepage) path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc)); d = opendir(path); if (d == NULL) { - LOG("Unable to open directory %s for complete save: %s", path, strerror(errno)); + NSLOG(netsurf, INFO, + "Unable to open directory %s for complete save: %s", + path, + strerror(errno)); if (errno == ENOTDIR) nsgtk_warning("NoDirError", path); else @@ -837,7 +840,7 @@ MULTIHANDLER(pdf) char *url_name; nserror res; - LOG("Print preview (generating PDF) started."); + NSLOG(netsurf, INFO, "Print preview (generating PDF) started."); res = nsurl_nice(browser_window_get_url(bw), &url_name, true); if (res != NSERROR_OK) { @@ -1221,10 +1224,10 @@ MULTIHANDLER(selectall) struct browser_window *bw = nsgtk_get_browser_window(g->top_level); if (nsgtk_widget_has_focus(GTK_WIDGET(g->url_bar))) { - LOG("Selecting all URL bar text"); + NSLOG(netsurf, INFO, "Selecting all URL bar text"); gtk_editable_select_region(GTK_EDITABLE(g->url_bar), 0, -1); } else { - LOG("Selecting all document text"); + NSLOG(netsurf, INFO, "Selecting all document text"); browser_window_key_press(bw, NS_KEY_SELECT_ALL); } @@ -1590,7 +1593,8 @@ MULTIHANDLER(localhistory) res = nsgtk_local_history_present(g->window, bw); if (res != NSERROR_OK) { - LOG("Unable to initialise local history window."); + NSLOG(netsurf, INFO, + "Unable to initialise local history window."); } return TRUE; } @@ -1600,7 +1604,8 @@ MULTIHANDLER(globalhistory) nserror res; res = nsgtk_global_history_present(); if (res != NSERROR_OK) { - LOG("Unable to initialise global history window."); + NSLOG(netsurf, INFO, + "Unable to initialise global history window."); } return TRUE; } @@ -1620,7 +1625,7 @@ MULTIHANDLER(showbookmarks) nserror res; res = nsgtk_hotlist_present(); if (res != NSERROR_OK) { - LOG("Unable to initialise bookmark window."); + NSLOG(netsurf, INFO, "Unable to initialise bookmark window."); } return TRUE; } @@ -1630,7 +1635,7 @@ MULTIHANDLER(showcookies) nserror res; res = nsgtk_cookies_present(); if (res != NSERROR_OK) { - LOG("Unable to initialise cookies window."); + NSLOG(netsurf, INFO, "Unable to initialise cookies window."); } return TRUE; } @@ -2073,7 +2078,8 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) return NULL; } - LOG("Constructing a scaffold of %p for gui_window %p", gs, toplevel); + NSLOG(netsurf, INFO, + "Constructing a scaffold of %p for gui_window %p", gs, toplevel); gs->top_level = toplevel; @@ -2278,7 +2284,7 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) /* finally, show the window. */ gtk_widget_show(GTK_WIDGET(gs->window)); - LOG("creation complete"); + NSLOG(netsurf, INFO, "creation complete"); return gs; } @@ -2466,7 +2472,8 @@ gui_search_web_provider_update(const char *provider_name, GdkPixbuf *srch_pixbuf = NULL; char *searchcontent; - LOG("name:%s bitmap %p", provider_name, provider_bitmap); + NSLOG(netsurf, INFO, "name:%s bitmap %p", provider_name, + provider_bitmap); if (provider_bitmap != NULL) { srch_pixbuf = nsgdk_pixbuf_get_from_surface(provider_bitmap->surface, 16, 16); diff --git a/frontends/gtk/schedule.c b/frontends/gtk/schedule.c index cf0333388..201432097 100644 --- a/frontends/gtk/schedule.c +++ b/frontends/gtk/schedule.c @@ -21,14 +21,10 @@ #include #include "utils/errors.h" +#include "utils/log.h" #include "gtk/schedule.h" -#ifdef DEBUG_GTK_SCHEDULE -#include "utils/log.h" -#else -#define LOG(format, args...) ((void) 0) -#endif /** Killable callback closure embodiment. */ typedef struct { @@ -50,7 +46,7 @@ nsgtk_schedule_generic_callback(gpointer data) _nsgtk_callback_t *cb = (_nsgtk_callback_t *)(data); if (cb->callback_killed) { /* This callback instance has been killed. */ - LOG("CB at %p already dead.", cb); + NSLOG(netsurf, DEBUG, "CB at %p already dead.", cb); } queued_callbacks = g_list_remove(queued_callbacks, cb); pending_callbacks = g_list_append(pending_callbacks, cb); @@ -64,7 +60,8 @@ nsgtk_schedule_kill_callback(void *_target, void *_match) _nsgtk_callback_t *match = (_nsgtk_callback_t *)_match; if ((target->callback == match->callback) && (target->context == match->context)) { - LOG("Found match for %p(%p), killing.", target->callback, target->context); + NSLOG(netsurf, DEBUG, "Found match for %p(%p), killing.", + target->callback, target->context); target->callback = NULL; target->context = NULL; target->callback_killed = true; @@ -122,7 +119,8 @@ schedule_run(void) /* Clear the pending list. */ pending_callbacks = NULL; - LOG("Captured a run of %d callbacks to fire.", g_list_length(this_run)); + NSLOG(netsurf, DEBUG, "Captured a run of %d callbacks to fire.", + g_list_length(this_run)); /* Run all the callbacks which made it this far. */ while (this_run != NULL) { diff --git a/frontends/gtk/ssl_cert.c b/frontends/gtk/ssl_cert.c index 5388f0194..9d98db1f6 100644 --- a/frontends/gtk/ssl_cert.c +++ b/frontends/gtk/ssl_cert.c @@ -183,7 +183,7 @@ nserror gtk_cert_verify(struct nsurl *url, res = nsgtk_builder_new_from_resname("ssl", &ncwin->builder); if (res != NSERROR_OK) { - LOG("SSL UI builder init failed"); + NSLOG(netsurf, INFO, "SSL UI builder init failed"); free(ncwin); return res; } diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c index 6adce3a06..dbe9d405b 100644 --- a/frontends/gtk/tabs.c +++ b/frontends/gtk/tabs.c @@ -147,18 +147,20 @@ nsgtk_tab_switch_page_after(GtkNotebook *notebook, if ((srcpagenum != -1) && (srcpagenum != (gint)selpagenum)) { /* ensure the add tab is not actually selected */ - LOG("src %d sel %d", srcpagenum, selpagenum); + NSLOG(netsurf, INFO, "src %d sel %d", srcpagenum, + selpagenum); srcpage = gtk_notebook_get_nth_page(notebook, srcpagenum); gw = g_object_get_data(G_OBJECT(srcpage), "gui_window"); if ((gw != NULL) && (nsgtk_get_scaffold(gw) != NULL)) { error = nsgtk_scaffolding_new_tab(gw); if (error != NSERROR_OK) { - LOG("Failed to open new tab."); + NSLOG(netsurf, INFO, + "Failed to open new tab."); } } } } else { - LOG("sel %d", selpagenum); + NSLOG(netsurf, INFO, "sel %d", selpagenum); /* tab with page in it */ gw = g_object_get_data(G_OBJECT(selpage), "gui_window"); if (gw != NULL) { diff --git a/frontends/gtk/throbber.c b/frontends/gtk/throbber.c index 9392c3909..b8efceca1 100644 --- a/frontends/gtk/throbber.c +++ b/frontends/gtk/throbber.c @@ -59,12 +59,14 @@ nserror nsgtk_throbber_init(void) if (res != NSERROR_OK) { break; } - LOG("%s",resname); + NSLOG(netsurf, INFO, "%s", resname); } if (frame < 1) { /* we need at least two frames - one for idle, one for active */ - LOG("Insufficent number of frames (%d) in throbber animation.", frame); + NSLOG(netsurf, INFO, + "Insufficent number of frames (%d) in throbber animation.", + frame); res = NSERROR_INIT_FAILED; } diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c index 1f8dbbb7c..0ca26c92d 100644 --- a/frontends/gtk/toolbar.c +++ b/frontends/gtk/toolbar.c @@ -971,7 +971,8 @@ static nserror nsgtk_toolbar_customization_save(struct nsgtk_scaffolding *g) nsgtk_scaffolding_button(g, tbidx)->location); if (plen == order_len) { /* ran out of space, bail early */ - LOG("toolbar ordering exceeded available space"); + NSLOG(netsurf, INFO, + "toolbar ordering exceeded available space"); break; } cur += plen; @@ -1110,7 +1111,7 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g) res = nsgtk_builder_new_from_resname("toolbar", &window->builder); if (res != NSERROR_OK) { - LOG("Toolbar UI builder init failed"); + NSLOG(netsurf, INFO, "Toolbar UI builder init failed"); nsgtk_warning(messages_get("NoMemory"), 0); nsgtk_toolbar_cancel_clicked(NULL, g); free(theme); diff --git a/frontends/gtk/viewdata.c b/frontends/gtk/viewdata.c index 6ed9dd9ac..d633238d0 100644 --- a/frontends/gtk/viewdata.c +++ b/frontends/gtk/viewdata.c @@ -371,7 +371,7 @@ window_init(const char *title, res = nsgtk_builder_new_from_resname("viewdata", &newctx->builder); if (res != NSERROR_OK) { - LOG("Viewdata UI builder init failed"); + NSLOG(netsurf, INFO, "Viewdata UI builder init failed"); free(newctx); return res; } @@ -381,7 +381,7 @@ window_init(const char *title, window = GTK_WINDOW(gtk_builder_get_object(newctx->builder, "ViewDataWindow")); if (window == NULL) { - LOG("Unable to find window in builder "); + NSLOG(netsurf, INFO, "Unable to find window in builder "); /* free the builder */ g_object_unref(G_OBJECT(newctx->builder)); @@ -616,7 +616,7 @@ static char** xdg_data_strvec(void) xdg_data_home, xdg_data_dirs); } - LOG("%s", xdg_data_path); + NSLOG(netsurf, INFO, "%s", xdg_data_path); svec = filepath_path_to_strvec(xdg_data_path); free(xdg_data_path); @@ -651,7 +651,7 @@ static char *xdg_get_default_app(const char *path, const char *mimetype) fname = malloc(fname_len); snprintf(fname, fname_len, "%s/applications/defaults.list", path); - LOG("Checking %s", fname); + NSLOG(netsurf, INFO, "Checking %s", fname); fp = fopen(fname, "r"); free(fname); @@ -674,8 +674,11 @@ static char *xdg_get_default_app(const char *path, const char *mimetype) ret = strdup(line + mimetype_len + 1); - LOG("Found line match for %s length %zu\n", mimetype, rd); - LOG("Result %s", ret); + NSLOG(netsurf, INFO, + "Found line match for %s length %zu\n", + mimetype, + rd); + NSLOG(netsurf, INFO, "Result %s", ret); break; } @@ -714,7 +717,7 @@ static char *xdg_get_exec_cmd(const char *path, const char *desktop) fname = malloc(fname_len); snprintf(fname, fname_len, "%s/applications/%s", path, desktop); - LOG("Checking %s", fname); + NSLOG(netsurf, INFO, "Checking %s", fname); fp = fopen(fname, "r"); free(fname); @@ -735,8 +738,8 @@ static char *xdg_get_exec_cmd(const char *path, const char *desktop) ret = strdup(line + SLEN("Exec=")); - LOG("Found Exec length %zu", rd); - LOG("Result %s", ret); + NSLOG(netsurf, INFO, "Found Exec length %zu", rd); + NSLOG(netsurf, INFO, "Result %s", ret); break; } @@ -801,7 +804,7 @@ static char **build_exec_argv(const char *fname, const char *exec_cmd) argv[aidx] = exec_arg(start, cur - start, fname); if (argv[aidx] != NULL) { - LOG("adding \"%s\"", argv[aidx]); + NSLOG(netsurf, INFO, "adding \"%s\"", argv[aidx]); aidx++; } } diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c index d32f4573a..7f24d40ac 100644 --- a/frontends/gtk/window.c +++ b/frontends/gtk/window.c @@ -458,7 +458,7 @@ nsgtk_window_scroll_event(GtkWidget *widget, break; #endif default: - LOG("Unhandled mouse scroll direction"); + NSLOG(netsurf, INFO, "Unhandled mouse scroll direction"); return TRUE; } @@ -741,7 +741,7 @@ gui_window_create(struct browser_window *bw, res = nsgtk_builder_new_from_resname("tabcontents", &tab_builder); if (res != NSERROR_OK) { - LOG("Tab contents UI builder init failed"); + NSLOG(netsurf, INFO, "Tab contents UI builder init failed"); return NULL; } @@ -754,7 +754,8 @@ gui_window_create(struct browser_window *bw, return NULL; } - LOG("Creating gui window %p for browser window %p", g, bw); + NSLOG(netsurf, INFO, "Creating gui window %p for browser window %p", + g, bw); g->bw = bw; g->mouse.state = 0; @@ -903,10 +904,10 @@ void nsgtk_window_destroy_browser(struct gui_window *gw) static void gui_window_destroy(struct gui_window *g) { - LOG("gui_window: %p", g); + NSLOG(netsurf, INFO, "gui_window: %p", g); assert(g != NULL); assert(g->bw != NULL); - LOG("scaffolding: %p", g->scaffold); + NSLOG(netsurf, INFO, "scaffolding: %p", g->scaffold); if (g->prev) { g->prev->next = g->next; @@ -918,7 +919,7 @@ static void gui_window_destroy(struct gui_window *g) g->next->prev = g->prev; } - LOG("window list head: %p", window_list); + NSLOG(netsurf, INFO, "window list head: %p", window_list); } /** @@ -940,13 +941,13 @@ static void gui_window_set_icon(struct gui_window *gw, struct hlcache_handle *ic if (icon != NULL) { icon_bitmap = content_get_bitmap(icon); if (icon_bitmap != NULL) { - LOG("Using %p bitmap", icon_bitmap); + NSLOG(netsurf, INFO, "Using %p bitmap", icon_bitmap); gw->icon = nsgdk_pixbuf_get_from_surface(icon_bitmap->surface, 16, 16); } } if (gw->icon == NULL) { - LOG("Using default favicon"); + NSLOG(netsurf, INFO, "Using default favicon"); g_object_ref(favicon_pixbuf); gw->icon = favicon_pixbuf; } @@ -1236,7 +1237,7 @@ gui_window_get_dimensions(struct gui_window *gw, *width /= scale; *height /= scale; } - LOG("gw:%p width:%i height:%i", gw, *width, *height); + NSLOG(netsurf, INFO, "gw:%p width:%i height:%i", gw, *width, *height); return NSERROR_OK; } @@ -1269,8 +1270,8 @@ static void gui_window_create_form_select_menu(struct gui_window *g, item = 0; option = form_select_get_option(control, item); while (option != NULL) { - LOG("Item %"PRIdPTR" option %p text %s", - item, option, option->text); + NSLOG(netsurf, INFO, "Item %"PRIdPTR" option %p text %s", + item, option, option->text); menu_item = gtk_check_menu_item_new_with_label(option->text); if (option->selected) { gtk_check_menu_item_set_active( @@ -1313,10 +1314,10 @@ gui_window_file_gadget_open(struct gui_window *g, NSGTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - LOG("*** open dialog: %p", dialog); + NSLOG(netsurf, INFO, "*** open dialog: %p", dialog); int ret = gtk_dialog_run(GTK_DIALOG(dialog)); - LOG("*** return value: %d", ret); + NSLOG(netsurf, INFO, "*** return value: %d", ret); if (ret == GTK_RESPONSE_ACCEPT) { char *filename; diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c index 16d33010d..1fbbbf0b1 100644 --- a/frontends/monkey/browser.c +++ b/frontends/monkey/browser.c @@ -471,7 +471,7 @@ monkey_window_handle_redraw(int argc, char **argv) clip.y1 = atoi(argv[6]); } - LOG("Issue redraw"); + NSLOG(netsurf, INFO, "Issue redraw"); fprintf(stdout, "WINDOW REDRAW WIN %d START\n", atoi(argv[2])); browser_window_redraw(gw->bw, gw->scrollx, gw->scrolly, &clip, &ctx); fprintf(stdout, "WINDOW REDRAW WIN %d STOP\n", atoi(argv[2])); diff --git a/frontends/monkey/dispatch.c b/frontends/monkey/dispatch.c index b531f05f9..e60325cf1 100644 --- a/frontends/monkey/dispatch.c +++ b/frontends/monkey/dispatch.c @@ -40,7 +40,7 @@ monkey_register_handler(const char *cmd, handle_command_fn fn) { monkey_cmdhandler_t *ret = calloc(sizeof(*ret), 1); if (ret == NULL) { - LOG("Unable to allocate handler"); + NSLOG(netsurf, INFO, "Unable to allocate handler"); return NSERROR_NOMEM; } ret->cmd = strdup(cmd); diff --git a/frontends/monkey/filetype.c b/frontends/monkey/filetype.c index 20bd1edad..979796baf 100644 --- a/frontends/monkey/filetype.c +++ b/frontends/monkey/filetype.c @@ -85,7 +85,8 @@ void monkey_fetch_filetype_init(const char *mimefile) fh = fopen(mimefile, "r"); if (fh == NULL) { - LOG("Unable to open a mime.types file, so using a minimal one for you."); + NSLOG(netsurf, INFO, + "Unable to open a mime.types file, so using a minimal one for you."); return; } diff --git a/frontends/monkey/main.c b/frontends/monkey/main.c index 1bea02471..d697f271f 100644 --- a/frontends/monkey/main.c +++ b/frontends/monkey/main.c @@ -278,20 +278,20 @@ static void monkey_run(void) /* setup timeout */ switch (schedtm) { case -1: - LOG("Iterate blocking"); + NSLOG(netsurf, INFO, "Iterate blocking"); fprintf(stdout, "GENERIC POLL BLOCKING\n"); timeout = NULL; break; case 0: - LOG("Iterate immediate"); + NSLOG(netsurf, INFO, "Iterate immediate"); tv.tv_sec = 0; tv.tv_usec = 0; timeout = &tv; break; default: - LOG("Iterate non-blocking"); + NSLOG(netsurf, INFO, "Iterate non-blocking"); fprintf(stdout, "GENERIC POLL TIMED %d\n", schedtm); tv.tv_sec = schedtm / 1000; /* miliseconds to seconds */ tv.tv_usec = (schedtm % 1000) * 1000; /* remainder to microseconds */ @@ -361,7 +361,7 @@ main(int argc, char **argv) messages = filepath_find(respaths, "Messages"); ret = messages_add_from_file(messages); if (ret != NSERROR_OK) { - LOG("Messages failed to load"); + NSLOG(netsurf, INFO, "Messages failed to load"); } /* common initialisation */ diff --git a/frontends/monkey/schedule.c b/frontends/monkey/schedule.c index af1144a0e..b34bd5aa5 100644 --- a/frontends/monkey/schedule.c +++ b/frontends/monkey/schedule.c @@ -204,13 +204,14 @@ void monkey_schedule_list(void) gettimeofday(&tv, NULL); - LOG("schedule list at %lld:%ld", (long long)tv.tv_sec, tv.tv_usec); + NSLOG(netsurf, INFO, "schedule list at %lld:%ld", + (long long)tv.tv_sec, tv.tv_usec); cur_nscb = schedule_list; while (cur_nscb != NULL) { - LOG("Schedule %p at %lld:%ld", - cur_nscb, (long long)cur_nscb->tv.tv_sec, cur_nscb->tv.tv_usec); + NSLOG(netsurf, INFO, "Schedule %p at %lld:%ld", cur_nscb, + (long long)cur_nscb->tv.tv_sec, cur_nscb->tv.tv_usec); cur_nscb = cur_nscb->next; } } diff --git a/frontends/riscos/401login.c b/frontends/riscos/401login.c index a23c01c90..4b2deb16b 100644 --- a/frontends/riscos/401login.c +++ b/frontends/riscos/401login.c @@ -191,7 +191,8 @@ void ro_gui_401login_close(wimp_w w) error = xwimp_delete_window(w); if (error) { - LOG("xwimp_delete_window: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } ro_gui_wimp_event_finalise(w); @@ -212,7 +213,7 @@ bool ro_gui_401login_apply(wimp_w w) auth = malloc(strlen(session->uname) + strlen(session->pwd) + 2); if (!auth) { - LOG("calloc failed"); + NSLOG(netsurf, INFO, "calloc failed"); ro_warn_user("NoMemory", 0); return false; } diff --git a/frontends/riscos/bitmap.c b/frontends/riscos/bitmap.c index 1a3524633..d554d54b4 100644 --- a/frontends/riscos/bitmap.c +++ b/frontends/riscos/bitmap.c @@ -287,7 +287,10 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags) error = xosspriteop_save_sprite_file(osspriteop_USER_AREA, (bitmap->sprite_area), path); if (error) { - LOG("xosspriteop_save_sprite_file: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_save_sprite_file: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("SaveError", error->errmess); return false; } @@ -347,7 +350,8 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags) error = xosfind_openoutw(0, path, NULL, &fw); if (error) { - LOG("xosfind_openoutw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_openoutw: 0x%x: %s", + error->errnum, error->errmess); free(chunk_buf); ro_warn_user("SaveError", error->errmess); return false; @@ -361,7 +365,8 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags) if (!error) error = xosgbpb_writew(fw, (byte*)p, image_size, NULL); if (error) { - LOG("xosgbpb_writew: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosgbpb_writew: 0x%x: %s", + error->errnum, error->errmess); free(chunk_buf); xosfind_closew(fw); ro_warn_user("SaveError", error->errmess); @@ -406,7 +411,10 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags) } error = xosgbpb_writew(fw, (byte*)chunk_buf, dp-chunk_buf, NULL); if (error) { - LOG("xosgbpb_writew: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosgbpb_writew: 0x%x: %s", + error->errnum, + error->errmess); free(chunk_buf); xosfind_closew(fw); ro_warn_user("SaveError", error->errmess); @@ -416,13 +424,15 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags) error = xosfind_closew(fw); if (error) { - LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); } error = xosfile_set_type(path, osfile_TYPE_SPRITE); if (error) { - LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); } @@ -509,7 +519,8 @@ void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, (osspriteop_id)s, &w, &h, NULL, NULL); if (error) { - LOG("xosspriteop_read_sprite_info: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosspriteop_read_sprite_info: 0x%x:%s", + error->errnum, error->errmess); return; } sp_offset = ((s->width + 1) * 4) - w; @@ -591,7 +602,7 @@ static osspriteop_area *thumbnail_create_8bpp(struct bitmap *bitmap) sprite_area = (osspriteop_area *)malloc(area_size); if (!sprite_area) { - LOG("no memory for malloc()"); + NSLOG(netsurf, INFO, "no memory for malloc()"); return NULL; } sprite_area->size = area_size; @@ -759,7 +770,8 @@ static void thumbnail_test(void) area_size = sizeof(osspriteop_area) + sizeof(osspriteop_header) + sizeof(int); if ((sprite_area = (osspriteop_area *)malloc(area_size)) == NULL) { - LOG("Insufficient memory to perform sprite test."); + NSLOG(netsurf, INFO, + "Insufficient memory to perform sprite test."); return; } sprite_area->size = area_size + 1; @@ -791,7 +803,7 @@ nserror riscos_bitmap_render(struct bitmap *bitmap, assert(content); assert(bitmap); - LOG("content %p in bitmap %p", content, bitmap); + NSLOG(netsurf, INFO, "content %p in bitmap %p", content, bitmap); /* check if we have access to 32bpp sprites natively */ if (thumbnail_32bpp_available == -1) { diff --git a/frontends/riscos/buffer.c b/frontends/riscos/buffer.c index 7176c1c1c..c63a270db 100644 --- a/frontends/riscos/buffer.c +++ b/frontends/riscos/buffer.c @@ -107,7 +107,12 @@ void ro_gui_buffer_open(wimp_draw *redraw) */ if ((clipping.x1 < clipping.x0) || (clipping.y1 < clipping.y0)) { - LOG("Invalid clipping rectangle (%i, %i) to (%i,%i)", clipping.x0, clipping.y0, clipping.x1, clipping.y1); + NSLOG(netsurf, INFO, + "Invalid clipping rectangle (%i, %i) to (%i,%i)", + clipping.x0, + clipping.y0, + clipping.x1, + clipping.y1); return; } @@ -138,7 +143,7 @@ void ro_gui_buffer_open(wimp_draw *redraw) (word_width * sprite_size.y * 4) + palette_size; buffer = (osspriteop_area *)malloc(total_size); if (!buffer) { - LOG("Failed to allocate memory"); + NSLOG(netsurf, INFO, "Failed to allocate memory"); ro_gui_buffer_free(); return; } @@ -149,7 +154,8 @@ void ro_gui_buffer_open(wimp_draw *redraw) mode = tinct_SPRITE_MODE; #else if ((error = xwimpreadsysinfo_wimp_mode(&mode)) != NULL) { - LOG("Error reading mode '%s'", error->errmess); + NSLOG(netsurf, INFO, "Error reading mode '%s'", + error->errmess); ro_gui_buffer_free(); return; } @@ -177,7 +183,9 @@ void ro_gui_buffer_open(wimp_draw *redraw) error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), (int *)&vals); if (error) { - LOG("Error reading mode properties '%s'", error->errmess); + NSLOG(netsurf, INFO, + "Error reading mode properties '%s'", + error->errmess); ro_gui_buffer_free(); return; } @@ -233,7 +241,9 @@ void ro_gui_buffer_open(wimp_draw *redraw) } break; default: - LOG("Unhandled 16bpp format from flags %d", vals.flags); + NSLOG(netsurf, INFO, + "Unhandled 16bpp format from flags %d", + vals.flags); ro_gui_buffer_free(); return; } @@ -261,13 +271,16 @@ void ro_gui_buffer_open(wimp_draw *redraw) } break; default: - LOG("Unhandled 32bpp data format from flags %d", vals.flags); + NSLOG(netsurf, INFO, + "Unhandled 32bpp data format from flags %d", + vals.flags); ro_gui_buffer_free(); return; } break; default: - LOG("Unhandled NCOLOUR value %d", vals.ncolour); + NSLOG(netsurf, INFO, "Unhandled NCOLOUR value %d", + vals.ncolour); ro_gui_buffer_free(); return; } @@ -305,7 +318,7 @@ void ro_gui_buffer_open(wimp_draw *redraw) buffer, buffer_name, palette, clipping.x0, clipping.y0, clipping.x1, clipping.y1)) != NULL) { - LOG("Grab error '%s'", error->errmess); + NSLOG(netsurf, INFO, "Grab error '%s'", error->errmess); ro_gui_buffer_free(); return; } @@ -314,7 +327,7 @@ void ro_gui_buffer_open(wimp_draw *redraw) */ if ((error = xosspriteop_read_save_area_size(osspriteop_PTR, buffer, (osspriteop_id)(buffer + 1), &size)) != NULL) { - LOG("Save area error '%s'", error->errmess); + NSLOG(netsurf, INFO, "Save area error '%s'", error->errmess); ro_gui_buffer_free(); return; } @@ -329,7 +342,7 @@ void ro_gui_buffer_open(wimp_draw *redraw) if ((error = xosspriteop_switch_output_to_sprite(osspriteop_PTR, buffer, (osspriteop_id)(buffer + 1), save_area, &context0, &context1, &context2, &context3)) != NULL) { - LOG("Switching error '%s'", error->errmess); + NSLOG(netsurf, INFO, "Switching error '%s'", error->errmess); free(save_area); ro_gui_buffer_free(); return; @@ -345,7 +358,8 @@ void ro_gui_buffer_open(wimp_draw *redraw) */ if ((error = xos_set_ecf_origin(-ro_plot_origin_x, -ro_plot_origin_y)) != NULL) { - LOG("Invalid ECF origin: '%s'", error->errmess); + NSLOG(netsurf, INFO, "Invalid ECF origin: '%s'", + error->errmess); } } diff --git a/frontends/riscos/configure.c b/frontends/riscos/configure.c index 9d28616ec..f4dced55b 100644 --- a/frontends/riscos/configure.c +++ b/frontends/riscos/configure.c @@ -212,7 +212,10 @@ void ro_gui_configure_open_window(wimp_open *open) y + configure_icon_height - CONFIGURE_ICON_PADDING_V); if (error) { - LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_resize_icon: 0x%x: %s", + error->errnum, + error->errmess); } x += configure_icon_width; l++; @@ -225,7 +228,8 @@ void ro_gui_configure_open_window(wimp_open *open) error = xwimp_force_redraw(configure_window, 0, -16384, 16384, 0); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -248,7 +252,8 @@ void ro_gui_configure_open_window(wimp_open *open) extent.y0 = -max_height; error = xwimp_set_extent(open->w, &extent); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -259,7 +264,8 @@ void ro_gui_configure_open_window(wimp_open *open) /* open the window */ error = xwimp_open_window(open); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -276,7 +282,7 @@ void ro_gui_configure_register(const char *window, /* create our tool */ tool = calloc(sizeof(struct configure_tool), 1); if (!tool) { - LOG("Insufficient memory for calloc()"); + NSLOG(netsurf, INFO, "Insufficient memory for calloc()"); die("Insufficient memory"); return; /* For the benefit of scan-build */ } @@ -284,7 +290,7 @@ void ro_gui_configure_register(const char *window, tool->translated[0] = '\0'; tool->validation = malloc(strlen(window) + 2); if (!tool->validation) { - LOG("Insufficient memory for malloc()"); + NSLOG(netsurf, INFO, "Insufficient memory for malloc()"); die("Insufficient memory"); } sprintf(tool->validation, "S%s", window); @@ -311,7 +317,8 @@ void ro_gui_configure_register(const char *window, CONFIGURE_TOOL_TRANSLATED_SIZE; error = xwimp_create_icon(&new_icon, &tool->i); if (error) { - LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s", + error->errnum, error->errmess); die(error->errmess); } @@ -360,7 +367,8 @@ bool ro_gui_configure_translate(void) error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0, &alphabet); if (error) { - LOG("failed reading alphabet: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "failed reading alphabet: 0x%x: %s", + error->errnum, error->errmess); /* assume Latin1 */ alphabet = territory_ALPHABET_LATIN1; } @@ -381,7 +389,10 @@ bool ro_gui_configure_translate(void) error = xwimptextop_string_width(tool->translated, strlen(tool->translated), &icon_width); if (error) { - LOG("xwimptextop_string_width: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimptextop_string_width: 0x%x: %s", + error->errnum, + error->errmess); return false; } icon_width += CONFIGURE_ICON_PADDING_H; @@ -395,7 +406,8 @@ bool ro_gui_configure_translate(void) configure_icon_width, 0); if (error) { - LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s", + error->errnum, error->errmess); } } diff --git a/frontends/riscos/configure/con_language.c b/frontends/riscos/configure/con_language.c index 2030c65c0..77e4f6cb4 100644 --- a/frontends/riscos/configure/con_language.c +++ b/frontends/riscos/configure/con_language.c @@ -98,7 +98,8 @@ bool ro_gui_options_language_ok(wimp_w w) if (temp) { nsoption_set_charp(language, temp); } else { - LOG("No memory to duplicate language code"); + NSLOG(netsurf, INFO, + "No memory to duplicate language code"); ro_warn_user("NoMemory", 0); } } @@ -113,7 +114,8 @@ bool ro_gui_options_language_ok(wimp_w w) if (temp) { nsoption_set_charp(accept_language,temp); } else { - LOG("No memory to duplicate language code"); + NSLOG(netsurf, INFO, + "No memory to duplicate language code"); ro_warn_user("NoMemory", 0); } } diff --git a/frontends/riscos/configure/con_theme.c b/frontends/riscos/configure/con_theme.c index fb0d3dfb0..28195dea9 100644 --- a/frontends/riscos/configure/con_theme.c +++ b/frontends/riscos/configure/con_theme.c @@ -104,20 +104,23 @@ bool ro_gui_options_theme_initialise(wimp_w w) return false; error = xwimp_create_window(&theme_pane_definition, &theme_pane); if (error) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); return false; } state.w = w; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return false; } icon_state.w = w; icon_state.i = THEME_PANE_AREA; error = xwimp_get_icon_state(&icon_state); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); return false; } state.w = theme_pane; @@ -126,7 +129,8 @@ bool ro_gui_options_theme_initialise(wimp_w w) state.visible.x0 += icon_state.icon.extent.x0 + 16; state.visible.y0 = state.visible.y1 + icon_state.icon.extent.y0 + 16; state.visible.y1 += icon_state.icon.extent.y1 - 28; - LOG("Y0 = %i, y1 = %i", icon_state.icon.extent.y0, icon_state.icon.extent.y1); + NSLOG(netsurf, INFO, "Y0 = %i, y1 = %i", icon_state.icon.extent.y0, + icon_state.icon.extent.y1); error = xwimp_open_window_nested(PTR_WIMP_OPEN(&state), w, wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_XORIGIN_SHIFT | @@ -141,7 +145,8 @@ bool ro_gui_options_theme_initialise(wimp_w w) wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT << wimp_CHILD_TS_EDGE_SHIFT); if (error) { - LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window_nested: 0x%x: %s", + error->errnum, error->errmess); return false; } @@ -176,7 +181,8 @@ void ro_gui_options_theme_finalise(wimp_w w) ro_gui_wimp_event_finalise(theme_pane); error = xwimp_delete_window(theme_pane); if (error) { - LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } theme_pane = 0; @@ -269,7 +275,7 @@ void ro_gui_options_theme_load(void) ro_toolbar_rebuild(toolbar); toolbar_display = calloc(sizeof(struct toolbar_display), 1); if (!toolbar_display) { - LOG("No memory for calloc()"); + NSLOG(netsurf, INFO, "No memory for calloc()"); ro_warn_user("NoMemory", 0); return; } @@ -291,7 +297,8 @@ void ro_gui_options_theme_load(void) state.w = theme_pane; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } diff --git a/frontends/riscos/content-handlers/artworks.c b/frontends/riscos/content-handlers/artworks.c index d6f6da318..8ec4edcae 100644 --- a/frontends/riscos/content-handlers/artworks.c +++ b/frontends/riscos/content-handlers/artworks.c @@ -183,7 +183,7 @@ bool artworks_convert(struct content *c) xos_read_var_val_size("Alias$LoadArtWorksModules", 0, os_VARTYPE_STRING, &used, NULL, NULL); if (used >= 0) { - LOG("Alias$LoadArtWorksModules not defined"); + NSLOG(netsurf, INFO, "Alias$LoadArtWorksModules not defined"); msg_data.error = messages_get("AWNotSeen"); content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; @@ -192,7 +192,8 @@ bool artworks_convert(struct content *c) /* load the modules, or do nothing if they're already loaded */ error = xos_cli("LoadArtWorksModules"); if (error) { - LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_cli: 0x%x: %s", error->errnum, + error->errmess); msg_data.error = error->errmess; content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; @@ -202,7 +203,8 @@ bool artworks_convert(struct content *c) error = (os_error*)_swix(AWRender_FileInitAddress, _OUT(0) | _OUT(1), &init_routine, &init_workspace); if (error) { - LOG("AWRender_FileInitAddress: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "AWRender_FileInitAddress: 0x%x: %s", + error->errnum, error->errmess); msg_data.error = error->errmess; content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; @@ -212,7 +214,8 @@ bool artworks_convert(struct content *c) &aw->render_routine, &aw->render_workspace); if (error) { - LOG("AWRender_RenderAddress: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "AWRender_RenderAddress: 0x%x: %s", + error->errnum, error->errmess); msg_data.error = error->errmess; content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; @@ -224,7 +227,8 @@ bool artworks_convert(struct content *c) error = awrender_init(&source_data, &source_size, init_routine, init_workspace); if (error) { - LOG("awrender_init: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "awrender_init: 0x%x : %s", + error->errnum, error->errmess); msg_data.error = error->errmess; content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; @@ -239,13 +243,15 @@ bool artworks_convert(struct content *c) &aw->y1); if (error) { - LOG("AWRender_DocBounds: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "AWRender_DocBounds: 0x%x: %s", + error->errnum, error->errmess); msg_data.error = error->errmess; content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; } - LOG("bounding box: %d,%d,%d,%d", aw->x0, aw->y0, aw->x1, aw->y1); + NSLOG(netsurf, INFO, "bounding box: %d,%d,%d,%d", aw->x0, aw->y0, + aw->x1, aw->y1); /* create the resizable workspace required by the ArtWorksRenderer rendering routine */ @@ -253,7 +259,8 @@ bool artworks_convert(struct content *c) aw->size = INITIAL_BLOCK_SIZE; aw->block = malloc(INITIAL_BLOCK_SIZE); if (!aw->block) { - LOG("failed to create block for ArtworksRenderer"); + NSLOG(netsurf, INFO, + "failed to create block for ArtworksRenderer"); msg_data.error = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; @@ -368,13 +375,15 @@ bool artworks_redraw(struct content *c, struct content_redraw_data *data, error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), vals); if (error) { - LOG("xos_read_vdu_variables: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_read_vdu_variables: 0x%x: %s", + error->errnum, error->errmess); return false; } error = xwimp_read_palette((os_palette*)&vals[3]); if (error) { - LOG("xwimp_read_palette: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_read_palette: 0x%x: %s", + error->errnum, error->errmess); return false; } @@ -393,7 +402,8 @@ bool artworks_redraw(struct content *c, struct content_redraw_data *data, aw->render_workspace); if (error) { - LOG("awrender_render: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "awrender_render: 0x%x: %s", + error->errnum, error->errmess); return false; } diff --git a/frontends/riscos/content-handlers/draw.c b/frontends/riscos/content-handlers/draw.c index 4627b19c0..bb66f9dbb 100644 --- a/frontends/riscos/content-handlers/draw.c +++ b/frontends/riscos/content-handlers/draw.c @@ -126,7 +126,8 @@ bool draw_convert(struct content *c) error = xdrawfile_bbox(0, (drawfile_diagram *) data, (int) source_size, 0, &bbox); if (error) { - LOG("xdrawfile_bbox: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xdrawfile_bbox: 0x%x: %s", + error->errnum, error->errmess); msg_data.error = error->errmess; content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; @@ -208,7 +209,8 @@ bool draw_redraw(struct content *c, struct content_redraw_data *data, error = xdrawfile_render(0, (drawfile_diagram *) src_data, (int) source_size, &matrix, 0, 0); if (error) { - LOG("xdrawfile_render: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xdrawfile_render: 0x%x: %s", + error->errnum, error->errmess); return false; } diff --git a/frontends/riscos/content-handlers/sprite.c b/frontends/riscos/content-handlers/sprite.c index 5cbade4e5..3556aa555 100644 --- a/frontends/riscos/content-handlers/sprite.c +++ b/frontends/riscos/content-handlers/sprite.c @@ -135,7 +135,10 @@ bool sprite_convert(struct content *c) (osspriteop_id) ((char *) area + area->first), &w, &h, NULL, NULL); if (error) { - LOG("xosspriteop_read_sprite_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_read_sprite_info: 0x%x: %s", + error->errnum, + error->errmess); msg_data.error = error->errmess; content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); return false; diff --git a/frontends/riscos/cookies.c b/frontends/riscos/cookies.c index 614bc3d10..125d04356 100644 --- a/frontends/riscos/cookies.c +++ b/frontends/riscos/cookies.c @@ -445,12 +445,12 @@ nserror ro_gui_cookies_present(void) res = ro_cookie_init(); if (res == NSERROR_OK) { - LOG("Presenting"); + NSLOG(netsurf, INFO, "Presenting"); ro_gui_dialog_open_top(cookie_window->core.wh, cookie_window->core.toolbar, 600, 800); } else { - LOG("Failed presenting code %d", res); + NSLOG(netsurf, INFO, "Failed presenting code %d", res); } return res; diff --git a/frontends/riscos/corewindow.c b/frontends/riscos/corewindow.c index 77dd1c375..84177aa90 100644 --- a/frontends/riscos/corewindow.c +++ b/frontends/riscos/corewindow.c @@ -63,22 +63,22 @@ static void update_scrollbars(struct ro_corewindow *ro_cw, wimp_open *open) int extent_height; os_box extent; - LOG("RO corewindow context %p", ro_cw); + NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw); /* extent of content in not smaller than window so start there */ extent_width = open->visible.x1 - open->visible.x0; extent_height = open->visible.y0 - open->visible.y1; - LOG("extent w:%d h:%d content w:%d h:%d origin h:%d", - extent_width, extent_height, - ro_cw->content_width, ro_cw->content_height, ro_cw->origin_y); + NSLOG(netsurf, INFO, + "extent w:%d h:%d content w:%d h:%d origin h:%d", extent_width, + extent_height, ro_cw->content_width, ro_cw->content_height, + ro_cw->origin_y); if (ro_cw->content_width > extent_width) { extent_width = ro_cw->content_width; } if (extent_height > (ro_cw->origin_y + ro_cw->content_height)) { extent_height = ro_cw->origin_y + ro_cw->content_height; } - LOG("extent w:%d h:%d", - extent_width, extent_height); + NSLOG(netsurf, INFO, "extent w:%d h:%d", extent_width, extent_height); extent.x0 = 0; extent.y0 = extent_height; extent.x1 = extent_width; @@ -86,15 +86,15 @@ static void update_scrollbars(struct ro_corewindow *ro_cw, wimp_open *open) error = xwimp_set_extent(ro_cw->wh, &extent); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); return; } error = xwimp_open_window(open); if (error) { - LOG("xwimp_open_window: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); } } @@ -130,8 +130,8 @@ static void ro_cw_redraw(wimp_draw *redraw) error = xwimp_get_rectangle(redraw, &more); } if (error != NULL) { - LOG("xwimp_redraw_window: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s", + error->errnum, error->errmess); } } @@ -145,7 +145,7 @@ static void ro_cw_scroll(wimp_scroll *scroll) wimp_open open; ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(scroll->w); - LOG("RO corewindow context %p", ro_cw); + NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw); page_x = scroll->visible.x1 - scroll->visible.x0 - 32; page_y = scroll->visible.y1 - scroll->visible.y0 - 32; @@ -202,8 +202,8 @@ static void ro_cw_scroll(wimp_scroll *scroll) error = xwimp_open_window(&open); if (error) { - LOG("xwimp_open_window: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); } } @@ -231,18 +231,18 @@ static void ro_cw_mouse_at(wimp_pointer *pointer, void *data) ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(pointer->w); if (ro_cw == NULL) { - LOG("no corewindow conext for window: 0x%x", - (unsigned int)pointer->w); + NSLOG(netsurf, INFO, "no corewindow conext for window: 0x%x", + (unsigned int)pointer->w); return; } - LOG("RO corewindow context %p", ro_cw); + NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw); /* Not a Menu click. */ state.w = pointer->w; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -285,14 +285,15 @@ static void ro_cw_drag_end(wimp_dragged *drag, void *data) error = xwimp_drag_box((wimp_drag *) -1); if (error) { - LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } error = xwimp_auto_scroll(0, NULL, NULL); if (error) { - LOG("xwimp_auto_scroll: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -345,12 +346,13 @@ ro_cw_drag_start(struct ro_corewindow *ro_cw, break; } - LOG("Drag start..."); + NSLOG(netsurf, INFO, "Drag start..."); error = xwimp_drag_box_with_flags(&drag, wimp_DRAG_BOX_KEEP_IN_LINE | wimp_DRAG_BOX_CLIP); if (error) { - LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } else { auto_scroll.w = ro_cw->wh; @@ -364,7 +366,8 @@ ro_cw_drag_start(struct ro_corewindow *ro_cw, error = xwimp_auto_scroll(wimp_AUTO_SCROLL_ENABLE_VERTICAL, &auto_scroll, NULL); if (error) { - LOG("xwimp_auto_scroll: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -388,8 +391,8 @@ static void ro_cw_pointer_leaving(wimp_leaving *leaving, void *data) ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(leaving->w); if (ro_cw == NULL) { - LOG("no corewindow conext for window: 0x%x", - (unsigned int)leaving->w); + NSLOG(netsurf, INFO, "no corewindow conext for window: 0x%x", + (unsigned int)leaving->w); return; } @@ -439,14 +442,14 @@ static bool ro_cw_mouse_click(wimp_pointer *pointer) struct ro_corewindow *ro_cw; ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(pointer->w); - LOG("RO corewindow context %p", ro_cw); + NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw); state.w = ro_cw->wh; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return false; } @@ -517,7 +520,7 @@ static bool ro_cw_keypress(wimp_key *key) nserror res; ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(key->w); - LOG("RO corewindow context %p", ro_cw); + NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw); c = (uint32_t) key->c; @@ -640,8 +643,8 @@ static void cw_tb_size(void *ctx) state.w = ro_cw->wh; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -649,8 +652,8 @@ static void cw_tb_size(void *ctx) 0, state.visible.y0 - state.visible.y1, state.visible.x1 - state.visible.x0, 0); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); return; } } @@ -759,8 +762,10 @@ ro_cw_invalidate(struct core_window *cw, const struct rect *r) info.w = ro_cw->wh; error = xwimp_get_window_info_header_only(&info); if (error) { - LOG("xwimp_get_window_info_header_only: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_info_header_only: 0x%x: %s", + error->errnum, + error->errmess); return NSERROR_INVALID; } } else { @@ -775,8 +780,8 @@ ro_cw_invalidate(struct core_window *cw, const struct rect *r) info.extent.x0, info.extent.y0, info.extent.x1, info.extent.y1); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } return NSERROR_OK; @@ -794,8 +799,8 @@ ro_cw_update_size(struct core_window *cw, int width, int height) wimp_window_state state; os_error *error; - LOG("content resize from w:%d h:%d to w:%d h:%d", - ro_cw->content_width, ro_cw->content_height, width, height); + NSLOG(netsurf, INFO, "content resize from w:%d h:%d to w:%d h:%d", + ro_cw->content_width, ro_cw->content_height, width, height); ro_cw->content_width = width * 2; ro_cw->content_height = -(2 * height); @@ -803,8 +808,8 @@ ro_cw_update_size(struct core_window *cw, int width, int height) state.w = ro_cw->wh; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -848,8 +853,8 @@ ro_cw_get_window_dimensions(struct core_window *cw, int *width, int *height) state.w = ro_cw->wh; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return; } diff --git a/frontends/riscos/dialog.c b/frontends/riscos/dialog.c index 6414778db..a50d1289b 100644 --- a/frontends/riscos/dialog.c +++ b/frontends/riscos/dialog.c @@ -220,7 +220,8 @@ wimp_w ro_gui_dialog_create(const char *template_name) window->sprite_area = gui_sprites; error = xwimp_create_window(window, &w); if (error) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); xwimp_close_template(); die(error->errmess); } @@ -259,12 +260,13 @@ wimp_window * ro_gui_dialog_load_template(const char *template_name) error = xwimp_load_template(wimp_GET_SIZE, 0, 0, wimp_NO_FONTS, name, 0, &window_size, &data_size, &context); if (error) { - LOG("xwimp_load_template: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_load_template: 0x%x: %s", + error->errnum, error->errmess); xwimp_close_template(); die(error->errmess); } if (!context) { - LOG("template '%s' missing", template_name); + NSLOG(netsurf, INFO, "template '%s' missing", template_name); xwimp_close_template(); die("Template"); } @@ -281,7 +283,8 @@ wimp_window * ro_gui_dialog_load_template(const char *template_name) error = xwimp_load_template(window, data, data + data_size, wimp_NO_FONTS, name, 0, 0, 0, 0); if (error) { - LOG("xwimp_load_template: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_load_template: 0x%x: %s", + error->errnum, error->errmess); xwimp_close_template(); die(error->errmess); } @@ -309,7 +312,8 @@ void ro_gui_dialog_open(wimp_w w) state.w = w; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -356,7 +360,8 @@ void ro_gui_dialog_close(wimp_w close) */ error = xwimp_get_caret_position(&caret); if (error) { - LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } else if (caret.w == close) { /* Check if we are a persistent window */ @@ -367,7 +372,10 @@ void ro_gui_dialog_close(wimp_w close) 32, -1); /* parent may have been closed first */ if ((error) && (error->errnum != 0x287)) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_set_caret_position: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -375,7 +383,8 @@ void ro_gui_dialog_close(wimp_w close) error = xwimp_close_window(close); if (error) { - LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -460,7 +469,8 @@ void ro_gui_dialog_open_at_pointer(wimp_w w) /* get the pointer position */ error = xwimp_get_pointer_info(&ptr); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -483,7 +493,8 @@ void ro_gui_dialog_open_xy(wimp_w w, int x, int y) state.w = w; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -498,7 +509,8 @@ void ro_gui_dialog_open_xy(wimp_w w, int x, int y) * on screen */ error = xwimp_close_window(w); if (error) { - LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -527,7 +539,10 @@ static void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w child) state.w = parent; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -544,7 +559,8 @@ static void ro_gui_dialog_open_centre_parent(wimp_w parent, wimp_w child) state.w = child; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -607,7 +623,7 @@ void ro_gui_dialog_add_persistent(wimp_w parent, wimp_w w) { return; } } - LOG("Unable to map persistent dialog to parent."); + NSLOG(netsurf, INFO, "Unable to map persistent dialog to parent."); return; } @@ -636,7 +652,9 @@ void ro_gui_dialog_close_persistent(wimp_w parent) { w = persistent_dialog[i].dialog; ro_gui_dialog_close(w); if (ro_gui_wimp_event_close_window(w)) - LOG("Persistent dialog close event: 0x%x", (unsigned)w); + NSLOG(netsurf, INFO, + "Persistent dialog close event: 0x%x", + (unsigned)w); persistent_dialog[i].parent = NULL; persistent_dialog[i].dialog = NULL; } @@ -713,7 +731,7 @@ static bool ro_gui_dialog_open_url_init(void) if ((definition->icons[ICON_OPENURL_URL].flags & wimp_ICON_INDIRECTED) == 0) { - LOG("open_url URL icon not indirected"); + NSLOG(netsurf, INFO, "open_url URL icon not indirected"); xwimp_close_template(); die("Template"); } @@ -731,7 +749,8 @@ static bool ro_gui_dialog_open_url_init(void) error = xwimp_create_window(definition, &dialog_openurl); if (error != NULL) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); xwimp_close_template(); die(error->errmess); } diff --git a/frontends/riscos/download.c b/frontends/riscos/download.c index 561409ed1..bdc705426 100644 --- a/frontends/riscos/download.c +++ b/frontends/riscos/download.c @@ -261,7 +261,10 @@ static nserror download_ro_filetype(download_context *ctx, bits *ftype_out) mime_type = download_context_get_mime_type(ctx); error = xmimemaptranslate_mime_type_to_filetype(mime_type, &ftype); if (error) { - LOG("xmimemaptranslate_mime_type_to_filetype: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xmimemaptranslate_mime_type_to_filetype: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); ftype = 0xffd; } @@ -339,7 +342,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui) error = xosfind_openoutw(osfind_NO_PATH | osfind_ERROR_IF_DIR, temp_name, 0, &dw->file); if (error) { - LOG("xosfind_openoutw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_openoutw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); free(dw); return 0; @@ -372,7 +376,7 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui) filename = strdup(temp_name); if (filename == NULL) { - LOG("Failed to establish download filename."); + NSLOG(netsurf, INFO, "Failed to establish download filename."); ro_warn_user("SaveError", error->errmess); free(dw); return 0; @@ -404,7 +408,7 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui) if (err != NSERROR_OK) { /* badenc should never happen */ assert(err !=NSERROR_BAD_ENCODING); - LOG("utf8_to_local_encoding failed"); + NSLOG(netsurf, INFO, "utf8_to_local_encoding failed"); ro_warn_user("NoMemory", 0); free(dw); return 0; @@ -430,7 +434,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui) /* create and open the download window */ error = xwimp_create_window(download_template, &dw->window); if (error) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); free(dw); return 0; @@ -485,7 +490,8 @@ static void gui_download_window_error(struct gui_download_window *dw, wimp_COLOUR_RED << wimp_ICON_FG_COLOUR_SHIFT, wimp_ICON_FG_COLOUR); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -493,7 +499,8 @@ static void gui_download_window_error(struct gui_download_window *dw, error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_PATH, wimp_ICON_SHADED, 0); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -501,7 +508,8 @@ static void gui_download_window_error(struct gui_download_window *dw, error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_ICON, wimp_ICON_SHADED, wimp_ICON_SHADED); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -528,11 +536,13 @@ static nserror gui_download_window_data(struct gui_download_window *dw, error = xosgbpb_writew(dw->file, (const byte *) data, size, &unwritten); if (error) { - LOG("xosgbpb_writew: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosgbpb_writew: 0x%x: %s", + error->errnum, error->errmess); msg = error->errmess; } else if (unwritten) { - LOG("xosgbpb_writew: unwritten %i", unwritten); + NSLOG(netsurf, INFO, "xosgbpb_writew: unwritten %i", + unwritten); msg = messages_get("Unwritten"); } else { @@ -555,20 +565,29 @@ static nserror gui_download_window_data(struct gui_download_window *dw, error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_ICON, wimp_ICON_SHADED, 0); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_set_icon_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_DESTINATION, wimp_ICON_DELETED, wimp_ICON_DELETED); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_set_icon_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_PATH, wimp_ICON_DELETED, 0); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_set_icon_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -717,13 +736,15 @@ void ro_gui_download_update_status(struct gui_download_window *dw) download_progress_x0 + width, download_progress_y1); if (error) { - LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_STATUS, 0, 0); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -759,13 +780,17 @@ void ro_gui_download_window_hide_caret(struct gui_download_window *dw) error = xwimp_get_caret_position(&caret); if (error) { - LOG("xwimp_get_caret_position: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } else if (caret.w == dw->window) { error = xwimp_set_caret_position(dw->window, (wimp_i)-1, 0, 0, 1 << 25, -1); if (error) { - LOG("xwimp_get_caret_position: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_caret_position: 0x%x : %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -791,7 +816,8 @@ static void gui_download_window_done(struct gui_download_window *dw) error = xosfind_closew(dw->file); if (error) { - LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); } dw->file = 0; @@ -800,7 +826,8 @@ static void gui_download_window_done(struct gui_download_window *dw) error = xosfile_set_type(dw->path, dw->file_type); if (error) { - LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); } @@ -856,7 +883,8 @@ bool ro_gui_download_click(wimp_pointer *pointer) *dot = 0; error = xos_cli(command); if (error) { - LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_cli: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); } } @@ -929,7 +957,8 @@ static void ro_gui_download_drag_end(wimp_dragged *drag, void *data) error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -959,7 +988,10 @@ static void ro_gui_download_drag_end(wimp_dragged *drag, void *data) error = xwimp_send_message_to_window(wimp_USER_MESSAGE, &message, pointer.w, pointer.i, 0); if (error) { - LOG("xwimp_send_message_to_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_send_message_to_window: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -1011,7 +1043,10 @@ char *ro_gui_download_canonicalise(const char *path) error = xosfscontrol_canonicalise_path(path, NULL, NULL, NULL, 0, &spare); if (error) { - LOG("xosfscontrol_canonicalise_path: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfscontrol_canonicalise_path: 0x%x: %s", + error->errnum, + error->errmess); return NULL; } @@ -1020,7 +1055,10 @@ char *ro_gui_download_canonicalise(const char *path) error = xosfscontrol_canonicalise_path(path, buf, NULL, NULL, 1 - spare, NULL); if (error) { - LOG("xosfscontrol_canonicalise_path: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfscontrol_canonicalise_path: 0x%x: %s", + error->errnum, + error->errmess); free(buf); return NULL; @@ -1065,13 +1103,17 @@ bool ro_gui_download_check_space(struct gui_download_window *dw, error = xosfscontrol_free_space64(dir, &free_lo, &free_hi, &max_file, NULL, NULL); if (error) { - LOG("xosfscontrol_free_space64: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfscontrol_free_space64: 0x%x: %s", + error->errnum, error->errmess); free_hi = 0; error = xosfscontrol_free_space(dir, (int*)&free_lo, &max_file, NULL); if (error) { - LOG("xosfscontrol_free_space: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfscontrol_free_space: 0x%x: %s", + error->errnum, + error->errmess); /* close our eyes and hope */ free(dir); return true; @@ -1108,7 +1150,10 @@ bool ro_gui_download_check_space(struct gui_download_window *dw, error = xosargs_read_allocation(dw->file, &allocation); if (error) { - LOG("xosargs_read_allocation: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosargs_read_allocation: 0x%x : %s", + error->errnum, + error->errmess); } else { space += allocation; @@ -1147,7 +1192,8 @@ os_error *ro_gui_download_move(struct gui_download_window *dw, error = xosfind_closew(dw->file); dw->file = 0; if (error) { - LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s", + error->errnum, error->errmess); return error; } } @@ -1165,11 +1211,13 @@ os_error *ro_gui_download_move(struct gui_download_window *dw, osfscontrol_COPY_LOOK, 0, 0, 0, 0, 0); if (error) { - LOG("xosfscontrol_copy: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfscontrol_copy: 0x%x: %s", + error->errnum, error->errmess); return error; } } else if (error) { - LOG("xosfscontrol_rename: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfscontrol_rename: 0x%x: %s", + error->errnum, error->errmess); return error; } @@ -1179,20 +1227,23 @@ os_error *ro_gui_download_move(struct gui_download_window *dw, fileswitch_ATTR_OWNER_READ | fileswitch_ATTR_OWNER_WRITE); if (error) { - LOG("xosfile_write: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_write: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); } error = xosfind_openupw(osfind_NO_PATH | osfind_ERROR_IF_DIR, dest_file, 0, &dw->file); if (error) { - LOG("xosfind_openupw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_openupw: 0x%x: %s", + error->errnum, error->errmess); return error; } error = xosargs_set_ptrw(dw->file, dw->received); if (error) { - LOG("xosargs_set_ptrw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosargs_set_ptrw: 0x%x: %s", + error->errnum, error->errmess); return error; } @@ -1201,7 +1252,8 @@ os_error *ro_gui_download_move(struct gui_download_window *dw, error = xosfile_set_type(dest_file, dw->file_type); if (error) { - LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); } } @@ -1273,7 +1325,8 @@ bool ro_gui_download_save(struct gui_download_window *dw, error = xosfile_read_stamped(file_name, &obj_type, NULL, NULL, NULL, NULL, NULL); if (error) { - LOG("xosfile_read_stamped: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_read_stamped: 0x%x:%s", + error->errnum, error->errmess); return false; } @@ -1309,12 +1362,16 @@ bool ro_gui_download_save(struct gui_download_window *dw, error = xosfind_openupw(osfind_NO_PATH | osfind_ERROR_IF_DIR, temp_name, 0, &dw->file); if (error) { - LOG("xosfind_openupw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_openupw: 0x%x: %s", + error->errnum, error->errmess); } else { error = xosargs_set_ptrw(dw->file, dw->received); if (error) { - LOG("xosargs_set_ptrw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosargs_set_ptrw: 0x%x: %s", + error->errnum, + error->errmess); } } @@ -1336,7 +1393,8 @@ bool ro_gui_download_save(struct gui_download_window *dw, error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_ICON, wimp_ICON_SHADED, wimp_ICON_SHADED); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -1349,13 +1407,15 @@ bool ro_gui_download_save(struct gui_download_window *dw, error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_PATH, wimp_ICON_DELETED, wimp_ICON_DELETED); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_DESTINATION, wimp_ICON_DELETED, 0); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -1401,7 +1461,8 @@ void ro_gui_download_send_dataload(struct gui_download_window *dw) * for the rather depressing details. */ if (error && error->errnum != error_WIMP_BAD_HANDLE) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -1482,7 +1543,8 @@ bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit) /* delete window */ error = xwimp_delete_window(dw->window); if (error) { - LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } ro_gui_wimp_event_finalise(dw->window); @@ -1491,7 +1553,8 @@ bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit) if (dw->file) { error = xosfind_closew(dw->file); if (error) { - LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); } } @@ -1502,7 +1565,8 @@ bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit) error = xosfile_delete(temp_name, 0, 0, 0, 0, 0); if (error) { - LOG("xosfile_delete: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_delete: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); } } diff --git a/frontends/riscos/filetype.c b/frontends/riscos/filetype.c index 75ff41414..73651cd63 100644 --- a/frontends/riscos/filetype.c +++ b/frontends/riscos/filetype.c @@ -72,7 +72,7 @@ const char *fetch_filetype(const char *unix_path) int objtype; if (!path) { - LOG("Insufficient memory for calloc"); + NSLOG(netsurf, INFO, "Insufficient memory for calloc"); ro_warn_user("NoMemory", 0); return "application/riscos"; } @@ -80,7 +80,7 @@ const char *fetch_filetype(const char *unix_path) /* convert path to RISC OS format and read file type */ r = __riscosify(unix_path, 0, __RISCOSIFY_NO_SUFFIX, path, len, 0); if (r == 0) { - LOG("__riscosify failed"); + NSLOG(netsurf, INFO, "__riscosify failed"); free(path); return "application/riscos"; } @@ -88,7 +88,9 @@ const char *fetch_filetype(const char *unix_path) error = xosfile_read_stamped_no_path(path, &objtype, 0, 0, 0, 0, &file_type); if (error) { - LOG("xosfile_read_stamped_no_path failed: %s", error->errmess); + NSLOG(netsurf, INFO, + "xosfile_read_stamped_no_path failed: %s", + error->errmess); free(path); return "application/riscos"; } @@ -108,7 +110,10 @@ const char *fetch_filetype(const char *unix_path) slash+1, &temp); if (error) /* ignore error and leave file_type alone */ - LOG("xmimemaptranslate_extension_to_filetype: ""0x%x %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xmimemaptranslate_extension_to_filetype: ""0x%x %s", + error->errnum, + error->errmess); else file_type = temp; } @@ -126,7 +131,7 @@ const char *fetch_filetype(const char *unix_path) /* not in internal table, so ask MimeMap */ error = xmimemaptranslate_filetype_to_mime_type(file_type, type_buf); if (error) { - LOG("0x%x %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "0x%x %s", error->errnum, error->errmess); free(path); return "application/riscos"; } @@ -139,7 +144,7 @@ const char *fetch_filetype(const char *unix_path) free(path); - LOG("mime type '%s'", type_buf); + NSLOG(netsurf, INFO, "mime type '%s'", type_buf); return (const char *)type_buf; } @@ -155,14 +160,15 @@ char *fetch_mimetype(const char *ro_path) struct type_entry *t; if (!mime) { - LOG("Insufficient memory for calloc"); + NSLOG(netsurf, INFO, "Insufficient memory for calloc"); ro_warn_user("NoMemory", 0); return 0; } e = xosfile_read_no_path(ro_path, &objtype, &load, 0, 0, 0); if (e) { - LOG("xosfile_read_no_path: 0x%x: %s", e->errnum, e->errmess); + NSLOG(netsurf, INFO, "xosfile_read_no_path: 0x%x: %s", + e->errnum, e->errmess); free(mime); return 0; } @@ -188,7 +194,7 @@ char *fetch_mimetype(const char *ro_path) if (e) /* if we get an error here, simply ignore it and * leave filetype unchanged */ - LOG("0x%x %s", e->errnum, e->errmess); + NSLOG(netsurf, INFO, "0x%x %s", e->errnum, e->errmess); else filetype = load; } @@ -205,7 +211,10 @@ char *fetch_mimetype(const char *ro_path) /* not in internal table, so ask MimeMap */ e = xmimemaptranslate_filetype_to_mime_type(filetype, mime); if (e) { - LOG("xmimemaptranslate_filetype_to_mime_type: 0x%x: %s", e->errnum, e->errmess); + NSLOG(netsurf, INFO, + "xmimemaptranslate_filetype_to_mime_type: 0x%x: %s", + e->errnum, + e->errmess); free(mime); return 0; } @@ -322,7 +331,7 @@ bits ro_filetype_from_unix_path(const char *unix_path) bits file_type; if (!path) { - LOG("Insufficient memory for calloc"); + NSLOG(netsurf, INFO, "Insufficient memory for calloc"); ro_warn_user("NoMemory", 0); return osfile_TYPE_DATA; } @@ -330,7 +339,7 @@ bits ro_filetype_from_unix_path(const char *unix_path) /* convert path to RISC OS format and read file type */ r = __riscosify(unix_path, 0, __RISCOSIFY_NO_SUFFIX, path, len, 0); if (r == 0) { - LOG("__riscosify failed"); + NSLOG(netsurf, INFO, "__riscosify failed"); free(path); return osfile_TYPE_DATA; } @@ -338,7 +347,9 @@ bits ro_filetype_from_unix_path(const char *unix_path) error = xosfile_read_stamped_no_path(path, 0, 0, 0, 0, 0, &file_type); if (error) { - LOG("xosfile_read_stamped_no_path failed: %s", error->errmess); + NSLOG(netsurf, INFO, + "xosfile_read_stamped_no_path failed: %s", + error->errmess); free(path); return osfile_TYPE_DATA; } diff --git a/frontends/riscos/font.c b/frontends/riscos/font.c index 560afc785..8913efeeb 100644 --- a/frontends/riscos/font.c +++ b/frontends/riscos/font.c @@ -65,7 +65,8 @@ static void nsfont_check_fonts(void) ".FixFonts", 0); die("FontBadInst"); } else { - LOG("xfont_find_font: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xfont_find_font: 0x%x: %s", + error->errnum, error->errmess); snprintf(s, sizeof s, messages_get("FontError"), error->errmess); die(s); @@ -74,7 +75,8 @@ static void nsfont_check_fonts(void) error = xfont_lose_font(font); if (error) { - LOG("xfont_lose_font: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xfont_lose_font: 0x%x: %s", + error->errnum, error->errmess); snprintf(s, sizeof s, messages_get("FontError"), error->errmess); die(s); @@ -118,17 +120,20 @@ void nsfont_init(void) nsfont_check_fonts(); - LOG("Initialise RUfl"); + NSLOG(netsurf, INFO, "Initialise RUfl"); code = rufl_init(); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) - LOG("rufl_init: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_init: rufl_FONT_MANAGER_ERROR: 0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); else - LOG("rufl_init: 0x%x", code); + NSLOG(netsurf, INFO, "rufl_init: 0x%x", code); die("The Unicode font library could not be initialized. " "Please report this to the developers."); } - LOG("RUfl initialised"); + NSLOG(netsurf, INFO, "RUfl initialised"); if (rufl_family_list_entries == 0) die("No fonts could be found. At least one font must be " @@ -162,9 +167,10 @@ const char *nsfont_fallback_font(void) const char *fallback = "Homerton"; if (!nsfont_exists(fallback)) { - LOG("Homerton not found, dumping RUfl family list"); + NSLOG(netsurf, INFO, + "Homerton not found, dumping RUfl family list"); for (unsigned int i = 0; i < rufl_family_list_entries; i++) { - LOG("'%s'", rufl_family_list[i]); + NSLOG(netsurf, INFO, "'%s'", rufl_family_list[i]); } fallback = rufl_family_list[0]; } @@ -230,9 +236,12 @@ ro_font_width(const plot_font_style_t *fstyle, width); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) - LOG("rufl_width: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_width: rufl_FONT_MANAGER_ERROR: 0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); else - LOG("rufl_width: 0x%x", code); + NSLOG(netsurf, INFO, "rufl_width: 0x%x", code); /* ro_warn_user("MiscError", "font error"); */ *width = 0; return NSERROR_INVALID; @@ -276,9 +285,12 @@ ro_font_position(const plot_font_style_t *fstyle, x * 2, char_offset, actual_x); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) - LOG("rufl_x_to_offset: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_x_to_offset: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); else - LOG("rufl_x_to_offset: 0x%x", code); + NSLOG(netsurf, INFO, "rufl_x_to_offset: 0x%x", code); /* ro_warn_user("MiscError", "font error"); */ *char_offset = 0; *actual_x = 0; @@ -335,10 +347,12 @@ ro_font_split(const plot_font_style_t *fstyle, x * 2, char_offset, actual_x); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) { - LOG("rufl_split: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", - rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_split: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); } else { - LOG("rufl_split: 0x%x", code); + NSLOG(netsurf, INFO, "rufl_split: 0x%x", code); } /* ro_warn_user("MiscError", "font error"); */ *char_offset = 0; @@ -370,10 +384,12 @@ ro_font_split(const plot_font_style_t *fstyle, actual_x); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) { - LOG("rufl_width: rufl_FONT_MANAGER_ERROR: 0x%x: %s", - rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_width: rufl_FONT_MANAGER_ERROR: 0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); } else { - LOG("rufl_width: 0x%x", code); + NSLOG(netsurf, INFO, "rufl_width: 0x%x", code); } /* ro_warn_user("MiscError", "font error"); */ *char_offset = 0; @@ -416,9 +432,12 @@ bool nsfont_paint(const plot_font_style_t *fstyle, const char *string, string, length, x, y, flags); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) { - LOG("rufl_paint: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_paint: rufl_FONT_MANAGER_ERROR: 0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); } else { - LOG("rufl_paint: 0x%x", code); + NSLOG(netsurf, INFO, "rufl_paint: 0x%x", code); } } @@ -513,7 +532,8 @@ ro_gui_wimp_desktop_font(char *family, error = xwimpreadsysinfo_font(&font_handle, NULL); if (error) { - LOG("xwimpreadsysinfo_font: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimpreadsysinfo_font: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); goto failsafe; } @@ -525,20 +545,22 @@ ro_gui_wimp_desktop_font(char *family, error = xfont_read_identifier(font_handle, NULL, &used); if (error) { - LOG("xfont_read_identifier: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xfont_read_identifier: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); goto failsafe; } if (family_size < (size_t) used + 1) { - LOG("desktop font name too long"); + NSLOG(netsurf, INFO, "desktop font name too long"); goto failsafe; } error = xfont_read_defn(font_handle, (byte *) family, &ptx, &pty, NULL, NULL, NULL, NULL); if (error) { - LOG("xfont_read_defn: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xfont_read_defn: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); goto failsafe; } @@ -550,7 +572,7 @@ ro_gui_wimp_desktop_font(char *family, } } - LOG("desktop font \"%s\"", family); + NSLOG(netsurf, INFO, "desktop font \"%s\"", family); if (strcasestr(family, ".Medium")) style = rufl_WEIGHT_500; @@ -566,7 +588,8 @@ ro_gui_wimp_desktop_font(char *family, *psize = max(ptx, pty); *pstyle = style; - LOG("family \"%s\", size %i, style %i", family, *psize, style); + NSLOG(netsurf, INFO, "family \"%s\", size %i, style %i", family, + *psize, style); return; diff --git a/frontends/riscos/global_history.c b/frontends/riscos/global_history.c index d122a4d7f..7dfc58317 100644 --- a/frontends/riscos/global_history.c +++ b/frontends/riscos/global_history.c @@ -474,12 +474,12 @@ nserror ro_gui_global_history_present(void) res = ro_global_history_init(); if (res == NSERROR_OK) { - LOG("Presenting"); + NSLOG(netsurf, INFO, "Presenting"); ro_gui_dialog_open_top(global_history_window->core.wh, global_history_window->core.toolbar, 600, 800); } else { - LOG("Failed presenting code %d", res); + NSLOG(netsurf, INFO, "Failed presenting code %d", res); } return res; diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c index 576e1ff12..51ea37066 100644 --- a/frontends/riscos/gui.c +++ b/frontends/riscos/gui.c @@ -307,7 +307,7 @@ static nserror set_defaults(struct nsoption_s *defaults) if (nsoption_charp(ca_bundle) == NULL || nsoption_charp(cookie_file) == NULL || nsoption_charp(cookie_jar) == NULL) { - LOG("Failed initialising default options"); + NSLOG(netsurf, INFO, "Failed initialising default options"); return NSERROR_BAD_PARAMETER; } @@ -430,7 +430,7 @@ static void ro_gui_signal(int sig) if (used) { int curr_slot; xwimp_slot_size(-1, -1, &curr_slot, 0, 0); - LOG("saving WimpSlot, size 0x%x", curr_slot); + NSLOG(netsurf, INFO, "saving WimpSlot, size 0x%x", curr_slot); xosfile_save("$.NetSurf_Slot", 0x8000, 0, (byte *) 0x8000, (byte *) 0x8000 + curr_slot); @@ -440,7 +440,11 @@ static void ro_gui_signal(int sig) byte *base_address; xosdynamicarea_read(__dynamic_num, &size, &base_address, 0, 0, 0, 0, 0); - LOG("saving DA %i, base %p, size 0x%x", __dynamic_num, base_address, size); + NSLOG(netsurf, INFO, + "saving DA %i, base %p, size 0x%x", + __dynamic_num, + base_address, + size); xosfile_save("$.NetSurf_DA", (bits) base_address, 0, base_address, @@ -452,7 +456,7 @@ static void ro_gui_signal(int sig) * defines a coredump directory. */ const _kernel_oserror *err = __unixlib_write_coredump (NULL); if (err != NULL) - LOG("Coredump failed: %s", err->errmess); + NSLOG(netsurf, INFO, "Coredump failed: %s", err->errmess); #endif xhourglass_colours(old_sand, old_glass, 0, 0); @@ -536,7 +540,8 @@ static char *ro_gui_uri_file_parse(const char *file_name, char **uri_title) *uri_title = NULL; fp = fopen(file_name, "rb"); if (!fp) { - LOG("fopen(\"%s\", \"rb\"): %i: %s", file_name, errno, strerror(errno)); + NSLOG(netsurf, INFO, "fopen(\"%s\", \"rb\"): %i: %s", + file_name, errno, strerror(errno)); ro_warn_user("LoadError", strerror(errno)); return 0; } @@ -597,14 +602,16 @@ static char *ro_gui_url_file_parse(const char *file_name) fp = fopen(file_name, "r"); if (!fp) { - LOG("fopen(\"%s\", \"r\"): %i: %s", file_name, errno, strerror(errno)); + NSLOG(netsurf, INFO, "fopen(\"%s\", \"r\"): %i: %s", + file_name, errno, strerror(errno)); ro_warn_user("LoadError", strerror(errno)); return 0; } if (!fgets(line, sizeof line, fp)) { if (ferror(fp)) { - LOG("fgets: %i: %s", errno, strerror(errno)); + NSLOG(netsurf, INFO, "fgets: %i: %s", errno, + strerror(errno)); ro_warn_user("LoadError", strerror(errno)); } else ro_warn_user("LoadError", messages_get("EmptyError")); @@ -641,7 +648,8 @@ static char *ro_gui_ieurl_file_parse(const char *file_name) fp = fopen(file_name, "r"); if (!fp) { - LOG("fopen(\"%s\", \"r\"): %i: %s", file_name, errno, strerror(errno)); + NSLOG(netsurf, INFO, "fopen(\"%s\", \"r\"): %i: %s", + file_name, errno, strerror(errno)); ro_warn_user("LoadError", strerror(errno)); return 0; } @@ -660,7 +668,7 @@ static char *ro_gui_ieurl_file_parse(const char *file_name) } } if (ferror(fp)) { - LOG("fgets: %i: %s", errno, strerror(errno)); + NSLOG(netsurf, INFO, "fgets: %i: %s", errno, strerror(errno)); ro_warn_user("LoadError", strerror(errno)); fclose(fp); return 0; @@ -732,7 +740,8 @@ static void ro_msg_dataopen(wimp_message *message) message->your_ref = message->my_ref; oserror = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender); if (oserror) { - LOG("xwimp_send_message: 0x%x: %s", oserror->errnum, oserror->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + oserror->errnum, oserror->errmess); ro_warn_user("WimpError", oserror->errmess); return; } @@ -855,7 +864,8 @@ static void ro_msg_dataload(wimp_message *message) oserror = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender); if (oserror) { - LOG("xwimp_send_message: 0x%x: %s", oserror->errnum, oserror->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + oserror->errnum, oserror->errmess); ro_warn_user("WimpError", oserror->errmess); return; } @@ -925,7 +935,10 @@ static void ro_msg_datasave(wimp_message *message) error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)dataxfer, message->sender); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_send_message: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -977,7 +990,8 @@ static void ro_msg_prequit(wimp_message *message) error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE, message, message->sender); if (error) { - LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -1003,7 +1017,8 @@ static void ro_msg_save_desktop(wimp_message *message) } if (error) { - LOG("xosgbpb_writew/xos_bputw: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosgbpb_writew/xos_bputw: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); /* we must cancel the save by acknowledging the message */ @@ -1011,7 +1026,8 @@ static void ro_msg_save_desktop(wimp_message *message) error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE, message, message->sender); if (error) { - LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -1062,7 +1078,8 @@ static void ro_gui_get_screen_properties(void) error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), vals); if (error) { - LOG("xos_read_vdu_variables: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_read_vdu_variables: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); return; } @@ -1079,9 +1096,9 @@ static void ro_gui_check_resolvers(void) char *resolvers; resolvers = getenv("Inet$Resolvers"); if (resolvers && resolvers[0]) { - LOG("Inet$Resolvers '%s'", resolvers); + NSLOG(netsurf, INFO, "Inet$Resolvers '%s'", resolvers); } else { - LOG("Inet$Resolvers not set or empty"); + NSLOG(netsurf, INFO, "Inet$Resolvers not set or empty"); ro_warn_user("Resolvers", 0); } } @@ -1196,7 +1213,8 @@ static nserror gui_init(int argc, char** argv) PTR_WIMP_MESSAGE_LIST(&task_messages), 0, &task_handle); if (error) { - LOG("xwimp_initialise: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_initialise: 0x%x: %s", + error->errnum, error->errmess); die(error->errmess); } /* Register message handlers */ @@ -1234,7 +1252,8 @@ static nserror gui_init(int argc, char** argv) die("Failed to locate Templates resource."); error = xwimp_open_template(path); if (error) { - LOG("xwimp_open_template failed: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_template failed: 0x%x: %s", + error->errnum, error->errmess); die(error->errmess); } @@ -1275,7 +1294,7 @@ static nserror gui_init(int argc, char** argv) /* parse command-line arguments */ if (argc == 2) { - LOG("parameters: '%s'", argv[1]); + NSLOG(netsurf, INFO, "parameters: '%s'", argv[1]); /* this is needed for launching URI files */ if (strcasecmp(argv[1], "-nowin") == 0) { return NSERROR_OK; @@ -1283,7 +1302,8 @@ static nserror gui_init(int argc, char** argv) ret = nsurl_create(NETSURF_HOMEPAGE, &url); } else if (argc == 3) { - LOG("parameters: '%s' '%s'", argv[1], argv[2]); + NSLOG(netsurf, INFO, "parameters: '%s' '%s'", argv[1], + argv[2]); open_window = true; /* HTML files */ @@ -1294,7 +1314,7 @@ static nserror gui_init(int argc, char** argv) else if (strcasecmp(argv[1], "-urlf") == 0) { char *urlf = ro_gui_url_file_parse(argv[2]); if (!urlf) { - LOG("allocation failed"); + NSLOG(netsurf, INFO, "allocation failed"); die("Insufficient memory for URL"); } ret = nsurl_create(urlf, &url); @@ -1306,7 +1326,8 @@ static nserror gui_init(int argc, char** argv) } /* Unknown => exit here. */ else { - LOG("Unknown parameters: '%s' '%s'", argv[1], argv[2]); + NSLOG(netsurf, INFO, "Unknown parameters: '%s' '%s'", + argv[1], argv[2]); return NSERROR_BAD_PARAMETER; } } @@ -1354,7 +1375,8 @@ const char *ro_gui_default_language(void) /* choose a language from the configured country number */ error = xosbyte_read(osbyte_VAR_COUNTRY_NUMBER, &country); if (error) { - LOG("xosbyte_read failed: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosbyte_read failed: 0x%x: %s", + error->errnum, error->errmess); country = 1; } switch (country) { @@ -1405,7 +1427,10 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out) /* calculate the canonical risc os path */ error = xosfscontrol_canonicalise_path(path, 0, 0, 0, 0, &spare); if (error) { - LOG("xosfscontrol_canonicalise_path failed: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfscontrol_canonicalise_path failed: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("PathToURL", error->errmess); return NSERROR_NOT_FOUND; } @@ -1418,7 +1443,10 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out) error = xosfscontrol_canonicalise_path(path, canonical_path, 0, 0, 1 - spare, 0); if (error) { - LOG("xosfscontrol_canonicalise_path failed: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfscontrol_canonicalise_path failed: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("PathToURL", error->errmess); free(canonical_path); return NSERROR_NOT_FOUND; @@ -1428,7 +1456,7 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out) unix_path = __unixify(canonical_path, __RISCOSIFY_NO_REVERSE_SUFFIX, NULL, 0, 0); if (unix_path == NULL) { - LOG("__unixify failed: %s", canonical_path); + NSLOG(netsurf, INFO, "__unixify failed: %s", canonical_path); free(canonical_path); return NSERROR_BAD_PARAMETER; } @@ -1446,7 +1474,7 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out) urllen = strlen(escaped_path) + FILE_SCHEME_PREFIX_LEN + 1; url = malloc(urllen); if (url == NULL) { - LOG("Unable to allocate url"); + NSLOG(netsurf, INFO, "Unable to allocate url"); free(escaped_path); return NSERROR_NOMEM; } @@ -1596,7 +1624,8 @@ static void ro_gui_keypress_cb(void *pw) if (ro_gui_wimp_event_keypress(key) == false) { os_error *error = xwimp_process_key(key->c); if (error) { - LOG("xwimp_process_key: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_process_key: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -1633,7 +1662,8 @@ static void ro_gui_keypress(wimp_key *key) } else if (ro_gui_wimp_event_keypress(key) == false) { os_error *error = xwimp_process_key(key->c); if (error) { - LOG("xwimp_process_key: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_process_key: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -1905,7 +1935,8 @@ void ro_gui_open_window_request(wimp_open *open) error = xwimp_open_window(open); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1926,7 +1957,8 @@ static void ro_gui_view_source_bounce(wimp_message *message) sprintf(command, "@RunType_FFF %s", filename); error = xwimp_start_task(command, 0); if (error) { - LOG("xwimp_start_task failed: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_start_task failed: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -1989,7 +2021,7 @@ void ro_gui_view_source(struct hlcache_handle *c) r = __riscosify(full_name, 0, __RISCOSIFY_NO_SUFFIX, message.file_name, 212, 0); if (r == 0) { - LOG("__riscosify failed"); + NSLOG(netsurf, INFO, "__riscosify failed"); return; } message.file_name[211] = '\0'; @@ -1999,7 +2031,10 @@ void ro_gui_view_source(struct hlcache_handle *c) (byte *) source_data, (byte *) source_data + source_size); if (error) { - LOG("xosfile_save_stamped failed: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfile_save_stamped failed: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); return; } @@ -2069,7 +2104,7 @@ static void ro_gui_choose_language(void) */ nserror ro_warn_user(const char *warning, const char *detail) { - LOG("%s %s", warning, detail); + NSLOG(netsurf, INFO, "%s %s", warning, detail); if (dialog_warning) { char warn_buffer[300]; @@ -2113,7 +2148,7 @@ void die(const char * const error) { os_error warn_error; - LOG("%s", error); + NSLOG(netsurf, INFO, "%s", error); warn_error.errnum = 1; /* \todo: reasonable ? */ strncpy(warn_error.errmess, messages_get(error), @@ -2350,7 +2385,7 @@ void ro_gui_dump_browser_window(struct browser_window *bw) /* open file for dump */ FILE *stream = fopen(".WWW.NetSurf.dump", "w"); if (!stream) { - LOG("fopen: errno %i", errno); + NSLOG(netsurf, INFO, "fopen: errno %i", errno); ro_warn_user("SaveError", strerror(errno)); return; } @@ -2363,7 +2398,8 @@ void ro_gui_dump_browser_window(struct browser_window *bw) error = xwimp_start_task("Filer_Run .WWW.NetSurf.dump", 0); if (error) { - LOG("xwimp_start_task failed: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_start_task failed: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -2403,7 +2439,7 @@ static char *get_cachepath(void) cachedir = getenv("Cache$Dir"); if ((cachedir == NULL) || (cachedir[0] == 0)) { - LOG("cachedir was null"); + NSLOG(netsurf, INFO, "cachedir was null"); return NULL; } ret = netsurf_mkpath(&cachepath, NULL, 2, cachedir, "NetSurf"); diff --git a/frontends/riscos/gui/button_bar.c b/frontends/riscos/gui/button_bar.c index 6ecd7cffa..34ae39ae5 100644 --- a/frontends/riscos/gui/button_bar.c +++ b/frontends/riscos/gui/button_bar.c @@ -138,7 +138,7 @@ struct button_bar *ro_gui_button_bar_create(struct theme_descriptor *theme, button_bar = malloc(sizeof(struct button_bar)); if (button_bar == NULL) { - LOG("No memory for malloc()"); + NSLOG(netsurf, INFO, "No memory for malloc()"); return NULL; } @@ -538,7 +538,10 @@ bool ro_gui_button_bar_icon_update(struct button_bar *button_bar) error = xwimp_create_icon(&icon, &button->icon); if (error) { - LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_create_icon: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); button->icon = -1; return false; @@ -548,7 +551,10 @@ bool ro_gui_button_bar_icon_update(struct button_bar *button_bar) error = xwimp_delete_icon(button_bar->window, button->icon); if (error != NULL) { - LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_delete_icon: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -598,7 +604,10 @@ bool ro_gui_button_bar_icon_resize(struct button_bar *button_bar) button->y_pos + button->y_size); if (error != NULL) { - LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_resize_icon: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); button->icon = -1; return false; @@ -769,7 +778,10 @@ bool ro_gui_button_bar_click(struct button_bar *button_bar, button_bar->sprites, sprite, &box, NULL); if (error) - LOG("xdragasprite_start: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xdragasprite_start: 0x%x: %s", + error->errnum, + error->errmess); ro_mouse_drag_start(ro_gui_button_bar_drag_end, NULL, NULL, NULL); @@ -870,7 +882,8 @@ void ro_gui_button_bar_drag_end(wimp_dragged *drag, void *data) error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -880,7 +893,8 @@ void ro_gui_button_bar_drag_end(wimp_dragged *drag, void *data) state.w = drag_start->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1068,7 +1082,7 @@ char *ro_gui_button_bar_get_config(struct button_bar *button_bar) config = malloc(size); if (config == NULL) { - LOG("No memory for malloc()"); + NSLOG(netsurf, INFO, "No memory for malloc()"); ro_warn_user("NoMemory", 0); return NULL; } diff --git a/frontends/riscos/gui/progress_bar.c b/frontends/riscos/gui/progress_bar.c index c47c2af7d..06d89dbf4 100644 --- a/frontends/riscos/gui/progress_bar.c +++ b/frontends/riscos/gui/progress_bar.c @@ -137,7 +137,8 @@ struct progress_bar *ro_gui_progress_bar_create(void) error = xwimp_create_window((wimp_window *)&progress_bar_definition, &pb->w); if (error) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); free(pb); return NULL; } @@ -165,7 +166,8 @@ void ro_gui_progress_bar_destroy(struct progress_bar *pb) ro_gui_wimp_event_finalise(pb->w); error = xwimp_delete_window(pb->w); if (error) { - LOG("xwimp_delete_window: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s", + error->errnum, error->errmess); } free(pb); @@ -327,7 +329,8 @@ void ro_gui_progress_bar_update(struct progress_bar *pb, int width, int height) redraw.box.x0 = cur.x1; error = xwimp_update_window(&redraw, &more); if (error) { - LOG("Error getting update window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "Error getting update window: 0x%x: %s", + error->errnum, error->errmess); return; } if (more) @@ -351,7 +354,8 @@ void ro_gui_progress_bar_redraw(wimp_draw *redraw) error = xwimp_redraw_window(redraw, &more); if (error) { - LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s", + error->errnum, error->errmess); return; } if (more) @@ -385,7 +389,8 @@ void ro_gui_progress_bar_animate(void *p) redraw.box = pb->visible; error = xwimp_update_window(&redraw, &more); if (error != NULL) { - LOG("Error getting update window: '%s'", error->errmess); + NSLOG(netsurf, INFO, "Error getting update window: '%s'", + error->errmess); return; } if (more) @@ -533,7 +538,8 @@ void ro_gui_progress_bar_redraw_window(wimp_draw *redraw, } error = xwimp_get_rectangle(redraw, &more); if (error) { - LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s", + error->errnum, error->errmess); return; } } diff --git a/frontends/riscos/gui/status_bar.c b/frontends/riscos/gui/status_bar.c index bcaf3baf9..dd1aab639 100644 --- a/frontends/riscos/gui/status_bar.c +++ b/frontends/riscos/gui/status_bar.c @@ -131,7 +131,8 @@ struct status_bar *ro_gui_status_bar_create(wimp_w parent, unsigned int width) error = xwimp_create_window((wimp_window *)&status_bar_definition, &sb->w); if (error) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); free(sb); return NULL; } @@ -165,7 +166,8 @@ void ro_gui_status_bar_destroy(struct status_bar *sb) ro_gui_wimp_event_finalise(sb->w); error = xwimp_delete_window(sb->w); if (error) { - LOG("xwimp_delete_window: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s", + error->errnum, error->errmess); } ro_gui_progress_bar_destroy(sb->pb); @@ -222,7 +224,8 @@ void ro_gui_status_bar_set_visible(struct status_bar *sb, bool visible) } else { os_error *error = xwimp_close_window(sb->w); if (error) { - LOG("xwimp_close_window: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x:%s", + error->errnum, error->errmess); } } } @@ -275,14 +278,15 @@ void ro_gui_status_bar_set_progress_range(struct status_bar *sb, old_range = ro_gui_progress_bar_get_range(sb->pb); ro_gui_progress_bar_set_range(sb->pb, range); - LOG("Ranges are %i vs %i", old_range, range); + NSLOG(netsurf, INFO, "Ranges are %i vs %i", old_range, range); if ((old_range == 0) && (range != 0)) { ro_gui_status_position_progress_bar(sb); } else if ((old_range != 0) && (range == 0)) { os_error *error = xwimp_close_window( ro_gui_progress_bar_get_window(sb->pb)); if (error) { - LOG("xwimp_close_window: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x:%s", + error->errnum, error->errmess); } } } @@ -354,7 +358,8 @@ void ro_gui_status_bar_resize(struct status_bar *sb) state.w = sb->parent; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return; } window_width = state.visible.x1 - state.visible.x0; @@ -377,7 +382,8 @@ void ro_gui_status_bar_resize(struct status_bar *sb) extent.y1 = status_height - 4; error = xwimp_set_extent(sb->w, &extent); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -405,7 +411,10 @@ void ro_gui_status_bar_resize(struct status_bar *sb) wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_TS_EDGE_SHIFT); if (error) { - LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_open_window_nested: 0x%x: %s", + error->errnum, + error->errmess); return; } ro_gui_status_position_progress_bar(sb); @@ -413,7 +422,8 @@ void ro_gui_status_bar_resize(struct status_bar *sb) status_width - WIDGET_WIDTH, 0, status_width, status_height - 4); if (error) { - LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -454,7 +464,8 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw) /* redraw the window */ error = xwimp_redraw_window(redraw, &more); if (error) { - LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s", + error->errnum, error->errmess); return; } while (more) { @@ -463,7 +474,10 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw) error = xcolourtrans_set_font_colours(font_CURRENT, 0xeeeeee00, 0x00000000, 14, 0, 0, 0); if (error) { - LOG("xcolourtrans_set_font_colours: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_font_colours: 0x%x: %s", + error->errnum, + error->errmess); return; } code = rufl_paint(ro_gui_desktop_font_family, @@ -474,10 +488,13 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw) rufl_BLEND_FONT); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) - LOG("rufl_FONT_MANAGER_ERROR: 0x%x: %s", - rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_FONT_MANAGER_ERROR: 0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); else - LOG("rufl_paint: 0x%x", code); + NSLOG(netsurf, INFO, + "rufl_paint: 0x%x", code); } } @@ -493,7 +510,8 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw) error = xwimp_get_rectangle(redraw, &more); if (error) { - LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s", + error->errnum, error->errmess); return; } } @@ -532,7 +550,10 @@ bool ro_gui_status_bar_click(wimp_pointer *pointer) drag.initial.y1 = pointer->pos.y; error = xwimp_drag_box(&drag); if (error) { - LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_drag_box: 0x%x: %s", + error->errnum, + error->errmess); } break; } @@ -557,7 +578,8 @@ void ro_gui_status_bar_open(wimp_open *open) state.w = sb->parent; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return; } window_width = state.visible.x1 - state.visible.x0; @@ -596,7 +618,8 @@ void ro_gui_status_position_progress_bar(struct status_bar *sb) state.w = sb->w; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -626,7 +649,8 @@ void ro_gui_status_position_progress_bar(struct status_bar *sb) wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_TS_EDGE_SHIFT); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); } /* update the progress bar display on non-standard width */ diff --git a/frontends/riscos/gui/throbber.c b/frontends/riscos/gui/throbber.c index a326f806c..f3b79a68e 100644 --- a/frontends/riscos/gui/throbber.c +++ b/frontends/riscos/gui/throbber.c @@ -81,7 +81,7 @@ struct throbber *ro_gui_throbber_create(struct theme_descriptor *theme) throbber = malloc(sizeof(struct throbber)); if (throbber == NULL) { - LOG("No memory for malloc()"); + NSLOG(netsurf, INFO, "No memory for malloc()"); return NULL; } @@ -248,7 +248,8 @@ bool ro_gui_throbber_icon_update(struct throbber *throbber) error = xwimp_create_icon(&icon, &throbber->icon); if (error != NULL) { - LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); throbber->icon = -1; return false; @@ -259,7 +260,8 @@ bool ro_gui_throbber_icon_update(struct throbber *throbber) } else if (throbber->hidden && throbber->icon != -1) { error = xwimp_delete_icon(throbber->window, throbber->icon); if (error != NULL) { - LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -295,7 +297,8 @@ bool ro_gui_throbber_icon_resize(struct throbber *throbber) throbber->extent.x0, throbber->extent.y0, throbber->extent.x1, throbber->extent.y1); if (error != NULL) { - LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); throbber->icon = -1; return false; diff --git a/frontends/riscos/gui/url_bar.c b/frontends/riscos/gui/url_bar.c index a5ec3f8c6..ee5c689df 100644 --- a/frontends/riscos/gui/url_bar.c +++ b/frontends/riscos/gui/url_bar.c @@ -140,7 +140,7 @@ struct url_bar *ro_gui_url_bar_create(struct theme_descriptor *theme) url_bar = malloc(sizeof(struct url_bar)); if (url_bar == NULL) { - LOG("No memory for malloc()"); + NSLOG(netsurf, INFO, "No memory for malloc()"); return NULL; } @@ -240,7 +240,8 @@ static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full) url_bar->container_icon, x0, y0, x1, y1); if (error != NULL) { - LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); url_bar->container_icon = -1; return false; @@ -260,7 +261,8 @@ static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full) url_bar->suggest_icon, x0, y0, x1, y1); if (error != NULL) { - LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); url_bar->suggest_icon = -1; return false; @@ -281,7 +283,8 @@ static bool ro_gui_url_bar_icon_resize(struct url_bar *url_bar, bool full) url_bar->text_icon, x0, y0, x1, y1); if (error != NULL) { - LOG("xwimp_resize_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); url_bar->text_icon = -1; return false; @@ -362,7 +365,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar) wimp_ICON_BUTTON_TYPE_SHIFT); error = xwimp_create_icon(&icon, &url_bar->container_icon); if (error != NULL) { - LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); url_bar->container_icon = -1; return false; @@ -373,7 +377,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar) error = xwimp_delete_icon(url_bar->window, url_bar->container_icon); if (error != NULL) { - LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -399,7 +404,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar) wimp_ICON_BUTTON_TYPE_SHIFT); error = xwimp_create_icon(&icon, &url_bar->text_icon); if (error) { - LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); url_bar->text_icon = -1; return false; @@ -410,7 +416,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar) error = xwimp_delete_icon(url_bar->window, url_bar->text_icon); if (error != NULL) { - LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -430,7 +437,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar) wimp_ICON_BUTTON_TYPE_SHIFT); error = xwimp_create_icon(&icon, &url_bar->suggest_icon); if (error) { - LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -450,7 +458,8 @@ static bool ro_gui_url_bar_icon_update(struct url_bar *url_bar) error = xwimp_delete_icon(url_bar->window, url_bar->suggest_icon); if (error != NULL) { - LOG("xwimp_delete_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -940,7 +949,8 @@ bool ro_gui_url_bar_take_caret(struct url_bar *url_bar) error = xwimp_set_caret_position(url_bar->window, url_bar->text_icon, -1, -1, -1, 0); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; @@ -977,7 +987,7 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url, if (err != NSERROR_OK) { /* A bad encoding should never happen, so assert this */ assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_to_enc failed"); + NSLOG(netsurf, INFO, "utf8_to_enc failed"); /* Paranoia */ local_text = NULL; } @@ -993,7 +1003,8 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url, if (strlen(local_url) >= url_bar->text_size) { url_bar->text_buffer[0] = '\0'; ro_warn_user("LongURL", NULL); - LOG("Long URL (%zu chars): %s", strlen(url), url); + NSLOG(netsurf, INFO, "Long URL (%zu chars): %s", strlen(url), + url); } else { strncpy(url_bar->text_buffer, local_url, url_bar->text_size - 1); @@ -1021,7 +1032,8 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url, error = xwimp_get_caret_position(&caret); if (error) { - LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1034,7 +1046,10 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url, error = xwimp_set_caret_position(url_bar->window, url_bar->text_icon, 0, 0, -1, strlen(set_url)); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_set_caret_position: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -1123,7 +1138,8 @@ bool ro_gui_url_bar_get_url_extent(struct url_bar *url_bar, os_box *extent) state.i = url_bar->container_icon; error = xwimp_get_icon_state(&state); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } diff --git a/frontends/riscos/help.c b/frontends/riscos/help.c index b6871c5eb..952b3f2d1 100644 --- a/frontends/riscos/help.c +++ b/frontends/riscos/help.c @@ -166,7 +166,8 @@ void ro_gui_interactive_help_request(wimp_message *message) error = xwimp_get_menu_state(wimp_GIVEN_WINDOW_AND_ICON, &menu_tree, window, icon); if (error) { - LOG("xwimp_get_menu_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_menu_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -269,7 +270,8 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message, error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message *)reply, reply->sender); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -297,7 +299,10 @@ bool ro_gui_interactive_help_available(void) error = xtaskmanager_enumerate_tasks(context, &task, sizeof(taskmanager_task), &context, 0); if (error) { - LOG("xtaskmanager_enumerate_tasks: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xtaskmanager_enumerate_tasks: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); } @@ -334,7 +339,8 @@ void ro_gui_interactive_help_start(void) if ((help_start) && (help_start[0])) { error = xwimp_start_task("", &task); if (error) { - LOG("xwimp_start_tast: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_start_tast: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -344,7 +350,8 @@ void ro_gui_interactive_help_start(void) if (!task) { error = xwimp_start_task("Resources:$.Apps.!Help", &task); if (error) { - LOG("xwimp_start_tast: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_start_tast: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -354,7 +361,10 @@ void ro_gui_interactive_help_start(void) if (task) { error = xos_read_monotonic_time(&help_time); if (error) { - LOG("xwimp_read_monotonic_time: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_read_monotonic_time: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } diff --git a/frontends/riscos/hotlist.c b/frontends/riscos/hotlist.c index b055d1bec..b0ed1e2f4 100644 --- a/frontends/riscos/hotlist.c +++ b/frontends/riscos/hotlist.c @@ -548,19 +548,20 @@ nserror ro_gui_hotlist_present(void) return NSERROR_OK; } - LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_cli: 0x%x: %s", error->errnum, + error->errmess); ro_warn_user("Failed to launch external hotlist: %s", error->errmess); } res = ro_hotlist_init(); if (res == NSERROR_OK) { - LOG("Presenting"); + NSLOG(netsurf, INFO, "Presenting"); ro_gui_dialog_open_top(hotlist_window->core.wh, hotlist_window->core.toolbar, 600, 800); } else { - LOG("Failed presenting code %d", res); + NSLOG(netsurf, INFO, "Failed presenting code %d", res); } return res; diff --git a/frontends/riscos/iconbar.c b/frontends/riscos/iconbar.c index 3430ed2f0..23f97258b 100644 --- a/frontends/riscos/iconbar.c +++ b/frontends/riscos/iconbar.c @@ -95,7 +95,8 @@ void ro_gui_iconbar_initialise(void) { "!netsurf" } } }; error = xwimp_create_icon(&icon, 0); if (error) { - LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s", + error->errnum, error->errmess); die(error->errmess); } @@ -238,7 +239,8 @@ bool ro_gui_iconbar_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, return true; case APPLICATION_QUIT: if (ro_gui_prequit()) { - LOG("QUIT in response to user request"); + NSLOG(netsurf, INFO, + "QUIT in response to user request"); riscos_done = true; } return true; diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c index acbe62d98..30cb30096 100644 --- a/frontends/riscos/image.c +++ b/frontends/riscos/image.c @@ -142,7 +142,8 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y, } if (error) { - LOG("xtinct_plotscaled%s: 0x%x: %s", (alpha ? "alpha" : ""), error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xtinct_plotscaled%s: 0x%x: %s", + (alpha ? "alpha" : ""), error->errnum, error->errmess); return false; } @@ -176,13 +177,16 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width, colourtrans_CURRENT_PALETTE, 0, colourtrans_GIVEN_SPRITE, 0, 0, &size); if (error) { - LOG("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_generate_table_for_sprite: 0x%x: %s", + error->errnum, + error->errmess); return false; } table = calloc(size, sizeof(char)); if (!table) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); ro_warn_user("NoMemory", 0); return false; } @@ -193,7 +197,10 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width, colourtrans_CURRENT_PALETTE, table, colourtrans_GIVEN_SPRITE, 0, 0, 0); if (error) { - LOG("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_generate_table_for_sprite: 0x%x: %s", + error->errnum, + error->errmess); free(table); return false; } @@ -208,7 +215,10 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width, x, (int)(y - req_height), 8, &f, table); if (error) { - LOG("xosspriteop_put_sprite_scaled: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_put_sprite_scaled: 0x%x: %s", + error->errnum, + error->errmess); free(table); return false; } diff --git a/frontends/riscos/local_history.c b/frontends/riscos/local_history.c index f9f1f2e01..bbe6a1d12 100644 --- a/frontends/riscos/local_history.c +++ b/frontends/riscos/local_history.c @@ -154,8 +154,8 @@ ro_local_history_tooltip(struct ro_local_history_window *lhw, int x, int y) /* not over a tree entry => close tooltip window. */ error = xwimp_close_window(dialog_tooltip); if (error) { - LOG("xwimp_close_window: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } @@ -167,8 +167,8 @@ ro_local_history_tooltip(struct ro_local_history_window *lhw, int x, int y) nsurl_length(url) > 256 ? 256 : nsurl_length(url), &width); if (error) { - LOG("xwimptextop_string_width: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimptextop_string_width: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); nsurl_unref(url); return NSERROR_NOMEM; @@ -182,8 +182,8 @@ ro_local_history_tooltip(struct ro_local_history_window *lhw, int x, int y) ic.i = 0; error = xwimp_get_icon_state(&ic); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } @@ -191,8 +191,8 @@ ro_local_history_tooltip(struct ro_local_history_window *lhw, int x, int y) ic.icon.extent.x0, ic.icon.extent.y0, width + 16, ic.icon.extent.y1); if (error) { - LOG("xwimp_resize_icon: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_resize_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } @@ -200,8 +200,8 @@ ro_local_history_tooltip(struct ro_local_history_window *lhw, int x, int y) state.w = dialog_tooltip; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } @@ -211,15 +211,16 @@ ro_local_history_tooltip(struct ro_local_history_window *lhw, int x, int y) box.y0 = -36; error = xwimp_set_extent(dialog_tooltip, &box); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } @@ -233,8 +234,8 @@ ro_local_history_tooltip(struct ro_local_history_window *lhw, int x, int y) /* open window */ error = xwimp_open_window(PTR_WIMP_OPEN(&state)); if (error) { - LOG("xwimp_open_window: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } @@ -363,8 +364,8 @@ ro_local_history_open(struct ro_local_history_window *lhw, wimp_w parent) box.y0 = -height; error = xwimp_set_extent(lhw->core.wh, &box); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } @@ -373,8 +374,8 @@ ro_local_history_open(struct ro_local_history_window *lhw, wimp_w parent) state.w = lhw->core.wh; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } @@ -385,8 +386,8 @@ ro_local_history_open(struct ro_local_history_window *lhw, wimp_w parent) state.next = wimp_HIDDEN; error = xwimp_open_window(PTR_WIMP_OPEN(&state)); if (error) { - LOG("xwimp_open_window: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_NOMEM; } @@ -403,10 +404,10 @@ nserror ro_gui_local_history_present(wimp_w parent, struct browser_window *bw) res = ro_local_history_init(bw, &local_history_window); if (res == NSERROR_OK) { - LOG("Presenting"); + NSLOG(netsurf, INFO, "Presenting"); res = ro_local_history_open(local_history_window, parent); } else { - LOG("Failed presenting error code %d", res); + NSLOG(netsurf, INFO, "Failed presenting error code %d", res); } return res; diff --git a/frontends/riscos/menus.c b/frontends/riscos/menus.c index d46afa28e..a6e978a6c 100644 --- a/frontends/riscos/menus.c +++ b/frontends/riscos/menus.c @@ -232,7 +232,8 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) current_menu_open = true; error = xwimp_create_menu(menu, x - 64, y); if (error) { - LOG("xwimp_create_menu: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_menu: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MenuError", error->errmess); ro_gui_menu_closed(); } @@ -258,14 +259,16 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i) icon_state.i = i; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MenuError", error->errmess); return; } error = xwimp_get_icon_state(&icon_state); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MenuError", error->errmess); return; } @@ -291,7 +294,8 @@ void ro_gui_menu_destroy(void) error = xwimp_create_menu(wimp_CLOSE_MENU, 0, 0); if (error) { - LOG("xwimp_create_menu: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_menu: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MenuError", error->errmess); } @@ -354,7 +358,8 @@ void ro_gui_menu_selection(wimp_selection *selection) /* re-open the menu for Adjust clicks */ error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); ro_gui_menu_closed(); return; @@ -420,7 +425,8 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning) error = xwimp_create_sub_menu(menu_entry->sub_menu, warning->pos.x, warning->pos.y); if (error) { - LOG("xwimp_create_sub_menu: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_sub_menu: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MenuError", error->errmess); } } @@ -485,7 +491,8 @@ void ro_gui_menu_refresh(wimp_menu *menu) os_error *error; error = xwimp_create_menu(current_menu, 0, 0); if (error) { - LOG("xwimp_create_menu: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_menu: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MenuError", error->errmess); } } @@ -851,7 +858,8 @@ int ro_gui_menu_get_checksum(void) error = xwimp_get_menu_state((wimp_menu_state_flags)0, &menu_tree, 0, 0); if (error) { - LOG("xwimp_get_menu_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_menu_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MenuError", error->errmess); return 0; } @@ -894,7 +902,8 @@ bool ro_gui_menu_translate(struct menu_definition *menu) /* read current alphabet */ error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0, &alphabet); if (error) { - LOG("failed reading alphabet: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "failed reading alphabet: 0x%x: %s", + error->errnum, error->errmess); /* assume Latin1 */ alphabet = territory_ALPHABET_LATIN1; } @@ -909,7 +918,7 @@ bool ro_gui_menu_translate(struct menu_definition *menu) 0, &translated); if (err != NSERROR_OK) { assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_to_enc failed"); + NSLOG(netsurf, INFO, "utf8_to_enc failed"); return false; } @@ -926,7 +935,7 @@ bool ro_gui_menu_translate(struct menu_definition *menu) 0, &translated); if (err != NSERROR_OK) { assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_to_enc failed"); + NSLOG(netsurf, INFO, "utf8_to_enc failed"); return false; } diff --git a/frontends/riscos/message.c b/frontends/riscos/message.c index 1c54ea0b7..7a0216185 100644 --- a/frontends/riscos/message.c +++ b/frontends/riscos/message.c @@ -64,7 +64,8 @@ bool ro_message_send_message(wimp_event_no event, wimp_message *message, /* send a message */ error = xwimp_send_message(event, message, task); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -101,7 +102,10 @@ bool ro_message_send_message_to_window(wimp_event_no event, wimp_message *messag /* send a message */ error = xwimp_send_message_to_window(event, message, to_w, to_i, to_t); if (error) { - LOG("xwimp_send_message_to_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_send_message_to_window: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } diff --git a/frontends/riscos/mouse.c b/frontends/riscos/mouse.c index a0cc0e7ce..89184cff3 100644 --- a/frontends/riscos/mouse.c +++ b/frontends/riscos/mouse.c @@ -81,7 +81,8 @@ void ro_mouse_poll(void) error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -194,7 +195,7 @@ void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data), ro_mouse_ignore_leaving_event == false) ro_mouse_poll_end_callback(NULL, ro_mouse_poll_data); - LOG("Unexpected mouse track termination."); + NSLOG(netsurf, INFO, "Unexpected mouse track termination."); ro_mouse_ignore_leaving_event = false; ro_mouse_poll_end_callback = NULL; diff --git a/frontends/riscos/plotters.c b/frontends/riscos/plotters.c index b459ba1f9..2fbd12aeb 100644 --- a/frontends/riscos/plotters.c +++ b/frontends/riscos/plotters.c @@ -79,15 +79,16 @@ ro_plot_draw_path(const draw_path * const path, error = xcolourtrans_set_gcol(c << 8, 0, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } error = xdraw_stroke(path, 0, 0, 0, width * 2 * 256, &line_style, dash_pattern); if (error) { - LOG("xdraw_stroke: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s", error->errnum, + error->errmess); return NSERROR_INVALID; } @@ -115,8 +116,8 @@ ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip) int clip_y1 = ro_plot_origin_y - clip->y1 * 2; if (clip_x1 < clip_x0 || clip_y0 < clip_y1) { - LOG("bad clip rectangle %i %i %i %i", - clip_x0, clip_y0, clip_x1, clip_y1); + NSLOG(netsurf, INFO, "bad clip rectangle %i %i %i %i", + clip_x0, clip_y0, clip_x1, clip_y1); return NSERROR_BAD_SIZE; } @@ -132,7 +133,8 @@ ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip) error = xos_writen(buf, 9); if (error) { - LOG("xos_writen: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_writen: 0x%x: %s", error->errnum, + error->errmess); return NSERROR_INVALID; } @@ -173,8 +175,8 @@ ro_plot_arc(const struct redraw_context *ctx, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } @@ -188,19 +190,22 @@ ro_plot_arc(const struct redraw_context *ctx, error = xos_plot(os_MOVE_TO, x, y); /* move to centre */ if (error) { - LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum, + error->errmess); return NSERROR_INVALID; } error = xos_plot(os_MOVE_TO, sx, sy); /* move to start */ if (error) { - LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum, + error->errmess); return NSERROR_INVALID; } error = xos_plot(os_PLOT_ARC | os_PLOT_TO, ex, ey); /* arc to end */ if (error) { - LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum, + error->errmess); return NSERROR_INVALID; } @@ -230,20 +235,24 @@ ro_plot_disc(const struct redraw_context *ctx, error = xcolourtrans_set_gcol(style->fill_colour << 8, 0, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, + error->errmess); return NSERROR_INVALID; } error = xos_plot(os_MOVE_TO, ro_plot_origin_x + x * 2, ro_plot_origin_y - y * 2); if (error) { - LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } error = xos_plot(os_PLOT_CIRCLE | os_PLOT_BY, radius * 2, 0); if (error) { - LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } } @@ -253,22 +262,26 @@ ro_plot_disc(const struct redraw_context *ctx, error = xcolourtrans_set_gcol(style->stroke_colour << 8, 0, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, + error->errmess); return NSERROR_INVALID; } error = xos_plot(os_MOVE_TO, ro_plot_origin_x + x * 2, ro_plot_origin_y - y * 2); if (error) { - LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } error = xos_plot(os_PLOT_CIRCLE_OUTLINE | os_PLOT_BY, radius * 2, 0); if (error) { - LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } } @@ -343,8 +356,10 @@ ro_plot_rectangle(const struct redraw_context *ctx, colourtrans_USE_ECFS_GCOL, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, + error->errmess); return NSERROR_INVALID; } @@ -352,7 +367,8 @@ ro_plot_rectangle(const struct redraw_context *ctx, ro_plot_origin_x + rect->x0 * 2, ro_plot_origin_y - rect->y0 * 2 - 1); if (error) { - LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } @@ -360,7 +376,8 @@ ro_plot_rectangle(const struct redraw_context *ctx, ro_plot_origin_x + rect->x1 * 2 - 1, ro_plot_origin_y - rect->y1 * 2); if (error) { - LOG("xos_plot: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } } @@ -441,13 +458,14 @@ ro_plot_polygon(const struct redraw_context *ctx, error = xcolourtrans_set_gcol(style->fill_colour << 8, 0, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INVALID; } error = xdraw_fill((draw_path *) path, 0, 0, 0); if (error) { - LOG("xdraw_fill: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xdraw_fill: 0x%x: %s", error->errnum, + error->errmess); return NSERROR_INVALID; } @@ -494,13 +512,13 @@ ro_plot_path(const struct redraw_context *ctx, } if (p[0] != PLOTTER_PATH_MOVE) { - LOG("path doesn't start with a move"); + NSLOG(netsurf, INFO, "path doesn't start with a move"); goto error; } path = malloc(sizeof *path * (n + 10)); if (!path) { - LOG("out of memory"); + NSLOG(netsurf, INFO, "out of memory"); goto error; } @@ -528,7 +546,7 @@ ro_plot_path(const struct redraw_context *ctx, path[i + 6] = -p[i + 6] * 2 * 256; i += 7; } else { - LOG("bad path command %f", p[i]); + NSLOG(netsurf, INFO, "bad path command %f", p[i]); goto error; } } @@ -546,15 +564,17 @@ ro_plot_path(const struct redraw_context *ctx, error = xcolourtrans_set_gcol(pstyle->fill_colour << 8, 0, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, + error->errmess); goto error; } error = xdraw_fill((draw_path *) path, 0, &trfm, 0); if (error) { - LOG("xdraw_stroke: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s", + error->errnum, error->errmess); goto error; } } @@ -563,16 +583,18 @@ ro_plot_path(const struct redraw_context *ctx, error = xcolourtrans_set_gcol(pstyle->stroke_colour << 8, 0, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, + error->errmess); goto error; } error = xdraw_stroke((draw_path *) path, 0, &trfm, 0, width * 2 * 256, &line_style, 0); if (error) { - LOG("xdraw_stroke: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s", + error->errnum, error->errmess); goto error; } } @@ -623,7 +645,7 @@ ro_plot_bitmap(const struct redraw_context *ctx, buffer = riscos_bitmap_get_buffer(bitmap); if (!buffer) { - LOG("bitmap_get_buffer failed"); + NSLOG(netsurf, INFO, "bitmap_get_buffer failed"); return NSERROR_INVALID; } @@ -669,8 +691,10 @@ ro_plot_text(const struct redraw_context *ctx, fstyle->background << 8, fstyle->foreground << 8, 14, 0, 0, 0); if (error) { - LOG("xcolourtrans_set_font_colours: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_font_colours: 0x%x: %s", + error->errnum, + error->errmess); return NSERROR_INVALID; } diff --git a/frontends/riscos/print.c b/frontends/riscos/print.c index b7ddd4e53..d965baff4 100644 --- a/frontends/riscos/print.c +++ b/frontends/riscos/print.c @@ -169,7 +169,8 @@ void ro_gui_print_prepare(struct gui_window *g) /* Read Printer Driver name */ error = xpdriver_info(0, 0, 0, 0, &desc, 0, 0, 0); if (error) { - LOG("xpdriver_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_info: 0x%x: %s", + error->errnum, error->errmess); printers_exists = false; } @@ -306,7 +307,8 @@ void print_send_printsave(struct hlcache_handle *h) e = xwimp_send_message(wimp_USER_MESSAGE_RECORDED, (wimp_message *)&m, 0); if (e) { - LOG("xwimp_send_message: 0x%x: %s", e->errnum, e->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + e->errnum, e->errmess); ro_warn_user("WimpError", e->errmess); ro_print_cleanup(); } @@ -330,7 +332,8 @@ bool print_send_printtypeknown(wimp_message *m) m->action = message_PRINT_TYPE_KNOWN; e = xwimp_send_message(wimp_USER_MESSAGE, m, m->sender); if (e) { - LOG("xwimp_send_message: 0x%x: %s", e->errnum, e->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + e->errnum, e->errmess); ro_warn_user("WimpError", e->errmess); return false; } @@ -436,7 +439,8 @@ bool ro_print_ack(wimp_message *m) /* read printer driver type */ error = xpdriver_info(&info_type, 0, 0, 0, 0, 0, 0, 0); if (error) { - LOG("xpdriver_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); ro_print_cleanup(); return true; @@ -461,7 +465,8 @@ bool ro_print_ack(wimp_message *m) error = xwimp_send_message(wimp_USER_MESSAGE_RECORDED, m, m->sender); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); /* and delete temporary file */ xosfile_delete(m->data.data_xfer.file_name, @@ -533,7 +538,8 @@ bool print_document(struct gui_window *g, const char *filename) /* read printer driver features */ error = xpdriver_info(0, 0, 0, &features, 0, 0, 0, 0); if (error) { - LOG("xpdriver_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); return false; } @@ -541,7 +547,8 @@ bool print_document(struct gui_window *g, const char *filename) /* read page size */ error = xpdriver_page_size(0, 0, &left, &bottom, &right, &top); if (error) { - LOG("xpdriver_page_size: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_page_size: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); return false; } @@ -564,7 +571,8 @@ bool print_document(struct gui_window *g, const char *filename) error = xosfind_openoutw(osfind_NO_PATH | osfind_ERROR_IF_DIR | osfind_ERROR_IF_ABSENT, filename, 0, &fhandle); if (error) { - LOG("xosfind_openoutw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_openoutw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); return false; } @@ -572,7 +580,8 @@ bool print_document(struct gui_window *g, const char *filename) /* select print job */ error = xpdriver_select_jobw(fhandle, "NetSurf", &old_job); if (error) { - LOG("xpdriver_select_jobw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_select_jobw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); xosfind_closew(fhandle); return false; @@ -632,18 +641,23 @@ bool print_document(struct gui_window *g, const char *filename) /* give page rectangle */ error = xpdriver_give_rectangle(0, &b, &t, &p, os_COLOUR_WHITE); if (error) { - LOG("xpdriver_give_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xpdriver_give_rectangle: 0x%x: %s", + error->errnum, + error->errmess); error_message = error->errmess; goto error; } - LOG("given rectangle: [(%d, %d), (%d, %d)]", b.x0, b.y0, b.x1, b.y1); + NSLOG(netsurf, INFO, "given rectangle: [(%d, %d), (%d, %d)]", + b.x0, b.y0, b.x1, b.y1); /* and redraw the document */ error = xpdriver_draw_page(print_num_copies, &b, 0, 0, &more, 0); if (error) { - LOG("xpdriver_draw_page: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_draw_page: 0x%x: %s", + error->errnum, error->errmess); error_message = error->errmess; goto error; } @@ -657,7 +671,9 @@ bool print_document(struct gui_window *g, const char *filename) .plot = &ro_plotters }; - LOG("redrawing area: [(%d, %d), (%d, %d)]", b.x0, b.y0, b.x1, b.y1); + NSLOG(netsurf, INFO, + "redrawing area: [(%d, %d), (%d, %d)]", b.x0, + b.y0, b.x1, b.y1); clip.x0 = (b.x0 - ro_plot_origin_x) / 2; clip.y0 = (ro_plot_origin_y - b.y1) / 2; clip.x1 = (b.x1 - ro_plot_origin_x) / 2; @@ -679,7 +695,10 @@ bool print_document(struct gui_window *g, const char *filename) error = xpdriver_get_rectangle(&b, &more, 0); if (error) { - LOG("xpdriver_get_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xpdriver_get_rectangle: 0x%x: %s", + error->errnum, + error->errmess); error_message = error->errmess; goto error; } @@ -701,14 +720,16 @@ bool print_document(struct gui_window *g, const char *filename) error = (os_error *) _swix(PDriver_EndJob, _IN(0), (int) fhandle); if (error) { - LOG("xpdriver_end_jobw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_end_jobw: 0x%x: %s", + error->errnum, error->errmess); error_message = error->errmess; goto error; } error = xosfind_closew(fhandle); if (error) { - LOG("xosfind_closew: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_closew: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("PrintError", error->errmess); return false; } @@ -716,7 +737,10 @@ bool print_document(struct gui_window *g, const char *filename) if (old_job) { error = xpdriver_select_jobw(old_job, 0, 0); if (error) { - LOG("xpdriver_select_jobw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xpdriver_select_jobw: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("PrintError", error->errmess); /* the printing succeeded anyway */ return true; @@ -855,11 +879,14 @@ print_fonts_plot_text(const struct redraw_context *ctx, text, length, 0, 0, print_fonts_callback, 0); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) { - LOG("rufl_paint_callback: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", - rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_paint_callback: rufl_FONT_MANAGER_ERROR: ""0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); print_fonts_error = rufl_fm_error->errmess; } else { - LOG("rufl_paint_callback: 0x%x", code); + NSLOG(netsurf, INFO, "rufl_paint_callback: 0x%x", + code); } return NSERROR_INVALID; } @@ -934,18 +961,22 @@ const char *print_declare_fonts(struct hlcache_handle *h) } for (i = 0; i != print_fonts_count; ++i) { - LOG("%u %s", i, print_fonts_list[i]); + NSLOG(netsurf, INFO, "%u %s", i, print_fonts_list[i]); error = xpdriver_declare_font(0, print_fonts_list[i], pdriver_KERNED); if (error) { - LOG("xpdriver_declare_font: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xpdriver_declare_font: 0x%x: %s", + error->errnum, + error->errmess); error_message = error->errmess; goto end; } } error = xpdriver_declare_font(0, 0, 0); if (error) { - LOG("xpdriver_declare_font: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xpdriver_declare_font: 0x%x: %s", + error->errnum, error->errmess); error_message = error->errmess; goto end; } diff --git a/frontends/riscos/query.c b/frontends/riscos/query.c index 1d7cf5120..49aea6321 100644 --- a/frontends/riscos/query.c +++ b/frontends/riscos/query.c @@ -175,7 +175,7 @@ query_id query_user_xy(const char *query, const char *detail, err = utf8_to_local_encoding(yes, 0, &local_text); if (err != NSERROR_OK) { assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_to_local_encoding_failed"); + NSLOG(netsurf, INFO, "utf8_to_local_encoding_failed"); local_text = NULL; } @@ -191,7 +191,8 @@ query_id query_user_xy(const char *query, const char *detail, error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width); if (error) { - LOG("xwimptextop_string_width: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimptextop_string_width: 0x%x:%s", + error->errnum, error->errmess); width = len * 16; } if (!query_yes_width) query_yes_width = icn->extent.x1 - icn->extent.x0; @@ -204,7 +205,7 @@ query_id query_user_xy(const char *query, const char *detail, err = utf8_to_local_encoding(no, 0, &local_text); if (err != NSERROR_OK) { assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_to_local_encoding_failed"); + NSLOG(netsurf, INFO, "utf8_to_local_encoding_failed"); local_text = NULL; } @@ -222,7 +223,8 @@ query_id query_user_xy(const char *query, const char *detail, icn->extent.x1 = tx - 16; error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width); if (error) { - LOG("xwimptextop_string_width: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimptextop_string_width: 0x%x:%s", + error->errnum, error->errmess); width = len * 16; } width += 28; @@ -263,7 +265,8 @@ query_id query_user_xy(const char *query, const char *detail, error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1); if (error) { - LOG("xwimp_get_caret_position: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -307,7 +310,10 @@ void ro_gui_query_window_bring_to_front(query_id id) error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1); if (error) { - LOG("xwimp_get_caret_position: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_caret_position: 0x%x : %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -327,7 +333,8 @@ void ro_gui_query_close(wimp_w w) ro_gui_dialog_close(w); error = xwimp_delete_window(qw->window); if (error) { - LOG("xwimp_delete_window: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } ro_gui_wimp_event_finalise(w); diff --git a/frontends/riscos/save.c b/frontends/riscos/save.c index bed0f5dd1..76ce6d3e5 100644 --- a/frontends/riscos/save.c +++ b/frontends/riscos/save.c @@ -166,7 +166,8 @@ wimp_w ro_gui_saveas_create(const char *template_name) error = xosmodule_alloc(area_size, (void **) &area); if (error) { - LOG("xosmodule_alloc: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosmodule_alloc: 0x%x: %s", + error->errnum, error->errmess); xwimp_close_template(); die(error->errmess); } else { @@ -176,7 +177,10 @@ wimp_w ro_gui_saveas_create(const char *template_name) error = xosspriteop_clear_sprites(osspriteop_USER_AREA, saveas_area); if (error) { - LOG("xosspriteop_clear_sprites: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_clear_sprites: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); xosmodule_free(saveas_area); @@ -192,7 +196,8 @@ wimp_w ro_gui_saveas_create(const char *template_name) /* create window */ error = xwimp_create_window(window, &w); if (error) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); xwimp_close_template(); die(error->errmess); } @@ -212,7 +217,8 @@ void ro_gui_saveas_quit(void) if (saveas_area) { os_error *error = xosmodule_free(saveas_area); if (error) { - LOG("xosmodule_free: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosmodule_free: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); } saveas_area = NULL; @@ -239,14 +245,14 @@ ro_gui_save_create_thumbnail(struct hlcache_handle *h, const char *name) bitmap = riscos_bitmap_create(34, 34, BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY); if (!bitmap) { - LOG("Thumbnail initialisation failed."); + NSLOG(netsurf, INFO, "Thumbnail initialisation failed."); return false; } riscos_bitmap_render(bitmap, h); area = riscos_bitmap_convert_8bpp(bitmap); riscos_bitmap_destroy(bitmap); if (!area) { - LOG("Thumbnail conversion failed."); + NSLOG(netsurf, INFO, "Thumbnail conversion failed."); return false; } @@ -391,7 +397,10 @@ ro_gui_save_set_state(struct hlcache_handle *h, gui_save_type save_type, } if (error) { - LOG("ro_gui_wimp_get_sprite: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "ro_gui_wimp_get_sprite: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); } else { /* the sprite area should always be large enough for @@ -501,7 +510,8 @@ static void ro_gui_save_drag_end(wimp_dragged *drag, void *data) error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -627,7 +637,8 @@ static void ro_gui_save_done(void) error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); } } @@ -667,7 +678,10 @@ static void ro_gui_save_done(void) ro_gui_dialog_close(dialog_saveas); error = xwimp_create_menu(wimp_CLOSE_MENU, 0, 0); if (error) { - LOG("xwimp_create_menu: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_create_menu: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MenuError", error->errmess); } } @@ -770,8 +784,8 @@ static void ro_gui_save_set_file_type(const char *path, lwc_string *mime_type) error = xosfile_set_type(path, rotype); if (error != NULL) { - LOG("xosfile_set_type: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s", + error->errnum, error->errmess); } } @@ -798,7 +812,8 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path) /* Create dir */ error = xosfile_create_dir(path, 0); if (error) { - LOG("xosfile_create_dir: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_create_dir: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); return false; } @@ -807,7 +822,7 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path) snprintf(buf, sizeof buf, "%s.!Run", path); fp = fopen(buf, "w"); if (!fp) { - LOG("fopen(): errno = %i", errno); + NSLOG(netsurf, INFO, "fopen(): errno = %i", errno); ro_warn_user("SaveError", strerror(errno)); return false; } @@ -816,7 +831,8 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path) fclose(fp); error = xosfile_set_type(buf, 0xfeb); if (error) { - LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_set_type: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); return false; } @@ -825,7 +841,8 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path) snprintf(buf, sizeof buf, "%s.!RunImage", path); fp = fopen(buf, "w"); if (!fp) { - LOG("Creating !RunImage failed: errno = %i", errno); + NSLOG(netsurf, INFO, "Creating !RunImage failed: errno = %i", + errno); } else { fclose(fp); } @@ -851,7 +868,10 @@ static bool ro_gui_save_complete(struct hlcache_handle *h, char *path) error = xosspriteop_save_sprite_file(osspriteop_NAME, saveas_area, buf); if (error) { - LOG("xosspriteop_save_sprite_file: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_save_sprite_file: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("SaveError", error->errmess); return false; } @@ -897,7 +917,10 @@ static bool ro_gui_save_object_native(struct hlcache_handle *h, char *path) (byte *) source_data, (byte *) source_data + source_size); if (error != NULL) { - LOG("xosfile_save_stamped: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfile_save_stamped: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("SaveError", error->errmess); return false; } @@ -947,7 +970,8 @@ ro_gui_save_content(struct hlcache_handle *h, char *path, bool force_overwrite) error = xosfile_read_stamped(path, &obj_type, NULL, NULL, NULL, NULL, NULL); if (error) { - LOG("xosfile_read_stamped: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_read_stamped: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); return false; } @@ -1003,7 +1027,10 @@ ro_gui_save_content(struct hlcache_handle *h, char *path, bool force_overwrite) (byte *) source_data, (byte *) source_data + source_size); if (error) { - LOG("xosfile_save_stamped: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfile_save_stamped: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("SaveError", error->errmess); return false; } @@ -1029,14 +1056,20 @@ ro_gui_save_content(struct hlcache_handle *h, char *path, bool force_overwrite) return false; error = xosfile_set_type(path, 0xfaf); if (error) - LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfile_set_type: 0x%x: %s", + error->errnum, + error->errmess); break; case GUI_SAVE_HISTORY_EXPORT_HTML: if (global_history_export(path, NULL) != NSERROR_OK) return false; error = xosfile_set_type(path, 0xfaf); if (error) - LOG("xosfile_set_type: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfile_set_type: 0x%x: %s", + error->errnum, + error->errmess); break; case GUI_SAVE_TEXT_SELECTION: @@ -1056,7 +1089,10 @@ ro_gui_save_content(struct hlcache_handle *h, char *path, bool force_overwrite) return ro_gui_save_clipboard(path); default: - LOG("Unexpected content type: %d, path %s", gui_save_current_type, path); + NSLOG(netsurf, INFO, + "Unexpected content type: %d, path %s", + gui_save_current_type, + path); return false; } return true; @@ -1121,7 +1157,8 @@ void gui_drag_save_object(struct gui_window *g, error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1158,7 +1195,8 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection) error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1210,8 +1248,8 @@ void ro_gui_drag_save_link(gui_save_type save_type, const nsurl *url, error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1252,7 +1290,10 @@ void ro_gui_drag_icon(int x, int y, const char *sprite) saveas_area, (osspriteop_id)sprite, NULL); if (error) { if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) { - LOG("xosspriteop_select_sprite: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_select_sprite: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); } } @@ -1272,7 +1313,8 @@ void ro_gui_drag_icon(int x, int y, const char *sprite) return; } - LOG("xdragasprite_start: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xdragasprite_start: 0x%x: %s", + error->errnum, error->errmess); } drag.type = wimp_DRAG_USER_FIXED; @@ -1285,7 +1327,8 @@ void ro_gui_drag_icon(int x, int y, const char *sprite) error = xwimp_drag_box(&drag); if (error) { - LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("DragError", error->errmess); } else { dragbox_active = true; @@ -1323,14 +1366,20 @@ void ro_gui_drag_box_cancel(void) if (using_dragasprite) { error = xdragasprite_stop(); if (error) { - LOG("xdragasprite_stop: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xdragasprite_stop: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } else { error = xwimp_drag_box(NULL); if (error) { - LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_drag_box: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -1384,7 +1433,8 @@ void ro_gui_save_datasave_ack(wimp_message *message) default: if (!gui_save_content) { - LOG("unexpected DataSaveAck: gui_save_content not set"); + NSLOG(netsurf, INFO, + "unexpected DataSaveAck: gui_save_content not set"); return; } break; diff --git a/frontends/riscos/save_draw.c b/frontends/riscos/save_draw.c index 1e0bc1ec6..9ee730434 100644 --- a/frontends/riscos/save_draw.c +++ b/frontends/riscos/save_draw.c @@ -54,7 +54,7 @@ static int ro_save_draw_height; */ static nserror ro_save_draw_error(pencil_code code) { - LOG("code %i", code); + NSLOG(netsurf, INFO, "code %i", code); switch (code) { case pencil_OK: @@ -333,13 +333,13 @@ ro_save_draw_path(const struct redraw_context *ctx, return NSERROR_OK; if (p[0] != PLOTTER_PATH_MOVE) { - LOG("path doesn't start with a move"); + NSLOG(netsurf, INFO, "path doesn't start with a move"); return NSERROR_INVALID; } path = malloc(sizeof *path * (n + 10)); if (!path) { - LOG("out of memory"); + NSLOG(netsurf, INFO, "out of memory"); return NSERROR_INVALID; } @@ -389,7 +389,7 @@ ro_save_draw_path(const struct redraw_context *ctx, i += 7; empty_path = false; } else { - LOG("bad path command %f", p[i]); + NSLOG(netsurf, INFO, "bad path command %f", p[i]); free(path); return NSERROR_INVALID; } @@ -624,8 +624,8 @@ bool save_as_draw(struct hlcache_handle *h, const char *path) (byte *) drawfile_buffer, (byte *) drawfile_buffer + drawfile_size); if (error) { - LOG("xosfile_save_stamped failed: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_save_stamped failed: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); pencil_free(ro_save_draw_diagram); return false; diff --git a/frontends/riscos/schedule.c b/frontends/riscos/schedule.c index 54308b7a9..cb44d906d 100644 --- a/frontends/riscos/schedule.c +++ b/frontends/riscos/schedule.c @@ -108,7 +108,7 @@ nserror riscos_schedule(int t, void (*callback)(void *p), void *p) entry = malloc(sizeof *entry); if (!entry) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); return NSERROR_NOMEM; } diff --git a/frontends/riscos/sslcert.c b/frontends/riscos/sslcert.c index 85b84456e..4d81268f4 100644 --- a/frontends/riscos/sslcert.c +++ b/frontends/riscos/sslcert.c @@ -82,14 +82,14 @@ static void ro_gui_cert_release_window(struct ro_cert_window *certw) error = xwimp_delete_window(certw->wh); if (error) { - LOG("xwimp_delete_window: 0x%x:%s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s", + error->errnum, error->errmess); } error = xwimp_delete_window(certw->core.wh); if (error) { - LOG("xwimp_delete_window: 0x%x:%s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s", + error->errnum, error->errmess); } free(certw); @@ -165,16 +165,16 @@ static nserror cert_attach_pane(wimp_w parent, wimp_w pane) winfo.w = pane; error = xwimp_get_window_info_header_only(&winfo); if (error) { - LOG("xwimp_get_window_info: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_info: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INIT_FAILED; } wstate.w = parent; error = xwimp_get_window_state(&wstate); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INIT_FAILED; } @@ -182,8 +182,8 @@ static nserror cert_attach_pane(wimp_w parent, wimp_w pane) istate.i = ICON_SSL_PANE; error = xwimp_get_icon_state(&istate); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INIT_FAILED; } @@ -211,8 +211,8 @@ static nserror cert_attach_pane(wimp_w parent, wimp_w pane) if (set_extent) { error = xwimp_set_extent(pane, &(winfo.extent)); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INIT_FAILED; } } @@ -225,8 +225,8 @@ static nserror cert_attach_pane(wimp_w parent, wimp_w pane) wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_LS_EDGE_SHIFT | wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_RS_EDGE_SHIFT); if (error) { - LOG("xwimp_open_window_nested: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window_nested: 0x%x: %s", + error->errnum, error->errmess); return NSERROR_INIT_FAILED; } @@ -336,8 +336,8 @@ gui_cert_verify(nsurl *url, /* Create the SSL window */ error = xwimp_create_window(dialog_cert_template, &ncwin->wh); if (error) { - LOG("xwimp_create_window: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); free(ncwin); return NSERROR_INIT_FAILED; } @@ -345,8 +345,8 @@ gui_cert_verify(nsurl *url, /* create ssl viewer pane window */ error = xwimp_create_window(cert_tree_template, &ncwin->core.wh); if (error) { - LOG("xwimp_create_window: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); free(ncwin); return NSERROR_INIT_FAILED; } diff --git a/frontends/riscos/textarea.c b/frontends/riscos/textarea.c index d9872927c..6f41c640b 100644 --- a/frontends/riscos/textarea.c +++ b/frontends/riscos/textarea.c @@ -138,7 +138,7 @@ uintptr_t ro_textarea_create(wimp_w parent, wimp_i icon, unsigned int flags, ret = malloc(sizeof(struct text_area)); if (!ret) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); return 0; } @@ -148,7 +148,7 @@ uintptr_t ro_textarea_create(wimp_w parent, wimp_i icon, unsigned int flags, ret->flags = flags; ret->text = malloc(64); if (!ret->text) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); free(ret); return 0; } @@ -160,7 +160,7 @@ uintptr_t ro_textarea_create(wimp_w parent, wimp_i icon, unsigned int flags, // ret->selection_end = (unsigned int)-1; ret->font_family = strdup(font_family ? font_family : "Corpus"); if (!ret->font_family) { - LOG("strdup failed"); + NSLOG(netsurf, INFO, "strdup failed"); free(ret->text); free(ret); return 0; @@ -181,7 +181,8 @@ uintptr_t ro_textarea_create(wimp_w parent, wimp_i icon, unsigned int flags, text_area_definition.title_fg = wimp_COLOUR_BLACK; error = xwimp_create_window(&text_area_definition, &ret->window); if (error) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); free(ret->font_family); free(ret->text); free(ret); @@ -228,7 +229,8 @@ bool ro_textarea_update(uintptr_t self) state.w = ta->parent; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return false; } @@ -236,7 +238,8 @@ bool ro_textarea_update(uintptr_t self) istate.i = ta->icon; error = xwimp_get_icon_state(&istate); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); return false; } @@ -267,7 +270,8 @@ bool ro_textarea_update(uintptr_t self) error = xwimp_set_extent(ta->window, &extent); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); return false; } @@ -282,7 +286,8 @@ bool ro_textarea_update(uintptr_t self) wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_RS_EDGE_SHIFT); if (error) { - LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window_nested: 0x%x: %s", + error->errnum, error->errmess); return false; } @@ -307,7 +312,8 @@ void ro_textarea_destroy(uintptr_t self) error = xwimp_delete_window(ta->window); if (error) { - LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s", + error->errnum, error->errmess); } ro_gui_wimp_event_finalise(ta->window); @@ -331,14 +337,14 @@ bool ro_textarea_set_text(uintptr_t self, const char *text) ta = (struct text_area *)self; if (!ta || ta->magic != MAGIC) { - LOG("magic doesn't match"); + NSLOG(netsurf, INFO, "magic doesn't match"); return true; } if (len >= ta->text_alloc) { char *temp = realloc(ta->text, len + 64); if (!temp) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return false; } ta->text = temp; @@ -368,7 +374,7 @@ int ro_textarea_get_text(uintptr_t self, char *buf, unsigned int len) ta = (struct text_area *)self; if (!ta || ta->magic != MAGIC) { - LOG("magic doesn't match"); + NSLOG(netsurf, INFO, "magic doesn't match"); return -1; } @@ -378,7 +384,7 @@ int ro_textarea_get_text(uintptr_t self, char *buf, unsigned int len) } if (len < ta->text_len) { - LOG("buffer too small"); + NSLOG(netsurf, INFO, "buffer too small"); return -1; } @@ -403,7 +409,7 @@ void ro_textarea_insert_text(uintptr_t self, unsigned int index, ta = (struct text_area *)self; if (!ta || ta->magic != MAGIC) { - LOG("magic doesn't match"); + NSLOG(netsurf, INFO, "magic doesn't match"); return; } @@ -420,7 +426,7 @@ void ro_textarea_insert_text(uintptr_t self, unsigned int index, if (b_len + ta->text_len >= ta->text_alloc) { char *temp = realloc(ta->text, b_len + ta->text_len + 64); if (!temp) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return; } @@ -457,7 +463,7 @@ void ro_textarea_replace_text(uintptr_t self, unsigned int start, ta = (struct text_area *)self; if (!ta || ta->magic != MAGIC) { - LOG("magic doesn't match"); + NSLOG(netsurf, INFO, "magic doesn't match"); return; } @@ -491,7 +497,7 @@ void ro_textarea_replace_text(uintptr_t self, unsigned int start, char *temp = realloc(ta->text, b_len + ta->text_len - (b_end - b_start) + 64); if (!temp) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return; } @@ -532,7 +538,7 @@ void ro_textarea_set_caret(uintptr_t self, unsigned int caret) ta = (struct text_area *)self; if (!ta || ta->magic != MAGIC) { - LOG("magic doesn't match"); + NSLOG(netsurf, INFO, "magic doesn't match"); return; } @@ -574,9 +580,10 @@ void ro_textarea_set_caret(uintptr_t self, unsigned int caret) b_off - ta->lines[ta->caret_pos.line].b_start, &x); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) - LOG("rufl_width: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, "rufl_width: 0x%x: %s", + rufl_fm_error->errnum, rufl_fm_error->errmess); else - LOG("rufl_width: 0x%x", code); + NSLOG(netsurf, INFO, "rufl_width: 0x%x", code); return; } @@ -585,7 +592,8 @@ void ro_textarea_set_caret(uintptr_t self, unsigned int caret) ta->line_height / 4 + ta->line_spacing, os_line_height.y, -1); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s", + error->errnum, error->errmess); return; } } @@ -609,7 +617,7 @@ void ro_textarea_set_caret_xy(uintptr_t self, int x, int y) ta = (struct text_area *)self; if (!ta || ta->magic != MAGIC) { - LOG("magic doesn't match"); + NSLOG(netsurf, INFO, "magic doesn't match"); return; } @@ -623,7 +631,8 @@ void ro_textarea_set_caret_xy(uintptr_t self, int x, int y) state.w = ta->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -644,9 +653,10 @@ void ro_textarea_set_caret_xy(uintptr_t self, int x, int y) x, &b_off, &x); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) - LOG("rufl_x_to_offset: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, "rufl_x_to_offset: 0x%x: %s", + rufl_fm_error->errnum, rufl_fm_error->errmess); else - LOG("rufl_x_to_offset: 0x%x", code); + NSLOG(netsurf, INFO, "rufl_x_to_offset: 0x%x", code); return; } @@ -670,7 +680,7 @@ unsigned int ro_textarea_get_caret(uintptr_t self) ta = (struct text_area *)self; if (!ta || ta->magic != MAGIC) { - LOG("magic doesn't match"); + NSLOG(netsurf, INFO, "magic doesn't match"); return -1; } @@ -711,7 +721,7 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line) ta->lines = malloc(LINE_CHUNK_SIZE * sizeof(struct line_info)); if (!ta->lines) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); return; } } @@ -734,9 +744,13 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line) &b_off, &x); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) - LOG("rufl_x_to_offset: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_x_to_offset: 0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); else - LOG("rufl_x_to_offset: 0x%x", code); + NSLOG(netsurf, INFO, + "rufl_x_to_offset: 0x%x", code); return; } @@ -745,7 +759,7 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line) (line_count + LINE_CHUNK_SIZE) * sizeof(struct line_info)); if (!temp) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); return; } @@ -809,7 +823,8 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line) error = xwimp_set_extent(ta->window, &extent); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -826,7 +841,10 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line) error = xwimp_get_window_state_and_nesting(&state, &parent, &linkage); if (error) { - LOG("xwimp_get_window_state_and_nesting: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state_and_nesting: 0x%x: %s", + error->errnum, + error->errmess); return; } @@ -839,7 +857,10 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line) state.w = ta->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state: 0x%x: %s", + error->errnum, + error->errmess); return; } @@ -853,7 +874,10 @@ void ro_textarea_reflow(struct text_area *ta, unsigned int line) error = xwimp_open_window_nested(PTR_WIMP_OPEN(&state), parent, linkage); if (error) { - LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_open_window_nested: 0x%x: %s", + error->errnum, + error->errmess); return; } @@ -1009,7 +1033,10 @@ bool ro_textarea_key_press(wimp_key *key) (wimp_message*)&keypress, ta->parent, ta->icon, 0); if (error) { - LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_send_message: 0x%x:%s", + error->errnum, + error->errmess); } break; } @@ -1060,7 +1087,8 @@ void ro_textarea_redraw_internal(wimp_draw *redraw, bool update) else error = xwimp_redraw_window(redraw, &more); if (error) { - LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -1076,13 +1104,17 @@ void ro_textarea_redraw_internal(wimp_draw *redraw, bool update) colourtrans_SET_BG_GCOL | colourtrans_USE_ECFS_GCOL, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, + error->errmess); return; } error = xos_clg(); if (error) { - LOG("xos_clg: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_clg: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -1113,7 +1145,10 @@ void ro_textarea_redraw_internal(wimp_draw *redraw, bool update) 0xD9D9D900 : 0xFFFFFF00, 0x00000000, 14, 0, 0, 0); if (error) { - LOG("xcolourtrans_set_font_colours: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_font_colours: 0x%x: %s", + error->errnum, + error->errmess); return; } @@ -1128,15 +1163,20 @@ void ro_textarea_redraw_internal(wimp_draw *redraw, bool update) rufl_BLEND_FONT); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) - LOG("rufl_paint: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); + NSLOG(netsurf, INFO, + "rufl_paint: rufl_FONT_MANAGER_ERROR: 0x%x: %s", + rufl_fm_error->errnum, + rufl_fm_error->errmess); else - LOG("rufl_paint: 0x%x", code); + NSLOG(netsurf, INFO, + "rufl_paint: 0x%x", code); } } error = xwimp_get_rectangle(redraw, &more); if (error) { - LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s", + error->errnum, error->errmess); return; } } @@ -1153,7 +1193,8 @@ void ro_textarea_open(wimp_open *open) error = xwimp_open_window(open); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); return; } } diff --git a/frontends/riscos/textselection.c b/frontends/riscos/textselection.c index 5a430c06f..efec96b56 100644 --- a/frontends/riscos/textselection.c +++ b/frontends/riscos/textselection.c @@ -92,12 +92,13 @@ void gui_start_selection(struct gui_window *g) wimp_drag drag; os_error *error; - LOG("starting text_selection drag"); + NSLOG(netsurf, INFO, "starting text_selection drag"); state.w = g->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -111,7 +112,8 @@ void gui_start_selection(struct gui_window *g) error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)&msg, wimp_BROADCAST); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } owns_caret_and_selection = true; @@ -127,7 +129,8 @@ void gui_start_selection(struct gui_window *g) wimp_AUTO_SCROLL_ENABLE_HORIZONTAL, &scroll, 0); if (error) - LOG("xwimp_auto_scroll: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s", + error->errnum, error->errmess); ro_mouse_drag_start(ro_gui_selection_drag_end, ro_gui_window_mouse_at, NULL, g); @@ -141,7 +144,8 @@ void gui_start_selection(struct gui_window *g) error = xwimp_drag_box(&drag); if (error) { - LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } last_start_window = g; @@ -166,17 +170,20 @@ static void ro_gui_selection_drag_end(wimp_dragged *drag, void *data) scroll.w = g->window; error = xwimp_auto_scroll(0, &scroll, 0); if (error) - LOG("xwimp_auto_scroll: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s", + error->errnum, error->errmess); error = xwimp_drag_box((wimp_drag*)-1); if (error) { - LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -217,7 +224,7 @@ static void gui_set_clipboard(const char *buffer, size_t length, wimp_full_message_claim_entity msg; os_error *error; - LOG("claiming clipboard"); + NSLOG(netsurf, INFO, "claiming clipboard"); msg.size = sizeof(msg); msg.your_ref = 0; @@ -227,13 +234,14 @@ static void gui_set_clipboard(const char *buffer, size_t length, error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)&msg, wimp_BROADCAST); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } owns_clipboard = true; } - LOG("clipboard now holds %zd bytes", clip_length); + NSLOG(netsurf, INFO, "clipboard now holds %zd bytes", clip_length); } @@ -441,7 +449,7 @@ void ro_gui_selection_claim_entity(wimp_full_message_claim_entity *claim) /* ignore our own broadcasts! */ if (claim->sender != task_handle) { - LOG("%x", claim->flags); + NSLOG(netsurf, INFO, "%x", claim->flags); if (claim->flags & wimp_CLAIM_CARET_OR_SELECTION) { owns_caret_and_selection = false; @@ -524,7 +532,8 @@ bool ro_gui_save_clipboard(const char *path) free(local_cb); if (error) { - LOG("xosfile_save_stamped: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_save_stamped: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("SaveError", error->errmess); return false; } @@ -606,7 +615,8 @@ void ro_gui_selection_send_dragging(wimp_pointer *pointer) { wimp_full_message_dragging dragmsg; - LOG("sending DRAGGING to %p, %d", pointer->w, pointer->i); + NSLOG(netsurf, INFO, "sending DRAGGING to %p, %d", pointer->w, + pointer->i); dragmsg.size = offsetof(wimp_full_message_dragging, file_types) + 8; dragmsg.your_ref = 0; diff --git a/frontends/riscos/theme.c b/frontends/riscos/theme.c index b0b4ab879..661beb765 100644 --- a/frontends/riscos/theme.c +++ b/frontends/riscos/theme.c @@ -364,7 +364,7 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) /* create a full filename */ filename = malloc(strlen(folder) + strlen(leafname) + 2); if (!filename) { - LOG("No memory for malloc"); + NSLOG(netsurf, INFO, "No memory for malloc"); ro_warn_user("NoMemory", 0); return false; } @@ -374,7 +374,8 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) error = xosfind_openinw(osfind_NO_PATH, filename, 0, &file_handle); if (error) { - LOG("xosfind_openinw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfind_openinw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("FileError", error->errmess); free(filename); return false; @@ -389,7 +390,8 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) 0, &output_left); xosfind_closew(file_handle); if (error) { - LOG("xosbgpb_read_atw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosbgpb_read_atw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("FileError", error->errmess); free(filename); return false; @@ -403,7 +405,7 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) current = (struct theme_descriptor *)calloc(1, sizeof(struct theme_descriptor)); if (!current) { - LOG("calloc failed"); + NSLOG(netsurf, INFO, "calloc failed"); ro_warn_user("NoMemory", 0); free(filename); return false; @@ -521,7 +523,7 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) descriptor->theme = (struct theme *)calloc(1, sizeof(struct theme)); if (!descriptor->theme) { - LOG("calloc() failed"); + NSLOG(netsurf, INFO, "calloc() failed"); ro_warn_user("NoMemory", 0); continue; } @@ -531,7 +533,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) error = xosfile_read_stamped_no_path(descriptor->filename, &obj_type, 0, 0, &file_size, 0, 0); if (error) { - LOG("xosfile_read_stamped_no_path: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfile_read_stamped_no_path: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("FileError", error->errmess); continue; } @@ -539,7 +544,7 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) continue; raw_data = malloc(file_size); if (!raw_data) { - LOG("malloc() failed"); + NSLOG(netsurf, INFO, "malloc() failed"); ro_warn_user("NoMemory", 0); continue; } @@ -547,7 +552,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) (byte *)raw_data, 0, 0, 0, 0, 0); if (error) { free(raw_data); - LOG("xosfile_load_stamped_no_path: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfile_load_stamped_no_path: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("FileError", error->errmess); continue; } @@ -556,7 +564,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) error = xsquash_decompress_return_sizes(-1, &workspace_size, 0); if (error) { free(raw_data); - LOG("xsquash_decompress_return_sizes: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xsquash_decompress_return_sizes: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); continue; } @@ -566,7 +577,7 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) if ((!decompressed) || (!workspace)) { free(decompressed); free(raw_data); - LOG("malloc() failed"); + NSLOG(netsurf, INFO, "malloc() failed"); ro_warn_user("NoMemory", 0); continue; } @@ -581,7 +592,8 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) free(raw_data); if (error) { free(decompressed); - LOG("xsquash_decompress: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xsquash_decompress: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); continue; } @@ -599,7 +611,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) descriptor->theme->sprite_area, sprite_name, 16, i, 0); if (error) { - LOG("xosspriteop_return_name: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_return_name: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); continue; } @@ -614,7 +629,10 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) &dimensions.x, &dimensions.y, (osbool *) 0, &mode); if (error) { - LOG("xosspriteop_read_sprite_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_read_sprite_info: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); continue; } diff --git a/frontends/riscos/theme_install.c b/frontends/riscos/theme_install.c index 43ecb4687..fbca9e4fa 100644 --- a/frontends/riscos/theme_install.c +++ b/frontends/riscos/theme_install.c @@ -182,7 +182,7 @@ bool ro_gui_theme_install_apply(wimp_w w) /* convert spaces to hard spaces */ theme_file = strdup(theme_install_descriptor.name); if (!theme_file) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); ro_warn_user("NoMemory", 0); return false; } @@ -203,7 +203,8 @@ bool ro_gui_theme_install_apply(wimp_w w) (byte *) source_data, (byte *) source_data + source_size); if (error) { - LOG("xosfile_save_stamped: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_save_stamped: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("ThemeInstallErr", 0); free(theme_file); return false; diff --git a/frontends/riscos/toolbar.c b/frontends/riscos/toolbar.c index 2b5cb3415..758c90cc2 100644 --- a/frontends/riscos/toolbar.c +++ b/frontends/riscos/toolbar.c @@ -227,7 +227,7 @@ struct toolbar *ro_toolbar_create(struct theme_descriptor *descriptor, toolbar = calloc(sizeof(struct toolbar), 1); if (toolbar == NULL) { - LOG("No memory for malloc()"); + NSLOG(netsurf, INFO, "No memory for malloc()"); ro_warn_user("NoMemory", 0); return NULL; } @@ -366,7 +366,8 @@ bool ro_toolbar_rebuild(struct toolbar *toolbar) old_window = toolbar->toolbar_handle; error = xwimp_delete_window(toolbar->toolbar_handle); if (error) - LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s", + error->errnum, error->errmess); toolbar->toolbar_handle = NULL; } @@ -375,7 +376,8 @@ bool ro_toolbar_rebuild(struct toolbar *toolbar) error = xwimp_create_window(&ro_toolbar_window, &toolbar->toolbar_handle); if (error) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -493,7 +495,8 @@ bool ro_toolbar_rebuild(struct toolbar *toolbar) icon.icon.data.indirected_text.size = 1; error = xwimp_create_icon(&icon, &toolbar->editor_div1); if (error) { - LOG("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_icon: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); toolbar->editor_div1 = -1; } @@ -558,7 +561,10 @@ bool ro_toolbar_attach(struct toolbar *toolbar, wimp_w parent) wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT << wimp_CHILD_TS_EDGE_SHIFT); if (error) { - LOG("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_open_window_nested: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -568,7 +574,8 @@ bool ro_toolbar_attach(struct toolbar *toolbar, wimp_w parent) error = xwimp_close_window(toolbar->toolbar_handle); if (error) { - LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -601,7 +608,10 @@ bool ro_toolbar_process(struct toolbar *toolbar, int width, bool reformat) outline.w = toolbar->parent_handle; error = xwimp_get_window_outline(&outline); if (error) { - LOG("xwimp_get_window_outline: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_outline: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -621,7 +631,10 @@ bool ro_toolbar_process(struct toolbar *toolbar, int width, bool reformat) state.w = toolbar->parent_handle; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -647,7 +660,10 @@ bool ro_toolbar_process(struct toolbar *toolbar, int width, bool reformat) error = xwimp_set_extent(toolbar->toolbar_handle, &extent); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -935,7 +951,7 @@ void ro_toolbar_destroy(struct toolbar *toolbar) if (toolbar == NULL) return; - LOG("Destroying toolbar 0x%x", (unsigned int)toolbar); + NSLOG(netsurf, INFO, "Destroying toolbar 0x%x", (unsigned int)toolbar); /* Destroy the widgets. */ @@ -994,7 +1010,8 @@ void ro_toolbar_redraw(wimp_draw *redraw) error = xwimp_redraw_window(redraw, &more); if (error) { - LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1013,7 +1030,8 @@ void ro_toolbar_redraw(wimp_draw *redraw) error = xwimp_get_rectangle(redraw, &more); if (error) { - LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1046,7 +1064,8 @@ bool ro_toolbar_click(wimp_pointer *pointer) state.w = toolbar->toolbar_handle; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -1325,7 +1344,8 @@ const char *ro_toolbar_get_help_suffix(wimp_w w, wimp_i i, os_coord *pos, state.w = toolbar->toolbar_handle; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NULL; } diff --git a/frontends/riscos/ucstables.c b/frontends/riscos/ucstables.c index 8e538ef95..3e31c992e 100644 --- a/frontends/riscos/ucstables.c +++ b/frontends/riscos/ucstables.c @@ -623,7 +623,8 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result) off - prev_off, &temp, NULL); if (err != NSERROR_OK) { assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_from_enc failed"); + NSLOG(netsurf, INFO, + "utf8_from_enc failed"); free(*result); return NSERROR_NOMEM; } @@ -665,7 +666,7 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result) &temp, NULL); if (err != NSERROR_OK) { assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_from_enc failed"); + NSLOG(netsurf, INFO, "utf8_from_enc failed"); free(*result); return NSERROR_NOMEM; } @@ -680,7 +681,7 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result) /* and copy into more reasonably-sized buffer */ temp = realloc((*result), cur_off + 1); if (!temp) { - LOG("realloc failed"); + NSLOG(netsurf, INFO, "realloc failed"); free(*result); return NSERROR_NOMEM; } diff --git a/frontends/riscos/uri.c b/frontends/riscos/uri.c index a2f126b31..d79cfe56d 100644 --- a/frontends/riscos/uri.c +++ b/frontends/riscos/uri.c @@ -120,7 +120,8 @@ void ro_uri_bounce(wimp_message *msg) /* Get required buffer size */ e = xuri_request_uri(0, NULL, 0, message->handle, &size); if (e) { - LOG("xuri_request_uri: %d: %s", e->errnum, e->errmess); + NSLOG(netsurf, INFO, "xuri_request_uri: %d: %s", e->errnum, + e->errmess); return; } @@ -131,7 +132,8 @@ void ro_uri_bounce(wimp_message *msg) /* Get URI */ e = xuri_request_uri(0, uri_buf, size, message->handle, 0); if (e) { - LOG("xuri_request_uri: %d: %s", e->errnum, e->errmess); + NSLOG(netsurf, INFO, "xuri_request_uri: %d: %s", e->errnum, + e->errmess); free(uri_buf); return; } diff --git a/frontends/riscos/url_complete.c b/frontends/riscos/url_complete.c index 16c6e3a2e..82c2d2c67 100644 --- a/frontends/riscos/url_complete.c +++ b/frontends/riscos/url_complete.c @@ -171,7 +171,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) -(url_complete_matches_selection + 1) * 44, 65536, -url_complete_matches_selection * 44); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -210,7 +211,10 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) state.w = parent; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -228,7 +232,10 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) error = xwimp_force_redraw(dialog_url_complete, 0, -(i + 1) * 44, 65536, -i * 44); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_force_redraw: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -281,7 +288,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) 0, -(old_selection + 1) * 44, 65536, -old_selection * 44); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -289,7 +297,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) 0, -(url_complete_matches_selection + 1) * 44, 65536, -url_complete_matches_selection * 44); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -320,7 +329,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) state.w = dialog_url_complete; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return true; } @@ -335,7 +345,8 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) error = xwimp_open_window(PTR_WIMP_OPEN(&state)); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return true; } @@ -411,7 +422,8 @@ void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open) state.w = dialog_url_complete; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -423,13 +435,14 @@ void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open) toolbar_state.w = ro_toolbar_get_window(toolbar); error = xwimp_get_window_state(&toolbar_state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } if (!ro_toolbar_get_url_field_extent(toolbar, &url_extent)) { - LOG("Failed to read URL field extent."); + NSLOG(netsurf, INFO, "Failed to read URL field extent."); return; } @@ -438,7 +451,8 @@ void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open) extent.x1 = 65536; error = xwimp_set_extent(dialog_url_complete, &extent); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -460,14 +474,16 @@ void ro_gui_url_complete_resize(struct toolbar *toolbar, wimp_open *open) if (state.visible.x1 - state.visible.x0 < 0) { error = xwimp_close_window(dialog_url_complete); if (error) { - LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } else { error = xwimp_open_window_nested_with_flags(&state, (wimp_w)-1, 0); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -507,7 +523,8 @@ bool ro_gui_url_complete_close(void) error = xwimp_close_window(dialog_url_complete); if (error) { - LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -547,7 +564,7 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) /* no matches? no redraw */ if (!url_complete_matches) { - LOG("Attempt to redraw with no matches made"); + NSLOG(netsurf, INFO, "Attempt to redraw with no matches made"); /* Fill is never used, so make it something obvious */ ro_gui_user_redraw(redraw, false, os_COLOUR_BLACK); return; @@ -582,7 +599,10 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) error = xwimp_plot_icon(&url_complete_icon); if (error) { - LOG("xwimp_plot_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_plot_icon: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -604,7 +624,10 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) url_complete_sprite.extent.y0 = -(line + 1) * 44; error = xwimp_plot_icon(&url_complete_sprite); if (error) { - LOG("xwimp_plot_icon: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_plot_icon: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -658,7 +681,8 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) state.w = dialog_url_complete; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -685,14 +709,16 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) 0, -(old_selection + 1) * 44, 65536, -old_selection * 44); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } error = xwimp_force_redraw(dialog_url_complete, 0, -(url_complete_matches_selection + 1) * 44, 65536, -url_complete_matches_selection * 44); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } diff --git a/frontends/riscos/url_protocol.c b/frontends/riscos/url_protocol.c index 9a7ae062c..184aaeab0 100644 --- a/frontends/riscos/url_protocol.c +++ b/frontends/riscos/url_protocol.c @@ -75,17 +75,19 @@ void ro_url_message_received(wimp_message *message) } else { if (!url_message->indirect.url.offset) { - LOG("no URL in message"); + NSLOG(netsurf, INFO, "no URL in message"); return; } if (28 < message->size && url_message->indirect.body_file.offset) { - LOG("POST for URL message not implemented"); + NSLOG(netsurf, INFO, + "POST for URL message not implemented"); return; } if (url_message->indirect.url.offset < 28 || 236 <= url_message->indirect.url.offset) { - LOG("external pointers in URL message unimplemented"); + NSLOG(netsurf, INFO, + "external pointers in URL message unimplemented"); /* these messages have never been seen in the wild, * and there is the problem of invalid addresses which * would cause an abort */ @@ -122,7 +124,8 @@ void ro_url_message_received(wimp_message *message) error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE, message, message->sender); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -165,7 +168,8 @@ void ro_url_broadcast(const char *url) error = xwimp_send_message(wimp_USER_MESSAGE_RECORDED, (wimp_message *) &message, 0); if (error) { - LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -184,7 +188,7 @@ void ro_url_load(const char *url) colon = strchr(url, ':'); if (!colon) { - LOG("invalid url '%s'", url); + NSLOG(netsurf, INFO, "invalid url '%s'", url); return; } @@ -204,7 +208,8 @@ void ro_url_load(const char *url) error = xwimp_start_task(command, 0); if (error) { - LOG("xwimp_start_task: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_start_task: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } diff --git a/frontends/riscos/wimp.c b/frontends/riscos/wimp.c index abf099a55..d851ab59e 100644 --- a/frontends/riscos/wimp.c +++ b/frontends/riscos/wimp.c @@ -103,7 +103,10 @@ void ro_gui_wimp_cache_furniture_sizes(wimp_w w) furniture_sizes.border_widths.x1 = 40; error = xwimpextend_get_furniture_sizes(&furniture_sizes); if (error) { - LOG("xwimpextend_get_furniture_sizes: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimpextend_get_furniture_sizes: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -123,13 +126,15 @@ bool ro_gui_wimp_read_eig_factors(os_mode mode, int *xeig, int *yeig) error = xos_read_mode_variable(mode, os_MODEVAR_XEIG_FACTOR, xeig, 0); if (error) { - LOG("xos_read_mode_variable: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_read_mode_variable: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); return false; } error = xos_read_mode_variable(mode, os_MODEVAR_YEIG_FACTOR, yeig, 0); if (error) { - LOG("xos_read_mode_variable: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xos_read_mode_variable: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); return false; } @@ -196,14 +201,16 @@ void ro_gui_force_redraw_icon(wimp_w w, wimp_i i) ic.i = i; error = xwimp_get_icon_state(&ic); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } error = xwimp_force_redraw(w, ic.icon.extent.x0, ic.icon.extent.y0, ic.icon.extent.x1, ic.icon.extent.y1); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -235,7 +242,8 @@ const char *ro_gui_get_icon_string(wimp_w w, wimp_i i) ic.i = i; error = xwimp_get_icon_state(&ic); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NULL; } @@ -277,7 +285,7 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8) if (err != NSERROR_OK) { /* A bad encoding should never happen, so assert this */ assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_to_enc failed"); + NSLOG(netsurf, INFO, "utf8_to_enc failed"); /* Paranoia */ local_text = NULL; } @@ -292,7 +300,8 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8) ic.i = i; error = xwimp_get_icon_state(&ic); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); goto exit; } @@ -325,7 +334,10 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8) (button_type == wimp_BUTTON_WRITE_CLICK_DRAG)) { error = xwimp_get_caret_position(&caret); if (error) { - LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_caret_position: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); goto exit; } @@ -336,7 +348,10 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8) error = xwimp_set_caret_position(w, i, caret.pos.x, caret.pos.y, -1, caret.index); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_set_caret_position: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -433,7 +448,8 @@ void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state) error = xwimp_set_icon_state(w, i, (state ? wimp_ICON_SELECTED : 0), wimp_ICON_SELECTED); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -452,7 +468,8 @@ bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i) ic.i = i; error = xwimp_get_icon_state(&ic); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -478,7 +495,8 @@ void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state) error = xwimp_set_icon_state(w, i, (state ? wimp_ICON_SHADED : 0), wimp_ICON_SHADED); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } if (!state) @@ -487,7 +505,8 @@ void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state) /* ensure the caret is not in a shaded icon */ error = xwimp_get_caret_position(&caret); if (error) { - LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -499,7 +518,8 @@ void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state) /* lose the caret */ error = xwimp_set_caret_position((wimp_w)-1, (wimp_i)-1, -1, -1, -1, -1); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -540,7 +560,8 @@ void ro_gui_set_icon_deleted_state(wimp_w w, wimp_i i, bool state) error = xwimp_set_icon_state(w, i, (state ? wimp_ICON_DELETED : 0), wimp_ICON_DELETED); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } if (!state) @@ -549,7 +570,8 @@ void ro_gui_set_icon_deleted_state(wimp_w w, wimp_i i, bool state) /* ensure the caret is not in a shaded icon */ error = xwimp_get_caret_position(&caret); if (error) { - LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -561,7 +583,8 @@ void ro_gui_set_icon_deleted_state(wimp_w w, wimp_i i, bool state) /* lose the caret */ error = xwimp_set_caret_position((wimp_w)-1, (wimp_i)-1, -1, -1, -1, -1); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -597,7 +620,8 @@ void ro_gui_set_icon_button_type(wimp_w w, wimp_i i, int type) error = xwimp_set_icon_state(w, i, wimp_ICON_BUTTON_TYPE, (type << wimp_ICON_BUTTON_TYPE_SHIFT)); if (error) { - LOG("xwimp_set_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -622,7 +646,8 @@ void ro_gui_set_icon_sprite(wimp_w w, wimp_i i, osspriteop_area *area, ic.i = i; error = xwimp_get_icon_state(&ic); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -659,7 +684,8 @@ void ro_gui_set_window_title(wimp_w w, const char *text) window.w = w; error = xwimp_get_window_info_header_only((wimp_window_info *)&window); if (error) { - LOG("xwimp_get_window_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -670,7 +696,7 @@ void ro_gui_set_window_title(wimp_w w, const char *text) /* A bad encoding should never happen, * so assert this */ assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_to_enc failed"); + NSLOG(netsurf, INFO, "utf8_to_enc failed"); return; } @@ -686,7 +712,8 @@ void ro_gui_set_window_title(wimp_w w, const char *text) */ error = xwimp_force_redraw_title(w); if (error) { - LOG("xwimp_force_redraw_title: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw_title: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -713,7 +740,8 @@ bool ro_gui_set_caret_first(wimp_w w) win_state.w = w; error = xwimp_get_window_state(&win_state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -724,7 +752,8 @@ bool ro_gui_set_caret_first(wimp_w w) window.w = w; error = xwimp_get_window_info_header_only((wimp_window_info *)&window); if (error) { - LOG("xwimp_get_window_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -735,7 +764,10 @@ bool ro_gui_set_caret_first(wimp_w w) state.i = icon; error = xwimp_get_icon_state(&state); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_icon_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -752,7 +784,10 @@ bool ro_gui_set_caret_first(wimp_w w) error = xwimp_set_caret_position(w, icon, 0, 0, -1, strlen(state.icon.data.indirected_text.text)); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_set_caret_position: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } return true; @@ -778,7 +813,10 @@ osspriteop_area *ro_gui_load_sprite_file(const char *pathname) error = xosfile_read_stamped_no_path(pathname, &obj_type, 0, 0, &len, 0, 0); if (error) { - LOG("xosfile_read_stamped_no_path: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosfile_read_stamped_no_path: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); return 0; } @@ -801,7 +839,10 @@ osspriteop_area *ro_gui_load_sprite_file(const char *pathname) error = xosspriteop_load_sprite_file(osspriteop_USER_AREA, area, pathname); if (error) { - LOG("xosspriteop_load_sprite_file: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_load_sprite_file: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); free(area); return 0; @@ -831,7 +872,10 @@ bool ro_gui_wimp_sprite_exists(const char *sprite) error = xwimpspriteop_select_sprite(sprite, 0); if (error) { if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) { - LOG("xwimpspriteop_select_sprite: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimpspriteop_select_sprite: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); } return false; @@ -904,7 +948,10 @@ bool ro_gui_wimp_get_sprite_dimensions(osspriteop_area *area, char *sprite, if (height != NULL) *height = dimensions.y; } else if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) { - LOG("xosspriteop_read_sprite_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_read_sprite_info: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); return false; } @@ -929,7 +976,8 @@ void ro_gui_user_redraw(wimp_draw *redraw, bool user_fill, error = xwimp_redraw_window(redraw, &more); if (error) { - LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -939,14 +987,18 @@ void ro_gui_user_redraw(wimp_draw *redraw, bool user_fill, colourtrans_SET_BG_GCOL, os_ACTION_OVERWRITE, 0, 0); if (error) { - LOG("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xcolourtrans_set_gcol: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); } os_clg(); } error = xwimp_get_rectangle(redraw, &more); if (error) { - LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -973,7 +1025,8 @@ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask, state.w = w; error = xwimp_get_window_state_and_nesting(&state, &parent, &linkage); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -986,7 +1039,8 @@ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask, state.next = wimp_HIDDEN; error = xwimp_open_window_nested_with_flags(&state, parent, linkage); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -994,7 +1048,8 @@ void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask, if (!open) { error = xwimp_close_window(w); if (error) { - LOG("xwimp_close_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1016,7 +1071,8 @@ bool ro_gui_wimp_check_window_furniture(wimp_w w, wimp_window_flags mask) state.w = w; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -1116,7 +1172,8 @@ void ro_gui_scroll(wimp_scroll *scroll) error = xwimp_open_window((wimp_open *) scroll); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); } } diff --git a/frontends/riscos/wimp_event.c b/frontends/riscos/wimp_event.c index 015e87baf..cdca470da 100644 --- a/frontends/riscos/wimp_event.c +++ b/frontends/riscos/wimp_event.c @@ -156,7 +156,9 @@ bool ro_gui_wimp_event_memorise(wimp_w w) ro_gui_get_icon_string(window->w, event->i)); if (!event->previous_value.textual) { error = true; - LOG("Unable to store state for icon %i", event->i); + NSLOG(netsurf, INFO, + "Unable to store state for icon %i", + event->i); } break; case EVENT_CHECKBOX: @@ -267,7 +269,10 @@ bool ro_gui_wimp_event_transfer(wimp_w from, wimp_w to) struct event_window *window; int h; - LOG("Transferring all events from window 0x%x to window 0x%x", (unsigned int)from, (unsigned int)to); + NSLOG(netsurf, INFO, + "Transferring all events from window 0x%x to window 0x%x", + (unsigned int)from, + (unsigned int)to); window = ro_gui_wimp_event_remove_window(from); if (window == NULL || window->w != from) @@ -293,7 +298,8 @@ void ro_gui_wimp_event_finalise(wimp_w w) struct event_window *window; struct icon_event *event; - LOG("Removing all events for window 0x%x", (unsigned int)w); + NSLOG(netsurf, INFO, "Removing all events for window 0x%x", + (unsigned int)w); window = ro_gui_wimp_event_remove_window(w); if (!window) return; @@ -330,7 +336,8 @@ void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i) struct event_window *window; struct icon_event *event, *parent, *child; - LOG("Removing all events for window 0x%x, icon %d", (unsigned int)w, (int)i); + NSLOG(netsurf, INFO, "Removing all events for window 0x%x, icon %d", + (unsigned int)w, (int)i); window = ro_gui_wimp_event_get_window(w); if (!window) return; @@ -344,7 +351,8 @@ void ro_gui_wimp_event_deregister(wimp_w w, wimp_i i) child = event->next; if (event->i == i) { - LOG("Removing event 0x%x", (unsigned int)event); + NSLOG(netsurf, INFO, "Removing event 0x%x", + (unsigned int)event); if (parent == NULL) window->first = child; @@ -576,7 +584,8 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu, ic.i = event->data.menu_gright.field; error = xwimp_get_icon_state(&ic); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -586,7 +595,8 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu, return prepared; error = xwimp_get_caret_position(&caret); if (error) { - LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -594,7 +604,10 @@ bool ro_gui_wimp_event_menu_selection(wimp_w w, wimp_i i, wimp_menu *menu, error = xwimp_set_caret_position(window->w, event->data.menu_gright.field, -1, -1, -1, strlen(menu_entry->data.indirected_text.text)); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_set_caret_position: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -666,7 +679,7 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer) for (search = window->first; search; search = search->next) if (search->i == event->data.linked_icon) break; if (!search) { - LOG("Incorrect reference."); + NSLOG(netsurf, INFO, "Incorrect reference."); return false; } stepping = search->data.numeric_field.stepping; @@ -703,13 +716,19 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer) open.w = pointer->w; error = xwimp_get_window_state(&open); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } error = xwimp_get_caret_position(&caret); if (error) { - LOG("xwimp_get_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_caret_position: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -718,7 +737,10 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer) ro_gui_menu_destroy(); error = xwimp_open_window(PTR_WIMP_OPEN(&open)); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_open_window: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -728,7 +750,10 @@ bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer) caret.pos.x, caret.pos.y, -1, caret.index); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_set_caret_position: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -796,7 +821,8 @@ void ro_gui_wimp_event_prepare_gright_menu(wimp_w w, struct icon_event *event) ic.i = event->data.menu_gright.field; error = xwimp_get_icon_state(&ic); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -903,7 +929,8 @@ bool ro_gui_wimp_event_keypress(wimp_key *key) */ error = xosbyte1(osbyte_ALPHABET_NUMBER, 127, 0, &t_alphabet); if (error) { - LOG("failed reading alphabet: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "failed reading alphabet: 0x%x: %s", + error->errnum, error->errmess); /* prevent any corruption of ucstable */ t_alphabet = alphabet; } @@ -917,7 +944,10 @@ bool ro_gui_wimp_event_keypress(wimp_key *key) error = xserviceinternational_get_ucs_conversion_table( alphabet, &unclaimed, &ostable); if (error != NULL) { - LOG("failed reading UCS conversion table: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "failed reading UCS conversion table: 0x%x: %s", + error->errnum, + error->errmess); /* Try using our own table instead */ ucstable = ucstable_from_alphabet(alphabet); } else if (unclaimed) { @@ -974,7 +1004,9 @@ bool ro_gui_wimp_event_keypress(wimp_key *key) /* If this ever happens, * RISC OS' UTF8 keyboard * drivers are broken */ - LOG("unexpected UTF8 start"" byte %x (ignoring)", c); + NSLOG(netsurf, INFO, + "unexpected UTF8 start"" byte %x (ignoring)", + c); return true; } /* Anything else is ASCII, so just @@ -985,7 +1017,9 @@ bool ro_gui_wimp_event_keypress(wimp_key *key) /* If this ever happens, * RISC OS' UTF8 keyboard * drivers are broken */ - LOG("unexpected keycode: ""%x (ignoring)", c); + NSLOG(netsurf, INFO, + "unexpected keycode: ""%x (ignoring)", + c); return true; } @@ -1074,7 +1108,8 @@ bool ro_gui_wimp_event_close_window(wimp_w w) { struct event_window *window; - LOG("Close event received for window 0x%x", (unsigned int)w); + NSLOG(netsurf, INFO, "Close event received for window 0x%x", + (unsigned int)w); if (w == ro_gui_wimp_event_submenu) ro_gui_wimp_event_submenu = 0; window = ro_gui_wimp_event_find_window(w); @@ -1615,7 +1650,8 @@ struct event_window *ro_gui_wimp_event_get_window(wimp_w w) if (window) return window; - LOG("Creating structure for window 0x%x", (unsigned int)w); + NSLOG(netsurf, INFO, "Creating structure for window 0x%x", + (unsigned int)w); window = calloc(1, sizeof(struct event_window)); if (!window) return NULL; diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c index 6dbcc325b..986e5c55d 100644 --- a/frontends/riscos/window.c +++ b/frontends/riscos/window.c @@ -206,7 +206,8 @@ gui_window_place_caret(struct gui_window *g, error = xwimp_set_caret_position(g->window, -1, x * 2, -(y + height) * 2, height * 2, -1); if (error) { - LOG("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } } @@ -235,7 +236,10 @@ static void gui_window_set_extent(struct gui_window *g, int width, int height) state.w = g->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -266,7 +270,8 @@ static void gui_window_set_extent(struct gui_window *g, int width, int height) os_box extent = { 0, -height, width, toolbar_height }; error = xwimp_set_extent(g->window, &extent); if (error) { - LOG("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -309,7 +314,8 @@ static void ro_gui_window_open(wimp_open *open) state.w = g->window; error = xwimp_get_window_state_and_nesting(&state, &parent, &linkage); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -414,7 +420,8 @@ static void ro_gui_window_open(wimp_open *open) error = xwimp_open_window_nested_with_flags(&state, parent, linkage); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -453,8 +460,10 @@ static void gui_window_update_extent(struct gui_window *g) info.w = g->window; error = xwimp_get_window_info_header_only(&info); if (error) { - LOG("xwimp_get_window_info_header_only: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_info_header_only: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1046,7 +1055,8 @@ ro_gui_window_scroll_action(struct gui_window *g, state.w = g->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); return; } @@ -1060,7 +1070,8 @@ ro_gui_window_scroll_action(struct gui_window *g, error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1180,7 +1191,8 @@ ro_gui_window_scroll_action(struct gui_window *g, error = xwimp_open_window((wimp_open *) &state); if (error) { - LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s", + error->errnum, error->errmess); } } } @@ -1218,7 +1230,8 @@ ro_gui_window_handle_local_keypress(struct gui_window *g, ro_error = xwimp_get_pointer_info(&pointer); if (ro_error) { - LOG("xwimp_get_pointer_info: 0x%x: %s\n", ro_error->errnum, ro_error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s\n", + ro_error->errnum, ro_error->errmess); ro_warn_user("WimpError", ro_error->errmess); return false; } @@ -1528,8 +1541,8 @@ static void ro_gui_window_close(wimp_w w) error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1559,7 +1572,10 @@ static void ro_gui_window_close(wimp_w w) } error = xos_cli(temp_name); if (error) { - LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xos_cli: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); return; } @@ -1611,7 +1627,8 @@ static void ro_gui_window_redraw(wimp_draw *redraw) error = xwimp_redraw_window(redraw, &more); if (error) { - LOG("xwimp_redraw_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -1653,7 +1670,8 @@ static void ro_gui_window_redraw(wimp_draw *redraw) if (error && !(ro_gui_current_redraw_gui-> option.buffer_everything && error->errnum == error_WIMP_GET_RECT)) { - LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); ro_gui_current_redraw_gui = NULL; return; @@ -1971,7 +1989,7 @@ ro_gui_window_prepare_form_select_menu(struct gui_window *g, if (err != NSERROR_OK) { /* badenc should never happen */ assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_to_local_encoding failed"); + NSLOG(netsurf, INFO, "utf8_to_local_encoding failed"); ro_warn_user("NoMemory", 0); ro_gui_menu_destroy(); return false; @@ -1997,7 +2015,7 @@ ro_gui_window_prepare_form_select_menu(struct gui_window *g, temp = cnv_space2nbsp(option->text); if (!temp) { - LOG("cnv_space2nbsp failed"); + NSLOG(netsurf, INFO, "cnv_space2nbsp failed"); ro_warn_user("NoMemory", 0); ro_gui_menu_destroy(); return false; @@ -2009,7 +2027,7 @@ ro_gui_window_prepare_form_select_menu(struct gui_window *g, /* A bad encoding should never happen, * so assert this */ assert(err != NSERROR_BAD_ENCODING); - LOG("utf8_to_enc failed"); + NSLOG(netsurf, INFO, "utf8_to_enc failed"); ro_warn_user("NoMemory", 0); ro_gui_menu_destroy(); return false; @@ -2831,7 +2849,10 @@ ro_gui_window_menu_select(wimp_w w, state.w = w; oserror = xwimp_get_window_state(&state); if (oserror) { - LOG("xwimp_get_window_state: 0x%x: %s", oserror->errnum, oserror->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state: 0x%x: %s", + oserror->errnum, + oserror->errmess); ro_warn_user("WimpError", oserror->errmess); } nsoption_set_int(window_x, state.visible.x0); @@ -3209,7 +3230,10 @@ static struct gui_window *gui_window_create(struct browser_window *bw, state.w = existing->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_state: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } window.visible.x0 = state.visible.x0; @@ -3313,7 +3337,8 @@ static struct gui_window *gui_window_create(struct browser_window *bw, error = xwimp_create_window(&window, &g->window); if (error) { - LOG("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); free(g); return 0; @@ -3382,8 +3407,8 @@ static struct gui_window *gui_window_create(struct browser_window *bw, state.w = g->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return g; } @@ -3459,7 +3484,8 @@ static void gui_window_destroy(struct gui_window *g) /* delete window */ error = xwimp_delete_window(w); if (error) { - LOG("xwimp_delete_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } ro_gui_wimp_event_finalise(w); @@ -3515,7 +3541,8 @@ static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) state.w = g->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -3550,8 +3577,8 @@ gui_window_set_scroll(struct gui_window *g, const struct rect *rect) state.w = g->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_BAD_PARAMETER; } @@ -3731,8 +3758,8 @@ static void gui_window_remove_caret(struct gui_window *g) error = xwimp_get_caret_position(&caret); if (error) { - LOG("xwimp_get_caret_position: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } @@ -3776,20 +3803,25 @@ static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data) error = xwimp_drag_box((wimp_drag*)-1); if (error) { - LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return; } error = xwimpspriteop_set_pointer_shape("ptr_default", 0x31, 0, 0, 0, 0); if (error) { - LOG("xwimpspriteop_set_pointer_shape: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimpspriteop_set_pointer_shape: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -3814,7 +3846,8 @@ static bool gui_window_scroll_start(struct gui_window *g) error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -3822,7 +3855,8 @@ static bool gui_window_scroll_start(struct gui_window *g) info.w = g->window; error = xwimp_get_window_info_header_only((wimp_window_info*)&info); if (error) { - LOG("xwimp_get_window_state: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -3844,7 +3878,8 @@ static bool gui_window_scroll_start(struct gui_window *g) error = xwimp_drag_box(&drag); if (error) { - LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -3876,7 +3911,10 @@ gui_window_drag_start(struct gui_window *g, * duration */ os_error *error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_pointer_info 0x%x : %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -3893,7 +3931,8 @@ gui_window_drag_start(struct gui_window *g, error = xwimp_drag_box(&drag); if (error) { - LOG("xwimp_drag_box: 0x%x : %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x : %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -3955,7 +3994,8 @@ gui_window_create_form_select_menu(struct gui_window *g, error = xwimp_get_pointer_info(&pointer); if (error) { - LOG("xwimp_get_pointer_info: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_pointer_info: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); ro_gui_menu_destroy(); return; @@ -3988,7 +4028,8 @@ ro_gui_window_import_text(struct gui_window *g, const char *filename) error = xosfile_read_stamped(filename, &obj_type, NULL, NULL, &size, NULL, NULL); if (error) { - LOG("xosfile_read_stamped: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_read_stamped: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("FileError", error->errmess); return true; /* was for us, but it didn't work! */ } @@ -4007,7 +4048,8 @@ ro_gui_window_import_text(struct gui_window *g, const char *filename) NULL, NULL, NULL, NULL, NULL); if (error) { - LOG("xosfile_load_stamped: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosfile_load_stamped: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("LoadError", error->errmess); free(buf); return true; @@ -4017,7 +4059,7 @@ ro_gui_window_import_text(struct gui_window *g, const char *filename) if (ret != NSERROR_OK) { /* bad encoding shouldn't happen */ assert(ret != NSERROR_BAD_ENCODING); - LOG("utf8_from_local_encoding failed"); + NSLOG(netsurf, INFO, "utf8_from_local_encoding failed"); free(buf); ro_warn_user("NoMemory", NULL); return true; @@ -4206,8 +4248,10 @@ ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect) info.w = g->window; error = xwimp_get_window_info_header_only(&info); if (error) { - LOG("xwimp_get_window_info_header_only: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_window_info_header_only: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_INVALID; } @@ -4216,8 +4260,8 @@ ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect) info.extent.x0, info.extent.y0, info.extent.x1, info.extent.y1); if (error) { - LOG("xwimp_force_redraw: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return NSERROR_INVALID; } @@ -4251,7 +4295,7 @@ ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect) } cur = malloc(sizeof(struct update_box)); if (!cur) { - LOG("No memory for malloc."); + NSLOG(netsurf, INFO, "No memory for malloc."); return NSERROR_NOMEM; } @@ -4323,7 +4367,8 @@ bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message) message->your_ref = message->my_ref; error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender); if (error) { - LOG("xwimp_send_message: 0x%x: %s\n", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s\n", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } @@ -4375,12 +4420,14 @@ ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi) (osspriteop_id)overlay, &width, &height, NULL, NULL); if (error) { - LOG("xosspriteop_read_sprite_info: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_read_sprite_info: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("MiscError", error->errmess); overlay = NULL; } else if (sprite_bpp(overlay) != 8) { - LOG("overlay sprite is not 8bpp"); + NSLOG(netsurf, INFO, "overlay sprite is not 8bpp"); overlay = NULL; } } @@ -4389,7 +4436,7 @@ ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi) bitmap = riscos_bitmap_create(width, height, BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY); if (!bitmap) { - LOG("Thumbnail initialisation failed."); + NSLOG(netsurf, INFO, "Thumbnail initialisation failed."); return; } riscos_bitmap_render(bitmap, h); @@ -4399,7 +4446,7 @@ ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi) area = riscos_bitmap_convert_8bpp(bitmap); riscos_bitmap_destroy(bitmap); if (!area) { - LOG("Thumbnail conversion failed."); + NSLOG(netsurf, INFO, "Thumbnail conversion failed."); return; } @@ -4420,7 +4467,8 @@ ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi) error = xosspriteop_save_sprite_file(osspriteop_USER_AREA, area, temp_fname); if (error) { - LOG("xosspriteop_save_sprite_file: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xosspriteop_save_sprite_file: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); free(area); return; @@ -4428,7 +4476,10 @@ ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi) error = xwimpspriteop_merge_sprite_file(temp_fname); if (error) { - LOG("xwimpspriteop_merge_sprite_file: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimpspriteop_merge_sprite_file: 0x%x:%s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); remove(temp_fname); free(area); @@ -4453,7 +4504,8 @@ ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi) error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)wi, wi->sender); if (error) { - LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); } else { @@ -4479,7 +4531,10 @@ bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message) error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender); if (error) { - LOG("xwimp_send_message: 0x%x: %s\n", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_send_message: 0x%x: %s\n", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } return true; @@ -4536,7 +4591,8 @@ void ro_gui_window_update_boxes(void) error = xwimp_update_window(&update, &more); if (error) { - LOG("xwimp_update_window: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_update_window: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); continue; } @@ -4569,7 +4625,10 @@ void ro_gui_window_update_boxes(void) * found. This appears to be a bug in RISC OS. */ if (error && !(use_buffer && error->errnum == error_WIMP_GET_RECT)) { - LOG("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_rectangle: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); ro_gui_current_redraw_gui = NULL; continue; @@ -4685,7 +4744,8 @@ ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos) state.w = g->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -4709,7 +4769,8 @@ bool ro_gui_window_to_screen_pos(struct gui_window *g, state.w = g->window; error = xwimp_get_window_state(&state); if (error) { - LOG("xwimp_get_window_state: 0x%x:%s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x:%s", + error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); return false; } @@ -4913,7 +4974,10 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) error = xwimpspriteop_set_pointer_shape(entry->sprite_name, 1, entry->xactive, entry->yactive, 0, 0); if (error) { - LOG("xwimpspriteop_set_pointer_shape: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimpspriteop_set_pointer_shape: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } else { @@ -4923,7 +4987,10 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) (osspriteop_id) entry->sprite_name, 1, entry->xactive, entry->yactive, 0, 0); if (error) { - LOG("xosspriteop_set_pointer_shape: 0x%x: %s", error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosspriteop_set_pointer_shape: 0x%x: %s", + error->errnum, + error->errmess); ro_warn_user("WimpError", error->errmess); } } diff --git a/frontends/windows/about.c b/frontends/windows/about.c index 65c81cd7d..2cd855b55 100644 --- a/frontends/windows/about.c +++ b/frontends/windows/about.c @@ -52,7 +52,7 @@ static BOOL init_about_dialog(HWND hwnd) hFont=CreateFont (26, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial"); if (hFont != NULL) { - LOG("Setting font object"); + NSLOG(netsurf, INFO, "Setting font object"); SendMessage(dlg_itm, WM_SETFONT, (WPARAM)hFont, 0); } @@ -85,7 +85,7 @@ static BOOL destroy_about_dialog(HWND hwnd) if (dlg_itm != NULL) { hFont = (HFONT)SendMessage(dlg_itm, WM_GETFONT, 0, 0); if (hFont != NULL) { - LOG("Destroyed font object"); + NSLOG(netsurf, INFO, "Destroyed font object"); DeleteObject(hFont); } } @@ -107,12 +107,12 @@ nsws_about_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) case WM_COMMAND: switch(LOWORD(wparam)) { case IDOK: - LOG("OK clicked"); + NSLOG(netsurf, INFO, "OK clicked"); EndDialog(hwnd, IDOK); break; case IDCANCEL: - LOG("Cancel clicked"); + NSLOG(netsurf, INFO, "Cancel clicked"); EndDialog(hwnd, IDOK); break; diff --git a/frontends/windows/bitmap.c b/frontends/windows/bitmap.c index f60dab613..1266adb61 100644 --- a/frontends/windows/bitmap.c +++ b/frontends/windows/bitmap.c @@ -52,7 +52,8 @@ void *win32_bitmap_create(int width, int height, unsigned int state) HBITMAP windib; uint8_t *pixdata; - LOG("width %d, height %d, state %u", width, height, state); + NSLOG(netsurf, INFO, "width %d, height %d, state %u", width, height, + state); pbmi = calloc(1, sizeof(BITMAPV5HEADER)); if (pbmi == NULL) { @@ -96,7 +97,7 @@ void *win32_bitmap_create(int width, int height, unsigned int state) bitmap->opaque = false; } - LOG("bitmap %p", bitmap); + NSLOG(netsurf, INFO, "bitmap %p", bitmap); return bitmap; } @@ -115,7 +116,7 @@ static unsigned char *bitmap_get_buffer(void *bitmap) { struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return NULL; } @@ -134,7 +135,7 @@ static size_t bitmap_get_rowstride(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } @@ -152,7 +153,7 @@ void win32_bitmap_destroy(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return; } @@ -195,11 +196,12 @@ static void bitmap_set_opaque(void *bitmap, bool opaque) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return; } - LOG("setting bitmap %p to %s", bm, opaque ? "opaque" : "transparent"); + NSLOG(netsurf, INFO, "setting bitmap %p to %s", bm, + opaque ? "opaque" : "transparent"); bm->opaque = opaque; } @@ -216,7 +218,7 @@ static bool bitmap_test_opaque(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return false; } @@ -224,11 +226,11 @@ static bool bitmap_test_opaque(void *bitmap) while (tst-- > 0) { if (bm->pixdata[(tst << 2) + 3] != 0xff) { - LOG("bitmap %p has transparency", bm); + NSLOG(netsurf, INFO, "bitmap %p has transparency", bm); return false; } } - LOG("bitmap %p is opaque", bm); + NSLOG(netsurf, INFO, "bitmap %p is opaque", bm); return true; } @@ -243,7 +245,7 @@ static bool bitmap_get_opaque(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return false; } @@ -255,7 +257,7 @@ static int bitmap_get_width(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } @@ -267,7 +269,7 @@ static int bitmap_get_height(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } @@ -328,8 +330,8 @@ bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content) height = ((width * bitmap->height) + (bitmap->width / 2)) / bitmap->width; - LOG("bitmap %p for content %p width %d, height %d", - bitmap, content, width, height); + NSLOG(netsurf, INFO, "bitmap %p for content %p width %d, height %d", + bitmap, content, width, height); /* create two memory device contexts to put the bitmaps in */ bufferdc = CreateCompatibleDC(NULL); diff --git a/frontends/windows/corewindow.c b/frontends/windows/corewindow.c index 3c31c5e46..7d88ce7c4 100644 --- a/frontends/windows/corewindow.c +++ b/frontends/windows/corewindow.c @@ -155,7 +155,7 @@ nsw32_corewindow_vscroll(struct nsw32_corewindow *nsw32_cw, SCROLLINFO si; /* current scroll information */ SCROLLINFO usi; /* updated scroll infomation for scrollwindowex */ - LOG("VSCROLL"); + NSLOG(netsurf, INFO, "VSCROLL"); si.cbSize = sizeof(si); si.fMask = SIF_ALL; @@ -230,7 +230,7 @@ nsw32_corewindow_hscroll(struct nsw32_corewindow *nsw32_cw, SCROLLINFO si; /* current scroll information */ SCROLLINFO usi; /* updated scroll infomation for scrollwindowex */ - LOG("VSCROLL"); + NSLOG(netsurf, INFO, "VSCROLL"); si.cbSize = sizeof(si); si.fMask = SIF_ALL; @@ -450,7 +450,7 @@ nsw32_cw_update_size(struct core_window *cw, int width, int height) nsw32_cw->content_width = width; nsw32_cw->content_height = height; - LOG("new content size w:%d h:%d", width, height); + NSLOG(netsurf, INFO, "new content size w:%d h:%d", width, height); update_scrollbars(nsw32_cw); } @@ -527,7 +527,7 @@ nsw32_corewindow_init(HINSTANCE hInstance, CS_DBLCLKS; } - LOG("creating hInstance %p core window", hInstance); + NSLOG(netsurf, INFO, "creating hInstance %p core window", hInstance); nsw32_cw->hWnd = CreateWindowEx(0, windowclassname_corewindow, nsw32_cw->title, @@ -541,7 +541,7 @@ nsw32_corewindow_init(HINSTANCE hInstance, hInstance, NULL); if (nsw32_cw->hWnd == NULL) { - LOG("Window create failed"); + NSLOG(netsurf, INFO, "Window create failed"); return NSERROR_NOMEM; } diff --git a/frontends/windows/download.c b/frontends/windows/download.c index 3a969834e..dfcd2b5a4 100644 --- a/frontends/windows/download.c +++ b/frontends/windows/download.c @@ -253,7 +253,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui) strcat(destination, "/"); if (strlen(destination) + strlen(filename) < PATH_MAX - 1) strcat(destination, filename); - LOG("download %s [%s] from %s to %s", filename, size, domain, destination); + NSLOG(netsurf, INFO, "download %s [%s] from %s to %s", filename, + size, domain, destination); w->title = filename; w->domain = domain; w->size = total_size; @@ -313,7 +314,8 @@ gui_download_window_data(struct gui_download_window *w, const char *data, struct timeval val; res = fwrite((void *)data, 1, size, w->file); if (res != size) - LOG("file write error %d of %d", size - res, size); + NSLOG(netsurf, INFO, "file write error %d of %d", size - res, + size); w->downloaded += res; w->progress = (unsigned int)(((long long)(w->downloaded) * 10000) / w->size); @@ -327,7 +329,7 @@ gui_download_window_data(struct gui_download_window *w, const char *data, static void gui_download_window_error(struct gui_download_window *w, const char *error_msg) { - LOG("error %s", error_msg); + NSLOG(netsurf, INFO, "error %s", error_msg); } static void gui_download_window_done(struct gui_download_window *w) diff --git a/frontends/windows/drawable.c b/frontends/windows/drawable.c index 28a76cfe8..f491e0a2a 100644 --- a/frontends/windows/drawable.c +++ b/frontends/windows/drawable.c @@ -83,7 +83,7 @@ nsws_drawable_vscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam) SCROLLINFO si; int mem; - LOG("VSCROLL %d", gw->requestscrolly); + NSLOG(netsurf, INFO, "VSCROLL %d", gw->requestscrolly); if (gw->requestscrolly != 0) return 0; @@ -157,7 +157,7 @@ nsws_drawable_hscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam) SCROLLINFO si; int mem; - LOG("HSCROLL %d", gw->requestscrollx); + NSLOG(netsurf, INFO, "HSCROLL %d", gw->requestscrollx); if (gw->requestscrollx != 0) return 0; @@ -369,7 +369,8 @@ nsws_drawable_mouseup(struct gui_window *gw, (gw->bw == NULL)) return 0; - LOG("state 0x%x, press 0x%x", gw->mouse->state, press); + NSLOG(netsurf, INFO, "state 0x%x, press 0x%x", gw->mouse->state, + press); if ((gw->mouse->state & press) != 0) { gw->mouse->state &= ~press; gw->mouse->state |= click; @@ -383,10 +384,10 @@ nsws_drawable_mouseup(struct gui_window *gw, gw->mouse->state &= ~BROWSER_MOUSE_MOD_3; if ((gw->mouse->state & click) != 0) { - LOG("mouse click bw %p, state 0x%x, x %f, y %f", - gw->bw, gw->mouse->state, - (x + gw->scrollx) / gw->scale, - (y + gw->scrolly) / gw->scale); + NSLOG(netsurf, INFO, + "mouse click bw %p, state 0x%x, x %f, y %f", gw->bw, + gw->mouse->state, (x + gw->scrollx) / gw->scale, + (y + gw->scrolly) / gw->scale); browser_window_mouse_click(gw->bw, gw->mouse->state, @@ -430,10 +431,9 @@ nsws_drawable_mousedown(struct gui_window *gw, gw->mouse->pressed_x = (x + gw->scrollx) / gw->scale; gw->mouse->pressed_y = (y + gw->scrolly) / gw->scale; - LOG("mouse click bw %p, state %x, x %f, y %f", - gw->bw, gw->mouse->state, - (x + gw->scrollx) / gw->scale, - (y + gw->scrolly) / gw->scale); + NSLOG(netsurf, INFO, "mouse click bw %p, state %x, x %f, y %f", + gw->bw, gw->mouse->state, (x + gw->scrollx) / gw->scale, + (y + gw->scrolly) / gw->scale); browser_window_mouse_click(gw->bw, gw->mouse->state, (x + gw->scrollx) / gw->scale, @@ -466,7 +466,8 @@ nsws_drawable_mousemove(struct gui_window *gw, int x, int y) (abs(x - gw->mouse->pressed_x) >= 5) && (abs(y - gw->mouse->pressed_y) >= 5)) { - LOG("Drag start state 0x%x", gw->mouse->state); + NSLOG(netsurf, INFO, "Drag start state 0x%x", + gw->mouse->state); if ((gw->mouse->state & BROWSER_MOUSE_PRESS_1) != 0) { browser_window_mouse_click(gw->bw, BROWSER_MOUSE_DRAG_1, @@ -515,7 +516,8 @@ nsws_window_drawable_event_callback(HWND hwnd, gw = nsws_get_gui_window(hwnd); if (gw == NULL) { - LOG("Unable to find gui window structure for hwnd %p", hwnd); + NSLOG(netsurf, INFO, + "Unable to find gui window structure for hwnd %p", hwnd); return DefWindowProc(hwnd, msg, wparam, lparam); } @@ -604,7 +606,7 @@ nsws_window_create_drawable(HINSTANCE hinstance, if (hwnd == NULL) { win_perror("WindowCreateDrawable"); - LOG("Window creation failed"); + NSLOG(netsurf, INFO, "Window creation failed"); return NULL; } diff --git a/frontends/windows/filetype.c b/frontends/windows/filetype.c index d31434aeb..a5fd9e95e 100644 --- a/frontends/windows/filetype.c +++ b/frontends/windows/filetype.c @@ -39,7 +39,7 @@ static const char *fetch_filetype(const char *unix_path) { int l; - LOG("unix path %s", unix_path); + NSLOG(netsurf, INFO, "unix path %s", unix_path); l = strlen(unix_path); if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0) return "text/css"; diff --git a/frontends/windows/findfile.c b/frontends/windows/findfile.c index e1c9595eb..e665530ba 100644 --- a/frontends/windows/findfile.c +++ b/frontends/windows/findfile.c @@ -99,7 +99,7 @@ char *nsws_find_resource(char *buf, const char *filename, const char *def) char t[PATH_MAX]; if (cdir != NULL) { - LOG("Found Home %s", cdir); + NSLOG(netsurf, INFO, "Found Home %s", cdir); strcpy(t, cdir); strcat(t, "/.netsurf/"); strcat(t, filename); @@ -126,7 +126,7 @@ char *nsws_find_resource(char *buf, const char *filename, const char *def) getcwd(t, PATH_MAX - SLEN("\\res\\") - strlen(filename)); strcat(t, "\\res\\"); strcat(t, filename); - LOG("looking in %s", t); + NSLOG(netsurf, INFO, "looking in %s", t); if ((realpath(t, buf) != NULL) && (access(buf, R_OK) == 0)) return buf; diff --git a/frontends/windows/gui.c b/frontends/windows/gui.c index 602dcd445..890bfae42 100644 --- a/frontends/windows/gui.c +++ b/frontends/windows/gui.c @@ -66,7 +66,7 @@ void win32_run(void) int timeout; /* timeout in miliseconds */ UINT timer_id = 0; - LOG("Starting messgae dispatcher"); + NSLOG(netsurf, INFO, "Starting messgae dispatcher"); while (!win32_quit) { /* run the scheduler and discover how long to wait for @@ -128,7 +128,7 @@ static void gui_get_clipboard(char **buffer, size_t *length) clipboard_handle = GetClipboardData(CF_TEXT); if (clipboard_handle != NULL) { content = GlobalLock(clipboard_handle); - LOG("pasting %s", content); + NSLOG(netsurf, INFO, "pasting %s", content); GlobalUnlock(clipboard_handle); } } diff --git a/frontends/windows/main.c b/frontends/windows/main.c index d019f10c7..98e90be80 100644 --- a/frontends/windows/main.c +++ b/frontends/windows/main.c @@ -99,7 +99,7 @@ static nserror get_config_home(char **config_home_out) *config_home_out = strdup(adPath); - LOG("using config path \"%s\"", *config_home_out); + NSLOG(netsurf, INFO, "using config path \"%s\"", *config_home_out); return NSERROR_OK; } @@ -343,15 +343,16 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) /* Locate the correct user configuration directory path */ ret = get_config_home(&nsw32_config_home); if (ret != NSERROR_OK) { - LOG("Unable to locate a configuration directory."); + NSLOG(netsurf, INFO, + "Unable to locate a configuration directory."); nsw32_config_home = NULL; } /* Initialise user options */ ret = nsw32_option_init(&argc, argv); if (ret != NSERROR_OK) { - LOG("Options failed to initialise (%s)\n", - messages_get_errorcode(ret)); + NSLOG(netsurf, INFO, "Options failed to initialise (%s)\n", + messages_get_errorcode(ret)); return 1; } @@ -365,7 +366,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) /* common initialisation */ ret = netsurf_init(NULL); if (ret != NSERROR_OK) { - LOG("NetSurf failed to initialise"); + NSLOG(netsurf, INFO, "NetSurf failed to initialise"); return 1; } @@ -392,7 +393,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) addr = NETSURF_HOMEPAGE; } - LOG("calling browser_window_create"); + NSLOG(netsurf, INFO, "calling browser_window_create"); ret = nsurl_create(addr, &url); if (ret == NSERROR_OK) { diff --git a/frontends/windows/plot.c b/frontends/windows/plot.c index 1bd0ba4a0..f38fe7522 100644 --- a/frontends/windows/plot.c +++ b/frontends/windows/plot.c @@ -84,7 +84,7 @@ plot_block(COLORREF col, int x, int y, int width, int height) /* ensure the plot HDC is set */ if (plot_hdc == NULL) { - LOG("HDC not set on call to plotters"); + NSLOG(netsurf, INFO, "HDC not set on call to plotters"); return NSERROR_INVALID; } @@ -299,7 +299,7 @@ plot_bitmap(struct bitmap *bitmap, int x, int y, int width, int height) /* ensure the plot HDC is set */ if (plot_hdc == NULL) { - LOG("HDC not set on call to plotters"); + NSLOG(netsurf, INFO, "HDC not set on call to plotters"); return NSERROR_INVALID; } @@ -404,7 +404,7 @@ arc(const struct redraw_context *ctx, /* ensure the plot HDC is set */ if (plot_hdc == NULL) { - LOG("HDC not set on call to plotters"); + NSLOG(netsurf, INFO, "HDC not set on call to plotters"); return NSERROR_INVALID; } @@ -515,7 +515,7 @@ disc(const struct redraw_context *ctx, /* ensure the plot HDC is set */ if (plot_hdc == NULL) { - LOG("HDC not set on call to plotters"); + NSLOG(netsurf, INFO, "HDC not set on call to plotters"); return NSERROR_INVALID; } @@ -594,7 +594,7 @@ line(const struct redraw_context *ctx, /* ensure the plot HDC is set */ if (plot_hdc == NULL) { - LOG("HDC not set on call to plotters"); + NSLOG(netsurf, INFO, "HDC not set on call to plotters"); return NSERROR_INVALID; } @@ -661,7 +661,7 @@ rectangle(const struct redraw_context *ctx, /* ensure the plot HDC is set */ if (plot_hdc == NULL) { - LOG("HDC not set on call to plotters"); + NSLOG(netsurf, INFO, "HDC not set on call to plotters"); return NSERROR_INVALID; } @@ -744,7 +744,7 @@ polygon(const struct redraw_context *ctx, /* ensure the plot HDC is set */ if (plot_hdc == NULL) { - LOG("HDC not set on call to plotters"); + NSLOG(netsurf, INFO, "HDC not set on call to plotters"); return NSERROR_INVALID; } @@ -878,7 +878,7 @@ bitmap(const struct redraw_context *ctx, PLOT_LOG("Plotting %p at %d,%d by %d,%d",bitmap, x,y,width,height); if (bitmap == NULL) { - LOG("Passed null bitmap!"); + NSLOG(netsurf, INFO, "Passed null bitmap!"); return NSERROR_OK; } @@ -993,7 +993,7 @@ text(const struct redraw_context *ctx, /* ensure the plot HDC is set */ if (plot_hdc == NULL) { - LOG("HDC not set on call to plotters"); + NSLOG(netsurf, INFO, "HDC not set on call to plotters"); return NSERROR_INVALID; } diff --git a/frontends/windows/prefs.c b/frontends/windows/prefs.c index f84ee1c96..591b57426 100644 --- a/frontends/windows/prefs.c +++ b/frontends/windows/prefs.c @@ -304,7 +304,8 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd, case WM_COMMAND: - LOG("WM_COMMAND Identifier 0x%x",LOWORD(wparam)); + NSLOG(netsurf, INFO, "WM_COMMAND Identifier 0x%x", + LOWORD(wparam)); switch(LOWORD(wparam)) { case IDC_PREFS_PROXYTYPE: diff --git a/frontends/windows/schedule.c b/frontends/windows/schedule.c index eae6c1d63..d6a757246 100644 --- a/frontends/windows/schedule.c +++ b/frontends/windows/schedule.c @@ -216,12 +216,14 @@ void list_schedule(void) gettimeofday(&tv, NULL); - LOG("schedule list at %ld:%ld", tv.tv_sec, tv.tv_usec); + NSLOG(netsurf, INFO, "schedule list at %ld:%ld", tv.tv_sec, + tv.tv_usec); cur_nscb = schedule_list; while (cur_nscb != NULL) { - LOG("Schedule %p at %ld:%ld", cur_nscb, cur_nscb->tv.tv_sec, cur_nscb->tv.tv_usec); + NSLOG(netsurf, INFO, "Schedule %p at %ld:%ld", cur_nscb, + cur_nscb->tv.tv_sec, cur_nscb->tv.tv_usec); cur_nscb = cur_nscb->next; } } diff --git a/frontends/windows/ssl_cert.c b/frontends/windows/ssl_cert.c index fac211c11..4db061626 100644 --- a/frontends/windows/ssl_cert.c +++ b/frontends/windows/ssl_cert.c @@ -191,7 +191,7 @@ nserror nsw32_cert_verify(struct nsurl *url, return res; } - LOG("creating hInstance %p SSL window", hinst); + NSLOG(netsurf, INFO, "creating hInstance %p SSL window", hinst); ncwin->hWnd = CreateWindowEx(0, windowclassname_sslcert, "SSL Certificate viewer", @@ -208,7 +208,7 @@ nserror nsw32_cert_verify(struct nsurl *url, hinst, NULL); if (ncwin->hWnd == NULL) { - LOG("Window create failed"); + NSLOG(netsurf, INFO, "Window create failed"); return NSERROR_NOMEM; } @@ -375,8 +375,11 @@ nsw32_window_ssl_cert_command(HWND hwnd, int identifier, HWND ctrl_window) { - LOG("notification_code %x identifier %x ctrl_window %p", - notification_code, identifier, ctrl_window); + NSLOG(netsurf, INFO, + "notification_code %x identifier %x ctrl_window %p", + notification_code, + identifier, + ctrl_window); switch(identifier) { case IDC_SSLCERT_BTN_ACCEPT: diff --git a/frontends/windows/window.c b/frontends/windows/window.c index c72173697..20db25a56 100644 --- a/frontends/windows/window.c +++ b/frontends/windows/window.c @@ -88,7 +88,7 @@ static int get_window_dpi(HWND hwnd) ReleaseDC(hwnd, hdc); - LOG("FIX DPI %d", dpi); + NSLOG(netsurf, INFO, "FIX DPI %d", dpi); return dpi; } @@ -163,7 +163,8 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct gui_window *gw) gw->mainmenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU_MAIN)); gw->rclick = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU_CONTEXT)); - LOG("creating hInstance %p GUI window %p", hInstance, gw); + NSLOG(netsurf, INFO, "creating hInstance %p GUI window %p", + hInstance, gw); hwnd = CreateWindowEx(0, windowclassname_main, "NetSurf Browser", @@ -181,7 +182,7 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct gui_window *gw) NULL); if (hwnd == NULL) { - LOG("Window create failed"); + NSLOG(netsurf, INFO, "Window create failed"); return NULL; } @@ -194,9 +195,9 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct gui_window *gw) (nsoption_int(window_height) >= 100) && (nsoption_int(window_x) >= 0) && (nsoption_int(window_y) >= 0)) { - LOG("Setting Window position %d,%d %d,%d", - nsoption_int(window_x), nsoption_int(window_y), - nsoption_int(window_width), nsoption_int(window_height)); + NSLOG(netsurf, INFO, "Setting Window position %d,%d %d,%d", + nsoption_int(window_x), nsoption_int(window_y), + nsoption_int(window_width), nsoption_int(window_height)); SetWindowPos(hwnd, HWND_TOP, nsoption_int(window_x), nsoption_int(window_y), @@ -227,47 +228,50 @@ nsws_window_toolbar_command(struct gui_window *gw, int identifier, HWND ctrl_window) { - LOG("notification_code %d identifier %d ctrl_window %p", - notification_code, identifier, ctrl_window); + NSLOG(netsurf, INFO, + "notification_code %d identifier %d ctrl_window %p", + notification_code, + identifier, + ctrl_window); switch(identifier) { case IDC_MAIN_URLBAR: switch (notification_code) { case EN_CHANGE: - LOG("EN_CHANGE"); + NSLOG(netsurf, INFO, "EN_CHANGE"); break; case EN_ERRSPACE: - LOG("EN_ERRSPACE"); + NSLOG(netsurf, INFO, "EN_ERRSPACE"); break; case EN_HSCROLL: - LOG("EN_HSCROLL"); + NSLOG(netsurf, INFO, "EN_HSCROLL"); break; case EN_KILLFOCUS: - LOG("EN_KILLFOCUS"); + NSLOG(netsurf, INFO, "EN_KILLFOCUS"); break; case EN_MAXTEXT: - LOG("EN_MAXTEXT"); + NSLOG(netsurf, INFO, "EN_MAXTEXT"); break; case EN_SETFOCUS: - LOG("EN_SETFOCUS"); + NSLOG(netsurf, INFO, "EN_SETFOCUS"); break; case EN_UPDATE: - LOG("EN_UPDATE"); + NSLOG(netsurf, INFO, "EN_UPDATE"); break; case EN_VSCROLL: - LOG("EN_VSCROLL"); + NSLOG(netsurf, INFO, "EN_VSCROLL"); break; default: - LOG("Unknown notification_code"); + NSLOG(netsurf, INFO, "Unknown notification_code"); break; } break; @@ -421,7 +425,7 @@ nsws_window_urlbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) case WM_DESTROY: hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0); if (hFont != NULL) { - LOG("Destroyed font object"); + NSLOG(netsurf, INFO, "Destroyed font object"); DeleteObject(hFont); } @@ -502,12 +506,13 @@ nsws_window_urlbar_create(HINSTANCE hInstance, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial"); if (hFont != NULL) { - LOG("Setting font object"); + NSLOG(netsurf, INFO, "Setting font object"); SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, 0); } - LOG("Created url bar hwnd:%p, x:%d, y:%d, w:%d, h:%d", - hwnd, urlx, urly, urlwidth, urlheight); + NSLOG(netsurf, INFO, + "Created url bar hwnd:%p, x:%d, y:%d, w:%d, h:%d", hwnd, urlx, + urly, urlwidth, urlheight); return hwnd; } @@ -548,7 +553,7 @@ nsws_window_throbber_create(HINSTANCE hInstance, NULL); nsws_find_resource(avi, "throbber.avi", "windows/res/throbber.avi"); - LOG("setting throbber avi as %s", avi); + NSLOG(netsurf, INFO, "setting throbber avi as %s", avi); Animate_Open(hwnd, avi); if (gw->throbbing) { Animate_Play(hwnd, 0, -1, -1); @@ -576,7 +581,8 @@ get_imagelist(HINSTANCE hInstance, int resid, int bsize, int bcnt) HIMAGELIST hImageList; HBITMAP hScrBM; - LOG("resource id %d, bzize %d, bcnt %d", resid, bsize, bcnt); + NSLOG(netsurf, INFO, "resource id %d, bzize %d, bcnt %d", resid, + bsize, bcnt); hImageList = ImageList_Create(bsize, bsize, ILC_COLOR24 | ILC_MASK, 0, @@ -997,8 +1003,11 @@ nsws_window_command(HWND hwnd, { nserror ret; - LOG("notification_code %x identifier %x ctrl_window %p", - notification_code, identifier, ctrl_window); + NSLOG(netsurf, INFO, + "notification_code %x identifier %x ctrl_window %p", + notification_code, + identifier, + ctrl_window); switch(identifier) { @@ -1073,7 +1082,7 @@ nsws_window_command(HWND hwnd, HANDLE h = GetClipboardData(CF_TEXT); if (h != NULL) { char *content = GlobalLock(h); - LOG("pasting %s\n", content); + NSLOG(netsurf, INFO, "pasting %s\n", content); GlobalUnlock(h); } CloseClipboard(); @@ -1276,7 +1285,7 @@ nsws_window_command(HWND hwnd, int len = SendMessage(gw->urlbar, WM_GETTEXTLENGTH, 0, 0); char addr[len + 1]; SendMessage(gw->urlbar, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)addr); - LOG("launching %s\n", addr); + NSLOG(netsurf, INFO, "launching %s\n", addr); if (nsurl_create(addr, &url) != NSERROR_OK) { win32_warning("NoMemory", 0); @@ -1313,7 +1322,7 @@ nsws_window_command(HWND hwnd, */ static bool win32_window_get_scroll(struct gui_window *gw, int *sx, int *sy) { - LOG("get scroll"); + NSLOG(netsurf, INFO, "get scroll"); if (gw == NULL) return false; @@ -1410,7 +1419,8 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) gw = nsws_get_gui_window(hwnd); if (gw == NULL) { - LOG("Unable to find gui window structure for hwnd %p", hwnd); + NSLOG(netsurf, INFO, + "Unable to find gui window structure for hwnd %p", hwnd); return DefWindowProc(hwnd, msg, wparam, lparam); } @@ -1463,7 +1473,7 @@ win32_window_create(struct browser_window *bw, { struct gui_window *gw; - LOG("Creating gui window for browser window %p", bw); + NSLOG(netsurf, INFO, "Creating gui window for browser window %p", bw); gw = calloc(1, sizeof(struct gui_window)); if (gw == NULL) { @@ -1484,7 +1494,7 @@ win32_window_create(struct browser_window *bw, gw->mouse = malloc(sizeof(struct browser_mouse)); if (gw->mouse == NULL) { free(gw); - LOG("Unable to allocate mouse state"); + NSLOG(netsurf, INFO, "Unable to allocate mouse state"); return NULL; } gw->mouse->gui = gw; @@ -1504,8 +1514,12 @@ win32_window_create(struct browser_window *bw, gw->statusbar = nsws_window_create_statusbar(hinst, gw->main, gw); gw->drawingarea = nsws_window_create_drawable(hinst, gw->main, gw); - LOG("new window: main:%p toolbar:%p statusbar %p drawingarea %p", - gw->main, gw->toolbar, gw->statusbar, gw->drawingarea); + NSLOG(netsurf, INFO, + "new window: main:%p toolbar:%p statusbar %p drawingarea %p", + gw->main, + gw->toolbar, + gw->statusbar, + gw->drawingarea); font_hwnd = gw->drawingarea; open_windows++; @@ -1556,7 +1570,7 @@ win32_window_get_dimensions(struct gui_window *gw, *width = gw->width; *height = gw->height; - LOG("gw:%p w=%d h=%d", gw, *width, *height); + NSLOG(netsurf, INFO, "gw:%p w=%d h=%d", gw, *width, *height); return NSERROR_OK; } @@ -1588,7 +1602,7 @@ static void win32_window_set_title(struct gui_window *w, const char *title) return; } - LOG("%p, title %s", w, title); + NSLOG(netsurf, INFO, "%p, title %s", w, title); fulltitle = malloc(strlen(title) + SLEN(" - NetSurf") + 1); if (fulltitle == NULL) { win32_warning("NoMemory", 0); diff --git a/render/box.c b/render/box.c index 77cc15bc3..8b9c89ee6 100644 --- a/render/box.c +++ b/render/box.c @@ -1155,7 +1155,7 @@ bool box_handle_scrollbars(struct content *c, struct box *box, if (box->scroll_y == NULL) { data = malloc(sizeof(struct html_scrollbar_data)); if (data == NULL) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); guit->misc->warning("NoMemory", 0); return false; } @@ -1176,7 +1176,7 @@ bool box_handle_scrollbars(struct content *c, struct box *box, if (box->scroll_x == NULL) { data = malloc(sizeof(struct html_scrollbar_data)); if (data == NULL) { - LOG("malloc failed"); + NSLOG(netsurf, INFO, "malloc failed"); guit->misc->warning("NoMemory", 0); return false; } diff --git a/render/box_construct.c b/render/box_construct.c index d0ffd9d83..549d9122f 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -1900,7 +1900,7 @@ bool box_frameset(BOX_SPECIAL_PARAMS) bool ok; if (content->frameset) { - LOG("Error: multiple framesets in document."); + NSLOG(netsurf, INFO, "Error: multiple framesets in document."); /* Don't convert children */ if (convert_children) *convert_children = false; diff --git a/render/box_normalise.c b/render/box_normalise.c index 5d36b99d7..9f78f75ac 100644 --- a/render/box_normalise.c +++ b/render/box_normalise.c @@ -111,7 +111,7 @@ bool box_normalise_block(struct box *block, html_content *c) assert(block != NULL); #ifdef BOX_NORMALISE_DEBUG - LOG("block %p, block->type %u", block, block->type); + NSLOG(netsurf, INFO, "block %p, block->type %u", block, block->type); #endif assert(block->type == BOX_BLOCK || block->type == BOX_INLINE_BLOCK || @@ -119,7 +119,8 @@ bool box_normalise_block(struct box *block, html_content *c) for (child = block->children; child != NULL; child = next_child) { #ifdef BOX_NORMALISE_DEBUG - LOG("child %p, child->type = %d", child, child->type); + NSLOG(netsurf, INFO, "child %p, child->type = %d", child, + child->type); #endif next_child = child->next; /* child may be destroyed */ @@ -223,7 +224,7 @@ bool box_normalise_table(struct box *table, html_content * c) assert(table->type == BOX_TABLE); #ifdef BOX_NORMALISE_DEBUG - LOG("table %p", table); + NSLOG(netsurf, INFO, "table %p", table); #endif col_info.num_columns = 1; @@ -337,7 +338,8 @@ bool box_normalise_table(struct box *table, html_content * c) struct box *row; #ifdef BOX_NORMALISE_DEBUG - LOG("table->children == 0, creating implied row"); + NSLOG(netsurf, INFO, + "table->children == 0, creating implied row"); #endif assert(table->style != NULL); @@ -399,7 +401,7 @@ bool box_normalise_table(struct box *table, html_content * c) return false; #ifdef BOX_NORMALISE_DEBUG - LOG("table %p done", table); + NSLOG(netsurf, INFO, "table %p done", table); #endif return true; @@ -585,7 +587,7 @@ bool box_normalise_table_row_group(struct box *row_group, assert(row_group->type == BOX_TABLE_ROW_GROUP); #ifdef BOX_NORMALISE_DEBUG - LOG("row_group %p", row_group); + NSLOG(netsurf, INFO, "row_group %p", row_group); #endif for (child = row_group->children; child != NULL; child = next_child) { @@ -677,7 +679,8 @@ bool box_normalise_table_row_group(struct box *row_group, if (row_group->children == NULL) { #ifdef BOX_NORMALISE_DEBUG - LOG("row_group->children == 0, inserting implied row"); + NSLOG(netsurf, INFO, + "row_group->children == 0, inserting implied row"); #endif assert(row_group->style != NULL); @@ -712,7 +715,7 @@ bool box_normalise_table_row_group(struct box *row_group, row_group->rows = group_row_count; #ifdef BOX_NORMALISE_DEBUG - LOG("row_group %p done", row_group); + NSLOG(netsurf, INFO, "row_group %p done", row_group); #endif return true; @@ -734,7 +737,7 @@ bool box_normalise_table_row(struct box *row, assert(row->type == BOX_TABLE_ROW); #ifdef BOX_NORMALISE_DEBUG - LOG("row %p", row); + NSLOG(netsurf, INFO, "row %p", row); #endif for (child = row->children; child != NULL; child = next_child) { @@ -843,7 +846,7 @@ bool box_normalise_table_row(struct box *row, col_info->num_rows++; #ifdef BOX_NORMALISE_DEBUG - LOG("row %p done", row); + NSLOG(netsurf, INFO, "row %p done", row); #endif return true; @@ -934,7 +937,7 @@ bool box_normalise_inline_container(struct box *cont, html_content * c) assert(cont->type == BOX_INLINE_CONTAINER); #ifdef BOX_NORMALISE_DEBUG - LOG("cont %p", cont); + NSLOG(netsurf, INFO, "cont %p", cont); #endif for (child = cont->children; child != NULL; child = next_child) { @@ -997,7 +1000,7 @@ bool box_normalise_inline_container(struct box *cont, html_content * c) } #ifdef BOX_NORMALISE_DEBUG - LOG("cont %p done", cont); + NSLOG(netsurf, INFO, "cont %p done", cont); #endif return true; diff --git a/render/box_textarea.c b/render/box_textarea.c index 1586d71c4..3b1e7750c 100644 --- a/render/box_textarea.c +++ b/render/box_textarea.c @@ -149,7 +149,9 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg) break; default: - LOG("Drag type %d not handled.", msg->data.drag); + NSLOG(netsurf, INFO, + "Drag type %d not handled.", + msg->data.drag); /* This is a logic faliure in the * front end code so abort. */ diff --git a/render/form.c b/render/form.c index a8b96fefb..904272d3a 100644 --- a/render/form.c +++ b/render/form.c @@ -218,7 +218,8 @@ void form_free_control(struct form_control *control) struct form_control *c; assert(control != NULL); - LOG("Control:%p name:%p value:%p initial:%p", control, control->name, control->value, control->initial_value); + NSLOG(netsurf, INFO, "Control:%p name:%p value:%p initial:%p", + control, control->name, control->value, control->initial_value); free(control->name); free(control->value); free(control->initial_value); @@ -229,7 +230,9 @@ void form_free_control(struct form_control *control) for (option = control->data.select.items; option; option = next) { next = option->next; - LOG("select option:%p text:%p value:%p", option, option->text, option->value); + NSLOG(netsurf, INFO, + "select option:%p text:%p value:%p", option, + option->text, option->value); free(option->text); free(option->value); free(option); @@ -348,7 +351,7 @@ bool form_successful_controls_dom(struct form *_form, /** \todo Replace this call with something DOMish */ charset = form_acceptable_charset(_form); if (charset == NULL) { - LOG("failed to find charset"); + NSLOG(netsurf, INFO, "failed to find charset"); return false; } @@ -362,7 +365,7 @@ bool form_successful_controls_dom(struct form *_form, err = dom_html_form_element_get_elements(form, &form_elements); if (err != DOM_NO_ERR) { - LOG("Could not get form elements"); + NSLOG(netsurf, INFO, "Could not get form elements"); goto dom_no_memory; } @@ -370,7 +373,7 @@ bool form_successful_controls_dom(struct form *_form, err = dom_html_collection_get_length(form_elements, &element_count); if (err != DOM_NO_ERR) { - LOG("Could not get form element count"); + NSLOG(netsurf, INFO, "Could not get form element count"); goto dom_no_memory; } @@ -402,7 +405,8 @@ bool form_successful_controls_dom(struct form *_form, err = dom_html_collection_item(form_elements, index, &form_element); if (err != DOM_NO_ERR) { - LOG("Could not retrieve form element %d", index); + NSLOG(netsurf, INFO, + "Could not retrieve form element %d", index); goto dom_no_memory; } @@ -414,7 +418,7 @@ bool form_successful_controls_dom(struct form *_form, */ err = dom_node_get_node_name(form_element, &nodename); if (err != DOM_NO_ERR) { - LOG("Could not get node name"); + NSLOG(netsurf, INFO, "Could not get node name"); goto dom_no_memory; } @@ -423,14 +427,16 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_text_area_element *)form_element, &element_disabled); if (err != DOM_NO_ERR) { - LOG("Could not get text area disabled property"); + NSLOG(netsurf, INFO, + "Could not get text area disabled property"); goto dom_no_memory; } err = dom_html_text_area_element_get_name( (dom_html_text_area_element *)form_element, &inputname); if (err != DOM_NO_ERR) { - LOG("Could not get text area name property"); + NSLOG(netsurf, INFO, + "Could not get text area name property"); goto dom_no_memory; } } else if (dom_string_isequal(nodename, corestring_dom_SELECT)) { @@ -438,14 +444,16 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_select_element *)form_element, &element_disabled); if (err != DOM_NO_ERR) { - LOG("Could not get select disabled property"); + NSLOG(netsurf, INFO, + "Could not get select disabled property"); goto dom_no_memory; } err = dom_html_select_element_get_name( (dom_html_select_element *)form_element, &inputname); if (err != DOM_NO_ERR) { - LOG("Could not get select name property"); + NSLOG(netsurf, INFO, + "Could not get select name property"); goto dom_no_memory; } } else if (dom_string_isequal(nodename, corestring_dom_INPUT)) { @@ -453,14 +461,16 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_input_element *)form_element, &element_disabled); if (err != DOM_NO_ERR) { - LOG("Could not get input disabled property"); + NSLOG(netsurf, INFO, + "Could not get input disabled property"); goto dom_no_memory; } err = dom_html_input_element_get_name( (dom_html_input_element *)form_element, &inputname); if (err != DOM_NO_ERR) { - LOG("Could not get input name property"); + NSLOG(netsurf, INFO, + "Could not get input name property"); goto dom_no_memory; } } else if (dom_string_isequal(nodename, corestring_dom_BUTTON)) { @@ -468,21 +478,23 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_button_element *)form_element, &element_disabled); if (err != DOM_NO_ERR) { - LOG("Could not get button disabled property"); + NSLOG(netsurf, INFO, + "Could not get button disabled property"); goto dom_no_memory; } err = dom_html_button_element_get_name( (dom_html_button_element *)form_element, &inputname); if (err != DOM_NO_ERR) { - LOG("Could not get button name property"); + NSLOG(netsurf, INFO, + "Could not get button name property"); goto dom_no_memory; } } else { /* Unknown element type came through! */ - LOG("Unknown element type: %*s", - (int)dom_string_byte_length(nodename), - dom_string_data(nodename)); + NSLOG(netsurf, INFO, "Unknown element type: %*s", + (int)dom_string_byte_length(nodename), + dom_string_data(nodename)); goto dom_no_memory; } if (element_disabled) @@ -495,7 +507,8 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_text_area_element *)form_element, &inputvalue); if (err != DOM_NO_ERR) { - LOG("Could not get text area content"); + NSLOG(netsurf, INFO, + "Could not get text area content"); goto dom_no_memory; } } else if (dom_string_isequal(nodename, corestring_dom_SELECT)) { @@ -504,13 +517,15 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_select_element *)form_element, &options); if (err != DOM_NO_ERR) { - LOG("Could not get select options collection"); + NSLOG(netsurf, INFO, + "Could not get select options collection"); goto dom_no_memory; } err = dom_html_options_collection_get_length( options, &options_count); if (err != DOM_NO_ERR) { - LOG("Could not get select options collection length"); + NSLOG(netsurf, INFO, + "Could not get select options collection length"); goto dom_no_memory; } for(option_index = 0; option_index < options_count; @@ -527,14 +542,17 @@ bool form_successful_controls_dom(struct form *_form, err = dom_html_options_collection_item( options, option_index, &option_element); if (err != DOM_NO_ERR) { - LOG("Could not get options item %d", option_index); + NSLOG(netsurf, INFO, + "Could not get options item %d", + option_index); goto dom_no_memory; } err = dom_html_option_element_get_selected( (dom_html_option_element *)option_element, &selected); if (err != DOM_NO_ERR) { - LOG("Could not get option selected property"); + NSLOG(netsurf, INFO, + "Could not get option selected property"); goto dom_no_memory; } if (!selected) @@ -543,13 +561,15 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_option_element *)option_element, &inputvalue); if (err != DOM_NO_ERR) { - LOG("Could not get option value"); + NSLOG(netsurf, INFO, + "Could not get option value"); goto dom_no_memory; } success_new = calloc(1, sizeof(*success_new)); if (success_new == NULL) { - LOG("Could not allocate data for option"); + NSLOG(netsurf, INFO, + "Could not allocate data for option"); goto dom_no_memory; } @@ -558,12 +578,14 @@ bool form_successful_controls_dom(struct form *_form, success_new->name = ENCODE_ITEM(inputname); if (success_new->name == NULL) { - LOG("Could not encode name for option"); + NSLOG(netsurf, INFO, + "Could not encode name for option"); goto dom_no_memory; } success_new->value = ENCODE_ITEM(inputvalue); if (success_new->value == NULL) { - LOG("Could not encode value for option"); + NSLOG(netsurf, INFO, + "Could not encode value for option"); goto dom_no_memory; } } @@ -573,7 +595,8 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_button_element *) form_element, &inputtype); if (err != DOM_NO_ERR) { - LOG("Could not get button element type"); + NSLOG(netsurf, INFO, + "Could not get button element type"); goto dom_no_memory; } if (dom_string_caseless_isequal( @@ -593,7 +616,8 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_button_element *)form_element, &inputvalue); if (err != DOM_NO_ERR) { - LOG("Could not get submit button value"); + NSLOG(netsurf, INFO, + "Could not get submit button value"); goto dom_no_memory; } /* Drop through to report successful button */ @@ -610,7 +634,8 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_input_element *) form_element, &inputtype); if (err != DOM_NO_ERR) { - LOG("Could not get input element type"); + NSLOG(netsurf, INFO, + "Could not get input element type"); goto dom_no_memory; } if (dom_string_caseless_isequal( @@ -630,7 +655,8 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_input_element *)form_element, &inputvalue); if (err != DOM_NO_ERR) { - LOG("Could not get submit button value"); + NSLOG(netsurf, INFO, + "Could not get submit button value"); goto dom_no_memory; } /* Drop through to report the successful button */ @@ -648,11 +674,13 @@ bool form_successful_controls_dom(struct form *_form, corestring_dom___ns_key_image_coords_node_data, &coords); if (err != DOM_NO_ERR) { - LOG("Could not get image XY data"); + NSLOG(netsurf, INFO, + "Could not get image XY data"); goto dom_no_memory; } if (coords == NULL) { - LOG("No XY data on the image input"); + NSLOG(netsurf, INFO, + "No XY data on the image input"); goto dom_no_memory; } @@ -661,7 +689,8 @@ bool form_successful_controls_dom(struct form *_form, success_new = calloc(1, sizeof(*success_new)); if (success_new == NULL) { free(basename); - LOG("Could not allocate data for image.x"); + NSLOG(netsurf, INFO, + "Could not allocate data for image.x"); goto dom_no_memory; } @@ -671,13 +700,15 @@ bool form_successful_controls_dom(struct form *_form, success_new->name = malloc(strlen(basename) + 3); if (success_new->name == NULL) { free(basename); - LOG("Could not allocate name for image.x"); + NSLOG(netsurf, INFO, + "Could not allocate name for image.x"); goto dom_no_memory; } success_new->value = malloc(20); if (success_new->value == NULL) { free(basename); - LOG("Could not allocate value for image.x"); + NSLOG(netsurf, INFO, + "Could not allocate value for image.x"); goto dom_no_memory; } sprintf(success_new->name, "%s.x", basename); @@ -686,7 +717,8 @@ bool form_successful_controls_dom(struct form *_form, success_new = calloc(1, sizeof(*success_new)); if (success_new == NULL) { free(basename); - LOG("Could not allocate data for image.y"); + NSLOG(netsurf, INFO, + "Could not allocate data for image.y"); goto dom_no_memory; } @@ -696,13 +728,15 @@ bool form_successful_controls_dom(struct form *_form, success_new->name = malloc(strlen(basename) + 3); if (success_new->name == NULL) { free(basename); - LOG("Could not allocate name for image.y"); + NSLOG(netsurf, INFO, + "Could not allocate name for image.y"); goto dom_no_memory; } success_new->value = malloc(20); if (success_new->value == NULL) { free(basename); - LOG("Could not allocate value for image.y"); + NSLOG(netsurf, INFO, + "Could not allocate value for image.y"); goto dom_no_memory; } sprintf(success_new->name, "%s.y", basename); @@ -717,7 +751,8 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_input_element *)form_element, &checked); if (err != DOM_NO_ERR) { - LOG("Could not get input element checked"); + NSLOG(netsurf, INFO, + "Could not get input element checked"); goto dom_no_memory; } if (!checked) @@ -726,7 +761,8 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_input_element *)form_element, &inputvalue); if (err != DOM_NO_ERR) { - LOG("Could not get input element value"); + NSLOG(netsurf, INFO, + "Could not get input element value"); goto dom_no_memory; } if (inputvalue == NULL) { @@ -741,7 +777,8 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_input_element *)form_element, &inputvalue); if (err != DOM_NO_ERR) { - LOG("Could not get file value"); + NSLOG(netsurf, INFO, + "Could not get file value"); goto dom_no_memory; } err = dom_node_get_user_data( @@ -749,14 +786,16 @@ bool form_successful_controls_dom(struct form *_form, corestring_dom___ns_key_file_name_node_data, &rawfile_temp); if (err != DOM_NO_ERR) { - LOG("Could not get file rawname"); + NSLOG(netsurf, INFO, + "Could not get file rawname"); goto dom_no_memory; } rawfile_temp = strdup(rawfile_temp != NULL ? rawfile_temp : ""); if (rawfile_temp == NULL) { - LOG("Could not copy file rawname"); + NSLOG(netsurf, INFO, + "Could not copy file rawname"); goto dom_no_memory; } /* Fall out to the allocation */ @@ -765,7 +804,8 @@ bool form_successful_controls_dom(struct form *_form, dom_string_caseless_isequal( inputtype, corestring_dom_button)) { /* Skip these */ - LOG("Skipping RESET and BUTTON"); + NSLOG(netsurf, INFO, + "Skipping RESET and BUTTON"); continue; } else { /* Everything else is treated as text values */ @@ -773,7 +813,8 @@ bool form_successful_controls_dom(struct form *_form, (dom_html_input_element *)form_element, &inputvalue); if (err != DOM_NO_ERR) { - LOG("Could not get input value"); + NSLOG(netsurf, INFO, + "Could not get input value"); goto dom_no_memory; } /* Fall out to the allocation */ @@ -782,7 +823,8 @@ bool form_successful_controls_dom(struct form *_form, success_new = calloc(1, sizeof(*success_new)); if (success_new == NULL) { - LOG("Could not allocate data for generic"); + NSLOG(netsurf, INFO, + "Could not allocate data for generic"); goto dom_no_memory; } @@ -791,12 +833,14 @@ bool form_successful_controls_dom(struct form *_form, success_new->name = ENCODE_ITEM(inputname); if (success_new->name == NULL) { - LOG("Could not encode name for generic"); + NSLOG(netsurf, INFO, + "Could not encode name for generic"); goto dom_no_memory; } success_new->value = ENCODE_ITEM(inputvalue); if (success_new->value == NULL) { - LOG("Could not encode value for generic"); + NSLOG(netsurf, INFO, + "Could not encode value for generic"); goto dom_no_memory; } if (rawfile_temp != NULL) { diff --git a/render/html.c b/render/html.c index 62dec9e95..482259f1c 100644 --- a/render/html.c +++ b/render/html.c @@ -89,8 +89,8 @@ bool fire_dom_event(dom_string *type, dom_node *target, dom_event_unref(evt); return false; } - LOG("Dispatching '%*s' against %p", - dom_string_length(type), dom_string_data(type), target); + NSLOG(netsurf, INFO, "Dispatching '%*s' against %p", + dom_string_length(type), dom_string_data(type), target); exc = dom_event_target_dispatch_event(target, evt, &result); if (exc != DOM_NO_ERR) { result = false; @@ -111,7 +111,7 @@ static void html_box_convert_done(html_content *c, bool success) dom_exception exc; /* returned by libdom functions */ dom_node *html; - LOG("Done XML to box (%p)", c); + NSLOG(netsurf, INFO, "Done XML to box (%p)", c); /* Clean up and report error if unsuccessful or aborted */ if ((success == false) || (c->aborted)) { @@ -141,7 +141,7 @@ static void html_box_convert_done(html_content *c, bool success) /** @todo should this call html_object_free_objects(c); * like the other error paths */ - LOG("error retrieving html element from dom"); + NSLOG(netsurf, INFO, "error retrieving html element from dom"); content_broadcast_errorcode(&c->base, NSERROR_DOM); content_set_error(&c->base); return; @@ -150,7 +150,7 @@ static void html_box_convert_done(html_content *c, bool success) /* extract image maps - can't do this sensibly in dom_to_box */ err = imagemap_extract(c); if (err != NSERROR_OK) { - LOG("imagemap extraction failed"); + NSLOG(netsurf, INFO, "imagemap extraction failed"); html_object_free_objects(c); content_broadcast_errorcode(&c->base, err); content_set_error(&c->base); @@ -601,14 +601,14 @@ void html_finish_conversion(html_content *htmlc) } /* convert dom tree to box tree */ - LOG("DOM to box (%p)", htmlc); + NSLOG(netsurf, INFO, "DOM to box (%p)", htmlc); content_set_status(&htmlc->base, messages_get("Processing")); msg_data.explicit_status_text = NULL; content_broadcast(&htmlc->base, CONTENT_MSG_STATUS, &msg_data); exc = dom_document_get_document_element(htmlc->document, (void *) &html); if ((exc != DOM_NO_ERR) || (html == NULL)) { - LOG("error retrieving html element from dom"); + NSLOG(netsurf, INFO, "error retrieving html element from dom"); content_broadcast_errorcode(&htmlc->base, NSERROR_DOM); content_set_error(&htmlc->base); return; @@ -616,7 +616,7 @@ void html_finish_conversion(html_content *htmlc) error = dom_to_box(html, htmlc, html_box_convert_done); if (error != NSERROR_OK) { - LOG("box conversion failed"); + NSLOG(netsurf, INFO, "box conversion failed"); dom_node_unref(html); html_object_free_objects(htmlc); content_broadcast_errorcode(&htmlc->base, error); @@ -687,9 +687,10 @@ dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw) content_broadcast(&htmlc->base, CONTENT_MSG_GETCTX, &msg_data); - LOG("javascript context: %p (htmlc: %p)", - htmlc->jscontext, - htmlc); + NSLOG(netsurf, INFO, + "javascript context: %p (htmlc: %p)", + htmlc->jscontext, + htmlc); } if (htmlc->jscontext != NULL) { js_handle_new_element(htmlc->jscontext, @@ -795,22 +796,22 @@ html_document_user_data_handler(dom_node_operation operation, switch (operation) { case DOM_NODE_CLONED: - LOG("Cloned"); + NSLOG(netsurf, INFO, "Cloned"); break; case DOM_NODE_RENAMED: - LOG("Renamed"); + NSLOG(netsurf, INFO, "Renamed"); break; case DOM_NODE_IMPORTED: - LOG("imported"); + NSLOG(netsurf, INFO, "imported"); break; case DOM_NODE_ADOPTED: - LOG("Adopted"); + NSLOG(netsurf, INFO, "Adopted"); break; case DOM_NODE_DELETED: /* This is the only path I expect */ break; default: - LOG("User data operation not handled."); + NSLOG(netsurf, INFO, "User data operation not handled."); assert(0); } } @@ -935,7 +936,7 @@ html_create_html_data(html_content *c, const http_parameter *params) lwc_string_unref(c->universal); c->universal = NULL; - LOG("Unable to set user data."); + NSLOG(netsurf, INFO, "Unable to set user data."); return NSERROR_DOM; } @@ -1142,11 +1143,11 @@ static bool html_convert(struct content *c) exc = dom_document_get_quirks_mode(htmlc->document, &htmlc->quirks); if (exc == DOM_NO_ERR) { html_css_quirks_stylesheets(htmlc); - LOG("quirks set to %d", htmlc->quirks); + NSLOG(netsurf, INFO, "quirks set to %d", htmlc->quirks); } htmlc->base.active--; /* the html fetch is no longer active */ - LOG("%d fetches active (%p)", htmlc->base.active, c); + NSLOG(netsurf, INFO, "%d fetches active (%p)", htmlc->base.active, c); /* The parse cannot be completed here because it may be paused * untill all the resources being fetched have completed. @@ -1199,11 +1200,11 @@ html_begin_conversion(html_content *htmlc) * complete to avoid repeating the completion pointlessly. */ if (htmlc->parse_completed == false) { - LOG("Completing parse (%p)", htmlc); + NSLOG(netsurf, INFO, "Completing parse (%p)", htmlc); /* complete parsing */ error = dom_hubbub_parser_completed(htmlc->parser); if (error != DOM_HUBBUB_OK) { - LOG("Parsing failed"); + NSLOG(netsurf, INFO, "Parsing failed"); content_broadcast_errorcode(&htmlc->base, libdom_hubbub_error_to_nserror(error)); @@ -1214,15 +1215,15 @@ html_begin_conversion(html_content *htmlc) } if (html_can_begin_conversion(htmlc) == false) { - LOG("Can't begin conversion (%p)", htmlc); + NSLOG(netsurf, INFO, "Can't begin conversion (%p)", htmlc); /* We can't proceed (see commentary above) */ return true; } /* Give up processing if we've been aborted */ if (htmlc->aborted) { - LOG("Conversion aborted (%p) (active: %u)", htmlc, - htmlc->base.active); + NSLOG(netsurf, INFO, "Conversion aborted (%p) (active: %u)", + htmlc, htmlc->base.active); content_set_error(&htmlc->base); content_broadcast_errorcode(&htmlc->base, NSERROR_STOPPED); return false; @@ -1258,7 +1259,7 @@ html_begin_conversion(html_content *htmlc) /* locate root element and ensure it is html */ exc = dom_document_get_document_element(htmlc->document, (void *) &html); if ((exc != DOM_NO_ERR) || (html == NULL)) { - LOG("error retrieving html element from dom"); + NSLOG(netsurf, INFO, "error retrieving html element from dom"); content_broadcast_errorcode(&htmlc->base, NSERROR_DOM); return false; } @@ -1268,7 +1269,7 @@ html_begin_conversion(html_content *htmlc) (node_name == NULL) || (!dom_string_caseless_lwc_isequal(node_name, corestring_lwc_html))) { - LOG("root element not html"); + NSLOG(netsurf, INFO, "root element not html"); content_broadcast_errorcode(&htmlc->base, NSERROR_DOM); dom_node_unref(html); return false; @@ -1374,7 +1375,8 @@ static void html_stop(struct content *c) break; default: - LOG("Unexpected status %d (%p)", c->status, c); + NSLOG(netsurf, INFO, "Unexpected status %d (%p)", c->status, + c); assert(0); } } @@ -1531,7 +1533,7 @@ static void html_destroy(struct content *c) html_content *html = (html_content *) c; struct form *f, *g; - LOG("content %p", c); + NSLOG(netsurf, INFO, "content %p", c); /* Destroy forms */ for (f = html->forms; f != NULL; f = g) { @@ -1920,7 +1922,7 @@ static void html__dom_user_data_handler(dom_node_operation operation, free(data); break; default: - LOG("User data operation not handled."); + NSLOG(netsurf, INFO, "User data operation not handled."); assert(0); } } @@ -1936,7 +1938,8 @@ static void html__set_file_gadget_filename(struct content *c, ret = guit->utf8->local_to_utf8(fn, 0, &utf8_fn); if (ret != NSERROR_OK) { assert(ret != NSERROR_BAD_ENCODING); - LOG("utf8 to local encoding conversion failed"); + NSLOG(netsurf, INFO, + "utf8 to local encoding conversion failed"); /* Load was for us - just no memory */ return; } @@ -2088,7 +2091,7 @@ static bool html_drop_file_at_point(struct content *c, int x, int y, char *file) if (ret != NSERROR_OK) { /* bad encoding shouldn't happen */ assert(ret != NSERROR_BAD_ENCODING); - LOG("local to utf8 encoding failed"); + NSLOG(netsurf, INFO, "local to utf8 encoding failed"); free(buffer); guit->misc->warning("NoMemory", NULL); return true; @@ -2154,19 +2157,19 @@ html_debug_dump(struct content *c, FILE *f, enum content_debug op) ret = NSERROR_OK; } else { if (htmlc->document == NULL) { - LOG("No document to dump"); + NSLOG(netsurf, INFO, "No document to dump"); return NSERROR_DOM; } exc = dom_document_get_document_element(htmlc->document, (void *) &html); if ((exc != DOM_NO_ERR) || (html == NULL)) { - LOG("Unable to obtain root node"); + NSLOG(netsurf, INFO, "Unable to obtain root node"); return NSERROR_DOM; } ret = libdom_dump_structure(html, f, 0); - LOG("DOM structure dump returning %d", ret); + NSLOG(netsurf, INFO, "DOM structure dump returning %d", ret); dom_node_unref(html); } diff --git a/render/html_css.c b/render/html_css.c index ad1470daf..303bee64d 100644 --- a/render/html_css.c +++ b/render/html_css.c @@ -103,18 +103,21 @@ html_convert_css_callback(hlcache_handle *css, switch (event->type) { case CONTENT_MSG_DONE: - LOG("done stylesheet slot %d '%s'", i, nsurl_access(hlcache_handle_get_url(css))); + NSLOG(netsurf, INFO, "done stylesheet slot %d '%s'", i, + nsurl_access(hlcache_handle_get_url(css))); parent->base.active--; - LOG("%d fetches active", parent->base.active); + NSLOG(netsurf, INFO, "%d fetches active", parent->base.active); break; case CONTENT_MSG_ERROR: - LOG("stylesheet %s failed: %s", nsurl_access(hlcache_handle_get_url(css)), event->data.error); + NSLOG(netsurf, INFO, "stylesheet %s failed: %s", + nsurl_access(hlcache_handle_get_url(css)), + event->data.error); case CONTENT_MSG_ERRORCODE: hlcache_handle_release(css); s->sheet = NULL; parent->base.active--; - LOG("%d fetches active", parent->base.active); + NSLOG(netsurf, INFO, "%d fetches active", parent->base.active); content_add_error(&parent->base, "?", 0); break; @@ -151,7 +154,7 @@ html_stylesheet_from_domnode(html_content *c, exc = dom_node_get_text_content(node, &style); if ((exc != DOM_NO_ERR) || (style == NULL)) { - LOG("No text content"); + NSLOG(netsurf, INFO, "No text content"); return NSERROR_OK; } @@ -182,7 +185,7 @@ html_stylesheet_from_domnode(html_content *c, nsurl_unref(url); c->base.active++; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); return NSERROR_OK; } @@ -254,13 +257,14 @@ static bool html_css_process_modified_style(html_content *c, error = html_stylesheet_from_domnode(c, s->node, &sheet); if (error != NSERROR_OK) { - LOG("Failed to update sheet"); + NSLOG(netsurf, INFO, "Failed to update sheet"); content_broadcast_errorcode(&c->base, error); return false; } if (sheet != NULL) { - LOG("Updating sheet %p with %p", s->sheet, sheet); + NSLOG(netsurf, INFO, "Updating sheet %p with %p", s->sheet, + sheet); if (s->sheet != NULL) { switch (content_get_status(s->sheet)) { @@ -269,7 +273,8 @@ static bool html_css_process_modified_style(html_content *c, default: hlcache_handle_abort(s->sheet); c->base.active--; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", + c->base.active); } hlcache_handle_release(s->sheet); } @@ -314,7 +319,9 @@ bool html_css_update_style(html_content *c, dom_node *style) s = html_create_style_element(c, style); } if (s == NULL) { - LOG("Could not find or create inline stylesheet for %p", style); + NSLOG(netsurf, INFO, + "Could not find or create inline stylesheet for %p", + style); return false; } @@ -418,7 +425,8 @@ bool html_css_process_link(html_content *htmlc, dom_node *node) } dom_string_unref(href); - LOG("linked stylesheet %i '%s'", htmlc->stylesheet_count, nsurl_access(joined)); + NSLOG(netsurf, INFO, "linked stylesheet %i '%s'", + htmlc->stylesheet_count, nsurl_access(joined)); /* extend stylesheets array to allow for new sheet */ stylesheets = realloc(htmlc->stylesheets, @@ -453,7 +461,7 @@ bool html_css_process_link(html_content *htmlc, dom_node *node) htmlc->stylesheet_count++; htmlc->base.active++; - LOG("%d fetches active", htmlc->base.active); + NSLOG(netsurf, INFO, "%d fetches active", htmlc->base.active); return true; @@ -518,7 +526,7 @@ nserror html_css_quirks_stylesheets(html_content *c) } c->base.active++; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); } return ns_error; @@ -562,7 +570,7 @@ nserror html_css_new_stylesheets(html_content *c) } c->base.active++; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); if (nsoption_bool(block_advertisements)) { @@ -576,7 +584,7 @@ nserror html_css_new_stylesheets(html_content *c) } c->base.active++; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); } @@ -589,7 +597,7 @@ nserror html_css_new_stylesheets(html_content *c) } c->base.active++; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); return ns_error; } diff --git a/render/html_css_fetcher.c b/render/html_css_fetcher.c index 9eda6aeb7..0f8809a42 100644 --- a/render/html_css_fetcher.c +++ b/render/html_css_fetcher.c @@ -61,13 +61,15 @@ static html_css_fetcher_context *ring = NULL; static bool html_css_fetcher_initialise(lwc_string *scheme) { - LOG("html_css_fetcher_initialise called for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "html_css_fetcher_initialise called for %s", + lwc_string_data(scheme)); return true; } static void html_css_fetcher_finalise(lwc_string *scheme) { - LOG("html_css_fetcher_finalise called for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "html_css_fetcher_finalise called for %s", + lwc_string_data(scheme)); } static bool html_css_fetcher_can_fetch(const nsurl *url) @@ -251,7 +253,8 @@ static void html_css_fetcher_poll(lwc_string *scheme) html_css_fetcher_send_callback(&msg, c); } } else { - LOG("Processing of %s failed!", nsurl_access(c->url)); + NSLOG(netsurf, INFO, "Processing of %s failed!", + nsurl_access(c->url)); /* Ensure that we're unlocked here. If we aren't, * then html_css_fetcher_process() is broken. @@ -290,7 +293,7 @@ nserror html_css_fetcher_register(void) if (lwc_intern_string("x-ns-css", SLEN("x-ns-css"), &scheme) != lwc_error_ok) { - LOG("could not intern \"x-ns-css\"."); + NSLOG(netsurf, INFO, "could not intern \"x-ns-css\"."); return NSERROR_INIT_FAILED; } diff --git a/render/html_interaction.c b/render/html_interaction.c index 1ae9801c6..55da3cc03 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -289,7 +289,7 @@ html__image_coords_dom_user_data_handler(dom_node_operation operation, break; default: - LOG("User data operation not handled."); + NSLOG(netsurf, INFO, "User data operation not handled."); assert(0); } } diff --git a/render/html_object.c b/render/html_object.c index c86c57520..e98bdba0b 100644 --- a/render/html_object.c +++ b/render/html_object.c @@ -160,7 +160,7 @@ html_object_callback(hlcache_handle *object, case CONTENT_MSG_DONE: c->base.active--; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); html_object_done(box, object, o->background); @@ -191,7 +191,8 @@ html_object_callback(hlcache_handle *object, if (box != NULL) { c->base.active--; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", + c->base.active); content_add_error(&c->base, "?", 0); html_object_failed(box, c, o->background); @@ -503,7 +504,8 @@ static bool html_replace_object(struct content_html_object *object, nsurl *url) /* remove existing object */ if (content_get_status(object->content) != CONTENT_STATUS_DONE) { c->base.active--; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", + c->base.active); } hlcache_handle_release(object->content); @@ -524,7 +526,7 @@ static bool html_replace_object(struct content_html_object *object, nsurl *url) for (page = c; page != NULL; page = page->page) { page->base.active++; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); page->base.status = CONTENT_STATUS_READY; } @@ -607,7 +609,8 @@ nserror html_object_abort_objects(html_content *htmlc) object->content = NULL; if (object->box != NULL) { htmlc->base.active--; - LOG("%d fetches active", htmlc->base.active); + NSLOG(netsurf, INFO, "%d fetches active", + htmlc->base.active); } break; @@ -645,7 +648,7 @@ nserror html_object_free_objects(html_content *html) struct content_html_object *victim = html->object_list; if (victim->content != NULL) { - LOG("object %p", victim->content); + NSLOG(netsurf, INFO, "object %p", victim->content); if (content_get_type(victim->content) == CONTENT_HTML) { guit->misc->schedule(-1, html_object_refresh, victim); @@ -707,7 +710,7 @@ bool html_fetch_object(html_content *c, nsurl *url, struct box *box, c->num_objects++; if (box != NULL) { c->base.active++; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); } return true; diff --git a/render/html_script.c b/render/html_script.c index 6ed74c5c4..186e5203b 100644 --- a/render/html_script.c +++ b/render/html_script.c @@ -165,19 +165,22 @@ convert_script_async_cb(hlcache_handle *script, break; case CONTENT_MSG_DONE: - LOG("script %d done '%s'", i, nsurl_access(hlcache_handle_get_url(script))); + NSLOG(netsurf, INFO, "script %d done '%s'", i, + nsurl_access(hlcache_handle_get_url(script))); parent->base.active--; - LOG("%d fetches active", parent->base.active); + NSLOG(netsurf, INFO, "%d fetches active", parent->base.active); break; case CONTENT_MSG_ERROR: - LOG("script %s failed: %s", nsurl_access(hlcache_handle_get_url(script)), event->data.error); + NSLOG(netsurf, INFO, "script %s failed: %s", + nsurl_access(hlcache_handle_get_url(script)), + event->data.error); case CONTENT_MSG_ERRORCODE: hlcache_handle_release(script); s->data.handle = NULL; parent->base.active--; - LOG("%d fetches active", parent->base.active); + NSLOG(netsurf, INFO, "%d fetches active", parent->base.active); content_add_error(&parent->base, "?", 0); break; @@ -219,19 +222,22 @@ convert_script_defer_cb(hlcache_handle *script, switch (event->type) { case CONTENT_MSG_DONE: - LOG("script %d done '%s'", i, nsurl_access(hlcache_handle_get_url(script))); + NSLOG(netsurf, INFO, "script %d done '%s'", i, + nsurl_access(hlcache_handle_get_url(script))); parent->base.active--; - LOG("%d fetches active", parent->base.active); + NSLOG(netsurf, INFO, "%d fetches active", parent->base.active); break; case CONTENT_MSG_ERROR: - LOG("script %s failed: %s", nsurl_access(hlcache_handle_get_url(script)), event->data.error); + NSLOG(netsurf, INFO, "script %s failed: %s", + nsurl_access(hlcache_handle_get_url(script)), + event->data.error); case CONTENT_MSG_ERRORCODE: hlcache_handle_release(script); s->data.handle = NULL; parent->base.active--; - LOG("%d fetches active", parent->base.active); + NSLOG(netsurf, INFO, "%d fetches active", parent->base.active); content_add_error(&parent->base, "?", 0); break; @@ -274,9 +280,10 @@ convert_script_sync_cb(hlcache_handle *script, switch (event->type) { case CONTENT_MSG_DONE: - LOG("script %d done '%s'", i, nsurl_access(hlcache_handle_get_url(script))); + NSLOG(netsurf, INFO, "script %d done '%s'", i, + nsurl_access(hlcache_handle_get_url(script))); parent->base.active--; - LOG("%d fetches active", parent->base.active); + NSLOG(netsurf, INFO, "%d fetches active", parent->base.active); s->already_started = true; @@ -293,20 +300,22 @@ convert_script_sync_cb(hlcache_handle *script, /* continue parse */ err = dom_hubbub_parser_pause(parent->parser, false); if (err != DOM_HUBBUB_OK) { - LOG("unpause returned 0x%x", err); + NSLOG(netsurf, INFO, "unpause returned 0x%x", err); } break; case CONTENT_MSG_ERROR: - LOG("script %s failed: %s", nsurl_access(hlcache_handle_get_url(script)), event->data.error); + NSLOG(netsurf, INFO, "script %s failed: %s", + nsurl_access(hlcache_handle_get_url(script)), + event->data.error); case CONTENT_MSG_ERRORCODE: hlcache_handle_release(script); s->data.handle = NULL; parent->base.active--; - LOG("%d fetches active", parent->base.active); + NSLOG(netsurf, INFO, "%d fetches active", parent->base.active); content_add_error(&parent->base, "?", 0); s->already_started = true; @@ -314,7 +323,7 @@ convert_script_sync_cb(hlcache_handle *script, /* continue parse */ err = dom_hubbub_parser_pause(parent->parser, false); if (err != DOM_HUBBUB_OK) { - LOG("unpause returned 0x%x", err); + NSLOG(netsurf, INFO, "unpause returned 0x%x", err); } break; @@ -360,7 +369,8 @@ exec_src_script(html_content *c, return DOM_HUBBUB_NOMEM; } - LOG("script %i '%s'", c->scripts_count, nsurl_access(joined)); + NSLOG(netsurf, INFO, "script %i '%s'", c->scripts_count, + nsurl_access(joined)); /* there are three ways to process the script tag at this point: * @@ -438,11 +448,11 @@ exec_src_script(html_content *c, */ /* mark duff script fetch as already started */ nscript->already_started = true; - LOG("Fetch failed with error %d", ns_error); + NSLOG(netsurf, INFO, "Fetch failed with error %d", ns_error); } else { /* update base content active fetch count */ c->base.active++; - LOG("%d fetches active", c->base.active); + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); switch (script_type) { case HTML_SCRIPT_SYNC: @@ -525,14 +535,15 @@ html_process_script(void *ctx, dom_node *node) msg_data.jscontext = &c->jscontext; content_broadcast(&c->base, CONTENT_MSG_GETCTX, &msg_data); - LOG("javascript context %p ", c->jscontext); + NSLOG(netsurf, INFO, "javascript context %p ", c->jscontext); if (c->jscontext == NULL) { /* no context and it could not be created, abort */ return DOM_HUBBUB_OK; } } - LOG("content %p parser %p node %p", c, c->parser, node); + NSLOG(netsurf, INFO, "content %p parser %p node %p", c, c->parser, + node); exc = dom_element_get_attribute(node, corestring_dom_type, &mimetype); if (exc != DOM_NO_ERR || mimetype == NULL) { diff --git a/render/imagemap.c b/render/imagemap.c index 6e2504bdc..0d3b42a1b 100644 --- a/render/imagemap.c +++ b/render/imagemap.c @@ -241,21 +241,35 @@ void imagemap_dump(html_content *c) map = c->imagemaps[i]; while (map != NULL) { - LOG("Imagemap: %s", map->key); + NSLOG(netsurf, INFO, "Imagemap: %s", map->key); for (entry = map->list; entry; entry = entry->next) { switch (entry->type) { case IMAGEMAP_DEFAULT: - LOG("\tDefault: %s", nsurl_access(entry->url)); + NSLOG(netsurf, INFO, "\tDefault: %s", + nsurl_access(entry->url)); break; case IMAGEMAP_RECT: - LOG("\tRectangle: %s: [(%d,%d),(%d,%d)]", nsurl_access(entry->url), entry->bounds.rect.x0, entry->bounds.rect.y0, entry->bounds.rect.x1, entry->bounds.rect.y1); + NSLOG(netsurf, INFO, + "\tRectangle: %s: [(%d,%d),(%d,%d)]", + nsurl_access(entry->url), + entry->bounds.rect.x0, + entry->bounds.rect.y0, + entry->bounds.rect.x1, + entry->bounds.rect.y1); break; case IMAGEMAP_CIRCLE: - LOG("\tCircle: %s: [(%d,%d),%d]", nsurl_access(entry->url), entry->bounds.circle.x, entry->bounds.circle.y, entry->bounds.circle.r); + NSLOG(netsurf, INFO, + "\tCircle: %s: [(%d,%d),%d]", + nsurl_access(entry->url), + entry->bounds.circle.x, + entry->bounds.circle.y, + entry->bounds.circle.r); break; case IMAGEMAP_POLY: - LOG("\tPolygon: %s:", nsurl_access(entry->url)); + NSLOG(netsurf, INFO, + "\tPolygon: %s:", + nsurl_access(entry->url)); for (j = 0; j != entry->bounds.poly.num; j++) { fprintf(stderr, "(%d,%d) ", diff --git a/render/layout.c b/render/layout.c index 6782fdfc6..962b4d403 100644 --- a/render/layout.c +++ b/render/layout.c @@ -343,7 +343,7 @@ layout_minmax_line(struct box *first, b->type == BOX_INLINE_END); #ifdef LAYOUT_DEBUG - LOG("%p: min %i, max %i", b, min, max); + NSLOG(netsurf, INFO, "%p: min %i, max %i", b, min, max); #endif if (b->type == BOX_BR) { @@ -625,7 +625,7 @@ layout_minmax_line(struct box *first, *line_max = max; #ifdef LAYOUT_DEBUG - LOG("line_min %i, line_max %i", min, max); + NSLOG(netsurf, INFO, "line_min %i, line_max %i", min, max); #endif assert(b != first); @@ -1470,7 +1470,7 @@ find_sides(struct box *fl, int fy0, fy1, fx0, fx1; #ifdef LAYOUT_DEBUG - LOG("y0 %i, y1 %i, x0 %i, x1 %i", y0, y1, *x0, *x1); + NSLOG(netsurf, INFO, "y0 %i, y1 %i, x0 %i, x1 %i", y0, y1, *x0, *x1); #endif *left = *right = 0; @@ -1501,7 +1501,8 @@ find_sides(struct box *fl, } #ifdef LAYOUT_DEBUG - LOG("x0 %i, x1 %i, left %p, right %p", *x0, *x1, *left, *right); + NSLOG(netsurf, INFO, "x0 %i, x1 %i, left %p, right %p", *x0, *x1, + *left, *right); #endif } @@ -1965,13 +1966,17 @@ static bool layout_table(struct box *table, int available_width, /* calculate width required by cells */ for (i = 0; i != columns; i++) { #ifdef LAYOUT_DEBUG - LOG("table %p, column %u: type %s, width %i, min %i, max %i", table, i, ((const char *[]){ + NSLOG(netsurf, INFO, + "table %p, column %u: type %s, width %i, min %i, max %i", + table, + i, ((const char *[]){ "UNKNOWN", "FIXED", "AUTO", "PERCENT", - "RELATIVE" - })[col[i].type], col[i].width, col[i].min, col[i].max); + "RELATIVE", + })[col[i].type], col[i].width, col[i].min, + col[i].max); #endif if (col[i].positioned) { @@ -1991,14 +1996,16 @@ static bool layout_table(struct box *table, int available_width, required_width += col[i].min; #ifdef LAYOUT_DEBUG - LOG("required_width %i", required_width); + NSLOG(netsurf, INFO, "required_width %i", required_width); #endif } required_width += (columns + 1 - positioned_columns) * border_spacing_h; #ifdef LAYOUT_DEBUG - LOG("width %i, min %i, max %i, auto %i, required %i", table_width, table->min_width, table->max_width, auto_width, required_width); + NSLOG(netsurf, INFO, + "width %i, min %i, max %i, auto %i, required %i", table_width, + table->min_width, table->max_width, auto_width, required_width); #endif if (auto_width < required_width) { @@ -2449,7 +2456,8 @@ static bool layout_block_object(struct box *block) assert(block->object); #ifdef LAYOUT_DEBUG - LOG("block %p, object %s, width %i", block, hlcache_handle_get_url(block->object), block->width); + NSLOG(netsurf, INFO, "block %p, object %s, width %i", block, + hlcache_handle_get_url(block->object), block->width); #endif if (content_get_type(block->object) == CONTENT_HTML) { @@ -2747,7 +2755,7 @@ layout_block_context(struct box *block, } #ifdef LAYOUT_DEBUG - LOG("box %p, cx %i, cy %i", box, cx, cy); + NSLOG(netsurf, INFO, "box %p, cx %i, cy %i", box, cx, cy); #endif /* Layout (except tables). */ @@ -3625,7 +3633,8 @@ static void layout_compute_relative_offset(struct box *box, int *x, int *y) } #ifdef LAYOUT_DEBUG - LOG("left %i, right %i, top %i, bottom %i", left, right, top, bottom); + NSLOG(netsurf, INFO, "left %i, right %i, top %i, bottom %i", left, + right, top, bottom); #endif *x = left; @@ -3888,8 +3897,11 @@ layout_text_box_split(html_content *content, else c2->parent->last = c2; #ifdef LAYOUT_DEBUG - LOG("split_box %p len: %u \"%.*s\"", split_box, split_box->length, split_box->length, split_box->text); - LOG(" new_box %p len: %u \"%.*s\"", c2, c2->length, c2->length, c2->text); + NSLOG(netsurf, INFO, "split_box %p len: %u \"%.*s\"", + split_box, split_box->length, split_box->length, + split_box->text); + NSLOG(netsurf, INFO, " new_box %p len: %u \"%.*s\"", c2, + c2->length, c2->length, c2->text); #endif return true; } @@ -4080,7 +4092,8 @@ place_float_below(struct box *c, int width, int cx, int y, struct box *cont) y : cont->cached_place_below_level; #ifdef LAYOUT_DEBUG - LOG("c %p, width %i, cx %i, y %i, cont %p", c, width, cx, y, cont); + NSLOG(netsurf, INFO, "c %p, width %i, cx %i, y %i, cont %p", c, + width, cx, y, cont); #endif do { @@ -4159,7 +4172,15 @@ layout_line(struct box *first, plot_font_style_t fstyle; #ifdef LAYOUT_DEBUG - LOG("first %p, first->text '%.*s', width %i, y %i, cx %i, cy %i", first, (int)first->length, first->text, *width, *y, cx, cy); + NSLOG(netsurf, INFO, + "first %p, first->text '%.*s', width %i, y %i, cx %i, cy %i", + first, + (int)first->length, + first->text, + *width, + *y, + cx, + cy); #endif /* find sides at top of line */ @@ -4190,7 +4211,7 @@ layout_line(struct box *first, * body executed at least once * keep in sync with the loop in layout_minmax_line() */ #ifdef LAYOUT_DEBUG - LOG("x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); + NSLOG(netsurf, INFO, "x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); #endif for (x = 0, b = first; x <= x1 - x0 && b != 0; b = b->next) { @@ -4203,7 +4224,7 @@ layout_line(struct box *first, b->type == BOX_INLINE_END); #ifdef LAYOUT_DEBUG - LOG("pass 1: b %p, x %i", b, x); + NSLOG(netsurf, INFO, "pass 1: b %p, x %i", b, x); #endif if (b->type == BOX_BR) @@ -4414,12 +4435,12 @@ layout_line(struct box *first, /* pass 2: place boxes in line: loop body executed at least once */ #ifdef LAYOUT_DEBUG - LOG("x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); + NSLOG(netsurf, INFO, "x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); #endif for (x = x_previous = 0, b = first; x <= x1 - x0 && b; b = b->next) { #ifdef LAYOUT_DEBUG - LOG("pass 2: b %p, x %i", b, x); + NSLOG(netsurf, INFO, "pass 2: b %p, x %i", b, x); #endif if (b->type == BOX_INLINE_BLOCK && @@ -4489,7 +4510,7 @@ layout_line(struct box *first, } else { /* float */ #ifdef LAYOUT_DEBUG - LOG("float %p", b); + NSLOG(netsurf, INFO, "float %p", b); #endif d = b->children; @@ -4501,7 +4522,8 @@ layout_line(struct box *first, return false; #ifdef LAYOUT_DEBUG - LOG("%p : %d %d", d, d->margin[TOP], d->border[TOP].width); + NSLOG(netsurf, INFO, "%p : %d %d", d, d->margin[TOP], + d->border[TOP].width); #endif d->x = d->margin[LEFT] + d->border[LEFT].width; @@ -4654,7 +4676,7 @@ layout_line(struct box *first, } x += space_before + w; #ifdef LAYOUT_DEBUG - LOG("forcing"); + NSLOG(netsurf, INFO, "forcing"); #endif } else if ((split == 0 || x1 - x0 <= x + space_before + w) && inline_count == 1) { @@ -4664,11 +4686,16 @@ layout_line(struct box *first, used_height = 0; if (left) { #ifdef LAYOUT_DEBUG - LOG("cy %i, left->y %i, left->height %i", cy, left->y, left->height); + NSLOG(netsurf, INFO, + "cy %i, left->y %i, left->height %i", + cy, + left->y, + left->height); #endif used_height = left->y + left->height - cy + 1; #ifdef LAYOUT_DEBUG - LOG("used_height %i", used_height); + NSLOG(netsurf, INFO, "used_height %i", + used_height); #endif } if (right && used_height < @@ -4680,20 +4707,22 @@ layout_line(struct box *first, b = split_box; #ifdef LAYOUT_DEBUG - LOG("moving below float"); + NSLOG(netsurf, INFO, "moving below float"); #endif } else if (split == 0 || x1 - x0 <= x + space_before + w) { /* first word of box doesn't fit so leave box for next * line */ b = split_box; #ifdef LAYOUT_DEBUG - LOG("leaving for next line"); + NSLOG(netsurf, INFO, "leaving for next line"); #endif } else { /* fit as many words as possible */ assert(split != 0); #ifdef LAYOUT_DEBUG - LOG("'%.*s' %i %zu %i", (int)split_box->length, split_box->text, x1 - x0, split, w); + NSLOG(netsurf, INFO, "'%.*s' %i %zu %i", + (int)split_box->length, split_box->text, + x1 - x0, split, w); #endif if (split != split_box->length) { if (!layout_text_box_split(content, &fstyle, @@ -4703,7 +4732,7 @@ layout_line(struct box *first, } x += space_before + w; #ifdef LAYOUT_DEBUG - LOG("fitting words"); + NSLOG(netsurf, INFO, "fitting words"); #endif } move_y = true; @@ -4843,7 +4872,13 @@ bool layout_inline_container(struct box *inline_container, int width, assert(inline_container->type == BOX_INLINE_CONTAINER); #ifdef LAYOUT_DEBUG - LOG("inline_container %p, width %i, cont %p, cx %i, cy %i", inline_container, width, cont, cx, cy); + NSLOG(netsurf, INFO, + "inline_container %p, width %i, cont %p, cx %i, cy %i", + inline_container, + width, + cont, + cx, + cy); #endif has_text_children = false; @@ -4873,7 +4908,7 @@ bool layout_inline_container(struct box *inline_container, int width, */ for (c = inline_container->children; c; ) { #ifdef LAYOUT_DEBUG - LOG("c %p", c); + NSLOG(netsurf, INFO, "c %p", c); #endif curwidth = inline_container->width; if (!layout_line(c, &curwidth, &y, cx, cy + y, cont, first_line, diff --git a/render/table.c b/render/table.c index acf00c70e..3210fde2d 100644 --- a/render/table.c +++ b/render/table.c @@ -219,13 +219,14 @@ bool table_calculate_column_types(struct box *table) #ifdef TABLE_DEBUG for (i = 0; i != table->columns; i++) - LOG("table %p, column %u: type %s, width %i", table, i, ((const char *[]){ + NSLOG(netsurf, INFO, + "table %p, column %u: type %s, width %i", table, i, ((const char *[]){ "UNKNOWN", "FIXED", "AUTO", "PERCENT", - "RELATIVE" - })[col[i].type], col[i].width); + "RELATIVE", + })[col[i].type], col[i].width); #endif return true; diff --git a/render/textplain.c b/render/textplain.c index 2f2d757c8..ab2d55955 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -423,7 +423,7 @@ static void textplain_reformat(struct content *c, int width, int height) size_t line_start; nserror res; - LOG("content %p w:%d h:%d", c, width, height); + NSLOG(netsurf, INFO, "content %p w:%d h:%d", c, width, height); /* compute available columns (assuming monospaced font) - use 8 * characters for better accuracy @@ -522,7 +522,7 @@ static void textplain_reformat(struct content *c, int width, int height) return; no_memory: - LOG("out of memory (line_count %lu)", line_count); + NSLOG(netsurf, INFO, "out of memory (line_count %lu)", line_count); return; } diff --git a/test/urldbtest.c b/test/urldbtest.c index 75a7210b0..3cba8835f 100644 --- a/test/urldbtest.c +++ b/test/urldbtest.c @@ -143,7 +143,7 @@ static nsurl *make_url(const char *url) { nsurl *nsurl; if (nsurl_create(url, &nsurl) != NSERROR_OK) { - LOG("failed creating nsurl"); + NSLOG(netsurf, INFO, "failed creating nsurl"); exit(1); } return nsurl; @@ -229,9 +229,8 @@ static void urldb_lwc_iterator(lwc_string *str, void *pw) { int *scount = pw; - LOG("[%3u] %.*s", str->refcnt, - (int)lwc_string_length(str), - lwc_string_data(str)); + NSLOG(netsurf, INFO, "[%3u] %.*s", str->refcnt, + (int)lwc_string_length(str), lwc_string_data(str)); (*scount)++; } @@ -245,7 +244,7 @@ static void urldb_teardown(void) corestrings_fini(); - LOG("Remaining lwc strings:"); + NSLOG(netsurf, INFO, "Remaining lwc strings:"); lwc_iterate_strings(urldb_lwc_iterator, &scount); ck_assert_int_eq(scount, 0); } @@ -712,7 +711,7 @@ static int cb_count; static bool urldb_iterate_entries_cb(nsurl *url, const struct url_data *data) { - LOG("url: %s", nsurl_access(url)); + NSLOG(netsurf, INFO, "url: %s", nsurl_access(url)); /* fprintf(stderr, "url:%s\ntitle:%s\n\n",nsurl_access(url), data->title); */ cb_count++; return true; @@ -995,7 +994,7 @@ static TCase *urldb_case_create(void) static bool urldb_iterate_cookies_cb(const struct cookie_data *data) { - LOG("%p", data); + NSLOG(netsurf, INFO, "%p", data); /* fprintf(stderr, "domain:%s\npath:%s\nname:%s\n\n",data->domain, data->path, data->name);*/ return true; } diff --git a/utils/filename.c b/utils/filename.c index 9c95901a1..01a403fd9 100644 --- a/utils/filename.c +++ b/utils/filename.c @@ -84,7 +84,8 @@ const char *filename_request(void) /* no available slots - create a new directory */ dir = filename_create_directory(NULL); if (dir == NULL) { - LOG("Failed to create a new directory."); + NSLOG(netsurf, INFO, + "Failed to create a new directory."); return NULL; } i = 63; @@ -182,10 +183,12 @@ bool filename_initialise(void) for (start = directory; *start != '\0'; start++) { if (*start == '/') { *start = '\0'; - LOG("Creating \"%s\"", directory); + NSLOG(netsurf, INFO, "Creating \"%s\"", directory); ret = nsmkdir(directory, S_IRWXU); if (ret != 0 && errno != EEXIST) { - LOG("Failed to create directory \"%s\"", directory); + NSLOG(netsurf, INFO, + "Failed to create directory \"%s\"", + directory); free(directory); return false; } @@ -194,7 +197,7 @@ bool filename_initialise(void) } } - LOG("Temporary directory location: %s", directory); + NSLOG(netsurf, INFO, "Temporary directory location: %s", directory); ret = nsmkdir(directory, S_IRWXU); free(directory); @@ -280,7 +283,8 @@ bool filename_flush_directory(const char *folder, int depth) child[sizeof(child) - 1] = '\0'; if (stat(child, &statbuf) == -1) { - LOG("Unable to stat %s: %s", child, strerror(errno)); + NSLOG(netsurf, INFO, "Unable to stat %s: %s", child, + strerror(errno)); continue; } @@ -348,7 +352,8 @@ bool filename_flush_directory(const char *folder, int depth) filename_delete_recursive(child); if (remove(child)) - LOG("Failed to remove '%s'", child); + NSLOG(netsurf, INFO, "Failed to remove '%s'", + child); else changed = true; } else { @@ -387,7 +392,8 @@ bool filename_delete_recursive(char *folder) child[sizeof(child) - 1] = '\0'; if (stat(child, &statbuf) == -1) { - LOG("Unable to stat %s: %s", child, strerror(errno)); + NSLOG(netsurf, INFO, "Unable to stat %s: %s", child, + strerror(errno)); continue; } @@ -399,7 +405,7 @@ bool filename_delete_recursive(char *folder) } if (remove(child)) { - LOG("Failed to remove '%s'", child); + NSLOG(netsurf, INFO, "Failed to remove '%s'", child); closedir(parent); return false; } @@ -465,7 +471,7 @@ static struct directory *filename_create_directory(const char *prefix) /* allocate a new directory */ new_dir = malloc(sizeof(struct directory)); if (new_dir == NULL) { - LOG("No memory for malloc()"); + NSLOG(netsurf, INFO, "No memory for malloc()"); return NULL; } @@ -499,7 +505,9 @@ static struct directory *filename_create_directory(const char *prefix) * whilst we are running if there is an error, so we * don't report this yet and try to create the * structure normally. */ - LOG("Failed to create optimised structure '%s'", filename_directory); + NSLOG(netsurf, INFO, + "Failed to create optimised structure '%s'", + filename_directory); } } @@ -519,7 +527,9 @@ static struct directory *filename_create_directory(const char *prefix) if (!is_dir(filename_directory)) { if (nsmkdir(filename_directory, S_IRWXU)) { - LOG("Failed to create directory '%s'", filename_directory); + NSLOG(netsurf, INFO, + "Failed to create directory '%s'", + filename_directory); return NULL; } } diff --git a/utils/hashtable.c b/utils/hashtable.c index af100dfc9..3a1711da0 100644 --- a/utils/hashtable.c +++ b/utils/hashtable.c @@ -81,7 +81,7 @@ struct hash_table *hash_create(unsigned int chains) struct hash_table *r = malloc(sizeof(struct hash_table)); if (r == NULL) { - LOG("Not enough memory for hash table."); + NSLOG(netsurf, INFO, "Not enough memory for hash table."); return NULL; } @@ -89,7 +89,8 @@ struct hash_table *hash_create(unsigned int chains) r->chain = calloc(chains, sizeof(struct hash_entry *)); if (r->chain == NULL) { - LOG("Not enough memory for %d hash table chains.", chains); + NSLOG(netsurf, INFO, + "Not enough memory for %d hash table chains.", chains); free(r); return NULL; } @@ -134,7 +135,7 @@ bool hash_add(struct hash_table *ht, const char *key, const char *value) e = malloc(sizeof(struct hash_entry)); if (e == NULL) { - LOG("Not enough memory for hash entry."); + NSLOG(netsurf, INFO, "Not enough memory for hash entry."); return false; } @@ -144,7 +145,8 @@ bool hash_add(struct hash_table *ht, const char *key, const char *value) v = strlen(value) ; e->pairing = malloc(v + e->key_length + 2); if (e->pairing == NULL) { - LOG("Not enough memory for string duplication."); + NSLOG(netsurf, INFO, + "Not enough memory for string duplication."); free(e); return false; } diff --git a/utils/idna.c b/utils/idna.c index 34cc40f83..572882ecb 100644 --- a/utils/idna.c +++ b/utils/idna.c @@ -63,17 +63,17 @@ static nserror punycode_status_to_nserror(enum punycode_status status) break; case punycode_bad_input: - LOG("Bad input"); + NSLOG(netsurf, INFO, "Bad input"); ret = NSERROR_BAD_ENCODING; break; case punycode_big_output: - LOG("Output too big"); + NSLOG(netsurf, INFO, "Output too big"); ret = NSERROR_BAD_SIZE; break; case punycode_overflow: - LOG("Overflow"); + NSLOG(netsurf, INFO, "Overflow"); ret = NSERROR_NOSPACE; break; @@ -437,7 +437,8 @@ static bool idna__is_valid(int32_t *label, size_t len) /* 2. Check characters 3 and 4 are not '--'. */ if ((label[2] == 0x002d) && (label[3] == 0x002d)) { - LOG("Check failed: characters 2 and 3 are '--'"); + NSLOG(netsurf, INFO, + "Check failed: characters 2 and 3 are '--'"); return false; } @@ -447,7 +448,8 @@ static bool idna__is_valid(int32_t *label, size_t len) if ((unicode_props->category == UTF8PROC_CATEGORY_MN) || (unicode_props->category == UTF8PROC_CATEGORY_MC) || (unicode_props->category == UTF8PROC_CATEGORY_ME)) { - LOG("Check failed: character 0 is a combining mark"); + NSLOG(netsurf, INFO, + "Check failed: character 0 is a combining mark"); return false; } @@ -456,14 +458,20 @@ static bool idna__is_valid(int32_t *label, size_t len) /* 4. Check characters not DISALLOWED by RFC5892 */ if (idna_prop == IDNA_P_DISALLOWED) { - LOG("Check failed: character %" PRIsizet " (%x) is DISALLOWED", i, label[i]); + NSLOG(netsurf, INFO, + "Check failed: character %"PRIsizet" (%x) is DISALLOWED", + i, + label[i]); return false; } /* 5. Check CONTEXTJ characters conform to defined rules */ if (idna_prop == IDNA_P_CONTEXTJ) { if (idna__contextj_rule(label, i, len) == false) { - LOG("Check failed: character %" PRIsizet " (%x) does not conform to CONTEXTJ rule", i, label[i]); + NSLOG(netsurf, INFO, + "Check failed: character %"PRIsizet" (%x) does not conform to CONTEXTJ rule", + i, + label[i]); return false; } } @@ -472,14 +480,20 @@ static bool idna__is_valid(int32_t *label, size_t len) /** \todo optionally we can check conformance to this rule */ if (idna_prop == IDNA_P_CONTEXTO) { if (idna__contexto_rule(label[i]) == false) { - LOG("Check failed: character %" PRIsizet " (%x) has no CONTEXTO rule defined", i, label[i]); + NSLOG(netsurf, INFO, + "Check failed: character %"PRIsizet" (%x) has no CONTEXTO rule defined", + i, + label[i]); return false; } } /* 7. Check characters are not UNASSIGNED */ if (idna_prop == IDNA_P_UNASSIGNED) { - LOG("Check failed: character %" PRIsizet " (%x) is UNASSIGNED", i, label[i]); + NSLOG(netsurf, INFO, + "Check failed: character %"PRIsizet" (%x) is UNASSIGNED", + i, + label[i]); return false; } @@ -588,7 +602,8 @@ static bool idna__verify(const char *label, size_t len) return true; } - LOG("Re-encoded ACE label %s does not match input", ace); + NSLOG(netsurf, INFO, "Re-encoded ACE label %s does not match input", + ace); free(ace); return false; @@ -641,7 +656,8 @@ idna_encode(const char *host, size_t len, char **ace_host, size_t *ace_len) /* This is already a DNS-valid ASCII string */ if ((idna__is_ace(host, label_len) == true) && (idna__verify(host, label_len) == false)) { - LOG("Cannot verify ACE label %s", host); + NSLOG(netsurf, INFO, + "Cannot verify ACE label %s", host); return NSERROR_BAD_URL; } strncpy(fqdn_p, host, label_len); diff --git a/utils/messages.c b/utils/messages.c index be53eccd0..e2d45e9da 100644 --- a/utils/messages.c +++ b/utils/messages.c @@ -74,7 +74,8 @@ message_process_line(struct hash_table *hash, uint8_t *ln, int lnlen) value = colon + 1; if (hash_add(hash, (char *)ln, (char *)value) == false) { - LOG("Unable to add %s:%s to hash table", ln, value); + NSLOG(netsurf, INFO, "Unable to add %s:%s to hash table", ln, + value); return NSERROR_INVALID; } return NSERROR_OK; @@ -97,7 +98,9 @@ static nserror messages_load_ctx(const char *path, struct hash_table **ctx) fp = gzopen(path, "r"); if (!fp) { - LOG("Unable to open messages file \"%.100s\": %s", path, strerror(errno)); + NSLOG(netsurf, INFO, + "Unable to open messages file \"%.100s\": %s", path, + strerror(errno)); return NSERROR_NOT_FOUND; } @@ -112,7 +115,9 @@ static nserror messages_load_ctx(const char *path, struct hash_table **ctx) nctx = *ctx; } if (nctx == NULL) { - LOG("Unable to create hash table for messages file %s", path); + NSLOG(netsurf, INFO, + "Unable to create hash table for messages file %s", + path); gzclose(fp); return NSERROR_NOMEM; } @@ -131,7 +136,9 @@ static nserror messages_load_ctx(const char *path, struct hash_table **ctx) value = colon + 1; if (hash_add(nctx, s, value) == false) { - LOG("Unable to add %s:%s to hash table of %s", s, value, path); + NSLOG(netsurf, INFO, + "Unable to add %s:%s to hash table of %s", s, + value, path); gzclose(fp); if (*ctx == NULL) { hash_destroy(nctx); @@ -202,7 +209,7 @@ nserror messages_add_from_file(const char *path) return NSERROR_BAD_PARAMETER; } - LOG("Loading Messages from '%s'", path); + NSLOG(netsurf, INFO, "Loading Messages from '%s'", path); err = messages_load_ctx(path, &messages_hash); @@ -225,7 +232,7 @@ nserror messages_add_from_inline(const uint8_t *data, size_t data_size) messages_hash = hash_create(HASH_SIZE); } if (messages_hash == NULL) { - LOG("Unable to create hash table"); + NSLOG(netsurf, INFO, "Unable to create hash table"); return NSERROR_NOMEM; } @@ -238,7 +245,7 @@ nserror messages_add_from_inline(const uint8_t *data, size_t data_size) ret = inflateInit2(&strm, 32 + MAX_WBITS); if (ret != Z_OK) { - LOG("inflateInit returned %d", ret); + NSLOG(netsurf, INFO, "inflateInit returned %d", ret); return NSERROR_INVALID; } @@ -271,7 +278,7 @@ nserror messages_add_from_inline(const uint8_t *data, size_t data_size) } if (used == sizeof(s)) { /* entire buffer used and no newline */ - LOG("Overlength line"); + NSLOG(netsurf, INFO, "Overlength line"); used = 0; } } while (ret != Z_STREAM_END); @@ -279,7 +286,7 @@ nserror messages_add_from_inline(const uint8_t *data, size_t data_size) inflateEnd(&strm); if (ret != Z_STREAM_END) { - LOG("inflate returned %d", ret); + NSLOG(netsurf, INFO, "inflate returned %d", ret); return NSERROR_INVALID; } return NSERROR_OK; diff --git a/utils/nsoption.c b/utils/nsoption.c index 8f05a911b..15f89ca5d 100644 --- a/utils/nsoption.c +++ b/utils/nsoption.c @@ -648,11 +648,12 @@ nsoption_read(const char *path, struct nsoption_s *opts) fp = fopen(path, "r"); if (!fp) { - LOG("Failed to open file '%s'", path); + NSLOG(netsurf, INFO, "Failed to open file '%s'", path); return NSERROR_NOT_FOUND; } - LOG("Successfully opened '%s' for Options file", path); + NSLOG(netsurf, INFO, "Successfully opened '%s' for Options file", + path); while (fgets(s, NSOPTION_MAX_LINE_LEN, fp)) { char *colon, *value; @@ -718,7 +719,8 @@ nsoption_write(const char *path, fp = fopen(path, "w"); if (!fp) { - LOG("failed to open file '%s' for writing", path); + NSLOG(netsurf, INFO, "failed to open file '%s' for writing", + path); return NSERROR_NOT_FOUND; } @@ -798,7 +800,7 @@ nsoption_commandline(int *pargc, char **argv, struct nsoption_s *opts) /* arg+arglen is the option to set, val is the value */ - LOG("%.*s = %s", arglen, arg, val); + NSLOG(netsurf, INFO, "%.*s = %s", arglen, arg, val); for (entry_loop = 0; entry_loop < NSOPTION_LISTEND; diff --git a/utils/nsurl/nsurl.c b/utils/nsurl/nsurl.c index 7166a2707..3b0af9328 100644 --- a/utils/nsurl/nsurl.c +++ b/utils/nsurl/nsurl.c @@ -230,7 +230,8 @@ lwc_string *nsurl_get_component(const nsurl *url, nsurl_component part) lwc_string_ref(url->components.fragment) : NULL; default: - LOG("Unsupported value passed to part param."); + NSLOG(netsurf, INFO, + "Unsupported value passed to part param."); assert(0); } @@ -296,7 +297,8 @@ bool nsurl_has_component(const nsurl *url, nsurl_component part) return false; default: - LOG("Unsupported value passed to part param."); + NSLOG(netsurf, INFO, + "Unsupported value passed to part param."); assert(0); } diff --git a/utils/nsurl/parse.c b/utils/nsurl/parse.c index 7474a612d..ce6f4435d 100644 --- a/utils/nsurl/parse.c +++ b/utils/nsurl/parse.c @@ -451,19 +451,19 @@ static void nsurl__get_string_markers(const char * const url_s, } #ifdef NSURL_DEBUG - LOG("marker.start: %i", marker.start); - LOG("marker.scheme_end: %i", marker.scheme_end); - LOG("marker.authority: %i", marker.authority); + NSLOG(netsurf, INFO, "marker.start: %i", marker.start); + NSLOG(netsurf, INFO, "marker.scheme_end: %i", marker.scheme_end); + NSLOG(netsurf, INFO, "marker.authority: %i", marker.authority); - LOG("marker.colon_first: %i", marker.colon_first); - LOG("marker.at: %i", marker.at); - LOG("marker.colon_last: %i", marker.colon_last); + NSLOG(netsurf, INFO, "marker.colon_first: %i", marker.colon_first); + NSLOG(netsurf, INFO, "marker.at: %i", marker.at); + NSLOG(netsurf, INFO, "marker.colon_last: %i", marker.colon_last); - LOG("marker.path: %i", marker.path); - LOG("marker.query: %i", marker.query); - LOG("marker.fragment: %i", marker.fragment); + NSLOG(netsurf, INFO, "marker.path: %i", marker.path); + NSLOG(netsurf, INFO, "marker.query: %i", marker.query); + NSLOG(netsurf, INFO, "marker.fragment: %i", marker.fragment); - LOG("marker.end: %i", marker.end); + NSLOG(netsurf, INFO, "marker.end: %i", marker.end); #endif /* Got all the URL components pegged out now */ @@ -485,8 +485,8 @@ static size_t nsurl__remove_dot_segments(char *path, char *output) while (*path_pos != '\0') { #ifdef NSURL_DEBUG - LOG(" in:%s", path_pos); - LOG("out:%.*s", output_pos - output, output); + NSLOG(netsurf, INFO, " in:%s", path_pos); + NSLOG(netsurf, INFO, "out:%.*s", output_pos - output, output); #endif if (*path_pos == '.') { if (*(path_pos + 1) == '.' && @@ -1324,7 +1324,8 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) assert(rel != NULL); #ifdef NSURL_DEBUG - LOG("base: \"%s\", rel: \"%s\"", nsurl_access(base), rel); + NSLOG(netsurf, INFO, "base: \"%s\", rel: \"%s\"", nsurl_access(base), + rel); #endif /* Peg out the URL sections */ diff --git a/utils/useragent.c b/utils/useragent.c index 72e45aada..b528dce4f 100644 --- a/utils/useragent.c +++ b/utils/useragent.c @@ -65,7 +65,8 @@ user_agent_build_string(void) core_user_agent_string = ua_string; - LOG("Built user agent \"%s\"", core_user_agent_string); + NSLOG(netsurf, INFO, "Built user agent \"%s\"", + core_user_agent_string); } /* This is a function so that later we can override it trivially */ diff --git a/utils/utf8.c b/utils/utf8.c index 5c930cd13..f0ac0c9b2 100644 --- a/utils/utf8.c +++ b/utils/utf8.c @@ -468,7 +468,8 @@ bool utf8_save_text(const char *utf8_text, const char *path) ret = guit->utf8->utf8_to_local(utf8_text, strlen(utf8_text), &conv); if (ret != NSERROR_OK) { - LOG("failed to convert to local encoding, return %d", ret); + NSLOG(netsurf, INFO, + "failed to convert to local encoding, return %d", ret); return false; } @@ -476,7 +477,7 @@ bool utf8_save_text(const char *utf8_text, const char *path) if (out) { int res = fputs(conv, out); if (res < 0) { - LOG("Warning: writing data failed"); + NSLOG(netsurf, INFO, "Warning: writing data failed"); } res = fputs("\n", out); -- cgit v1.2.1 From 9e81082355a54daf468589f5c4f351d869ec5a21 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 6 Sep 2017 18:27:19 +0100 Subject: Use coccinelle to change logging macro calls in c++ for F in $(git ls-files '*.cpp');do spatch --c++ --sp-file foo.cocci --in-place ${F};done @@ expression E; @@ -LOG(E); +NSLOG(netsurf, INFO, E); @@ expression E, E1; @@ -LOG(E, E1); +NSLOG(netsurf, INFO, E, E1); @@ expression E, E1, E2; @@ -LOG(E, E1, E2); +NSLOG(netsurf, INFO, E, E1, E2); @@ expression E, E1, E2, E3; @@ -LOG(E, E1, E2, E3); +NSLOG(netsurf, INFO, E, E1, E2, E3); @@ expression E, E1, E2, E3, E4; @@ -LOG(E, E1, E2, E3, E4); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4); @@ expression E, E1, E2, E3, E4, E5; @@ -LOG(E, E1, E2, E3, E4, E5); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5); @@ expression E, E1, E2, E3, E4, E5, E6; @@ -LOG(E, E1, E2, E3, E4, E5, E6); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6); @@ expression E, E1, E2, E3, E4, E5, E6, E7; @@ -LOG(E, E1, E2, E3, E4, E5, E6, E7); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7); --- frontends/beos/bitmap.cpp | 7 ++++--- frontends/beos/fetch_rsrc.cpp | 22 +++++++++++++++------- frontends/beos/gui.cpp | 21 +++++++++++---------- frontends/beos/plotters.cpp | 4 ++-- frontends/beos/scaffolding.cpp | 16 ++++++++++------ frontends/beos/schedule.cpp | 16 ++++++++++------ frontends/beos/throbber.cpp | 16 +++++++++++----- frontends/beos/window.cpp | 23 ++++++++++++++--------- 8 files changed, 77 insertions(+), 48 deletions(-) diff --git a/frontends/beos/bitmap.cpp b/frontends/beos/bitmap.cpp index 68d8442ab..c4b008755 100644 --- a/frontends/beos/bitmap.cpp +++ b/frontends/beos/bitmap.cpp @@ -377,7 +377,7 @@ nsbeos_bitmap_get_pretile_x(struct bitmap* bitmap) if (!bitmap->pretile_x) { int width = bitmap->primary->Bounds().Width() + 1; int xmult = (MIN_PRETILE_WIDTH + width - 1)/width; - LOG("Pretiling %p for X*%d", bitmap, xmult); + NSLOG(netsurf, INFO, "Pretiling %p for X*%d", bitmap, xmult); bitmap->pretile_x = nsbeos_bitmap_generate_pretile(bitmap->primary, xmult, 1); } return bitmap->pretile_x; @@ -396,7 +396,7 @@ nsbeos_bitmap_get_pretile_y(struct bitmap* bitmap) if (!bitmap->pretile_y) { int height = bitmap->primary->Bounds().Height() + 1; int ymult = (MIN_PRETILE_HEIGHT + height - 1)/height; - LOG("Pretiling %p for Y*%d", bitmap, ymult); + NSLOG(netsurf, INFO, "Pretiling %p for Y*%d", bitmap, ymult); bitmap->pretile_y = nsbeos_bitmap_generate_pretile(bitmap->primary, 1, ymult); } return bitmap->pretile_y; @@ -416,7 +416,8 @@ nsbeos_bitmap_get_pretile_xy(struct bitmap* bitmap) int height = bitmap->primary->Bounds().Height() + 1; int xmult = (MIN_PRETILE_WIDTH + width - 1)/width; int ymult = (MIN_PRETILE_HEIGHT + height - 1)/height; - LOG("Pretiling %p for X*%d Y*%d", bitmap, xmult, ymult); + NSLOG(netsurf, INFO, "Pretiling %p for X*%d Y*%d", bitmap, + xmult, ymult); bitmap->pretile_xy = nsbeos_bitmap_generate_pretile(bitmap->primary, xmult, ymult); } return bitmap->pretile_xy; diff --git a/frontends/beos/fetch_rsrc.cpp b/frontends/beos/fetch_rsrc.cpp index e77f4c96e..ae3648354 100644 --- a/frontends/beos/fetch_rsrc.cpp +++ b/frontends/beos/fetch_rsrc.cpp @@ -71,13 +71,15 @@ BResources *gAppResources = NULL; static bool fetch_rsrc_initialise(lwc_string *scheme) { - LOG("fetch_rsrc_initialise called for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "fetch_rsrc_initialise called for %s", + lwc_string_data(scheme)); return true; } static void fetch_rsrc_finalise(lwc_string *scheme) { - LOG("fetch_rsrc_finalise called for %s", lwc_string_data(scheme)); + NSLOG(netsurf, INFO, "fetch_rsrc_finalise called for %s", + lwc_string_data(scheme)); } static bool fetch_rsrc_can_fetch(const nsurl *url) @@ -162,7 +164,7 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c) * rsrc://[TYPE][@NUM]/name[,mime] */ - LOG("*** Processing %s", c->url); + NSLOG(netsurf, INFO, "*** Processing %s", c->url); if (strlen(c->url) < 7) { /* 7 is the minimum possible length (rsrc://) */ @@ -199,11 +201,13 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c) uint8 c1, c2, c3, c4; if (sscanf(params, "%c%c%c%c", &c1, &c2, &c3, &c4) > 3) { type = c1 << 24 | c2 << 16 | c3 << 8 | c4; - LOG("fetch_rsrc: type:%4.4s\n", (char *)&type); + NSLOG(netsurf, INFO, "fetch_rsrc: type:%4.4s\n", + (char *)&type); } } - LOG("fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name); + NSLOG(netsurf, INFO, "fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, + c->name); bool found; if (id) @@ -278,7 +282,10 @@ static void fetch_rsrc_poll(lwc_string *scheme) char header[64]; fetch_set_http_code(c->parent_fetch, 200); - LOG("setting rsrc: MIME type to %s, length to %zd", c->mimetype, c->datalen); + NSLOG(netsurf, INFO, + "setting rsrc: MIME type to %s, length to %zd", + c->mimetype, + c->datalen); /* Any callback can result in the fetch being aborted. * Therefore, we _must_ check for this after _every_ * call to fetch_rsrc_send_callback(). @@ -308,7 +315,8 @@ static void fetch_rsrc_poll(lwc_string *scheme) fetch_rsrc_send_callback(&msg, c); } } else { - LOG("Processing of %s failed!", c->url); + NSLOG(netsurf, INFO, "Processing of %s failed!", + c->url); /* Ensure that we're unlocked here. If we aren't, * then fetch_rsrc_process() is broken. diff --git a/frontends/beos/gui.cpp b/frontends/beos/gui.cpp index d3321b58d..f2c991777 100644 --- a/frontends/beos/gui.cpp +++ b/frontends/beos/gui.cpp @@ -112,7 +112,7 @@ static int sEventPipe[2]; /* exported function defined in beos/gui.h */ nserror beos_warn_user(const char *warning, const char *detail) { - LOG("warn_user: %s (%s)", warning, detail); + NSLOG(netsurf, INFO, "warn_user: %s (%s)", warning, detail); BAlert *alert; BString text(warning); if (detail) @@ -354,14 +354,15 @@ static void check_homedir(void) if (err < B_OK) { /* we really can't continue without a home directory. */ - LOG("Can't find user settings directory - nowhere to store state!"); + NSLOG(netsurf, INFO, + "Can't find user settings directory - nowhere to store state!"); die("NetSurf needs to find the user settings directory in order to run.\n"); } path.Append("NetSurf"); err = create_directory(path.Path(), 0644); if (err < B_OK) { - LOG("Unable to create %s", path.Path()); + NSLOG(netsurf, INFO, "Unable to create %s", path.Path()); die("NetSurf could not create its settings directory.\n"); } } @@ -387,7 +388,7 @@ static nsurl *gui_get_resource_url(const char *path) path = "favicon.png"; u << path; - LOG("(%s) -> '%s'\n", path, u.String()); + NSLOG(netsurf, INFO, "(%s) -> '%s'\n", path, u.String()); nsurl_create(u.String(), &url); return url; } @@ -588,7 +589,7 @@ static void gui_init(int argc, char** argv) die("Unable to load throbber image.\n"); find_resource(buf, "Choices", "%/Choices"); - LOG("Using '%s' as Preferences file", buf); + NSLOG(netsurf, INFO, "Using '%s' as Preferences file", buf); options_file_location = strdup(buf); nsoption_read(buf, NULL); @@ -631,12 +632,12 @@ static void gui_init(int argc, char** argv) if (nsoption_charp(cookie_file) == NULL) { find_resource(buf, "Cookies", "%/Cookies"); - LOG("Using '%s' as Cookies file", buf); + NSLOG(netsurf, INFO, "Using '%s' as Cookies file", buf); nsoption_set_charp(cookie_file, strdup(buf)); } if (nsoption_charp(cookie_jar) == NULL) { find_resource(buf, "Cookies", "%/Cookies"); - LOG("Using '%s' as Cookie Jar file", buf); + NSLOG(netsurf, INFO, "Using '%s' as Cookie Jar file", buf); nsoption_set_charp(cookie_jar, strdup(buf)); } if ((nsoption_charp(cookie_file) == NULL) || @@ -645,13 +646,13 @@ static void gui_init(int argc, char** argv) if (nsoption_charp(url_file) == NULL) { find_resource(buf, "URLs", "%/URLs"); - LOG("Using '%s' as URL file", buf); + NSLOG(netsurf, INFO, "Using '%s' as URL file", buf); nsoption_set_charp(url_file, strdup(buf)); } if (nsoption_charp(ca_path) == NULL) { find_resource(buf, "certs", "/etc/ssl/certs"); - LOG("Using '%s' as certificate path", buf); + NSLOG(netsurf, INFO, "Using '%s' as certificate path", buf); nsoption_set_charp(ca_path, strdup(buf)); } @@ -1038,7 +1039,7 @@ int main(int argc, char** argv) char path[12]; sprintf(path,"%.2s/Messages", getenv("LC_MESSAGES")); - LOG("Loading messages from resource %s\n", path); + NSLOG(netsurf, INFO, "Loading messages from resource %s\n", path); const uint8_t* res = (const uint8_t*)resources.LoadResource('data', path, &size); if (size > 0 && res != NULL) { diff --git a/frontends/beos/plotters.cpp b/frontends/beos/plotters.cpp index c77e6353e..c4903e045 100644 --- a/frontends/beos/plotters.cpp +++ b/frontends/beos/plotters.cpp @@ -538,7 +538,7 @@ nsbeos_plot_path(const struct redraw_context *ctx, } if (p[0] != PLOTTER_PATH_MOVE) { - LOG("path doesn't start with a move"); + NSLOG(netsurf, INFO, "path doesn't start with a move"); return NSERROR_INVALID; } @@ -563,7 +563,7 @@ nsbeos_plot_path(const struct redraw_context *ctx, shape.BezierTo(pt); i += 7; } else { - LOG("bad path command %f", p[i]); + NSLOG(netsurf, INFO, "bad path command %f", p[i]); return NSERROR_INVALID; } } diff --git a/frontends/beos/scaffolding.cpp b/frontends/beos/scaffolding.cpp index 7efdb5962..e6fb6e5a1 100644 --- a/frontends/beos/scaffolding.cpp +++ b/frontends/beos/scaffolding.cpp @@ -796,7 +796,7 @@ int32 nsbeos_replicant_main_thread(void *_arg) static void nsbeos_window_destroy_event(NSBrowserWindow *window, nsbeos_scaffolding *g, BMessage *event) { - LOG("Being Destroyed = %d", g->being_destroyed); + NSLOG(netsurf, INFO, "Being Destroyed = %d", g->being_destroyed); if (--open_windows == 0) nsbeos_done = true; @@ -854,7 +854,9 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m bw = nsbeos_get_browser_for_gui(scaffold->top_level); bool reloadAll = false; - LOG("nsbeos_scaffolding_dispatch_event() what = 0x%08lx", message->what); + NSLOG(netsurf, INFO, + "nsbeos_scaffolding_dispatch_event() what = 0x%08lx", + message->what); switch (message->what) { case B_QUIT_REQUESTED: nsbeos_scaffolding_destroy(scaffold); @@ -997,7 +999,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m browser_window_key_press(bw, NS_KEY_PASTE); break; case B_SELECT_ALL: - LOG("Selecting all text"); + NSLOG(netsurf, INFO, "Selecting all text"); browser_window_key_press(bw, NS_KEY_SELECT_ALL); break; case B_NETPOSITIVE_BACK: @@ -1359,7 +1361,8 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m void nsbeos_scaffolding_destroy(nsbeos_scaffolding *scaffold) { - LOG("Being Destroyed = %d", scaffold->being_destroyed); + NSLOG(netsurf, INFO, "Being Destroyed = %d", + scaffold->being_destroyed); if (scaffold->being_destroyed) return; scaffold->being_destroyed = 1; nsbeos_window_destroy_event(scaffold->window, scaffold, NULL); @@ -1444,7 +1447,7 @@ static void recursively_set_menu_items_target(BMenu *menu, BHandler *handler) void nsbeos_attach_toplevel_view(nsbeos_scaffolding *g, BView *view) { - LOG("Attaching view to scaffolding %p", g); + NSLOG(netsurf, INFO, "Attaching view to scaffolding %p", g); // this is a replicant,... and it went bad if (!g->window) { @@ -1722,7 +1725,8 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel) { struct beos_scaffolding *g = (struct beos_scaffolding *)malloc(sizeof(*g)); - LOG("Constructing a scaffold of %p for gui_window %p", g, toplevel); + NSLOG(netsurf, INFO, + "Constructing a scaffold of %p for gui_window %p", g, toplevel); g->top_level = toplevel; g->being_destroyed = 0; diff --git a/frontends/beos/schedule.cpp b/frontends/beos/schedule.cpp index e96e56d81..552a7cd49 100644 --- a/frontends/beos/schedule.cpp +++ b/frontends/beos/schedule.cpp @@ -58,7 +58,8 @@ nsbeos_schedule_kill_callback(void *_target, void *_match) _nsbeos_callback_t *match = (_nsbeos_callback_t *)_match; if ((target->callback == match->callback) && (target->context == match->context)) { - LOG("Found match for %p(%p), killing.", target->callback, target->context); + NSLOG(netsurf, INFO, "Found match for %p(%p), killing.", + target->callback, target->context); target->callback = NULL; target->context = NULL; target->callback_killed = true; @@ -69,7 +70,8 @@ nsbeos_schedule_kill_callback(void *_target, void *_match) static void schedule_remove(void (*callback)(void *p), void *p) { - LOG("schedule_remove() for %p(%p)", cb->callback, cb->context); + NSLOG(netsurf, INFO, "schedule_remove() for %p(%p)", cb->callback, + cb->context); if (callbacks == NULL) return; _nsbeos_callback_t cb_match; @@ -81,7 +83,7 @@ schedule_remove(void (*callback)(void *p), void *p) nserror beos_schedule(int t, void (*callback)(void *p), void *p) { - LOG("t:%d cb:%p p:%p", t, cb->callback, cb->context); + NSLOG(netsurf, INFO, "t:%d cb:%p p:%p", t, cb->callback, cb->context); if (callbacks == NULL) { callbacks = new BList; @@ -111,7 +113,7 @@ nserror beos_schedule(int t, void (*callback)(void *p), void *p) bool schedule_run(void) { - LOG("schedule_run()"); + NSLOG(netsurf, INFO, "schedule_run()"); earliest_callback_timeout = B_INFINITE_TIMEOUT; if (callbacks == NULL) @@ -120,7 +122,8 @@ schedule_run(void) bigtime_t now = system_time(); int32 i; - LOG("Checking %ld callbacks to for deadline.", this_run->CountItems()); + NSLOG(netsurf, INFO, "Checking %ld callbacks to for deadline.", + this_run->CountItems()); /* Run all the callbacks which made it this far. */ for (i = 0; i < callbacks->CountItems(); ) { @@ -132,7 +135,8 @@ schedule_run(void) i++; continue; } - LOG("Running callbacks %p(%p).", cb->callback, cb->context); + NSLOG(netsurf, INFO, "Running callbacks %p(%p).", + cb->callback, cb->context); if (!cb->callback_killed) cb->callback(cb->context); callbacks->RemoveItem(cb); diff --git a/frontends/beos/throbber.cpp b/frontends/beos/throbber.cpp index fe40b3edc..27ed42352 100644 --- a/frontends/beos/throbber.cpp +++ b/frontends/beos/throbber.cpp @@ -50,14 +50,17 @@ bool nsbeos_throbber_initialise_from_png(const int frames, ...) if (frames < 2) { /* we need at least two frames - one for idle, one for active */ - LOG("Insufficent number of frames in throbber animation!"); - LOG("(called with %d frames, where 2 is a minimum.)", frames); + NSLOG(netsurf, INFO, + "Insufficent number of frames in throbber animation!"); + NSLOG(netsurf, INFO, + "(called with %d frames, where 2 is a minimum.)", + frames); return false; } BResources *res = get_app_resources(); if (res == NULL) { - LOG("Can't find resources for throbber!"); + NSLOG(netsurf, INFO, "Can't find resources for throbber!"); return false; } @@ -74,14 +77,17 @@ bool nsbeos_throbber_initialise_from_png(const int frames, ...) data = res->LoadResource('data', fn, &size); throb->framedata[i] = NULL; if (!data) { - LOG("Error when loading resource %s", fn); + NSLOG(netsurf, INFO, "Error when loading resource %s", + fn); errors_when_loading = true; continue; } BMemoryIO mem(data, size); throb->framedata[i] = BTranslationUtils::GetBitmap(&mem); if (throb->framedata[i] == NULL) { - LOG("Error when loading %s: GetBitmap() returned NULL", fn); + NSLOG(netsurf, INFO, + "Error when loading %s: GetBitmap() returned NULL", + fn); errors_when_loading = true; } } diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp index fde818df2..c6e2aadfc 100644 --- a/frontends/beos/window.cpp +++ b/frontends/beos/window.cpp @@ -354,7 +354,8 @@ static struct gui_window *gui_window_create(struct browser_window *bw, return 0; } - LOG("Creating gui window %p for browser window %p", g, bw); + NSLOG(netsurf, INFO, "Creating gui window %p for browser window %p", + g, bw); g->bw = bw; g->mouse.state = 0; @@ -436,19 +437,21 @@ void nsbeos_dispatch_event(BMessage *message) continue; if (gui && gui != z) { - LOG("discarding event for destroyed gui_window"); + NSLOG(netsurf, INFO, + "discarding event for destroyed gui_window"); delete message; return; } if (scaffold && (!y || scaffold != y->scaffold)) { - LOG("discarding event for destroyed scaffolding"); + NSLOG(netsurf, INFO, + "discarding event for destroyed scaffolding"); delete message; return; } // messages for top-level if (scaffold) { - LOG("dispatching to top-level"); + NSLOG(netsurf, INFO, "dispatching to top-level"); nsbeos_scaffolding_dispatch_event(scaffold, message); delete message; return; @@ -763,7 +766,8 @@ void nsbeos_window_keypress_event(BView *view, gui_window *g, BMessage *event) if (!numbytes) numbytes = strlen(bytes); - LOG("mods 0x%08lx key %ld raw %ld byte[0] %d", mods, key, raw_char, buff[0]); + NSLOG(netsurf, INFO, "mods 0x%08lx key %ld raw %ld byte[0] %d", mods, + key, raw_char, buff[0]); char byte; if (numbytes == 1) { @@ -930,10 +934,10 @@ static void gui_window_destroy(struct gui_window *g) g->next->prev = g->prev; - LOG("Destroying gui_window %p", g); + NSLOG(netsurf, INFO, "Destroying gui_window %p", g); assert(g != NULL); assert(g->bw != NULL); - LOG(" Scaffolding: %p", g->scaffold); + NSLOG(netsurf, INFO, " Scaffolding: %p", g->scaffold); if (g->view == NULL) return; @@ -1090,8 +1094,9 @@ static void gui_window_update_extent(struct gui_window *g) x_max -= g->view->Bounds().Width() + 1; y_max -= g->view->Bounds().Height() + 1; - LOG("x_max = %d y_max = %d x_prop = %f y_prop = %f\n", - x_max, y_max, x_prop, y_prop); + NSLOG(netsurf, INFO, + "x_max = %d y_max = %d x_prop = %f y_prop = %f\n", x_max, + y_max, x_prop, y_prop); if (g->view->ScrollBar(B_HORIZONTAL)) { g->view->ScrollBar(B_HORIZONTAL)->SetRange(0, x_max); -- cgit v1.2.1 From 63f5ba6f62eb3f506d06d16f29e18c49338a1128 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 3 Sep 2017 23:19:11 +0100 Subject: update bindings with logging changes --- content/handlers/javascript/duktape/Console.bnd | 2 +- content/handlers/javascript/duktape/Document.bnd | 19 +++++++++++-------- content/handlers/javascript/duktape/Element.bnd | 2 +- content/handlers/javascript/duktape/EventTarget.bnd | 3 ++- content/handlers/javascript/duktape/Location.bnd | 8 ++++---- content/handlers/javascript/duktape/Window.bnd | 7 ++++--- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/content/handlers/javascript/duktape/Console.bnd b/content/handlers/javascript/duktape/Console.bnd index 7b4de1ee3..c4c0c8399 100644 --- a/content/handlers/javascript/duktape/Console.bnd +++ b/content/handlers/javascript/duktape/Console.bnd @@ -34,7 +34,7 @@ write_log_entry(duk_context *ctx, unsigned int group, char logtype) /* spcs... pfx strs... */ duk_concat(ctx, duk_get_top(ctx)); /* str */ - LOG("%s", duk_safe_to_string(ctx, 0)); + NSLOG(netsurf, INFO, "%s", duk_safe_to_string(ctx, 0)); } %}; diff --git a/content/handlers/javascript/duktape/Document.bnd b/content/handlers/javascript/duktape/Document.bnd index 8658aec45..ece417d0d 100644 --- a/content/handlers/javascript/duktape/Document.bnd +++ b/content/handlers/javascript/duktape/Document.bnd @@ -41,11 +41,12 @@ method Document::write() corestring_dom___ns_key_html_content_data, &htmlc); if ((err != DOM_NO_ERR) || (htmlc == NULL)) { - LOG("error getting htmlc. parent node:%p htmlc:%p", - priv->parent.node, htmlc); + NSLOG(netsurf, INFO, + "error getting htmlc. parent node:%p htmlc:%p", + priv->parent.node, htmlc); return 0; } else if (htmlc->parser == NULL) { - LOG("error; no parser for htmlc: %p", htmlc); + NSLOG(netsurf, INFO, "error; no parser for htmlc: %p", htmlc); return 0; } @@ -74,11 +75,12 @@ method Document::writeln() corestring_dom___ns_key_html_content_data, &htmlc); if ((err != DOM_NO_ERR) || (htmlc == NULL)) { - LOG("error getting htmlc. parent node:%p htmlc:%p", - priv->parent.node, htmlc); + NSLOG(netsurf, INFO, + "error getting htmlc. parent node:%p htmlc:%p", + priv->parent.node, htmlc); return 0; } else if (htmlc->parser == NULL) { - LOG("error; no parser for htmlc: %p", htmlc); + NSLOG(netsurf, INFO, "error; no parser for htmlc: %p", htmlc); return 0; } @@ -311,8 +313,9 @@ getter Document::cookie() return 1; } } else { - LOG("error getting htmlc. parent node:%p htmlc:%p", - priv->parent.node, htmlc); + NSLOG(netsurf, INFO, + "error getting htmlc. parent node:%p htmlc:%p", + priv->parent.node, htmlc); } return 0; %} diff --git a/content/handlers/javascript/duktape/Element.bnd b/content/handlers/javascript/duktape/Element.bnd index d34e8c1eb..f7e33545f 100644 --- a/content/handlers/javascript/duktape/Element.bnd +++ b/content/handlers/javascript/duktape/Element.bnd @@ -183,7 +183,7 @@ getter Element::childElementCount() element = NULL; } } - LOG("I found %u of them", jsret); + NSLOG(netsurf, INFO, "I found %u of them", jsret); duk_push_uint(ctx, jsret); return 1; %} diff --git a/content/handlers/javascript/duktape/EventTarget.bnd b/content/handlers/javascript/duktape/EventTarget.bnd index 92e2ac83e..d1f9e50d7 100644 --- a/content/handlers/javascript/duktape/EventTarget.bnd +++ b/content/handlers/javascript/duktape/EventTarget.bnd @@ -173,7 +173,8 @@ method EventTarget::addEventListener() exc = dom_string_create((const uint8_t*)ev_ty, ev_ty_l, &ev_ty_s); if (exc != DOM_NO_ERR) { - LOG("Oh dear, failed to create dom_string in addEventListener()"); + NSLOG(netsurf, INFO, + "Oh dear, failed to create dom_string in addEventListener()"); return 0; } dukky_register_event_listener_for( diff --git a/content/handlers/javascript/duktape/Location.bnd b/content/handlers/javascript/duktape/Location.bnd index ca7e90509..a731730de 100644 --- a/content/handlers/javascript/duktape/Location.bnd +++ b/content/handlers/javascript/duktape/Location.bnd @@ -40,7 +40,7 @@ method Location::reload() if (priv_win->win != NULL) { browser_window_reload(priv_win->win, false); } else { - LOG("failed to get browser context"); + NSLOG(netsurf, INFO, "failed to get browser context"); } return 0; %} @@ -54,7 +54,7 @@ method Location::assign() duk_pop(ctx); if (priv_win == NULL || priv_win->win == NULL) { - LOG("failed to get browser context"); + NSLOG(netsurf, INFO, "failed to get browser context"); return 0; } @@ -83,7 +83,7 @@ method Location::replace() duk_pop(ctx); if (priv_win == NULL || priv_win->win == NULL) { - LOG("failed to get browser context"); + NSLOG(netsurf, INFO, "failed to get browser context"); return 0; } @@ -131,7 +131,7 @@ setter Location::href() duk_pop(ctx); if (priv_win == NULL || priv_win->win == NULL) { - LOG("failed to get browser context"); + NSLOG(netsurf, INFO, "failed to get browser context"); return 0; } diff --git a/content/handlers/javascript/duktape/Window.bnd b/content/handlers/javascript/duktape/Window.bnd index 4af8c7aa9..3f680d47d 100644 --- a/content/handlers/javascript/duktape/Window.bnd +++ b/content/handlers/javascript/duktape/Window.bnd @@ -25,9 +25,10 @@ init Window(struct browser_window *win, struct html_content *htmlc) /* element window */ priv->win = win; priv->htmlc = htmlc; - LOG("win=%p htmlc=%p", priv->win, priv->htmlc); + NSLOG(netsurf, INFO, "win=%p htmlc=%p", priv->win, priv->htmlc); - LOG("URL is %s", nsurl_access(browser_window_get_url(priv->win))); + NSLOG(netsurf, INFO, + "URL is %s", nsurl_access(browser_window_get_url(priv->win))); %} prototype Window() @@ -138,6 +139,6 @@ method Window::alert() %{ duk_size_t msg_len; const char *msg = duk_safe_to_lstring(ctx, 0, &msg_len); - LOG("JS ALERT: %*s", (int)msg_len, msg); + NSLOG(netsurf, INFO, "JS ALERT: %*s", (int)msg_len, msg); return 0; %} -- cgit v1.2.1 From 72e6050eb3ae7c9e7a96936f2949bae7ef8ca4be Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 4 Sep 2017 14:31:12 +0100 Subject: add low level cache category and use it --- content/llcache.c | 145 ++++++++++++++++++++++++++---------------------------- utils/log.c | 11 ++--- utils/log.h | 4 +- 3 files changed, 75 insertions(+), 85 deletions(-) diff --git a/content/llcache.c b/content/llcache.c index b81aba84f..50e6188f4 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -52,16 +52,6 @@ #include "content/backing_store.h" #include "content/urldb.h" -/** Define to enable tracing of llcache operations. */ -#undef LLCACHE_TRACE -//#define LLCACHE_TRACE 1 - -#ifdef LLCACHE_TRACE -#define LLCACHE_LOG(x...) LOG(x) -#else -#define LLCACHE_LOG(x...) ((void) 0) -#endif - /** * State of a low-level cache object fetch. */ @@ -316,7 +306,8 @@ static nserror llcache_object_user_new(llcache_handle_callback cb, void *pw, u->handle = h; - LLCACHE_LOG("Created user %p (%p, %p, %p)", u, h, (void *) cb, pw); + NSLOG(llcache, DEBUG, + "Created user %p (%p, %p, %p)", u, h, (void *) cb, pw); *user = u; @@ -333,7 +324,7 @@ static nserror llcache_object_user_new(llcache_handle_callback cb, void *pw, */ static nserror llcache_object_user_destroy(llcache_object_user *user) { - LLCACHE_LOG("Destroyed user %p", user); + NSLOG(llcache, DEBUG, "Destroyed user %p", user); assert(user->next == NULL); assert(user->prev == NULL); @@ -377,7 +368,7 @@ static nserror llcache_object_remove_user(llcache_object *object, object->last_used = time(NULL); } - LLCACHE_LOG("Removing user %p from %p", user, object); + NSLOG(llcache, DEBUG, "Removing user %p from %p", user, object); return NSERROR_OK; } @@ -433,7 +424,7 @@ static nserror llcache_object_new(nsurl *url, llcache_object **result) if (obj == NULL) return NSERROR_NOMEM; - LLCACHE_LOG("Created object %p (%s)", obj, nsurl_access(url)); + NSLOG(llcache, DEBUG, "Created object %p (%s)", obj, nsurl_access(url)); obj->url = nsurl_ref(url); @@ -874,7 +865,7 @@ static nserror llcache_object_refetch(llcache_object *object) /* Reset fetch state */ object->fetch.state = LLCACHE_FETCH_INIT; - LLCACHE_LOG("Re-fetching %p", object); + NSLOG(llcache, DEBUG, "Re-fetching %p", object); /* Kick off fetch */ res = fetch_start(object->url, @@ -921,7 +912,7 @@ static nserror llcache_object_fetch(llcache_object *object, uint32_t flags, nsurl *referer_clone = NULL; llcache_post_data *post_clone = NULL; - LLCACHE_LOG("Starting fetch for %p", object); + NSLOG(llcache, DEBUG, "Starting fetch for %p", object); if (post != NULL) { error = llcache_post_data_clone(post, &post_clone); @@ -955,8 +946,8 @@ static nserror llcache_object_destroy(llcache_object *object) { size_t i; - LLCACHE_LOG("Destroying object %p, %s", object, - nsurl_access(object->url)); + NSLOG(llcache, DEBUG, "Destroying object %p, %s", object, + nsurl_access(object->url)); if (object->source_data != NULL) { if (object->store_state == LLCACHE_STATE_DISC) { @@ -1038,16 +1029,17 @@ llcache_object_rfc2616_remaining_lifetime(const llcache_cache_control *cd) current_age += cd->res_time - cd->req_time + now - cd->res_time; /* Determine freshness lifetime of this object */ - if (cd->max_age != INVALID_AGE) + if (cd->max_age != INVALID_AGE) { freshness_lifetime = cd->max_age; - else if (cd->expires != 0) + } else if (cd->expires != 0) { freshness_lifetime = cd->expires - cd->date; - else if (cd->last_modified != 0) + } else if (cd->last_modified != 0) { freshness_lifetime = (now - cd->last_modified) / 10; - else + } else { freshness_lifetime = 0; + } - /* LLCACHE_LOG("%d:%d", freshness_lifetime, current_age); */ + NSLOG(llcache, DEBUG, "%d:%d", freshness_lifetime, current_age); if ((cd->no_cache == LLCACHE_VALIDATE_FRESH) && (freshness_lifetime > current_age)) { @@ -1076,7 +1068,7 @@ static bool llcache_object_is_fresh(const llcache_object *object) remaining_lifetime = llcache_object_rfc2616_remaining_lifetime(cd); - LLCACHE_LOG("%p: (%d > 0 || %d != %d)", object, + NSLOG(llcache, DEBUG, "%p: (%d > 0 || %d != %d)", object, remaining_lifetime, object->fetch.state, LLCACHE_FETCH_COMPLETE); @@ -1322,7 +1314,7 @@ llcache_serialise_metadata(llcache_object *object, datasize -= use; } - LLCACHE_LOG("Filled buffer with %d spare", datasize); + NSLOG(llcache, DEBUG, "Filled buffer with %d spare", datasize); *data_out = data; *datasize_out = allocsize - datasize; @@ -1331,13 +1323,13 @@ llcache_serialise_metadata(llcache_object *object, overflow: /* somehow we overflowed the buffer - hth? */ - NSLOG(netsurf, INFO, "Overflowed metadata buffer"); + NSLOG(llcache, INFO, "Overflowed metadata buffer"); free(data); return NSERROR_INVALID; operror: /* output error */ - NSLOG(netsurf, INFO, "Output error"); + NSLOG(llcache, INFO, "Output error"); free(data); return NSERROR_INVALID; } @@ -1374,7 +1366,7 @@ llcache_process_metadata(llcache_object *object) size_t num_headers; size_t hloop; - NSLOG(netsurf, INFO, "Retrieving metadata"); + NSLOG(llcache, INFO, "Retrieving metadata"); /* attempt to retrieve object metadata from the backing store */ res = guit->llcache->fetch(object->url, @@ -1385,7 +1377,7 @@ llcache_process_metadata(llcache_object *object) return res; } - NSLOG(netsurf, INFO, "Processing retrieved data"); + NSLOG(llcache, INFO, "Processing retrieved data"); /* metadata line 1 is the url the metadata referrs to */ line = 1; @@ -1408,7 +1400,7 @@ llcache_process_metadata(llcache_object *object) * by simply skipping caching of this object. */ - NSLOG(netsurf, INFO, "Got metadata for %s instead of %s", + NSLOG(llcache, INFO, "Got metadata for %s instead of %s", nsurl_access(metadataurl), nsurl_access(object->url)); nsurl_unref(metadataurl); @@ -1502,7 +1494,8 @@ llcache_process_metadata(llcache_object *object) return NSERROR_OK; format_error: - NSLOG(netsurf, INFO, "metadata error on line %d error code %d\n", + NSLOG(llcache, INFO, + "metadata error on line %d error code %d\n", line, res); guit->llcache->release(object->url, BACKING_STORE_META); @@ -1585,7 +1578,7 @@ llcache_object_retrieve_from_cache(nsurl *url, nserror error; llcache_object *obj, *newest = NULL; - LLCACHE_LOG("Searching cache for %s flags:%x referer:%s post:%p", + NSLOG(llcache, DEBUG, "Searching cache for %s flags:%x referer:%s post:%p", nsurl_access(url), flags, referer==NULL?"":nsurl_access(referer), post); @@ -1604,7 +1597,7 @@ llcache_object_retrieve_from_cache(nsurl *url, * pull from persistent store. */ if (newest == NULL) { - LLCACHE_LOG("No viable object found in llcache"); + NSLOG(llcache, DEBUG, "No viable object found in llcache"); error = llcache_object_new(url, &obj); if (error != NSERROR_OK) @@ -1613,7 +1606,7 @@ llcache_object_retrieve_from_cache(nsurl *url, /* attempt to retrieve object from persistent store */ error = llcache_object_fetch_persistant(obj, flags, referer, post, redirect_count); if (error == NSERROR_OK) { - LLCACHE_LOG("retrieved object from persistent store"); + NSLOG(llcache, DEBUG, "retrieved object from persistent store"); /* set newest object from persistent store which * will cause the normal object handling to be used. @@ -1631,7 +1624,7 @@ llcache_object_retrieve_from_cache(nsurl *url, if ((newest != NULL) && (llcache_object_is_fresh(newest))) { /* Found a suitable object, and it's still fresh */ - LLCACHE_LOG("Found fresh %p", newest); + NSLOG(llcache, DEBUG, "Found fresh %p", newest); /* The client needs to catch up with the object's state. * This will occur the next time that llcache_poll is called. @@ -1652,7 +1645,7 @@ llcache_object_retrieve_from_cache(nsurl *url, * failed, destroy cache object and fall though to * cache miss to re-fetch */ - LLCACHE_LOG("Persistent retrieval failed for %p", newest); + NSLOG(llcache, DEBUG, "Persistent retrieval failed for %p", newest); llcache_object_remove_from_list(newest, &llcache->cached_objects); llcache_object_destroy(newest); @@ -1673,7 +1666,7 @@ llcache_object_retrieve_from_cache(nsurl *url, if (error != NSERROR_OK) return error; - LLCACHE_LOG("Found candidate %p (%p)", obj, newest); + NSLOG(llcache, DEBUG, "Found candidate %p (%p)", obj, newest); /* Clone candidate's cache data */ error = llcache_object_clone_cache_data(newest, obj, true); @@ -1703,7 +1696,7 @@ llcache_object_retrieve_from_cache(nsurl *url, return NSERROR_OK; } - LLCACHE_LOG("Persistent retrieval failed for %p", newest); + NSLOG(llcache, DEBUG, "Persistent retrieval failed for %p", newest); /* retrieval of source data from persistent store * failed, destroy cache object and fall though to @@ -1758,7 +1751,7 @@ llcache_object_retrieve(nsurl *url, nsurl *defragmented_url; bool uncachable = false; - LLCACHE_LOG("Retrieve %s (%x, %s, %p)", nsurl_access(url), flags, + NSLOG(llcache, DEBUG, "Retrieve %s (%x, %s, %p)", nsurl_access(url), flags, referer==NULL?"":nsurl_access(referer), post); @@ -1825,7 +1818,7 @@ llcache_object_retrieve(nsurl *url, /* Returned object is already in the cached list */ } - LLCACHE_LOG("Retrieved %p", obj); + NSLOG(llcache, DEBUG, "Retrieved %p", obj); *result = obj; @@ -1858,7 +1851,7 @@ static nserror llcache_object_add_user(llcache_object *object, object->users->prev = user; object->users = user; - LLCACHE_LOG("Adding user %p to %p", user, object); + NSLOG(llcache, DEBUG, "Adding user %p to %p", user, object); return NSERROR_OK; } @@ -1899,7 +1892,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, /* Forcibly stop redirecting if we've followed too many redirects */ #define REDIRECT_LIMIT 10 if (object->fetch.redirect_count > REDIRECT_LIMIT) { - NSLOG(netsurf, INFO, "Too many nested redirects"); + NSLOG(llcache, INFO, "Too many nested redirects"); event.type = LLCACHE_EVENT_ERROR; event.data.msg = messages_get("BadRedirect"); @@ -2494,7 +2487,7 @@ static void llcache_persist_slowcheck(void *p) total_bandwidth = (llcache->total_written * 1000) / llcache->total_elapsed; if (total_bandwidth < llcache->minimum_bandwidth) { - NSLOG(netsurf, INFO, + NSLOG(llcache, INFO, "Current bandwidth %"PRIu64" less than minimum %"PRIsizet, total_bandwidth, llcache->minimum_bandwidth); @@ -2527,7 +2520,7 @@ static void llcache_persist(void *p) ret = build_candidate_list(&lst, &lst_count); if (ret != NSERROR_OK) { - LLCACHE_LOG("Unable to construct candidate list for persistent writeout"); + NSLOG(llcache, DEBUG, "Unable to construct candidate list for persistent writeout"); return; } @@ -2545,7 +2538,7 @@ static void llcache_persist(void *p) total_elapsed += elapsed; total_bandwidth = (total_written * 1000) / total_elapsed; - LLCACHE_LOG("Wrote %zd bytes in %lums bw:%lu %s", + NSLOG(llcache, DEBUG, "Wrote %zd bytes in %lums bw:%lu %s", written, elapsed, (written * 1000) / elapsed, nsurl_access(lst[idx]->url) ); @@ -2553,7 +2546,7 @@ static void llcache_persist(void *p) * (bandwidth) for this run being exceeded. */ if (total_elapsed > llcache->time_quantum) { - NSLOG(netsurf, INFO, "Overran timeslot"); + NSLOG(llcache, INFO, "Overran timeslot"); /* writeout has exhausted the available time. * Either the writeout is slow or the last * object was very large. @@ -2612,10 +2605,10 @@ static void llcache_persist(void *p) llcache->total_written += total_written; llcache->total_elapsed += total_elapsed; - LLCACHE_LOG("writeout size:%zd time:%lu bandwidth:%lubytes/s", + NSLOG(llcache, DEBUG, "writeout size:%zd time:%lu bandwidth:%lubytes/s", total_written, total_elapsed, total_bandwidth); - LLCACHE_LOG("Rescheduling writeout in %dms", next); + NSLOG(llcache, DEBUG, "Rescheduling writeout in %dms", next); guit->misc->schedule(next, llcache_persist, NULL); } @@ -2632,7 +2625,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p) llcache_object *object = p; llcache_event event; - LLCACHE_LOG("Fetch event %d for %p", msg->type, object); + NSLOG(llcache, DEBUG, "Fetch event %d for %p", msg->type, object); switch (msg->type) { case FETCH_HEADER: @@ -2856,10 +2849,7 @@ static nserror llcache_object_notify_users(llcache_object *object) nserror error; llcache_object_user *user, *next_user; llcache_event event; - -#ifdef LLCACHE_TRACE bool emitted_notify = false; -#endif /** * State transitions and event emission for users. @@ -2920,19 +2910,20 @@ static nserror llcache_object_notify_users(llcache_object *object) * continue is used) */ -#ifdef LLCACHE_TRACE if (handle->state != objstate) { if (emitted_notify == false) { - NSLOG(netsurf, INFO, "Notifying users of %p", + NSLOG(llcache, DEBUG, + "Notifying users of %p", object); emitted_notify = true; } - NSLOG(netsurf, INFO, - "User %p state: %d Object state: %d", user, - handle->state, objstate); + NSLOG(llcache, DEBUG, + "User %p state: %d Object state: %d", + user, + handle->state, + objstate); } -#endif /* User: INIT, Obj: HEADERS, DATA, COMPLETE => User->HEADERS */ if (handle->state == LLCACHE_FETCH_INIT && @@ -3189,7 +3180,7 @@ void llcache_clean(bool purge) int remaining_lifetime; uint32_t limit; - LLCACHE_LOG("Attempting cache clean"); + NSLOG(llcache, DEBUG, "Attempting cache clean"); /* If the cache is being purged set the size limit to zero. */ if (purge) { @@ -3209,7 +3200,7 @@ void llcache_clean(bool purge) (object->candidate_count == 0) && (object->fetch.fetch == NULL) && (object->fetch.outstanding_query == false)) { - LLCACHE_LOG("Discarding uncachable object with no users (%p) %s", + NSLOG(llcache, DEBUG, "Discarding uncachable object with no users (%p) %s", object, nsurl_access(object->url)); llcache_object_remove_from_list(object, @@ -3236,7 +3227,7 @@ void llcache_clean(bool purge) (object->fetch.outstanding_query == false) && (remaining_lifetime <= 0)) { /* object is stale */ - LLCACHE_LOG("discarding stale cacheable object with no " + NSLOG(llcache, DEBUG, "discarding stale cacheable object with no " "users or pending fetches (%p) %s", object, nsurl_access(object->url)); @@ -3282,7 +3273,7 @@ void llcache_clean(bool purge) llcache_size -= object->source_len; - LLCACHE_LOG("Freeing source data for %p len:%zd", + NSLOG(llcache, DEBUG, "Freeing source data for %p len:%zd", object, object->source_len); } @@ -3302,12 +3293,12 @@ void llcache_clean(bool purge) (object->fetch.outstanding_query == false) && (object->store_state == LLCACHE_STATE_DISC) && (object->source_data == NULL)) { - LLCACHE_LOG("discarding backed object len:%zd " - "age:%d (%p) %s", - object->source_len, - time(NULL) - object->last_used, - object, - nsurl_access(object->url)); + NSLOG(llcache, DEBUG, + "discarding backed object len:%zd age:%ld (%p) %s", + object->source_len, + time(NULL) - object->last_used, + object, + nsurl_access(object->url)); llcache_size -= total_object_size(object); @@ -3333,11 +3324,12 @@ void llcache_clean(bool purge) (object->fetch.fetch == NULL) && (object->fetch.outstanding_query == false) && (object->store_state == LLCACHE_STATE_RAM)) { - LLCACHE_LOG("discarding fresh object len:%zd age:%d (%p) %s", - object->source_len, - time(NULL) - object->last_used, - object, - nsurl_access(object->url)); + NSLOG(llcache, DEBUG, + "discarding fresh object len:%zd age:%ld (%p) %s", + object->source_len, + time(NULL) - object->last_used, + object, + nsurl_access(object->url)); llcache_size -= object->source_len + sizeof(*object); @@ -3347,7 +3339,7 @@ void llcache_clean(bool purge) } } - LLCACHE_LOG("Size: %u (limit: %u)", llcache_size, limit); + NSLOG(llcache, DEBUG, "Size: %u (limit: %u)", llcache_size, limit); } /* Exported interface documented in content/llcache.h */ @@ -3369,7 +3361,8 @@ llcache_initialise(const struct llcache_parameters *prm) llcache->fetch_attempts = prm->fetch_attempts; llcache->all_caught_up = true; - NSLOG(netsurf, INFO, "llcache initialising with a limit of %d bytes", + NSLOG(llcache, INFO, + "llcache initialising with a limit of %d bytes", llcache->limit); /* backing store initialisation */ @@ -3433,7 +3426,7 @@ void llcache_finalise(void) llcache->total_elapsed; } - NSLOG(netsurf, INFO, + NSLOG(llcache, INFO, "Backing store wrote %"PRIu64" bytes in %"PRIu64" ms ""(average %"PRIu64" bytes/second)", llcache->total_written, llcache->total_elapsed, diff --git a/utils/log.c b/utils/log.c index 2f0d3b3bf..834a3e933 100644 --- a/utils/log.c +++ b/utils/log.c @@ -1,9 +1,5 @@ /* - * Copyright 2007 Rob Kendrick - * Copyright 2004-2007 James Bursa - * Copyright 2003 Phil Mellor - * Copyright 2003 John M Bell - * Copyright 2004 John Tytgat + * Copyright 2017 Vincent Sanders * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -36,8 +32,6 @@ bool verbose_log = false; /** The stream to which logging is sent */ static FILE *logfile; -NSLOG_DEFINE_CATEGORY(netsurf, "NetSurf default logging"); - /** Subtract the `struct timeval' values X and Y * * \param result The timeval structure to store the result in @@ -97,6 +91,9 @@ static const char *nslog_gettime(void) #ifdef WITH_NSLOG +NSLOG_DEFINE_CATEGORY(netsurf, "NetSurf default logging"); +NSLOG_DEFINE_CATEGORY(llcache, "Low level cache"); + static void netsurf_render_log(void *_ctx, nslog_entry_context_t *ctx, diff --git a/utils/log.h b/utils/log.h index 0e73f4d37..50ceac0b1 100644 --- a/utils/log.h +++ b/utils/log.h @@ -43,6 +43,7 @@ typedef bool(nslog_ensure_t)(FILE *fptr); */ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv); +/* ensure a logging level is defined */ #ifndef NETSURF_LOG_LEVEL #define NETSURF_LOG_LEVEL INFO #endif @@ -56,6 +57,7 @@ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv); #include NSLOG_DECLARE_CATEGORY(netsurf); +NSLOG_DECLARE_CATEGORY(llcache); #else /* WITH_NSLOG */ @@ -89,8 +91,6 @@ extern void nslog_log(const char *file, const char *func, int ln, const char *fo } \ } while(0) -#define NSLOG_DEFINE_CATEGORY(catname, description) - #endif /* WITH_NSLOG */ #endif -- cgit v1.2.1 From 71225624f6f227f479a423f93d966ac0480de042 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 5 Sep 2017 14:08:48 +0100 Subject: update fetch debug logging to use catagory --- content/fetch.c | 80 ++++++++++++++++++++++++++++----------------------------- utils/log.c | 1 + utils/log.h | 1 + 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/content/fetch.c b/content/fetch.c index fc72d13f9..766502941 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -60,16 +60,6 @@ #include "javascript/fetcher.h" #include "content/urldb.h" -/* Define this to turn on verbose fetch logging */ -#undef DEBUG_FETCH_VERBOSE - -/** Verbose fetcher logging */ -#ifdef DEBUG_FETCH_VERBOSE -#define FETCH_LOG(x...) LOG(x...) -#else -#define FETCH_LOG(x...) -#endif - /** The maximum number of fetchers that can be added */ #define MAX_FETCHERS 10 @@ -158,8 +148,10 @@ static int get_fetcher_for_scheme(lwc_string *scheme) static bool fetch_dispatch_job(struct fetch *fetch) { RING_REMOVE(queue_ring, fetch); - FETCH_LOG("Attempting to start fetch %p, fetcher %p, url %s", fetch, - fetch->fetcher_handle, nsurl_access(fetch->url)); + NSLOG(fetch, DEBUG, + "Attempting to start fetch %p, fetcher %p, url %s", fetch, + fetch->fetcher_handle, + nsurl_access(fetch->url)); if (!fetchers[fetch->fetcherd].ops.start(fetch->fetcher_handle)) { RING_INSERT(queue_ring, fetch); /* Put it back on the end of the queue */ @@ -210,14 +202,13 @@ static bool fetch_choose_and_dispatch(void) static void dump_rings(void) { -#ifdef DEBUG_FETCH_VERBOSE struct fetch *q; struct fetch *f; q = queue_ring; if (q) { do { - NSLOG(netsurf, INFO, "queue_ring: %s", + NSLOG(fetch, DEBUG, "queue_ring: %s", nsurl_access(q->url)); q = q->r_next; } while (q != queue_ring); @@ -225,12 +216,11 @@ static void dump_rings(void) f = fetch_ring; if (f) { do { - NSLOG(netsurf, INFO, "fetch_ring: %s", + NSLOG(fetch, DEBUG, "fetch_ring: %s", nsurl_access(f->url)); f = f->r_next; } while (f != fetch_ring); } -#endif } /** @@ -246,7 +236,10 @@ static bool fetch_dispatch_jobs(void) RING_GETSIZE(struct fetch, queue_ring, all_queued); RING_GETSIZE(struct fetch, fetch_ring, all_active); - FETCH_LOG("queue_ring %i, fetch_ring %i", all_queued, all_active); + NSLOG(fetch, DEBUG, + "queue_ring %i, fetch_ring %i", + all_queued, + all_active); dump_rings(); while ((all_queued != 0) && @@ -254,12 +247,14 @@ static bool fetch_dispatch_jobs(void) fetch_choose_and_dispatch()) { all_queued--; all_active++; - FETCH_LOG("%d queued, %d fetching", - all_queued, all_active); + NSLOG(fetch, DEBUG, + "%d queued, %d fetching", + all_queued, + all_active); } - FETCH_LOG("Fetch ring is now %d elements.", all_active); - FETCH_LOG("Queue ring is now %d elements.", all_queued); + NSLOG(fetch, DEBUG, "Fetch ring is now %d elements.", all_active); + NSLOG(fetch, DEBUG, "Queue ring is now %d elements.", all_queued); return (all_active > 0); } @@ -269,7 +264,7 @@ static void fetcher_poll(void *unused) int fetcherd; if (fetch_dispatch_jobs()) { - FETCH_LOG("Polling fetchers"); + NSLOG(fetch, DEBUG, "Polling fetchers"); for (fetcherd = 0; fetcherd < MAX_FETCHERS; fetcherd++) { if (fetchers[fetcherd].refcount > 0) { /* fetcher present */ @@ -343,7 +338,7 @@ void fetcher_quit(void) * the reference count to allow the fetcher to * be stopped. */ - NSLOG(netsurf, INFO, + NSLOG(fetch, INFO, "Fetcher for scheme %s still has %d active users at quit.", lwc_string_data(fetchers[fetcherd].scheme), fetchers[fetcherd].refcount); @@ -396,12 +391,12 @@ fetch_fdset(fd_set *read_fd_set, int fetcherd; /* fetcher index */ if (!fetch_dispatch_jobs()) { - FETCH_LOG("No jobs"); + NSLOG(fetch, DEBUG, "No jobs"); *maxfd_out = -1; return NSERROR_OK; } - FETCH_LOG("Polling fetchers"); + NSLOG(fetch, DEBUG, "Polling fetchers"); for (fetcherd = 0; fetcherd < MAX_FETCHERS; fetcherd++) { if (fetchers[fetcherd].refcount > 0) { @@ -484,7 +479,7 @@ fetch_start(nsurl *url, return NSERROR_NO_FETCH_HANDLER; } - FETCH_LOG("fetch %p, url '%s'", fetch, nsurl_access(url)); + NSLOG(fetch, DEBUG, "fetch %p, url '%s'", fetch, nsurl_access(url)); /* construct a new fetch structure */ fetch->callback = callback; @@ -576,7 +571,7 @@ fetch_start(nsurl *url, /* Ask the queue to run. */ if (fetch_dispatch_jobs()) { - FETCH_LOG("scheduling poll"); + NSLOG(fetch, DEBUG, "scheduling poll"); /* schedule active fetchers to run again in 10ms */ guit->misc->schedule(10, fetcher_poll, NULL); } @@ -589,7 +584,8 @@ fetch_start(nsurl *url, void fetch_abort(struct fetch *f) { assert(f); - FETCH_LOG("fetch %p, fetcher %p, url '%s'", f, f->fetcher_handle, + NSLOG(fetch, DEBUG, + "fetch %p, fetcher %p, url '%s'", f, f->fetcher_handle, nsurl_access(f->url)); fetchers[f->fetcherd].ops.abort(f->fetcher_handle); } @@ -597,7 +593,10 @@ void fetch_abort(struct fetch *f) /* exported interface documented in content/fetch.h */ void fetch_free(struct fetch *f) { - FETCH_LOG("Freeing fetch %p, fetcher %p", f, f->fetcher_handle); + NSLOG(fetch, DEBUG, + "Freeing fetch %p, fetcher %p", + f, + f->fetcher_handle); fetchers[f->fetcherd].ops.free(f->fetcher_handle); @@ -723,7 +722,8 @@ void fetch_multipart_data_destroy(struct fetch_multipart_data *list) free(list->name); free(list->value); if (list->file) { - FETCH_LOG("Freeing rawfile: %s", list->rawfile); + NSLOG(fetch, DEBUG, + "Freeing rawfile: %s", list->rawfile); free(list->rawfile); } free(list); @@ -741,8 +741,13 @@ fetch_send_callback(const fetch_msg *msg, struct fetch *fetch) /* exported interface documented in content/fetch.h */ void fetch_remove_from_queues(struct fetch *fetch) { - FETCH_LOG("Fetch %p, fetcher %p can be freed", - fetch, fetch->fetcher_handle); + int all_active; + int all_queued; + + NSLOG(fetch, DEBUG, + "Fetch %p, fetcher %p can be freed", + fetch, + fetch->fetcher_handle); /* Go ahead and free the fetch properly now */ if (fetch->fetch_is_active) { @@ -751,24 +756,19 @@ void fetch_remove_from_queues(struct fetch *fetch) RING_REMOVE(queue_ring, fetch); } -#ifdef DEBUG_FETCH_VERBOSE - int all_active; - int all_queued; RING_GETSIZE(struct fetch, fetch_ring, all_active); RING_GETSIZE(struct fetch, queue_ring, all_queued); - NSLOG(netsurf, INFO, "Fetch ring is now %d elements.", all_active); - - NSLOG(netsurf, INFO, "Queue ring is now %d elements.", all_queued); -#endif + NSLOG(fetch, DEBUG, "Fetch ring is now %d elements.", all_active); + NSLOG(fetch, DEBUG, "Queue ring is now %d elements.", all_queued); } /* exported interface documented in content/fetch.h */ void fetch_set_http_code(struct fetch *fetch, long http_code) { - FETCH_LOG("Setting HTTP code to %ld", http_code); + NSLOG(fetch, DEBUG, "Setting HTTP code to %ld", http_code); fetch->http_code = http_code; } diff --git a/utils/log.c b/utils/log.c index 834a3e933..db90cbf18 100644 --- a/utils/log.c +++ b/utils/log.c @@ -93,6 +93,7 @@ static const char *nslog_gettime(void) NSLOG_DEFINE_CATEGORY(netsurf, "NetSurf default logging"); NSLOG_DEFINE_CATEGORY(llcache, "Low level cache"); +NSLOG_DEFINE_CATEGORY(fetch, "objet fetching"); static void netsurf_render_log(void *_ctx, diff --git a/utils/log.h b/utils/log.h index 50ceac0b1..eee469255 100644 --- a/utils/log.h +++ b/utils/log.h @@ -58,6 +58,7 @@ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv); NSLOG_DECLARE_CATEGORY(netsurf); NSLOG_DECLARE_CATEGORY(llcache); +NSLOG_DECLARE_CATEGORY(fetch); #else /* WITH_NSLOG */ -- cgit v1.2.1 From b346790cf67d5bda40ed06c035f02d0af414361a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 6 Sep 2017 18:23:14 +0100 Subject: update plotter logging to use a catagory --- frontends/amiga/plotters.c | 34 +++++++++++----------------------- frontends/windows/plot.c | 44 +++++++++++++++++--------------------------- utils/log.c | 1 + utils/log.h | 1 + 4 files changed, 30 insertions(+), 50 deletions(-) diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c index dc2c16724..7c5df4678 100644 --- a/frontends/amiga/plotters.c +++ b/frontends/amiga/plotters.c @@ -53,15 +53,6 @@ #include "amiga/rtg.h" #include "amiga/utf8.h" -/* set AMI_PLOTTER_DEBUG to 0 for no debugging, 1 for debugging */ -//#define AMI_PLOTTER_DEBUG 1 - -#ifdef AMI_PLOTTER_DEBUG -#define PLOT_LOG(x...) LOG(x) -#else -#define PLOT_LOG(x...) ((void) 0) -#endif - HOOKF(void, ami_bitmap_tile_hook, struct RastPort *, rp, struct BackFillMessage *); struct bfbitmap { @@ -119,9 +110,6 @@ static bool palette_mapped = true; /* palette-mapped state for the screen */ */ #define AREA_SIZE 25000 -/* Define the below to get additional debug */ -#undef AMI_PLOTTER_DEBUG - struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list) { /* init shared bitmaps */ @@ -438,7 +426,7 @@ static void ami_arc_gfxlib(struct RastPort *rp, int x, int y, int radius, int an static nserror ami_bitmap(struct gui_globals *glob, int x, int y, int width, int height, struct bitmap *bitmap) { - PLOT_LOG("[ami_plotter] Entered ami_bitmap()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_bitmap()"); struct BitMap *tbm; @@ -458,7 +446,7 @@ ami_bitmap(struct gui_globals *glob, int x, int y, int width, int height, struct return NSERROR_OK; } - PLOT_LOG("[ami_plotter] ami_bitmap() got native bitmap"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] ami_bitmap() got native bitmap"); #ifdef __amigaos4__ if (__builtin_expect((GfxBase->LibNode.lib_Version >= 53) && @@ -617,7 +605,7 @@ ami_clip(const struct redraw_context *ctx, const struct rect *clip) struct gui_globals *glob = (struct gui_globals *)ctx->priv; struct Region *reg = NULL; - PLOT_LOG("[ami_plotter] Entered ami_clip()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_clip()"); if (glob->rp->Layer) { reg = NewRegion(); @@ -661,7 +649,7 @@ ami_arc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2) { - PLOT_LOG("[ami_plotter] Entered ami_arc()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_arc()"); struct gui_globals *glob = (struct gui_globals *)ctx->priv; @@ -693,7 +681,7 @@ ami_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius) { - PLOT_LOG("[ami_plotter] Entered ami_disc()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_disc()"); struct gui_globals *glob = (struct gui_globals *)ctx->priv; @@ -728,7 +716,7 @@ ami_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line) { - PLOT_LOG("[ami_plotter] Entered ami_line()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_line()"); struct gui_globals *glob = (struct gui_globals *)ctx->priv; @@ -780,7 +768,7 @@ ami_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect) { - PLOT_LOG("[ami_plotter] Entered ami_rectangle()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_rectangle()"); struct gui_globals *glob = (struct gui_globals *)ctx->priv; @@ -844,7 +832,7 @@ ami_polygon(const struct redraw_context *ctx, const int *p, unsigned int n) { - PLOT_LOG("[ami_plotter] Entered ami_polygon()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_polygon()"); struct gui_globals *glob = (struct gui_globals *)ctx->priv; @@ -893,7 +881,7 @@ ami_path(const struct redraw_context *ctx, unsigned int i; struct bez_point start_p = {0, 0}, cur_p = {0, 0}, p_a, p_b, p_c, p_r; - PLOT_LOG("[ami_plotter] Entered ami_path()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_path()"); struct gui_globals *glob = (struct gui_globals *)ctx->priv; @@ -1037,7 +1025,7 @@ ami_bitmap_tile(const struct redraw_context *ctx, bool repeat_x = (flags & BITMAPF_REPEAT_X); bool repeat_y = (flags & BITMAPF_REPEAT_Y); - PLOT_LOG("[ami_plotter] Entered ami_bitmap_tile()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_bitmap_tile()"); struct gui_globals *glob = (struct gui_globals *)ctx->priv; @@ -1154,7 +1142,7 @@ ami_text(const struct redraw_context *ctx, const char *text, size_t length) { - PLOT_LOG("[ami_plotter] Entered ami_text()"); + NSLOG(plot, DEEPDEBUG, "[ami_plotter] Entered ami_text()"); struct gui_globals *glob = (struct gui_globals *)ctx->priv; diff --git a/frontends/windows/plot.c b/frontends/windows/plot.c index f38fe7522..376d37252 100644 --- a/frontends/windows/plot.c +++ b/frontends/windows/plot.c @@ -41,16 +41,6 @@ #include "windows/gui.h" #include "windows/plot.h" - -/* set NSWS_PLOT_DEBUG to 0 for no debugging, 1 for debugging */ -/* #define NSWS_PLOT_DEBUG */ - -#ifdef NSWS_PLOT_DEBUG -#define PLOT_LOG(x...) LOG(x) -#else -#define PLOT_LOG(x...) ((void) 0) -#endif - HDC plot_hdc; /** currently set clipping rectangle */ @@ -159,9 +149,9 @@ plot_alpha_bitmap(HDC hdc, BITMAPINFO *bmi; HBITMAP MemBMh; - PLOT_LOG("%p bitmap %d,%d width %d height %d", + NSLOG(plot, DEEPDEBUG, "%p bitmap %d,%d width %d height %d", bitmap, x, y, width, height); - PLOT_LOG("clipped %ld,%ld to %ld,%ld", + NSLOG(plot, DEEPDEBUG, "clipped %ld,%ld to %ld,%ld", plot_clip.left, plot_clip.top, plot_clip.right, plot_clip.bottom); @@ -172,7 +162,7 @@ plot_alpha_bitmap(HDC hdc, if ((bitmap->width != width) || (bitmap->height != height)) { - PLOT_LOG("scaling from %d,%d to %d,%d", + NSLOG(plot, DEEPDEBUG, "scaling from %d,%d to %d,%d", bitmap->width, bitmap->height, width, height); bitmap = bitmap_scale(bitmap, width, height); if (bitmap == NULL) { @@ -344,7 +334,7 @@ plot_bitmap(struct bitmap *bitmap, int x, int y, int width, int height) if (bltres == 0) { res = NSERROR_INVALID; } - PLOT_LOG("bltres = %d", bltres); + NSLOG(plot, DEEPDEBUG, "bltres = %d", bltres); } else { /* Bitmap with alpha.*/ res = plot_alpha_bitmap(plot_hdc, bitmap, x, y, width, height); @@ -366,7 +356,7 @@ plot_bitmap(struct bitmap *bitmap, int x, int y, int width, int height) */ static nserror clip(const struct redraw_context *ctx, const struct rect *clip) { - PLOT_LOG("clip %d,%d to %d,%d", clip->x0, clip->y0, clip->x1, clip->y1); + NSLOG(plot, DEEPDEBUG, "clip %d,%d to %d,%d", clip->x0, clip->y0, clip->x1, clip->y1); plot_clip.left = clip->x0; plot_clip.top = clip->y0; @@ -399,7 +389,7 @@ arc(const struct redraw_context *ctx, int x, int y, int radius, int angle1, int angle2) { - PLOT_LOG("arc centre %d,%d radius %d from %d to %d", x, y, radius, + NSLOG(plot, DEEPDEBUG, "arc centre %d,%d radius %d from %d to %d", x, y, radius, angle1, angle2); /* ensure the plot HDC is set */ @@ -511,7 +501,7 @@ disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius) { - PLOT_LOG("disc at %d,%d radius %d", x, y, radius); + NSLOG(plot, DEEPDEBUG, "disc at %d,%d radius %d", x, y, radius); /* ensure the plot HDC is set */ if (plot_hdc == NULL) { @@ -590,7 +580,7 @@ line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line) { - PLOT_LOG("from %d,%d to %d,%d", x0, y0, x1, y1); + NSLOG(plot, DEEPDEBUG, "from %d,%d to %d,%d", x0, y0, x1, y1); /* ensure the plot HDC is set */ if (plot_hdc == NULL) { @@ -656,7 +646,7 @@ rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect) { - PLOT_LOG("rectangle from %d,%d to %d,%d", + NSLOG(plot, DEEPDEBUG, "rectangle from %d,%d to %d,%d", rect->x0, rect->y0, rect->x1, rect->y1); /* ensure the plot HDC is set */ @@ -740,7 +730,7 @@ polygon(const struct redraw_context *ctx, const int *p, unsigned int n) { - PLOT_LOG("polygon %d points", n); + NSLOG(plot, DEEPDEBUG, "polygon %d points", n); /* ensure the plot HDC is set */ if (plot_hdc == NULL) { @@ -788,7 +778,7 @@ polygon(const struct redraw_context *ctx, points[i].x = (long) p[2 * i]; points[i].y = (long) p[2 * i + 1]; - PLOT_LOG("%ld,%ld ", points[i].x, points[i].y); + NSLOG(plot, DEEPDEBUG, "%ld,%ld ", points[i].x, points[i].y); } SelectClipRgn(plot_hdc, clipregion); @@ -831,7 +821,7 @@ path(const struct redraw_context *ctx, float width, const float transform[6]) { - PLOT_LOG("path unimplemented"); + NSLOG(plot, DEEPDEBUG, "path unimplemented"); return NSERROR_OK; } @@ -875,7 +865,7 @@ bitmap(const struct redraw_context *ctx, /* Bail early if we can */ - PLOT_LOG("Plotting %p at %d,%d by %d,%d",bitmap, x,y,width,height); + NSLOG(plot, DEEPDEBUG, "Plotting %p at %d,%d by %d,%d",bitmap, x,y,width,height); if (bitmap == NULL) { NSLOG(netsurf, INFO, "Passed null bitmap!"); @@ -937,8 +927,8 @@ bitmap(const struct redraw_context *ctx, } } - PLOT_LOG("Tiled plotting %d,%d by %d,%d", x, y, width, height); - PLOT_LOG("clipped %ld,%ld to %ld,%ld", + NSLOG(plot, DEEPDEBUG, "Tiled plotting %d,%d by %d,%d", x, y, width, height); + NSLOG(plot, DEEPDEBUG, "clipped %ld,%ld to %ld,%ld", plot_clip.left, plot_clip.top, plot_clip.right, plot_clip.bottom); @@ -952,7 +942,7 @@ bitmap(const struct redraw_context *ctx, for (; y > plot_clip.top; y -= height); } - PLOT_LOG("repeat from %d,%d to %ld,%ld", + NSLOG(plot, DEEPDEBUG, "repeat from %d,%d to %ld,%ld", x, y, plot_clip.right, plot_clip.bottom); /* tile down and across to extents */ @@ -989,7 +979,7 @@ text(const struct redraw_context *ctx, const char *text, size_t length) { - PLOT_LOG("words %s at %d,%d", text, x, y); + NSLOG(plot, DEEPDEBUG, "words %s at %d,%d", text, x, y); /* ensure the plot HDC is set */ if (plot_hdc == NULL) { diff --git a/utils/log.c b/utils/log.c index db90cbf18..8630d87a4 100644 --- a/utils/log.c +++ b/utils/log.c @@ -94,6 +94,7 @@ static const char *nslog_gettime(void) NSLOG_DEFINE_CATEGORY(netsurf, "NetSurf default logging"); NSLOG_DEFINE_CATEGORY(llcache, "Low level cache"); NSLOG_DEFINE_CATEGORY(fetch, "objet fetching"); +NSLOG_DEFINE_CATEGORY(plot, "rendering system"); static void netsurf_render_log(void *_ctx, diff --git a/utils/log.h b/utils/log.h index eee469255..247624769 100644 --- a/utils/log.h +++ b/utils/log.h @@ -59,6 +59,7 @@ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv); NSLOG_DECLARE_CATEGORY(netsurf); NSLOG_DECLARE_CATEGORY(llcache); NSLOG_DECLARE_CATEGORY(fetch); +NSLOG_DECLARE_CATEGORY(plot); #else /* WITH_NSLOG */ -- cgit v1.2.1 From b9bdc279f228c6e70d05c85361fe7d018beba444 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 Sep 2017 15:30:08 +0100 Subject: Update scheduler logging to use catagory --- frontends/amiga/schedule.c | 8 +++++--- frontends/atari/schedule.c | 25 ++++++++++--------------- frontends/beos/schedule.cpp | 28 ++++++++++++++++------------ frontends/framebuffer/schedule.c | 17 +++++++---------- frontends/gtk/schedule.c | 8 +++++--- frontends/monkey/schedule.c | 14 ++++---------- frontends/windows/schedule.c | 40 ++++++++++++++++++++++------------------ utils/log.c | 1 + utils/log.h | 1 + 9 files changed, 71 insertions(+), 71 deletions(-) diff --git a/frontends/amiga/schedule.c b/frontends/amiga/schedule.c index 30a36815c..043edc7fe 100644 --- a/frontends/amiga/schedule.c +++ b/frontends/amiga/schedule.c @@ -228,9 +228,11 @@ static void ami_schedule_dump(void) while ((nscb = pblIteratorNext(iterator)) != -1) { Amiga2Date(nscb->tv.Seconds, &clockdata); - LOG("nscb: %p, at %d-%d-%d %d:%d:%d.%d, callback: %p, %p", - nscb, clockdata.mday, clockdata.month, clockdata.year, clockdata.hour, clockdata.min, clockdata.sec, - nscb->tv.Microseconds, nscb->callback, nscb->p); + NSLOG(netsurf, INFO, + "nscb: %p, at %d-%d-%d %d:%d:%d.%d, callback: %p, %p", + nscb, clockdata.mday, clockdata.month, clockdata.year, + clockdata.hour, clockdata.min, clockdata.sec, + nscb->tv.Microseconds, nscb->callback, nscb->p); if(CheckIO((struct IORequest *)nscb) == NULL) { NSLOG(netsurf, INFO, "-> ACTIVE"); } else { diff --git a/frontends/atari/schedule.c b/frontends/atari/schedule.c index a8d06e499..9a7836b1f 100644 --- a/frontends/atari/schedule.c +++ b/frontends/atari/schedule.c @@ -23,15 +23,10 @@ #include "utils/sys_time.h" #include "utils/errors.h" +#include "utils/log.h" #include "atari/schedule.h" -#ifdef DEBUG_SCHEDULER -#include "utils/log.h" -#else -#define LOG(x...) -#endif - #define MS_NOW() ((clock() * 1000) / CLOCKS_PER_SEC) /* linked list of scheduled callbacks */ @@ -71,7 +66,7 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) return NSERROR_OK; } - NSLOG(netsurf, INFO, "removing %p, %p", callback, p); + NSLOG(schedule, DEBUG, "removing %p, %p", callback, p); cur_nscb = schedule_list; prev_nscb = NULL; @@ -80,7 +75,7 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) if ((cur_nscb->callback == callback) && (cur_nscb->p == p)) { /* item to remove */ - NSLOG(netsurf, INFO, + NSLOG(schedule, DEBUG, "callback entry %p removing %p(%p)", cur_nscb, cur_nscb->callback, cur_nscb->p); @@ -120,7 +115,7 @@ nserror atari_schedule(int ival, void (*callback)(void *p), void *p) nscb->timeout = MS_NOW() + ival; - NSLOG(netsurf, INFO, "adding callback %p for %p(%p) at %d ms", nscb, + NSLOG(schedule, DEBUG, "adding callback %p for %p(%p) at %d ms", nscb, callback, p, nscb->timeout); nscb->callback = callback; @@ -167,7 +162,7 @@ int schedule_run(void) prev_nscb->next = unlnk_nscb->next; } - NSLOG(netsurf, INFO, + NSLOG(schedule, DEBUG, "callback entry %p running %p(%p)", unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p); @@ -178,7 +173,7 @@ int schedule_run(void) /* need to deal with callback modifying the list. */ if (schedule_list == NULL) { - NSLOG(netsurf, INFO, "schedule_list == NULL"); + NSLOG(schedule, DEBUG, "schedule_list == NULL"); return -1; /* no more callbacks scheduled */ } @@ -203,7 +198,7 @@ int schedule_run(void) /* make rettime relative to now and convert to ms */ nexttime = nexttime - now; - NSLOG(netsurf, INFO, "returning time to next event as %ldms", + NSLOG(schedule, DEBUG, "returning time to next event as %ldms", nexttime); /*return next event time in milliseconds (24days max wait) */ @@ -216,15 +211,15 @@ void list_schedule(void) { struct nscallback *cur_nscb; - NSLOG(netsurf, INFO, "schedule list at ms clock %ld", MS_NOW()); + NSLOG(schedule, DEBUG, "schedule list at ms clock %ld", MS_NOW()); cur_nscb = schedule_list; while (cur_nscb != NULL) { - NSLOG(netsurf, INFO, "Schedule %p at %ld", cur_nscb, + NSLOG(schedule, DEBUG, "Schedule %p at %ld", cur_nscb, cur_nscb->timeout); cur_nscb = cur_nscb->next; } - NSLOG(netsurf, INFO, "Maxmium callbacks scheduled: %d", max_scheduled); + NSLOG(schedule, DEBUG, "Maxmium callbacks scheduled: %d", max_scheduled); } diff --git a/frontends/beos/schedule.cpp b/frontends/beos/schedule.cpp index 552a7cd49..c2caea954 100644 --- a/frontends/beos/schedule.cpp +++ b/frontends/beos/schedule.cpp @@ -28,11 +28,7 @@ extern "C" { #include "netsurf/content_type.h" #include "netsurf/browser_window.h" -#ifdef DEBUG_BEOS_SCHEDULE #include "utils/log.h" -#else -#define LOG(x...) -#endif } /** Killable callback closure embodiment. */ @@ -58,8 +54,10 @@ nsbeos_schedule_kill_callback(void *_target, void *_match) _nsbeos_callback_t *match = (_nsbeos_callback_t *)_match; if ((target->callback == match->callback) && (target->context == match->context)) { - NSLOG(netsurf, INFO, "Found match for %p(%p), killing.", - target->callback, target->context); + NSLOG(schedule, DEBUG, + "Found match for %p(%p), killing.", + target->callback, + target->context); target->callback = NULL; target->context = NULL; target->callback_killed = true; @@ -70,7 +68,9 @@ nsbeos_schedule_kill_callback(void *_target, void *_match) static void schedule_remove(void (*callback)(void *p), void *p) { - NSLOG(netsurf, INFO, "schedule_remove() for %p(%p)", cb->callback, + NSLOG(schedule, DEBUG, + "schedule_remove() for %p(%p)", + cb->callback, cb->context); if (callbacks == NULL) return; @@ -83,7 +83,7 @@ schedule_remove(void (*callback)(void *p), void *p) nserror beos_schedule(int t, void (*callback)(void *p), void *p) { - NSLOG(netsurf, INFO, "t:%d cb:%p p:%p", t, cb->callback, cb->context); + NSLOG(schedule, DEBUG, "t:%d cb:%p p:%p", t, cb->callback, cb->context); if (callbacks == NULL) { callbacks = new BList; @@ -113,7 +113,7 @@ nserror beos_schedule(int t, void (*callback)(void *p), void *p) bool schedule_run(void) { - NSLOG(netsurf, INFO, "schedule_run()"); + NSLOG(schedule, DEBUG, "schedule_run()"); earliest_callback_timeout = B_INFINITE_TIMEOUT; if (callbacks == NULL) @@ -122,7 +122,8 @@ schedule_run(void) bigtime_t now = system_time(); int32 i; - NSLOG(netsurf, INFO, "Checking %ld callbacks to for deadline.", + NSLOG(schedule, DEBUG, + "Checking %ld callbacks to for deadline.", this_run->CountItems()); /* Run all the callbacks which made it this far. */ @@ -135,8 +136,11 @@ schedule_run(void) i++; continue; } - NSLOG(netsurf, INFO, "Running callbacks %p(%p).", - cb->callback, cb->context); + NSLOG(schedule, DEBUG, + "Running callbacks %p(%p).", + cb->callback, + cb->context); + if (!cb->callback_killed) cb->callback(cb->context); callbacks->RemoveItem(cb); diff --git a/frontends/framebuffer/schedule.c b/frontends/framebuffer/schedule.c index c94cead44..6d1711236 100644 --- a/frontends/framebuffer/schedule.c +++ b/frontends/framebuffer/schedule.c @@ -24,12 +24,6 @@ #include "framebuffer/schedule.h" -#ifdef DEBUG_SCHEDULER -#define SRLOG(x...) LOG(x) -#else -#define SRLOG(x...) ((void) 0) -#endif - /* linked list of scheduled callbacks */ static struct nscallback *schedule_list = NULL; @@ -63,7 +57,7 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) return NSERROR_OK; } - SRLOG("removing %p, %p", callback, p); + NSLOG(schedule, DEBUG, "removing %p, %p", callback, p); cur_nscb = schedule_list; prev_nscb = NULL; @@ -73,7 +67,8 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) (cur_nscb->p == p)) { /* item to remove */ - SRLOG("callback entry %p removing %p(%p)", + NSLOG(schedule, DEBUG, + "callback entry %p removing %p(%p)", cur_nscb, cur_nscb->callback, cur_nscb->p); /* remove callback */ @@ -109,7 +104,7 @@ nserror framebuffer_schedule(int tival, void (*callback)(void *p), void *p) return ret; } - SRLOG("Adding %p(%p) in %d", callback, p, tival); + NSLOG(schedule, DEBUG, "Adding %p(%p) in %d", callback, p, tival); tv.tv_sec = tival / 1000; /* miliseconds to seconds */ tv.tv_usec = (tival % 1000) * 1000; /* remainder to microseconds */ @@ -190,7 +185,9 @@ int schedule_run(void) /* make rettime relative to now */ timersub(&nexttime, &tv, &rettime); - SRLOG("returning time to next event as %ldms",(rettime.tv_sec * 1000) + (rettime.tv_usec / 1000)); + NSLOG(schedule, DEBUG, + "returning time to next event as %ldms", + (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000)); /* return next event time in milliseconds (24days max wait) */ return (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000); diff --git a/frontends/gtk/schedule.c b/frontends/gtk/schedule.c index 201432097..d5b45674b 100644 --- a/frontends/gtk/schedule.c +++ b/frontends/gtk/schedule.c @@ -46,7 +46,7 @@ nsgtk_schedule_generic_callback(gpointer data) _nsgtk_callback_t *cb = (_nsgtk_callback_t *)(data); if (cb->callback_killed) { /* This callback instance has been killed. */ - NSLOG(netsurf, DEBUG, "CB at %p already dead.", cb); + NSLOG(schedule, DEBUG, "CB at %p already dead.", cb); } queued_callbacks = g_list_remove(queued_callbacks, cb); pending_callbacks = g_list_append(pending_callbacks, cb); @@ -60,7 +60,8 @@ nsgtk_schedule_kill_callback(void *_target, void *_match) _nsgtk_callback_t *match = (_nsgtk_callback_t *)_match; if ((target->callback == match->callback) && (target->context == match->context)) { - NSLOG(netsurf, DEBUG, "Found match for %p(%p), killing.", + NSLOG(schedule, DEBUG, + "Found match for %p(%p), killing.", target->callback, target->context); target->callback = NULL; target->context = NULL; @@ -119,7 +120,8 @@ schedule_run(void) /* Clear the pending list. */ pending_callbacks = NULL; - NSLOG(netsurf, DEBUG, "Captured a run of %d callbacks to fire.", + NSLOG(schedule, DEBUG, + "Captured a run of %d callbacks to fire.", g_list_length(this_run)); /* Run all the callbacks which made it this far. */ diff --git a/frontends/monkey/schedule.c b/frontends/monkey/schedule.c index b34bd5aa5..d3e442a06 100644 --- a/frontends/monkey/schedule.c +++ b/frontends/monkey/schedule.c @@ -24,12 +24,6 @@ #include "monkey/schedule.h" -#ifdef DEBUG_SCHEDULER -#define SRLOG(x...) LOG(x) -#else -#define SRLOG(x...) ((void) 0) -#endif - /* linked list of scheduled callbacks */ static struct nscallback *schedule_list = NULL; @@ -63,7 +57,7 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) return NSERROR_OK; } - SRLOG("removing %p, %p", callback, p); + NSLOG(schedule, DEBUG, "removing %p, %p", callback, p); cur_nscb = schedule_list; prev_nscb = NULL; @@ -73,7 +67,7 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) (cur_nscb->p == p)) { /* item to remove */ - SRLOG("callback entry %p removing %p(%p)", + NSLOG(schedule, DEBUG, "callback entry %p removing %p(%p)", cur_nscb, cur_nscb->callback, cur_nscb->p); /* remove callback */ @@ -109,7 +103,7 @@ nserror monkey_schedule(int tival, void (*callback)(void *p), void *p) return ret; } - SRLOG("Adding %p(%p) in %d", callback, p, tival); + NSLOG(schedule, DEBUG, "Adding %p(%p) in %d", callback, p, tival); tv.tv_sec = tival / 1000; /* miliseconds to seconds */ tv.tv_usec = (tival % 1000) * 1000; /* remainder to microseconds */ @@ -190,7 +184,7 @@ int monkey_schedule_run(void) /* make rettime relative to now */ timersub(&nexttime, &tv, &rettime); - SRLOG("returning time to next event as %ldms", + NSLOG(schedule, DEBUG, "returning time to next event as %ldms", (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000)); /* return next event time in milliseconds (24days max wait) */ diff --git a/frontends/windows/schedule.c b/frontends/windows/schedule.c index d6a757246..76358ec68 100644 --- a/frontends/windows/schedule.c +++ b/frontends/windows/schedule.c @@ -25,12 +25,6 @@ #include "windows/schedule.h" -#ifdef DEBUG_SCHEDULER -#define SRLOG(x...) LOG(x) -#else -#define SRLOG(x...) ((void) 0) -#endif - /* linked list of scheduled callbacks */ static struct nscallback *schedule_list = NULL; @@ -66,7 +60,7 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) return NSERROR_OK; } - SRLOG("removing %p, %p", callback, p); + NSLOG(schedule, DEBUG, "removing %p, %p", callback, p); cur_nscb = schedule_list; prev_nscb = NULL; @@ -76,8 +70,11 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) (cur_nscb->p == p)) { /* item to remove */ - SRLOG("callback entry %p removing %p(%p)", - cur_nscb, cur_nscb->callback, cur_nscb->p); + NSLOG(schedule, DEBUG, + "callback entry %p removing %p(%p)", + cur_nscb, + cur_nscb->callback, + cur_nscb->p); /* remove callback */ unlnk_nscb = cur_nscb; @@ -118,7 +115,8 @@ nserror win32_schedule(int ival, void (*callback)(void *p), void *p) return NSERROR_NOMEM; } - SRLOG("adding callback %p for %p(%p) at %d cs", + NSLOG(schedule, DEBUG, + "adding callback %p for %p(%p) at %d cs", nscb, callback, p, ival); gettimeofday(&nscb->tv, NULL); @@ -168,8 +166,11 @@ schedule_run(void) prev_nscb->next = unlnk_nscb->next; } - SRLOG("callback entry %p running %p(%p)", - unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p); + NSLOG(schedule, DEBUG, + "callback entry %p running %p(%p)", + unlnk_nscb, + unlnk_nscb->callback, + unlnk_nscb->p); /* call callback */ unlnk_nscb->callback(unlnk_nscb->p); @@ -201,8 +202,9 @@ schedule_run(void) /* make returned time relative to now */ timersub(&nexttime, &tv, &rettime); - SRLOG("returning time to next event as %ldms", - (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000)); + NSLOG(schedule, DEBUG, + "returning time to next event as %ldms", + (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000)); /* return next event time in milliseconds (24days max wait) */ return (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000); @@ -216,14 +218,16 @@ void list_schedule(void) gettimeofday(&tv, NULL); - NSLOG(netsurf, INFO, "schedule list at %ld:%ld", tv.tv_sec, - tv.tv_usec); + NSLOG(netsurf, INFO, "schedule list at %ld:%ld", tv.tv_sec, tv.tv_usec); cur_nscb = schedule_list; while (cur_nscb != NULL) { - NSLOG(netsurf, INFO, "Schedule %p at %ld:%ld", cur_nscb, - cur_nscb->tv.tv_sec, cur_nscb->tv.tv_usec); + NSLOG(netsurf, INFO, + "Schedule %p at %ld:%ld", + cur_nscb, + cur_nscb->tv.tv_sec, + cur_nscb->tv.tv_usec); cur_nscb = cur_nscb->next; } } diff --git a/utils/log.c b/utils/log.c index 8630d87a4..f555a862a 100644 --- a/utils/log.c +++ b/utils/log.c @@ -95,6 +95,7 @@ NSLOG_DEFINE_CATEGORY(netsurf, "NetSurf default logging"); NSLOG_DEFINE_CATEGORY(llcache, "Low level cache"); NSLOG_DEFINE_CATEGORY(fetch, "objet fetching"); NSLOG_DEFINE_CATEGORY(plot, "rendering system"); +NSLOG_DEFINE_CATEGORY(schedule, "scheduler"); static void netsurf_render_log(void *_ctx, diff --git a/utils/log.h b/utils/log.h index 247624769..3f2f98deb 100644 --- a/utils/log.h +++ b/utils/log.h @@ -60,6 +60,7 @@ NSLOG_DECLARE_CATEGORY(netsurf); NSLOG_DECLARE_CATEGORY(llcache); NSLOG_DECLARE_CATEGORY(fetch); NSLOG_DECLARE_CATEGORY(plot); +NSLOG_DECLARE_CATEGORY(schedule); #else /* WITH_NSLOG */ -- cgit v1.2.1 From 3faaf00ca3e3c6b3ae5e7ec61bc623917f4fb9fe Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 Sep 2017 16:47:45 +0100 Subject: revert semantic patch change to framebuffer font tool --- frontends/framebuffer/convert_font.c | 198 ++++++++++++++++------------------- 1 file changed, 92 insertions(+), 106 deletions(-) diff --git a/frontends/framebuffer/convert_font.c b/frontends/framebuffer/convert_font.c index 6d7c4d44e..010af857a 100644 --- a/frontends/framebuffer/convert_font.c +++ b/frontends/framebuffer/convert_font.c @@ -278,8 +278,7 @@ bool generate_font_header(const char *path, struct font_data *data) fp = fopen(path, "wb"); if (fp == NULL) { - NSLOG(netsurf, INFO, LOG_ERROR, - "Couldn't open header file \"%s\"\n", path); + LOG(LOG_ERROR, "Couldn't open header file \"%s\"\n", path); return false; } @@ -316,8 +315,7 @@ bool generate_font_source(const char *path, struct font_data *data) fp = fopen(path, "wb"); if (fp == NULL) { - NSLOG(netsurf, INFO, LOG_ERROR, - "Couldn't open output file \"%s\"\n", path); + LOG(LOG_ERROR, "Couldn't open output file \"%s\"\n", path); return false; } @@ -415,14 +413,14 @@ static bool add_glyph_to_data(glyph_entry *add, int id, int style, d->e[d->glyphs++] = e; e->index = d->glyphs; if (d->glyphs >= 0xfffd) { - NSLOG(netsurf, INFO, LOG_ERROR, - " Too many glyphs for internal data ""representation\n"); + LOG(LOG_ERROR, " Too many glyphs for internal data " + "representation\n"); return false; } } else { /* Duplicate glyph */ - NSLOG(netsurf, INFO, LOG_DEBUG, - " U+%.4X (%s) is duplicate\n", id, short_labels[style]); + LOG(LOG_DEBUG, " U+%.4X (%s) is duplicate\n", + id, short_labels[style]); } /* Find glyph's section */ @@ -434,8 +432,8 @@ static bool add_glyph_to_data(glyph_entry *add, int id, int style, size_t size = (d->sec_count[style] + 1) * SECTION_SIZE; uint16_t *temp = realloc(d->sections[style], size); if (temp == NULL) { - NSLOG(netsurf, INFO, LOG_ERROR, - " Couldn't increase sections ""allocation\n"); + LOG(LOG_ERROR, " Couldn't increase sections " + "allocation\n"); return false; } memset(temp + d->sec_count[style] * 256, 0, @@ -458,50 +456,47 @@ static bool check_glyph_data_valid(int pos, char c) if (pos == 44) { if (c != '\n') { - NSLOG(netsurf, INFO, LOG_ERROR, - " Invalid glyph data: ""expecting '\\n', got '%c' (%i)\n", - c, - c); + LOG(LOG_ERROR, " Invalid glyph data: " + "expecting '\\n', got '%c' (%i)\n", + c, c); return false; } else { return true; } } else if (pos < 3) { if (c != ' ') { - NSLOG(netsurf, INFO, LOG_ERROR, - " Invalid glyph data: ""expecting ' ', got '%c' (%i)\n", - c, - c); + LOG(LOG_ERROR, " Invalid glyph data: " + "expecting ' ', got '%c' (%i)\n", + c, c); return false; } else { return true; } } else if (offset == 0) { if (c != '\n' && c != ' ') { - NSLOG(netsurf, INFO, LOG_ERROR, - " Invalid glyph data: ""expecting '\\n' or ' ', ""got '%c' (%i)\n", - c, - c); + LOG(LOG_ERROR, " Invalid glyph data: " + "expecting '\\n' or ' ', " + "got '%c' (%i)\n", + c, c); return false; } else { return true; } } else if (offset < 3) { if (c != ' ') { - NSLOG(netsurf, INFO, LOG_ERROR, - " Invalid glyph data: ""expecting ' ', got '%c' (%i)\n", - c, - c); + LOG(LOG_ERROR, " Invalid glyph data: " + "expecting ' ', got '%c' (%i)\n", + c, c); return false; } else { return true; } } else if (offset >= 3 && pos < 11) { if (c != '.' && c != '#') { - NSLOG(netsurf, INFO, LOG_ERROR, - " Invalid glyph data: ""expecting '.' or '#', ""got '%c' (%i)\n", - c, - c); + LOG(LOG_ERROR, " Invalid glyph data: " + "expecting '.' or '#', " + "got '%c' (%i)\n", + c, c); return false; } else { return true; @@ -510,10 +505,10 @@ static bool check_glyph_data_valid(int pos, char c) /* offset must be >=3 */ if (c != '.' && c != '#' && c != ' ') { - NSLOG(netsurf, INFO, LOG_ERROR, - " Invalid glyph data: ""expecting '.', '#', or ' ', ""got '%c' (%i)\n", - c, - c); + LOG(LOG_ERROR, " Invalid glyph data: " + "expecting '.', '#', or ' ', " + "got '%c' (%i)\n", + c, c); return false; } @@ -702,11 +697,11 @@ static bool parse_glyph_data(struct parse_context *ctx, char c, /* Check that character is valid */ if (check_glyph_data_valid(ctx->data.in_gd.pos, c) == false) { - NSLOG(netsurf, INFO, LOG_ERROR, - " Error in U+%.4X data: ""glyph line: %i, pos: %i\n", - ctx->id, - ctx->data.in_gd.line, - ctx->data.in_gd.pos); + LOG(LOG_ERROR, " Error in U+%.4X data: " + "glyph line: %i, pos: %i\n", + ctx->id, + ctx->data.in_gd.line, + ctx->data.in_gd.pos); goto error; } @@ -717,8 +712,8 @@ static bool parse_glyph_data(struct parse_context *ctx, char c, ctx->data.in_gd.e[glyph] = calloc(sizeof(struct glyph_entry), 1); if (ctx->data.in_gd.e[glyph] == NULL) { - NSLOG(netsurf, INFO, LOG_ERROR, - " Couldn't allocate memory for ""glyph entry\n"); + LOG(LOG_ERROR, " Couldn't allocate memory for " + "glyph entry\n"); goto error; } @@ -740,17 +735,18 @@ static bool parse_glyph_data(struct parse_context *ctx, char c, if (c == '\n') { if (ctx->data.in_gd.line == 0) { if (ctx->data.in_gd.e[0] == NULL) { - NSLOG(netsurf, INFO, LOG_ERROR, - " Error in U+%.4X data: ""\"Regular\" glyph style must ""be present\n", - ctx->id); + LOG(LOG_ERROR, " Error in U+%.4X data: " + "\"Regular\" glyph style must " + "be present\n", ctx->id); goto error; } } else if (ctx->data.in_gd.styles != ctx->data.in_gd.line_styles) { - NSLOG(netsurf, INFO, LOG_ERROR, - " Error in U+%.4X data: ""glyph line: %i ""styles don't match first line\n", - ctx->id, - ctx->data.in_gd.line); + LOG(LOG_ERROR, " Error in U+%.4X data: " + "glyph line: %i " + "styles don't match first line\n", + ctx->id, + ctx->data.in_gd.line); goto error; } @@ -768,10 +764,10 @@ static bool parse_glyph_data(struct parse_context *ctx, char c, ctx->count[i] += 1; if (glyph_is_codepoint(ctx->data.in_gd.e[i], ctx->id, i)) { - NSLOG(netsurf, INFO, LOG_DEBUG, - " U+%.4X (%s) is ""codepoint\n", - ctx->id, - short_labels[i]); + LOG(LOG_DEBUG, " U+%.4X (%s) is " + "codepoint\n", + ctx->id, + short_labels[i]); ctx->codepoints += 1; free(ctx->data.in_gd.e[i]); ctx->data.in_gd.e[i] = NULL; @@ -814,8 +810,7 @@ static bool get_hex_digit_value(char c, int *v) else if (c >= 'A' && c <= 'F') *v = (10 + c - 'A'); else { - NSLOG(netsurf, INFO, LOG_ERROR, - "Invalid hex digit '%c' (%i)\n", c, c); + LOG(LOG_ERROR, "Invalid hex digit '%c' (%i)\n", c, c); return false; } @@ -852,16 +847,14 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, while (pos < end) { if (*pos == '\r') { - NSLOG(netsurf, INFO, LOG_ERROR, - "Detected \'\\r\': Bad line ending\n"); + LOG(LOG_ERROR, "Detected \'\\r\': Bad line ending\n"); return false; } switch (ctx->state) { case START: if (*pos != '*') { - NSLOG(netsurf, INFO, LOG_ERROR, - "First character must be '*'\n"); + LOG(LOG_ERROR, "First character must be '*'\n"); printf("Got: %c (%i)\n", *pos, *pos); return false; } @@ -873,13 +866,12 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, case IN_HEADER: if (ctx->data.in_header.new_line == true) { if (*pos != '*') { - NSLOG(netsurf, INFO, LOG_INFO, - " Got header ""(%i bytes)\n", - d->header_len); - NSLOG(netsurf, INFO, LOG_DEBUG, - " Header:\n\n%.*s\n", - d->header_len, - d->header); + LOG(LOG_INFO, " Got header " + "(%i bytes)\n", + d->header_len); + LOG(LOG_DEBUG, " Header:\n\n%.*s\n", + d->header_len, + d->header); ctx->data.before_id.new_line = false; ctx->data.before_id.u = false; ctx->state = BEFORE_ID; @@ -894,9 +886,9 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, } if (d->header_len == HEADER_MAX) { - NSLOG(netsurf, INFO, LOG_ERROR, - " Header too long ""(>%i bytes)\n", - d->header_len); + LOG(LOG_ERROR, " Header too long " + "(>%i bytes)\n", + d->header_len); return false; } @@ -930,8 +922,7 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, ok = assemble_codepoint(pos, ctx->data.g_id.c++, &ctx->id); if (!ok) { - NSLOG(netsurf, INFO, LOG_ERROR, - " Invalid glyph ID\n"); + LOG(LOG_ERROR, " Invalid glyph ID\n"); return false; } @@ -1003,8 +994,8 @@ static bool parse_chunk(struct parse_context *ctx, const char *buf, size_t len, } for (i = 0; i < 4; i++) { - NSLOG(netsurf, INFO, LOG_DEBUG, " %s: %i gylphs\n", - labels[i], ctx->count[i] - count[i]); + LOG(LOG_DEBUG, " %s: %i gylphs\n", labels[i], + ctx->count[i] - count[i]); } return true; @@ -1028,15 +1019,13 @@ bool load_font(const char *path, struct font_data **data) fp = fopen(path, "rb"); if (fp == NULL) { - NSLOG(netsurf, INFO, LOG_ERROR, - "Couldn't open font data file\n"); + LOG(LOG_ERROR, "Couldn't open font data file\n"); return false; } d = calloc(sizeof(struct font_data), 1); if (d == NULL) { - NSLOG(netsurf, INFO, LOG_ERROR, - "Couldn't allocate memory for font data\n"); + LOG(LOG_ERROR, "Couldn't allocate memory for font data\n"); fclose(fp); return false; } @@ -1045,19 +1034,18 @@ bool load_font(const char *path, struct font_data **data) fseek(fp, 0L, SEEK_END); file_len = ftell(fp); if (file_len == -1) { - NSLOG(netsurf, INFO, LOG_ERROR, "Could not size input file\n"); + LOG(LOG_ERROR, "Could not size input file\n"); free(d); fclose(fp); return false; } fseek(fp, 0L, SEEK_SET); - NSLOG(netsurf, INFO, LOG_DEBUG, "Input size: %zu bytes\n", file_len); + LOG(LOG_DEBUG, "Input size: %zu bytes\n", file_len); /* Allocate buffer for data chunks */ buf = malloc(CHUNK_SIZE); if (buf == NULL) { - NSLOG(netsurf, INFO, LOG_ERROR, - "Couldn't allocate memory for input buffer\n"); + LOG(LOG_ERROR, "Couldn't allocate memory for input buffer\n"); free(d); fclose(fp); return false; @@ -1066,24 +1054,20 @@ bool load_font(const char *path, struct font_data **data) /* Initialise parser */ parse_init(&ctx); - NSLOG(netsurf, INFO, LOG_DEBUG, "Using chunk size of %i bytes\n", - CHUNK_SIZE); + LOG(LOG_DEBUG, "Using chunk size of %i bytes\n", CHUNK_SIZE); /* Parse the input file in chunks */ for (done = 0; done < file_len; done += CHUNK_SIZE) { - NSLOG(netsurf, INFO, LOG_INFO, "Parsing input chunk %zu\n", - done / CHUNK_SIZE); + LOG(LOG_INFO, "Parsing input chunk %zu\n", done / CHUNK_SIZE); /* Read chunk */ len = fread(buf, 1, CHUNK_SIZE, fp); if (file_len - done < CHUNK_SIZE && len != file_len - done) { - NSLOG(netsurf, INFO, LOG_WARNING, - "Last chunk has suspicious size\n"); + LOG(LOG_WARNING, "Last chunk has suspicious size\n"); } else if (file_len - done >= CHUNK_SIZE && len != CHUNK_SIZE) { - NSLOG(netsurf, INFO, LOG_ERROR, - "Problem reading file\n"); + LOG(LOG_ERROR, "Problem reading file\n"); free(buf); free(d); fclose(fp); @@ -1098,33 +1082,29 @@ bool load_font(const char *path, struct font_data **data) fclose(fp); return false; } - NSLOG(netsurf, INFO, LOG_DEBUG, "Parsed %zu bytes\n", - done + len); + LOG(LOG_DEBUG, "Parsed %zu bytes\n", done + len); } fclose(fp); if (ctx.state != BEFORE_ID) { - NSLOG(netsurf, INFO, LOG_ERROR, "Unexpected end of file\n"); + LOG(LOG_ERROR, "Unexpected end of file\n"); free(buf); free(d); return false; } - NSLOG(netsurf, INFO, LOG_INFO, "Parsing complete:\n"); + LOG(LOG_INFO, "Parsing complete:\n"); count = 0; for (i = 0; i < 4; i++) { - NSLOG(netsurf, INFO, LOG_INFO, " %s: %i gylphs\n", - labels[i], ctx.count[i]); + LOG(LOG_INFO, " %s: %i gylphs\n", labels[i], ctx.count[i]); count += ctx.count[i]; } - NSLOG(netsurf, INFO, LOG_RESULT, - " Total %i gylphs ""(of which %i unique, %i codepoints, %i duplicates)\n", - count, - d->glyphs, - ctx.codepoints, - count - d->glyphs - ctx.codepoints); + LOG(LOG_RESULT, " Total %i gylphs " + "(of which %i unique, %i codepoints, %i duplicates)\n", + count, d->glyphs, ctx.codepoints, + count - d->glyphs - ctx.codepoints); free(buf); @@ -1135,9 +1115,16 @@ bool load_font(const char *path, struct font_data **data) static void log_usage(const char *argv0) { level = LOG_INFO; - NSLOG(netsurf, INFO, LOG_INFO, - "Usage:\n""\t%s [options] \n""\n""Options:\n""\t--help -h Display this text\n""\t--quiet -q Don't show warnings\n""\t--verbose -v Verbose output\n""\t--debug -d Full debug output\n", - argv0); + LOG(LOG_INFO, + "Usage:\n" + "\t%s [options] \n" + "\n" + "Options:\n" + "\t--help -h Display this text\n" + "\t--quiet -q Don't show warnings\n" + "\t--verbose -v Verbose output\n" + "\t--debug -d Full debug output\n", + argv0); } int main(int argc, char** argv) @@ -1200,9 +1187,8 @@ int main(int argc, char** argv) in_path = argv[optind]; out_path = argv[optind + 1]; - NSLOG(netsurf, INFO, LOG_DEBUG, "Using input path: \"%s\"\n", in_path); - NSLOG(netsurf, INFO, LOG_DEBUG, "Using output path: \"%s\"\n", - out_path); + LOG(LOG_DEBUG, "Using input path: \"%s\"\n", in_path); + LOG(LOG_DEBUG, "Using output path: \"%s\"\n", out_path); ok = load_font(in_path, &data); if (!ok) { -- cgit v1.2.1 From 2b0a5ef2e732ed484096b558116d28ac7abbef0a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 Sep 2017 16:57:58 +0100 Subject: update framebuffer toolkit logging to use a ctagory --- frontends/framebuffer/fbtk.h | 6 ------ frontends/framebuffer/fbtk/fbtk.c | 42 ++++++++++++++++++++------------------- utils/log.c | 1 + utils/log.h | 1 + 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/frontends/framebuffer/fbtk.h b/frontends/framebuffer/fbtk.h index 3cc326cef..86bdc864b 100644 --- a/frontends/framebuffer/fbtk.h +++ b/frontends/framebuffer/fbtk.h @@ -21,12 +21,6 @@ #include "netsurf/types.h" -#ifdef FBTK_LOGGING -#define FBTK_LOG(x) LOG(x) -#else -#define FBTK_LOG(x) -#endif - #define FB_SCROLL_COLOUR 0xFFAAAAAA #define FB_FRAME_COLOUR 0xFFDDDDDD #define FB_COLOUR_BLACK 0xFF000000 diff --git a/frontends/framebuffer/fbtk/fbtk.c b/frontends/framebuffer/fbtk/fbtk.c index a0b0f6660..91f6e2570 100644 --- a/frontends/framebuffer/fbtk/fbtk.c +++ b/frontends/framebuffer/fbtk/fbtk.c @@ -53,7 +53,7 @@ dump_tk_tree(fbtk_widget_t *widget) int indent = 0; while (widget != NULL) { - NSLOG(netsurf, INFO, "%*s%p", indent, "", widget); + NSLOG(fbtk, DEBUG, "%*s%p", indent, "", widget); if (widget->first_child != NULL) { widget = widget->first_child; indent += 6; @@ -100,11 +100,13 @@ fbtk_request_redraw(fbtk_widget_t *widget) widget->redraw.width = widget->width; widget->redraw.height = widget->height; -#ifdef FBTK_LOGGING - NSLOG(netsurf, INFO, "redrawing %p %d,%d %d,%d", widget, - widget->redraw.x, widget->redraw.y, widget->redraw.width, + NSLOG(fbtk, DEBUG, + "redrawing %p %d,%d %d,%d", + widget, + widget->redraw.x, + widget->redraw.y, + widget->redraw.width, widget->redraw.height); -#endif cwidget = widget->last_child; while (cwidget != NULL) { @@ -134,9 +136,11 @@ fbtk_set_mapping(fbtk_widget_t *widget, bool map) return 0; } -/** swap the widget given with the next sibling. - * + +/** * Swap a sibling widget with the next deepest in the hierachy + * + * \param lw The widget to swap */ static void swap_siblings(fbtk_widget_t *lw) @@ -403,7 +407,6 @@ fbtk_set_ptr(fbtk_widget_t *widget, fbtk_callback_info *cbi) } - /* internally exported function documented in widget.h */ fbtk_widget_t * fbtk_get_root_widget(fbtk_widget_t *widget) @@ -436,6 +439,7 @@ fbtk_get_absx(fbtk_widget_t *widget) return x; } + /* exported function documented in fbtk.h */ int fbtk_get_absy(fbtk_widget_t *widget) @@ -450,6 +454,7 @@ fbtk_get_absy(fbtk_widget_t *widget) return y; } + /* exported function documented in fbtk.h */ int fbtk_get_height(fbtk_widget_t *widget) @@ -554,10 +559,7 @@ fbtk_widget_new(fbtk_widget_t *parent, if (neww == NULL) return NULL; -#ifdef FBTK_LOGGING - NSLOG(netsurf, INFO, "creating %p %d,%d %d,%d", neww, x, y, width, - height); -#endif + NSLOG(fbtk, DEBUG, "creating %p %d,%d %d,%d", neww, x, y, width, height); /* make new window fit inside parent */ if (width == 0) { @@ -578,10 +580,8 @@ fbtk_widget_new(fbtk_widget_t *parent, height = parent->height - y; } -#ifdef FBTK_LOGGING - NSLOG(netsurf, INFO, "using %p %d,%d %d,%d", neww, x, y, width, - height); -#endif + NSLOG(fbtk, DEBUG, "using %p %d,%d %d,%d", neww, x, y, width, height); + /* set values */ neww->type = type; neww->x = x; @@ -639,10 +639,12 @@ do_redraw(nsfb_t *nsfb, fbtk_widget_t *widget) plot_ctx.x1 = plot_ctx.x0 + widget->redraw.width; plot_ctx.y1 = plot_ctx.y0 + widget->redraw.height; -#ifdef FBTK_LOGGING - NSLOG(netsurf, INFO, "clipping %p %d,%d %d,%d", widget, - plot_ctx.x0, plot_ctx.y0, plot_ctx.x1, plot_ctx.y1); -#endif + NSLOG(fbtk, DEBUG, + "clipping %p %d,%d %d,%d", + widget, + plot_ctx.x0, plot_ctx.y0, + plot_ctx.x1, plot_ctx.y1); + if (nsfb_plot_set_clip(nsfb, &plot_ctx) == true) { fbtk_post_callback(widget, FBTK_CBT_REDRAW); } diff --git a/utils/log.c b/utils/log.c index f555a862a..3beb695f6 100644 --- a/utils/log.c +++ b/utils/log.c @@ -96,6 +96,7 @@ NSLOG_DEFINE_CATEGORY(llcache, "Low level cache"); NSLOG_DEFINE_CATEGORY(fetch, "objet fetching"); NSLOG_DEFINE_CATEGORY(plot, "rendering system"); NSLOG_DEFINE_CATEGORY(schedule, "scheduler"); +NSLOG_DEFINE_CATEGORY(fbtk, "Framebuffer toolkit"); static void netsurf_render_log(void *_ctx, diff --git a/utils/log.h b/utils/log.h index 3f2f98deb..1dbc9e304 100644 --- a/utils/log.h +++ b/utils/log.h @@ -61,6 +61,7 @@ NSLOG_DECLARE_CATEGORY(llcache); NSLOG_DECLARE_CATEGORY(fetch); NSLOG_DECLARE_CATEGORY(plot); NSLOG_DECLARE_CATEGORY(schedule); +NSLOG_DECLARE_CATEGORY(fbtk); #else /* WITH_NSLOG */ -- cgit v1.2.1 From 5d6f189d8bb723201d44a0d4f35d93ffb6a00a54 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 Sep 2017 18:12:09 +0100 Subject: Fixup everything the semantic patch missed --- content/content.c | 2 +- content/fs_backing_store.c | 12 ++++++------ frontends/amiga/bitmap.c | 11 ++++++++--- frontends/amiga/corewindow.c | 3 ++- frontends/amiga/gui.c | 3 ++- frontends/amiga/libs.c | 18 +++++++++--------- frontends/amiga/menu.c | 4 +++- frontends/atari/deskmenu.c | 2 +- frontends/beos/font.cpp | 7 +++---- frontends/beos/gui.cpp | 12 ++++++++---- frontends/beos/window.cpp | 2 +- frontends/gtk/layout_pango.c | 7 ++++--- frontends/gtk/resources.c | 5 +++-- frontends/riscos/configure/con_image.c | 5 +++-- frontends/riscos/gui.c | 6 ++++-- frontends/riscos/textselection.c | 2 +- frontends/riscos/theme.c | 11 +++++++---- frontends/windows/font.c | 9 +++++---- frontends/windows/windbg.h | 14 ++++++++------ frontends/windows/window.c | 22 ++++++++++++++++------ render/html.c | 2 +- utils/nsurl/private.h | 32 ++++++++++++++++++++++++-------- 22 files changed, 120 insertions(+), 71 deletions(-) diff --git a/content/content.c b/content/content.c index 8ed5c1ba8..9a240417d 100644 --- a/content/content.c +++ b/content/content.c @@ -770,7 +770,7 @@ void content_broadcast(struct content *c, content_msg msg, struct content_user *user, *next; assert(c); -// LOG("%p -> msg:%d", c, msg); + NSLOG(netsurf, DEEPDEBUG, "%p -> msg:%d", c, msg); for (user = c->user_list->next; user != 0; user = next) { next = user->next; /* user may be destroyed during callback */ if (user->callback != 0) diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c index 648565088..1b59ea150 100644 --- a/content/fs_backing_store.c +++ b/content/fs_backing_store.c @@ -1153,12 +1153,12 @@ build_entrymap(struct store_state *state) state->total_alloc = 0; for (eloop = 1; eloop < state->last_entry; eloop++) { - /* - LOG("entry:%d ident:0x%08x used:%d", - eloop, - BS_ADDRESS(state->entries[eloop].ident, state), - state->entries[eloop].use_count); - */ + + NSLOG(llcache, DEEPDEBUG, + "entry:%d ident:0x%08x used:%d", + eloop, + BS_ADDRESS(state->entries[eloop].ident, state), + state->entries[eloop].use_count); /* update the address map to point at the entry */ BS_ENTRY_INDEX(state->entries[eloop].ident, state) = eloop; diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c index 757b55965..0fde677ae 100644 --- a/frontends/amiga/bitmap.c +++ b/frontends/amiga/bitmap.c @@ -602,8 +602,12 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, TAG_DONE); if (err != COMPERR_Success) { - LOG("Composite error %ld - falling back", err); - /* If it failed, do it again the way which works in software */ + NSLOG(netsurf, INFO, + "Composite error %ld - falling back", + err); + /* If it failed, do it again the way + * which works in software + */ #else { #endif @@ -617,7 +621,8 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, COMPTAG_FriendBitMap, scrn->RastPort.BitMap, TAG_DONE); /* If it still fails... it's non-fatal */ - LOG("Fallback returned error %ld", err); + NSLOG(netsurf, INFO, + "Fallback returned error %ld", err); } } else /* Do it the old-fashioned way. This is pretty slow, even on OS4.1 */ #endif diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c index 243146a3a..42ee866ea 100644 --- a/frontends/amiga/corewindow.c +++ b/frontends/amiga/corewindow.c @@ -526,7 +526,8 @@ HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *) break; default: - LOG("IDCMP hook unhandled event: %ld", msg->Class); + NSLOG(netsurf, INFO, + "IDCMP hook unhandled event: %ld", msg->Class); break; } } diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index 387c2151c..e4acf70c2 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -3863,7 +3863,8 @@ HOOKF(void, ami_scroller_hook, Object *, object, struct IntuiMessage *) break; default: - LOG("IDCMP hook unhandled event: %ld", msg->Class); + NSLOG(netsurf, INFO, + "IDCMP hook unhandled event: %ld", msg->Class); break; } // ReplyMsg((struct Message *)msg); diff --git a/frontends/amiga/libs.c b/frontends/amiga/libs.c index 30694542c..43fe43f1a 100644 --- a/frontends/amiga/libs.c +++ b/frontends/amiga/libs.c @@ -56,11 +56,11 @@ #ifdef __amigaos4__ #define AMINS_LIB_OPEN(LIB, LIBVER, PREFIX, INTERFACE, INTVER, FAIL) \ - LOG("Opening %s v%d", LIB, LIBVER); \ + NSLOG(netsurf, INFO, "Opening %s v%d", LIB, LIBVER); \ if((PREFIX##Base = (struct PREFIX##Base *)OpenLibrary(LIB, LIBVER))) { \ I##PREFIX = (struct PREFIX##IFace *)GetInterface((struct Library *)PREFIX##Base, INTERFACE, INTVER, NULL); \ if(I##PREFIX == NULL) { \ - LOG("Failed to get %s interface v%d of %s", INTERFACE, INTVER, LIB); \ + NSLOG(netsurf, INFO, "Failed to get %s interface v%d of %s", INTERFACE, INTVER, LIB); \ AMINS_LIB_CLOSE(PREFIX) \ if(FAIL == true) { \ STRPTR error = ASPrintf("Unable to open interface %s v%d\nof %s v%ld (fatal error - not an OS4 lib?)", INTERFACE, INTVER, LIB, LIBVER); \ @@ -70,7 +70,7 @@ } \ } \ } else { \ - LOG("Failed to open %s v%d", LIB, LIBVER); \ + NSLOG(netsurf, INFO, "Failed to open %s v%d", LIB, LIBVER); \ if(FAIL == true) { \ STRPTR error = ASPrintf("Unable to open %s v%ld (fatal error)", LIB, LIBVER); \ ami_misc_fatal_error(error); \ @@ -90,13 +90,13 @@ struct PREFIX##IFace *I##PREFIX = NULL; #define AMINS_CLASS_OPEN(CLASS, CLASSVER, PREFIX, CLASSGET, NEEDINTERFACE) \ - LOG("Opening %s v%d", CLASS, CLASSVER); \ + NSLOG(netsurf, INFO, "Opening %s v%d", CLASS, CLASSVER); \ if((PREFIX##Base = OpenClass(CLASS, CLASSVER, &PREFIX##Class))) { \ if(NEEDINTERFACE == true) { \ - LOG(" + interface"); \ + NSLOG(netsurf, INFO, " + interface"); \ I##PREFIX = (struct PREFIX##IFace *)GetInterface((struct Library *)PREFIX##Base, "main", 1, NULL); \ if(I##PREFIX == NULL) { \ - LOG("Failed to get main interface v1 of %s", CLASS); \ + NSLOG(netsurf, INFO, "Failed to get main interface v1 of %s", CLASS); \ } \ } \ } \ @@ -118,10 +118,10 @@ #else #define AMINS_LIB_OPEN(LIB, LIBVER, PREFIX, INTERFACE, INTVER, FAIL) \ - LOG("Opening %s v%d", LIB, LIBVER); \ + NSLOG(netsurf, INFO, "Opening %s v%d", LIB, LIBVER); \ if((PREFIX##Base = (struct PREFIX##Base *)OpenLibrary(LIB, LIBVER))) { \ } else { \ - LOG("Failed to open %s v%d", LIB, LIBVER); \ + NSLOG(netsurf, INFO, "Failed to open %s v%d", LIB, LIBVER); \ if(FAIL == true) { \ STRPTR error = ASPrintf("Unable to open %s v%d (fatal error)", LIB, LIBVER); \ ami_misc_fatal_error(error); \ @@ -137,7 +137,7 @@ struct PREFIX##Base *PREFIX##Base = NULL; #define AMINS_CLASS_OPEN(CLASS, CLASSVER, PREFIX, CLASSGET, NEEDINTERFACE) \ - LOG("Opening %s v%d", CLASS, CLASSVER); \ + NSLOG(netsurf, INFO, "Opening %s v%d", CLASS, CLASSVER); \ if((PREFIX##Base = OpenLibrary(CLASS, CLASSVER))) { \ PREFIX##Class = CLASSGET##_GetClass(); \ } \ diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c index 65265c34d..1f3f981ea 100644 --- a/frontends/amiga/menu.c +++ b/frontends/amiga/menu.c @@ -263,7 +263,9 @@ static int ami_menu_layout_mc_recursive(Object *menu_parent, struct ami_menu_dat TAG_DONE); } - //LOG("Adding item %p ID %d (%s) to parent %p", menu_item, j, md[j]->menulab, menu_parent); + NSLOG(netsurf, DEEPDEBUG, + "Adding item %p ID %d (%s) to parent %p", + menu_item, j, md[j]->menulab, menu_parent); IDoMethod(menu_parent, OM_ADDMEMBER, menu_item); continue; } else if (md[j]->menutype > level) { diff --git a/frontends/atari/deskmenu.c b/frontends/atari/deskmenu.c index 32dfd7084..ded68ca5b 100644 --- a/frontends/atari/deskmenu.c +++ b/frontends/atari/deskmenu.c @@ -181,7 +181,7 @@ static void __CDECL menu_about(short item, short title, void *data) nserror error; char buf[PATH_MAX]; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "abort menu"); strcpy((char*)&buf, "file://"); strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) ); diff --git a/frontends/beos/font.cpp b/frontends/beos/font.cpp index 407918f0c..81113032d 100644 --- a/frontends/beos/font.cpp +++ b/frontends/beos/font.cpp @@ -204,8 +204,8 @@ static nserror beos_font_position(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) { - //LOG("(, '%s', %d, %d, , )", string, length, x); - //fprintf(stderr, "%s(, '%s', %d, %d, , )\n", __FUNCTION__, string, length, x); + NSLOG(netsurf, DEEPDEBUG, "(, '%s', %d, %d, , )", string, length, x); + int index; BFont font; @@ -261,8 +261,7 @@ static nserror beos_font_split(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) { - //fprintf(stderr, "%s(, '%s', %d, %d, , )\n", __FUNCTION__, string, length, x); - //LOG("(, '%s', %d, %d, , )", string, length, x); + NSLOG(netsurf, DEEPDEBUG, "(, '%s', %d, %d, , )", string, length, x); int index = 0; BFont font; diff --git a/frontends/beos/gui.cpp b/frontends/beos/gui.cpp index f2c991777..69a0d6dde 100644 --- a/frontends/beos/gui.cpp +++ b/frontends/beos/gui.cpp @@ -764,17 +764,21 @@ void nsbeos_gui_poll(void) timeout.tv_sec = (long)(next_schedule / 1000000LL); timeout.tv_usec = (long)(next_schedule % 1000000LL); - //LOG("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule); + NSLOG(netsurf, DEEPDEBUG, + "gui_poll: select(%d, ..., %Ldus", + max_fd, next_schedule); fd_count = select(max_fd, &read_fd_set, &write_fd_set, &exc_fd_set, &timeout); - //LOG("select: %d\n", fd_count); + NSLOG(netsurf, DEEPDEBUG, "select: %d\n", fd_count); if (fd_count > 0 && FD_ISSET(sEventPipe[0], &read_fd_set)) { BMessage *message; int len = read(sEventPipe[0], &message, sizeof(void *)); - //LOG("gui_poll: BMessage ? %d read", len); + NSLOG(netsurf, DEEPDEBUG, "gui_poll: BMessage ? %d read", len); if (len == sizeof(void *)) { - //LOG("gui_poll: BMessage.what %-4.4s\n", &(message->what)); + NSLOG(netsurf, DEEPDEBUG, + "gui_poll: BMessage.what %-4.4s\n", + &(message->what)); nsbeos_dispatch_event(message); } } diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp index c6e2aadfc..f4229207b 100644 --- a/frontends/beos/window.cpp +++ b/frontends/beos/window.cpp @@ -457,7 +457,7 @@ void nsbeos_dispatch_event(BMessage *message) return; } - //LOG("processing message"); + NSLOG(netsurf, DEEPDEBUG, "processing message"); switch (message->what) { case B_QUIT_REQUESTED: // from the BApplication diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c index 300278648..9e17c3b1c 100644 --- a/frontends/gtk/layout_pango.c +++ b/frontends/gtk/layout_pango.c @@ -84,9 +84,10 @@ nsfont_width(const plot_font_style_t *fstyle, pango_layout_get_pixel_size(nsfont_pango_layout, width, 0); - /* LOG("fstyle: %p string:\"%.*s\", length: %u, width: %dpx", - fstyle, length, string, length, *width); - */ + NSLOG(netsurf, DEEPDEBUG, + "fstyle: %p string:\"%.*s\", length: %u, width: %dpx", + fstyle, length, string, length, *width); + return NSERROR_OK; } diff --git a/frontends/gtk/resources.c b/frontends/gtk/resources.c index c07548b01..0f0d180e0 100644 --- a/frontends/gtk/resources.c +++ b/frontends/gtk/resources.c @@ -202,7 +202,8 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) resource->path); return NSERROR_OK; } - /*LOG("gresource \"%s\" not found", resname);*/ + NSLOG(netsurf, DEEPDEBUG, + "gresource \"%s\" not found", resname); free(resname); langc++; @@ -226,7 +227,7 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) resource->path); return NSERROR_OK; } - /*LOG("gresource \"%s\" not found", resname);*/ + NSLOG(netsurf, DEEPDEBUG, "gresource \"%s\" not found", resname);*/ free(resname); #endif diff --git a/frontends/riscos/configure/con_image.c b/frontends/riscos/configure/con_image.c index 49dd4f76d..c7fc7f314 100644 --- a/frontends/riscos/configure/con_image.c +++ b/frontends/riscos/configure/con_image.c @@ -150,8 +150,9 @@ void ro_gui_options_image_redraw(wimp_draw *redraw) icon_state.i = IMAGE_CURRENT_DISPLAY; error = xwimp_get_icon_state(&icon_state); if (error) { - LOG("xwimp_get_icon_state: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_get_icon_state: 0x%x: %s", + error->errnum, error->errmess); ro_warn_user("MenuError", error->errmess); return; } diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c index 51ea37066..9d651bc10 100644 --- a/frontends/riscos/gui.c +++ b/frontends/riscos/gui.c @@ -274,8 +274,10 @@ set_colour_from_wimp(struct nsoption_s *opts, error = xwimp_read_true_palette((os_palette *) &palette); if (error != NULL) { - LOG("xwimp_read_palette: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xwimp_read_palette: 0x%x: %s", + error->errnum, + error->errmess); } else { /* entries are in B0G0R0LL */ def_colour = palette.entries[wimp] >> 8; diff --git a/frontends/riscos/textselection.c b/frontends/riscos/textselection.c index efec96b56..e5be27791 100644 --- a/frontends/riscos/textselection.c +++ b/frontends/riscos/textselection.c @@ -482,7 +482,7 @@ void ro_gui_selection_data_request(wimp_full_message_data_request *req) // bits ftype = req->file_types[i]; // if (ftype == ~0U) break; /* list terminator */ // -// LOG("type %x", ftype); +// NSLOG(netsurf, INFO, "type %x", ftype); // i++; // } diff --git a/frontends/riscos/theme.c b/frontends/riscos/theme.c index 661beb765..341b7f7cd 100644 --- a/frontends/riscos/theme.c +++ b/frontends/riscos/theme.c @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -/** \file - * Window themes (implementation). +/** + * \file + * Window themes implementation. */ #include @@ -180,8 +181,10 @@ static void ro_gui_theme_get_available_in_dir(const char *directory) (osgbpb_info_list *) &info, 1, context, sizeof(info), 0, &read_count, &context); if (error) { - LOG("xosgbpb_dir_entries_info: 0x%x: %s", - error->errnum, error->errmess); + NSLOG(netsurf, INFO, + "xosgbpb_dir_entries_info: 0x%x: %s", + error->errnum, + error->errmess); if (error->errnum == 0xd6) /* no such dir */ return; ro_warn_user("MiscError", error->errmess); diff --git a/frontends/windows/font.c b/frontends/windows/font.c index 75464f992..37ccf23fe 100644 --- a/frontends/windows/font.c +++ b/frontends/windows/font.c @@ -309,10 +309,11 @@ win32_font_split(const plot_font_style_t *style, } } -/* - LOG("ret %d Split %u chars at %ipx: Split at char %i (%ipx) - %.*s", - ret, length, x, *char_offset, *actual_x, *char_offset, string); -*/ + + NSLOG(netsurf, DEEPDEBUG, + "ret %d Split %u chars at %ipx: Split at char %i (%ipx) - %.*s", + ret, length, x, *char_offset, *actual_x, *char_offset, string); + return ret; } diff --git a/frontends/windows/windbg.h b/frontends/windows/windbg.h index b2d8640f4..6cd9f97f8 100644 --- a/frontends/windows/windbg.h +++ b/frontends/windows/windbg.h @@ -24,11 +24,13 @@ const char *msg_num_to_name(int msg); void win_perror(const char *lpszFunction); -#define LOG_WIN_MSG(h, m, w, l) \ - if (((m) != WM_SETCURSOR) && \ - ((m) != WM_MOUSEMOVE) && \ - ((m) != WM_NCHITTEST) && \ - ((m) != WM_ENTERIDLE)) \ - LOG("%s, hwnd %p, w 0x%x, l 0x%Ix", msg_num_to_name(m), h, w, l); +#define LOG_WIN_MSG(h, m, w, l) \ + if (((m) != WM_SETCURSOR) && \ + ((m) != WM_MOUSEMOVE) && \ + ((m) != WM_NCHITTEST) && \ + ((m) != WM_ENTERIDLE)) \ + NSLOG(netsurf, INFO, \ + "%s, hwnd %p, w 0x%x, l 0x%Ix", \ + msg_num_to_name(m), h, w, l) #endif diff --git a/frontends/windows/window.c b/frontends/windows/window.c index 20db25a56..5c5dc6731 100644 --- a/frontends/windows/window.c +++ b/frontends/windows/window.c @@ -163,7 +163,8 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct gui_window *gw) gw->mainmenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU_MAIN)); gw->rclick = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU_CONTEXT)); - NSLOG(netsurf, INFO, "creating hInstance %p GUI window %p", + NSLOG(netsurf, INFO, + "creating hInstance %p GUI window %p", hInstance, gw); hwnd = CreateWindowEx(0, windowclassname_main, @@ -195,7 +196,8 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct gui_window *gw) (nsoption_int(window_height) >= 100) && (nsoption_int(window_x) >= 0) && (nsoption_int(window_y) >= 0)) { - NSLOG(netsurf, INFO, "Setting Window position %d,%d %d,%d", + NSLOG(netsurf, INFO, + "Setting Window position %d,%d %d,%d", nsoption_int(window_x), nsoption_int(window_y), nsoption_int(window_width), nsoption_int(window_height)); SetWindowPos(hwnd, HWND_TOP, @@ -1879,7 +1881,9 @@ nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect) gw->requestscrolly = rect->y0 - gw->scrolly; } - /*LOG("requestscroll x,y:%d,%d", w->requestscrollx, w->requestscrolly);*/ + NSLOG(netsurf, DEEPDEBUG, + "requestscroll x,y:%d,%d", + w->requestscrollx, w->requestscrolly); /* set the vertical scroll offset */ si.cbSize = sizeof(si); @@ -1890,7 +1894,9 @@ nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect) si.nPos = max(gw->scrolly + gw->requestscrolly, 0); si.nPos = min(si.nPos, height - gw->height); SetScrollInfo(gw->drawingarea, SB_VERT, &si, TRUE); - /*LOG("SetScrollInfo VERT min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos);*/ + NSLOG(netsurf, DEEPDEBUG, + "SetScrollInfo VERT min:%d max:%d page:%d pos:%d", + si.nMin, si.nMax, si.nPage, si.nPos); /* set the horizontal scroll offset */ si.cbSize = sizeof(si); @@ -1901,7 +1907,9 @@ nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect) si.nPos = max(gw->scrollx + gw->requestscrollx, 0); si.nPos = min(si.nPos, width - gw->width); SetScrollInfo(gw->drawingarea, SB_HORZ, &si, TRUE); - /*LOG("SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos);*/ + NSLOG(netsurf, DEEPDEBUG, + "SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", + si.nMin, si.nMax, si.nPage, si.nPos); /* Set caret position */ GetCaretPos(&p); @@ -1915,7 +1923,9 @@ nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect) r.left = 0; r.right = gw->width + 1; ScrollWindowEx(gw->drawingarea, - gw->requestscrollx, - gw->requestscrolly, &r, NULL, NULL, &redraw, SW_INVALIDATE); - /*LOG("ScrollWindowEx %d, %d", - w->requestscrollx, - w->requestscrolly);*/ + NSLOG(netsurf, DEEPDEBUG, + "ScrollWindowEx %d, %d", + - w->requestscrollx, - w->requestscrolly); gw->scrolly += gw->requestscrolly; gw->scrollx += gw->requestscrollx; gw->requestscrollx = 0; diff --git a/render/html.c b/render/html.c index 482259f1c..3cfc5e236 100644 --- a/render/html.c +++ b/render/html.c @@ -769,7 +769,7 @@ dom_event_fetcher(dom_string *type, dom_default_action_phase phase, void **pw) { - //LOG("type:%s", dom_string_data(type)); + NSLOG(netsurf, DEEPDEBUG, "type:%s", dom_string_data(type)); if (phase == DOM_DEFAULT_ACTION_END) { if (dom_string_isequal(type, corestring_dom_DOMNodeInserted)) { diff --git a/utils/nsurl/private.h b/utils/nsurl/private.h index 89d7ed49e..bc6737cd6 100644 --- a/utils/nsurl/private.h +++ b/utils/nsurl/private.h @@ -187,28 +187,44 @@ static inline void nsurl__components_destroy(struct nsurl_components *c) static inline void nsurl__dump(const nsurl *url) { if (url->components.scheme) - LOG(" Scheme: %s", lwc_string_data(url->components.scheme)); + NSLOG(netsurf, INFO,netsurf, INFO, + " Scheme: %s", + lwc_string_data(url->components.scheme)); if (url->components.username) - LOG("Username: %s", lwc_string_data(url->components.username)); + NSLOG(netsurf, INFO, + "Username: %s", + lwc_string_data(url->components.username)); if (url->components.password) - LOG("Password: %s", lwc_string_data(url->components.password)); + NSLOG(netsurf, INFO, + "Password: %s", + lwc_string_data(url->components.password)); if (url->components.host) - LOG(" Host: %s", lwc_string_data(url->components.host)); + NSLOG(netsurf, INFO, + " Host: %s", + lwc_string_data(url->components.host)); if (url->components.port) - LOG(" Port: %s", lwc_string_data(url->components.port)); + NSLOG(netsurf, INFO, + " Port: %s", + lwc_string_data(url->components.port)); if (url->components.path) - LOG(" Path: %s", lwc_string_data(url->components.path)); + NSLOG(netsurf, INFO, + " Path: %s", + lwc_string_data(url->components.path)); if (url->components.query) - LOG(" Query: %s", lwc_string_data(url->components.query)); + NSLOG(netsurf, INFO, + " Query: %s", + lwc_string_data(url->components.query)); if (url->components.fragment) - LOG("Fragment: %s", lwc_string_data(url->components.fragment)); + NSLOG(netsurf, INFO, + "Fragment: %s", + lwc_string_data(url->components.fragment)); } #endif -- cgit v1.2.1 From 86c3f3e005bb6b82be82b6883b501f6c7bf6b881 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 Sep 2017 18:26:53 +0100 Subject: update layout logging to use a catagory --- render/layout.c | 222 +++++++++++++++++++++++++++----------------------------- utils/log.c | 1 + utils/log.h | 1 + 3 files changed, 110 insertions(+), 114 deletions(-) diff --git a/render/layout.c b/render/layout.c index 962b4d403..ba1d8e150 100644 --- a/render/layout.c +++ b/render/layout.c @@ -62,10 +62,6 @@ #include "render/layout.h" #include "render/table.h" - -/* Define to enable layout debugging */ -#undef LAYOUT_DEBUG - #define AUTO INT_MIN /* Fixed point percentage (a) of an integer (b), to an integer */ @@ -342,9 +338,7 @@ layout_minmax_line(struct box *first, b->type == BOX_BR || b->type == BOX_TEXT || b->type == BOX_INLINE_END); -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "%p: min %i, max %i", b, min, max); -#endif + NSLOG(layout, DEBUG, "%p: min %i, max %i", b, min, max); if (b->type == BOX_BR) { b = b->next; @@ -624,9 +618,7 @@ layout_minmax_line(struct box *first, *line_min = min; *line_max = max; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "line_min %i, line_max %i", min, max); -#endif + NSLOG(layout, DEBUG, "line_min %i, line_max %i", min, max); assert(b != first); assert(0 <= *line_min); @@ -1469,9 +1461,7 @@ find_sides(struct box *fl, { int fy0, fy1, fx0, fx1; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "y0 %i, y1 %i, x0 %i, x1 %i", y0, y1, *x0, *x1); -#endif + NSLOG(layout, DEBUG, "y0 %i, y1 %i, x0 %i, x1 %i", y0, y1, *x0, *x1); *left = *right = 0; for (; fl; fl = fl->next_float) { @@ -1500,10 +1490,8 @@ find_sides(struct box *fl, } } -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "x0 %i, x1 %i, left %p, right %p", *x0, *x1, + NSLOG(layout, DEBUG, "x0 %i, x1 %i, left %p, right %p", *x0, *x1, *left, *right); -#endif } @@ -1965,19 +1953,22 @@ static bool layout_table(struct box *table, int available_width, /* calculate width required by cells */ for (i = 0; i != columns; i++) { -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, + + NSLOG(layout, DEBUG, "table %p, column %u: type %s, width %i, min %i, max %i", table, - i, ((const char *[]){ - "UNKNOWN", - "FIXED", - "AUTO", - "PERCENT", - "RELATIVE", - })[col[i].type], col[i].width, col[i].min, + i, + ((const char *[]){ + "UNKNOWN", + "FIXED", + "AUTO", + "PERCENT", + "RELATIVE", + })[col[i].type], + col[i].width, + col[i].min, col[i].max); -#endif + if (col[i].positioned) { positioned_columns++; @@ -1995,18 +1986,14 @@ static bool layout_table(struct box *table, int available_width, } else required_width += col[i].min; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "required_width %i", required_width); -#endif + NSLOG(layout, DEBUG, "required_width %i", required_width); } required_width += (columns + 1 - positioned_columns) * border_spacing_h; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, + NSLOG(layout, DEBUG, "width %i, min %i, max %i, auto %i, required %i", table_width, table->min_width, table->max_width, auto_width, required_width); -#endif if (auto_width < required_width) { /* table narrower than required width for columns: @@ -2455,10 +2442,8 @@ static bool layout_block_object(struct box *block) block->type == BOX_TABLE_CELL); assert(block->object); -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "block %p, object %s, width %i", block, + NSLOG(layout, DEBUG, "block %p, object %s, width %i", block, hlcache_handle_get_url(block->object), block->width); -#endif if (content_get_type(block->object) == CONTENT_HTML) { content_reformat(block->object, false, block->width, 1); @@ -2754,9 +2739,7 @@ layout_block_context(struct box *block, goto advance_to_next_box; } -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "box %p, cx %i, cy %i", box, cx, cy); -#endif + NSLOG(layout, DEBUG, "box %p, cx %i, cy %i", box, cx, cy); /* Layout (except tables). */ if (box->object) { @@ -3195,9 +3178,12 @@ layout_absolute(struct box *box, box->float_container = NULL; /* 10.3.7 */ -#ifdef LAYOUT_DEBUG - LOG("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", left, margin[LEFT], border[LEFT].width, padding[LEFT], width, padding[RIGHT], border[RIGHT].width, margin[RIGHT], right, containing_block->width); -#endif + NSLOG(layout, DEBUG, + "%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", + left, margin[LEFT], border[LEFT].width, padding[LEFT], width, + padding[RIGHT], border[RIGHT].width, margin[RIGHT], right, + containing_block->width); + if (left == AUTO && width == AUTO && right == AUTO) { if (margin[LEFT] == AUTO) @@ -3360,9 +3346,11 @@ layout_absolute(struct box *box, } } -#ifdef LAYOUT_DEBUG - LOG("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", left, margin[LEFT], border[LEFT].width, padding[LEFT], width, padding[RIGHT], border[RIGHT].width, margin[RIGHT], right, containing_block->width); -#endif + NSLOG(layout, DEBUG, + "%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", + left, margin[LEFT], border[LEFT].width, padding[LEFT], width, + padding[RIGHT], border[RIGHT].width, margin[RIGHT], right, + containing_block->width); box->x = left + margin[LEFT] + border[LEFT].width - cx; if (containing_block->type == BOX_BLOCK || @@ -3394,9 +3382,11 @@ layout_absolute(struct box *box, } /* 10.6.4 */ -#ifdef LAYOUT_DEBUG - LOG("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", top, margin[TOP], border[TOP].width, padding[TOP], height, padding[BOTTOM], border[BOTTOM].width, margin[BOTTOM], bottom, containing_block->height); -#endif + NSLOG(layout, DEBUG, + "%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", + top, margin[TOP], border[TOP].width, padding[TOP], height, + padding[BOTTOM], border[BOTTOM].width, margin[BOTTOM], bottom, + containing_block->height); if (top == AUTO && height == AUTO && bottom == AUTO) { top = static_top; @@ -3482,9 +3472,11 @@ layout_absolute(struct box *box, } } -#ifdef LAYOUT_DEBUG - LOG("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", top, margin[TOP], border[TOP].width, padding[TOP], height, padding[BOTTOM], border[BOTTOM].width, margin[BOTTOM], bottom, containing_block->height); -#endif + NSLOG(layout, DEBUG, + "%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", + top, margin[TOP], border[TOP].width, padding[TOP], height, + padding[BOTTOM], border[BOTTOM].width, margin[BOTTOM], bottom, + containing_block->height); box->y = top + margin[TOP] + border[TOP].width - cy; if (containing_block->type == BOX_BLOCK || @@ -3632,10 +3624,8 @@ static void layout_compute_relative_offset(struct box *box, int *x, int *y) bottom = -top; } -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "left %i, right %i, top %i, bottom %i", left, + NSLOG(layout, DEBUG, "left %i, right %i, top %i, bottom %i", left, right, top, bottom); -#endif *x = left; *y = top; @@ -3896,13 +3886,15 @@ layout_text_box_split(html_content *content, c2->next->prev = c2; else c2->parent->last = c2; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "split_box %p len: %u \"%.*s\"", - split_box, split_box->length, split_box->length, - split_box->text); - NSLOG(netsurf, INFO, " new_box %p len: %u \"%.*s\"", c2, - c2->length, c2->length, c2->text); -#endif + + NSLOG(layout, DEBUG, + "split_box %p len: %u \"%.*s\"", + split_box, split_box->length, split_box->length, + split_box->text); + NSLOG(layout, DEBUG, + " new_box %p len: %u \"%.*s\"", c2, + c2->length, c2->length, c2->text); + return true; } @@ -4091,10 +4083,9 @@ place_float_below(struct box *c, int width, int cx, int y, struct box *cont) yy = y > cont->cached_place_below_level ? y : cont->cached_place_below_level; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "c %p, width %i, cx %i, y %i, cont %p", c, + NSLOG(layout, DEBUG, + "c %p, width %i, cx %i, y %i, cont %p", c, width, cx, y, cont); -#endif do { y = yy; @@ -4171,8 +4162,7 @@ layout_line(struct box *first, const struct gui_layout_table *font_func = content->font_func; plot_font_style_t fstyle; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, + NSLOG(layout, DEBUG, "first %p, first->text '%.*s', width %i, y %i, cx %i, cy %i", first, (int)first->length, @@ -4181,7 +4171,6 @@ layout_line(struct box *first, *y, cx, cy); -#endif /* find sides at top of line */ x0 += cx; @@ -4210,9 +4199,9 @@ layout_line(struct box *first, /* pass 1: find height of line assuming sides at top of line: loop * body executed at least once * keep in sync with the loop in layout_minmax_line() */ -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); -#endif + + NSLOG(layout, DEBUG, "x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); + for (x = 0, b = first; x <= x1 - x0 && b != 0; b = b->next) { int min_width, max_width, min_height, max_height; @@ -4223,9 +4212,9 @@ layout_line(struct box *first, b->type == BOX_BR || b->type == BOX_TEXT || b->type == BOX_INLINE_END); -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "pass 1: b %p, x %i", b, x); -#endif + + NSLOG(layout, DEBUG, "pass 1: b %p, x %i", b, x); + if (b->type == BOX_BR) break; @@ -4434,14 +4423,12 @@ layout_line(struct box *first, space_after = space_before = 0; /* pass 2: place boxes in line: loop body executed at least once */ -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); -#endif + + NSLOG(layout, DEBUG, "x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); for (x = x_previous = 0, b = first; x <= x1 - x0 && b; b = b->next) { -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "pass 2: b %p, x %i", b, x); -#endif + + NSLOG(layout, DEBUG, "pass 2: b %p, x %i", b, x); if (b->type == BOX_INLINE_BLOCK && (css_computed_position(b->style) == @@ -4509,9 +4496,7 @@ layout_line(struct box *first, } else { /* float */ -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "float %p", b); -#endif + NSLOG(layout, DEBUG, "float %p", b); d = b->children; d->float_children = 0; @@ -4521,10 +4506,11 @@ layout_line(struct box *first, if (!layout_float(d, *width, content)) return false; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "%p : %d %d", d, d->margin[TOP], + NSLOG(layout, DEBUG, + "%p : %d %d", + d, + d->margin[TOP], d->border[TOP].width); -#endif d->x = d->margin[LEFT] + d->border[LEFT].width; d->y = d->margin[TOP] + d->border[TOP].width; @@ -4655,9 +4641,18 @@ layout_line(struct box *first, if (split == 0) w = split_box->width; -#ifdef LAYOUT_DEBUG - LOG("splitting: split_box %p \"%.*s\", spilt %zu, w %i, ""left %p, right %p, inline_count %u", split_box, (int)split_box->length, split_box->text, split, w, left, right, inline_count); -#endif + + NSLOG(layout, DEBUG, + "splitting: split_box %p \"%.*s\", spilt %zu, w %i, " + "left %p, right %p, inline_count %u", + split_box, + (int)split_box->length, + split_box->text, + split, + w, + left, + right, + inline_count); if ((split == 0 || x1 - x0 <= x + space_before + w) && !left && !right && inline_count == 1) { @@ -4675,9 +4670,9 @@ layout_line(struct box *first, b = split_box->next; } x += space_before + w; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "forcing"); -#endif + + NSLOG(layout, DEBUG, "forcing"); + } else if ((split == 0 || x1 - x0 <= x + space_before + w) && inline_count == 1) { /* first word of first box doesn't fit, but a float is @@ -4685,18 +4680,18 @@ layout_line(struct box *first, assert(left || right); used_height = 0; if (left) { -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, + + NSLOG(layout, DEBUG, "cy %i, left->y %i, left->height %i", cy, left->y, left->height); -#endif + used_height = left->y + left->height - cy + 1; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "used_height %i", + + NSLOG(layout, DEBUG, "used_height %i", used_height); -#endif + } if (right && used_height < right->y + right->height - cy + 1) @@ -4706,24 +4701,24 @@ layout_line(struct box *first, used_height = 0; b = split_box; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "moving below float"); -#endif + + NSLOG(layout, DEBUG, "moving below float"); + } else if (split == 0 || x1 - x0 <= x + space_before + w) { /* first word of box doesn't fit so leave box for next * line */ b = split_box; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "leaving for next line"); -#endif + + NSLOG(layout, DEBUG, "leaving for next line"); + } else { /* fit as many words as possible */ assert(split != 0); -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "'%.*s' %i %zu %i", + + NSLOG(layout, DEBUG, "'%.*s' %i %zu %i", (int)split_box->length, split_box->text, x1 - x0, split, w); -#endif + if (split != split_box->length) { if (!layout_text_box_split(content, &fstyle, split_box, split, w)) @@ -4731,9 +4726,9 @@ layout_line(struct box *first, b = split_box->next; } x += space_before + w; -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "fitting words"); -#endif + + NSLOG(layout, DEBUG, "fitting words"); + } move_y = true; } @@ -4871,15 +4866,14 @@ bool layout_inline_container(struct box *inline_container, int width, assert(inline_container->type == BOX_INLINE_CONTAINER); -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, + NSLOG(layout, DEBUG, "inline_container %p, width %i, cont %p, cx %i, cy %i", inline_container, width, cont, cx, cy); -#endif + has_text_children = false; for (c = inline_container->children; c; c = c->next) { @@ -4907,9 +4901,9 @@ bool layout_inline_container(struct box *inline_container, int width, * curwidth = width and have the multiword lines wrap to the min width) */ for (c = inline_container->children; c; ) { -#ifdef LAYOUT_DEBUG - NSLOG(netsurf, INFO, "c %p", c); -#endif + + NSLOG(layout, DEBUG, "c %p", c); + curwidth = inline_container->width; if (!layout_line(c, &curwidth, &y, cx, cy + y, cont, first_line, has_text_children, content, &next)) diff --git a/utils/log.c b/utils/log.c index 3beb695f6..3dbb5c6b3 100644 --- a/utils/log.c +++ b/utils/log.c @@ -97,6 +97,7 @@ NSLOG_DEFINE_CATEGORY(fetch, "objet fetching"); NSLOG_DEFINE_CATEGORY(plot, "rendering system"); NSLOG_DEFINE_CATEGORY(schedule, "scheduler"); NSLOG_DEFINE_CATEGORY(fbtk, "Framebuffer toolkit"); +NSLOG_DEFINE_CATEGORY(layout, "Layout"); static void netsurf_render_log(void *_ctx, diff --git a/utils/log.h b/utils/log.h index 1dbc9e304..1f15e1371 100644 --- a/utils/log.h +++ b/utils/log.h @@ -62,6 +62,7 @@ NSLOG_DECLARE_CATEGORY(fetch); NSLOG_DECLARE_CATEGORY(plot); NSLOG_DECLARE_CATEGORY(schedule); NSLOG_DECLARE_CATEGORY(fbtk); +NSLOG_DECLARE_CATEGORY(layout); #else /* WITH_NSLOG */ -- cgit v1.2.1 From 3a633acc3f3eb4d1199e9a7193ff293a25947031 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 Sep 2017 18:33:07 +0100 Subject: fixup junk comment close --- frontends/gtk/resources.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontends/gtk/resources.c b/frontends/gtk/resources.c index 0f0d180e0..ef92fefc8 100644 --- a/frontends/gtk/resources.c +++ b/frontends/gtk/resources.c @@ -227,7 +227,7 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) resource->path); return NSERROR_OK; } - NSLOG(netsurf, DEEPDEBUG, "gresource \"%s\" not found", resname);*/ + NSLOG(netsurf, DEEPDEBUG, "gresource \"%s\" not found", resname); free(resname); #endif -- cgit v1.2.1 From 3f3e7de6d94d66d515d43d4e921092f340788e4f Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 Sep 2017 21:07:03 +0100 Subject: do not attempt to log when output is not enabled --- utils/log.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/utils/log.c b/utils/log.c index 3dbb5c6b3..5ebe51f99 100644 --- a/utils/log.c +++ b/utils/log.c @@ -105,20 +105,21 @@ netsurf_render_log(void *_ctx, const char *fmt, va_list args) { + if (verbose_log) { + fprintf(logfile, + "%s %.*s:%i %.*s: ", + nslog_gettime(), + ctx->filenamelen, + ctx->filename, + ctx->lineno, + ctx->funcnamelen, + ctx->funcname); - fprintf(logfile, - "%s %.*s:%i %.*s: ", - nslog_gettime(), - ctx->filenamelen, - ctx->filename, - ctx->lineno, - ctx->funcnamelen, - ctx->funcname); - - vfprintf(logfile, fmt, args); + vfprintf(logfile, fmt, args); - /* Log entries aren't newline terminated add one for clarity */ - fputc('\n', logfile); + /* Log entries aren't newline terminated add one for clarity */ + fputc('\n', logfile); + } } #else -- cgit v1.2.1 From f89f7192efc43daa64c1fb591d0cfcc098b82c82 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 Sep 2017 21:08:02 +0100 Subject: fix size+t formatting in logging --- frontends/gtk/layout_pango.c | 5 +++-- render/layout.c | 16 +++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c index 9e17c3b1c..a5964eb37 100644 --- a/frontends/gtk/layout_pango.c +++ b/frontends/gtk/layout_pango.c @@ -30,6 +30,7 @@ #include "utils/log.h" #include "utils/nsoption.h" +#include "netsurf/inttypes.h" #include "netsurf/layout.h" #include "netsurf/plot_style.h" @@ -85,8 +86,8 @@ nsfont_width(const plot_font_style_t *fstyle, pango_layout_get_pixel_size(nsfont_pango_layout, width, 0); NSLOG(netsurf, DEEPDEBUG, - "fstyle: %p string:\"%.*s\", length: %u, width: %dpx", - fstyle, length, string, length, *width); + "fstyle: %p string:\"%.*s\", length: %" PRIsizet ", width: %dpx", + fstyle, (int)length, string, length, *width); return NSERROR_OK; diff --git a/render/layout.c b/render/layout.c index ba1d8e150..8c3374bcf 100644 --- a/render/layout.c +++ b/render/layout.c @@ -47,6 +47,7 @@ #include "utils/talloc.h" #include "utils/utils.h" #include "utils/nsoption.h" +#include "netsurf/inttypes.h" #include "netsurf/content.h" #include "netsurf/browser_window.h" #include "netsurf/layout.h" @@ -2442,7 +2443,7 @@ static bool layout_block_object(struct box *block) block->type == BOX_TABLE_CELL); assert(block->object); - NSLOG(layout, DEBUG, "block %p, object %s, width %i", block, + NSLOG(layout, DEBUG, "block %p, object %p, width %i", block, hlcache_handle_get_url(block->object), block->width); if (content_get_type(block->object) == CONTENT_HTML) { @@ -3888,12 +3889,17 @@ layout_text_box_split(html_content *content, c2->parent->last = c2; NSLOG(layout, DEBUG, - "split_box %p len: %u \"%.*s\"", - split_box, split_box->length, split_box->length, + "split_box %p len: %" PRIsizet " \"%.*s\"", + split_box, + split_box->length, + (int)split_box->length, split_box->text); NSLOG(layout, DEBUG, - " new_box %p len: %u \"%.*s\"", c2, - c2->length, c2->length, c2->text); + " new_box %p len: %" PRIsizet " \"%.*s\"", + c2, + c2->length, + (int)c2->length, + c2->text); return true; } -- cgit v1.2.1 From 50cbb9894111528de5225c5023b71aa9be678b1d Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 8 Sep 2017 19:38:11 +0100 Subject: Hopefully quash warning about time_t formatting on openbsd --- content/llcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/llcache.c b/content/llcache.c index 50e6188f4..fd2a52897 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -3296,7 +3296,7 @@ void llcache_clean(bool purge) NSLOG(llcache, DEBUG, "discarding backed object len:%zd age:%ld (%p) %s", object->source_len, - time(NULL) - object->last_used, + (long)(time(NULL) - object->last_used), object, nsurl_access(object->url)); -- cgit v1.2.1 From 0ad2f2de6f6a696a70b2c61b4cd9820514ef53da Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 8 Sep 2017 19:45:13 +0100 Subject: Hopefully quash LOG compile errors in BeOS --- frontends/beos/schedule.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/frontends/beos/schedule.cpp b/frontends/beos/schedule.cpp index c2caea954..7877a838b 100644 --- a/frontends/beos/schedule.cpp +++ b/frontends/beos/schedule.cpp @@ -70,8 +70,7 @@ schedule_remove(void (*callback)(void *p), void *p) { NSLOG(schedule, DEBUG, "schedule_remove() for %p(%p)", - cb->callback, - cb->context); + callback, p); if (callbacks == NULL) return; _nsbeos_callback_t cb_match; @@ -83,7 +82,7 @@ schedule_remove(void (*callback)(void *p), void *p) nserror beos_schedule(int t, void (*callback)(void *p), void *p) { - NSLOG(schedule, DEBUG, "t:%d cb:%p p:%p", t, cb->callback, cb->context); + NSLOG(schedule, DEBUG, "t:%d cb:%p p:%p", t, callback, p); if (callbacks == NULL) { callbacks = new BList; @@ -124,7 +123,7 @@ schedule_run(void) NSLOG(schedule, DEBUG, "Checking %ld callbacks to for deadline.", - this_run->CountItems()); + callbacks->CountItems()); /* Run all the callbacks which made it this far. */ for (i = 0; i < callbacks->CountItems(); ) { -- cgit v1.2.1 From a1dc9ab55f155467dbf6b48e305658661fa09c98 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 8 Sep 2017 19:46:29 +0100 Subject: Hopefully quash LOG compile errors in Windows --- frontends/windows/plot.c | 3 ++- frontends/windows/window.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontends/windows/plot.c b/frontends/windows/plot.c index 376d37252..3668e4bb6 100644 --- a/frontends/windows/plot.c +++ b/frontends/windows/plot.c @@ -580,7 +580,8 @@ line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line) { - NSLOG(plot, DEEPDEBUG, "from %d,%d to %d,%d", x0, y0, x1, y1); + NSLOG(plot, DEEPDEBUG, "from %d,%d to %d,%d", + line->x0, line->y0, line->x1, line->y1); /* ensure the plot HDC is set */ if (plot_hdc == NULL) { diff --git a/frontends/windows/window.c b/frontends/windows/window.c index 5c5dc6731..9c050a497 100644 --- a/frontends/windows/window.c +++ b/frontends/windows/window.c @@ -1883,7 +1883,7 @@ nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect) NSLOG(netsurf, DEEPDEBUG, "requestscroll x,y:%d,%d", - w->requestscrollx, w->requestscrolly); + gw->requestscrollx, gw->requestscrolly); /* set the vertical scroll offset */ si.cbSize = sizeof(si); -- cgit v1.2.1 From 9c93ed1bca859e5b5cb3c018be327fb91213c558 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 8 Sep 2017 19:56:23 +0100 Subject: Hopefully quash INFO confusion on Atari MINT platform --- frontends/atari/rootwin.c | 2 +- utils/log.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frontends/atari/rootwin.c b/frontends/atari/rootwin.c index 6576eac77..42f740093 100644 --- a/frontends/atari/rootwin.c +++ b/frontends/atari/rootwin.c @@ -244,7 +244,7 @@ int window_create(struct gui_window * gw, flags |= ( SIZER ); } if( inflags & WIDGET_STATUSBAR ) { - flags |= ( INFO ); + flags |= ( /* INFO */ 0x0010 ); } gw->root = malloc(sizeof(struct s_gui_win_root)); diff --git a/utils/log.h b/utils/log.h index 1f15e1371..7b5bcc3e8 100644 --- a/utils/log.h +++ b/utils/log.h @@ -25,6 +25,10 @@ #include "utils/errors.h" +#if defined(__MINT__) +#undef INFO +#endif + extern bool verbose_log; /** -- cgit v1.2.1 From b525293a95026fb581e311d4646dfe63e83eee3e Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 8 Sep 2017 20:42:12 +0100 Subject: Fix up log call parameters --- frontends/windows/window.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontends/windows/window.c b/frontends/windows/window.c index 9c050a497..90d076812 100644 --- a/frontends/windows/window.c +++ b/frontends/windows/window.c @@ -1922,10 +1922,19 @@ nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect) r.bottom = gw->height + 1; r.left = 0; r.right = gw->width + 1; - ScrollWindowEx(gw->drawingarea, - gw->requestscrollx, - gw->requestscrolly, &r, NULL, NULL, &redraw, SW_INVALIDATE); + ScrollWindowEx(gw->drawingarea, + - gw->requestscrollx, + - gw->requestscrolly, + &r, + NULL, + NULL, + &redraw, + SW_INVALIDATE); NSLOG(netsurf, DEEPDEBUG, "ScrollWindowEx %d, %d", - - w->requestscrollx, - w->requestscrolly); + - gw->requestscrollx, + - gw->requestscrolly); + gw->scrolly += gw->requestscrolly; gw->scrollx += gw->requestscrollx; gw->requestscrollx = 0; -- cgit v1.2.1 From 8b88e440905708ad9354fb72afff206d6208a760 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 8 Sep 2017 20:47:22 +0100 Subject: fix time_t logging --- content/llcache.c | 2 +- frontends/monkey/schedule.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/llcache.c b/content/llcache.c index fd2a52897..d48a31b9b 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -3327,7 +3327,7 @@ void llcache_clean(bool purge) NSLOG(llcache, DEBUG, "discarding fresh object len:%zd age:%ld (%p) %s", object->source_len, - time(NULL) - object->last_used, + (long)(time(NULL) - object->last_used), object, nsurl_access(object->url)); diff --git a/frontends/monkey/schedule.c b/frontends/monkey/schedule.c index d3e442a06..3d76997f4 100644 --- a/frontends/monkey/schedule.c +++ b/frontends/monkey/schedule.c @@ -185,7 +185,7 @@ int monkey_schedule_run(void) timersub(&nexttime, &tv, &rettime); NSLOG(schedule, DEBUG, "returning time to next event as %ldms", - (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000)); + (long)((rettime.tv_sec * 1000) + (rettime.tv_usec / 1000))); /* return next event time in milliseconds (24days max wait) */ return (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000); -- cgit v1.2.1 From bb056e55b1374a72ed7784a461d027fbd6360b40 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 8 Sep 2017 21:15:41 +0100 Subject: Sort out the logging so that -v etc do the right thing --- Makefile | 7 +++++ Makefile.defaults | 5 ++++ desktop/options.h | 5 ++++ utils/log.c | 76 ++++++++++++++++++++++++++++++++++++++++++++----------- utils/log.h | 12 +++++++++ utils/nsoption.c | 7 ++++- 6 files changed, 96 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 146b2f7cb..d6723e046 100644 --- a/Makefile +++ b/Makefile @@ -575,6 +575,13 @@ CXXFLAGS += -DNETSURF_HOMEPAGE=\"$(NETSURF_HOMEPAGE)\" CFLAGS += -DNETSURF_LOG_LEVEL=$(NETSURF_LOG_LEVEL) CXXFLAGS += -DNETSURF_LOG_LEVEL=$(NETSURF_LOG_LEVEL) +# and the logging filter +CFLAGS += -DNETSURF_BUILTIN_LOG_FILTER=\"$(NETSURF_BUILTIN_LOG_FILTER)\" +CXXFLAGS += -DNETSURF_BUILTIN_LOG_FILTER=\"$(NETSURF_BUILTIN_LOG_FILTER)\" +# and the verbose logging filter +CFLAGS += -DNETSURF_BUILTIN_VERBOSE_FILTER=\"$(NETSURF_BUILTIN_VERBOSE_FILTER)\" +CXXFLAGS += -DNETSURF_BUILTIN_VERBOSE_FILTER=\"$(NETSURF_BUILTIN_VERBOSE_FILTER)\" + # ---------------------------------------------------------------------------- # General make rules # ---------------------------------------------------------------------------- diff --git a/Makefile.defaults b/Makefile.defaults index d6637da9e..1f9ce5fdf 100644 --- a/Makefile.defaults +++ b/Makefile.defaults @@ -79,6 +79,11 @@ NETSURF_USE_NSLOG := AUTO # The minimum logging level *compiled* into netsurf # Valid options are: DEEPDEBUG, DEBUG, VERBOSE, INFO, WARNING, ERROR, CRITICAL NETSURF_LOG_LEVEL := INFO +# The log filter set during log initialisation before options are available +NETSURF_BUILTIN_LOG_FILTER := level:WARNING +# The log filter set during log initialisation before options are available +# if the logging level is set to verbose +NETSURF_BUILTIN_VERBOSE_FILTER := level:VERBOSE # Enable stripping the NetSurf binary # Valid options: YES, NO diff --git a/desktop/options.h b/desktop/options.h index d91898c6e..9b7064efa 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -289,3 +289,8 @@ NSOPTION_COLOUR(sys_colour_ThreeDShadow, 0x00d5d5d5) NSOPTION_COLOUR(sys_colour_Window, 0x00f1f1f1) NSOPTION_COLOUR(sys_colour_WindowFrame, 0x004e4e4e) NSOPTION_COLOUR(sys_colour_WindowText, 0x00000000) + +/** Filter for non-verbose logging */ +NSOPTION_STRING(log_filter, "level:WARNING") +/** Filter for verbose logging */ +NSOPTION_STRING(verbose_filter, "level:VERBOSE") diff --git a/utils/log.c b/utils/log.c index 5ebe51f99..68a470aa9 100644 --- a/utils/log.c +++ b/utils/log.c @@ -20,6 +20,7 @@ #include #include "utils/config.h" +#include "utils/nsoption.h" #include "utils/sys_time.h" #include "utils/utsname.h" #include "desktop/version.h" @@ -105,21 +106,43 @@ netsurf_render_log(void *_ctx, const char *fmt, va_list args) { - if (verbose_log) { - fprintf(logfile, - "%s %.*s:%i %.*s: ", - nslog_gettime(), - ctx->filenamelen, - ctx->filename, - ctx->lineno, - ctx->funcnamelen, - ctx->funcname); + fprintf(logfile, + "%s %.*s:%i %.*s: ", + nslog_gettime(), + ctx->filenamelen, + ctx->filename, + ctx->lineno, + ctx->funcnamelen, + ctx->funcname); + + vfprintf(logfile, fmt, args); + + /* Log entries aren't newline terminated add one for clarity */ + fputc('\n', logfile); +} - vfprintf(logfile, fmt, args); +/* exported interface documented in utils/log.h */ +nserror +nslog_set_filter(const char *filter) +{ + nslog_error err; + nslog_filter_t *filt = NULL; + + err = nslog_filter_from_text(filter, &filt); + if (err != NSLOG_NO_ERROR) { + if (err == NSLOG_NO_MEMORY) + return NSERROR_NOMEM; + else + return NSERROR_INVALID; + } - /* Log entries aren't newline terminated add one for clarity */ - fputc('\n', logfile); + err = nslog_filter_set_active(filt, NULL); + if (err != NSLOG_NO_ERROR) { + nslog_filter_unref(filt); + return NSERROR_NOSPACE; } + + return NSERROR_OK; } #else @@ -147,6 +170,15 @@ nslog_log(const char *file, const char *func, int ln, const char *format, ...) } } +/* exported interface documented in utils/log.h */ +nserror +nslog_set_filter(const char *filter) +{ + (void)(filter); + return NSERROR_OK; +} + + #endif nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) @@ -195,7 +227,7 @@ nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) /* ensure we actually show logging */ verbose_log = true; } - } else if (verbose_log == true) { + } else { /* default is logging to stderr */ logfile = stderr; } @@ -211,10 +243,14 @@ nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) #ifdef WITH_NSLOG - if (nslog_set_render_callback(netsurf_render_log, NULL) != NSLOG_NO_ERROR) { + if (nslog_set_filter(verbose_log ? + NETSURF_BUILTIN_VERBOSE_FILTER : + NETSURF_BUILTIN_LOG_FILTER) != NSERROR_OK) { + ret = NSERROR_INIT_FAILED; + verbose_log = false; + } else if (nslog_set_render_callback(netsurf_render_log, NULL) != NSLOG_NO_ERROR) { ret = NSERROR_INIT_FAILED; verbose_log = false; - } else if (nslog_uncork() != NSLOG_NO_ERROR) { ret = NSERROR_INIT_FAILED; verbose_log = false; @@ -241,3 +277,13 @@ nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) return ret; } + +/* exported interface documented in utils/log.h */ +nserror +nslog_set_filter_by_options() +{ + if (verbose_log) + return nslog_set_filter(nsoption_charp(verbose_filter)); + else + return nslog_set_filter(nsoption_charp(log_filter)); +} diff --git a/utils/log.h b/utils/log.h index 7b5bcc3e8..e73c8c3ee 100644 --- a/utils/log.h +++ b/utils/log.h @@ -47,6 +47,18 @@ typedef bool(nslog_ensure_t)(FILE *fptr); */ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv); +/** + * Set the logging filter. + * + * Compiles and enables the given logging filter. + */ +extern nserror nslog_set_filter(const char *filter); + +/** + * Set the logging filter according to the options. + */ +extern nserror nslog_set_filter_by_options(void); + /* ensure a logging level is defined */ #ifndef NETSURF_LOG_LEVEL #define NETSURF_LOG_LEVEL INFO diff --git a/utils/nsoption.c b/utils/nsoption.c index 15f89ca5d..09529a0d0 100644 --- a/utils/nsoption.c +++ b/utils/nsoption.c @@ -187,7 +187,7 @@ static void nsoption_validate(struct nsoption_s *opts, struct nsoption_s *defs) break; } } - if (black == true) { + if (black == true && defs != NULL) { for (cloop = NSOPTION_SYS_COLOUR_START; cloop <= NSOPTION_SYS_COLOUR_END; cloop++) { @@ -209,6 +209,9 @@ static void nsoption_validate(struct nsoption_s *opts, struct nsoption_s *defs) opts[NSOPTION_max_retried_fetches].value.u) > 60) && (opts[NSOPTION_max_retried_fetches].value.u > 1)) opts[NSOPTION_max_retried_fetches].value.u--; + + /* We ignore the result because we can't fail to validate. Yay */ + (void)nslog_set_filter_by_options(); } /** @@ -820,6 +823,8 @@ nsoption_commandline(int *pargc, char **argv, struct nsoption_s *opts) } *pargc -= (idx - 1); + nsoption_validate(opts, nsoptions_default); + return NSERROR_OK; } -- cgit v1.2.1 From c1c8ed794de6c0f2a4da18ceb6a62c9f8841aeac Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 8 Sep 2017 21:49:59 +0100 Subject: Revert "Hopefully quash INFO confusion on Atari MINT platform" This reverts commit 9c93ed1bca859e5b5cb3c018be327fb91213c558. --- frontends/atari/rootwin.c | 2 +- utils/log.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/frontends/atari/rootwin.c b/frontends/atari/rootwin.c index 42f740093..6576eac77 100644 --- a/frontends/atari/rootwin.c +++ b/frontends/atari/rootwin.c @@ -244,7 +244,7 @@ int window_create(struct gui_window * gw, flags |= ( SIZER ); } if( inflags & WIDGET_STATUSBAR ) { - flags |= ( /* INFO */ 0x0010 ); + flags |= ( INFO ); } gw->root = malloc(sizeof(struct s_gui_win_root)); diff --git a/utils/log.h b/utils/log.h index e73c8c3ee..a94afc130 100644 --- a/utils/log.h +++ b/utils/log.h @@ -25,10 +25,6 @@ #include "utils/errors.h" -#if defined(__MINT__) -#undef INFO -#endif - extern bool verbose_log; /** -- cgit v1.2.1 From 053fd7b5830b4adfe9703be281f6ecfa68e0410b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 8 Sep 2017 21:57:15 +0100 Subject: Fix atari INFO macro name collision --- frontends/atari/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/frontends/atari/Makefile b/frontends/atari/Makefile index b4fb16ec1..a2f27e2f2 100644 --- a/frontends/atari/Makefile +++ b/frontends/atari/Makefile @@ -47,6 +47,7 @@ CFLAGS += -U__STRICT_ANSI__ -std=c99 -Dsmall -Dnsatari \ -D_BSD_SOURCE \ -D_XOPEN_SOURCE=600 \ -D_POSIX_C_SOURCE=200112L \ + -DNSLOG_LEVEL_0x0010=NSLOG_LEVEL_INFO \ $(shell $(PKG_CONFIG) --cflags openssl ) \ $(shell $(PKG_CONFIG) --cflags libcurl ) -- cgit v1.2.1 From 4837ffb0ad6099b9a301fc040ad0e99be681bec3 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 9 Sep 2017 09:31:34 +0100 Subject: add some basic logging documentation --- docs/logging.md | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ docs/mainpage.md | 5 ++++ 2 files changed, 95 insertions(+) create mode 100644 docs/logging.md diff --git a/docs/logging.md b/docs/logging.md new file mode 100644 index 000000000..41c7ea1bd --- /dev/null +++ b/docs/logging.md @@ -0,0 +1,90 @@ +NetSurf logging +=============== + +NetSurf has a large number of internal diagnostic messages which can +be viewed by the developer (or user if they wish) + +Each message has a category and a level which can be used to control +which messages are displayed. + +The message category is used to allow filters to separate messages of +the same level from different sources. + +The logging levels, from low to high, are: + + - DEEPDEBUG + - DEBUG + - VERBOSE + - INFO + - WARNING + - ERROR + - CRITICAL + +Compilation control +------------------- + +At compilation time the logging behaviour can be controlled by using +configuration overrides in a Makefile.config The parameters are: + + - NETSURF_USE_NSLOG + This controls if the NetSurf logging library (nslog) is used to + allow comprehensive filtering of messages. The value defaults to + AUTO which will use pkg-config to locate the library and enable if + present. If set to NO or the library cannot be located the browsers + logging will revert to simple boolean enabled/disabled logging + controlled by the -v command line switch. + + - NETSURF_LOG_LEVEL + This controls what level of message is compiled into the NetSurf + binary. The default value is VERBOSE and when not using nslog this + value is also used to select what level of logging is shown with the + -v command line switch. + + - NETSURF_BUILTIN_LOG_FILTER + When using nslog this sets the default non-verbose filter. The + default value ("level:WARNING") shows all messages of level WARNING + and above + + - NETSURF_BUILTIN_VERBOSE_FILTER + When using nslog this sets the default verbose filter. The default + value ("level:VERBOSE") shows all messages of level VERBOSE and + above. The verbose level is selected from the commandline with the + -v switch + +Command line +------------ + +The main command line switches that control logging are: + + - -v + switches between the normal and verbose levels + + - -V + Send the logging to a file instead of standard output + + - -log_filter= + Set the non verbose filter + + - -log_verbose_filter= + Set the verbose filter + +Options +------- + +The logging filters can be configured by setting the log_filter and +log_verbose_filter options. + +Adding messages +--------------- + +Messages can be easily added by including the utils/log.h header and +he NSLOG() macro. for example + + NSLOG(netsurf, INFO, "An example message %d", example_func()); + +nslog +----- + +If the nslog library is used it allows for application of a filter to +control which messages are output. The nslog filter syntax is best +viewed in its [documentation](http://source.netsurf-browser.org/libnslog.git/tree/docs/mainpage.md) diff --git a/docs/mainpage.md b/docs/mainpage.md index 41f26d441..fa72d1464 100644 --- a/docs/mainpage.md +++ b/docs/mainpage.md @@ -15,6 +15,11 @@ There are some basic user guides for the The [core user options](docs/netsurf-options.md) of the browser are documented which are augmented by each frontend in a specific manner. +### Logging + +The [logging](docs/logging.md) interface controls debug and error +messages not output through the GUI. + Documented API -------------- -- cgit v1.2.1 From 1eb19587bf3d96712d8d3313ecb32e92e1fcbd30 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 9 Sep 2017 10:59:21 +0100 Subject: Fix up tests with nslog changes --- test/data/Choices-all | 2 ++ test/nsoption.c | 3 +++ test/urldbtest.c | 3 +++ 3 files changed, 8 insertions(+) diff --git a/test/data/Choices-all b/test/data/Choices-all index b9cab1fb3..9f2e18377 100644 --- a/test/data/Choices-all +++ b/test/data/Choices-all @@ -95,6 +95,8 @@ sys_colour_ThreeDShadow:d5d5d5 sys_colour_Window:f1f1f1 sys_colour_WindowFrame:4e4e4e sys_colour_WindowText:000000 +log_filter:level:WARNING +verbose_filter:level:VERBOSE render_resample:1 downloads_clear:0 request_overwrite:1 diff --git a/test/nsoption.c b/test/nsoption.c index 5874c94b6..8f2388a5b 100644 --- a/test/nsoption.c +++ b/test/nsoption.c @@ -39,6 +39,9 @@ const char *test_choices_all_path = "test/data/Choices-all"; const char *test_choices_full_path = "test/data/Choices-full"; const char *test_choices_missing_path = "test/data/Choices-missing"; +/* Stubs */ +nserror nslog_set_filter_by_options() { return NSERROR_OK; } + /** * generate test output filenames */ diff --git a/test/urldbtest.c b/test/urldbtest.c index 3cba8835f..620ce4cb5 100644 --- a/test/urldbtest.c +++ b/test/urldbtest.c @@ -77,6 +77,9 @@ struct test_urls { #define NELEMS(x) (sizeof(x) / sizeof((x)[0])) +/* Stubs */ +nserror nslog_set_filter_by_options() { return NSERROR_OK; } + /** * generate test output filenames */ -- cgit v1.2.1 From d17b710fa945276b186a67abf05844095583738e Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Sep 2017 14:31:22 +0100 Subject: GTK: Corewindow: Fix modifier keys on mouse click. Modifiers were getting unset for the click (release) events. --- frontends/gtk/corewindow.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontends/gtk/corewindow.c b/frontends/gtk/corewindow.c index 53ee17333..6ca5d228f 100644 --- a/frontends/gtk/corewindow.c +++ b/frontends/gtk/corewindow.c @@ -145,6 +145,7 @@ nsgtk_cw_button_release_event(GtkWidget *widget, { struct nsgtk_corewindow *nsgtk_cw = (struct nsgtk_corewindow *)g; struct nsgtk_corewindow_mouse *mouse = &nsgtk_cw->mouse_state; + bool was_drag = false; /* only button 1 clicks are considered double clicks. If the * mouse state is PRESS then we are waiting for a release to @@ -168,9 +169,11 @@ nsgtk_cw_button_release_event(GtkWidget *widget, } else if (mouse->state & BROWSER_MOUSE_HOLDING_1) { mouse->state ^= (BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON); + was_drag = true; } else if (mouse->state & BROWSER_MOUSE_HOLDING_2) { mouse->state ^= (BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_ON); + was_drag = true; } /* Handle modifiers being removed */ @@ -188,9 +191,10 @@ nsgtk_cw_button_release_event(GtkWidget *widget, } /* end drag with modifiers */ - if (mouse->state & (BROWSER_MOUSE_MOD_1 | - BROWSER_MOUSE_MOD_2 | - BROWSER_MOUSE_MOD_3)) { + if (was_drag && (mouse->state & ( + BROWSER_MOUSE_MOD_1 | + BROWSER_MOUSE_MOD_2 | + BROWSER_MOUSE_MOD_3))) { mouse->state = BROWSER_MOUSE_HOVER; } -- cgit v1.2.1 From 02a8b5bca0cfe8307624dc7c2bf736069c0a2e0b Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Sep 2017 14:38:13 +0100 Subject: Treeview: Split out textarea construction helper. --- desktop/treeview.c | 66 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 259ec0590..df5c5e9b7 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -3367,6 +3367,47 @@ static void treeview_textarea_callback(void *data, struct textarea_msg *msg) } +/** + * Helper to create a textarea. + * + * \param[in] tree The treeview we're creating the textarea for. + * \param[in] width The width of the textarea. + * \param[in] height The height of the textarea. + * \param[in] text The text style to use for the text area. + * \param[in] ta_callback The textarea callback function to give the textarea. + * \return the textarea pointer on success, or NULL on failure. + */ +static struct textarea *treeview_create_textarea( + treeview *tree, + int width, + int height, + plot_font_style_t text, + textarea_client_callback ta_callback) +{ + /* Configure the textarea */ + textarea_flags ta_flags = TEXTAREA_INTERNAL_CARET; + textarea_setup ta_setup = { + .text = text, + .width = width, + .height = height, + .pad_top = 0, + .pad_left = 2, + .pad_right = 2, + .pad_bottom = 0, + .border_width = 1, + .border_col = 0x000000, + .selected_bg = 0x000000, + .selected_text = 0xffffff, + }; + + ta_setup.text.foreground = 0x000000; + ta_setup.text.background = 0xffffff; + + /* Create text area */ + return textarea_create(ta_flags, &ta_setup, ta_callback, tree); +} + + /** * Start edit of node field, at given y-coord, if editable * @@ -3392,8 +3433,6 @@ treeview_edit_node_at_point(treeview *tree, int field_y = node_y; int field_x; int width, height; - textarea_setup ta_setup; - textarea_flags ta_flags; bool success; /* If the main field is editable, make field_data point to it */ @@ -3435,31 +3474,14 @@ treeview_edit_node_at_point(treeview *tree, /* Get window width/height */ treeview__cw_get_window_dimensions(tree, &width, &height); - /* Anow textarea width/height */ + /* Calculate textarea width/height */ field_x = n->inset + tree_g.step_width + tree_g.icon_step - 3; width -= field_x; height = tree_g.line_height; - /* Configure the textarea */ - ta_flags = TEXTAREA_INTERNAL_CARET; - - ta_setup.width = width; - ta_setup.height = height; - ta_setup.pad_top = 0; - ta_setup.pad_right = 2; - ta_setup.pad_bottom = 0; - ta_setup.pad_left = 2; - ta_setup.border_width = 1; - ta_setup.border_col = 0x000000; - ta_setup.selected_text = 0xffffff; - ta_setup.selected_bg = 0x000000; - ta_setup.text = plot_style_odd.text; - ta_setup.text.foreground = 0x000000; - ta_setup.text.background = 0xffffff; - /* Create text area */ - tree->edit.textarea = textarea_create(ta_flags, &ta_setup, - treeview_textarea_callback, tree); + tree->edit.textarea = treeview_create_textarea(tree, width, height, + plot_style_odd.text, treeview_textarea_callback); if (tree->edit.textarea == NULL) { return false; } -- cgit v1.2.1 From ec94d5f812723c586b26d4c1700b641e5cb2f7a0 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 10 Sep 2017 10:30:27 +0100 Subject: move history bitmap thumbnail into the page information structure --- desktop/browser_history.c | 20 ++++++++++++-------- desktop/browser_private.h | 2 +- desktop/local_history.c | 4 ++-- desktop/save_complete.c | 15 +++++++++------ 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/desktop/browser_history.c b/desktop/browser_history.c index c7d010419..ba122f30d 100644 --- a/desktop/browser_history.c +++ b/desktop/browser_history.c @@ -326,19 +326,21 @@ nserror browser_window_history_add(struct browser_window *bw, } entry->page.url = nsurl_ref(nsurl); - entry->page.frag_id = frag_id ? lwc_string_ref(frag_id) : 0; - + entry->page.frag_id = frag_id ? lwc_string_ref(frag_id) : NULL; entry->page.title = title; + entry->page.bitmap = NULL; + entry->back = history->current; entry->next = 0; entry->forward = entry->forward_pref = entry->forward_last = 0; entry->children = 0; - entry->bitmap = 0; + if (history->current) { - if (history->current->forward_last) + if (history->current->forward_last) { history->current->forward_last->next = entry; - else + } else { history->current->forward = entry; + } history->current->forward_pref = entry; history->current->forward_last = entry; history->current->children++; @@ -373,7 +375,7 @@ nserror browser_window_history_add(struct browser_window *bw, } } } - entry->bitmap = bitmap; + entry->page.bitmap = bitmap; browser_window_history__layout(history); @@ -392,7 +394,9 @@ nserror browser_window_history_update(struct browser_window *bw, history = bw->history; - if (!history || !history->current || !history->current->bitmap) { + if (!history || + !history->current || + !history->current->page.bitmap) { return NSERROR_INVALID; } @@ -407,7 +411,7 @@ nserror browser_window_history_update(struct browser_window *bw, free(history->current->page.title); history->current->page.title = title; - guit->bitmap->render(history->current->bitmap, content); + guit->bitmap->render(history->current->page.bitmap, content); return NSERROR_OK; } diff --git a/desktop/browser_private.h b/desktop/browser_private.h index 8bbc573eb..3cdef5c89 100644 --- a/desktop/browser_private.h +++ b/desktop/browser_private.h @@ -45,6 +45,7 @@ struct history_page { struct nsurl *url; /**< Page URL, never NULL. */ lwc_string *frag_id; /** Fragment identifier, or NULL. */ char *title; /**< Page title, never NULL. */ + struct bitmap *bitmap; /**< Thumbnail bitmap, or NULL. */ }; /** @@ -61,7 +62,6 @@ struct history_entry { unsigned int children; /**< Number of children. */ int x; /**< Position of node. */ int y; /**< Position of node. */ - struct bitmap *bitmap; /**< Thumbnail bitmap, or 0. */ }; /** diff --git a/desktop/local_history.c b/desktop/local_history.c index 01222e204..3219de90c 100644 --- a/desktop/local_history.c +++ b/desktop/local_history.c @@ -144,9 +144,9 @@ redraw_entry(struct history *history, } /* Only attempt to plot bitmap if it is present */ - if (entry->bitmap != NULL) { + if (entry->page.bitmap != NULL) { res = ctx->plot->bitmap(ctx, - entry->bitmap, + entry->page.bitmap, entry->x + x, entry->y + y, WIDTH, HEIGHT, diff --git a/desktop/save_complete.c b/desktop/save_complete.c index cd1ac53b4..9a88ad180 100644 --- a/desktop/save_complete.c +++ b/desktop/save_complete.c @@ -195,10 +195,12 @@ 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 *save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx, - const char *source, unsigned long size, const nsurl *base, - unsigned long *osize) +static char * +save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx, + const char *source, + unsigned long size, + const nsurl *base, + unsigned long *osize) { char *rewritten; unsigned long offset = 0; @@ -207,8 +209,9 @@ static char *save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx, /* count number occurrences of @import to (over)estimate result size */ /* can't use strstr because source is not 0-terminated string */ - for (offset = 0; SLEN("@import") < size && - offset <= size - SLEN("@import"); offset++) { + for (offset = 0; + (SLEN("@import") < size) && (offset <= (size - SLEN("@import"))); + offset++) { if (source[offset] == '@' && ascii_to_lower(source[offset + 1]) == 'i' && ascii_to_lower(source[offset + 2]) == 'm' && -- cgit v1.2.1 From 8123e65351788fa633962c4f5e1bb41f1ef346e2 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 10 Sep 2017 14:22:05 +0100 Subject: Finalise nslog layer properly in closedown --- frontends/amiga/gui.c | 3 +++ frontends/atari/gui.c | 4 ++++ frontends/beos/gui.cpp | 6 ++++++ frontends/framebuffer/gui.c | 3 +++ frontends/gtk/gui.c | 3 +++ frontends/monkey/main.c | 3 +++ frontends/riscos/gui.c | 3 +++ frontends/windows/main.c | 3 +++ utils/log.c | 18 +++++++++++++++++- utils/log.h | 9 +++++++++ 10 files changed, 54 insertions(+), 1 deletion(-) diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index e4acf70c2..fbaa2acfb 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -5841,6 +5841,9 @@ int main(int argc, char** argv) free(current_user_dir); FreeVec(current_user_faviconcache); + /* finalise logging */ + nslog_finalise(); + #ifndef __amigaos4__ /* OS3 low memory handler */ ami_memory_fini(memhandler); diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c index a400285d3..6ee63b301 100644 --- a/frontends/atari/gui.c +++ b/frontends/atari/gui.c @@ -1225,6 +1225,10 @@ int main(int argc, char** argv) fclose(stderr); #endif NSLOG(netsurf, INFO, "exit_gem"); + + /* finalise logging */ + nslog_finalise(); + exit_gem(); return 0; diff --git a/frontends/beos/gui.cpp b/frontends/beos/gui.cpp index 69a0d6dde..19f8eac49 100644 --- a/frontends/beos/gui.cpp +++ b/frontends/beos/gui.cpp @@ -1066,6 +1066,12 @@ int main(int argc, char** argv) netsurf_exit(); + /* finalise options */ + nsoption_finalise(nsoptions, nsoptions_default); + + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c index ebd0b7b66..e252f25f3 100644 --- a/frontends/framebuffer/gui.c +++ b/frontends/framebuffer/gui.c @@ -2215,6 +2215,9 @@ main(int argc, char** argv) /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c index 6a61b3d06..8c9ad088d 100644 --- a/frontends/gtk/gui.c +++ b/frontends/gtk/gui.c @@ -1198,5 +1198,8 @@ int main(int argc, char** argv) /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/monkey/main.c b/frontends/monkey/main.c index d697f271f..53cde5a72 100644 --- a/frontends/monkey/main.c +++ b/frontends/monkey/main.c @@ -404,5 +404,8 @@ main(int argc, char **argv) /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c index 9d651bc10..cfc513f72 100644 --- a/frontends/riscos/gui.c +++ b/frontends/riscos/gui.c @@ -2557,5 +2557,8 @@ int main(int argc, char** argv) netsurf_exit(); nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/windows/main.c b/frontends/windows/main.c index 98e90be80..a3a7c2b39 100644 --- a/frontends/windows/main.c +++ b/frontends/windows/main.c @@ -419,5 +419,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/utils/log.c b/utils/log.c index 68a470aa9..e267b3179 100644 --- a/utils/log.c +++ b/utils/log.c @@ -137,8 +137,8 @@ nslog_set_filter(const char *filter) } err = nslog_filter_set_active(filt, NULL); + filt = nslog_filter_unref(filt); if (err != NSLOG_NO_ERROR) { - nslog_filter_unref(filt); return NSERROR_NOSPACE; } @@ -287,3 +287,19 @@ nslog_set_filter_by_options() else return nslog_set_filter(nsoption_charp(log_filter)); } + +/* exported interface documented in utils/log.h */ +void +nslog_finalise() +{ + NSLOG(netsurf, INFO, + "Finalising logging, please report any further messages"); + verbose_log = true; + if (logfile != stderr) { + fclose(logfile); + logfile = stderr; + } +#ifdef WITH_NSLOG + nslog_cleanup(); +#endif +} diff --git a/utils/log.h b/utils/log.h index a94afc130..b773ec4a2 100644 --- a/utils/log.h +++ b/utils/log.h @@ -43,6 +43,15 @@ typedef bool(nslog_ensure_t)(FILE *fptr); */ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv); +/** + * Shut down the logging system. + * + * Shuts down the logging subsystem, resetting to verbose logging and output + * to stderr. Note, if logging is done after calling this, it will be sent + * to stderr without filtering. + */ +extern void nslog_finalise(void); + /** * Set the logging filter. * -- cgit v1.2.1 From 521651ea5194ec1aac65d95c8e0bd33000b6bad9 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Sep 2017 18:24:18 +0100 Subject: Treeview: API: Add searchable flag for treeview creation. --- desktop/treeview.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop/treeview.h b/desktop/treeview.h index 45469b77f..b9347d2f0 100644 --- a/desktop/treeview.h +++ b/desktop/treeview.h @@ -76,7 +76,8 @@ typedef enum { TREEVIEW_NO_MOVES = (1 << 0), /**< No node drags */ TREEVIEW_NO_DELETES = (1 << 1), /**< No node deletes */ TREEVIEW_READ_ONLY = TREEVIEW_NO_MOVES | TREEVIEW_NO_DELETES, - TREEVIEW_DEL_EMPTY_DIRS = (1 << 2) /**< Delete dirs on empty */ + TREEVIEW_DEL_EMPTY_DIRS = (1 << 2), /**< Delete dirs on empty */ + TREEVIEW_SEARCHABLE = (1 << 3), /**< Treeview has search bar */ } treeview_flags; /** -- cgit v1.2.1 From 1420d01a2190ef7a4d6ded135c59b697e44194b4 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Sep 2017 21:18:19 +0100 Subject: Treeview: Add search drag type to enumeration. --- desktop/treeview.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index df5c5e9b7..8b7f8a75a 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -171,7 +171,8 @@ struct treeview_drag { TV_DRAG_NONE, TV_DRAG_SELECTION, TV_DRAG_MOVE, - TV_DRAG_TEXTAREA + TV_DRAG_TEXTAREA, + TV_DRAG_SEARCH, } type; /**< Drag type */ treeview_node *start_node; /**< Start node */ bool selected; /**< Start node is selected */ -- cgit v1.2.1 From 3d2adf4330851a147763c9d853f00fc914f1b8f9 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Sep 2017 18:35:24 +0100 Subject: Treeview: Create and destroy a textarea for search. --- desktop/treeview.c | 166 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 43 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 8b7f8a75a..e41fdc43e 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -207,6 +207,15 @@ struct treeview_edit { }; +/** + * Treeview search box details + */ +struct treeview_search { + struct textarea *textarea; /**< Search box. Never NULL. */ + bool active; /**< Whether the search box is active */ +}; + + /** * The treeview context */ @@ -225,6 +234,8 @@ struct treeview { struct treeview_move move; /**< Move drag details */ struct treeview_edit edit; /**< Edit details */ + struct treeview_search search; /**< Treeview search box */ + const struct treeview_callback_table *callbacks; /**< For node events */ const struct core_window_callback_table *cw_t; /**< Window cb table */ @@ -1504,6 +1515,94 @@ treeview_delete_node(treeview *tree, } +/** + * Helper to create a textarea. + * + * \param[in] tree The treeview we're creating the textarea for. + * \param[in] width The width of the textarea. + * \param[in] height The height of the textarea. + * \param[in] border The border colour to use. + * \param[in] background The background colour to use. + * \param[in] foreground The foreground colour to use. + * \param[in] text The text style to use for the text area. + * \param[in] ta_callback The textarea callback function to give the textarea. + * \return the textarea pointer on success, or NULL on failure. + */ +static struct textarea *treeview__create_textarea( + treeview *tree, + int width, + int height, + colour border, + colour background, + colour foreground, + plot_font_style_t text, + textarea_client_callback ta_callback) +{ + /* Configure the textarea */ + textarea_flags ta_flags = TEXTAREA_INTERNAL_CARET; + textarea_setup ta_setup = { + .text = text, + .width = width, + .height = height, + .pad_top = 0, + .pad_left = 2, + .pad_right = 2, + .pad_bottom = 0, + .border_width = 1, + .border_col = border, + .selected_bg = foreground, + .selected_text = background, + }; + + ta_setup.text.foreground = foreground; + ta_setup.text.background = background; + + /* Create text area */ + return textarea_create(ta_flags, &ta_setup, ta_callback, tree); +} + + +/** + * Callback for textarea_create, in desktop/treeview.h + * + * \param data treeview context + * \param msg textarea message + */ +static void treeview_textarea_search_callback(void *data, + struct textarea_msg *msg) +{ + treeview *tree = data; + struct rect *r; + + switch (msg->type) { + case TEXTAREA_MSG_DRAG_REPORT: + if (msg->data.drag == TEXTAREA_DRAG_NONE) { + /* Textarea drag finished */ + tree->drag.type = TV_DRAG_NONE; + } else { + /* Textarea drag started */ + tree->drag.type = TV_DRAG_SEARCH; + } + treeview__cw_drag_status(tree, tree->drag.type); + break; + + case TEXTAREA_MSG_REDRAW_REQUEST: + r = &msg->data.redraw; + r->x0 += tree_g.window_padding + tree_g.icon_size; + r->y0 += 0; + r->x1 += 600; + r->y1 += tree_g.line_height; + + /* Redraw the textarea */ + cw_invalidate_area(tree, r); + break; + + default: + break; + } +} + + /* Exported interface, documented in treeview.h */ nserror treeview_create(treeview **tree, @@ -1583,6 +1682,23 @@ treeview_create(treeview **tree, (*tree)->edit.textarea = NULL; (*tree)->edit.node = NULL; + if (flags & TREEVIEW_SEARCHABLE) { + (*tree)->search.textarea = treeview__create_textarea( + *tree, 600, tree_g.line_height, + plot_style_even.text.background, + plot_style_even.text.background, + plot_style_even.text.foreground, + plot_style_odd.text, + treeview_textarea_search_callback); + if ((*tree)->search.textarea == NULL) { + treeview_destroy(*tree); + return NSERROR_NOMEM; + } + } else { + (*tree)->search.textarea = NULL; + } + (*tree)->search.active = false; + (*tree)->flags = flags; (*tree)->cw_t = cw_t; @@ -1640,6 +1756,10 @@ nserror treeview_destroy(treeview *tree) } free(tree->fields); + if (tree->search.textarea != NULL) { + textarea_destroy(tree->search.textarea); + } + /* Free treeview */ free(tree); @@ -3368,47 +3488,6 @@ static void treeview_textarea_callback(void *data, struct textarea_msg *msg) } -/** - * Helper to create a textarea. - * - * \param[in] tree The treeview we're creating the textarea for. - * \param[in] width The width of the textarea. - * \param[in] height The height of the textarea. - * \param[in] text The text style to use for the text area. - * \param[in] ta_callback The textarea callback function to give the textarea. - * \return the textarea pointer on success, or NULL on failure. - */ -static struct textarea *treeview_create_textarea( - treeview *tree, - int width, - int height, - plot_font_style_t text, - textarea_client_callback ta_callback) -{ - /* Configure the textarea */ - textarea_flags ta_flags = TEXTAREA_INTERNAL_CARET; - textarea_setup ta_setup = { - .text = text, - .width = width, - .height = height, - .pad_top = 0, - .pad_left = 2, - .pad_right = 2, - .pad_bottom = 0, - .border_width = 1, - .border_col = 0x000000, - .selected_bg = 0x000000, - .selected_text = 0xffffff, - }; - - ta_setup.text.foreground = 0x000000; - ta_setup.text.background = 0xffffff; - - /* Create text area */ - return textarea_create(ta_flags, &ta_setup, ta_callback, tree); -} - - /** * Start edit of node field, at given y-coord, if editable * @@ -3481,8 +3560,9 @@ treeview_edit_node_at_point(treeview *tree, height = tree_g.line_height; /* Create text area */ - tree->edit.textarea = treeview_create_textarea(tree, width, height, - plot_style_odd.text, treeview_textarea_callback); + tree->edit.textarea = treeview__create_textarea(tree, width, height, + 0x000000, 0xffffff, 0x000000, plot_style_odd.text, + treeview_textarea_callback); if (tree->edit.textarea == NULL) { return false; } -- cgit v1.2.1 From f877069399608c8805d871b0ff08852186467490 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Sep 2017 18:42:35 +0100 Subject: Treeview: Add search bar rendering to redraw function. --- desktop/treeview.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/desktop/treeview.c b/desktop/treeview.c index e41fdc43e..acf49ce15 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -2175,6 +2175,40 @@ treeview_redraw(treeview *tree, data.repeat_x = false; data.repeat_y = false; + if (tree->flags & TREEVIEW_SEARCHABLE) { + if (render_y < r.y1) { + enum treeview_resource_id icon = TREE_RES_SEARCH; + + /* Fill the blank area at the bottom */ + rect.x0 = r.x0; + rect.y0 = render_y; + rect.x1 = r.x1; + rect.y1 = render_y + tree_g.line_height; + new_ctx.plot->rectangle(&new_ctx, &plot_style_even.bg, + &rect); + + if (treeview_res[icon].ready) { + /* Icon resource is available */ + data.x = tree_g.window_padding; + data.y = render_y + ((tree_g.line_height - + treeview_res[icon].height + 1) / + 2); + data.background_colour = plot_style_even.bg. + fill_colour; + + content_redraw(treeview_res[icon].c, + &data, &r, &new_ctx); + } + + textarea_redraw(tree->search.textarea, + x + tree_g.window_padding + + tree_g.icon_step, y, + plot_style_even.bg.fill_colour, 1.0, + &r, &new_ctx); + } + render_y += tree_g.line_height; + } + while (node != NULL) { int i; next = (node->flags & TV_NFLAGS_EXPANDED) ? -- cgit v1.2.1 From adbcb7f1b904c1a725fab4be7323a350f9ce02a8 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Sep 2017 18:45:22 +0100 Subject: Treeview: Update treeview mouse handling to offset for search bar presence. --- desktop/treeview.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index acf49ce15..5c0d05c1f 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -2695,7 +2695,8 @@ static bool treeview_clear_selection(treeview *tree, struct rect *rect) sw.purpose = TREEVIEW_WALK_CLEAR_SELECTION; sw.data.redraw.required = false; sw.data.redraw.rect = rect; - sw.current_y = 0; + sw.current_y = (tree->flags & TREEVIEW_SEARCHABLE) ? + tree_g.line_height : 0; treeview_walk_internal(tree->root, false, NULL, treeview_node_selection_walk_cb, &sw); @@ -2723,7 +2724,8 @@ static bool treeview_select_all(treeview *tree, struct rect *rect) sw.purpose = TREEVIEW_WALK_SELECT_ALL; sw.data.redraw.required = false; sw.data.redraw.rect = rect; - sw.current_y = 0; + sw.current_y = (tree->flags & TREEVIEW_SEARCHABLE) ? + tree_g.line_height : 0; treeview_walk_internal(tree->root, false, NULL, treeview_node_selection_walk_cb, &sw); @@ -2742,7 +2744,8 @@ static void treeview_commit_selection_drag(treeview *tree) struct treeview_selection_walk_data sw; sw.purpose = TREEVIEW_WALK_COMMIT_SELECT_DRAG; - sw.current_y = 0; + sw.current_y = (tree->flags & TREEVIEW_SEARCHABLE) ? + tree_g.line_height : 0; if (tree->drag.start.y > tree->drag.prev.y) { sw.data.drag.sel_min = tree->drag.prev.y; @@ -3967,6 +3970,8 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) { struct rect r; bool redraw = false; + int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ? + tree_g.line_height : 0; assert(tree != NULL); assert(tree->root != NULL); @@ -4023,7 +4028,7 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) } } - if (y > tree->root->height) { + if (y > tree->root->height + search_height) { /* Below tree */ r.x0 = 0; @@ -4101,7 +4106,7 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) ma.mouse = mouse; ma.x = x; ma.y = y; - ma.current_y = 0; + ma.current_y = search_height; treeview_walk_internal(tree->root, false, NULL, treeview_node_mouse_action_cb, &ma); -- cgit v1.2.1 From 3a02a4ea484685e5fce9c6c77f521670959d926b Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Sep 2017 21:24:29 +0100 Subject: Treeview: Handle mouse clicks on search bar. --- desktop/treeview.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/desktop/treeview.c b/desktop/treeview.c index 5c0d05c1f..a460f4d12 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -3981,6 +3981,23 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) textarea_mouse_action(tree->edit.textarea, mouse, x - tree->edit.x, y - tree->edit.y); return; + } else if (tree->drag.type == TV_DRAG_SEARCH || y < search_height) { + if (tree->search.active == false) { + tree->search.active = true; + if (treeview_clear_selection(tree, &r)) { + cw_invalidate_area(tree, &r); + } + } + textarea_mouse_action(tree->search.textarea, mouse, + x - tree_g.window_padding - tree_g.icon_size, + y); + return; + } else if (mouse & (BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_PRESS_2) && + tree->search.active == true) { + + tree->search.active = false; + textarea_set_caret(tree->search.textarea, -1); + return; } /* Handle textarea related mouse action */ -- cgit v1.2.1 From 43cdd742212ae0b47080717bfab028b1c78fbebc Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Sep 2017 21:23:32 +0100 Subject: Treeview: Add keypress handling to the search bar. --- desktop/treeview.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index a460f4d12..ba1056ed0 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -3281,7 +3281,7 @@ bool treeview_keypress(treeview *tree, uint32_t key) assert(tree != NULL); - /* Pass to textarea, if editing in progress */ + /* Pass to any textarea, if editing in progress */ if (tree->edit.textarea != NULL) { switch (key) { case NS_KEY_ESCAPE: @@ -3294,6 +3294,23 @@ bool treeview_keypress(treeview *tree, uint32_t key) default: return textarea_keypress(tree->edit.textarea, key); } + } else if (tree->search.active == true) { + switch (key) { + case NS_KEY_ESCAPE: + textarea_set_text(tree->search.textarea, ""); + textarea_set_caret(tree->search.textarea, 0); + r.x0 = tree_g.window_padding + tree_g.icon_size; + r.x1 = 600; + r.y0 = 0; + r.y1 = tree_g.line_height; + cw_invalidate_area(tree, &r); + return true; + case NS_KEY_NL: + case NS_KEY_CR: + return true; + default: + return textarea_keypress(tree->search.textarea, key); + } } /* Keypress to be handled by treeview */ -- cgit v1.2.1 From 37127c4a52b6d85faef379ad6c6e07f63b1ccf46 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 10 Sep 2017 11:55:25 +0100 Subject: Treeview: Ensure window extents take account of search bar presence. --- desktop/treeview.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index ba1056ed0..277955078 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -348,8 +348,12 @@ static inline void treeview__cw_update_size( const struct treeview *tree, int width, int height) { + int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ? + tree_g.line_height : 0; + if (tree->cw_t != NULL) { - tree->cw_t->update_size(tree->cw_h, width, height); + tree->cw_t->update_size(tree->cw_h, width, + height + search_height); } } @@ -4151,12 +4155,15 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) /* Exported interface, documented in treeview.h */ int treeview_get_height(treeview *tree) { + int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ? + tree_g.line_height : 0; + assert(tree != NULL); assert(tree->root != NULL); treeview__cw_update_size(tree, -1, tree->root->height); - return tree->root->height; + return tree->root->height + search_height; } -- cgit v1.2.1 From 50688cde51ae5f78af59a43d56ad687f62e9bfe5 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 10 Sep 2017 11:57:02 +0100 Subject: Treeview: Improve some code wrapping. --- desktop/treeview.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 277955078..765d9275f 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -962,7 +962,7 @@ treeview_create_node_entry(treeview *tree, } e = malloc(sizeof(struct treeview_node_entry) + - (tree->n_fields - 1) * sizeof(struct treeview_field)); + (tree->n_fields - 1) * sizeof(struct treeview_field)); if (e == NULL) { return NSERROR_NOMEM; } @@ -978,8 +978,8 @@ treeview_create_node_entry(treeview *tree, assert(fields != NULL); assert(fields[0].field != NULL); assert(lwc_string_isequal(tree->fields[0].field, - fields[0].field, &match) == lwc_error_ok && - match == true); + fields[0].field, &match) == lwc_error_ok && + match == true); n->text.data = fields[0].value; n->text.len = fields[0].value_len; n->text.width = 0; @@ -994,8 +994,8 @@ treeview_create_node_entry(treeview *tree, for (i = 1; i < tree->n_fields; i++) { assert(fields[i].field != NULL); assert(lwc_string_isequal(tree->fields[i].field, - fields[i].field, &match) == lwc_error_ok && - match == true); + fields[i].field, &match) == lwc_error_ok && + match == true); e->fields[i - 1].value.data = fields[i].value; e->fields[i - 1].value.len = fields[i].value_len; @@ -1103,11 +1103,10 @@ treeview_walk(treeview *tree, if (root == NULL) root = tree->root; - return treeview_walk_internal(root, - true, - (leave_cb != NULL) ? treeview_walk_bwd_cb : NULL, - (enter_cb != NULL) ? treeview_walk_fwd_cb : NULL, - &tw); + return treeview_walk_internal(root, true, + (leave_cb != NULL) ? treeview_walk_bwd_cb : NULL, + (enter_cb != NULL) ? treeview_walk_fwd_cb : NULL, + &tw); } -- cgit v1.2.1 From d627b930f2d70da0c6a8bd7481050a288db628c9 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 10 Sep 2017 11:58:47 +0100 Subject: Treeview: API: Allow treeview fields to be flagged searchable. --- desktop/treeview.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/desktop/treeview.h b/desktop/treeview.h index b9347d2f0..a8cf29ac5 100644 --- a/desktop/treeview.h +++ b/desktop/treeview.h @@ -114,11 +114,12 @@ struct treeview_node_msg { * treeview field flags */ enum treeview_field_flags { - TREE_FLAG_NONE = 0, /**< No flags set */ - TREE_FLAG_ALLOW_EDIT = (1 << 0), /**< Whether allow edit field */ - TREE_FLAG_DEFAULT = (1 << 1), /**< Whether field is default */ - TREE_FLAG_SHOW_NAME = (1 << 2), /**< Whether field name shown */ - TREE_FLAG_COPY_TEXT = (1 << 3) /**< Whether to copy to clipb */ + TREE_FLAG_NONE = 0, /**< No flags set */ + TREE_FLAG_ALLOW_EDIT = (1 << 0), /**< Whether allow edit field */ + TREE_FLAG_DEFAULT = (1 << 1), /**< Whether field is default */ + TREE_FLAG_SHOW_NAME = (1 << 2), /**< Whether field name shown */ + TREE_FLAG_COPY_TEXT = (1 << 3), /**< Whether to copy to clipb */ + TREE_FLAG_SEARCHABLE = (1 << 4), /**< Whether field is searchable */ }; -- cgit v1.2.1 From f41f7486bae2162ec6f33c1cf5de344e812fef1a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 10 Sep 2017 12:02:36 +0100 Subject: Treeview: Add node matching to search text modification callback. --- desktop/treeview.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 131 insertions(+), 3 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 765d9275f..46772c28f 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -22,10 +22,13 @@ * Treeview handling implementation. */ +#include + #include "utils/utils.h" #include "utils/log.h" #include "utils/nsurl.h" #include "utils/nsoption.h" +#include "utils/config.h" #include "netsurf/bitmap.h" #include "netsurf/content.h" #include "netsurf/plotters.h" @@ -104,7 +107,8 @@ enum treeview_node_flags { TV_NFLAGS_NONE = 0, /**< No node flags set */ TV_NFLAGS_EXPANDED = (1 << 0), /**< Whether node is expanded */ TV_NFLAGS_SELECTED = (1 << 1), /**< Whether node is selected */ - TV_NFLAGS_SPECIAL = (1 << 2) /**< Render as special node */ + TV_NFLAGS_SPECIAL = (1 << 2), /**< Render as special node */ + TV_NFLAGS_MATCHED = (1 << 3), /**< Whether node matches search */ }; @@ -211,8 +215,9 @@ struct treeview_edit { * Treeview search box details */ struct treeview_search { - struct textarea *textarea; /**< Search box. Never NULL. */ - bool active; /**< Whether the search box is active */ + struct textarea *textarea; /**< Search box. */ + bool active; /**< Whether the search box has focus. */ + bool search; /**< Whether we have a search term. */ }; @@ -1565,6 +1570,117 @@ static struct textarea *treeview__create_textarea( } +/** + * Data used when doing a treeview walk for search. + */ +struct treeview_search_walk_data { + treeview *tree; /**< The treeview to search. */ + const char *text; /**< The string being searched for. */ + const unsigned int len; /**< Length of string being searched for. */ + int window_height; /**< Accumulate height for matching entries. */ +}; + + +/** + * Treewalk node callback for handling search. + * + * \param[in] n Current node. + * \param[in] ctx Treeview search context. + * \param[in,out] skip_children Flag to allow children to be skipped. + * \param[in,out] end Flag to allow iteration to be finished early. + * \return NSERROR_OK on success else error code. + */ +static nserror treeview__search_walk_cb( + treeview_node *n, + void *ctx, + bool *skip_children, + bool *end) +{ + struct treeview_search_walk_data *sw = ctx; + + if (n->type != TREE_NODE_ENTRY) { + return NSERROR_OK; + } + + if (sw->len == 0) { + n->flags &= ~TV_NFLAGS_MATCHED; + } else { + struct treeview_node_entry *entry = + (struct treeview_node_entry *)n; + bool matched = false; + + + for (int i = 0; i < sw->tree->n_fields; i++) { + struct treeview_field *ef = &(sw->tree->fields[i + 1]); + if (ef->flags & TREE_FLAG_SEARCHABLE) { + if (strcasestr(entry->fields[i].value.data, + sw->text) != NULL) { + matched = true; + break; + } + } + } + + if (!matched && strcasestr(n->text.data, sw->text) != NULL) { + matched = true; + } + + if (matched) { + n->flags |= TV_NFLAGS_MATCHED; + sw->window_height += tree_g.line_height; + } else { + n->flags &= ~TV_NFLAGS_MATCHED; + } + } + + return NSERROR_OK; +} + + +/** + * Search treeview for text. + * + * \param[in] tree Treeview to search. + * \param[in] text UTF-8 string to search for. (NULL-terminated.) + * \param[in] len Byte length of UTF-8 string. + * \return NSERROR_OK on success, appropriate error otherwise. + */ +static nserror treeview__search( + treeview *tree, + const char *text, + unsigned int len) +{ + nserror err; + uint32_t height; + struct treeview_search_walk_data sw = { + .len = len, + .text = text, + .tree = tree, + .window_height = 0, + }; + + assert(text[len] == '\0'); + + err = treeview_walk_internal(tree->root, true, NULL, + treeview__search_walk_cb, &sw); + if (err != NSERROR_OK) { + return err; + } + + if (len > 0) { + tree->search.search = true; + height = sw.window_height; + } else { + tree->search.search = false; + height = tree->root->height; + } + + treeview__cw_update_size(tree, -1, height); + + return NSERROR_OK; +} + + /** * Callback for textarea_create, in desktop/treeview.h * @@ -1577,6 +1693,10 @@ static void treeview_textarea_search_callback(void *data, treeview *tree = data; struct rect *r; + if (tree->search.active == false) { + return; + } + switch (msg->type) { case TEXTAREA_MSG_DRAG_REPORT: if (msg->data.drag == TEXTAREA_DRAG_NONE) { @@ -1600,6 +1720,13 @@ static void treeview_textarea_search_callback(void *data, cw_invalidate_area(tree, r); break; + case TEXTAREA_MSG_TEXT_MODIFIED: + /* Textarea length includes trailing NULL, so subtract it. */ + treeview__search(tree, + msg->data.modified.text, + msg->data.modified.len - 1); + break; + default: break; } @@ -1701,6 +1828,7 @@ treeview_create(treeview **tree, (*tree)->search.textarea = NULL; } (*tree)->search.active = false; + (*tree)->search.search = false; (*tree)->flags = flags; -- cgit v1.2.1 From c478f35c81478e48d3a86ac57e7bb7c34a3ce107 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 10 Sep 2017 13:12:35 +0100 Subject: Treeview: Split tree-style treeview rendering out into helper. --- desktop/treeview.c | 272 +++++++++++++++++++++++++++++------------------------ 1 file changed, 150 insertions(+), 122 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 46772c28f..8b66730d5 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -2243,38 +2243,40 @@ nserror treeview_expand(treeview *tree, bool only_folders) } -/* Exported interface, documented in treeview.h */ -void -treeview_redraw(treeview *tree, +/** + * Draw a treeview normally, in tree mode. + * + * \param[in] tree The treeview we're rendering. + * \param[in] x X coordinate we're rendering the treeview at. + * \param[in] y Y coordinate we're rendering the treeview at. + * \param[in,out] render_y Current vertical position in tree, updated on exit. + * \param[in] r Clip rectangle. + * \param[in] data Redraw data for rendering contents. + * \param[in] ctx Current render context. + */ +static void treeview_redraw_tree( + treeview *tree, const int x, const int y, - struct rect *clip, + int *render_y_in_out, + struct rect *r, + struct content_redraw_data *data, const struct redraw_context *ctx) { - struct redraw_context new_ctx = *ctx; - treeview_node *node, *root, *next; - struct treeview_node_entry *entry; struct treeview_node_style *style = &plot_style_odd; - struct content_redraw_data data; - struct rect r; - struct rect rect; - uint32_t count = 0; - int render_y = y; - int inset; - int x0; - int baseline = (tree_g.line_height * 3 + 2) / 4; enum treeview_resource_id res = TREE_RES_CONTENT; - plot_style_t *bg_style; - plot_font_style_t *text_style; + int baseline = (tree_g.line_height * 3 + 2) / 4; plot_font_style_t *infotext_style; - struct bitmap *furniture; - int height; + treeview_node *root = tree->root; + treeview_node *node = tree->root; + int render_y = *render_y_in_out; + plot_font_style_t *text_style; + plot_style_t *bg_style; int sel_min, sel_max; - bool invert_selection; - - assert(tree != NULL); - assert(tree->root != NULL); - assert(tree->root->flags & TV_NFLAGS_EXPANDED); + uint32_t count = 0; + struct rect rect; + int inset; + int x0; if (tree->drag.start.y > tree->drag.prev.y) { sel_min = tree->drag.prev.y; @@ -2284,64 +2286,14 @@ treeview_redraw(treeview *tree, sel_max = tree->drag.prev.y; } - /* Start knockout rendering if it's available for this plotter */ - if (ctx->plot->option_knockout) { - knockout_plot_start(ctx, &new_ctx); - } - - /* Set up clip rectangle */ - r.x0 = clip->x0 + x; - r.y0 = clip->y0 + y; - r.x1 = clip->x1 + x; - r.y1 = clip->y1 + y; - new_ctx.plot->clip(&new_ctx, &r); - - /* Draw the tree */ - node = root = tree->root; - - /* Setup common content redraw data */ - data.width = tree_g.icon_size; - data.height = tree_g.icon_size; - data.scale = 1; - data.repeat_x = false; - data.repeat_y = false; - - if (tree->flags & TREEVIEW_SEARCHABLE) { - if (render_y < r.y1) { - enum treeview_resource_id icon = TREE_RES_SEARCH; - - /* Fill the blank area at the bottom */ - rect.x0 = r.x0; - rect.y0 = render_y; - rect.x1 = r.x1; - rect.y1 = render_y + tree_g.line_height; - new_ctx.plot->rectangle(&new_ctx, &plot_style_even.bg, - &rect); - - if (treeview_res[icon].ready) { - /* Icon resource is available */ - data.x = tree_g.window_padding; - data.y = render_y + ((tree_g.line_height - - treeview_res[icon].height + 1) / - 2); - data.background_colour = plot_style_even.bg. - fill_colour; - - content_redraw(treeview_res[icon].c, - &data, &r, &new_ctx); - } - - textarea_redraw(tree->search.textarea, - x + tree_g.window_padding + - tree_g.icon_step, y, - plot_style_even.bg.fill_colour, 1.0, - &r, &new_ctx); - } - render_y += tree_g.line_height; - } - while (node != NULL) { + struct treeview_node_entry *entry; + struct bitmap *furniture; + bool invert_selection; + treeview_node *next; + int height; int i; + next = (node->flags & TV_NFLAGS_EXPANDED) ? node->children : NULL; @@ -2374,7 +2326,7 @@ treeview_redraw(treeview *tree, height = (node->type == TREE_NODE_ENTRY) ? node->height : tree_g.line_height; - if ((render_y + height) < r.y0) { + if ((render_y + height) < r->y0) { /* This node's line is above clip region */ render_y += height; continue; @@ -2407,21 +2359,21 @@ treeview_redraw(treeview *tree, } /* Render background */ - rect.x0 = r.x0; + rect.x0 = r->x0; rect.y0 = render_y; - rect.x1 = r.x1; + rect.x1 = r->x1; rect.y1 = render_y + height; - new_ctx.plot->rectangle(&new_ctx, bg_style, &rect); + ctx->plot->rectangle(ctx, bg_style, &rect); /* Render toggle */ - new_ctx.plot->bitmap(&new_ctx, - furniture, - inset, - render_y + tree_g.line_height / 4, - style->furn[TREE_FURN_EXPAND].size, - style->furn[TREE_FURN_EXPAND].size, - bg_style->fill_colour, - BITMAPF_NONE); + ctx->plot->bitmap(ctx, + furniture, + inset, + render_y + tree_g.line_height / 4, + style->furn[TREE_FURN_EXPAND].size, + style->furn[TREE_FURN_EXPAND].size, + bg_style->fill_colour, + BITMAPF_NONE); /* Render icon */ if (node->type == TREE_NODE_ENTRY) { @@ -2434,26 +2386,25 @@ treeview_redraw(treeview *tree, if (treeview_res[res].ready) { /* Icon resource is available */ - data.x = inset + tree_g.step_width; - data.y = render_y + ((tree_g.line_height - + data->x = inset + tree_g.step_width; + data->y = render_y + ((tree_g.line_height - treeview_res[res].height + 1) / 2); - data.background_colour = bg_style->fill_colour; + data->background_colour = bg_style->fill_colour; - content_redraw(treeview_res[res].c, - &data, &r, &new_ctx); + content_redraw(treeview_res[res].c, data, r, ctx); } /* Render text */ x0 = inset + tree_g.step_width + tree_g.icon_step; - new_ctx.plot->text(&new_ctx, - text_style, - x0, render_y + baseline, - node->text.data, - node->text.len); + ctx->plot->text(ctx, + text_style, + x0, render_y + baseline, + node->text.data, + node->text.len); /* Rendered the node */ render_y += tree_g.line_height; - if (render_y > r.y1) { + if (render_y > r->y1) { /* Passed the bottom of what's in the clip region. * Done. */ break; @@ -2473,25 +2424,25 @@ treeview_redraw(treeview *tree, if (ef->flags & TREE_FLAG_SHOW_NAME) { int max_width = tree->field_width; - new_ctx.plot->text(&new_ctx, - infotext_style, - x0 + max_width - ef->value.width - tree_g.step_width, - render_y + baseline, - ef->value.data, - ef->value.len); - - new_ctx.plot->text(&new_ctx, - infotext_style, - x0 + max_width, - render_y + baseline, - entry->fields[i].value.data, - entry->fields[i].value.len); + ctx->plot->text(ctx, + infotext_style, + x0 + max_width - ef->value.width - tree_g.step_width, + render_y + baseline, + ef->value.data, + ef->value.len); + + ctx->plot->text(ctx, + infotext_style, + x0 + max_width, + render_y + baseline, + entry->fields[i].value.data, + entry->fields[i].value.len); } else { - new_ctx.plot->text(&new_ctx, - infotext_style, - x0, render_y + baseline, - entry->fields[i].value.data, - entry->fields[i].value.len); + ctx->plot->text(ctx, + infotext_style, + x0, render_y + baseline, + entry->fields[i].value.data, + entry->fields[i].value.len); } /* Rendered the expanded entry field */ @@ -2500,13 +2451,90 @@ treeview_redraw(treeview *tree, /* Finished rendering expanded entry */ - if (render_y > r.y1) { + if (render_y > r->y1) { /* Passed the bottom of what's in the clip region. * Done. */ break; } } + *render_y_in_out = render_y; +} + + +/* Exported interface, documented in treeview.h */ +void +treeview_redraw(treeview *tree, + const int x, + const int y, + struct rect *clip, + const struct redraw_context *ctx) +{ + struct redraw_context new_ctx = *ctx; + struct content_redraw_data data; + struct rect r; + struct rect rect; + int render_y = y; + + assert(tree != NULL); + assert(tree->root != NULL); + assert(tree->root->flags & TV_NFLAGS_EXPANDED); + + /* Start knockout rendering if it's available for this plotter */ + if (ctx->plot->option_knockout) { + knockout_plot_start(ctx, &new_ctx); + } + + /* Set up clip rectangle */ + r.x0 = clip->x0 + x; + r.y0 = clip->y0 + y; + r.x1 = clip->x1 + x; + r.y1 = clip->y1 + y; + new_ctx.plot->clip(&new_ctx, &r); + + /* Setup common content redraw data */ + data.width = tree_g.icon_size; + data.height = tree_g.icon_size; + data.scale = 1; + data.repeat_x = false; + data.repeat_y = false; + + if (tree->flags & TREEVIEW_SEARCHABLE) { + if (render_y < r.y1) { + enum treeview_resource_id icon = TREE_RES_SEARCH; + + /* Fill the blank area at the bottom */ + rect.x0 = r.x0; + rect.y0 = render_y; + rect.x1 = r.x1; + rect.y1 = render_y + tree_g.line_height; + new_ctx.plot->rectangle(&new_ctx, &plot_style_even.bg, + &rect); + + if (treeview_res[icon].ready) { + /* Icon resource is available */ + data.x = tree_g.window_padding; + data.y = render_y + ((tree_g.line_height - + treeview_res[icon].height + 1) / + 2); + data.background_colour = plot_style_even.bg. + fill_colour; + + content_redraw(treeview_res[icon].c, + &data, &r, &new_ctx); + } + + textarea_redraw(tree->search.textarea, + x + tree_g.window_padding + + tree_g.icon_step, y, + plot_style_even.bg.fill_colour, 1.0, + &r, &new_ctx); + } + render_y += tree_g.line_height; + } + + treeview_redraw_tree(tree, x, y, &render_y, &r, &data, &new_ctx); + if (render_y < r.y1) { /* Fill the blank area at the bottom */ rect.x0 = r.x0; -- cgit v1.2.1 From c20ad212731526d46f872a8220c6a1f53696f7e1 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 10 Sep 2017 15:50:35 +0100 Subject: Treeview: Add support for rendering search filter matches as-you-type. --- desktop/treeview.c | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 230 insertions(+), 1 deletion(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 8b66730d5..85bc61d8e 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -2462,6 +2462,228 @@ static void treeview_redraw_tree( } +/** + * Draw a treeview normally, in tree mode. + * + * \param[in] tree The treeview we're rendering. + * \param[in] x X coordinate we're rendering the treeview at. + * \param[in] y Y coordinate we're rendering the treeview at. + * \param[in,out] render_y Current vertical position in tree, updated on exit. + * \param[in] r Clip rectangle. + * \param[in] data Redraw data for rendering contents. + * \param[in] ctx Current render context. + */ +static void treeview_redraw_search( + treeview *tree, + const int x, + const int y, + int *render_y_in_out, + struct rect *r, + struct content_redraw_data *data, + const struct redraw_context *ctx) +{ + struct treeview_node_style *style = &plot_style_odd; + enum treeview_resource_id res = TREE_RES_CONTENT; + int baseline = (tree_g.line_height * 3 + 2) / 4; + plot_font_style_t *infotext_style; + treeview_node *root = tree->root; + treeview_node *node = tree->root; + int render_y = *render_y_in_out; + plot_font_style_t *text_style; + plot_style_t *bg_style; + int sel_min, sel_max; + uint32_t count = 0; + struct rect rect; + int inset; + int x0; + + if (tree->drag.start.y > tree->drag.prev.y) { + sel_min = tree->drag.prev.y; + sel_max = tree->drag.start.y; + } else { + sel_min = tree->drag.start.y; + sel_max = tree->drag.prev.y; + } + + while (node != NULL) { + struct treeview_node_entry *entry; + struct bitmap *furniture; + bool invert_selection; + treeview_node *next; + int height; + int i; + + next = node->children; + + if (next != NULL) { + /* down to children */ + node = next; + } else { + /* No children. As long as we're not at the root, + * go to next sibling if present, or nearest ancestor + * with a next sibling. */ + + while (node != root && + node->next_sib == NULL) { + node = node->parent; + } + + if (node == root) + break; + + node = node->next_sib; + } + + assert(node != NULL); + assert(node != root); + assert(node->type == TREE_NODE_FOLDER || + node->type == TREE_NODE_ENTRY); + + if (node->type == TREE_NODE_FOLDER || + !(node->flags & TV_NFLAGS_MATCHED)) { + continue; + } + + count++; + inset = x + tree_g.window_padding; + height = tree_g.line_height; + + if ((render_y + height) < r->y0) { + /* This node's line is above clip region */ + render_y += height; + continue; + } + + style = (count & 0x1) ? &plot_style_odd : &plot_style_even; + if (tree->drag.type == TV_DRAG_SELECTION && + (render_y + height >= sel_min && + render_y < sel_max)) { + invert_selection = true; + } else { + invert_selection = false; + } + if ((node->flags & TV_NFLAGS_SELECTED && !invert_selection) || + (!(node->flags & TV_NFLAGS_SELECTED) && + invert_selection)) { + bg_style = &style->sbg; + text_style = &style->stext; + infotext_style = &style->sitext; + furniture = (node->flags & TV_NFLAGS_EXPANDED) ? + style->furn[TREE_FURN_CONTRACT].sel : + style->furn[TREE_FURN_EXPAND].sel; + } else { + bg_style = &style->bg; + text_style = &style->text; + infotext_style = &style->itext; + furniture = (node->flags & TV_NFLAGS_EXPANDED) ? + style->furn[TREE_FURN_CONTRACT].bmp : + style->furn[TREE_FURN_EXPAND].bmp; + } + + /* Render background */ + rect.x0 = r->x0; + rect.y0 = render_y; + rect.x1 = r->x1; + rect.y1 = render_y + height; + ctx->plot->rectangle(ctx, bg_style, &rect); + + /* Render toggle */ + ctx->plot->bitmap(ctx, + furniture, + inset, + render_y + tree_g.line_height / 4, + style->furn[TREE_FURN_EXPAND].size, + style->furn[TREE_FURN_EXPAND].size, + bg_style->fill_colour, + BITMAPF_NONE); + + /* Render icon */ + if (node->type == TREE_NODE_ENTRY) { + res = TREE_RES_CONTENT; + } else if (node->flags & TV_NFLAGS_SPECIAL) { + res = TREE_RES_FOLDER_SPECIAL; + } else { + res = TREE_RES_FOLDER; + } + + if (treeview_res[res].ready) { + /* Icon resource is available */ + data->x = inset + tree_g.step_width; + data->y = render_y + ((tree_g.line_height - + treeview_res[res].height + 1) / 2); + data->background_colour = bg_style->fill_colour; + + content_redraw(treeview_res[res].c, data, r, ctx); + } + + /* Render text */ + x0 = inset + tree_g.step_width + tree_g.icon_step; + ctx->plot->text(ctx, + text_style, + x0, render_y + baseline, + node->text.data, + node->text.len); + + /* Rendered the node */ + render_y += tree_g.line_height; + if (render_y > r->y1) { + /* Passed the bottom of what's in the clip region. + * Done. */ + break; + } + + + if (node->type != TREE_NODE_ENTRY || + !(node->flags & TV_NFLAGS_EXPANDED)) + /* Done everything for this node */ + continue; + + /* Render expanded entry fields */ + entry = (struct treeview_node_entry *)node; + for (i = 0; i < tree->n_fields - 1; i++) { + struct treeview_field *ef = &(tree->fields[i + 1]); + + if (ef->flags & TREE_FLAG_SHOW_NAME) { + int max_width = tree->field_width; + + ctx->plot->text(ctx, + infotext_style, + x0 + max_width - ef->value.width - tree_g.step_width, + render_y + baseline, + ef->value.data, + ef->value.len); + + ctx->plot->text(ctx, + infotext_style, + x0 + max_width, + render_y + baseline, + entry->fields[i].value.data, + entry->fields[i].value.len); + } else { + ctx->plot->text(ctx, + infotext_style, + x0, render_y + baseline, + entry->fields[i].value.data, + entry->fields[i].value.len); + } + + /* Rendered the expanded entry field */ + render_y += tree_g.line_height; + } + + /* Finished rendering expanded entry */ + + if (render_y > r->y1) { + /* Passed the bottom of what's in the clip region. + * Done. */ + break; + } + } + + *render_y_in_out = render_y; +} + + /* Exported interface, documented in treeview.h */ void treeview_redraw(treeview *tree, @@ -2533,7 +2755,14 @@ treeview_redraw(treeview *tree, render_y += tree_g.line_height; } - treeview_redraw_tree(tree, x, y, &render_y, &r, &data, &new_ctx); + /* Render the treeview data */ + if (tree->search.search == true) { + treeview_redraw_search(tree, x, y, + &render_y, &r, &data, &new_ctx); + } else { + treeview_redraw_tree(tree, x, y, + &render_y, &r, &data, &new_ctx); + } if (render_y < r.y1) { /* Fill the blank area at the bottom */ -- cgit v1.2.1 From 8fb2fc6fc347ddd68db0ce70648e9a2d25ef88e3 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 10 Sep 2017 16:05:41 +0100 Subject: rationalise history icon bitmap handling to ensure correct lifetime --- content/urldb.c | 47 ----------- content/urldb.h | 10 --- desktop/browser_history.c | 198 ++++++++++++++++++++++++++++++---------------- desktop/browser_history.h | 25 +++--- frontends/amiga/gui.c | 7 +- include/netsurf/bitmap.h | 2 +- include/netsurf/url_db.h | 9 --- 7 files changed, 147 insertions(+), 151 deletions(-) diff --git a/content/urldb.c b/content/urldb.c index add2a1d80..cacc475f2 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -202,7 +202,6 @@ struct path_data { char **fragment; /**< Array of fragments */ bool persistent; /**< This entry should persist */ - struct bitmap *thumb; /**< Thumbnail image of resource */ struct url_internal_data urld; /**< URL data for resource */ /** @@ -2702,10 +2701,6 @@ static void urldb_destroy_path_node_content(struct path_data *node) free(node->fragment[i]); free(node->fragment); - if (node->thumb) { - guit->bitmap->destroy(node->thumb); - } - free(node->urld.title); for (a = node->cookies; a; a = b) { @@ -3465,48 +3460,6 @@ bool urldb_get_cert_permissions(nsurl *url) } -/* exported interface documented in content/urldb.h */ -bool urldb_set_thumbnail(nsurl *url, struct bitmap *bitmap) -{ - struct path_data *p; - - assert(url); - - /* add url, in case it's missing */ - urldb_add_url(url); - - p = urldb_find_url(url); - if (p == NULL) { - return false; - } - - NSLOG(netsurf, INFO, "Setting bitmap on %s", nsurl_access(url)); - - if ((p->thumb) && (p->thumb != bitmap)) { - guit->bitmap->destroy(p->thumb); - } - - p->thumb = bitmap; - - return true; -} - - -/* exported interface documented in netsurf/url_db.h */ -struct bitmap *urldb_get_thumbnail(nsurl *url) -{ - struct path_data *p; - - assert(url); - - p = urldb_find_url(url); - if (!p) - return NULL; - - return p->thumb; -} - - /* exported interface documented in netsurf/url_db.h */ void urldb_iterate_partial(const char *prefix, diff --git a/content/urldb.h b/content/urldb.h index b2c233194..4aa548704 100644 --- a/content/urldb.h +++ b/content/urldb.h @@ -110,16 +110,6 @@ struct nsurl *urldb_get_url(struct nsurl *url); bool urldb_get_cert_permissions(struct nsurl *url); -/** - * Set thumbnail for url, replacing any existing thumbnail - * - * \param url Absolute URL to consider - * \param bitmap Opaque pointer to thumbnail data, or NULL to invalidate - * \return true on successful setting else false - */ -bool urldb_set_thumbnail(struct nsurl *url, struct bitmap *bitmap); - - /** * Parse Set-Cookie header and insert cookie(s) into database * diff --git a/desktop/browser_history.c b/desktop/browser_history.c index ba122f30d..c8a896290 100644 --- a/desktop/browser_history.c +++ b/desktop/browser_history.c @@ -50,7 +50,7 @@ * Clone a history entry * * \param history opaque history structure, as returned by history_create() - * \param entry entry to clone + * \param entry entry to clone * \return A cloned history entry or NULL on error */ static struct history_entry * @@ -62,47 +62,85 @@ browser_window_history__clone_entry(struct history *history, struct history_entry *prev = NULL; struct history_entry *new_entry; + assert(entry); assert(entry->page.url); assert(entry->page.title); /* clone the entry */ - new_entry = malloc(sizeof *entry); - if (!new_entry) + new_entry = calloc(1, sizeof *entry); + if (!new_entry) { return NULL; + } - memcpy(new_entry, entry, sizeof *entry); - new_entry->page.url = nsurl_ref(entry->page.url); - if (entry->page.frag_id) - new_entry->page.frag_id = lwc_string_ref(entry->page.frag_id); - + /* copy page information */ new_entry->page.title = strdup(entry->page.title); - if (!new_entry->page.url || !new_entry->page.title || - ((entry->page.frag_id) && (!new_entry->page.frag_id))) { - nsurl_unref(new_entry->page.url); - if (new_entry->page.frag_id) - lwc_string_unref(new_entry->page.frag_id); + if (new_entry->page.title == NULL) { + free(new_entry); + return NULL; + } + + new_entry->page.url = nsurl_ref(entry->page.url); + if (new_entry->page.url == NULL) { free(new_entry->page.title); free(new_entry); return NULL; } - /* update references */ - if (history->current == entry) - history->current = new_entry; + if (entry->page.frag_id == NULL) { + new_entry->page.frag_id = NULL; + } else { + new_entry->page.frag_id = lwc_string_ref(entry->page.frag_id); + if (new_entry->page.frag_id == NULL) { + nsurl_unref(new_entry->page.url); + free(new_entry); + return NULL; + } + } + + if (entry->page.bitmap == NULL) { + new_entry->page.bitmap = NULL; + } else { + /* create a new bitmap and copy original into it */ + unsigned char *bmsrc_data; + unsigned char *bmdst_data; + size_t bmsize; + + new_entry->page.bitmap = guit->bitmap->create(WIDTH, HEIGHT, + BITMAP_NEW | BITMAP_OPAQUE); + + if (new_entry->page.bitmap != NULL) { + bmsrc_data = guit->bitmap->get_buffer(entry->page.bitmap); + bmdst_data = guit->bitmap->get_buffer(new_entry->page.bitmap); + bmsize = guit->bitmap->get_rowstride(new_entry->page.bitmap) * + guit->bitmap->get_height(new_entry->page.bitmap); + memcpy(bmdst_data, bmsrc_data, bmsize); + } + } + + /* copy tree values */ + new_entry->back = entry->back; + new_entry->next = entry->next; + new_entry->forward = entry->forward; + new_entry->forward_pref = entry->forward_pref; + new_entry->forward_last = entry->forward_last; /* recurse for all children */ - for (child = new_entry->forward; child; child = child->next) { + for (child = new_entry->forward; child != NULL; child = child->next) { new_child = browser_window_history__clone_entry(history, child); - if (new_child) { - new_child->back = new_entry; - } else { + if (new_child == NULL) { nsurl_unref(new_entry->page.url); - if (new_entry->page.frag_id) + if (new_entry->page.frag_id) { lwc_string_unref(new_entry->page.frag_id); + } free(new_entry->page.title); + if (entry->page.bitmap != NULL) { + guit->bitmap->destroy(entry->page.bitmap); + } free(new_entry); return NULL; } + + new_child->back = new_entry; if (prev) prev->next = new_child; if (new_entry->forward == child) @@ -113,6 +151,12 @@ browser_window_history__clone_entry(struct history *history, new_entry->forward_last = new_child; prev = new_child; } + + /* update references */ + if (history->current == entry) { + history->current = new_entry; + } + return new_entry; } @@ -123,15 +167,20 @@ browser_window_history__clone_entry(struct history *history, static void browser_window_history__free_entry(struct history_entry *entry) { - if (!entry) - return; - browser_window_history__free_entry(entry->forward); - browser_window_history__free_entry(entry->next); - nsurl_unref(entry->page.url); - if (entry->page.frag_id) - lwc_string_unref(entry->page.frag_id); - free(entry->page.title); - free(entry); + if (entry != NULL) { + browser_window_history__free_entry(entry->forward); + browser_window_history__free_entry(entry->next); + + nsurl_unref(entry->page.url); + if (entry->page.frag_id) { + lwc_string_unref(entry->page.frag_id); + } + free(entry->page.title); + if (entry->page.bitmap != NULL) { + guit->bitmap->destroy(entry->page.bitmap); + } + free(entry); + } } @@ -297,14 +346,14 @@ nserror browser_window_history_clone(const struct browser_window *existing, /* exported interface documented in desktop/browser_history.h */ -nserror browser_window_history_add(struct browser_window *bw, - struct hlcache_handle *content, lwc_string *frag_id) +nserror +browser_window_history_add(struct browser_window *bw, + struct hlcache_handle *content, + lwc_string *frag_id) { struct history *history; struct history_entry *entry; - nsurl *nsurl = hlcache_handle_get_url(content); char *title; - struct bitmap *bitmap; nserror ret; assert(bw); @@ -313,26 +362,40 @@ nserror browser_window_history_add(struct browser_window *bw, history = bw->history; - /* allocate space */ entry = malloc(sizeof *entry); if (entry == NULL) { return NSERROR_NOMEM; } + /* page information */ title = strdup(content_get_title(content)); if (title == NULL) { free(entry); return NSERROR_NOMEM; } - entry->page.url = nsurl_ref(nsurl); + entry->page.url = nsurl_ref(hlcache_handle_get_url(content)); entry->page.frag_id = frag_id ? lwc_string_ref(frag_id) : NULL; entry->page.title = title; - entry->page.bitmap = NULL; + /* create thumbnail for localhistory view */ + NSLOG(netsurf, DEBUG, + "Creating thumbnail for %s", nsurl_access(entry->page.url)); + + entry->page.bitmap = guit->bitmap->create(WIDTH, HEIGHT, + BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE); + if (entry->page.bitmap != NULL) { + ret = guit->bitmap->render(entry->page.bitmap, content); + if (ret != NSERROR_OK) { + /* Thumbnail render failed */ + NSLOG(netsurf, WARNING, "Thumbnail render failed"); + } + } + + /* insert into tree */ entry->back = history->current; - entry->next = 0; - entry->forward = entry->forward_pref = entry->forward_last = 0; + entry->next = NULL; + entry->forward = entry->forward_pref = entry->forward_last = NULL; entry->children = 0; if (history->current) { @@ -349,34 +412,6 @@ nserror browser_window_history_add(struct browser_window *bw, } history->current = entry; - /* if we have a thumbnail, don't update until the page has finished - * loading */ - bitmap = urldb_get_thumbnail(nsurl); - if (bitmap == NULL) { - NSLOG(netsurf, INFO, "Creating thumbnail for %s", - nsurl_access(nsurl)); - bitmap = guit->bitmap->create(WIDTH, HEIGHT, - BITMAP_NEW | BITMAP_CLEAR_MEMORY | - BITMAP_OPAQUE); - if (bitmap != NULL) { - ret = guit->bitmap->render(bitmap, content); - if (ret == NSERROR_OK) { - /* Successful thumbnail so register it - * with the url. - */ - urldb_set_thumbnail(nsurl, bitmap); - } else { - /* Thumbnailing failed. Ignore it - * silently but clean up bitmap. - */ - NSLOG(netsurf, INFO, "Thumbnail renderfailed"); - guit->bitmap->destroy(bitmap); - bitmap = NULL; - } - } - } - entry->page.bitmap = bitmap; - browser_window_history__layout(history); return NSERROR_OK; @@ -411,7 +446,9 @@ nserror browser_window_history_update(struct browser_window *bw, free(history->current->page.title); history->current->page.title = title; - guit->bitmap->render(history->current->page.bitmap, content); + if (history->current->page.bitmap != NULL) { + guit->bitmap->render(history->current->page.bitmap, content); + } return NSERROR_OK; } @@ -475,6 +512,27 @@ bool browser_window_history_forward_available(struct browser_window *bw) bw->history->current->forward_pref); } +/* exported interface documented in desktop/browser_history.h */ +nserror +browser_window_history_get_thumbnail(struct browser_window *bw, + struct bitmap **bitmap_out) +{ + struct bitmap *bitmap; + + if (!bw || !bw->history || !bw->history->current) { + return NSERROR_INVALID; + } + + if (bw->history->current->page.bitmap == NULL) { + bitmap = content_get_bitmap(bw->current_content); + } else { + bitmap = bw->history->current->page.bitmap; + } + + *bitmap_out = bitmap; + + return NSERROR_OK; +} /* exported interface documented in desktop/browser_history.h */ nserror browser_window_history_go(struct browser_window *bw, @@ -519,7 +577,7 @@ nserror browser_window_history_go(struct browser_window *bw, /* exported interface documented in desktop/browser_history.h */ -void browser_window_history_enumerate_forward(const struct browser_window *bw, +void browser_window_history_enumerate_forward(const struct browser_window *bw, browser_window_history_enumerate_cb cb, void *user_data) { struct history_entry *e; @@ -537,7 +595,7 @@ void browser_window_history_enumerate_forward(const struct browser_window *bw, /* exported interface documented in desktop/browser_history.h */ -void browser_window_history_enumerate_back(const struct browser_window *bw, +void browser_window_history_enumerate_back(const struct browser_window *bw, browser_window_history_enumerate_cb cb, void *user_data) { struct history_entry *e; diff --git a/desktop/browser_history.h b/desktop/browser_history.h index 9140e2ce0..d2021198c 100644 --- a/desktop/browser_history.h +++ b/desktop/browser_history.h @@ -75,6 +75,14 @@ bool browser_window_history_back_available(struct browser_window *bw); */ bool browser_window_history_forward_available(struct browser_window *bw); +/** + * Get the thumbnail bitmap for the current history entry + * + * \param bw The browser window + * \param bitmap The bitmat for the current history entry. + * \return NSERROR_OK or error code on faliure. + */ +nserror browser_window_history_get_thumbnail(struct browser_window *bw, struct bitmap **bitmap_out); /** * Callback function type for history enumeration @@ -136,21 +144,19 @@ struct nsurl *browser_window_history_entry_get_url(const struct history_entry *e /** * Returns the URL to a history entry * - * \param entry the history entry to retrieve the fragment id from - * \return the fragment id + * \param entry the history entry to retrieve the fragment id from + * \return the fragment id */ -const char *browser_window_history_entry_get_fragment_id( - const struct history_entry *entry); +const char *browser_window_history_entry_get_fragment_id(const struct history_entry *entry); /** * Returns the title of a history entry * - * \param entry the history entry to retrieve the title from - * \return the title + * \param entry The history entry to retrieve the title from + * \return the title */ -const char *browser_window_history_entry_get_title( - const struct history_entry *entry); +const char *browser_window_history_entry_get_title(const struct history_entry *entry); /** @@ -161,7 +167,6 @@ const char *browser_window_history_entry_get_title( * \param new_window open entry in new window * \return NSERROR_OK or error code on faliure. */ -nserror browser_window_history_go(struct browser_window *bw, - struct history_entry *entry, bool new_window); +nserror browser_window_history_go(struct browser_window *bw, struct history_entry *entry, bool new_window); #endif diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index fbaa2acfb..eca5b927c 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -2527,10 +2527,9 @@ static BOOL ami_gui_event(void *w) #ifdef __amigaos4__ case WMHI_ICONIFY: { - struct bitmap *bm; - - bm = urldb_get_thumbnail(browser_window_get_url(gwin->gw->bw)); - if(!bm) bm = content_get_bitmap(browser_window_get_content(gwin->gw->bw)); + struct bitmap *bm = NULL; + browser_window_history_get_thumbnail(gwin->gw->bw, + &bm); gwin->dobj = amiga_icon_from_bitmap(bm); amiga_icon_superimpose_favicon_internal(gwin->gw->favicon, gwin->dobj); diff --git a/include/netsurf/bitmap.h b/include/netsurf/bitmap.h index e54bdff85..a85efce99 100644 --- a/include/netsurf/bitmap.h +++ b/include/netsurf/bitmap.h @@ -154,7 +154,7 @@ struct gui_bitmap_table { * * \param bitmap The bitmap to save * \param path The path to save the bitmap to. - * \param flags Flags affectin the save. + * \param flags Flags affecting the save. */ bool (*save)(void *bitmap, const char *path, unsigned flags); diff --git a/include/netsurf/url_db.h b/include/netsurf/url_db.h index be2c656ff..217cf8fcd 100644 --- a/include/netsurf/url_db.h +++ b/include/netsurf/url_db.h @@ -95,15 +95,6 @@ void urldb_iterate_partial(const char *prefix, bool (*callback)(struct nsurl *ur void urldb_iterate_entries(bool (*callback)(struct nsurl *url, const struct url_data *data)); -/** - * Retrieve thumbnail data for given URL - * - * \param url Absolute URL to search for - * \return Pointer to thumbnail data, or NULL if not found. - */ -struct bitmap *urldb_get_thumbnail(struct nsurl *url); - - /** * Find data for an URL. * -- cgit v1.2.1 From 4cea5a853bf0a5072a6599a0eee0f2b603708b86 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 11 Sep 2017 10:35:38 +0100 Subject: remove test for removed API --- test/urldbtest.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/test/urldbtest.c b/test/urldbtest.c index 620ce4cb5..1c76de1ee 100644 --- a/test/urldbtest.c +++ b/test/urldbtest.c @@ -869,27 +869,6 @@ START_TEST(urldb_auth_details_test) END_TEST -START_TEST(urldb_thumbnail_test) -{ - nsurl *url; - struct bitmap *bmap; - struct bitmap *res; - bool set; - - url = make_url(wikipedia_url); - bmap = (struct bitmap*)url; - - set = urldb_set_thumbnail(url, bmap); - ck_assert(set == true); - - res = urldb_get_thumbnail(url); - ck_assert(res != NULL); - ck_assert(res == bmap); - - nsurl_unref(url); -} -END_TEST - START_TEST(urldb_cert_permissions_test) { nsurl *url; @@ -985,7 +964,6 @@ static TCase *urldb_case_create(void) tcase_add_test(tc, urldb_iterate_partial_numeric_v4_test); tcase_add_test(tc, urldb_iterate_partial_numeric_v6_test); tcase_add_test(tc, urldb_auth_details_test); - tcase_add_test(tc, urldb_thumbnail_test); tcase_add_test(tc, urldb_cert_permissions_test); tcase_add_test(tc, urldb_update_visit_test); tcase_add_test(tc, urldb_reset_visit_test); -- cgit v1.2.1 From d2d5ef276b40e124ad93a995704e371929d22a70 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 11 Sep 2017 16:43:25 +0100 Subject: annotate error case fall through in switch to supress warnings --- desktop/searchweb.c | 4 ++++ render/html_css.c | 2 ++ render/html_script.c | 35 ++++++++++++++++++++--------------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/desktop/searchweb.c b/desktop/searchweb.c index 8933fc9fa..c07cac9d5 100644 --- a/desktop/searchweb.c +++ b/desktop/searchweb.c @@ -299,6 +299,8 @@ search_web_ico_callback(hlcache_handle *ico, NSLOG(netsurf, INFO, "icon %s error: %s", nsurl_access(hlcache_handle_get_url(ico)), event->data.error); + /* fall through */ + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(ico); /* clear reference to released handle */ @@ -457,6 +459,8 @@ default_ico_callback(hlcache_handle *ico, NSLOG(netsurf, INFO, "icon %s error: %s", nsurl_access(hlcache_handle_get_url(ico)), event->data.error); + /* fall through */ + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(ico); /* clear reference to released handle */ diff --git a/render/html_css.c b/render/html_css.c index 303bee64d..45bc16f56 100644 --- a/render/html_css.c +++ b/render/html_css.c @@ -113,6 +113,8 @@ html_convert_css_callback(hlcache_handle *css, NSLOG(netsurf, INFO, "stylesheet %s failed: %s", nsurl_access(hlcache_handle_get_url(css)), event->data.error); + /* fall through */ + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(css); s->sheet = NULL; diff --git a/render/html_script.c b/render/html_script.c index 186e5203b..c73a4806d 100644 --- a/render/html_script.c +++ b/render/html_script.c @@ -96,7 +96,7 @@ nserror html_script_exec(html_content *c) s->already_started = true; - } + } } } @@ -105,8 +105,8 @@ nserror html_script_exec(html_content *c) /* create new html script entry */ static struct html_script * -html_process_new_script(html_content *c, - dom_string *mimetype, +html_process_new_script(html_content *c, + dom_string *mimetype, enum html_script_type type) { struct html_script *nscript; @@ -176,6 +176,8 @@ convert_script_async_cb(hlcache_handle *script, NSLOG(netsurf, INFO, "script %s failed: %s", nsurl_access(hlcache_handle_get_url(script)), event->data.error); + /* fall through */ + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(script); s->data.handle = NULL; @@ -233,6 +235,8 @@ convert_script_defer_cb(hlcache_handle *script, NSLOG(netsurf, INFO, "script %s failed: %s", nsurl_access(hlcache_handle_get_url(script)), event->data.error); + /* fall through */ + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(script); s->data.handle = NULL; @@ -301,7 +305,7 @@ convert_script_sync_cb(hlcache_handle *script, err = dom_hubbub_parser_pause(parent->parser, false); if (err != DOM_HUBBUB_OK) { NSLOG(netsurf, INFO, "unpause returned 0x%x", err); - } + } break; @@ -309,8 +313,9 @@ convert_script_sync_cb(hlcache_handle *script, NSLOG(netsurf, INFO, "script %s failed: %s", nsurl_access(hlcache_handle_get_url(script)), event->data.error); - case CONTENT_MSG_ERRORCODE: + /* fall through */ + case CONTENT_MSG_ERRORCODE: hlcache_handle_release(script); s->data.handle = NULL; parent->base.active--; @@ -324,7 +329,7 @@ convert_script_sync_cb(hlcache_handle *script, err = dom_hubbub_parser_pause(parent->parser, false); if (err != DOM_HUBBUB_OK) { NSLOG(netsurf, INFO, "unpause returned 0x%x", err); - } + } break; @@ -376,10 +381,10 @@ exec_src_script(html_content *c, * * Syncronously pause the parent parse and continue after * the script has downloaded and executed. (default) - * Async Start the script downloading and execute it when it - * becomes available. - * Defered Start the script downloading and execute it when - * the page has completed parsing, may be set along + * Async Start the script downloading and execute it when it + * becomes available. + * Defered Start the script downloading and execute it when + * the page has completed parsing, may be set along * with async where it is ignored. */ @@ -388,7 +393,7 @@ exec_src_script(html_content *c, * value or the attribute name itself are valid. However * various browsers interpret this in various ways the most * compatible approach is to be liberal and accept any - * value. Note setting the values to "false" still makes them true! + * value. Note setting the values to "false" still makes them true! */ exc = dom_element_has_attribute(node, corestring_dom_async, &async); if (exc != DOM_NO_ERR) { @@ -401,7 +406,7 @@ exec_src_script(html_content *c, script_cb = convert_script_async_cb; } else { - exc = dom_element_has_attribute(node, + exc = dom_element_has_attribute(node, corestring_dom_defer, &defer); if (exc != DOM_NO_ERR) { return DOM_HUBBUB_OK; /* dom error */ @@ -444,14 +449,14 @@ exec_src_script(html_content *c, if (ns_error != NSERROR_OK) { /* @todo Deal with fetch error better. currently assume - * fetch never became active + * fetch never became active */ /* mark duff script fetch as already started */ - nscript->already_started = true; + nscript->already_started = true; NSLOG(netsurf, INFO, "Fetch failed with error %d", ns_error); } else { /* update base content active fetch count */ - c->base.active++; + c->base.active++; NSLOG(netsurf, INFO, "%d fetches active", c->base.active); switch (script_type) { -- cgit v1.2.1 From 8afeffedad0d7c3e63929f2e6a78f2e71aa1f773 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 11 Sep 2017 16:44:46 +0100 Subject: fix warning due to undefined bitmap structure --- desktop/browser_history.h | 1 + 1 file changed, 1 insertion(+) diff --git a/desktop/browser_history.h b/desktop/browser_history.h index d2021198c..9b6f1fd42 100644 --- a/desktop/browser_history.h +++ b/desktop/browser_history.h @@ -37,6 +37,7 @@ struct browser_window; struct history_entry; +struct bitmap; /** * Go back in the history. -- cgit v1.2.1 From b9bdc8d3125bf656d865c1015b1fbb7b1be15f8d Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 11 Sep 2017 17:29:57 +0100 Subject: fix image cache format specifiers signedness --- content/handlers/image/image_cache.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/content/handlers/image/image_cache.c b/content/handlers/image/image_cache.c index 7fba11fb9..a1de01da5 100644 --- a/content/handlers/image/image_cache.c +++ b/content/handlers/image/image_cache.c @@ -636,7 +636,7 @@ case chr : \ FMTCHR('b', PRIssizet, params.hysteresis); FMTCHR('c', PRIssizet, total_bitmap_size); FMTCHR('d', "d", bitmap_count); - FMTCHR('e', "d", current_age / 1000); + FMTCHR('e', "u", current_age / 1000); FMTCHR('f', PRIssizet, max_bitmap_size); FMTCHR('g', "d", max_bitmap_size_count); FMTCHR('h', "d", max_bitmap_count); @@ -645,7 +645,7 @@ case chr : \ case 'j': slen += snprintf(string + slen, size - slen, - "%d", pct?100:op_count); + "%u", pct?100:op_count); break; FMTPCHR('k', "d", hit_count, op_count); @@ -665,7 +665,7 @@ case chr : \ FMTCHR('t', "d", specultive_miss_count); FMTCHR('u', "d", total_extra_conversions); FMTCHR('v', "d", total_extra_conversions_count); - FMTCHR('w', "d", peak_conversions_size); + FMTCHR('w', "u", peak_conversions_size); FMTCHR('x', "d", peak_conversions); @@ -688,8 +688,11 @@ case chr : \ } /* exported interface documented in image_cache.h */ -int image_cache_snentryf(char *string, size_t size, unsigned int entryn, - const char *fmt) +int +image_cache_snentryf(char *string, + size_t size, + unsigned int entryn, + const char *fmt) { struct image_cache_entry_s *centry; size_t slen = 0; /* current output string length */ @@ -706,7 +709,7 @@ int image_cache_snentryf(char *string, size_t size, unsigned int entryn, switch (fmt[fmtc]) { case 'e': slen += snprintf(string + slen, size - slen, - "%d", entryn); + "%u", entryn); break; case 'r': -- cgit v1.2.1 From ff312f214e58ceb5b509540a64671d82f82701da Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 11 Sep 2017 17:33:35 +0100 Subject: fix format specifiers signedness in atari settings --- frontends/atari/settings.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/frontends/atari/settings.c b/frontends/atari/settings.c index ac4afa315..7084bacf7 100644 --- a/frontends/atari/settings.c +++ b/frontends/atari/settings.c @@ -257,15 +257,15 @@ static void display_settings(void) /* "Cache" tab: */ tmp_option_memory_cache_size = nsoption_int(memory_cache_size) / (1024*1024); - snprintf( spare, 255, "%d", tmp_option_memory_cache_size ); + snprintf( spare, 255, "%u", tmp_option_memory_cache_size ); set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 4 ); tmp_option_disc_cache_size = nsoption_int(disc_cache_size) / (1024*1024); - snprintf( spare, 255, "%d", tmp_option_disc_cache_size ); + snprintf( spare, 255, "%u", tmp_option_disc_cache_size ); set_text( SETTINGS_STR_MAX_DISC_CACHE, spare, 4 ); tmp_option_disc_cache_age = nsoption_int(disc_cache_age); - snprintf( spare, 255, "%02d", tmp_option_disc_cache_age ); + snprintf( spare, 255, "%02u", tmp_option_disc_cache_age ); set_text( SETTINGS_EDIT_CACHE_AGE, spare, 3 ); /* "Paths" tab: */ @@ -303,7 +303,7 @@ static void display_settings(void) // TODO: activate this option? tmp_option_min_reflow_period = nsoption_int(min_reflow_period); - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); + snprintf( spare, 255, "%04u", tmp_option_min_reflow_period ); set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, INPUT_MIN_REFLOW_PERIOD_MAX_LEN ); @@ -597,7 +597,7 @@ static void form_event(int index, int external) tmp_option_memory_cache_size = 1; if( tmp_option_memory_cache_size > 999 ) tmp_option_memory_cache_size = 999; - snprintf( spare, 255, "%02d", tmp_option_memory_cache_size ); + snprintf( spare, 255, "%02u", tmp_option_memory_cache_size ); set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 5 ); is_button = true; OBJ_REDRAW(SETTINGS_STR_MAX_MEM_CACHE); @@ -614,7 +614,7 @@ static void form_event(int index, int external) tmp_option_disc_cache_size = 1; if( tmp_option_disc_cache_size > 9999 ) tmp_option_disc_cache_size = 9999; - snprintf( spare, 255, "%02d", tmp_option_disc_cache_size ); + snprintf( spare, 255, "%02u", tmp_option_disc_cache_size ); set_text( SETTINGS_STR_MAX_DISC_CACHE, spare, 5 ); is_button = true; OBJ_REDRAW(SETTINGS_STR_MAX_DISC_CACHE); @@ -630,7 +630,7 @@ static void form_event(int index, int external) if( tmp_option_disc_cache_age > 99 ) tmp_option_disc_cache_age = 0; - snprintf( spare, 255, "%02d", tmp_option_disc_cache_age ); + snprintf( spare, 255, "%02u", tmp_option_disc_cache_age ); set_text( SETTINGS_EDIT_CACHE_AGE, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_CACHE_AGE); @@ -645,7 +645,7 @@ static void form_event(int index, int external) if( tmp_option_max_cached_fetch_handles > 31 ) tmp_option_max_cached_fetch_handles = 31; - snprintf( spare, 255, "%02d", tmp_option_max_cached_fetch_handles ); + snprintf( spare, 255, "%02u", tmp_option_max_cached_fetch_handles ); set_text( SETTINGS_EDIT_MAX_CACHED_CONNECTIONS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_CACHED_CONNECTIONS); @@ -660,7 +660,7 @@ static void form_event(int index, int external) if( tmp_option_max_fetchers > 31 ) tmp_option_max_fetchers = 31; - snprintf( spare, 255, "%02d", tmp_option_max_fetchers ); + snprintf( spare, 255, "%02u", tmp_option_max_fetchers ); set_text( SETTINGS_EDIT_MAX_FETCHERS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS); @@ -675,7 +675,7 @@ static void form_event(int index, int external) if( tmp_option_max_fetchers_per_host > 31 ) tmp_option_max_fetchers_per_host = 31; - snprintf( spare, 255, "%02d", tmp_option_max_fetchers_per_host ); + snprintf( spare, 255, "%02u", tmp_option_max_fetchers_per_host ); set_text( SETTINGS_EDIT_MAX_FETCHERS_PER_HOST, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS_PER_HOST); @@ -691,7 +691,7 @@ static void form_event(int index, int external) if( tmp_option_expire_url > 99 ) tmp_option_expire_url = 0; - snprintf( spare, 255, "%02d", tmp_option_expire_url ); + snprintf( spare, 255, "%02u", tmp_option_expire_url ); set_text( SETTINGS_EDIT_HISTORY_AGE, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_HISTORY_AGE); @@ -726,7 +726,7 @@ static void form_event(int index, int external) if( tmp_option_font_min_size < 10 ) tmp_option_font_min_size = 10; - snprintf( spare, 255, "%03d", tmp_option_font_min_size ); + snprintf( spare, 255, "%03u", tmp_option_font_min_size ); set_text( SETTINGS_EDIT_MIN_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_FONT_SIZE); @@ -744,7 +744,7 @@ static void form_event(int index, int external) if( tmp_option_font_size < 50 ) tmp_option_font_size = 50; - snprintf( spare, 255, "%03d", tmp_option_font_size ); + snprintf( spare, 255, "%03u", tmp_option_font_size ); set_text( SETTINGS_EDIT_DEF_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_DEF_FONT_SIZE); @@ -760,7 +760,7 @@ static void form_event(int index, int external) if( tmp_option_min_reflow_period > 9999 ) tmp_option_min_reflow_period = 10; - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); + snprintf( spare, 255, "%04u", tmp_option_min_reflow_period ); set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, 4 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_REFLOW_PERIOD); -- cgit v1.2.1 From 0a6e8fc0b072da21c7ec9c8d602b7ffad6bd4100 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 11 Sep 2017 17:42:49 +0100 Subject: fix beos throbber allocation --- frontends/beos/throbber.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontends/beos/throbber.cpp b/frontends/beos/throbber.cpp index 27ed42352..315afef83 100644 --- a/frontends/beos/throbber.cpp +++ b/frontends/beos/throbber.cpp @@ -64,7 +64,7 @@ bool nsbeos_throbber_initialise_from_png(const int frames, ...) return false; } - throb = (struct nsbeos_throbber *)malloc(sizeof(throb)); + throb = (struct nsbeos_throbber *)malloc(sizeof(*throb)); throb->nframes = frames; throb->framedata = (BBitmap **)malloc(sizeof(BBitmap *) * throb->nframes); -- cgit v1.2.1 From db6b3441c412cdc2e6eb197f9601056c2c85dcf8 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 11 Sep 2017 18:27:10 +0100 Subject: Treeview: Scroll to top when treeview search bar is modified. --- desktop/treeview.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 85bc61d8e..3bbc83928 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -363,6 +363,27 @@ static inline void treeview__cw_update_size( } +/** + * Corewindow callback_wrapper: Scroll to top of window. + * + * \param[in] tree The treeview to scroll. + */ +static inline void treeview__cw_scroll_top( + const struct treeview *tree) +{ + struct rect r = { + .x0 = 0, + .y0 = 0, + .x1 = tree_g.window_padding, + .y1 = tree_g.line_height, + }; + + if (tree->cw_t != NULL) { + tree->cw_t->scroll_visible(tree->cw_h, &r); + } +} + + /** * Corewindow callback wrapper: Get window viewport dimensions * @@ -1609,7 +1630,6 @@ static nserror treeview__search_walk_cb( (struct treeview_node_entry *)n; bool matched = false; - for (int i = 0; i < sw->tree->n_fields; i++) { struct treeview_field *ef = &(sw->tree->fields[i + 1]); if (ef->flags & TREE_FLAG_SEARCHABLE) { @@ -1676,6 +1696,7 @@ static nserror treeview__search( } treeview__cw_update_size(tree, -1, height); + treeview__cw_scroll_top(tree); return NSERROR_OK; } -- cgit v1.2.1 From 0a0ad71bdb181bb309ba86d283704ba7b0e89dc1 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 11 Sep 2017 18:29:54 +0100 Subject: Treeview: Fix function namespace. --- desktop/treeview.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 3bbc83928..e6dcbc032 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -332,9 +332,9 @@ static struct treeview_resource treeview_res[TREE_RES_LAST] = { * \param[in] tree The treeview to request redraw on. * \param[in] r rectangle to redraw */ -static inline -void cw_invalidate_area(const struct treeview *tree, - const struct rect *r) +static inline void treeview__cw_invalidate_area( + const struct treeview *tree, + const struct rect *r) { if (tree->cw_t != NULL) { tree->cw_t->invalidate(tree->cw_h, r); @@ -833,7 +833,7 @@ treeview_create_node_folder(treeview *tree, r.y0 = treeview_node_y(tree, n); r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } } @@ -884,7 +884,7 @@ treeview_update_node_folder(treeview *tree, r.y0 = treeview_node_y(tree, folder); r.x1 = REDRAW_MAX; r.y1 = r.y0 + tree_g.line_height; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } return NSERROR_OK; @@ -956,7 +956,7 @@ treeview_update_node_entry(treeview *tree, r.y0 = treeview_node_y(tree, entry); r.x1 = REDRAW_MAX; r.y1 = r.y0 + entry->height; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } return NSERROR_OK; @@ -1043,7 +1043,7 @@ treeview_create_node_entry(treeview *tree, r.y0 = treeview_node_y(tree, n); r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } } @@ -1195,7 +1195,7 @@ static void treeview_edit_cancel(treeview *tree, bool redraw) r.y0 = tree->edit.y; r.x1 = tree->edit.x + tree->edit.w; r.y1 = tree->edit.y + tree->edit.h; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } } @@ -1537,7 +1537,7 @@ treeview_delete_node(treeview *tree, if (visible && !(flags & TREE_OPTION_SUPPRESS_REDRAW)) { r.x0 = 0; r.x1 = REDRAW_MAX; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } return NSERROR_OK; @@ -1738,7 +1738,7 @@ static void treeview_textarea_search_callback(void *data, r->y1 += tree_g.line_height; /* Redraw the textarea */ - cw_invalidate_area(tree, r); + treeview__cw_invalidate_area(tree, r); break; case TEXTAREA_MSG_TEXT_MODIFIED: @@ -2028,7 +2028,7 @@ nserror treeview_node_expand(treeview *tree, treeview_node *node) r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } return res; @@ -2137,7 +2137,7 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node) r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } return res; @@ -2184,7 +2184,7 @@ nserror treeview_contract(treeview *tree, bool all) treeview__cw_update_size(tree, -1, tree->root->height); /* Redraw */ - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); return NSERROR_OK; } @@ -2258,7 +2258,7 @@ nserror treeview_expand(treeview *tree, bool only_folders) r.x1 = REDRAW_MAX; r.y1 = tree->root->height; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } return res; } @@ -3712,7 +3712,7 @@ bool treeview_keypress(treeview *tree, uint32_t key) r.x1 = 600; r.y0 = 0; r.y1 = tree_g.line_height; - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); return true; case NS_KEY_NL: case NS_KEY_CR: @@ -3766,7 +3766,7 @@ bool treeview_keypress(treeview *tree, uint32_t key) } if (redraw) { - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } return true; @@ -3942,7 +3942,7 @@ static void treeview_textarea_callback(void *data, struct textarea_msg *msg) r->y1 += tree->edit.y; /* Redraw the textarea */ - cw_invalidate_area(tree, r); + treeview__cw_invalidate_area(tree, r); break; default: @@ -4102,7 +4102,7 @@ void treeview_edit_selection(treeview *tree) rect.y0 = y; rect.x1 = REDRAW_MAX; rect.y1 = y + tree_g.line_height; - cw_invalidate_area(tree, &rect); + treeview__cw_invalidate_area(tree, &rect); } @@ -4382,7 +4382,7 @@ treeview_node_mouse_action_cb(treeview_node *node, } if (redraw) { - cw_invalidate_area(ma->tree, &r); + treeview__cw_invalidate_area(ma->tree, &r); } *end = true; /* Reached line with click; stop walking tree */ @@ -4411,7 +4411,7 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) if (tree->search.active == false) { tree->search.active = true; if (treeview_clear_selection(tree, &r)) { - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } } textarea_mouse_action(tree->search.textarea, mouse, @@ -4463,7 +4463,7 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) tree->move.target_pos = TV_TARGET_NONE; treeview__cw_drag_status(tree, CORE_WINDOW_DRAG_NONE); - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); return; default: /* No drag to end */ @@ -4538,7 +4538,7 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) } if (redraw) { - cw_invalidate_area(tree, &r); + treeview__cw_invalidate_area(tree, &r); } } else { -- cgit v1.2.1 From 45a7e6269b2328de9178af76ff4aed41c2e69129 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 11 Sep 2017 19:52:07 +0100 Subject: Treeview: Slight simplification of treeview_walk_internal(). --- desktop/treeview.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index e6dcbc032..a6e3e609b 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -566,13 +566,12 @@ treeview_walk_internal(treeview_node *root, node = root; parent = node->parent; next_sibling = node->next_sib; - child = (!skip_children && - (full || (node->flags & TV_NFLAGS_EXPANDED))) ? + child = (full || (node->flags & TV_NFLAGS_EXPANDED)) ? node->children : NULL; while (node != NULL) { - if (child != NULL) { + if (child != NULL && !skip_children) { /* Down to children */ node = child; } else { @@ -639,7 +638,6 @@ treeview_walk_internal(treeview_node *root, return NSERROR_OK; } } - child = skip_children ? NULL : child; } return NSERROR_OK; } -- cgit v1.2.1 From f142b3684cd98ace5271c0a72600761585cdfa58 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 14 Sep 2017 20:07:42 +0100 Subject: Treeview: Track height of display in search view. --- desktop/treeview.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index a6e3e609b..029fd9dbe 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -218,6 +218,7 @@ struct treeview_search { struct textarea *textarea; /**< Search box. */ bool active; /**< Whether the search box has focus. */ bool search; /**< Whether we have a search term. */ + int height; /**< Current search display height. */ }; @@ -326,6 +327,20 @@ static struct treeview_resource treeview_res[TREE_RES_LAST] = { }; +/** + * Get the display height of the treeview data component of the display. + * + * \param[in] tree Treeview to get the height of. + * \return the display height in pixels. + */ +static inline int treeview__get_display_height(treeview *tree) +{ + return (tree->search.search == false) ? + tree->root->height : + tree->search.height; +} + + /** * Corewindow callback wrapper: Request a redraw of the window * @@ -1645,7 +1660,7 @@ static nserror treeview__search_walk_cb( if (matched) { n->flags |= TV_NFLAGS_MATCHED; - sw->window_height += tree_g.line_height; + sw->window_height += n->height; } else { n->flags &= ~TV_NFLAGS_MATCHED; } @@ -1670,12 +1685,20 @@ static nserror treeview__search( { nserror err; uint32_t height; + uint32_t prev_height = treeview__get_display_height(tree); + int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ? + tree_g.line_height : 0; struct treeview_search_walk_data sw = { .len = len, .text = text, .tree = tree, .window_height = 0, }; + struct rect r = { + .x0 = 0, + .y0 = search_height, + .x1 = REDRAW_MAX, + }; assert(text[len] == '\0'); @@ -1686,6 +1709,7 @@ static nserror treeview__search( } if (len > 0) { + tree->search.height = sw.window_height; tree->search.search = true; height = sw.window_height; } else { @@ -1693,7 +1717,9 @@ static nserror treeview__search( height = tree->root->height; } - treeview__cw_update_size(tree, -1, height); + r.y1 = ((height > prev_height) ? height : prev_height) + search_height; + treeview__cw_invalidate_area(tree, &r); + treeview__cw_update_size(tree, -1, height + search_height); treeview__cw_scroll_top(tree); return NSERROR_OK; @@ -2565,7 +2591,7 @@ static void treeview_redraw_search( count++; inset = x + tree_g.window_padding; - height = tree_g.line_height; + height = node->height; if ((render_y + height) < r->y0) { /* This node's line is above clip region */ @@ -4469,7 +4495,7 @@ treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y) } } - if (y > tree->root->height + search_height) { + if (y > treeview__get_display_height(tree) + search_height) { /* Below tree */ r.x0 = 0; @@ -4560,13 +4586,14 @@ int treeview_get_height(treeview *tree) { int search_height = (tree->flags & TREEVIEW_SEARCHABLE) ? tree_g.line_height : 0; + int height = treeview__get_display_height(tree); assert(tree != NULL); assert(tree->root != NULL); - treeview__cw_update_size(tree, -1, tree->root->height); + treeview__cw_update_size(tree, -1, height); - return tree->root->height + search_height; + return height + search_height; } -- cgit v1.2.1 From 283fb3633938971d04b2bf8f2b690ce9c8a83951 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 14 Sep 2017 20:10:30 +0100 Subject: Treeview: Update treeview walker to handle walking the filtered display. --- desktop/treeview.c | 200 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 137 insertions(+), 63 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 029fd9dbe..7ba487a63 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -552,11 +552,36 @@ static int treeview_node_y(treeview *tree, treeview_node *node) } +/** + * The treeview walk mode. Controls which nodes are visited in a walk. + */ +enum treeview_walk_mode { + /** + * Walk to all nodes in the (sub)tree. + */ + TREEVIEW_WALK_MODE_LOGICAL_COMPLETE, + + /** + * Walk to expanded nodes in the (sub)tree only. Children of + * collapsed nodes are not visited. + */ + TREEVIEW_WALK_MODE_LOGICAL_EXPANDED, + + /** + * Walk displayed nodes. This differs from the + * `TREEVIEW_WALK_MODE_LOGICAL_EXPANDED` mode when there is + * an active search filter display. + */ + TREEVIEW_WALK_MODE_DISPLAY, +}; + + /** * Walk a treeview subtree, calling a callback at each node (depth first) * + * \param tree Treeview being walked. * \param root Root to walk tree from (doesn't get a callback call) - * \param full Iff true, visit children of collapsed nodes + * \param mode The treeview walk mode to use. * \param callback_bwd Function to call on each node in backwards order * \param callback_fwd Function to call on each node in forwards order * \param ctx Context to pass to callback @@ -564,20 +589,37 @@ static int treeview_node_y(treeview *tree, treeview_node *node) * * \note Any node deletion must happen in callback_bwd. */ -static nserror -treeview_walk_internal(treeview_node *root, - bool full, - nserror (*callback_bwd)(treeview_node *n, void *ctx, bool *end), - nserror (*callback_fwd)(treeview_node *n, void *ctx, bool *skip_children, bool *end), - void *ctx) +static nserror treeview_walk_internal( + treeview *tree, + treeview_node *root, + enum treeview_walk_mode mode, + nserror (*callback_bwd)( + treeview_node *n, + void *ctx, + bool *end), + nserror (*callback_fwd)( + treeview_node *n, + void *ctx, + bool *skip_children, + bool *end), + void *ctx) { treeview_node *node, *child, *parent, *next_sibling; - bool abort = false; + bool walking_search = (mode == TREEVIEW_WALK_MODE_DISPLAY && + tree->search.search == true); bool skip_children = false; + bool abort = false; + bool full = false; nserror err; + bool entry; assert(root != NULL); + if (mode == TREEVIEW_WALK_MODE_LOGICAL_COMPLETE || walking_search) { + /* We need to visit children of collapsed folders. */ + full = true; + } + node = root; parent = node->parent; next_sibling = node->next_sib; @@ -594,9 +636,10 @@ treeview_walk_internal(treeview_node *root, * go to next sibling if present, or nearest ancestor * with a next sibling. */ - while (node != root && - next_sibling == NULL) { - if (callback_bwd != NULL) { + while (node != root && next_sibling == NULL) { + entry = (node->type == TREE_NODE_ENTRY); + if (callback_bwd != NULL && + (entry || !walking_search)) { /* Backwards callback */ err = callback_bwd(node, ctx, &abort); @@ -636,11 +679,18 @@ treeview_walk_internal(treeview_node *root, assert(node != NULL); assert(node != root); + entry = (node->type == TREE_NODE_ENTRY); + parent = node->parent; next_sibling = node->next_sib; child = (full || (node->flags & TV_NFLAGS_EXPANDED)) ? node->children : NULL; + if (walking_search && (!entry || + !(node->flags & TV_NFLAGS_MATCHED))) { + continue; + } + if (callback_fwd != NULL) { /* Forwards callback */ err = callback_fwd(node, ctx, &skip_children, &abort); @@ -723,14 +773,17 @@ treeview_set_inset_from_parent(treeview_node *n, /** * Insert a treeview node into a treeview * - * \param a parentless node to insert - * \param b tree node to insert a as a relation of + * \param tree the treeview to insert node into. + * \param a parentless node to insert + * \param b tree node to insert a as a relation of * \param rel The relationship between \a a and \a b */ static inline void -treeview_insert_node(treeview_node *a, - treeview_node *b, - enum treeview_relationship rel) +treeview_insert_node( + treeview *tree, + treeview_node *a, + treeview_node *b, + enum treeview_relationship rel) { assert(a != NULL); assert(a->parent == NULL); @@ -765,8 +818,9 @@ treeview_insert_node(treeview_node *a, a->inset = a->parent->inset + tree_g.step_width; if (a->children != NULL) { - treeview_walk_internal(a, true, NULL, - treeview_set_inset_from_parent, NULL); + treeview_walk_internal(tree, a, + TREEVIEW_WALK_MODE_LOGICAL_COMPLETE, NULL, + treeview_set_inset_from_parent, NULL); } if (a->parent->flags & TV_NFLAGS_EXPANDED) { @@ -831,7 +885,7 @@ treeview_create_node_folder(treeview *tree, n->client_data = data; - treeview_insert_node(n, relation, rel); + treeview_insert_node(tree, n, relation, rel); if (n->parent->flags & TV_NFLAGS_EXPANDED) { /* Inform front end of change in dimensions */ @@ -1041,7 +1095,7 @@ treeview_create_node_entry(treeview *tree, e->fields[i - 1].value.width = 0; } - treeview_insert_node(n, relation, rel); + treeview_insert_node(tree, n, relation, rel); if (n->parent->flags & TV_NFLAGS_EXPANDED) { /* Inform front end of change in dimensions */ @@ -1142,7 +1196,8 @@ treeview_walk(treeview *tree, if (root == NULL) root = tree->root; - return treeview_walk_internal(root, true, + return treeview_walk_internal(tree, root, + TREEVIEW_WALK_MODE_LOGICAL_COMPLETE, (leave_cb != NULL) ? treeview_walk_bwd_cb : NULL, (enter_cb != NULL) ? treeview_walk_fwd_cb : NULL, &tw); @@ -1370,8 +1425,9 @@ treeview_delete_node_internal(treeview *tree, } /* Delete any children first */ - err = treeview_walk_internal(n, true, treeview_delete_node_walk_cb, - NULL, &nd); + err = treeview_walk_internal(tree, n, + TREEVIEW_WALK_MODE_LOGICAL_COMPLETE, + treeview_delete_node_walk_cb, NULL, &nd); if (err != NSERROR_OK) { return err; } @@ -1702,7 +1758,8 @@ static nserror treeview__search( assert(text[len] == '\0'); - err = treeview_walk_internal(tree->root, true, NULL, + err = treeview_walk_internal(tree, tree->root, + TREEVIEW_WALK_MODE_LOGICAL_COMPLETE, NULL, treeview__search_walk_cb, &sw); if (err != NSERROR_OK) { return err; @@ -2129,8 +2186,8 @@ treeview_node_contract_internal(treeview *tree, treeview_node *node) selected = node->flags & TV_NFLAGS_SELECTED; /* Contract children. */ - treeview_walk_internal(node, false, treeview_node_contract_cb, - NULL, &data); + treeview_walk_internal(tree, node, TREEVIEW_WALK_MODE_LOGICAL_EXPANDED, + treeview_node_contract_cb, NULL, &data); /* Contract node */ treeview_node_contract_cb(node, &data, false); @@ -2194,8 +2251,9 @@ nserror treeview_contract(treeview *tree, bool all) selected = n->flags & TV_NFLAGS_SELECTED; /* Contract children. */ - treeview_walk_internal(n, false, - treeview_node_contract_cb, NULL, &data); + treeview_walk_internal(tree, n, + TREEVIEW_WALK_MODE_LOGICAL_EXPANDED, + treeview_node_contract_cb, NULL, &data); /* Contract node */ treeview_node_contract_cb(n, &data, false); @@ -2269,11 +2327,9 @@ nserror treeview_expand(treeview *tree, bool only_folders) data.tree = tree; data.only_folders = only_folders; - res = treeview_walk_internal(tree->root, - true, - NULL, - treeview_expand_cb, - &data); + res = treeview_walk_internal(tree, tree->root, + TREEVIEW_WALK_MODE_LOGICAL_COMPLETE, + NULL, treeview_expand_cb, &data); if (res == NSERROR_OK) { /* expansion succeeded, schedule redraw */ @@ -3062,8 +3118,9 @@ bool treeview_has_selection(treeview *tree) sw.purpose = TREEVIEW_WALK_HAS_SELECTION; sw.data.has_selection = false; - treeview_walk_internal(tree->root, false, NULL, - treeview_node_s