From fd9efcbec2d1d6e25460b117841a0931de28cb6f Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 2 Oct 2015 21:18:42 +0000 Subject: [PATCH] server: Convert com_rmatt() to lopsub. No change to the action handler, remove_attribute(), necessary. --- afs.cmd | 7 ------- attribute.c | 22 ++++++++++++++++------ m4/lls/server_cmd.suite.m4 | 9 +++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/afs.cmd b/afs.cmd index 35c3601c..5a8ff3c1 100644 --- a/afs.cmd +++ b/afs.cmd @@ -59,13 +59,6 @@ U: addatt attribute1... H: This adds new attributes to the attribute table. At most 64 H: attributes may be defined. --- -N: rmatt -P: AFS_READ | AFS_WRITE -D: Remove attribute(s). -U: rmatt pattern... -H: Remove all attributes matching any given pattern. All information -H: about this attribute in the audio file table is lost. ---- N: rm P: AFS_READ | AFS_WRITE D: Remove entries from the audio file table. diff --git a/attribute.c b/attribute.c index 2beabafa..c869e391 100644 --- a/attribute.c +++ b/attribute.c @@ -318,31 +318,41 @@ static int remove_attribute(struct osl_table *table, struct osl_row *row, static int com_rmatt_callback(struct afs_callback_arg *aca) { + const struct lls_command *cmd = SERVER_CMD_CMD_PTR(RMATT); int ret; struct pattern_match_data pmd = { .table = attribute_table, - .patterns = aca->query, .loop_col_num = ATTCOL_BITNUM, .match_col_num = ATTCOL_NAME, .data = aca, .action = remove_attribute }; + ret = lls(lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr)); + assert(ret >= 0); + pmd.lpr = aca->lpr; ret = for_each_matching_row(&pmd); if (ret < 0) goto out; if (pmd.num_matches == 0) ret = -E_NO_MATCH; out: + lls_free_parse_result(aca->lpr, cmd); return ret; } -int com_rmatt(struct command_context *cc) +static int com_rmatt(struct command_context *cc, struct lls_parse_result *lpr) { - if (cc->argc < 2) - return -E_ATTR_SYNTAX; - return send_standard_callback_request(cc->argc - 1, cc->argv + 1, - com_rmatt_callback, afs_cb_result_handler, cc); + const struct lls_command *cmd = SERVER_CMD_CMD_PTR(RMATT); + char *errctx; + int ret = lls(lls_check_arg_count(lpr, 1, INT_MAX, &errctx)); + + if (ret < 0) { + send_errctx(cc, errctx); + return ret; + } + return send_lls_callback_request(com_rmatt_callback, cmd, lpr, cc); } +EXPORT_SERVER_CMD_HANDLER(rmatt); /** * Return a binary representation of the given attribute value. diff --git a/m4/lls/server_cmd.suite.m4 b/m4/lls/server_cmd.suite.m4 index b8ee2fc6..e1d6037f 100644 --- a/m4/lls/server_cmd.suite.m4 +++ b/m4/lls/server_cmd.suite.m4 @@ -246,6 +246,15 @@ aux_info_prefix = Permissions: Set the 'P' (playing) bit of the vss status flags. [/description] +[subcommand rmatt] + purpose = remove attribute(s) + non-opts-name = pattern... + aux_info = AFS_READ | AFS_WRITE + [description] + Remove all attributes which match any given pattern. All information + about the removed attributes in the audio file table is lost. + [/description] + [subcommand sender] purpose = control paraslash senders synopsis = [sender cmd [arguments]] -- 2.39.2