]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
afs.c: Move com_select() and its callback down.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 30 Aug 2022 11:55:48 +0000 (13:55 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 17 Oct 2022 18:36:21 +0000 (20:36 +0200)
Preparation for the upcoming introduction of afs_error(), which will
be called by the select callback and should therefore be located
above the callback. No code changes, nothing to see here.

afs.c

diff --git a/afs.c b/afs.c
index cea8f2707491f00bab0f457a3463fd4762147a21..6493586a6abad51c1f6bd5d3716c7a1dd1beeb23 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -525,53 +525,6 @@ static void flush_and_free_pb(struct para_buffer *pb)
        free(pb->buf);
 }
 
-static int com_select_callback(struct afs_callback_arg *aca)
-{
-       const struct lls_command *cmd = SERVER_CMD_CMD_PTR(SELECT);
-       const char *arg;
-       int ret;
-
-       ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
-       assert(ret >= 0);
-       arg = lls_input(0, aca->lpr);
-       score_clear();
-       if (current_play_mode == PLAY_MODE_MOOD)
-               mood_unload();
-       else
-               playlist_unload();
-       ret = activate_mood_or_playlist(arg, &aca->pbout);
-       if (ret >= 0)
-               goto free_lpr;
-       /* ignore subsequent errors (but log them) */
-       if (current_mop && strcmp(current_mop, arg) != 0) {
-               int ret2;
-               para_printf(&aca->pbout, "switching back to %s\n", current_mop);
-               ret2 = activate_mood_or_playlist(current_mop, &aca->pbout);
-               if (ret2 >= 0)
-                       goto free_lpr;
-               para_printf(&aca->pbout, "could not reactivate %s: %s\n",
-                       current_mop, para_strerror(-ret2));
-       }
-       activate_mood_or_playlist(NULL, &aca->pbout);
-free_lpr:
-       lls_free_parse_result(aca->lpr, cmd);
-       return ret;
-}
-
-static int com_select(struct command_context *cc, struct lls_parse_result *lpr)
-{
-       const struct lls_command *cmd = SERVER_CMD_CMD_PTR(SELECT);
-       char *errctx;
-       int ret = lls(lls_check_arg_count(lpr, 1, 1, &errctx));
-
-       if (ret < 0) {
-               send_errctx(cc, errctx);
-               return ret;
-       }
-       return send_lls_callback_request(com_select_callback, cmd, lpr, cc);
-}
-EXPORT_SERVER_CMD_HANDLER(select);
-
 static void init_admissible_files(const char *arg)
 {
        int ret = activate_mood_or_playlist(arg, NULL);
@@ -985,6 +938,53 @@ out:
        exit(EXIT_FAILURE);
 }
 
+static int com_select_callback(struct afs_callback_arg *aca)
+{
+       const struct lls_command *cmd = SERVER_CMD_CMD_PTR(SELECT);
+       const char *arg;
+       int ret;
+
+       ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
+       assert(ret >= 0);
+       arg = lls_input(0, aca->lpr);
+       score_clear();
+       if (current_play_mode == PLAY_MODE_MOOD)
+               mood_unload();
+       else
+               playlist_unload();
+       ret = activate_mood_or_playlist(arg, &aca->pbout);
+       if (ret >= 0)
+               goto free_lpr;
+       /* ignore subsequent errors (but log them) */
+       if (current_mop && strcmp(current_mop, arg) != 0) {
+               int ret2;
+               para_printf(&aca->pbout, "switching back to %s\n", current_mop);
+               ret2 = activate_mood_or_playlist(current_mop, &aca->pbout);
+               if (ret2 >= 0)
+                       goto free_lpr;
+               para_printf(&aca->pbout, "could not reactivate %s: %s\n",
+                       current_mop, para_strerror(-ret2));
+       }
+       activate_mood_or_playlist(NULL, &aca->pbout);
+free_lpr:
+       lls_free_parse_result(aca->lpr, cmd);
+       return ret;
+}
+
+static int com_select(struct command_context *cc, struct lls_parse_result *lpr)
+{
+       const struct lls_command *cmd = SERVER_CMD_CMD_PTR(SELECT);
+       char *errctx;
+       int ret = lls(lls_check_arg_count(lpr, 1, 1, &errctx));
+
+       if (ret < 0) {
+               send_errctx(cc, errctx);
+               return ret;
+       }
+       return send_lls_callback_request(com_select_callback, cmd, lpr, cc);
+}
+EXPORT_SERVER_CMD_HANDLER(select);
+
 static int com_init_callback(struct afs_callback_arg *aca)
 {
        uint32_t table_mask = *(uint32_t *)aca->query.data;