summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-08-15 11:50:08 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2012-08-15 11:50:08 +0100
commitfcb7143ecb0c1acedfb30d34931896dbefc660b1 (patch)
tree483fc6697869ac7aea386818086d91f926585dac /content
parentc3f9e3d3cea7bddb708fb0c75d9b4ed31e6341d7 (diff)
downloadnetsurf-fcb7143ecb0c1acedfb30d34931896dbefc660b1.tar.gz
netsurf-fcb7143ecb0c1acedfb30d34931896dbefc660b1.tar.bz2
Simplify content status text setting.
Diffstat (limited to 'content')
-rw-r--r--content/content.c53
-rw-r--r--content/content_protected.h2
2 files changed, 25 insertions, 30 deletions
diff --git a/content/content.c b/content/content.c
index b80626cdf..8b089cd1e 100644
--- a/content/content.c
+++ b/content/content.c
@@ -59,7 +59,6 @@ const char * const content_status_name[] = {
static nserror content_llcache_callback(llcache_handle *llcache,
const llcache_event *event, void *pw);
static void content_convert(struct content *c);
-static void content_update_status(struct content *c);
/**
@@ -169,7 +168,7 @@ nserror content_llcache_callback(llcache_handle *llcache,
(void) llcache_handle_get_source_data(llcache, &source_size);
- content_set_status(c, messages_get("Processing"), source_size);
+ content_set_status(c, messages_get("Processing"));
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
content_convert(c);
@@ -182,7 +181,7 @@ nserror content_llcache_callback(llcache_handle *llcache,
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
break;
case LLCACHE_EVENT_PROGRESS:
- content_set_status(c, "%s", event->data.msg);
+ content_set_status(c, event->data.msg);
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
break;
}
@@ -207,31 +206,7 @@ bool content_can_reformat(hlcache_handle *h)
}
-/**
- * Updates content with new status.
- *
- * The textual status contained in the content is updated with given string.
- *
- * \param status_message new textual status
- */
-
-void content_set_status(struct content *c, const char *status_message, ...)
-{
- va_list ap;
- int len;
-
- va_start(ap, status_message);
- if ((len = vsnprintf(c->sub_status, sizeof (c->sub_status),
- status_message, ap)) < 0 ||
- (int)sizeof (c->sub_status) <= len)
- c->sub_status[sizeof (c->sub_status) - 1] = '\0';
- va_end(ap);
-
- content_update_status(c);
-}
-
-
-void content_update_status(struct content *c)
+static void content_update_status(struct content *c)
{
if (c->status == CONTENT_STATUS_LOADING ||
c->status == CONTENT_STATUS_READY) {
@@ -245,8 +220,28 @@ void content_update_status(struct content *c)
"%s (%.1fs)", messages_get("Done"),
(float) time / 100);
}
+}
+
+
+/**
+ * Updates content with new status.
+ *
+ * The textual status contained in the content is updated with given string.
+ *
+ * \param status_message new textual status
+ */
+
+void content_set_status(struct content *c, const char *status_message)
+{
+ size_t len = strlen(status_message);
- /* LOG(("%s", c->status_message)); */
+ if (len >= sizeof(c->sub_status)) {
+ len = sizeof(c->sub_status) - 1;
+ }
+ memcpy(c->sub_status, status_message, len);
+ c->sub_status[len] = '\0';
+
+ content_update_status(c);
}
diff --git a/content/content_protected.h b/content/content_protected.h
index ad0b0afa6..e37573493 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -160,7 +160,7 @@ void content_set_ready(struct content *c);
void content_set_done(struct content *c);
void content_set_error(struct content *c);
-void content_set_status(struct content *c, const char *status_message, ...);
+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);
void content_add_error(struct content *c, const char *token,