]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - score.c
Improve playlist_open().
[paraslash.git] / score.c
diff --git a/score.c b/score.c
index edc46ed4f577435a1512be6925b63c305559c038..19cfef86212dd867d6dea3c924a0f40ca897a2cd 100644 (file)
--- a/score.c
+++ b/score.c
@@ -76,18 +76,6 @@ static struct osl_table_description score_table_desc = {
        .column_descriptions = score_cols
 };
 
-/**
- * Compute the number of files in score table.
- *
- * \param num Result is returned here.
- *
- * \return Positive on success, negative on errors.
- */
-int get_num_admissible_files(unsigned *num)
-{
-       return osl(osl_get_num_rows(score_table, num));
-}
-
 /* On errors (negative return value) the content of score is undefined. */
 static int get_score_of_row(void *score_row, long *score)
 {
@@ -157,7 +145,7 @@ int score_update(const struct osl_row *aft_row, long percent)
                return 1;
        if (ret < 0)
                return ret;
-       ret = get_num_admissible_files(&n);
+       ret = osl(osl_get_num_rows(score_table, &n));
        if (ret < 0)
                return ret;
        new_pos = 1 + (n - 1) * percent / 100;
@@ -208,17 +196,15 @@ static int get_score_row_from_aft_row(const struct osl_row *aft_row,
 }
 
 /**
- * Loop over all files in the score table.
- *
- * \param data A pointer to arbitrary data.
- * \param func Function to be called for each admissible file.
+ * Call the given function for each row of the score table.
  *
- * \return The return value of the underlying call to osl_rbtree_loop().
+ * \param func Callback, called once per row.
+ * \param data Passed verbatim to the callback.
  *
- * This is used for the ls command. The \a data parameter is passed as the
- * second argument to \a func.
+ * \return The return value of the underlying call to osl_rbtree_loop(). The
+ * loop terminates early if the callback returns negative.
  */
-int admissible_file_loop(void *data, osl_rbtree_loop_func *func)
+int score_loop(osl_rbtree_loop_func *func, void *data)
 {
        return osl(osl_rbtree_loop(score_table, SCORECOL_SCORE, data, func));
 }
@@ -314,12 +300,6 @@ int clear_score_table(void)
        return score_open(NULL);
 }
 
-static int score_event_handler(__a_unused enum afs_events event,
-               __a_unused struct para_buffer *pb, __a_unused void *data)
-{
-       return 1;
-}
-
 /**
  * Initialize the scoring subsystem.
  *
@@ -330,5 +310,4 @@ void score_init(struct afs_table *t)
        t->name = score_table_desc.name;
        t->open = score_open;
        t->close = score_close;
-       t->event_handler = score_event_handler;
 }