diff src/xs_length.c @ 62:0d1df20745dd

Started to rewrite STIL-support
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 22 Jun 2003 11:38:00 +0000
parents 85811bcd049e
children bf7b647b3239
line wrap: on
line diff
--- a/src/xs_length.c	Sun Jun 22 11:37:05 2003 +0000
+++ b/src/xs_length.c	Sun Jun 22 11:38:00 2003 +0000
@@ -32,27 +32,27 @@
 /*
  * Pointer to database in memory
  */
-static t_xs_dbentry	*xs_database = NULL, *xs_dblast = NULL;
-static t_xs_dbentry	**xs_dbindex = NULL;
+static t_xs_sldb_node	*xs_database = NULL, *xs_dblast = NULL;
+static t_xs_sldb_node	**xs_dbindex = NULL;
 static gint		xs_dbnodes   = 0;
 
 
 /*
  * Hash-database handling functions
  */
-t_xs_dbentry *xs_db_node_new(void)
+t_xs_sldb_node *xs_db_node_new(void)
 {
- t_xs_dbentry *pResult;
+ t_xs_sldb_node *pResult;
  
  /* Allocate memory for new node */
- pResult = (t_xs_dbentry *) g_malloc0(sizeof(t_xs_dbentry));
+ pResult = (t_xs_sldb_node *) g_malloc0(sizeof(t_xs_sldb_node));
  if (pResult == NULL) return NULL;
  
  return pResult;
 }
 
 
-void xs_db_node_free(t_xs_dbentry *pNode)
+void xs_db_node_free(t_xs_sldb_node *pNode)
 {
  if (pNode) free(pNode);
 }
@@ -61,7 +61,7 @@
 /*
  * Insert given node to db linked list
  */
-void xs_db_node_insert(t_xs_dbentry *pNode)
+void xs_db_node_insert(t_xs_sldb_node *pNode)
 {
  if (xs_dblast)
  	{
@@ -95,10 +95,10 @@
 /*
  * Get song length from database
  */
-t_xs_dbentry * xs_db_get(t_xs_md5hash pHash)
+t_xs_sldb_node * xs_db_get(t_xs_md5hash pHash)
 {
  gint iStartNode, iEndNode, iQNode, iFound, r, i;
- t_xs_dbentry *pResult;
+ t_xs_sldb_node *pResult;
 
  /* Check the database pointers */
  if ((xs_database == NULL) || (xs_dbindex == NULL))
@@ -205,7 +205,7 @@
  gchar inLine[XS_BUFSIZE];
  guint lineNum, linePos;
  gboolean iOK;
- t_xs_dbentry *tmpNode;
+ t_xs_sldb_node *tmpNode;
  
  /* Try to open the file */
  if ((inFile = fopen(dbFilename, "ra")) == NULL)
@@ -280,7 +280,7 @@
 				iOK = FALSE;
 			}
 
-		/* Add an entry to db in memory */
+		/* Add an node to db in memory */
 		if (iOK)
 			xs_db_node_insert(tmpNode);
 			else
@@ -309,8 +309,8 @@
 gint xs_db_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_dbentry **) pNode1)->md5Hash,
-                      (*(t_xs_dbentry **) pNode2)->md5Hash);
+ return xs_db_cmphash((*(t_xs_sldb_node **) pNode1)->md5Hash,
+                      (*(t_xs_sldb_node **) pNode2)->md5Hash);
 }
 
 
@@ -319,7 +319,7 @@
  */
 gint xs_songlen_init(void)
 {
- t_xs_dbentry *pCurr;
+ t_xs_sldb_node *pCurr;
  gint i;
  
  /* Read the database */
@@ -342,7 +342,7 @@
  if (xs_dbnodes > 0)
 	{
 	/* Allocate memory for index-table */
-	xs_dbindex = (t_xs_dbentry **) g_malloc(sizeof(t_xs_dbentry *) * xs_dbnodes);
+	xs_dbindex = (t_xs_sldb_node **) g_malloc(sizeof(t_xs_sldb_node *) * xs_dbnodes);
 	if (xs_dbindex == NULL) return -6;
 
 	/* Get node-pointers to table */
@@ -355,7 +355,7 @@
 		}
 
 	/* Sort the indexes */
-	qsort(xs_dbindex, xs_dbnodes, sizeof(t_xs_dbentry *), xs_db_cmp);
+	qsort(xs_dbindex, xs_dbnodes, sizeof(t_xs_sldb_node *), xs_db_cmp);
 	}
 
  /* OK */
@@ -368,7 +368,7 @@
  */
 void xs_songlen_close(void)
 {
- t_xs_dbentry *pCurr, *pNext;
+ t_xs_sldb_node *pCurr, *pNext;
  
  /* Free the memory allocated for database */
  pCurr = xs_database;
@@ -550,7 +550,7 @@
  */
 gint32 xs_songlen_get(gchar *fileName, gint subTune)
 {
- t_xs_dbentry *dbEntry;
+ t_xs_sldb_node *dbNode;
  t_xs_md5hash dbHash;
  gint32 iResult;
 
@@ -561,10 +561,10 @@
 	/* Get the hash and then look up from db */
 	if (xs_get_sid_hash(fileName, dbHash) == 0)
 		{
-		dbEntry = xs_db_get(dbHash);
+		dbNode = xs_db_get(dbHash);
 
-		if (dbEntry && (subTune >= 0) && (subTune < dbEntry->nLengths))
-			iResult = dbEntry->sLengths[subTune - 1];
+		if (dbNode && (subTune >= 0) && (subTune < dbNode->nLengths))
+			iResult = dbNode->sLengths[subTune - 1];
   		}
 	}
 #if 0