X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=aft.c;h=c255b245fdf0209f0c8b09ba0b28310fddcb8fa5;hb=9602629057e1016f8ca7dfa2aae1477e4faece65;hp=6b5e0b74c4e70edc6d75c3dfeec9f9594f942e7b;hpb=586e2d24be69bc0aca8ad6c2033a4f4d193f5372;p=paraslash.git diff --git a/aft.c b/aft.c index 6b5e0b74..c255b245 100644 --- a/aft.c +++ b/aft.c @@ -1735,9 +1735,9 @@ static int com_add_callback(int fd, const struct osl_object *query) afs_event(AUDIO_FILE_ADD, &msg, aft_row); out: if (ret < 0) - para_printf(&msg, "%s\n", para_strerror(-ret)); + para_printf(&msg, "could not add %s\n", path); flush_and_free_pb(&msg); - return 0; + return ret; } /** Used by com_add(). */ @@ -1974,12 +1974,12 @@ static int touch_audio_file(__a_unused struct osl_table *table, ret = get_afsi_object_of_row(row, &obj); if (ret < 0) { - para_printf(&tad->pb, "%s: %s\n", name, para_strerror(-ret)); + para_printf(&tad->pb, "cannot touch %s\n", name); return ret; } ret = load_afsi(&old_afsi, &obj); if (ret < 0) { - para_printf(&tad->pb, "%s: %s\n", name, para_strerror(-ret)); + para_printf(&tad->pb, "cannot touch %s\n", name); return ret; } new_afsi = old_afsi; @@ -2036,12 +2036,10 @@ static int com_touch_callback(int fd, const struct osl_object *query) if (tad.cto->flags & TOUCH_FLAG_FNM_PATHNAME) pmd.fnmatch_flags |= FNM_PATHNAME; ret = for_each_matching_row(&pmd); - if (ret < 0) - para_printf(&tad.pb, "%s\n", para_strerror(-ret)); - else if (pmd.num_matches == 0) - para_printf(&tad.pb, "no matches\n"); + if (ret >= 0 && pmd.num_matches == 0) + ret = -E_NO_MATCH; flush_and_free_pb(&tad.pb); - return 0; + return ret; } int com_touch(struct command_context *cc) @@ -2111,11 +2109,8 @@ int com_touch(struct command_context *cc) } if (i >= cc->argc) return -E_AFT_SYNTAX; - ret = send_option_arg_callback_request(&query, cc->argc - i, + return send_option_arg_callback_request(&query, cc->argc - i, cc->argv + i, com_touch_callback, afs_cb_result_handler, cc); - if (ret < 0) - send_strerror(cc, -ret); - return ret; } /** Flags for com_rm(). */ @@ -2147,7 +2142,7 @@ static int remove_audio_file(__a_unused struct osl_table *table, afs_event(AUDIO_FILE_REMOVE, &crd->pb, row); ret = osl(osl_del_row(audio_file_table, row)); if (ret < 0) - para_printf(&crd->pb, "%s: %s\n", name, para_strerror(-ret)); + para_printf(&crd->pb, "cannot remove %s\n", name); return ret; } @@ -2176,16 +2171,15 @@ static int com_rm_callback(int fd, const struct osl_object *query) if (crd.flags & RM_FLAG_FNM_PATHNAME) pmd.fnmatch_flags |= FNM_PATHNAME; ret = for_each_matching_row(&pmd); - if (ret < 0) { - para_printf(&crd.pb, "%s\n", para_strerror(-ret)); - return 0; - } - if ((pmd.num_matches == 0) && !(crd.flags & RM_FLAG_FORCE)) - para_printf(&crd.pb, "no matches -- nothing removed\n"); + if (ret < 0) + goto out; + if (pmd.num_matches == 0) + ret = -E_NO_MATCH; else if (crd.flags & RM_FLAG_VERBOSE) - para_printf(&crd.pb, "removed %u files\n", pmd.num_matches); + para_printf(&crd.pb, "removed %u file(s)\n", pmd.num_matches); +out: flush_and_free_pb(&crd.pb); - return 0; + return ret; } /* TODO options: -r (recursive) */ @@ -2193,7 +2187,7 @@ int com_rm(struct command_context *cc) { uint32_t flags = 0; struct osl_object query = {.data = &flags, .size = sizeof(flags)}; - int i, ret; + int i; for (i = 1; i < cc->argc; i++) { const char *arg = cc->argv[i]; @@ -2219,11 +2213,8 @@ int com_rm(struct command_context *cc) } if (i >= cc->argc) return -E_AFT_SYNTAX; - ret = send_option_arg_callback_request(&query, cc->argc - i, + return send_option_arg_callback_request(&query, cc->argc - i, cc->argv + i, com_rm_callback, afs_cb_result_handler, cc); - if (ret < 0) - send_strerror(cc, -ret); - return ret; } /** @@ -2319,23 +2310,23 @@ static int com_cpsi_callback(int fd, const struct osl_object *query) if (ret < 0) goto out; ret = for_each_matching_row(&pmd); -out: if (ret < 0) - para_printf(&cad.pb, "%s\n", para_strerror(-ret)); - else if (pmd.num_matches > 0) { + goto out; + if (pmd.num_matches > 0) { if (cad.flags & CPSI_FLAG_VERBOSE) - para_printf(&cad.pb, "copied requested afsi from %s " - "to %u files\n", source_path, pmd.num_matches); + para_printf(&cad.pb, "updated afsi of %u file(s)\n", + pmd.num_matches); } else - para_printf(&cad.pb, "no matches - nothing copied\n"); + ret = -E_NO_MATCH; +out: flush_and_free_pb(&cad.pb); - return 0; + return ret; } int com_cpsi(struct command_context *cc) { unsigned flags = 0; - int i, ret; + int i; struct osl_object options = {.data = &flags, .size = sizeof(flags)}; for (i = 1; i < cc->argc; i++) { @@ -2376,11 +2367,8 @@ int com_cpsi(struct command_context *cc) return -E_AFT_SYNTAX; if (!(flags & ~CPSI_FLAG_VERBOSE)) /* no copy flags given */ flags = ~(unsigned)CPSI_FLAG_VERBOSE | flags; - ret = send_option_arg_callback_request(&options, cc->argc - i, + return send_option_arg_callback_request(&options, cc->argc - i, cc->argv + i, com_cpsi_callback, afs_cb_result_handler, cc); - if (ret < 0) - send_strerror(cc, -ret); - return ret; } struct change_atts_data { @@ -2470,12 +2458,10 @@ static int com_setatt_callback(int fd, const struct osl_object *query) if (ret < 0) goto out; if (pmd.num_matches == 0) - para_printf(&cad.pb, "no matches\n"); + ret = -E_NO_MATCH; out: - if (ret < 0) - para_printf(&cad.pb, "%s\n", para_strerror(-ret)); flush_and_free_pb(&cad.pb); - return 0; + return ret; } int com_setatt(struct command_context *cc)