+
+/**
+ * Flags for the check command.
+ *
+ * \sa com_check().
+ */
+enum com_check_flags {
+ /** Check the audio file table. */
+ CHECK_AFT = 1,
+ /** Check the mood table. */
+ CHECK_MOODS = 2,
+ /** Check the playlist table. */
+ CHECK_PLAYLISTS = 4
+};
+
+int com_check(int fd, int argc, char * const * const argv)
+{
+ unsigned flags = 0;
+ int i, ret;
+ struct osl_object result;
+
+ for (i = 1; i < argc; i++) {
+ const char *arg = argv[i];
+ if (arg[0] != '-')
+ break;
+ if (!strcmp(arg, "--")) {
+ i++;
+ break;
+ }
+ if (!strcmp(arg, "-a")) {
+ flags |= CHECK_AFT;
+ continue;
+ }
+ if (!strcmp(arg, "-p")) {
+ flags |= CHECK_PLAYLISTS;
+ continue;
+ }
+ if (!strcmp(arg, "-m")) {
+ flags |= CHECK_MOODS;
+ continue;
+ }
+ return -E_AFS_SYNTAX;
+ }
+ if (i < argc)
+ return -E_AFS_SYNTAX;
+ if (!flags)
+ flags = ~0U;
+ if (flags & CHECK_AFT) {
+ ret = send_callback_request(aft_check_callback, NULL, &result);
+ if (ret < 0)
+ return ret;
+ if (ret > 0) {
+ ret = send_buffer(fd, (char *) result.data);
+ free(result.data);
+ if (ret < 0)
+ return ret;
+ }
+ }
+ if (flags & CHECK_PLAYLISTS) {
+ ret = send_callback_request(playlist_check_callback, NULL, &result);
+ if (ret < 0)
+ return ret;
+ if (ret > 0) {
+ ret = send_buffer(fd, (char *) result.data);
+ free(result.data);
+ if (ret < 0)
+ return ret;
+ }
+ }
+ if (flags & CHECK_MOODS) {
+ ret = send_callback_request(mood_check_callback, NULL, &result);
+ if (ret < 0)
+ return ret;
+ if (ret > 0) {
+ ret = send_buffer(fd, (char *) result.data);
+ free(result.data);
+ if (ret < 0)
+ return ret;
+ }
+ }
+ return 1;
+}
+
+void afs_event(enum afs_events event, struct para_buffer *pb,
+ void *data)
+{
+ int i, ret;
+
+ for (i = 0; i < NUM_AFS_TABLES; i++) {
+ struct afs_table *t = &afs_tables[i];
+ if (!t->event_handler)
+ continue;
+ ret = t->event_handler(event, pb, data);
+ if (ret < 0)
+ PARA_CRIT_LOG("%s\n", para_strerror(-ret));
+ }
+}
+
+int images_event_handler(__a_unused enum afs_events event,
+ __a_unused struct para_buffer *pb, __a_unused void *data)
+{
+ return 1;
+}
+
+int lyrics_event_handler(__a_unused enum afs_events event,
+ __a_unused struct para_buffer *pb, __a_unused void *data)
+{
+ return 1;
+}