# HG changeset patch # User Matti Hamalainen # Date 1073778664 0 # Node ID 2bc56809ec0b54986281c92ffbc7f64fe1d74b23 # Parent a27f075ebb68f6aa5a0e86889415d4a696424f52 STIL-support fixes, variable renaming diff -r a27f075ebb68 -r 2bc56809ec0b src/xmms-sid.c --- a/src/xmms-sid.c Sat Jan 10 22:56:04 2004 +0000 +++ b/src/xmms-sid.c Sat Jan 10 23:51:04 2004 +0000 @@ -162,15 +162,17 @@ XSDEBUG("init#2: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); - /* Read song-length database */ + /* Initialize song-length database */ if (xs_cfg.songlenDBEnable && (xs_songlen_init() < 0)) { XSERR("Error initializing song-length database!\n"); } - /* Initialize STIL structures */ - -// FIXME FIXME FIx ME + /* Initialize STIL database */ + if (xs_cfg.stilDBEnable && (xs_stil_init() < 0)) + { + XSERR("Error initializing STIL database!\n"); + } XSDEBUG("OK\n"); } @@ -194,8 +196,7 @@ /* Free allocated memory */ xs_songlen_close(); - -// FIXME FIXME: STIL-entries + xs_stil_close(); XSDEBUG("shutdown finished.\n"); } diff -r a27f075ebb68 -r 2bc56809ec0b src/xs_length.c --- a/src/xs_length.c Sat Jan 10 22:56:04 2004 +0000 +++ b/src/xs_length.c Sat Jan 10 23:51:04 2004 +0000 @@ -39,7 +39,7 @@ /* * Hash-database handling functions */ -t_xs_sldb_node *xs_db_node_new(void) +t_xs_sldb_node *xs_sldb_node_new(void) { t_xs_sldb_node *pResult; @@ -51,7 +51,7 @@ } -void xs_db_node_free(t_xs_sldb_node *pNode) +void xs_sldb_node_free(t_xs_sldb_node *pNode) { if (pNode) g_free(pNode); } @@ -64,7 +64,7 @@ #define LTHIS (pNode) #define LNEXT (pNode->pNext) -void xs_db_node_insert(t_xs_sldb_node *pNode) +void xs_sldb_node_insert(t_xs_sldb_node *pNode) { if (xs_sldb) { @@ -87,7 +87,7 @@ * negative if testHash1 < testHash2 * positive if testHash1 > testHash2 */ -gint xs_db_cmphash(t_xs_md5hash testHash1, t_xs_md5hash testHash2) +gint xs_sldb_cmphash(t_xs_md5hash testHash1, t_xs_md5hash testHash2) { register gint i, res = 0; @@ -102,7 +102,7 @@ /* * Get song length from database */ -t_xs_sldb_node * xs_db_get(t_xs_md5hash pHash) +t_xs_sldb_node * xs_sldb_get(t_xs_md5hash pHash) { gint iStartNode, iEndNode, iQNode, r, i; gboolean iFound; @@ -121,7 +121,7 @@ while ((!iFound) && ((iEndNode - iStartNode) > 128)) { - r = xs_db_cmphash(pHash, xs_sldbi[iQNode]->md5Hash); + r = xs_sldb_cmphash(pHash, xs_sldbi[iQNode]->md5Hash); if (r < 0) { /* Hash was in the <- LEFT side */ @@ -145,7 +145,7 @@ i = iStartNode; while ((i <= iEndNode) && (!iFound)) { - if (xs_db_cmphash(pHash, xs_sldbi[i]->md5Hash) == 0) + if (xs_sldb_cmphash(pHash, xs_sldbi[i]->md5Hash) == 0) iFound = TRUE; else i++; @@ -207,7 +207,7 @@ /* * Read database to memory */ -gint xs_db_read(gchar *dbFilename) +gint xs_sldb_read(gchar *dbFilename) { FILE *inFile; gchar inLine[XS_BUFSIZE]; @@ -243,7 +243,7 @@ dbFilename, lineNum); } else { /* Allocate new node */ - if ((tmpNode = xs_db_node_new()) == NULL) + if ((tmpNode = xs_sldb_node_new()) == NULL) { XSERR("Error allocating new node. Fatal error.\n"); exit(5); @@ -271,7 +271,7 @@ XSERR("'=' expected in SongLengthDB file '%s' line #%d, column #%d\n", dbFilename, lineNum, linePos); - xs_db_node_free(tmpNode); + xs_sldb_node_free(tmpNode); } else { /* First playtime is after '=' */ linePos++; @@ -292,9 +292,9 @@ /* Add an node to db in memory */ if (iOK) - xs_db_node_insert(tmpNode); + xs_sldb_node_insert(tmpNode); else - xs_db_node_free(tmpNode); + xs_sldb_node_free(tmpNode); } } } @@ -317,10 +317,10 @@ /* * Compare two nodes' hashes */ -gint xs_db_cmp(const void *pNode1, const void *pNode2) +gint xs_sldb_cmp(const void *pNode1, const void *pNode2) { /* We assume here that we never ever get NULL-pointers or similar */ - return xs_db_cmphash((*(t_xs_sldb_node **) pNode1)->md5Hash, + return xs_sldb_cmphash((*(t_xs_sldb_node **) pNode1)->md5Hash, (*(t_xs_sldb_node **) pNode2)->md5Hash); } @@ -339,7 +339,7 @@ if (!xs_cfg.songlenDBPath) return -10; - if (xs_db_read(xs_cfg.songlenDBPath) < 0) + if (xs_sldb_read(xs_cfg.songlenDBPath) < 0) return -9; XSDEBUG("indexing...\n"); @@ -370,7 +370,7 @@ } /* Sort the indexes */ - qsort(xs_sldbi, xs_sldbn, sizeof(t_xs_sldb_node *), xs_db_cmp); + qsort(xs_sldbi, xs_sldbn, sizeof(t_xs_sldb_node *), xs_sldb_cmp); } /* OK */ @@ -392,7 +392,7 @@ while (pCurr) { pNext = pCurr->pNext; - xs_db_node_free(pCurr); + xs_sldb_node_free(pCurr); pCurr = pNext; } @@ -567,7 +567,7 @@ /* Get the hash and then look up from db */ if (xs_get_sid_hash(pcFilename, dbHash) == 0) { - pResult = xs_db_get(dbHash); + pResult = xs_sldb_get(dbHash); } } diff -r a27f075ebb68 -r 2bc56809ec0b src/xs_stil.c --- a/src/xs_stil.c Sat Jan 10 22:56:04 2004 +0000 +++ b/src/xs_stil.c Sat Jan 10 23:51:04 2004 +0000 @@ -40,7 +40,7 @@ /* * Hash-database handling functions */ -t_xs_stil_node *xs_db_node_new(void) +t_xs_stil_node *xs_stildb_node_new(void) { t_xs_stil_node *pResult; @@ -52,8 +52,10 @@ } -void xs_db_node_free(t_xs_stil_node *pNode) +void xs_stildb_node_free(t_xs_stil_node *pNode) { + gint i; + if (pNode) { for (i = 0; i < pNode->nsubTunes; i++) @@ -77,7 +79,7 @@ #define LTHIS (pNode) #define LNEXT (pNode->pNext) -void xs_db_node_insert(t_xs_stil_node *pNode) +void xs_stildb_node_insert(t_xs_stil_node *pNode) { if (xs_stildb) { @@ -95,27 +97,9 @@ /* - * Compare two given MD5-hashes. - * Return: 0 if equal - * negative if testHash1 < testHash2 - * positive if testHash1 > testHash2 + * Get STIL information from database */ -gint xs_db_cmphash(t_xs_md5hash testHash1, t_xs_md5hash testHash2) -{ - register gint i, res = 0; - - /* Compute difference of hashes */ - for (i = 0; (i < XS_MD5HASH_LENGTH) && (!res); i++) - res = (testHash1[i] - testHash2[i]); - - return res; -} - - -/* - * Get song length from database - */ -t_xs_stil_node * xs_db_get(gchar *pcFilename) +t_xs_stil_node * xs_stildb_get(gchar *pcFilename) { gint iStartNode, iEndNode, iQNode, r, i; gboolean iFound; @@ -134,7 +118,7 @@ while ((!iFound) && ((iEndNode - iStartNode) > 128)) { - r = xs_db_cmphash(pHash, xs_stildbi[iQNode]->md5Hash); + r = strcmp(pcFilename, xs_stildbi[iQNode]->pcFilename); if (r < 0) { /* Hash was in the <- LEFT side */ @@ -158,7 +142,7 @@ i = iStartNode; while ((i <= iEndNode) && (!iFound)) { - if (xs_db_cmphash(pHash, xs_stildbi[i]->md5Hash) == 0) + if (strcmp(pcFilename, xs_stildbi[iQNode]->pcFilename) == 0) iFound = TRUE; else i++; @@ -215,29 +199,29 @@ /* * Compare two nodes' hashes */ -gint xs_db_cmp(const void *pNode1, const void *pNode2) +gint xs_stildb_cmp(const void *pNode1, const void *pNode2) { /* We assume here that we never ever get NULL-pointers or similar */ - return xs_db_cmphash((*(t_xs_stil_node **) pNode1)->md5Hash, - (*(t_xs_stil_node **) pNode2)->md5Hash); + return strcmp((*(t_xs_stil_node **) pNode1)->pcFilename, + (*(t_xs_stil_node **) pNode2)->pcFilename); } /* * Initialize the song-length system */ -gint xs_songlen_init(void) +gint xs_stil_init(void) { t_xs_stil_node *pCurr; gint i; -XSDEBUG("stildb_init()\n"); +XSDEBUG("stil_init()\n"); /* Read the database */ - if (!xs_cfg.songlenDBPath) + if (!xs_cfg.stilDBPath) return -10; - if (xs_db_read(xs_cfg.songlenDBPath) < 0) + if (xs_stildb_read(xs_cfg.stilDBPath) < 0) return -9; XSDEBUG("indexing...\n"); @@ -268,7 +252,7 @@ } /* Sort the indexes */ - qsort(xs_stildbi, xs_stildbn, sizeof(t_xs_stil_node *), xs_db_cmp); + qsort(xs_stildbi, xs_stildbn, sizeof(t_xs_stil_node *), xs_stildb_cmp); } /* OK */ @@ -290,7 +274,7 @@ while (pCurr) { pNext = pCurr->pNext; - xs_db_node_free(pCurr); + xs_stildb_node_free(pCurr); pCurr = pNext; }