9f58f7 command_util: grep source files only once.
b4aff8 command_util: Fix make dependencies for *_command_list.h.
289547 Make (most) command handlers static.
ad3864 command_util: Remove code for generating .c files.
c9df5d command_util: Write array definition in header mode.
73ca79 command_util: Output array members with backslashes.
3792a2 command_util: Avoid empty output lines.
a51586 command_util: replace dump_xxx() by make_xxx().
6a4f5e command_util: Kill HC and CC header lines.
TODO
NONE
aclocal.m4
-*_command_list.c
*_command_list.h
*_command_list.man
paraslash-git.tar.bz2
gcc-compat.h \
fade.c \
config.h \
- *_command_list.[ch] \
+ *_command_list.h \
*_completion.h
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
$(subst z,Z,$1))))))))))))))))))))))))))
-%_command_list.c: %.cmd
- @[ -z "$(Q)" ] || echo 'GEN $@'
- $(Q) ./command_util.sh c < $< >$@
-%_command_list.h: %.cmd
+%_command_list.h: %.cmd %.c
@[ -z "$(Q)" ] || echo 'GEN $@'
$(Q) ./command_util.sh h < $< >$@
-%_command_list.man: %.cmd
+%_command_list.man: %.cmd %.c
@[ -z "$(Q)" ] || echo 'GEN $@'
$(Q) ./command_util.sh man < $< > $@
-%_completion.h: %.cmd
+%_completion.h: %.cmd %.c
@[ -z "$(Q)" ] || echo 'GEN $@'
$(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
$(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
+server_command_list.h server_command_list.man server_completion.h: command.c
+afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
+audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
+
server_command_lists_man = server_command_list.man afs_command_list.man
man/man1/para_server.1: para_server $(server_command_lists_man) | $(man_dir)
@[ -z "$(Q)" ] || echo 'MAN $<'
- Several fixes and latency improvements to various decoders.
- The alsa writer now limits the prebuffer time to 500ms.
- Documentation improvements.
+ - Overhaul of the command_util.sh script.
------------------------------------------
0.4.10 (2012-03-30) "heterogeneous vacuum"
-OF: afs_command_list
+BN: afs
SF: afs.c aft.c attribute.c
-HC: Prototypes for the commands of the audio file selector.
-CC: Array of commands for the audio file selector.
-AT: server_command
-SI: osl regex
-IN: para error crypt sideband command string afh afs server list user_list
SN: list of afs commands
TM: mood lyr img pl
---
-OF: audiod_command_list
+BN: audiod
SF: audiod_command.c
-HC: prototypes for the audiod command handlers
-CC: array of audiod commands
-AT: audiod_command
-IN: list para sched audiod
SN: list of audiod commands
---
N: cycle
extern struct sched sched;
extern char *stat_item_values[NUM_STAT_ITEMS];
+
+struct audiod_command audiod_cmds[] = {DEFINE_AUDIOD_CMD_ARRAY};
+
/** Iterate over the array of all audiod commands. */
#define FOR_EACH_COMMAND(c) for (c = 0; audiod_cmds[c].name; c++)
* 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;
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;
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;
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:
#include "signal.h"
#include "version.h"
+struct server_command afs_cmds[] = {DEFINE_AFS_CMD_ARRAY};
+struct server_command server_cmds[] = {DEFINE_SERVER_CMD_ARRAY};
+
/** Commands including options must be shorter than this. */
#define MAX_COMMAND_LEN 32768
return ret;
}
-int com_sender(struct command_context *cc)
+static int com_sender(struct command_context *cc)
{
int i, ret = 0;
char *msg = NULL;
}
/* 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;
}
/* version */
-int com_version(struct command_context *cc)
+static int com_version(struct command_context *cc)
{
char *msg;
size_t len;
#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;
}
/* help */
-int com_help(struct command_context *cc)
+static int com_help(struct command_context *cc)
{
struct server_command *cmd;
char *perms, *handler, *buf;
}
/* hup */
-int com_hup(struct command_context *cc)
+static int com_hup(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* term */
-int com_term(struct command_context *cc)
+static int com_term(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
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;
}
/* stop */
-int com_stop(struct command_context *cc)
+static int com_stop(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* pause */
-int com_pause(struct command_context *cc)
+static int com_pause(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* next */
-int com_next(struct command_context *cc)
+static int com_next(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* nomore */
-int com_nomore(struct command_context *cc)
+static int com_nomore(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
}
/* ff */
-int com_ff(struct command_context *cc)
+static int com_ff(struct command_context *cc)
{
long promille;
int ret, backwards = 0;
}
/* jmp */
-int com_jmp(struct command_context *cc)
+static int com_jmp(struct command_context *cc)
{
long unsigned int i;
int ret;
#!/usr/bin/env bash
-
read_header()
{
local key value i
---)
break
;;
- HC:)
- header_comment="$value"
- ;;
- CC:)
- c_file_comment="$value"
- ;;
- OF:)
- output_file="$value"
- array_name=${value%command_list}cmds
+ BN:)
+ base_name="$value"
;;
SF:)
source_files="$value"
;;
- AT:)
- array_type="$value"
- ;;
- SI:)
- for i in $value; do
- system_includes="$system_includes
-#include <$i.h>"
- done
- ;;
- IN:)
- for i in $value; do
- includes="$includes
-#include \"$i.h\""
- done
- includes="$includes
-#include \"$output_file.h\""
- ;;
SN:)
section_name="$value"
;;
template_members="$value"
esac
done
- if test -z "$header_comment" -o -z "$c_file_comment" \
- -o -z "$output_file"; then
- echo "header error" 1&>2
- exit 1
- fi
}
read_one_command()
done
}
-dump_proto()
+make_proto()
{
- local source_file match=""
-
- echo '/**'
- echo " * $desc_txt"
- echo ' *'
- echo " * Usage: $usage_txt"
- echo ' * '
- echo "$help_txt" | sed -e 's/^/ * /g'
- echo ' */'
+ local regex='\(__noreturn \)*\(static \)*int com_'
+ local source_file match="" all_commands CR='
+'
if test -n "$prototype"; then
- echo "$prototype"
- echo
+ result="$prototype$CR"
return
fi
+ all_commands="$(cat $source_files | grep "$regex")"
+ 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 "$regex$name_txt(" <<< "$all_commands" | head -n 1 | sed -e 's/$/;/1')
if test -n "$match"; then
- echo "$match"
+ result="$result$match$CR"
break
fi
done
- echo
}
-dump_array_member()
+make_array_member()
{
- local TAB=' '
- echo '{'
- echo ".name = \"$name_txt\","
- echo ".handler = com_$name_txt,"
+ local TAB=' ' CR='
+'
+ local tmp
+
+ result="{.name = \"$name_txt\", .handler = com_$name_txt, "
if test -n "$perms_txt"; then
- echo ".perms = $perms_txt,"
+ result="$result .perms = $perms_txt,"
fi
- echo ".description = \"$desc_txt\","
- echo ".usage = \"$usage_txt\","
- echo ".help = "
- printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
- -e "s/$TAB/\\\t/g"
- echo '},'
+ result="$result.description = \"$desc_txt\", .usage = \"$usage_txt\", \\$CR .help = "
+ tmp="$(printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
+ -e "s/$TAB/\\\t/g" -e's/$/\\/g')"
+ result="$result$tmp$CR}, \\$CR"
}
-dump_completion()
+make_completion()
{
- echo " {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\"
+ local CR='
+'
+ result=" {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\$CR"
}
template_loop()
{
+ local loop_result=
+
local t_name="$name_txt"
local t_perms="$perms_txt"
local t_desc="$desc_txt"
local t_source_files="$source_files"
local member
for member in $template_members; do
- local sed_cmd="sed -e s/@member@/$member/g"
- #echo "sed_cmd: $sed_cmd"
- name_txt=$(echo "$t_name" | $sed_cmd)
- #name_txt="$tname"
- perms_txt=$(echo "$t_perms" | $sed_cmd)
- desc_txt=$(echo "$t_desc" | $sed_cmd)
- usage_txt=$(echo "$t_usage" | $sed_cmd)
- help_txt=$(printf "%s\n" "$t_help" | $sed_cmd)
- prototype=$(echo "$template_prototype" | $sed_cmd)
+ name_txt="${t_name//@member@/$member}"
+ perms_txt="${t_perms//@member@/$member}"
+ desc_txt="${t_desc//@member@/$member}"
+ usage_txt="${t_usage//@member@/$member}"
+ help_txt="${t_help//@member@/$member}"
+ prototype="${template_prototype//@member@/$member}"
+ result=
$1
+ loop_result="$loop_result$result"
done
-
-}
-
-com_c_file()
-{
- echo "/** \file $output_file.c $c_file_comment */"
- echo "$system_includes"
- echo "$includes"
- echo "struct $array_type $array_name[] = {"
- while : ; do
- read_one_command
- if test $ret -lt 0; then
- exit 1
- fi
- if test $ret -eq 0; then
- break
- fi
- if test $template -eq 0; then
- dump_array_member
- continue
- fi
- template_loop dump_array_member
- done
- echo '{.name = NULL}};'
+ result="$loop_result"
+ # reset global variables
+ name_txt="$t_name"
+ perms_txt="$t_perms"
+ desc_txt="$t_desc"
+ usage_txt="$t_usage"
+ help_txt="$t_help"
+ source_files="$t_source_files"
}
com_header()
{
- echo "/** \file $output_file.h $header_comment */"
- echo
- echo "extern struct $array_type $array_name[];"
+ local array_members CR='
+'
+
while : ; do
read_one_command
if test $ret -lt 0; then
break
fi
if test $template -eq 0; then
- dump_proto
+ make_proto
+ printf "%s" "$result"
+ make_array_member
+ array_members="$array_members$result"
continue
fi
- template_loop dump_proto
+ template_loop make_proto
+ printf "%s" "$result"
+ template_loop make_array_member
+ array_members="$array_members$result"
done
+ array_members="$array_members{.name = NULL} \\$CR"
+ echo "#define DEFINE_$(tr 'a-z' 'A-Z' <<< "$base_name")_CMD_ARRAY $array_members"
}
com_completion()
break
fi
if test $template -eq 0; then
- dump_completion
+ make_completion
+ printf "%s" "$result"
continue
fi
- template_loop dump_completion
+ template_loop make_completion
+ printf "%s" "$result"
done
echo
}
arg="$1"
shift
case "$arg" in
- "c")
- com_c_file
- ;;
"h")
com_header
;;
dccp_recv recv_common write_common file_write audiod_command
client_common recv stdout filter stdin audioc write client
exec send_common ggo udp_recv color fec fecdec_filter
- prebuffer_filter audiod_command_list bitstream imdct
+ prebuffer_filter bitstream imdct
wma_afh wma_common wmadec_filter buffer_tree crypt_common
gui gui_theme sideband"
audiod_errlist_objs="audiod signal string daemon stat net crypt_common sideband
time grab_client filter_common wav_filter compress_filter amp_filter http_recv dccp_recv
recv_common fd sched write_common file_write audiod_command fecdec_filter
- client_common ggo udp_recv color fec prebuffer_filter audiod_command_list
+ client_common ggo udp_recv color fec prebuffer_filter
bitstream imdct wma_common wmadec_filter buffer_tree"
audiod_ldflags="-lm"
audiod_audio_formats="wma"
string signal time daemon http_send close_on_fork mm
crypt_common ipc dccp_send fd user_list chunk_queue
afs aft mood score attribute blob playlist sched acl
- send_common udp_send color fec server_command_list
- afs_command_list wma_afh wma_common sideband"
-
+ send_common udp_send color fec wma_afh wma_common sideband"
all_errlist_objs="$all_errlist_objs server vss command
http_send close_on_fork mm ipc dccp_send user_list
chunk_queue afs aft mood score attribute blob playlist
- acl udp_send server_command_list afs_command_list"
+ acl udp_send"
server_ldflags=""
server_audio_formats="mp3 wma"
#define COLOR_ERRORS
#define SIGNAL_ERRORS
#define FADE_ERRORS
-#define SERVER_COMMAND_LIST_ERRORS
-#define AFS_COMMAND_LIST_ERRORS
-#define AUDIOD_COMMAND_LIST_ERRORS
#define STDOUT_ERRORS
#define FILE_WRITE_ERRORS
#define STDIN_ERRORS
-OF: server_command_list
+BN: server
SF: command.c
-HC: prototypes for the server command handlers
-CC: array of server commands
-AT: server_command
-SI: osl regex
-IN: para error crypt sideband command string afh afs server list user_list
SN: list of server commands
---
N: ff