From a775408e5d2e3b21dff741b89ff5330b397b5138 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 28 Aug 2016 18:46:22 +0200 Subject: [PATCH] Simplify the error subsystem, get rid of error2.[ch]. This commit removes error2.c and the surrounding infrastructure of the build system, getting rid of ~600 LOC. After the change there are no more subsystems for error codes, and we don't need to host-compile error2.c any more. Since all executables now contain the text of every error code, the change has some impact on the sizes of the (stripped) executables: Before: After: 64K para_afh 71K para_afh 43K para_audioc 47K para_audioc 256K para_audiod 259K para_audiod 64K para_client 71K para_client 39K para_fade 47K para_fade 141K para_filter 144K para_filter 51K para_gui 59K para_gui 252K para_play 255K para_play 97K para_recv 104K para_recv 227K para_server 230K para_server 60K para_write 67K para_write This increase in size is justified by the major simplification. --- .gitignore | 1 - Doxyfile | 2 +- Makefile.in | 1 - Makefile.real | 16 +-- afh.c | 4 +- audioc.c | 3 +- audiod.c | 5 +- client.c | 3 +- configure.ac | 84 ------------- error.h | 337 +++----------------------------------------------- error2.c | 169 ------------------------- fade.c | 4 +- filter.c | 6 +- gui.c | 5 +- play.c | 6 +- recv.c | 6 +- server.c | 8 +- write.c | 3 +- 18 files changed, 49 insertions(+), 614 deletions(-) delete mode 100644 error2.c diff --git a/.gitignore b/.gitignore index 2889d20d..10a7a8a9 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ web/dia/overview.pdf *.swp *.rej *~ -error2.h web_sync confdefs.h conftest diff --git a/Doxyfile b/Doxyfile index 50c74695..f6476603 100644 --- a/Doxyfile +++ b/Doxyfile @@ -779,7 +779,7 @@ RECURSIVE = NO # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = error2.h +EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/Makefile.in b/Makefile.in index 94b64827..ec55c8e3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -14,7 +14,6 @@ GENGETOPT := @GENGETOPT@ HELP2MAN := @HELP2MAN@ ggo_descriptions_declared := @ggo_descriptions_declared@ -object_executable_matrix := @object_executable_matrix@ executables := @executables@ receivers := @receivers@ diff --git a/Makefile.real b/Makefile.real index ce4881d2..980192ec 100644 --- a/Makefile.real +++ b/Makefile.real @@ -10,7 +10,6 @@ endif vardir := /var/paraslash mandir := $(datarootdir)/man/man1 STRIP := $(CROSS_COMPILE)strip -HOSTCC ?= cc MKDIR_P := mkdir -p prefixed_executables := $(addprefix para_, $(executables)) @@ -34,7 +33,6 @@ cmdline_dir := $(build_dir)/cmdline cmdlist_dir := $(build_dir)/cmdlist m4depdir := $(build_dir)/m4deps help2man_dir := $(build_dir)/help2man -hostbin_dir := $(build_dir)/host/bin m4_ggo_dir := m4/gengetopt test_dir := t @@ -78,7 +76,7 @@ ifeq ($(findstring clean, $(MAKECMDGOALS)),) endif $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \ - $(help2man_dir) $(hostbin_dir) $(cmdlist_dir): + $(help2man_dir) $(cmdlist_dir): $(Q) $(MKDIR_P) $@ # When in doubt, use brute force (Ken Thompson) @@ -95,7 +93,6 @@ CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"' CPPFLAGS += -DBUILD_DATE='"$(build_date)"' CPPFLAGS += -DUNAME_RS='"$(uname_rs)"' CPPFLAGS += -DCC_VERSION='"$(cc_version)"' -CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F) CPPFLAGS += -I/usr/local/include CPPFLAGS += -I$(cmdline_dir) CPPFLAGS += -I$(cmdlist_dir) @@ -190,13 +187,6 @@ $(man_dir)/para_%.1: $(ggo_dir)/%.ggo man_util.bash \ WRITERS="$(writers)" \ ./man_util.bash $@ -$(hostbin_dir)/error2: error2.c | $(hostbin_dir) - @[ -z "$(Q)" ] || echo 'HCC $<' - $(Q) $(HOSTCC) -o $@ $< -error2.h: $(hostbin_dir)/error2 config.h - @[ -z "$(Q)" ] || echo 'ER2 $<' - @echo "$(object_executable_matrix)" | $< > $@ - $(object_dir)/%.o: %.c | $(object_dir) $(object_dir)/opus%.o $(dep_dir)/opus%.d: CPPFLAGS += $(opus_cppflags) @@ -276,7 +266,7 @@ $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h # The compiler outputs dependencies either as foo.h or as some_directory/foo.h, # depending on whether the latter file exists. Since make needs the directory # part we prefix the dependency as appropriate. -$(dep_dir)/%.d: %.c error2.h | $(dep_dir) +$(dep_dir)/%.d: %.c | $(dep_dir) @[ -z "$(Q)" ] || echo 'DEP $<' $(Q) $(CC) $(CPPFLAGS) -MM -MG -MP -MT $@ -MT $(object_dir)/$(*F).o $< \ | sed -e "s@ \([a-zA-Z0-9_]\{1,\}\.cmdline.h\)@ $(cmdline_dir)/\1@g" \ @@ -350,7 +340,7 @@ clean2: clean $(Q) rm -rf $(build_dir) distclean: clean2 test-clean @[ -z "$(Q)" ] || echo 'DISTCLEAN' - $(Q) rm -f Makefile autoscan.log config.status config.log error2.h + $(Q) rm -f Makefile autoscan.log config.status config.log $(Q) rm -f GPATH GRTAGS GSYMS GTAGS maintainer-clean: distclean diff --git a/afh.c b/afh.c index 8975777b..36c432e5 100644 --- a/afh.c +++ b/afh.c @@ -17,8 +17,10 @@ #include "version.h" #include "ggo.h" +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; + static struct afh_args_info conf; -INIT_AFH_ERRLISTS; static int loglevel; INIT_STDERR_LOGGING(loglevel) diff --git a/audioc.c b/audioc.c index 337c8062..f8fd80fa 100644 --- a/audioc.c +++ b/audioc.c @@ -24,7 +24,8 @@ #include "ggo.h" #include "version.h" -INIT_AUDIOC_ERRLISTS; +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; /** The gengetopt structure containing command line args. */ static struct audioc_args_info conf; diff --git a/audiod.c b/audiod.c index 285d2762..0f082e26 100644 --- a/audiod.c +++ b/audiod.c @@ -39,9 +39,10 @@ #include "signal.h" #include "version.h" +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; + __printf_2_3 void (*para_log)(int, const char*, ...) = daemon_log; -/** define the array of error lists needed by para_audiod */ -INIT_AUDIOD_ERRLISTS; /** define the array containing all supported audio formats */ const char *audio_formats[] = {AUDIOD_AUDIO_FORMAT_ARRAY NULL}; diff --git a/client.c b/client.c index 31cfff09..d70bdb93 100644 --- a/client.c +++ b/client.c @@ -22,7 +22,8 @@ #include "error.h" #include "version.h" -INIT_CLIENT_ERRLISTS; +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; static struct sched sched; static struct client_task *ct; diff --git a/configure.ac b/configure.ac index 8d4ce59a..ffb06934 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,3 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - AC_PREREQ([2.61]) AC_INIT([paraslash], [m4_esyscmd_s(./GIT-VERSION-GEN)], @@ -10,20 +7,6 @@ AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile]) AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)]) AC_DEFUN([add_cmdline],[$(for i in $@; do printf "${i}.cmdline "; done)]) -AC_DEFUN([make_errlist_defines], \ - $(for i in $@; do \ - printf "DEFINE_ERRLIST($(echo $i | tr 'a-z' 'A-Z'));"; \ - done) \ -) -AC_DEFUN([make_para_errlists], \ - $(for i in $@; do \ - printf "PARA_ERRLIST($(echo $i | tr 'a-z' 'A-Z')), "; \ - done) \ -) -AC_DEFUN([objlist_to_errlist],[ \ - make_errlist_defines($@) \ - [const char **para_errlist[[]]] = {make_para_errlists($@)} \ -]) AC_DEFUN([LIB_ARG_WITH], [ AC_ARG_WITH($1-headers, [AS_HELP_STRING(--with-$1-headers=dir, [look for $1 headers in dir])]) @@ -458,8 +441,6 @@ if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes; then fi server_objs="add_cmdline($server_cmdline_objs) $server_errlist_objs" AC_SUBST(server_objs, add_dot_o($server_objs)) - AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS, - objlist_to_errlist($server_errlist_objs), errors used by para_server) else build_server="no" fi @@ -495,8 +476,6 @@ if test -n "$CRYPTOLIB"; then fi client_objs="add_cmdline($client_cmdline_objs) $client_errlist_objs" AC_SUBST(client_objs, add_dot_o($client_objs)) - AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS, - objlist_to_errlist($client_errlist_objs), errors used by para_client) else build_client="no" fi @@ -608,8 +587,6 @@ if test -n "$CRYPTOLIB"; then fi audiod_objs="add_cmdline($audiod_cmdline_objs) $audiod_errlist_objs" AC_SUBST(audiod_objs, add_dot_o($audiod_objs)) - AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs), - errors used by para_audiod) enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)" AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS, @@ -637,9 +614,6 @@ if test $HAVE_OSS = yes -o $HAVE_ALSA = yes; then fi fade_objs="add_cmdline($fade_cmdline_objs) $fade_errlist_objs" AC_SUBST(fade_objs, add_dot_o($fade_objs)) - AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS, - objlist_to_errlist($fade_errlist_objs), - errors used by para_fade) enum="$( for i in $mixers; do printf "${i}_MIX, " | tr '[a-z]' '[A-Z]' @@ -685,8 +659,6 @@ if test $HAVE_CURSES = yes; then " gui_objs="add_cmdline($gui_cmdline_objs) $gui_errlist_objs" AC_SUBST(gui_objs, add_dot_o($gui_objs)) - AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS, - objlist_to_errlist($gui_errlist_objs), errors used by para_gui) else build_gui="no" AC_MSG_WARN([no curses lib, cannot build para_gui]) @@ -768,8 +740,6 @@ AC_SUBST(filters) filter_objs="add_cmdline($filter_cmdline_objs) $filter_errlist_objs" AC_SUBST(filter_objs, add_dot_o($filter_objs)) -AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS, - objlist_to_errlist($filter_errlist_objs), errors used by para_filter) enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)" AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS, @@ -820,8 +790,6 @@ fi recv_objs="add_cmdline($recv_cmdline_objs) $recv_errlist_objs" AC_SUBST(receivers, "http dccp udp afh") AC_SUBST(recv_objs, add_dot_o($recv_objs)) -AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs), - errors used by para_recv) ########################################################################### afh audio_format_handlers="mp3 wma" afh_cmdline_objs="afh" @@ -862,8 +830,6 @@ fi afh_objs="add_cmdline($afh_cmdline_objs) $afh_errlist_objs" AC_SUBST(afh_objs, add_dot_o($afh_objs)) -AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS, - objlist_to_errlist($afh_errlist_objs), errors used by para_afh) ########################################################################## play play_errlist_objs=" play @@ -965,8 +931,6 @@ fi play_objs="add_cmdline($play_cmdline_objs) $play_errlist_objs" AC_SUBST(play_objs, add_dot_o($play_objs)) -AC_DEFINE_UNQUOTED(INIT_PLAY_ERRLISTS, - objlist_to_errlist($play_errlist_objs), errors used by para_play) ######################################################################### write write_cmdline_objs=" write @@ -1016,8 +980,6 @@ fi AC_SUBST(writers) write_objs="add_cmdline($write_cmdline_objs) $write_errlist_objs" AC_SUBST(write_objs, add_dot_o($write_objs)) -AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS, - objlist_to_errlist($write_errlist_objs), errors used by para_write) enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)" AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS, enum of supported writers) @@ -1048,52 +1010,6 @@ if test $HAVE_READLINE = yes; then fi audioc_objs="add_cmdline($audioc_cmdline_objs) $audioc_errlist_objs" AC_SUBST(audioc_objs, add_dot_o($audioc_objs)) -AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS, - objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc) -############################################################# error2.h -# these are always built -all_errlist_objs=" - $recv_errlist_objs - $filter_errlist_objs - $audioc_errlist_objs - $write_errlist_objs - $afh_errlist_objs - $play_errlist_objs -" - -# optional executables -if test "$build_server" = "yes"; then - all_errlist_objs="$all_errlist_objs $server_errlist_objs" -fi -if test "$build_gui" = "yes"; then - all_errlist_objs="$all_errlist_objs $gui_errlist_objs" -fi -if test "$build_fade" = "yes"; then - all_errlist_objs="$all_errlist_objs $fade_errlist_objs" -fi -if test "$build_client" = "yes"; then - all_errlist_objs="$all_errlist_objs $client_errlist_objs" -fi -if test "$build_audiod" = "yes"; then - all_errlist_objs="$all_errlist_objs $audiod_errlist_objs" -fi - -all_errlist_objs="$(echo $all_errlist_objs | tr ' ' '\n' | sort | uniq)" - -object_executable_matrix= -for i in $executables; do - eval objs=\$${i}_errlist_objs - object_executable_matrix="$object_executable_matrix $i: $objs" -done -# use echo to replace newlines by space -AC_SUBST(object_executable_matrix, $(echo $object_executable_matrix)) - -SS=$(for obj in $all_errlist_objs; do - printf '%s' " SS_$obj,"; done | tr 'a-z' 'A-Z') -AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM, - [enum {$SS NUM_SS}], - [list of all objects that use the paraslash error facility] -) ################################################################## status items status_items="basename status num_played mtime bitrate frequency file_size diff --git a/error.h b/error.h index ff85c8d1..6c8e434d 100644 --- a/error.h +++ b/error.h @@ -4,91 +4,33 @@ * Licensed under the GPL v2. For licencing details see COPYING. */ -/** \file error.h List of error messages for all subsystems. */ +/** \file error.h List of error codes and messages. */ -/** \cond errors */ - -/* List of all subsystems that use paraslash's error facility. */ -DEFINE_ERRLIST_OBJECT_ENUM; - -/* these do not need error handling (yet) */ -#define SERVER_ERRORS -#define TIME_ERRORS -#define CLOSE_ON_FORK_ERRORS -#define DAEMON_ERRORS -#define GUI_THEME_ERRORS -#define RINGBUFFER_ERRORS -#define SCORE_ERRORS -#define RECV_ERRORS -#define IPC_ERRORS -#define DCCP_SEND_ERRORS -#define HTTP_SEND_ERRORS -#define GGO_ERRORS -#define COLOR_ERRORS -#define SIGNAL_ERRORS -#define OSS_MIX_ERRORS -#define STDOUT_ERRORS -#define FILE_WRITE_ERRORS -#define STDIN_ERRORS -#define WRITE_ERRORS -#define CHECK_WAV_ERRORS -#define VERSION_ERRORS -#define SCHED_ERRORS - - -extern const char **para_errlist[]; - -#define SYNC_FILTER_ERRORS\ +/** Codes and messages. */ +#define PARA_ERRORS \ PARA_ERROR(SYNC_COMPLETE, "all buddies in sync"), \ PARA_ERROR(SYNC_LISTEN_FD, "no fd to listen on"), \ - -#define ALSA_MIX_ERRORS \ PARA_ERROR(ALSA_MIX_OPEN, "could not open mixer"), \ PARA_ERROR(ALSA_MIX_GET_VAL, "could not read control element state"), \ PARA_ERROR(ALSA_MIX_SET_VAL, "could not set control element state"), \ PARA_ERROR(ALSA_MIX_RANGE, "value control element out of range"), \ - - -#define RESAMPLE_FILTER_ERRORS \ PARA_ERROR(RESAMPLE_EOF, "resample filter: end of file"), \ PARA_ERROR(LIBSAMPLERATE, "secret rabbit code error"), \ - - -#define OPUS_COMMON_ERRORS \ PARA_ERROR(OPUS_HEADER, "invalid opus header"), \ - - -#define OPUS_AFH_ERRORS \ PARA_ERROR(OPUS_COMMENT, "invalid or corrupted opus comment"), \ - - -#define OPUSDEC_FILTER_ERRORS \ PARA_ERROR(CREATE_OPUS_DECODER, "could not create opus decoder"), \ PARA_ERROR(OPUS_SET_GAIN, "opus: could not set gain"), \ PARA_ERROR(OPUS_DECODE, "opus decode error"), \ - -#define SIDEBAND_ERRORS \ PARA_ERROR(BAD_BAND, "invalid or unexpected band designator"), \ PARA_ERROR(SB_PACKET_SIZE, "invalid sideband packet size or protocol error"), \ - - -#define PLAY_ERRORS \ PARA_ERROR(PLAY_SYNTAX, "para_play: syntax error"), \ PARA_ERROR(NO_VALID_FILES, "no valid file found in playlist"), \ PARA_ERROR(BAD_PLAY_CMD, "invalid command"), \ - -#define FADE_ERRORS \ PARA_ERROR(BAD_CHANNEL, "invalid channel"), \ - -#define FLACDEC_FILTER_ERRORS \ PARA_ERROR(FLACDEC_DECODER_ALLOC, "could not allocate stream decoder"), \ PARA_ERROR(FLACDEC_DECODER_INIT, "could not init stream decoder"), \ PARA_ERROR(FLACDEC_EOF, "flacdec encountered end of file condition"), \ - -#define GUI_ERRORS \ PARA_ERROR(GUI_SIGCHLD, "received SIGCHLD"), \ - -#define FLAC_AFH_ERRORS \ PARA_ERROR(FLAC_CHAIN_ALLOC, "could not create metadata chain"), \ PARA_ERROR(FLAC_CHAIN_READ, "could not read meta chain"), \ PARA_ERROR(FLAC_ITER_ALLOC, "could not allocate meta iterator"), \ @@ -100,13 +42,7 @@ extern const char **para_errlist[]; PARA_ERROR(FLAC_STREAMINFO, "could not read stream info meta block"), \ PARA_ERROR(FLAC_REPLACE_COMMENT, "could not replace vorbis comment"), \ PARA_ERROR(FLAC_WRITE_CHAIN, "failed to write metadata chain"), \ - - -#define AFH_RECV_ERRORS \ PARA_ERROR(AFH_RECV_BAD_FILENAME, "no file name given"), \ - - -#define OGG_AFH_COMMON_ERRORS \ PARA_ERROR(STREAM_PACKETOUT, "ogg stream packet-out error"), \ PARA_ERROR(STREAM_PACKETIN, "ogg stream packet-in error"), \ PARA_ERROR(SYNC_PAGEOUT, "ogg sync page-out error (no ogg file?)"), \ @@ -114,67 +50,33 @@ extern const char **para_errlist[]; PARA_ERROR(STREAM_PAGEOUT, "ogg stream page-out error"), \ PARA_ERROR(OGG_SYNC, "internal ogg storage overflow"), \ PARA_ERROR(OGG_EMPTY, "no ogg pages found"), \ - - -#define SPX_AFH_ERRORS \ PARA_ERROR(SPX_COMMENT, "invalid speex comment"), \ - - -#define SPX_COMMON_ERRORS \ PARA_ERROR(SPX_HEADER, "can not read speex header"), \ PARA_ERROR(SPX_HEADER_MODE, "invalid speex mode in header"), \ PARA_ERROR(SPX_VERSION, "incompatible speex bit stream version"), \ PARA_ERROR(SPX_DECODER_INIT, "speex decoder initialization failed"), \ PARA_ERROR(SPX_CTL_BAD_RQ, "speex_decoder_ctl: invalid request"), \ PARA_ERROR(SPX_CTL_INVAL, "speex_decoder_ctl: invalid argument"), \ - -#define SPXDEC_FILTER_ERRORS \ PARA_ERROR(SPX_DECODE, "speex decoding error"), \ PARA_ERROR(SPX_DECODE_OVERFLOW, "speex decoding overflow"), \ PARA_ERROR(SPX_EOS, "speex: end of stream"), \ - -#define BUFFER_TREE_ERRORS \ PARA_ERROR(BTR_EOF, "buffer tree: end of file"), \ PARA_ERROR(BTR_NO_CHILD, "btr node has no children"), \ PARA_ERROR(BTR_NAVAIL, "btr node: value currently unavailable"), \ - - -#define BITSTREAM_ERRORS \ PARA_ERROR(VLC, "invalid vlc code"), \ - - -#define WMA_AFH_ERRORS \ PARA_ERROR(NO_WMA, "asf/wma format not recognized"), \ - - -#define WMA_COMMON_ERRORS \ PARA_ERROR(WMA_NO_GUID, "audio stream guid not found"), \ - - -#define WMADEC_FILTER_ERRORS \ PARA_ERROR(WMA_BAD_PARAMS, "invalid WMA parameters"), \ PARA_ERROR(WMA_OUTPUT_SPACE, "insufficient output space"), \ PARA_ERROR(WMA_BAD_SUPERFRAME, "invalid superframe"), \ PARA_ERROR(WMA_BLOCK_SIZE, "invalid block size"), \ PARA_ERROR(INCOHERENT_BLOCK_LEN, "incoherent block length"), \ PARA_ERROR(WMADEC_EOF, "wmadec: end of file"), \ - - -#define IMDCT_ERRORS \ PARA_ERROR(FFT_BAD_PARAMS, "invalid params for fft"), \ - - -#define PREBUFFER_FILTER_ERRORS \ PARA_ERROR(PREBUFFER_SUCCESS, "prebuffering complete"), \ - - -#define OSS_WRITE_ERRORS \ PARA_ERROR(BAD_SAMPLE_FORMAT, "sample format not supported"), \ PARA_ERROR(BAD_CHANNEL_COUNT, "channel count not supported"), \ PARA_ERROR(BAD_SAMPLERATE, "sample rate not supported"), \ - - -#define AO_WRITE_ERRORS \ PARA_ERROR(AO_DEFAULT_DRIVER, "ao: no usable output device"), \ PARA_ERROR(AO_BAD_DRIVER, "ao: invalid driver"), \ PARA_ERROR(AO_BAD_OPTION, "ao option is not of type key:value"), \ @@ -185,91 +87,40 @@ extern const char **para_errlist[]; PARA_ERROR(AO_BAD_SAMPLE_FORMAT, "ao: unsigned sample formats not supported"), \ PARA_ERROR(AO_PTHREAD, "pthread error"), \ PARA_ERROR(AO_EOF, "ao: end of file"), \ - - -#define COMPRESS_FILTER_ERRORS \ PARA_ERROR(COMPRESS_EOF, "compress: end of file"), \ - - -#define WAV_FILTER_ERRORS \ PARA_ERROR(WAV_BAD_FC, "invalid filter configuration"), \ PARA_ERROR(WAV_EOF, "wav filter: end of file"), \ PARA_ERROR(WAV_SUCCESS, "successfully wrote wav header"), \ - - -#define FEC_ERRORS \ PARA_ERROR(FEC_BAD_IDX, "invalid index vector"), \ PARA_ERROR(FEC_SINGULAR, "unexpected singular matrix"), \ PARA_ERROR(FEC_PIVOT, "pivot column not found"), \ PARA_ERROR(FEC_PARMS, "invalid fec parameters"), \ - - -#define FECDEC_FILTER_ERRORS \ PARA_ERROR(BAD_FEC_HEADER, "invalid fec header"), \ PARA_ERROR(BAD_SLICE_SIZE, "slice size zero or too large"), \ PARA_ERROR(BAD_SLICE_NUM, "invalid slice number"), \ PARA_ERROR(FECDEC_OVERRUN, "fecdec output buffer overrun"), \ PARA_ERROR(FECDEC_EOF, "received eof packet"), \ - - -#define AMP_FILTER_ERRORS \ PARA_ERROR(AMP_ZERO_AMP, "no amplification necessary"), \ PARA_ERROR(AMP_EOF, "amp: end of file"), \ - - -#define SEND_COMMON_ERRORS \ PARA_ERROR(MAX_CLIENTS, "maximal number of clients exceeded"), \ - - -#define CLIENT_ERRORS \ PARA_ERROR(TASK_STARTED, "task started"), \ - - -#define AFH_ERRORS \ PARA_ERROR(AFH_SYNTAX, "afh syntax error"), \ - - -#define AFH_COMMON_ERRORS \ PARA_ERROR(AUDIO_FORMAT, "audio format not recognized"), \ - - -#define ACL_ERRORS \ PARA_ERROR(ACL_PERM, "access denied by acl"), \ - - -#define AFS_ERRORS \ PARA_ERROR(BAD_TABLE_NAME, "invalid table"), \ PARA_ERROR(AFS_SYNTAX, "afs syntax error"), \ PARA_ERROR(AFS_SIGNAL, "afs caught deadly signal"), \ PARA_ERROR(AFS_SOCKET, "afs socket not writable"), \ - - -#define MOOD_ERRORS \ PARA_ERROR(NO_MOOD, "no mood available"), \ - - -#define MM_ERRORS \ PARA_ERROR(MOOD_SYNTAX, "mood syntax error"), \ - - -#define ATTRIBUTE_ERRORS \ PARA_ERROR(ATTR_SYNTAX, "attribute syntax error"), \ PARA_ERROR(NO_ATTRIBUTES, "no attributes defined yet"), \ PARA_ERROR(ATT_TABLE_FULL, "no more space left in attribute table"), \ - - -#define BLOB_ERRORS \ PARA_ERROR(BLOB_SYNTAX, "blob syntax error"), \ PARA_ERROR(DUMMY_ROW, "attempted to access blob dummy object"), \ - - -#define PLAYLIST_ERRORS \ PARA_ERROR(PLAYLIST_LOADED, ""), /* not really an error */ \ PARA_ERROR(PATH_FOUND, ""), /* not really an error */ \ PARA_ERROR(PLAYLIST_EMPTY, "attempted to load empty playlist"), \ - - -#define AFT_ERRORS \ PARA_ERROR(BAD_AFSI, "invalid afs info"), \ PARA_ERROR(LOCALTIME, "localtime() failed"), \ PARA_ERROR(STRFTIME, "strftime() failed"), \ @@ -280,35 +131,20 @@ extern const char **para_errlist[]; PARA_ERROR(AFT_SYNTAX, "audio file table syntax error"), \ PARA_ERROR(HASH_MISMATCH, "hash mismatch, consider re-add"), \ PARA_ERROR(NO_MATCH, "no matches"), \ - - -#define USER_LIST_ERRORS \ PARA_ERROR(USERLIST, "failed to open user list file"), \ - - -#define OSX_WRITE_ERRORS \ PARA_ERROR(STREAM_FORMAT, "could not set stream format"), \ PARA_ERROR(ADD_CALLBACK, "can not add callback"), \ PARA_ERROR(OPEN_COMP, "OpenAComponent() error"), \ PARA_ERROR(UNIT_INIT, "AudioUnitInitialize() error"), \ PARA_ERROR(UNIT_START, "AudioUnitStart() error"), \ PARA_ERROR(DEFAULT_COMP, "can not find default audio output component"), \ - - -#define AUDIOC_ERRORS \ PARA_ERROR(AUDIOC_EOF, "audioc: end of file"), \ - - -#define CLIENT_COMMON_ERRORS \ PARA_ERROR(CLIENT_SYNTAX, "syntax error"), \ PARA_ERROR(NO_CONFIG, "config file not found"), \ PARA_ERROR(BAD_CONFIG, "syntax error in config file"), \ PARA_ERROR(SERVER_EOF, "connection closed by para_server"), \ PARA_ERROR(SERVER_CMD_SUCCESS, "command terminated successfully"), \ PARA_ERROR(SERVER_CMD_FAILURE, "command failed"), \ - - -#define NET_ERRORS \ PARA_ERROR(NAME_TOO_LONG, "name too long for struct sockaddr_un"), \ PARA_ERROR(ADDRESS_LOOKUP, "can not resolve requested address"),\ PARA_ERROR(CHMOD, "failed to set socket mode"), \ @@ -316,27 +152,12 @@ extern const char **para_errlist[]; PARA_ERROR(RECVMSG, "recvmsg() failed"), \ PARA_ERROR(SCM_CREDENTIALS, "did not receive SCM credentials"), \ PARA_ERROR(MAKESOCK, "makesock error"), \ - - -#define UDP_RECV_ERRORS \ PARA_ERROR(UDP_OVERRUN, "output buffer overrun"), \ - - -#define UDP_SEND_ERRORS \ PARA_ERROR(TARGET_EXISTS, "requested target is already present"),\ - PARA_ERROR(TARGET_NOT_FOUND, "requested target not found") - - -#define HTTP_RECV_ERRORS \ + PARA_ERROR(TARGET_NOT_FOUND, "requested target not found"), \ PARA_ERROR(HTTP_RECV_OVERRUN, "http_recv: output buffer overrun"), \ - - -#define RECV_COMMON_ERRORS \ PARA_ERROR(RECV_SYNTAX, "recv syntax error"), \ PARA_ERROR(RECV_EOF, "end of file"), \ - - -#define AUDIOD_ERRORS \ PARA_ERROR(NO_MORE_SLOTS, "no more empty slots"), \ PARA_ERROR(MISSING_COLON, "syntax error: missing colon"), \ PARA_ERROR(UNSUPPORTED_AUDIO_FORMAT, "given audio format not supported"), \ @@ -345,50 +166,26 @@ extern const char **para_errlist[]; PARA_ERROR(STATUS_TIMEOUT, "status item timeout"), \ PARA_ERROR(AUDIOD_SIGNAL, "caught deadly signal"), \ PARA_ERROR(AUDIOD_TERM, "terminating on user request"), \ - - -#define AUDIOD_COMMAND_ERRORS \ PARA_ERROR(CLIENT_WRITE, "client write error"), \ PARA_ERROR(UCRED_PERM, "permission denied"), \ PARA_ERROR(INVALID_AUDIOD_CMD, "invalid command"), \ PARA_ERROR(TOO_MANY_CLIENTS, "maximal number of stat clients exceeded"), \ PARA_ERROR(UNKNOWN_STAT_ITEM, "status item not recognized"), \ - - -#define FILTER_COMMON_ERRORS \ PARA_ERROR(BAD_FILTER_OPTIONS, "invalid filter option given"), \ PARA_ERROR(UNSUPPORTED_FILTER, "given filter not supported"), \ - - -#define STAT_ERRORS \ PARA_ERROR(STAT_ITEM_PARSE, "failed to parse status item"), \ - - -#define OGGDEC_FILTER_ERRORS \ PARA_ERROR(OGGDEC_READ, "read from media returned an error"), \ PARA_ERROR(OGGDEC_NOTVORBIS, "bitstream is not vorbis data"), \ PARA_ERROR(OGGDEC_VERSION, "vorbis version mismatch"), \ PARA_ERROR(OGGDEC_BADHEADER, "invalid vorbis bitstream header"), \ PARA_ERROR(OGGDEC_FAULT, "bug or heap/stack corruption"), \ PARA_ERROR(OGGDEC_BADLINK, "invalid stream section or requested link corrupt"), \ - - -#define GRAB_CLIENT_ERRORS \ PARA_ERROR(GC_WRITE, "grab client write error"), \ PARA_ERROR(GC_SYNTAX, "grab client syntax error"), \ - - -#define MP3DEC_FILTER_ERRORS \ PARA_ERROR(MAD_FRAME_DECODE, "mad frame decode error"), \ PARA_ERROR(MP3DEC_EOF, "mp3dec: end of file"), \ PARA_ERROR(MP3DEC_CORRUPT, "too many corrupt frames"), \ - - -#define FILTER_ERRORS \ PARA_ERROR(NO_FILTERS, "at least one filter must be given"), \ - - -#define STRING_ERRORS \ PARA_ERROR(ATOI_OVERFLOW, "value too large"), \ PARA_ERROR(ATOI_NO_DIGITS, "no digits found in string"), \ PARA_ERROR(ATOI_JUNK_AT_END, "further characters after number"), \ @@ -396,13 +193,7 @@ extern const char **para_errlist[]; PARA_ERROR(REGEX, "regular expression error"), \ PARA_ERROR(ARG_NOT_FOUND, "argument not found in arg vector"), \ PARA_ERROR(BAD_LL, "invalid loglevel"), \ - - -#define EXEC_ERRORS \ PARA_ERROR(DUP_PIPE, "exec error: can not create pipe"), \ - - -#define MP3_AFH_ERRORS \ PARA_ERROR(FRAME, "invalid mp3 frame"), \ PARA_ERROR(FRAME_LENGTH, "invalid frame length"), \ PARA_ERROR(MP3_INFO, "could not read mp3 info"), \ @@ -412,39 +203,22 @@ extern const char **para_errlist[]; PARA_ERROR(ID3_ATTACH, "could not attach id3 frame"), \ PARA_ERROR(ID3_SETENCODING, "could not set id3 text encoding field"), \ PARA_ERROR(ID3_SETSTRING, "could not set id3 string field"), \ - -#define AAC_AFH_ERRORS \ PARA_ERROR(STSZ, "did not find stcz atom"), \ PARA_ERROR(MP4ASC, "audio spec config error"), \ PARA_ERROR(AAC_AFH_INIT, "failed to init aac decoder"), \ PARA_ERROR(MP4V2, "mp4v2 library error"), \ - -#define AAC_COMMON_ERRORS \ PARA_ERROR(ESDS, "did not find esds atom"), \ PARA_ERROR(STCO, "did not find stco atom"), \ - - -#define OGG_AFH_ERRORS \ PARA_ERROR(VORBIS, "vorbis synthesis header-in error (not vorbis?)"), \ PARA_ERROR(VORBIS_COMMENTHEADER, "could not create vorbis comment header"), \ PARA_ERROR(OGG_PACKET_IN, "ogg_stream_packetin() failed"), \ PARA_ERROR(OGG_STREAM_FLUSH, "ogg_stream_flush() failed"), \ - - -#define VSS_ERRORS \ PARA_ERROR(NOFD, "did not receive open fd from afs"), \ PARA_ERROR(BAD_CT, "invalid chunk table or bad FEC configuration"), \ PARA_ERROR(AFS_SHORT_READ, "short read from afs socket"), \ - - -#define CRYPT_COMMON_ERRORS \ PARA_ERROR(SSH_KEY_HEADER, "ssh key header not found"), \ PARA_ERROR(KEY_PERM, "unprotected private key"), \ - -#define BASE64_ERRORS \ PARA_ERROR(BASE64, "base64 decode error"), \ - -#define CRYPT_ERRORS \ PARA_ERROR(PRIVATE_KEY, "can not read private key"), \ PARA_ERROR(PUBLIC_KEY, "can not read public key"), \ PARA_ERROR(RSA, "RSA error"), \ @@ -452,8 +226,6 @@ extern const char **para_errlist[]; PARA_ERROR(DECRYPT, "decrypt error"), \ PARA_ERROR(BLINDING, "failed to activate key blinding"), \ PARA_ERROR(BIGNUM, "bignum error"), \ - -#define GCRYPT_ERRORS \ PARA_ERROR(MPI_SCAN, "could not scan multi-precision integer"), \ PARA_ERROR(MPI_PRINT, "could not convert multi-precision integer"), \ PARA_ERROR(SEXP_FIND, "could not find sublist in S-expression"), \ @@ -465,9 +237,6 @@ extern const char **para_errlist[]; PARA_ERROR(ASN1_PARSE, "could not parse ASN.1 key"), \ PARA_ERROR(SSH_PARSE, "could not parse ssh public key"), \ PARA_ERROR(OEAP, "error during oeap (un)padding"), \ - - -#define COMMAND_ERRORS \ PARA_ERROR(COMMAND_SYNTAX, "syntax error in command"), \ PARA_ERROR(AUTH_REQUEST, "did not receive auth request"), \ PARA_ERROR(NO_AUDIO_FILE, "no audio file"), \ @@ -479,81 +248,32 @@ extern const char **para_errlist[]; PARA_ERROR(BAD_USER, "auth request for invalid user"), \ PARA_ERROR(BAD_FEATURE, "invalid feature request"), \ PARA_ERROR(BAD_AUTH, "authentication failure"), \ - - -#define DCCP_RECV_ERRORS \ PARA_ERROR(DCCP_OVERRUN, "dccp output buffer buffer overrun"), \ - - -#define FD_ERRORS \ PARA_ERROR(FGETS, "fgets error"), \ PARA_ERROR(EOF, "end of file"), \ PARA_ERROR(READ_PATTERN, "did not read expected pattern"), \ PARA_ERROR(SHORT_WRITE, "unexpected short write"), \ PARA_ERROR(EMPTY, "file is empty"), \ - - -#define ALSA_WRITE_ERRORS \ PARA_ERROR(ALSA, "alsa error"), \ - - -#define WRITE_COMMON_ERRORS \ PARA_ERROR(WRITE_COMMON_EOF, "end of file"), \ - - -#define AACDEC_FILTER_ERRORS \ PARA_ERROR(AACDEC_INIT, "failed to init aac decoder"), \ PARA_ERROR(AAC_DECODE, "aac decode error"), \ - -#define CHUNK_QUEUE_ERRORS \ PARA_ERROR(QUEUE, "packet queue overrun"), \ - - -#define INTERACTIVE_ERRORS \ PARA_ERROR(I9E_EOF, "end of input"), \ PARA_ERROR(I9E_SETUPTERM, "failed to set up terminal"), \ PARA_ERROR(I9E_TERM_RQ, "received termination request"), \ -/** \endcond errors */ - -/** - * The subsystem shift. - * - * 255 error codes ought to be enough for every subsystem. Use the higher bits - * of the return value to encode the subsystem number. - */ -#define SS_SHIFT 8 - -/** - * Compute the subsystem offset. - * - * It is given by x * 2**8 where \a x is the subsystem number. - */ -#define SS_OFFSET(ss) (SS_ ## ss << SS_SHIFT) - -/** - * Make the enum of all errors of one subsystem. - * - * As zero should not be an error, we define a dummy enum entry with value - * 2**ss. That lets the real errors start at 2**ss + 1. - */ -#define SS_ENUM(ss) enum {\ - E_ ## ss ## _DUMMY = SS_OFFSET(ss), \ - ss ## _ERRORS} - -/** - * Determine the subsystem number from the error number. - * - * Easy, it's just \a num / 2**8. - */ -#define ERRNUM_TO_SS(num) ((num) >> SS_SHIFT) - /** - * Determine the index of an error number. - * - * Also easy: It's the lower 8 bits of num. + * This is temporarily defined to expand to its first argument (prefixed by + * 'E_') and gets later redefined to expand to the error text only */ -#define ERRNUM_TO_INDEX(num) (((1 << SS_SHIFT) - 1) & (num)) +#define PARA_ERROR(err, msg) E_ ## err +enum para_error_codes {PARA_ERRORS}; +#undef PARA_ERROR +#define PARA_ERROR(err, msg) msg +/** Array of error strings. */ +extern const char * const para_errlist[]; +#define DEFINE_PARA_ERRLIST const char * const para_errlist[] = {PARA_ERRORS} /** * This bit indicates whether a number is considered a system error number @@ -579,7 +299,6 @@ extern const char **para_errlist[]; /** Set the osl error bit for the given number. */ #define OSL_ERRNO_TO_PARA_ERROR(num) ((num) | (1 << OSL_ERROR_BIT)) - static const char *weak_osl_strerror(int) __attribute__ ((weakref("osl_strerror"))); /** * Paraslash's version of strerror(3). @@ -597,7 +316,7 @@ _static_inline_ const char *para_strerror(int num) } if (IS_SYSTEM_ERROR(num)) return strerror(num & ~(1U << SYSTEM_ERROR_BIT)); - return para_errlist[ERRNUM_TO_SS(num)][ERRNUM_TO_INDEX(num)]; + return para_errlist[num]; } /** @@ -617,31 +336,3 @@ _static_inline_ int osl(int ret) return ret; return -OSL_ERRNO_TO_PARA_ERROR(-ret); } - -/** - * Define the error list for one subsystem. - * - * The first entry (index 0) is always the name of the subsystem. Used by - * macros in config.h (generated by configure). - */ -#define DEFINE_ERRLIST(ss) const char * ss ## _ERRLIST[] = {#ss, ss ## _ERRORS} - -/** - * Activate errors for one subsystem. - * - * Each executable needs only the error lists of those subsystems it is - * actually linked with. We always reserve space for NUM_SS char pointers, - * but only init those of the needed subsystems. This macro is used by macros - * in config.h (generated by configure). - */ -#define PARA_ERRLIST(ss) [SS_ ## ss] = ss ## _ERRLIST - -/** - * This is temporarily defined to expand to its first argument (prefixed by - * 'E_') and gets later redefined to expand to the error text only - */ -#define PARA_ERROR(err, msg) E_ ## err -#include "error2.h" -#undef PARA_ERROR -/* Rest of the world only sees the error text. */ -#define PARA_ERROR(err, msg) msg diff --git a/error2.c b/error2.c deleted file mode 100644 index 85eb41c2..00000000 --- a/error2.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2013 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ - -/** \file error2.c Simple program to create error2.h. */ - -#include -#include -#include -#include -#include -#include -#include -#include - -// #define DEBUG -#ifdef DEBUG - #define log(fmt, ...) fprintf(stderr, "%s: " fmt, __FUNCTION__, ## __VA_ARGS__) -#else - #define log(...) do {;} while (0) -#endif /* DEBUG*/ - -#define HASH_TABLE_BITS 8 -#define HASH_TABLE_SIZE (1 << HASH_TABLE_BITS) - -/* number of executables seen so far */ -static int num_exe; - -struct hash_table_entry { - char *key; - /* only used for objecs, not for executables */ - unsigned exe_bitmask; -}; - -static struct hash_table_entry exe_table[HASH_TABLE_SIZE]; -static struct hash_table_entry obj_table[HASH_TABLE_SIZE]; - -/* no need for anything sophisticated here */ -static int hash_token(const char *tok) -{ - uint32_t tmp = 31415927; - const uint8_t *src = (typeof(src))tok; - - for (; *src; src++) { - tmp *= 27182817; - tmp += *tok; - } - return tmp % HASH_TABLE_SIZE; -} - -static inline bool slot_empty(int idx, struct hash_table_entry *table) -{ - return table[idx].key == NULL; -} - -static char *safe_strdup(const char *str) -{ - char *result = strdup(str); - if (result) - return result; - errno = ENOMEM; - perror("strdup"); - exit(EXIT_FAILURE); -} - -static bool lookup(const char *tok, struct hash_table_entry *table, int *idx) -{ - int i, h = hash_token(tok); - - for (i = 0; i < HASH_TABLE_SIZE; i++) { - *idx = (h + i) % HASH_TABLE_SIZE; - if (slot_empty(*idx, table)) - return false; - if (!strcmp(table[*idx].key, tok)) - return true; - } - log ("hash table full !?\n"); - exit(EXIT_FAILURE); -} - -static bool insert(const char *tok, struct hash_table_entry *table, int *idx) -{ - if (lookup(tok, table, idx)) - return false; /* not inserted */ - table[*idx].key = safe_strdup(tok); - return true; -} - -static void process_token(char *tok) -{ - int idx; - size_t len = strlen(tok); - - assert(len > 0); - if (tok[len - 1] == ':') { - tok[len - 1] = '\0'; - if (insert(tok, exe_table, &idx)) { /* new exe */ - log("exe #%d: '%s', idx: %d\n", num_exe, tok, idx); - num_exe++; - } - } else { - if (num_exe == 0) { - log("invalid input\n"); - exit(EXIT_FAILURE); - } - insert(tok, obj_table, &idx); - obj_table[idx].exe_bitmask |= (1 << (num_exe - 1)); - } -} - -static void print_ss_enum(int idx) -{ - char *s = obj_table[idx].key; - - printf("SS_ENUM("); - for (; *s; s++) - printf("%c", toupper(*s)); - printf(");\n"); -} - -static void dump_bipolar(void) -{ - int i, j; - - for (i = 0; i < HASH_TABLE_SIZE; i++) { - if (slot_empty(i, obj_table)) - continue; - printf("#ifdef MAIN_INPUT_FILE_IS_%s\n", obj_table[i].key); - for (j = 0; j < HASH_TABLE_SIZE; j++) { - unsigned mi, mj; - if (slot_empty(j, obj_table)) - continue; - mi = obj_table[i].exe_bitmask; - mj = obj_table[j].exe_bitmask; - if ((mi & mj) == mi) - print_ss_enum(j); - } - printf("#endif\n"); - } -} - -/** - * The main function of error2.c. - * - * The purpose of this program is to create the error2.h file which defines the - * enumerations of all error codes which may be used by any given .c file. This - * header is included by most .c files of the paraslash suite. - * - * Since this program is executed on the build system, it must be compiled with - * the host compiler. - * - * \return \p EXIT_SUCCESS or \p EXIT_FAILURE. - */ -int main(void) -{ - int ret; - - for (;;) { - char tok[100]; - ret = scanf("%96s", tok); - if (ret != 1) - break; - process_token(tok); - } - dump_bipolar(); - return 0; -} diff --git a/fade.c b/fade.c index e05e3173..2ade4710 100644 --- a/fade.c +++ b/fade.c @@ -17,7 +17,9 @@ #include "ggo.h" #include "version.h" -INIT_FADE_ERRLISTS; +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; + static struct fade_args_info conf; enum mixer_id {MIXER_ENUM}; diff --git a/filter.c b/filter.c index 804b5e1e..81901896 100644 --- a/filter.c +++ b/filter.c @@ -21,6 +21,9 @@ #include "error.h" #include "version.h" +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; + /** The list of all status items used by para_{server,audiod,gui}. */ const char *status_item_list[] = {STATUS_ITEM_ARRAY}; @@ -32,9 +35,6 @@ const char *status_item_list[] = {STATUS_ITEM_ARRAY}; */ char *stat_item_values[NUM_STAT_ITEMS] = {NULL}; -/** Initialize the array of errors for para_filter. */ -INIT_FILTER_ERRLISTS; - /** The task that reads from stdin. */ static struct stdin_task stdin_task_struct; /** pointer to the stdin task. */ diff --git a/gui.c b/gui.c index b0eae64a..63afca07 100644 --- a/gui.c +++ b/gui.c @@ -26,8 +26,9 @@ #include "ggo.h" #include "version.h" -/** define the array of error lists needed by para_gui */ -INIT_GUI_ERRLISTS; +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; + static char *stat_content[NUM_STAT_ITEMS]; static struct gui_window { diff --git a/play.c b/play.c index d2539ee1..034e0f6f 100644 --- a/play.c +++ b/play.c @@ -36,6 +36,9 @@ * Playlist handling is done exclusively in play context. */ +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; + /** * Describes a request to change the state of para_play. * @@ -95,9 +98,6 @@ struct play_task { char *afhi_txt; }; -/** Initialize the array of errors for para_play. */ -INIT_PLAY_ERRLISTS; - /* Activate the afh receiver. */ extern void afh_recv_init(struct receiver *r); #undef AFH_RECEIVER diff --git a/recv.c b/recv.c index f42a7dc0..9de3033f 100644 --- a/recv.c +++ b/recv.c @@ -22,6 +22,9 @@ #include "stdout.h" #include "version.h" +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; + extern void afh_recv_init(struct receiver *r); #undef AFH_RECEIVER #define AFH_RECEIVER {.name = "afh", .init = afh_recv_init}, @@ -34,9 +37,6 @@ static int loglevel; /** Always log to stderr. */ INIT_STDERR_LOGGING(loglevel); -/** init array of error codes used by para_recv */ -INIT_RECV_ERRLISTS; - __noreturn static void print_help_and_die(void) { struct ggo_help h = DEFINE_GGO_HELP(recv); diff --git a/server.c b/server.c index 088cc8b1..59a62047 100644 --- a/server.c +++ b/server.c @@ -18,7 +18,7 @@ * - Buffer trees: \ref buffer_tree.h, * - Sideband API: \ref sideband.h, * - Crypto: \ref crypt.h, \ref crypt_backend.h, - * - Error subsystem: \ref error.h, \ref error2.c, + * - Error subsystem: \ref error.h, * - Inter process communication: \ref ipc.h, * - Forward error correction: \ref fec.h, * - Daemons: \ref daemon.h, @@ -65,10 +65,10 @@ #include "ggo.h" #include "version.h" -__printf_2_3 void (*para_log)(int, const char*, ...) = daemon_log; +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; -/** Define the array of error lists needed by para_server. */ -INIT_SERVER_ERRLISTS; +__printf_2_3 void (*para_log)(int, const char*, ...) = daemon_log; /** Shut down non-authorized connections after that many seconds. */ #define ALARM_TIMEOUT 10 diff --git a/write.c b/write.c index b3f103e9..62caf097 100644 --- a/write.c +++ b/write.c @@ -24,7 +24,8 @@ #include "version.h" #include "check_wav.h" -INIT_WRITE_ERRLISTS; +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; static struct write_args_info conf; -- 2.39.5