X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=afs.c;h=c6ecbecf02795558d155ad99f50882d2782462a3;hb=eb3afb241df1e8247dfd2e944032202976e73af8;hp=0c615747435657b65ec5302192561fd902c84348;hpb=52e9fee3dd1d4d6dad8f268770412bcd7720026f;p=paraslash.git diff --git a/afs.c b/afs.c index 0c615747..c6ecbecf 100644 --- a/afs.c +++ b/afs.c @@ -1108,7 +1108,9 @@ enum com_check_flags { /** Check the mood table. */ CHECK_MOODS = 2, /** Check the playlist table. */ - CHECK_PLAYLISTS = 4 + CHECK_PLAYLISTS = 4, + /** Check the attribute table against the audio file table. */ + CHECK_ATTS = 8 }; int com_check(struct command_context *cc) @@ -1128,6 +1130,10 @@ int com_check(struct command_context *cc) flags |= CHECK_AFT; continue; } + if (!strcmp(arg, "-A")) { + flags |= CHECK_ATTS; + continue; + } if (!strcmp(arg, "-p")) { flags |= CHECK_PLAYLISTS; continue; @@ -1148,6 +1154,12 @@ int com_check(struct command_context *cc) if (ret < 0) return ret; } + if (flags & CHECK_ATTS) { + ret = send_callback_request(attribute_check_callback, NULL, + afs_cb_result_handler, cc); + if (ret < 0) + return ret; + } if (flags & CHECK_PLAYLISTS) { ret = send_callback_request(playlist_check_callback, NULL, afs_cb_result_handler, cc); @@ -1170,10 +1182,14 @@ int com_check(struct command_context *cc) * \param pb May be \p NULL. * \param data Type depends on \a event. * - * This function calls the table handlers of all tables and passes \a pb and \a - * data verbatim. It's up to the handlers to interpret the \a data pointer. + * This function calls each table event handler, passing \a pb and \a data + * verbatim. It's up to the handlers to interpret the \a data pointer. If a + * handler returns negative, the loop is aborted. + * + * \return The (negative) error code of the first handler that failed, or non-negative + * if all handlers succeeded. */ -void afs_event(enum afs_events event, struct para_buffer *pb, +__must_check int afs_event(enum afs_events event, struct para_buffer *pb, void *data) { int i, ret; @@ -1183,10 +1199,13 @@ void afs_event(enum afs_events event, struct para_buffer *pb, if (!t->event_handler) continue; ret = t->event_handler(event, pb, data); - if (ret < 0) + if (ret < 0) { PARA_CRIT_LOG("table %s, event %d: %s\n", t->name, event, para_strerror(-ret)); + return ret; + } } + return 1; } /**