play: Convert com_play() to lopsub.
[paraslash.git] / play.c
diff --git a/play.c b/play.c
index 1700f9ac467eff2998af7321747360b994698c46..6ca97e6bef58a3bb7c71d3af4137507d0eabb202 100644 (file)
--- a/play.c
+++ b/play.c
@@ -847,16 +847,21 @@ static int com_ls(struct play_task *pt,
 }
 EXPORT_PLAY_CMD_HANDLER(ls);
 
-static int com_play(struct play_task *pt, int argc, char **argv)
+static int com_play(struct play_task *pt, struct lls_parse_result *lpr)
 {
        int32_t x;
        int ret;
-       char state;
+       char state, *errctx;
 
-       if (argc > 2)
-               return -E_PLAY_SYNTAX;
+       ret = lls(lls_check_arg_count(lpr, 0, 1, &errctx));
+       if (ret < 0) {
+               if (errctx)
+                       PARA_ERROR_LOG("%s\n", errctx);
+               free(errctx);
+               return ret;
+       }
        state = get_playback_state(pt);
-       if (argc == 1) {
+       if (lls_num_inputs(lpr) == 0) {
                if (state == 'P')
                        return 0;
                pt->next_file = pt->current_file;
@@ -864,7 +869,7 @@ static int com_play(struct play_task *pt, int argc, char **argv)
                pt->playing = true;
                return 0;
        }
-       ret = para_atoi32(argv[1], &x);
+       ret = para_atoi32(lls_input(0, lpr), &x);
        if (ret < 0)
                return ret;
        if (x < 0 || x >= conf.inputs_num)
@@ -874,6 +879,7 @@ static int com_play(struct play_task *pt, int argc, char **argv)
        pt->rq = CRT_FILE_CHANGE;
        return 0;
 }
+EXPORT_PLAY_CMD_HANDLER(play);
 
 static int com_pause(struct play_task *pt, int argc, __a_unused char **argv)
 {