]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - score.c
Replace struct table_info by struct afs_table.
[paraslash.git] / score.c
diff --git a/score.c b/score.c
index 6c15a0f571e8cd79647493910f64edc7679c947c..e233f7352c19af0c6f23a47030d024e334cb0239 100644 (file)
--- a/score.c
+++ b/score.c
@@ -7,14 +7,12 @@
 /** \file score.c Scoring functions to determine the audio file streaming order. */
 #include "para.h"
 #include "error.h"
+#include "string.h"
 #include "afh.h"
 #include "afs.h"
 #include "list.h"
-#include "string.h"
 
-int mood_compute_score(const void *row, long *score);
-
-static void *score_table;
+static struct osl_table *score_table;
 
 static int ptr_compare(const struct osl_object *obj1, const struct osl_object *obj2)
 {
@@ -78,7 +76,6 @@ static struct osl_column_description score_cols[] = {
 };
 
 static struct osl_table_description score_table_desc = {
-       .dir = DATABASE_DIR,
        .name = "score",
        .num_columns = NUM_SCORE_COLUMNS,
        .flags = 0,
@@ -199,7 +196,7 @@ int score_update(const struct osl_row *aft_row, long percent)
        obj.size = sizeof(long);
        obj.data = para_malloc(obj.size);
        *(long *)obj.data = new_score;
-       PARA_NOTICE_LOG("new score: %ld, position: %u/%u\n", new_score,
+       PARA_DEBUG_LOG("new score: %ld, position: %u/%u\n", new_score,
                new_pos, n);
        return osl_update_object(score_table, row, SCORECOL_SCORE, &obj);
 }
@@ -333,33 +330,36 @@ int row_belongs_to_score_table(const struct osl_row *aft_row)
        return ret;
 }
 
-/**
- * Close the score table.
- *
- * \param flags Options passed to osl_close_table().
- *
- * \sa score_init().
- */
-void score_shutdown(enum osl_close_flags flags)
+/* Close the score table. */
+static void score_close(void)
 {
-       osl_close_table(score_table, flags | OSL_FREE_VOLATILE);
+       osl_close_table(score_table, OSL_FREE_VOLATILE);
+       score_table = NULL;
 }
 
 /**
- * Init the scoring subsystem.
+ * Open the score table.
  *
- * \param ti Gets filled in by the function.
+ * \param dir The database directory.
  *
  * \return The return value of the underlying call to osl_open_table().
  *
  * \sa score_shutdown().
  */
-int score_init(struct table_info *ti)
+static int score_open(const char *dir)
 {
-       ti->desc = &score_table_desc;
-       ti->flags = TBLFLAG_SKIP_CREATE;
-       int ret = osl_open_table(ti->desc, &ti->table);
+       score_table_desc.dir = dir;
+       return osl_open_table(&score_table_desc, &score_table);
+}
 
-       score_table = ti->table;
-       return ret;
+/**
+ * Initialize the scoring subsystem.
+ *
+ * \param t Members Gets filled in by the function.
+ */
+void score_init(struct afs_table *t)
+{
+       t->name = score_table_desc.name;
+       t->open = score_open;
+       t->close = score_close;
 }