# HG changeset patch # User Matti Hamalainen # Date 1425564880 -7200 # Node ID 5d20c80df290a0a803a908454ce71c938ca5dee2 # Parent 0ee6ba7b3e4a1aaf72267711391d59b9a59cef97 Improve probing. diff -r 0ee6ba7b3e4a -r 5d20c80df290 minijss/jloadjss.c --- 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) diff -r 0ee6ba7b3e4a -r 5d20c80df290 minijss/jloadxm.c --- 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();