]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
command_util.sh: Make it read the function prototype from the source file
authorAndre Noll <maan@systemlinux.org>
Sun, 11 Feb 2007 16:06:46 +0000 (17:06 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 11 Feb 2007 16:06:46 +0000 (17:06 +0100)
This is much cleaner as the commands differ by gcc attribute usage,
e.g. __a_unused.  But it also means that in the source code

(a) the opening bracket for the function body must not be on
the same line (com_hist got this wrong),

(b) for all command handlers, the parameters must be called
fd, argc and argv,

(c) If a command handler uses __noreturn, that attribute must
be the first word, see audiod's com_term().

So change the few occasions where this was not the case.

audiod.cmd
audiod_command.c
command.c
command_util.sh
error.h
mysql_selector.c
mysql_selector.cmd
playlist_selector.cmd
random_selector.cmd
server.cmd

index 8300e4418f3c20cec0ac3894a0765ae92fd925ba..f6d1a1f64ee71ac6faba4c38e11800d3d5cacd39 100644 (file)
@@ -1,4 +1,5 @@
-FN: audiod_command_list
+OF: audiod_command_list
+SF: audiod_command.c
 HC: prototypes for the audiod command handlers
 CC: array of audiod commands
 AT: audiod_command
index d1e36490822c216da260003457a1fecfc3c02941..524fb57dbd7d81cd5cf96923ab7501bff7f1036e 100644 (file)
@@ -350,7 +350,7 @@ err_out:
        return 1;
 }
 
-int __noreturn com_term(int fd, __a_unused int argc, __a_unused char **argv)
+__noreturn int com_term(int fd, __a_unused int argc, __a_unused char **argv)
 {
        close(fd);
        clean_exit(EXIT_SUCCESS, "terminating on user request");
index 9ef629257134e4d8cad97fc344b30e0be473956d..d0d9047b7d3d97dc1061a6c52db158e500d4969c 100644 (file)
--- a/command.c
+++ b/command.c
@@ -341,18 +341,18 @@ int com_si(int fd, int argc, __a_unused char **argv)
 }
 
 /* version */
-int com_version(int socket_fd, int argc, __a_unused char **argv)
+int com_version(int fd, int argc, __a_unused char **argv)
 {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
-       return send_buffer(socket_fd, VERSION_TEXT("server")
+       return send_buffer(fd, VERSION_TEXT("server")
                "built: " BUILD_DATE "\n"
                SYSTEM ", " CC_VERSION "\n"
        );
 }
 
 /* sc */
-int com_sc(int socket_fd, int argc, char **argv)
+int com_sc(int fd, int argc, char **argv)
 {
        char *name = NULL;
        int ret, old = 0, count = -1; /* print af change forever */
@@ -367,7 +367,7 @@ repeat:
        }
        mmd_unlock();
        if (name) {
-               ret = send_va_buffer(socket_fd, "%s\n", name);
+               ret = send_va_buffer(fd, "%s\n", name);
                free(name);
                name = NULL;
                if (ret < 0)
@@ -380,7 +380,7 @@ repeat:
 }
 
 /* sb */
-int com_sb(int socket_fd, int argc, char **argv)
+int com_sb(int fd, int argc, char **argv)
 {
        char *sb;
        int ret, nr = -1;       /* status bar will be printed that many
@@ -393,7 +393,7 @@ int com_sb(int socket_fd, int argc, char **argv)
                mmd_lock();
                sb = get_sb_string(mmd);
                mmd_unlock();
-               ret = send_va_buffer(socket_fd, "%s\n", sb);
+               ret = send_va_buffer(fd, "%s\n", sb);
                free(sb);
                if (ret < 0)
                        return ret;
@@ -407,7 +407,7 @@ int com_sb(int socket_fd, int argc, char **argv)
 }
 
 /* stat */
-int com_stat(int socket_fd, int argc, char **argv)
+int com_stat(int fd, int argc, char **argv)
 {
        int ret, num = 0;/* status will be printed that many
                          * times. num <= 0 means: print forever
@@ -423,7 +423,7 @@ int com_stat(int socket_fd, int argc, char **argv)
 
                mmd_dup(nmmd);
                s = get_status(nmmd);
-               ret = send_buffer(socket_fd, s);
+               ret = send_buffer(fd, s);
                free(s);
                if (ret < 0)
                        goto out;
@@ -525,7 +525,7 @@ int com_help(int fd, int argc, char **argv)
 }
 
 /* hup */
-int com_hup(__a_unused int socket_fd, int argc, __a_unused char **argv)
+int com_hup(__a_unused int fd, int argc, __a_unused char **argv)
 {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -534,7 +534,7 @@ int com_hup(__a_unused int socket_fd, int argc, __a_unused char **argv)
 }
 
 /* term */
-int com_term(__a_unused int socket_fd, int argc, __a_unused char **argv)
+int com_term(__a_unused int fd, int argc, __a_unused char **argv)
 {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -542,7 +542,7 @@ int com_term(__a_unused int socket_fd, int argc, __a_unused char **argv)
        return 1;
 }
 
-int com_play(__a_unused int socket_fd, int argc, __a_unused char **argv)
+int com_play(__a_unused int fd, int argc, __a_unused char **argv)
 {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -555,7 +555,7 @@ int com_play(__a_unused int socket_fd, int argc, __a_unused char **argv)
 }
 
 /* stop */
-int com_stop(__a_unused int socket_fd, int argc, __a_unused char **argv)
+int com_stop(__a_unused int fd, int argc, __a_unused char **argv)
 {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -568,7 +568,7 @@ int com_stop(__a_unused int socket_fd, int argc, __a_unused char **argv)
 }
 
 /* pause */
-int com_pause(__a_unused int socket_fd, int argc, __a_unused char **argv)
+int com_pause(__a_unused int fd, int argc, __a_unused char **argv)
 {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -607,7 +607,7 @@ int com_chs(int fd, int argc, char **argv)
 }
 
 /* next */
-int com_next(__a_unused int socket_fd, int argc, __a_unused char **argv)
+int com_next(__a_unused int fd, int argc, __a_unused char **argv)
 {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -619,7 +619,7 @@ int com_next(__a_unused int socket_fd, int argc, __a_unused char **argv)
 }
 
 /* nomore */
-int com_nomore(__a_unused int socket_fd, int argc, __a_unused char **argv)
+int com_nomore(__a_unused int fd, int argc, __a_unused char **argv)
 {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -631,7 +631,7 @@ int com_nomore(__a_unused int socket_fd, int argc, __a_unused char **argv)
 }
 
 /* ff */
-int com_ff(__a_unused int socket_fd, int argc, char **argv)
+int com_ff(__a_unused int fd, int argc, char **argv)
 {
        long promille;
        int ret, backwards = 0;
@@ -670,7 +670,7 @@ out:
 }
 
 /* jmp */
-int com_jmp(__a_unused int socket_fd, int argc, char **argv)
+int com_jmp(__a_unused int fd, int argc, char **argv)
 {
        long unsigned int i;
        int ret;
index 326bb032abfa827b21ea4d09f524cc7266938680..4a9a03cc77f9637e20fc797d99f655ca3ce90a30 100755 (executable)
@@ -36,10 +36,13 @@ read_header()
                CC:)
                        c_file_comment="$value"
                        ;;
-               FN:)
-                       file_name="$value"
+               OF:)
+                       output_file="$value"
                        array_name=${value%command_list}cmds
                        ;;
+               SF:)
+                       source_file="$value"
+                       ;;
                AT:)
                        array_type="$value"
                        ;;
@@ -49,14 +52,14 @@ read_header()
 #include \"$i.h\""
                        done
                        includes="$includes
-#include \"$file_name.h\""
+#include \"$output_file.h\""
                        ;;
                SN:)
                        section_name="$value"
                esac
        done
        if test -z "$header_comment" -o -z "$c_file_comment" \
-                       -o -z "$file_name"; then
+                       -o -z "$output_file"; then
                echo "header error" 1&>2
                exit 1
        fi
@@ -166,7 +169,7 @@ com_man()
 
 com_c_file()
 {
-       echo "/** \file $file_name.c $c_file_comment */"
+       echo "/** \file $output_file.c $c_file_comment */"
        echo "$includes"
        echo "struct $array_type $array_name[] = {"
        while : ; do
@@ -199,17 +202,13 @@ dump_proto()
        echo ' * '
        echo "$help_txt" | sed -e 's/^/ * /g'
        echo ' */'
-       if test $line_handler -eq 0; then
-               echo "int com_$name_txt(int fd, int argc, char **argv);"
-       else
-               echo "int com_$name_txt(int fd, char *cmdline);"
-       fi
+       grep "^\(__noreturn \)*int com_$name_txt(" $source_file | sed -e 's/$/;/1'
        echo
 }
 
 com_header()
 {
-       echo "/** \file $file_name.h $header_comment */"
+       echo "/** \file $output_file.h $header_comment */"
        echo
        echo "extern struct $array_type $array_name[];"
        while : ; do
diff --git a/error.h b/error.h
index 9563303fabf9e3aca1556f34180a50753ca9d16e..34b18f193bef5dd4f8a54083cbb4c842ae3ed8be 100644 (file)
--- a/error.h
+++ b/error.h
@@ -518,7 +518,7 @@ extern const char **para_errlist[];
  */
 #define PARA_ERROR(err, msg) E_ ## err
 
-#define SS_NAME(ss) para_errlist[ss]? para_errlist[ss][0] : ""
+// #define SS_NAME(ss) para_errlist[ss]? para_errlist[ss][0] : ""
 
 /** \cond popcorn time */
 SS_ENUM(GUI);
index f8885f9a0f50ea0dd185e4cbecbc3a0ab17d1d0e..b059de70b61cd49f8aa46e7c64411e8fb4617852 100644 (file)
@@ -459,7 +459,8 @@ int com_laa(int fd, int argc, __a_unused char *argv[])
 /*
  * history
  */
-int com_hist(int fd, int argc, char *argv[]) {
+int com_hist(int fd, int argc, char *argv[])
+{
        int ret;
        void *result = NULL;
        char *q, *atts;
index df88a2203ee96724d31e5e1a0c80addf507972f3..7696352df6b80eca9ccef6196fab818c9d1b6436 100644 (file)
@@ -1,4 +1,5 @@
-FN: mysql_selector_command_list
+OF: mysql_selector_command_list
+SF: mysql_selector.c
 HC: prototypes for the commands of the mysql audio file selector
 CC: array of commands for the mysql audio file selector
 AT: server_command
index f829028a7caad3e8c47eba3237418792c2c18ae4..e84e97ee592fa4f9944355ffbd3677070a80e4af 100644 (file)
@@ -1,4 +1,5 @@
-FN: playlist_selector_command_list
+OF: playlist_selector_command_list
+SF: playlist_selector.c
 HC: prototypes for the commands of the playlist audio file selector
 CC: array of commands for the playlist audio file selector
 AT: server_command
index fe3ef72439dd72e1108a56f8f594d6f12a55e793..f1901f88d78934041af9993584adcf2bff2f54cf 100644 (file)
@@ -1,4 +1,5 @@
-FN: random_selector_command_list
+OF: random_selector_command_list
+SF: random_selector.c
 HC: prototypes for the commands of the random audio file selector
 CC: array of commands for the random audio file selector
 AT: server_command
index 71ed6d9ea027e1734cb4f08a9689c81c20f2d44d..ad175c8df14ce9f3eb66d624e72f3998cd303ff7 100644 (file)
@@ -1,4 +1,5 @@
-FN: server_command_list
+OF: server_command_list
+SF: command.c
 HC: prototypes for the server command handlers
 CC: array of server commands
 AT: server_command