Make (most) command handlers static.
authorAndre Noll <maan@systemlinux.org>
Sat, 7 Apr 2012 06:30:27 +0000 (08:30 +0200)
committerAndre Noll <maan@systemlinux.org>
Fri, 29 Jun 2012 19:36:31 +0000 (21:36 +0200)
Now that the array of commands for para_server and para_audiod are
read from a header file, the command handlers can be made static if
they are in the same file that defines the command array.

This patch makes all such handlers static and tweaks command_util.sh
to recognize also static functions.

audiod_command.c
command.c
command_util.sh

index 1c3b0582d5bfb0a1cff62b28351a52d843e073ed..35b76b5f6fa277ea2aa55656f557b32ef36b5585 100644 (file)
@@ -252,7 +252,7 @@ static int dump_commands(int fd)
  * to each individual command to close the fd if necessary.
  */
 
-int com_help(int fd, int argc, char **argv)
+static int com_help(int fd, int argc, char **argv)
 {
        int i, ret;
        char *buf;
@@ -287,7 +287,7 @@ out:
        return ret;
 }
 
-int com_tasks(int fd, __a_unused int argc, __a_unused char **argv)
+static int com_tasks(int fd, __a_unused int argc, __a_unused char **argv)
 {
        char *tl = get_task_list(&sched);
        int ret = 1;
@@ -299,7 +299,7 @@ int com_tasks(int fd, __a_unused int argc, __a_unused char **argv)
        return ret;
 }
 
-int com_stat(int fd, int argc, char **argv)
+static int com_stat(int fd, int argc, char **argv)
 {
        int i, ret, parser_friendly = 0;
        uint64_t mask = 0;
@@ -345,39 +345,39 @@ int com_stat(int fd, int argc, char **argv)
        return ret;
 }
 
-int com_grab(int fd, int argc, char **argv)
+static int com_grab(int fd, int argc, char **argv)
 {
        return grab_client_new(fd, argc, argv, &sched);
 }
 
-__noreturn int com_term(int fd, __a_unused int argc, __a_unused char **argv)
+__noreturn static int com_term(int fd, __a_unused int argc, __a_unused char **argv)
 {
        close(fd);
        clean_exit(EXIT_SUCCESS, "terminating on user request");
 }
 
-int com_on(int fd, __a_unused int argc, __a_unused char **argv)
+static int com_on(int fd, __a_unused int argc, __a_unused char **argv)
 {
        audiod_status = AUDIOD_ON;
        close(fd);
        return 1;
 }
 
-int com_off(int fd, __a_unused int argc, __a_unused char **argv)
+static int com_off(int fd, __a_unused int argc, __a_unused char **argv)
 {
        audiod_status = AUDIOD_OFF;
        close(fd);
        return 1;
 }
 
-int com_sb(int fd, __a_unused int argc, __a_unused char **argv)
+static int com_sb(int fd, __a_unused int argc, __a_unused char **argv)
 {
        audiod_status = AUDIOD_STANDBY;
        close(fd);
        return 1;
 }
 
-int com_cycle(int fd, int argc, char **argv)
+static int com_cycle(int fd, int argc, char **argv)
 {
        switch (audiod_status) {
                case  AUDIOD_ON:
index e051aae4e627ac1b3ef5f30581700cb9af432928..f9bace34146e28ccaf7b0632e0fa34ede51de8aa 100644 (file)
--- a/command.c
+++ b/command.c
@@ -317,7 +317,7 @@ fail:
        return ret;
 }
 
-int com_sender(struct command_context *cc)
+static int com_sender(struct command_context *cc)
 {
        int i, ret = 0;
        char *msg = NULL;
@@ -374,7 +374,7 @@ int com_sender(struct command_context *cc)
 }
 
 /* server info */
-int com_si(struct command_context *cc)
+static int com_si(struct command_context *cc)
 {
        int i, ret;
        char *msg, *ut, *sender_info = NULL;
@@ -417,7 +417,7 @@ int com_si(struct command_context *cc)
 }
 
 /* version */
-int com_version(struct command_context *cc)
+static int com_version(struct command_context *cc)
 {
        char *msg;
        size_t len;
@@ -498,7 +498,7 @@ out:
 #undef EMPTY_STATUS_ITEMS
 
 /* stat */
-int com_stat(struct command_context *cc)
+static int com_stat(struct command_context *cc)
 {
        int i, ret;
        struct misc_meta_data tmp, *nmmd = &tmp;
@@ -608,7 +608,7 @@ static struct server_command *get_cmd_ptr(const char *name, char **handler)
 }
 
 /* help */
-int com_help(struct command_context *cc)
+static int com_help(struct command_context *cc)
 {
        struct server_command *cmd;
        char *perms, *handler, *buf;
@@ -647,7 +647,7 @@ int com_help(struct command_context *cc)
 }
 
 /* hup */
-int com_hup(struct command_context *cc)
+static int com_hup(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -656,7 +656,7 @@ int com_hup(struct command_context *cc)
 }
 
 /* term */
-int com_term(struct command_context *cc)
+static int com_term(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -664,7 +664,7 @@ int com_term(struct command_context *cc)
        return 1;
 }
 
-int com_play(struct command_context *cc)
+static int com_play(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -676,7 +676,7 @@ int com_play(struct command_context *cc)
 }
 
 /* stop */
-int com_stop(struct command_context *cc)
+static int com_stop(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -689,7 +689,7 @@ int com_stop(struct command_context *cc)
 }
 
 /* pause */
-int com_pause(struct command_context *cc)
+static int com_pause(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -704,7 +704,7 @@ int com_pause(struct command_context *cc)
 }
 
 /* next */
-int com_next(struct command_context *cc)
+static int com_next(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -716,7 +716,7 @@ int com_next(struct command_context *cc)
 }
 
 /* nomore */
-int com_nomore(struct command_context *cc)
+static int com_nomore(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -728,7 +728,7 @@ int com_nomore(struct command_context *cc)
 }
 
 /* ff */
-int com_ff(struct command_context *cc)
+static int com_ff(struct command_context *cc)
 {
        long promille;
        int ret, backwards = 0;
@@ -767,7 +767,7 @@ out:
 }
 
 /* jmp */
-int com_jmp(struct command_context *cc)
+static int com_jmp(struct command_context *cc)
 {
        long unsigned int i;
        int ret;
index 1530aee7333ea03a1b2748d85d60ce68c2eae2dd..2bceda43c5dc238b8c0b5c57b1a22e9ae4860505 100755 (executable)
@@ -173,7 +173,7 @@ make_proto()
        fi
        result=
        for source_file in $source_files; do
-               match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1')
+               match=$(grep "^\(__noreturn \)*\(static \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1')
                if test -n "$match"; then
                        result="$result$match$CR"
                        break