mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Add user-defined error and status codes.
This commit is contained in:
1 parent
90e49caf51
commit
3863427127
10 files changed
+282
-42
No files matched your search
+15
-4
@@ -63,6 +63,7 @@ typedef enum {
|
||||
puffs_gif_error_unexpected_eof = -10 + 1,
|
||||
puffs_gif_status_short_read = -12,
|
||||
puffs_gif_status_short_write = -14,
|
||||
puffs_gif_error_bad_gif_image = -256 + 1,
|
||||
} puffs_gif_status;
|
||||
|
||||
bool puffs_gif_status_is_error(puffs_gif_status s);
|
||||
@@ -121,7 +122,7 @@ bool puffs_gif_status_is_error(puffs_gif_status s) {
|
||||
return s & 1;
|
||||
}
|
||||
|
||||
const char* puffs_gif_status_strings[8] = {
|
||||
const char* puffs_gif_status_strings[9] = {
|
||||
"gif: ok",
|
||||
"gif: bad version",
|
||||
"gif: bad receiver",
|
||||
@@ -130,14 +131,21 @@ const char* puffs_gif_status_strings[8] = {
|
||||
"gif: unexpected EOF",
|
||||
"gif: short read",
|
||||
"gif: short write",
|
||||
"gif: bad GIF image",
|
||||
};
|
||||
|
||||
const char* puffs_gif_status_string(puffs_gif_status s) {
|
||||
s = -(s >> 1);
|
||||
if ((0 <= s) && (s < 8)) {
|
||||
return puffs_gif_status_strings[s];
|
||||
if (0 <= s) {
|
||||
if (s < 8) {
|
||||
return puffs_gif_status_strings[s];
|
||||
}
|
||||
s -= 120;
|
||||
if ((8 <= s) && (s < 9)) {
|
||||
return puffs_gif_status_strings[s];
|
||||
}
|
||||
}
|
||||
return "";
|
||||
return "gif: unknown status";
|
||||
}
|
||||
|
||||
// ---------------- Private Structs
|
||||
@@ -241,6 +249,9 @@ label_0_continue:;
|
||||
} else if (v_code == v_end_code) {
|
||||
status = puffs_gif_status_ok;
|
||||
goto cleanup0;
|
||||
} else {
|
||||
status = puffs_gif_error_bad_gif_image;
|
||||
goto cleanup0;
|
||||
}
|
||||
goto label_0_break;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ typedef enum {
|
||||
puffs_gif_error_unexpected_eof = -10 + 1,
|
||||
puffs_gif_status_short_read = -12,
|
||||
puffs_gif_status_short_write = -14,
|
||||
puffs_gif_error_bad_gif_image = -256 + 1,
|
||||
} puffs_gif_status;
|
||||
|
||||
bool puffs_gif_status_is_error(puffs_gif_status s);
|
||||
|
||||
Reference in new issue
Block a user