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.
+OF: audiod_command_list
+SF: audiod_command.c
HC: prototypes for the audiod command handlers
CC: array of audiod commands
AT: audiod_command
HC: prototypes for the audiod command handlers
CC: array of audiod commands
AT: audiod_command
-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");
{
close(fd);
clean_exit(EXIT_SUCCESS, "terminating on user request");
-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;
{
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 */
"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 */
{
char *name = NULL;
int ret, old = 0, count = -1; /* print af change forever */
}
mmd_unlock();
if (name) {
}
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)
free(name);
name = NULL;
if (ret < 0)
-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
{
char *sb;
int ret, nr = -1; /* status bar will be printed that many
mmd_lock();
sb = get_sb_string(mmd);
mmd_unlock();
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;
free(sb);
if (ret < 0)
return ret;
-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
{
int ret, num = 0;/* status will be printed that many
* times. num <= 0 means: print forever
mmd_dup(nmmd);
s = get_status(nmmd);
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;
free(s);
if (ret < 0)
goto out;
-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;
{
if (argc != 1)
return -E_COMMAND_SYNTAX;
-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;
{
if (argc != 1)
return -E_COMMAND_SYNTAX;
-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;
{
if (argc != 1)
return -E_COMMAND_SYNTAX;
-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;
{
if (argc != 1)
return -E_COMMAND_SYNTAX;
-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;
{
if (argc != 1)
return -E_COMMAND_SYNTAX;
-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;
{
if (argc != 1)
return -E_COMMAND_SYNTAX;
-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;
{
if (argc != 1)
return -E_COMMAND_SYNTAX;
-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;
{
long promille;
int ret, backwards = 0;
-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;
{
long unsigned int i;
int ret;
CC:)
c_file_comment="$value"
;;
CC:)
c_file_comment="$value"
;;
- FN:)
- file_name="$value"
+ OF:)
+ output_file="$value"
array_name=${value%command_list}cmds
;;
array_name=${value%command_list}cmds
;;
+ SF:)
+ source_file="$value"
+ ;;
AT:)
array_type="$value"
;;
AT:)
array_type="$value"
;;
#include \"$i.h\""
done
includes="$includes
#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" \
;;
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
echo "header error" 1&>2
exit 1
fi
- 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
echo "$includes"
echo "struct $array_type $array_name[] = {"
while : ; do
echo ' * '
echo "$help_txt" | sed -e 's/^/ * /g'
echo ' */'
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 "/** \file $file_name.h $header_comment */"
+ echo "/** \file $output_file.h $header_comment */"
echo
echo "extern struct $array_type $array_name[];"
while : ; do
echo
echo "extern struct $array_type $array_name[];"
while : ; do
*/
#define PARA_ERROR(err, msg) E_ ## err
*/
#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);
/** \cond popcorn time */
SS_ENUM(GUI);
-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;
int ret;
void *result = NULL;
char *q, *atts;
-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
HC: prototypes for the commands of the mysql audio file selector
CC: array of commands for the mysql audio file selector
AT: server_command
-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
HC: prototypes for the commands of the playlist audio file selector
CC: array of commands for the playlist audio file selector
AT: server_command
-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
HC: prototypes for the commands of the random audio file selector
CC: array of commands for the random audio file selector
AT: server_command
+OF: server_command_list
+SF: command.c
HC: prototypes for the server command handlers
CC: array of server commands
AT: server_command
HC: prototypes for the server command handlers
CC: array of server commands
AT: server_command