X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aft.c;h=db4c494d07bcd7c759de9708d1f2c30d4ba278aa;hp=12424c40e0dda04400698c6e14d71e69387ccfd9;hb=6494f4bfddde1b9e06c4cb8bcd3acf7b9cc762f1;hpb=b2e6a24448a9e49e0766ab4f32163580eeff469e diff --git a/aft.c b/aft.c index 12424c40..db4c494d 100644 --- a/aft.c +++ b/aft.c @@ -7,6 +7,7 @@ /** \file aft.c Audio file table functions. */ #include /* readdir() */ +#include #include "para.h" #include "error.h" #include "string.h" @@ -432,13 +433,13 @@ static void load_chunk_table(struct afh_info *afhi, char *buf) * \param path The full path of the audio file. * \param row Result pointer. * - * \return The return value of the underlying call to osl_get_row(). + * \return Standard. */ int aft_get_row_of_path(const char *path, struct osl_row **row) { struct osl_object obj = {.data = (char *)path, .size = strlen(path) + 1}; - return osl_get_row(audio_file_table, AFTCOL_PATH, &obj, row); + return osl(osl_get_row(audio_file_table, AFTCOL_PATH, &obj, row)); } /** @@ -447,12 +448,12 @@ int aft_get_row_of_path(const char *path, struct osl_row **row) * \param hash The hash value of the desired audio file. * \param row resul pointer. * - * \return The return value of the underlying call to osl_get_row(). + * \return Standard. */ int aft_get_row_of_hash(HASH_TYPE *hash, struct osl_row **row) { const struct osl_object obj = {.data = hash, .size = HASH_SIZE}; - return osl_get_row(audio_file_table, AFTCOL_HASH, &obj, row); + return osl(osl_get_row(audio_file_table, AFTCOL_HASH, &obj, row)); } /** @@ -461,11 +462,11 @@ int aft_get_row_of_hash(HASH_TYPE *hash, struct osl_row **row) * \param row Pointer to a row in the audio file table. * \param obj Result pointer. * - * \return The return value of the underlying call to osl_get_object(). + * \return Standard. */ int get_afsi_object_of_row(const struct osl_row *row, struct osl_object *obj) { - return osl_get_object(audio_file_table, row, AFTCOL_AFSI, obj); + return osl(osl_get_object(audio_file_table, row, AFTCOL_AFSI, obj)); } /** @@ -534,8 +535,8 @@ int get_afsi_of_path(const char *path, struct afs_info *afsi) int get_audio_file_path_of_row(const struct osl_row *row, char **path) { struct osl_object path_obj; - int ret = osl_get_object(audio_file_table, row, AFTCOL_PATH, - &path_obj); + int ret = osl(osl_get_object(audio_file_table, row, AFTCOL_PATH, + &path_obj)); if (ret < 0) return ret; *path = path_obj.data; @@ -552,9 +553,10 @@ int get_audio_file_path_of_row(const struct osl_row *row, char **path) * * \sa get_hash_of_row(). */ -static int get_hash_object_of_aft_row(const struct osl_row *row, struct osl_object *obj) +static int get_hash_object_of_aft_row(const struct osl_row *row, + struct osl_object *obj) { - return osl_get_object(audio_file_table, row, AFTCOL_HASH, obj); + return osl(osl_get_object(audio_file_table, row, AFTCOL_HASH, obj)); } /** @@ -592,8 +594,8 @@ static int get_hash_of_row(const struct osl_row *row, HASH_TYPE **hash) int get_afhi_of_row(const struct osl_row *row, struct afh_info *afhi) { struct osl_object obj; - int ret = osl_get_object(audio_file_table, row, AFTCOL_AFHI, - &obj); + int ret = osl(osl_get_object(audio_file_table, row, AFTCOL_AFHI, + &obj)); if (ret < 0) return ret; load_afhi(obj.data, afhi); @@ -1383,8 +1385,8 @@ static void com_ls_callback(int fd, const struct osl_object *query) if (opts->flags & LS_FLAG_ADMISSIBLE_ONLY) ret = admissible_file_loop(opts, prepare_ls_row); else - ret = osl_rbtree_loop(audio_file_table, AFTCOL_PATH, opts, - prepare_ls_row); + ret = osl(osl_rbtree_loop(audio_file_table, AFTCOL_PATH, opts, + prepare_ls_row)); if (ret < 0) goto out; if (!opts->num_matching_paths) @@ -1532,12 +1534,12 @@ int com_ls(int fd, int argc, char * const * const argv) * \param private_data An arbitrary data pointer, passed to \a func. * \param func The custom function to be called. * - * \return The return value of the underlying call to osl_rbtree_loop(). + * \return Standard. */ int audio_file_loop(void *private_data, osl_rbtree_loop_func *func) { - return osl_rbtree_loop(audio_file_table, AFTCOL_HASH, private_data, - func); + return osl(osl_rbtree_loop(audio_file_table, AFTCOL_HASH, private_data, + func)); } static struct osl_row *find_hash_sister(HASH_TYPE *hash) @@ -1697,7 +1699,7 @@ static void com_add_callback(int fd, const struct osl_object *query) PARA_INFO_LOG("request to add %s\n", path); hs = find_hash_sister(hash); ret = aft_get_row_of_path(path, &pb); - if (ret < 0 && ret != -E_OSL_RB_KEY_NOT_FOUND) + if (ret < 0 && ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) goto out; if (hs && pb && hs == pb && !(flags & ADD_FLAG_FORCE)) { if (flags & ADD_FLAG_VERBOSE) @@ -1714,23 +1716,23 @@ static void com_add_callback(int fd, const struct osl_object *query) if (ret < 0) goto out; } - ret = osl_del_row(audio_file_table, pb); + ret = osl(osl_del_row(audio_file_table, pb)); if (ret < 0) goto out; pb = NULL; } /* file rename, update hs' path */ if (flags & ADD_FLAG_VERBOSE) { - ret = osl_get_object(audio_file_table, hs, - AFTCOL_PATH, &obj); + ret = osl(osl_get_object(audio_file_table, hs, + AFTCOL_PATH, &obj)); if (ret < 0) goto out; ret = para_printf(&msg, "renamed from %s\n", (char *)obj.data); if (ret < 0) goto out; } - ret = osl_update_object(audio_file_table, hs, AFTCOL_PATH, - &objs[AFTCOL_PATH]); + ret = osl(osl_update_object(audio_file_table, hs, AFTCOL_PATH, + &objs[AFTCOL_PATH])); if (ret < 0) goto out; afs_event(AUDIO_FILE_RENAME, &msg, hs); @@ -1774,12 +1776,12 @@ static void com_add_callback(int fd, const struct osl_object *query) if (ret < 0) goto out; } - ret = osl_update_object(audio_file_table, row, AFTCOL_AFHI, - &objs[AFTCOL_AFHI]); + ret = osl(osl_update_object(audio_file_table, row, AFTCOL_AFHI, + &objs[AFTCOL_AFHI])); if (ret < 0) goto out; - ret = osl_update_object(audio_file_table, row, AFTCOL_CHUNKS, - &objs[AFTCOL_CHUNKS]); + ret = osl(osl_update_object(audio_file_table, row, AFTCOL_CHUNKS, + &objs[AFTCOL_CHUNKS])); if (ret < 0) goto out; afs_event(AFHI_CHANGE, &msg, row); @@ -1797,7 +1799,7 @@ static void com_add_callback(int fd, const struct osl_object *query) objs[AFTCOL_AFSI].data = &afsi_buf; objs[AFTCOL_AFSI].size = AFSI_SIZE; save_afsi(&default_afsi, &objs[AFTCOL_AFSI]); - ret = osl_add_and_get_row(audio_file_table, objs, &aft_row); + ret = osl(osl_add_and_get_row(audio_file_table, objs, &aft_row)); afs_event(AUDIO_FILE_ADD, &msg, aft_row); out: if (ret < 0) @@ -1860,7 +1862,7 @@ static int add_one_audio_file(const char *path, void *private_data) query.size = strlen(path) + 1; ret = send_callback_request(path_brother_callback, &query, get_row_pointer_from_result, &pb); - if (ret < 0 && ret != -E_OSL_RB_KEY_NOT_FOUND) + if (ret < 0 && ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) goto out_free; ret = 1; if (pb && (pad->flags & ADD_FLAG_LAZY)) { /* lazy is really cheap */ @@ -2224,7 +2226,7 @@ static int remove_audio_file(__a_unused struct osl_table *table, return ret; } afs_event(AUDIO_FILE_REMOVE, &crd->pb, row); - ret = osl_del_row(audio_file_table, row); + ret = osl(osl_del_row(audio_file_table, row)); if (ret < 0) para_printf(&crd->pb, "%s: %s\n", name, para_strerror(-ret)); else @@ -2563,7 +2565,7 @@ static int aft_open(const char *dir) int ret; audio_file_table_desc.dir = dir; - ret = osl_open_table(&audio_file_table_desc, &audio_file_table); + ret = osl(osl_open_table(&audio_file_table_desc, &audio_file_table)); if (ret >= 0) { unsigned num; osl_get_num_rows(audio_file_table, &num); @@ -2580,7 +2582,7 @@ static int aft_open(const char *dir) static int aft_create(const char *dir) { audio_file_table_desc.dir = dir; - return osl_create_table(&audio_file_table_desc); + return osl(osl_create_table(&audio_file_table_desc)); } static int clear_attribute(struct osl_row *row, void *data)