server: Convert com_rmatt() to lopsub.
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 2 Oct 2015 21:18:42 +0000 (21:18 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 26 Mar 2017 09:02:28 +0000 (11:02 +0200)
No change to the action handler, remove_attribute(), necessary.

afs.cmd
attribute.c
m4/lls/server_cmd.suite.m4

diff --git a/afs.cmd b/afs.cmd
index 35c3601cc2ed5197815e924343ac869429968bb9..5a8ff3c17623e3c489424bead013a1954bf9e576 100644 (file)
--- 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.
 ---
 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.
 N: rm
 P: AFS_READ | AFS_WRITE
 D: Remove entries from the audio file table.
index 2beabafa7a3d4b65f7ea87207b0c1e020f15a1d3..c869e39197005d79603cf069a11b0162414d4c5b 100644 (file)
@@ -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)
 {
 
 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,
        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
        };
                .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:
        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;
 }
 
        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.
 
 /**
  * Return a binary representation of the given attribute value.
index b8ee2fc640d78969d39d4918962e2c33929d1038..e1d6037fabb68596ef4f6b697e61818f51e16560 100644 (file)
@@ -246,6 +246,15 @@ aux_info_prefix = Permissions:
                Set the 'P' (playing) bit of the vss status flags.
        [/description]
 
                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]]
 [subcommand sender]
        purpose = control paraslash senders
        synopsis = [sender cmd [arguments]]