Changed error codes

This commit is contained in:
Pünkösd Marcell 2020-11-06 02:44:09 +01:00
parent cbb8da45ce
commit 3d5729f7b7
6 changed files with 37 additions and 27 deletions

View File

@ -193,5 +193,5 @@ uint8_t parse_caff_get_first_ciff(uint8_t *caff_data, uint64_t caff_data_len, ui
p += seek_by; p += seek_by;
} }
return CAFF_PARSE_ANIMATION_COUNT_ERROR; return CAFF_PARSE_UNKNOWN_ERROR;
} }

View File

@ -7,15 +7,18 @@
#include <stdint.h> #include <stdint.h>
#define CAFF_PARSE_SUCCESS 0 #define CAFF_PARSE_ERROR_PREFIX 0x10
#define CAFF_PARSE_LENGTH_ERROR 1 #define CAFF_PARSE_LENGTH_ERROR (CAFF_PARSE_ERROR_PREFIX + 0x01)
#define CAFF_PARSE_BAD_FRAME 2 #define CAFF_PARSE_BAD_FRAME (CAFF_PARSE_ERROR_PREFIX + 0x02)
#define CAFF_PARSE_HEADER_ERROR 3 #define CAFF_PARSE_HEADER_ERROR (CAFF_PARSE_ERROR_PREFIX + 0x03)
#define CAFF_PARSE_ANIMATION_COUNT_ERROR 4 #define CAFF_PARSE_ANIMATION_COUNT_ERROR (CAFF_PARSE_ERROR_PREFIX + 0x04)
#define CAFF_PARSE_NO_CREDITS_ERROR 5 #define CAFF_PARSE_NO_CREDITS_ERROR (CAFF_PARSE_ERROR_PREFIX + 0x05)
#define CAFF_PARSE_BAD_MAGIC 6 #define CAFF_PARSE_BAD_MAGIC (CAFF_PARSE_ERROR_PREFIX + 0x06)
#define CAFF_PARSE_BAD_DATE 7 #define CAFF_PARSE_BAD_DATE (CAFF_PARSE_ERROR_PREFIX + 0x07)
#define CAFF_PARSE_NO_DURATION 8 #define CAFF_PARSE_NO_DURATION (CAFF_PARSE_ERROR_PREFIX + 0x08)
#define CAFF_PARSE_UNKNOWN_ERROR (CAFF_PARSE_ERROR_PREFIX + 0x09)
#define CAFF_PARSE_SUCCESS 0x00
#define CAFF_FRAME_HEADER 0x1 #define CAFF_FRAME_HEADER 0x1
#define CAFF_FRAME_CREDITS 0x2 #define CAFF_FRAME_CREDITS 0x2

View File

@ -7,12 +7,14 @@
#include <stdint.h> #include <stdint.h>
#define CIFF_PARSE_UNKNOWN_ERROR 1 #define CIFF_PARSE_ERROR_PREFIX 0x20
#define CIFF_PARSE_HEADER_LENGTHS_INCORRECT 2 #define CIFF_PARSE_HEADER_LENGTHS_INCORRECT (CIFF_PARSE_ERROR_PREFIX + 0x01)
#define CIFF_PARSE_HEADER_DIMENSIONS_INCORRECT 3 #define CIFF_PARSE_HEADER_DIMENSIONS_INCORRECT (CIFF_PARSE_ERROR_PREFIX + 0x02)
#define CIFF_PARSE_HEADER_TOO_SHORT 4 #define CIFF_PARSE_HEADER_TOO_SHORT (CIFF_PARSE_ERROR_PREFIX + 0x03)
#define CIFF_PARSE_HEADER_BAD_MAGIC 5 #define CIFF_PARSE_HEADER_BAD_MAGIC (CIFF_PARSE_ERROR_PREFIX + 0x04)
#define CIFF_PARSE_SUCCESS 0 #define CIFF_PARSE_UNKNOWN_ERROR (CIFF_PARSE_ERROR_PREFIX + 0x05)
#define CIFF_PARSE_SUCCESS 0x00
typedef struct __attribute__ ((packed)) ciff_static_header_t { typedef struct __attribute__ ((packed)) ciff_static_header_t {
uint32_t magic; // should be equal to 0x46464943 (Because x86 is big-endian, so essentially this is in reverse) uint32_t magic; // should be equal to 0x46464943 (Because x86 is big-endian, so essentially this is in reverse)

View File

@ -7,7 +7,7 @@
uint8_t flip_image(const uint8_t *source, uint8_t *destination, uint64_t data_length, uint64_t width, uint64_t height) { uint8_t flip_image(const uint8_t *source, uint8_t *destination, uint64_t data_length, uint64_t width, uint64_t height) {
if ((width*height*3) != data_length) { if ((width*height*3) != data_length) {
return IMAGE_FLIP_FAIL; return IMAGE_FLIP_LENGTH_ERROR;
} }
for (uint64_t i = 0; i < height; i++) { for (uint64_t i = 0; i < height; i++) {

View File

@ -7,8 +7,11 @@
#include <stdint.h> #include <stdint.h>
#define IMAGE_FLIP_SUCCESS 0
#define IMAGE_FLIP_FAIL 0 #define IMAGE_FLIP_ERROR_PREFIX 0x30
#define IMAGE_FLIP_LENGTH_ERROR (IMAGE_FLIP_ERROR_PREFIX + 0x01)
#define IMAGE_FLIP_SUCCESS 0x00
uint8_t flip_image(const uint8_t* source, uint8_t* destination, uint64_t data_length, uint64_t width, uint64_t height); uint8_t flip_image(const uint8_t* source, uint8_t* destination, uint64_t data_length, uint64_t width, uint64_t height);

View File

@ -10,11 +10,13 @@
#include "magic_memory.h" #include "magic_memory.h"
#define FILE_READ_COULD_NOT_OPEN 1 #define FILE_READ_ERROR_PREFIX 0x00
#define FILE_READ_TOO_BIG 2 #define FILE_READ_COULD_NOT_OPEN (FILE_READ_ERROR_PREFIX + 0x01)
#define FILE_READ_COULD_NOT_ALLOCATE 3 #define FILE_READ_TOO_BIG (FILE_READ_ERROR_PREFIX + 0x02)
#define FILE_READ_ERROR 4 #define FILE_READ_COULD_NOT_ALLOCATE (FILE_READ_ERROR_PREFIX + 0x03)
#define FILE_READ_SUCCESS 0 #define FILE_READ_ERROR (FILE_READ_ERROR_PREFIX + 0x04)
#define FILE_READ_SUCCESS 0x00
bool contains(const uint8_t *data, uint64_t data_len, uint8_t what); bool contains(const uint8_t *data, uint64_t data_len, uint8_t what);