handle status items via autoconf.
authorAndre Noll <maan@systemlinux.org>
Sat, 10 Nov 2007 16:23:04 +0000 (17:23 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 10 Nov 2007 16:23:04 +0000 (17:23 +0100)
configure.ac
para.h
stat.c

index 0ecc297..06b7e52 100644 (file)
@@ -79,7 +79,6 @@ http_recv dccp_recv recv_common write_common file_write audiod_command
 client_common recv stdout filter stdin audioc write client fsck exec"
 all_executables="server audiod recv filter audioc write client fsck"
 
-
 recv_cmdline_objs="recv.cmdline http_recv.cmdline dccp_recv.cmdline"
 recv_errlist_objs="http_recv recv_common recv time string net dccp_recv
        dccp fd sched stdout"
@@ -493,6 +492,8 @@ AC_CONFIG_FILES([Makefile])
 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
 AC_DEFUN([objlist_to_errlist],[$(for i in $@; do printf "DEFINE_ERRLIST($(echo $i| tr 'a-z' 'A-Z'));"; done) [const char **para_errlist[[]]] = {$(for i in $@; do printf "PARA_ERRLIST($(echo $i | tr 'a-z' 'A-Z')), "; done) }])
 
+############################################################# error2.h
+
 AC_DEFUN([define_safe_error_enums],
 [
        exe=""
@@ -532,6 +533,7 @@ AC_DEFUN([define_safe_error_enums],
 ]
 )
 
+
 AC_MSG_NOTICE(creating error2.h)
 for obj in $all_errlist_objs; do
        SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
@@ -544,6 +546,37 @@ AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
        [list of all objects that use paraslash's error facility]
 )
 
+################################################################## status items
+
+status_items="basename status num_played mtime bitrate frequency file_size
+status_flags format score audio_file_info tag_info1 tag_info2 afs_mode
+attributes_txt decoder_flags audiod_status play_time attributes_bitmap
+offset seconds_total stream_start current_time audiod_uptime image_id
+lyrics_id duration directory"
+
+# $1: prefix, $2: items
+AC_DEFUN([make_enum_items], [$(
+       for i in $2; do
+               printf "$1_$(echo $i | tr 'a-z' 'A-Z'), "
+       done
+)])
+
+# $1: prefix, $2: items
+AC_DEFUN([make_enum_array], [$(
+       for i in $2; do
+               printf "\"$i\", "
+       done
+)])
+
+AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM,
+       make_enum_items(SI,  $status_items),
+       [enum of all status items]
+)
+AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY,
+       make_enum_array(SI,  $status_items),
+       [char * array of all status items]
+)
+
 
 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
diff --git a/para.h b/para.h
index 14a77cf..2c95f81 100644 (file)
--- a/para.h
+++ b/para.h
@@ -158,22 +158,8 @@ int tv_convex_combination(const long a, const struct timeval *tv1,
                struct timeval *result);
 void ms2tv(const long unsigned n, struct timeval *tv);
 
-/* stat */
-enum {
-       SI_BASENAME,            SI_STATUS,              SI_NUM_PLAYED,
-       SI_MTIME,               SI_BITRATE,             SI_FREQUENCY,
-       SI_FILE_SIZE,           SI_STATUS_FLAGS,        SI_FORMAT,
-       SI_SCORE,               SI_AUDIO_FILE_INFO,     SI_TAG_INFO1,
-       SI_TAG_INFO2,           SI_AFS_MODE,            SI_ATTRIBUTES_BITMAP,
-       SI_DIRECTORY,           SI_DECODER_FLAGS,       SI_AUDIOD_STATUS,
-       SI_PLAY_TIME,           SI_ATTRIBUTES_TXT,      SI_OFFSET,
-       SI_SECONDS_TOTAL,       SI_STREAM_START,        SI_CURRENT_TIME,
-       SI_AUDIOD_UPTIME,       SI_IMAGE_ID,            SI_LYRICS_ID,
-       SI_DURATION,
-       NUM_STAT_ITEMS
-};
-
-extern const char *status_item_list[NUM_STAT_ITEMS];
+enum status_items {STATUS_ITEM_ENUM NUM_STAT_ITEMS};
+extern const char *status_item_list[];
 
 int stat_item_valid(const char *item);
 int stat_line_valid(const char *);
diff --git a/stat.c b/stat.c
index 1ea2318..feb669b 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -44,45 +44,8 @@ static struct list_head client_list;
 static int initialized;
 static int num_clients;
 
-/** The list of all status items used by para_server/para_audiod. */
-const char *status_item_list[NUM_STAT_ITEMS] = {
-       [SI_BASENAME] = "basename",
-       [SI_STATUS] = "status",
-       [SI_NUM_PLAYED] = "num_played",
-
-       [SI_MTIME] = "mtime",
-       [SI_BITRATE] = "bitrate",
-       [SI_FREQUENCY] = "frequency",
-
-       [SI_FILE_SIZE] = "file_size",
-       [SI_STATUS_FLAGS] = "status_flags",
-       [SI_FORMAT] = "format",
-
-       [SI_SCORE] = "score",
-       [SI_AUDIO_FILE_INFO] = "audio_file_info",
-
-       [SI_TAG_INFO1] = "taginfo1",
-       [SI_TAG_INFO2] =  "taginfo2",
-       [SI_AFS_MODE] = "afs_mode",
-       [SI_ATTRIBUTES_TXT] = "attributes_txt",
-
-       [SI_DIRECTORY] = "dir",
-       [SI_DECODER_FLAGS] = "decoder_flags",
-       [SI_AUDIOD_STATUS] = "audiod_status",
-
-       [SI_PLAY_TIME] = "play_time",
-       [SI_ATTRIBUTES_BITMAP] = "attributes_bitmap",
-       [SI_OFFSET] = "offset",
-
-       [SI_SECONDS_TOTAL] = "seconds_total",
-       [SI_STREAM_START] = "stream_start",
-       [SI_CURRENT_TIME] = "current_time",
-
-       [SI_AUDIOD_UPTIME] = "audiod_uptime",
-       [SI_IMAGE_ID] = "image_id",
-       [SI_LYRICS_ID] = "lyrics_id",
-       [SI_DURATION] = "duration"
-};
+/** The list of all status items used by para_{server,audiod,gui}. */
+const char *status_item_list[] = {STATUS_ITEM_ARRAY};
 
 static void dump_stat_client_list(void)
 {