Mercurial > hg > dmlib
changeset 1198:5d20c80df290
Improve probing.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Mar 2015 16:14:40 +0200 |
parents | 0ee6ba7b3e4a |
children | a79edf59d5d8 |
files | minijss/jloadjss.c minijss/jloadxm.c |
diffstat | 2 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/minijss/jloadjss.c Thu Mar 05 16:02:02 2015 +0200 +++ b/minijss/jloadjss.c Thu Mar 05 16:14:40 2015 +0200 @@ -329,11 +329,17 @@ if (jssH.idVersion != JSSMOD_VERSION) { + if (probe) + return DMERR_VERSION; + else JSSERROR(DMERR_VERSION, DMERR_VERSION, "Unsupported version of JSSMOD 0x%4x, this version only supports 0x%4x!\n", jssH.idVersion, JSSMOD_VERSION); } + if (probe) + return DMERR_OK; + // Allocate the module module = jssAllocateModule(); if (module == NULL)
--- a/minijss/jloadxm.c Thu Mar 05 16:02:02 2015 +0200 +++ b/minijss/jloadxm.c Thu Mar 05 16:14:40 2015 +0200 @@ -915,12 +915,14 @@ if (xmH.unUsed1A != 0x1a) { + if (!probe) JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Possibly modified or corrupted XM [%x]\n", xmH.unUsed1A); } if (xmH.norders > XM_MaxOrders) { + if (!probe) JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Number of orders %d > %d, possibly broken module.\n", xmH.norders, XM_MaxOrders); @@ -929,12 +931,14 @@ if (xmH.norders == 0) { + if (!probe) JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Number of orders was zero.\n"); } if (xmH.npatterns > XM_MaxPatterns) { + if (!probe) JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Number of patterns %d > %d, possibly broken module.\n", xmH.npatterns, XM_MaxPatterns); @@ -943,6 +947,7 @@ if (xmH.npatterns == 0) { + if (!probe) JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Number of patterns was zero.\n"); } @@ -956,6 +961,7 @@ if (xmH.ninstruments <= 0 || xmH.ninstruments > XM_MaxInstruments) { + if (!probe) JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Number of instruments was invalid, %d (should be 1 - %d).\n", xmH.ninstruments, XM_MaxInstruments); @@ -963,6 +969,9 @@ if (xmH.headSize < XM_HeaderSize) { + if (probe) + return DMERR_NOT_SUPPORTED; + else JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, "XM header size less than %d bytes (%d bytes).\n", XM_HeaderSize, xmH.headSize); @@ -975,6 +984,7 @@ break; default: + if (!probe) JSSWARNING(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, "Unsupported version of XM format 0x%04x.\n", xmH.version); @@ -994,6 +1004,9 @@ dmfseek(inFile, xmH.headSize - XM_HeaderSize, SEEK_CUR); } + if (probe) + return DMERR_OK; + /* Okay, allocate a module structure */ module = jssAllocateModule();