X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=afs.c;h=d738c3d99f1143648f98f0b65b714bbf1e69ccee;hp=531cada83dc4724c92ea2c329e8a3e3b48602030;hb=98f2c8aea52a49fad3fd6df67b1eb32c1499176c;hpb=9242741b62d726e7b673a3b10c62bbc8509a75ef diff --git a/afs.c b/afs.c index 531cada8..d738c3d9 100644 --- a/afs.c +++ b/afs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2009 Andre Noll + * Copyright (C) 2007-2010 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -60,13 +60,13 @@ enum afs_table_num { }; static struct afs_table afs_tables[NUM_AFS_TABLES] = { - [TBLNUM_AUDIO_FILES] = {.init = aft_init}, - [TBLNUM_ATTRIBUTES] = {.init = attribute_init}, - [TBLNUM_SCORES] = {.init = score_init}, - [TBLNUM_MOODS] = {.init = moods_init}, - [TBLNUM_LYRICS] = {.init = lyrics_init}, - [TBLNUM_IMAGES] = {.init = images_init}, - [TBLNUM_PLAYLIST] = {.init = playlists_init}, + [TBLNUM_AUDIO_FILES] = {.init = aft_init, .name = "audio_files"}, + [TBLNUM_ATTRIBUTES] = {.init = attribute_init, .name = "attributes"}, + [TBLNUM_SCORES] = {.init = score_init, .name = "scores"}, + [TBLNUM_MOODS] = {.init = moods_init, .name = "moods"}, + [TBLNUM_LYRICS] = {.init = lyrics_init, .name = "lyrics"}, + [TBLNUM_IMAGES] = {.init = images_init, .name = "images"}, + [TBLNUM_PLAYLIST] = {.init = playlists_init, .name = "playlists"}, }; struct command_task { @@ -1003,7 +1003,7 @@ static void create_tables_callback(int fd, const struct osl_object *query) { uint32_t table_mask = *(uint32_t *)query->data; int i, ret; - char *buf; + struct para_buffer pb = {.buf = NULL}; close_afs_tables(); for (i = 0; i < NUM_AFS_TABLES; i++) { @@ -1016,15 +1016,15 @@ static void create_tables_callback(int fd, const struct osl_object *query) ret = t->create(database_dir); if (ret < 0) goto out; + para_printf(&pb, "successfully created %s table\n", t->name); } ret = open_afs_tables(); out: - if (ret >= 0) - buf = make_message("successfully created afs table(s)\n"); - else - buf = make_message("%s\n", para_strerror(-ret)); - pass_buffer_as_shm(buf, strlen(buf), &fd); - free(buf); + if (ret < 0) + para_printf(&pb, "%s\n", para_strerror(-ret)); + if (pb.buf) + pass_buffer_as_shm(pb.buf, pb.offset, &fd); + free(pb.buf); } int com_init(struct rc4_context *rc4c, int argc, char * const * const argv) @@ -1151,12 +1151,30 @@ void afs_event(enum afs_events event, struct para_buffer *pb, } } +/** + * Dummy event handler for the images table. + * + * \param event Unused. + * \param pb Unused. + * \param data Unused. + * + * This table does not honor events. + */ int images_event_handler(__a_unused enum afs_events event, __a_unused struct para_buffer *pb, __a_unused void *data) { return 1; } +/** + * Dummy event handler for the lyrics table. + * + * \param event Unused. + * \param pb Unused. + * \param data Unused. + * + * This table does not honor events. + */ int lyrics_event_handler(__a_unused enum afs_events event, __a_unused struct para_buffer *pb, __a_unused void *data) {