]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Convert com_init() to lopsub.
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 2 Oct 2015 21:23:54 +0000 (21:23 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 26 Mar 2017 09:02:28 +0000 (11:02 +0200)
No change necessary for the callback as the init command does
not have any options. The only information that must travel from the
command handler to the callback is the set of tables to create. The
corresponding bitmask is passed without serializing the parse result.

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

diff --git a/afs.c b/afs.c
index 57ec13385f6c2725be4b5bb7a3d17faa10d024d8..f0fa57fcb6087a5d812fc282712eb7fd1701cc8f 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -16,6 +16,7 @@
 #include <arpa/inet.h>
 #include <sys/un.h>
 #include <netdb.h>
+#include <lopsub.h>
 
 #include "server.cmdline.h"
 #include "para.h"
@@ -1071,23 +1072,24 @@ out:
        return ret;
 }
 
-int com_init(struct command_context *cc)
+static int com_init(struct command_context *cc, struct lls_parse_result *lpr)
 {
        int i, j, ret;
        uint32_t table_mask = (1 << (NUM_AFS_TABLES + 1)) - 1;
        struct osl_object query = {.data = &table_mask,
                .size = sizeof(table_mask)};
+       unsigned num_inputs = lls_num_inputs(lpr);
 
        ret = make_database_dir();
        if (ret < 0)
                return ret;
-       if (cc->argc != 1) {
+       if (num_inputs > 0) {
                table_mask = 0;
-               for (i = 1; i < cc->argc; i++) {
+               for (i = 0; i < num_inputs; i++) {
                        for (j = 0; j < NUM_AFS_TABLES; j++) {
                                struct afs_table *t = &afs_tables[j];
 
-                               if (strcmp(cc->argv[i], t->name))
+                               if (strcmp(lls_input(i, lpr), t->name))
                                        continue;
                                table_mask |= (1 << j);
                                break;
@@ -1099,6 +1101,7 @@ int com_init(struct command_context *cc)
        return send_callback_request(com_init_callback, &query,
                afs_cb_result_handler, cc);
 }
+EXPORT_SERVER_CMD_HANDLER(init);
 
 /**
  * Flags for the check command.
diff --git a/afs.cmd b/afs.cmd
index 7028d1bb2190b632e724af8a04adf34df62b5bd3..6e2967ad9a75f9a95a343202cf27aa117064aae2 100644 (file)
--- a/afs.cmd
+++ b/afs.cmd
@@ -3,13 +3,6 @@ SF: afs.c aft.c attribute.c
 SN: list of afs commands
 TM: mood lyr img pl
 ---
-N: init
-P: AFS_READ | AFS_WRITE
-D: Initialize the osl tables for the audio file selector.
-U: init [table_name ...]
-H: When invoked without arguments, this command creates all tables. Otherwise
-H: only the tables given by table_name... are created.
----
 N: ls
 P: AFS_READ
 D: List audio files.
index e5bdcedec25dd0fdb59deb6678b003112581c529..4a1f9f462497eb26ec1cfd57fd0d153539dbfef7 100644 (file)
@@ -87,6 +87,16 @@ aux_info_prefix = Permissions:
                to the server process has the same effect as running this command.
        [/description]
 
+[subcommand init]
+       purpose = initialize the database tables for the audio file selector
+       synopsis = [table_name...]
+       aux_info = AFS_READ | AFS_WRITE
+       [description]
+               When invoked without arguments, this command creates all
+               tables: audio_files, attributes, scores, moods, lyrics, images,
+               playlists. Otherwise only the given tables are created.
+       [/description]
+
 [subcommand jmp]
        purpose = reposition the current stream
        non-opts-name = n