struct list_head score_list;
};
+/*
+ * If current_mood is NULL then no mood is currently open. If
+ * current_mood->name is NULL, the dummy mood is currently open
+ */
static struct mood *current_mood;
/**
static struct mood *alloc_new_mood(const char *name)
{
struct mood *m = para_calloc(sizeof(struct mood));
- m->name = para_strdup(name);
+ if (name)
+ m->name = para_strdup(name);
INIT_LIST_HEAD(&m->accept_list);
INIT_LIST_HEAD(&m->deny_list);
INIT_LIST_HEAD(&m->score_list);
if (!*mood_name)
return -E_DUMMY_ROW;
mlpd.m = alloc_new_mood(mood_name);
- ret = for_each_line_ro(mood_def.data, mood_def.size,
+ ret = for_each_line(FELF_READ_ONLY, mood_def.data, mood_def.size,
parse_mood_line, &mlpd);
osl_close_disk_object(&mood_def);
if (ret < 0) {
ret = para_printf(pb, "checking mood %s...\n", mood_name);
if (ret < 0)
goto out;
- ret = for_each_line_ro(mood_def.data, mood_def.size,
+ ret = for_each_line(FELF_READ_ONLY, mood_def.data, mood_def.size,
parse_mood_line, &mlpd);
if (ret < 0)
para_printf(pb, "%s line %u: %s\n", mood_name, mlpd.line_num,
return ret;
close_current_mood();
current_mood = m;
- } else {
+ } else { /* load dummy mood */
close_current_mood();
- current_mood = alloc_new_mood("dummy");
+ current_mood = alloc_new_mood(NULL);
}
aa.m = current_mood;
PARA_NOTICE_LOG("computing statistics of admissible files\n");
if (ret < 0)
goto out;
}
- PARA_NOTICE_LOG("loaded mood %s\n", current_mood->name);
+ PARA_NOTICE_LOG("loaded mood %s\n", mood_name? mood_name : "(dummy)");
ret = statistics.num;
out:
free(aa.array);
* This function performs actions required due to the occurrence of the given
* event. Possible actions include reload of the current mood and update of the
* score of an audio file.
+ *
+ * \return Standard.
*/
int moods_event_handler(enum afs_events event, __a_unused struct para_buffer *pb,
void *data)