Mercurial > hg > dmlib
changeset 2114:27cf33c3a646
Return actual error code from enc and dec functions instead of just BOOL.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 26 May 2019 02:43:08 +0300 |
parents | 3fcf1c3a3287 |
children | 51b8826bd4c1 |
files | tools/lib64fmts.c tools/lib64gfx.c tools/lib64gfx.h |
diffstat | 3 files changed, 20 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/lib64fmts.c Sun May 26 01:16:57 2019 +0300 +++ b/tools/lib64fmts.c Sun May 26 02:43:08 2019 +0300 @@ -47,7 +47,7 @@ } -static BOOL fmtEncodeMicroIllustrator(const DMC64EncDecOp *op, DMGrowBuf *buf, +static int fmtEncodeMicroIllustrator(const DMC64EncDecOp *op, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageCommonFormat *fmt) { (void) op; @@ -57,7 +57,7 @@ memcpy(buf->data + 2, fmtMicroIllustratorMagicID_1, sizeof(fmtMicroIllustratorMagicID_1)); memcpy(buf->data + 9, fmtMicroIllustratorMagicID_2, sizeof(fmtMicroIllustratorMagicID_2)); - return TRUE; + return DMERR_OK; } @@ -242,7 +242,7 @@ } -static BOOL fmtDrazLaceGetLaceType(const DMC64EncDecOp *op, DMC64Image *img, +static int fmtDrazLaceGetLaceType(const DMC64EncDecOp *op, DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt) { (void) fmt; @@ -252,16 +252,16 @@ else img->laceType = D64_ILACE_RES; - return TRUE; + return DMERR_OK; } -static BOOL fmtDrazLaceSetLaceType(const DMC64EncDecOp *op, DMGrowBuf *buf, +static int fmtDrazLaceSetLaceType(const DMC64EncDecOp *op, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageCommonFormat *fmt) { (void) fmt; buf->data[op->offs] = (img->laceType == D64_ILACE_RES) ? 1 : 0; - return TRUE; + return DMERR_OK; } @@ -364,16 +364,18 @@ } -static BOOL fmtEncodeGunPaint(const DMC64EncDecOp *op, DMGrowBuf *buf, +static int fmtEncodeGunPaint(const DMC64EncDecOp *op, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageCommonFormat *fmt) { (void) op; (void) img; (void) fmt; + // Here we assume that the op triggering this function is // at the end of the oplist, so the memory is allocated, memcpy(buf->data + fmtGunPaintMagicOffs + 2, fmtGunPaintMagicID, fmtGunPaintMagicLen); - return TRUE; + + return DMERR_OK; } @@ -577,14 +579,14 @@ } -static BOOL fmtTruePaintGetLaceType(const DMC64EncDecOp *op, DMC64Image *img, +static int fmtTruePaintGetLaceType(const DMC64EncDecOp *op, DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt) { (void) op; (void) buf; (void) fmt; img->laceType = D64_ILACE_RES; - return TRUE; + return DMERR_OK; } @@ -961,14 +963,14 @@ } -static BOOL fmtECIGetLaceType(const DMC64EncDecOp *op, DMC64Image *img, +static int fmtECIGetLaceType(const DMC64EncDecOp *op, DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt) { (void) op; (void) buf; (void) fmt; img->laceType = D64_ILACE_COLOR; - return TRUE; + return DMERR_OK; }
--- a/tools/lib64gfx.c Sun May 26 01:16:57 2019 +0300 +++ b/tools/lib64gfx.c Sun May 26 02:43:08 2019 +0300 @@ -1056,9 +1056,9 @@ case DO_FUNC: if (op->decFunction != NULL && - !op->decFunction(op, img, buf, fmt->format)) + (res = op->decFunction(op, img, buf, fmt->format)) != DMERR_OK) { - return dmError(DMERR_INTERNAL, + return dmError(res, "Decode op custom function failed: op #%d, " "offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); @@ -1236,9 +1236,9 @@ case DO_FUNC: if (op->encFunction != NULL && - !op->encFunction(op, buf, img, fmt->format)) + (res = op->encFunction(op, buf, img, fmt->format)) != DMERR_OK) { - res = dmError(DMERR_INTERNAL, + dmErrorMsg( "Encode op custom function failed: op #%d, " "offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len);
--- a/tools/lib64gfx.h Sun May 26 01:16:57 2019 +0300 +++ b/tools/lib64gfx.h Sun May 26 02:43:08 2019 +0300 @@ -184,8 +184,8 @@ size_t size; // Size of data (0 for "default") size_t offs2; // Offset in data-block - BOOL (*decFunction)(const struct _DMC64EncDecOp *op, DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt); - BOOL (*encFunction)(const struct _DMC64EncDecOp *op, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageCommonFormat *fmt); + int (*decFunction)(const struct _DMC64EncDecOp *op, DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt); + int (*encFunction)(const struct _DMC64EncDecOp *op, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageCommonFormat *fmt); } DMC64EncDecOp;