diff options
Diffstat (limited to 'utils/messages.c')
-rw-r--r-- | utils/messages.c | 89 |
1 files changed, 74 insertions, 15 deletions
diff --git a/utils/messages.c b/utils/messages.c index 0c558cdfc..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; @@ -338,6 +345,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,9 +361,29 @@ 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_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_SPRITE_ERROR: + /* A RISC OS Sprite error occurred */ + return messages_get_ctx("SpriteError", 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 */ @@ -398,12 +429,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 */ + /* 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); return messages_get_ctx("Unknown", messages_hash); } |