Mercurial > hg > sidinfo
changeset 388:c96448875797
Change "new SLDB" boolean to a flags int.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 23 Feb 2022 20:09:55 +0200 |
parents | 51d6e86aa196 |
children | e89e5d956a63 |
files | sidinfo.c sidlib.c sidlib.h |
diffstat | 3 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/sidinfo.c Sat Jan 01 16:27:28 2022 +0200 +++ b/sidinfo.c Wed Feb 23 20:09:55 2022 +0200 @@ -101,8 +101,7 @@ char *setHVSCPath = NULL, *setSLDBPath = NULL, *setSTILDBPath = NULL; -BOOL setSLDBNewFormat = FALSE, - optParsable = FALSE, +BOOL optParsable = FALSE, optFieldNamePrefix = TRUE, optHexadecimal = FALSE, optFieldOutput = TRUE, @@ -110,7 +109,9 @@ optShowHelp = FALSE; char *optOneLineFieldSep = NULL, *optEscapeChars = NULL; -int optNFiles = 0; +int optNFiles = 0, + setSIDLibFlags = 0; + PSFStack optFormat; @@ -1014,7 +1015,7 @@ th_io_set_handlers(infh, siPSIDError, NULL); // Read PSID data - if ((res = sidlib_read_sid_file_alloc(infh, &psid, setSLDBNewFormat, NULL)) != THERR_OK) + if ((res = sidlib_read_sid_file_alloc(infh, &psid, setSIDLibFlags, NULL)) != THERR_OK) goto error; // Get songlength information, if any @@ -1255,11 +1256,12 @@ // Read SLDB and STILDB if (setSLDBPath != NULL) { - setSLDBNewFormat = th_strrcasecmp(setSLDBPath, ".md5") != NULL; + if (th_strrcasecmp(setSLDBPath, ".md5") != NULL) + setSIDLibFlags |= SIDLIB_FLG_NEW_SLDB; THMSG(1, "Reading SLDB (%s format [%s]): %s\n", - setSLDBNewFormat ? "new" : "old", - setSLDBNewFormat ? ".md5" : ".txt", + (setSIDLibFlags & SIDLIB_FLG_NEW_SLDB) ? "new" : "old", + (setSIDLibFlags & SIDLIB_FLG_NEW_SLDB) ? ".md5" : ".txt", setSLDBPath); if ((res = sidutil_read_sldb_file(setSLDBPath, &sidSLDB)) != THERR_OK)
--- a/sidlib.c Sat Jan 01 16:27:28 2022 +0200 +++ b/sidlib.c Wed Feb 23 20:09:55 2022 +0200 @@ -110,7 +110,7 @@ int sidlib_read_sid_file(th_ioctx *ctx, SIDLibPSIDHeader *psid, - const BOOL newSLDB, SIDLibChConvCtx *chconv) + const int flags, SIDLibChConvCtx *chconv) { int ret = THERR_OK; th_md5state_t state; @@ -203,7 +203,7 @@ // Initialize MD5-hash calculation th_md5_init(&state); - if (newSLDB) + if (flags & SIDLIB_FLG_NEW_SLDB) { // New Songlengths.md5 style hash calculation: // We just hash the whole file, so seek back to beginning .. @@ -266,14 +266,14 @@ int sidlib_read_sid_file_alloc(th_ioctx *ctx, SIDLibPSIDHeader **ppsid, - const BOOL newSLDB, SIDLibChConvCtx *chconv) + const int flags, SIDLibChConvCtx *chconv) { if ((*ppsid = th_malloc0(sizeof(SIDLibPSIDHeader))) == NULL) return THERR_MALLOC; (*ppsid)->allocated = TRUE; - return sidlib_read_sid_file(ctx, *ppsid, newSLDB, chconv); + return sidlib_read_sid_file(ctx, *ppsid, flags, chconv); }
--- a/sidlib.h Sat Jan 01 16:27:28 2022 +0200 +++ b/sidlib.h Wed Feb 23 20:09:55 2022 +0200 @@ -27,6 +27,12 @@ enum { + SIDLIB_FLG_NEW_SLDB = 0x01, // Using 'new' Songlengths.md5 style SLDB +}; + + +enum +{ // Player flags PSF_PLAYER_TYPE = 0x01, // 0 = built-in, 1 = Compute! SIDPlayer MUS PSF_PLAYSID_TUNE = 0x02, // 0 = Real C64-compatible, 1 = PlaySID specific (v2NG) @@ -168,8 +174,8 @@ // // Functions // -int sidlib_read_sid_file(th_ioctx *ctx, SIDLibPSIDHeader *psid, const BOOL newSLDB, SIDLibChConvCtx *chconv); -int sidlib_read_sid_file_alloc(th_ioctx *ctx, SIDLibPSIDHeader **ppsid, const BOOL newSLDB, SIDLibChConvCtx *chconv); +int sidlib_read_sid_file(th_ioctx *ctx, SIDLibPSIDHeader *psid, const int flags, SIDLibChConvCtx *chconv); +int sidlib_read_sid_file_alloc(th_ioctx *ctx, SIDLibPSIDHeader **ppsid, const int flags, SIDLibChConvCtx *chconv); void sidlib_free_sid_file(SIDLibPSIDHeader *psid); int sidlib_write_sid_header(th_ioctx *ctx, const SIDLibPSIDHeader *psid);