diff --git a/CVS/Entries b/CVS/Entries deleted file mode 100644 index 41533b4..0000000 --- a/CVS/Entries +++ /dev/null @@ -1,33 +0,0 @@ -/COPYING/1.1.1.1/Tue Jul 14 22:35:22 1998// -/INSTALL.generic/1.1.1.1/Tue Jul 14 22:35:22 1998// -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:22 1998// -/configure/1.1.1.1/Tue Jul 14 22:35:22 1998// -/install-sh/1.1.1.1/Tue Jul 14 22:35:22 1998// -/mkinstalldirs/1.1.1.1/Tue Jul 14 22:35:22 1998// -/version/1.1.1.1/Tue Jul 14 22:35:22 1998// -D/adpcm//// -D/contrib//// -D/doc//// -D/etc//// -D/examples//// -D/gsm//// -D/include//// -D/java//// -D/lib//// -D/librplay//// -D/perl//// -D/rplay//// -D/rplayd//// -D/rptp//// -D/rx//// -/INSTALL/1.2/Thu Aug 13 06:12:58 1998// -/Makefile.config.in/1.2/Thu Aug 13 06:12:59 1998// -/NEWS/1.2/Thu Aug 13 06:13:00 1998// -/PORTING/1.2/Thu Aug 13 06:13:01 1998// -/README/1.3/Thu Aug 13 06:13:02 1998// -/README.linux/1.2/Thu Aug 13 06:13:03 1998// -/README.sgi/1.2/Thu Aug 13 06:13:04 1998// -/README.sun/1.2/Thu Aug 13 06:13:05 1998// -/TODO/1.2/Thu Aug 13 06:13:06 1998// -/configure.in/1.2/Thu Aug 13 06:13:07 1998// -/ChangeLog/1.5/Thu Oct 15 15:15:05 1998// diff --git a/CVS/Repository b/CVS/Repository deleted file mode 100644 index aad1463..0000000 --- a/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay diff --git a/CVS/Root b/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/ChangeLog b/ChangeLog index 8d83653..df13231 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +1999-03-21 Mark R. Boyns + + * fixed Makefile dependencies and shared library builds. + +1999-03-09 Mark R. Boyns + + * rptp/rptp.c: added monitor support + support for GNU readline + display progress info for get, put, and monitor + + * rplayd/connection.c: monitor support + + * rplayd/rplayd.c: added audio monitor support + + * rplayd/command: added rptp monitor command + + * rplayd/host.c: added "m" monitor access + +1999-03-02 Mark R. Boyns + + * devrplay/devrplay.c: new fake /dev/dsp hack based on esddsp. + +1998-11-10 Mark R. Boyns + + * rptp/rptp.c: added set command. + +1998-11-06 Mark R. Boyns + + * rplayd: fixed SNPRINTF code and other potential buffer overflow + problems. + 1998-10-15 Mark R. Boyns * Version 3.3.1 released. diff --git a/NEWS b/NEWS index 0ef7153..521887b 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,46 @@ rplay NEWS - User-visible changes. -Copyright (C) 1993-98 Mark R. Boyns +Copyright (C) 1993-99 Mark R. Boyns + +Changes since rplay 3.3.1: + +* Added devrplay.so which can be used with LD_PRELOAD to add rplay support + to audio applications use /dev/dsp. devrplay is known to work with rvplayer, + xmp, mpg123, freeamp, s3mod, esd (Enlightenment Sound Daemon) and even + rplayd itself. devrplay.so should be installed in your LD_LIBRARY_PATH. + Example usage: + + bash$ LD_PRELOAD=devrplay.so rvplayer + bash$ LD_PRELOAD=devrplay.so /usr/X11R6/lib/X11/rvplayer/rvplayer + bash$ LD_PRELOAD=devrplay.so dd if=/foo/bar/sound.wav of=/dev/dsp + bash$ LD_PRELOAD=devrplay.so xxmp sound.mod + bash$ LD_PRELOAD=devrplay.so mpg123 sound.mp3 + + tcsh users will probably need to `setenv LD_PRELOAD devrplay.so; command' + instead of using the `LD_PRELOAD=devrplay.so command' syntax. + + devrplay has only been tested on Linux, but it should be possible to + get it working on other systems. + +* Added rptp "set" command. This can be used to set rplayd + variables. One important use of this is to set the audio-close + variable. Examples: + + Tell rplayd to close the audio device: + $ rptp set audio-close 1 + + Tell rplayd *not* to close the audio device: + $ rptp set audio-close 0 + +* Added rplayd monitor support which allows rptp clients to monitor + audio data that is written to the audio device. rptp clients can + now issue the "monitor" command to start receiving audio data. + One use of this feature is to pipe the audio data to a program + for visual display. + +* rptp includes support for GNU readline and also displays progress + information when doing get, put, and monitor. + +* Fixed several potential rplayd buffer overflows. Changes since rplay 3.2: @@ -35,4 +76,4 @@ * Lots of bug fixes. -$Id: NEWS,v 1.2 1998/08/13 06:13:00 boyns Exp $ +$Id: NEWS,v 1.4 1999/03/10 21:17:20 boyns Exp $ diff --git a/README b/README index 2cb9d00..06497ea 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ rplay 3.3 README -Copyright (C) 1993-98 Mark R. Boyns +Copyright (C) 1993-99 Mark R. Boyns rplay is a flexible network audio system that allows sounds to be played to and from local and remote Unix systems. Sounds can be @@ -52,4 +52,4 @@ Send suggestions and bug reports to -$Id: README,v 1.3 1998/08/13 06:13:02 boyns Exp $ +$Id: README,v 1.4 1999/03/10 07:51:00 boyns Exp $ diff --git a/TODO b/TODO index f78c493..53321ee 100644 --- a/TODO +++ b/TODO @@ -2,18 +2,12 @@ * rplayd tends to peg the cpu when it is trying to connect to another rplayd. This needs to be fixed. - -* Fix regex.[ch] to compile with a C++ compiler. * Support more than one audio device in rplayd. A client should be able to specify which device to use. Should there be more than one audio spool? * Add RPLAY_VOLUME_LEFT and RPLAY_VOLUME_RIGHT attributes. RPLAY_VOLUME should still apply to both left & right. - -* Use GNU rx instead of GNU regex. Is rx faster? - -* Add GNU readline support to the rptp client. * rplayd needs to be updated to use the RPTP `set application=rplayd' command when connecting to other rplay servers. @@ -29,12 +23,8 @@ of course not play the directory, but it keeps the directory in its sound list. rplayd should remove the directories from its list. -* Implement a C++ interface to the RPLAY and RPTP protocols. - * Stereo G.72x files don't work and I don't know how to fix 'em. * Don't modify audio-port by default -* Java support? - -$Id: TODO,v 1.2 1998/08/13 06:13:06 boyns Exp $ +$Id: TODO,v 1.3 1999/03/10 07:51:00 boyns Exp $ diff --git a/adpcm/CVS/Entries b/adpcm/CVS/Entries deleted file mode 100644 index 732fdd8..0000000 --- a/adpcm/CVS/Entries +++ /dev/null @@ -1,14 +0,0 @@ -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998// -/README/1.1.1.1/Tue Jul 14 22:35:23 1998// -/README.rplay/1.1.1.1/Tue Jul 14 22:35:23 1998// -/g72xdecode.1/1.1.1.1/Tue Jul 14 22:35:23 1998// -/g72xencode.1/1.1.1.1/Tue Jul 14 22:35:23 1998// -/decode.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/encode.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/g711.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/g721.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/g723_24.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/g723_40.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/g72x.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/g72x.h/1.1.1.1/Thu Aug 13 06:09:31 1998// -D diff --git a/adpcm/CVS/Repository b/adpcm/CVS/Repository deleted file mode 100644 index 4e0557c..0000000 --- a/adpcm/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/adpcm diff --git a/adpcm/CVS/Root b/adpcm/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/adpcm/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/configure b/configure index 995bf06..c604a6f 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12 +# Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -15,8 +15,6 @@ --enable-rplayd-user=USER" ac_help="$ac_help --enable-rplayd-group=GROUP" -ac_help="$ac_help - --with-x use the X Window System" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -55,6 +53,7 @@ # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -338,7 +337,7 @@ verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12" + echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) @@ -508,9 +507,11 @@ # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross +ac_exeext= +ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then @@ -543,15 +544,16 @@ # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:547: checking for $ac_word" >&5 +echo "configure:548: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" @@ -572,16 +574,17 @@ # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:576: checking for $ac_word" >&5 +echo "configure:578: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - for ac_dir in $PATH; do + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then @@ -616,25 +619,61 @@ echo "$ac_t""no" 1>&6 fi + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:629: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:624: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:661: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross -cat > conftest.$ac_ext < conftest.$ac_ext << EOF + +#line 672 "configure" +#include "confdefs.h" + main(){return(0);} EOF -if { (eval echo configure:638: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:677: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -648,18 +687,24 @@ ac_cv_prog_cc_works=no fi rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:658: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:703: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:663: checking whether we are using GNU C" >&5 +echo "configure:708: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -668,7 +713,7 @@ yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:672: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:717: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -679,11 +724,15 @@ if test $ac_cv_prog_gcc = yes; then GCC=yes - ac_test_CFLAGS="${CFLAGS+set}" - ac_save_CFLAGS="$CFLAGS" - CFLAGS= - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:687: checking whether ${CC-cc} accepts -g" >&5 +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:736: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -698,16 +747,20 @@ fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 - if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" - elif test $ac_cv_prog_cc_g = yes; then +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then CFLAGS="-g -O2" else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then CFLAGS="-O2" + else + CFLAGS= fi -else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" fi @@ -744,7 +797,7 @@ echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 -echo "configure:748: checking for POSIXized ISC" >&5 +echo "configure:801: checking for POSIXized ISC" >&5 if test -d /etc/conf/kconfig.d && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 then @@ -765,7 +818,7 @@ fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:769: checking how to run the C preprocessor" >&5 +echo "configure:822: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -780,14 +833,14 @@ # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:790: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:843: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else @@ -797,14 +850,14 @@ rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:807: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:860: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else @@ -812,7 +865,26 @@ echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:877: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* CPP=/lib/cpp +fi +rm -f conftest* fi rm -f conftest* fi @@ -851,28 +923,30 @@ # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:859: checking for a BSD compatible install" >&5 +echo "configure:932: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. : else ac_cv_path_install="$ac_dir/$ac_prog -c" @@ -902,10 +976,12 @@ # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:909: checking whether ln -s works" >&5 +echo "configure:985: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -928,15 +1004,16 @@ # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:932: checking for $ac_word" >&5 +echo "configure:1008: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_RANLIB="ranlib" @@ -959,15 +1036,16 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:963: checking for $ac_word" >&5 +echo "configure:1040: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ETAGS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$ETAGS"; then ac_cv_prog_ETAGS="$ETAGS" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_ETAGS="$ac_prog" @@ -993,15 +1071,16 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:997: checking for $ac_word" >&5 +echo "configure:1075: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_MAKEDEPEND'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$MAKEDEPEND"; then ac_cv_prog_MAKEDEPEND="$MAKEDEPEND" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_MAKEDEPEND="$ac_prog" @@ -1027,15 +1106,16 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1031: checking for $ac_word" >&5 +echo "configure:1110: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$MAKEINFO"; then ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_MAKEINFO="$ac_prog" @@ -1061,15 +1141,16 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1065: checking for $ac_word" >&5 +echo "configure:1145: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_TEXI2DVI'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$TEXI2DVI"; then ac_cv_prog_TEXI2DVI="$TEXI2DVI" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_TEXI2DVI="$ac_prog" @@ -1095,15 +1176,16 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1099: checking for $ac_word" >&5 +echo "configure:1180: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_TEXI2HTML'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$TEXI2HTML"; then ac_cv_prog_TEXI2HTML="$TEXI2HTML" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_TEXI2HTML="$ac_prog" @@ -1129,15 +1211,16 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1133: checking for $ac_word" >&5 +echo "configure:1215: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DVIPS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$DVIPS"; then ac_cv_prog_DVIPS="$DVIPS" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_DVIPS="$ac_prog" @@ -1164,12 +1247,12 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:1168: checking for $ac_hdr that defines DIR" >&5 +echo "configure:1251: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> @@ -1177,7 +1260,7 @@ DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:1181: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1264: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -1202,7 +1285,7 @@ # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:1206: checking for opendir in -ldir" >&5 +echo "configure:1289: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1210,7 +1293,7 @@ ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1243,7 +1326,7 @@ else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:1247: checking for opendir in -lx" >&5 +echo "configure:1330: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1251,7 +1334,7 @@ ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1285,12 +1368,12 @@ fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1289: checking for ANSI C header files" >&5 +echo "configure:1372: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1298,8 +1381,8 @@ #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1302: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1385: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes @@ -1315,7 +1398,7 @@ if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1333,7 +1416,7 @@ if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1354,7 +1437,7 @@ : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1365,7 +1448,7 @@ exit (0); } EOF -if { (eval echo configure:1369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1389,12 +1472,12 @@ fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1393: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:1476: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1403,7 +1486,7 @@ struct tm *tp; ; return 0; } EOF -if { (eval echo configure:1407: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1490: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -1423,856 +1506,22 @@ fi -# If we find X, set shell vars x_includes and x_libraries to the -# paths, otherwise set no_x=yes. -# Uses ac_ vars as temps to allow command line to override cache and checks. -# --without-x overrides everything else, but does not touch the cache. -echo $ac_n "checking for X""... $ac_c" 1>&6 -echo "configure:1432: checking for X" >&5 - -# Check whether --with-x or --without-x was given. -if test "${with_x+set}" = set; then - withval="$with_x" - : -fi - -# $have_x is `yes', `no', `disabled', or empty when we do not yet know. -if test "x$with_x" = xno; then - # The user explicitly disabled X. - have_x=disabled -else - if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then - # Both variables are already set. - have_x=yes - else -if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # One or both of the vars are not set, and there is no cached value. -ac_x_includes=NO ac_x_libraries=NO -rm -fr conftestdir -if mkdir conftestdir; then - cd conftestdir - # Make sure to not put "make" in the Imakefile rules, since we grep it out. - cat > Imakefile <<'EOF' -acfindx: - @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' -EOF - if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then - # GNU make sometimes prints "make[1]: Entering...", which would confuse us. - eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` - # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. - for ac_extension in a so sl; do - if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && - test -f $ac_im_libdir/libX11.$ac_extension; then - ac_im_usrlibdir=$ac_im_libdir; break - fi - done - # Screen out bogus values from the imake configuration. They are - # bogus both because they are the default anyway, and because - # using them would break gcc on systems where it needs fixed includes. - case "$ac_im_incroot" in - /usr/include) ;; - *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; - esac - case "$ac_im_usrlibdir" in - /usr/lib | /lib) ;; - *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; - esac - fi - cd .. - rm -fr conftestdir -fi - -if test "$ac_x_includes" = NO; then - # Guess where to find include files, by looking for this one X11 .h file. - test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h - - # First, try using that file with no special directory specified. -cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1499: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - # We can compile using X headers with no special include directory. -ac_x_includes= -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - # Look for the header file in a standard set of common directories. -# Check X11 before X11Rn because it is often a symlink to the current release. - for ac_dir in \ - /usr/X11/include \ - /usr/X11R6/include \ - /usr/X11R5/include \ - /usr/X11R4/include \ - \ - /usr/include/X11 \ - /usr/include/X11R6 \ - /usr/include/X11R5 \ - /usr/include/X11R4 \ - \ - /usr/local/X11/include \ - /usr/local/X11R6/include \ - /usr/local/X11R5/include \ - /usr/local/X11R4/include \ - \ - /usr/local/include/X11 \ - /usr/local/include/X11R6 \ - /usr/local/include/X11R5 \ - /usr/local/include/X11R4 \ - \ - /usr/X386/include \ - /usr/x386/include \ - /usr/XFree86/include/X11 \ - \ - /usr/include \ - /usr/local/include \ - /usr/unsupported/include \ - /usr/athena/include \ - /usr/local/x11r5/include \ - /usr/lpp/Xamples/include \ - \ - /usr/openwin/include \ - /usr/openwin/share/include \ - ; \ - do - if test -r "$ac_dir/$x_direct_test_include"; then - ac_x_includes=$ac_dir - break - fi - done -fi -rm -f conftest* -fi # $ac_x_includes = NO - -if test "$ac_x_libraries" = NO; then - # Check for the libraries. - - test -z "$x_direct_test_library" && x_direct_test_library=Xt - test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc - - # See if we find them without any special options. - # Don't add to $LIBS permanently. - ac_save_LIBS="$LIBS" - LIBS="-l$x_direct_test_library $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - LIBS="$ac_save_LIBS" -# We can link X programs with no special library path. -ac_x_libraries= -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - LIBS="$ac_save_LIBS" -# First see if replacing the include by lib works. -# Check X11 before X11Rn because it is often a symlink to the current release. -for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ - /usr/X11/lib \ - /usr/X11R6/lib \ - /usr/X11R5/lib \ - /usr/X11R4/lib \ - \ - /usr/lib/X11 \ - /usr/lib/X11R6 \ - /usr/lib/X11R5 \ - /usr/lib/X11R4 \ - \ - /usr/local/X11/lib \ - /usr/local/X11R6/lib \ - /usr/local/X11R5/lib \ - /usr/local/X11R4/lib \ - \ - /usr/local/lib/X11 \ - /usr/local/lib/X11R6 \ - /usr/local/lib/X11R5 \ - /usr/local/lib/X11R4 \ - \ - /usr/X386/lib \ - /usr/x386/lib \ - /usr/XFree86/lib/X11 \ - \ - /usr/lib \ - /usr/local/lib \ - /usr/unsupported/lib \ - /usr/athena/lib \ - /usr/local/x11r5/lib \ - /usr/lpp/Xamples/lib \ - /lib/usr/lib/X11 \ - \ - /usr/openwin/lib \ - /usr/openwin/share/lib \ - ; \ -do - for ac_extension in a so sl; do - if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then - ac_x_libraries=$ac_dir - break 2 - fi - done -done -fi -rm -f conftest* -fi # $ac_x_libraries = NO - -if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then - # Didn't find X anywhere. Cache the known absence of X. - ac_cv_have_x="have_x=no" -else - # Record where we found X for the cache. - ac_cv_have_x="have_x=yes \ - ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" -fi -fi - fi - eval "$ac_cv_have_x" -fi # $with_x != no - -if test "$have_x" != yes; then - echo "$ac_t""$have_x" 1>&6 - no_x=yes -else - # If each of the values was on the command line, it overrides each guess. - test "x$x_includes" = xNONE && x_includes=$ac_x_includes - test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries - # Update the cache value to reflect the command line values. - ac_cv_have_x="have_x=yes \ - ac_x_includes=$x_includes ac_x_libraries=$x_libraries" - echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 -fi - -if test "$no_x" = yes; then - # Not all programs may use this symbol, but it does not hurt to define it. - cat >> confdefs.h <<\EOF -#define X_DISPLAY_MISSING 1 -EOF - - X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= -else - if test -n "$x_includes"; then - X_CFLAGS="$X_CFLAGS -I$x_includes" - fi - - # It would also be nice to do this for all -L options, not just this one. - if test -n "$x_libraries"; then - X_LIBS="$X_LIBS -L$x_libraries" - # For Solaris; some versions of Sun CC require a space after -R and - # others require no space. Words are not sufficient . . . . - case "`(uname -sr) 2>/dev/null`" in - "SunOS 5"*) - echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 -echo "configure:1681: checking whether -R must be followed by a space" >&5 - ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" - cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - ac_R_nospace=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_R_nospace=no -fi -rm -f conftest* - if test $ac_R_nospace = yes; then - echo "$ac_t""no" 1>&6 - X_LIBS="$X_LIBS -R$x_libraries" - else - LIBS="$ac_xsave_LIBS -R $x_libraries" - cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - ac_R_space=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_R_space=no -fi -rm -f conftest* - if test $ac_R_space = yes; then - echo "$ac_t""yes" 1>&6 - X_LIBS="$X_LIBS -R $x_libraries" - else - echo "$ac_t""neither works" 1>&6 - fi - fi - LIBS="$ac_xsave_LIBS" - esac - fi - - # Check for system-dependent libraries X programs must link with. - # Do this before checking for the system-independent R6 libraries - # (-lICE), since we may need -lsocket or whatever for X linking. - - if test "$ISC" = yes; then - X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" - else - # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X - # libraries were built with DECnet support. And karl@cs.umb.edu says - # the Alpha needs dnet_stub (dnet does not exist). - echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 -echo "configure:1746: checking for dnet_ntoa in -ldnet" >&5 -ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldnet $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_lib_dnet_dnet_ntoa = no; then - echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 -echo "configure:1787: checking for dnet_ntoa in -ldnet_stub" >&5 -ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldnet_stub $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" -else - echo "$ac_t""no" 1>&6 -fi - - fi - - # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, - # to get the SysV transport functions. - # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4) - # needs -lnsl. - # The nsl library prevents programs from opening the X display - # on Irix 5.2, according to dickey@clark.net. - echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:1835: checking for gethostbyname" >&5 -if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char gethostbyname(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) -choke me -#else -gethostbyname(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_func_gethostbyname=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_gethostbyname=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_func_gethostbyname = no; then - echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:1884: checking for gethostbyname in -lnsl" >&5 -ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lnsl $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" -else - echo "$ac_t""no" 1>&6 -fi - - fi - - # lieder@skyler.mavd.honeywell.com says without -lsocket, - # socket/setsockopt and other routines are undefined under SCO ODT - # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary - # on later versions), says simon@lia.di.epfl.ch: it contains - # gethostby* variants that don't use the nameserver (or something). - # -lsocket must be given before -lnsl if both are needed. - # We assume that if connect needs -lnsl, so does gethostbyname. - echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:1933: checking for connect" >&5 -if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char connect(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_connect) || defined (__stub___connect) -choke me -#else -connect(); -#endif - -; return 0; } -EOF -if { (eval echo configure:1961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_func_connect=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_connect=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_func_connect = no; then - echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 -echo "configure:1982: checking for connect in -lsocket" >&5 -ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lsocket $X_EXTRA_LIBS $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" -else - echo "$ac_t""no" 1>&6 -fi - - fi - - # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. - echo $ac_n "checking for remove""... $ac_c" 1>&6 -echo "configure:2025: checking for remove" >&5 -if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char remove(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_remove) || defined (__stub___remove) -choke me -#else -remove(); -#endif - -; return 0; } -EOF -if { (eval echo configure:2053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_func_remove=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_remove=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_func_remove = no; then - echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 -echo "configure:2074: checking for remove in -lposix" >&5 -ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lposix $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" -else - echo "$ac_t""no" 1>&6 -fi - - fi - - # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. - echo $ac_n "checking for shmat""... $ac_c" 1>&6 -echo "configure:2117: checking for shmat" >&5 -if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shmat(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_shmat) || defined (__stub___shmat) -choke me -#else -shmat(); -#endif - -; return 0; } -EOF -if { (eval echo configure:2145: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_func_shmat=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_shmat=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -fi - - if test $ac_cv_func_shmat = no; then - echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 -echo "configure:2166: checking for shmat in -lipc" >&5 -ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lipc $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" -else - echo "$ac_t""no" 1>&6 -fi - - fi - fi - - # Check for libraries that X11R6 Xt/Xaw programs need. - ac_save_LDFLAGS="$LDFLAGS" - test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" - # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to - # check for ICE first), but we must link in the order -lSM -lICE or - # we get undefined symbols. So assume we have SM if we have ICE. - # These have to be linked with before -lX11, unlike the other - # libraries we check for below, so use a different variable. - # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. - echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 -echo "configure:2218: checking for IceConnectionNumber in -lICE" >&5 -ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lICE $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" -else - echo "$ac_t""no" 1>&6 -fi - - LDFLAGS="$ac_save_LDFLAGS" - -fi - -for ac_hdr in fcntl.h sys/file.h sys/ioctl.h sys/time.h stdlib.h unistd.h memory.h string.h strings.h utime.h limits.h forms.h X11/forms.h +for ac_hdr in fcntl.h sys/file.h sys/ioctl.h sys/time.h stdlib.h unistd.h memory.h string.h strings.h utime.h limits.h gsm.h gsm/gsm.h rxposix.h rx/rxposix.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2265: checking for $ac_hdr" >&5 +echo "configure:1514: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2275: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1524: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" @@ -2298,12 +1547,12 @@ done echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:2302: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:1551: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2319,7 +1568,7 @@ s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:2323: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1572: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -2341,12 +1590,12 @@ echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:2345: checking for working const" >&5 +echo "configure:1594: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1648: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -2416,12 +1665,12 @@ fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:2420: checking for size_t" >&5 +echo "configure:1669: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2430,7 +1679,7 @@ #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then rm -rf conftest* ac_cv_type_size_t=yes else @@ -2453,18 +1702,18 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2457: checking for $ac_hdr" >&5 +echo "configure:1706: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2467: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1716: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" @@ -2492,12 +1741,12 @@ for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2496: checking for $ac_func" >&5 +echo "configure:1745: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2545,7 +1794,7 @@ done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:2549: checking for working mmap" >&5 +echo "configure:1798: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2553,7 +1802,7 @@ ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes else @@ -2716,7 +1965,7 @@ fi echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 -echo "configure:2720: checking for 8-bit clean memcmp" >&5 +echo "configure:1969: checking for 8-bit clean memcmp" >&5 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2724,7 +1973,7 @@ ac_cv_func_memcmp_clean=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1987: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_memcmp_clean=yes else @@ -2749,15 +1998,15 @@ fi echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 -test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o" +test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:2756: checking for vprintf" >&5 +echo "configure:2005: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2033: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -2804,12 +2053,12 @@ if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:2808: checking for _doprnt" >&5 +echo "configure:2057: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -2857,12 +2106,12 @@ fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:2861: checking return type of signal handlers" >&5 +echo "configure:2110: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2879,7 +2128,7 @@ int i; ; return 0; } EOF -if { (eval echo configure:2883: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2132: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -2897,15 +2146,15 @@ EOF -for ac_func in getcwd gethostname mkdir re_comp regcomp select snprintf socket strdup strerror strstr fstat fchmod fchown utime utimes memmove sigset vsnprintf waitpid +for ac_func in getcwd gethostname mkdir re_comp regcomp select snprintf socket strdup strerror strstr fstat fchmod fchown utime utimes memmove sigset vsnprintf waitpid random srandom do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2904: checking for $ac_func" >&5 +echo "configure:2153: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2181: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2953,7 +2202,7 @@ done echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:2957: checking for socket in -lsocket" >&5 +echo "configure:2206: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2961,7 +2210,7 @@ ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2993,7 +2242,7 @@ fi echo $ac_n "checking for t_accept in -lnsl""... $ac_c" 1>&6 -echo "configure:2997: checking for t_accept in -lnsl" >&5 +echo "configure:2246: checking for t_accept in -lnsl" >&5 ac_lib_var=`echo nsl'_'t_accept | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3001,7 +2250,7 @@ ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3033,6 +2282,148 @@ fi +echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6 +echo "configure:2287: checking for readline in -lreadline" >&5 +ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lreadline $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + RL_LIBS="-lreadline" +else + echo "$ac_t""no" 1>&6 +fi + + + +echo $ac_n "checking for gsm_decode in -lgsm""... $ac_c" 1>&6 +echo "configure:2329: checking for gsm_decode in -lgsm" >&5 +ac_lib_var=`echo gsm'_'gsm_decode | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lgsm $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + HAVE_GSM="yes" +else + echo "$ac_t""no" 1>&6 +fi + +if test "$HAVE_GSM" = "yes"; then + GSM_LIBS="-lgsm" + GSM_INCS="" +else + GSM_LIBS="-L../gsm -lgsm" + GSM_INCS="-I\${srcdir}/../gsm" +fi + + + +echo $ac_n "checking for regncomp in -lrx""... $ac_c" 1>&6 +echo "configure:2379: checking for regncomp in -lrx" >&5 +ac_lib_var=`echo rx'_'regncomp | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lrx $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + HAVE_RX="yes" +else + echo "$ac_t""no" 1>&6 +fi + +if test "$HAVE_RX" = "yes"; then + RX_LIBS="-lrx" + RX_INCS="" +else + RX_LIBS="-L../rx -lrx" + RX_INCS="-I\${srcdir}/../rx" +fi + + + RPLAY_TOP=`pwd` @@ -3043,9 +2434,9 @@ if test -z "$RPLAY_TARGET"; then echo $ac_n "checking for sun""... $ac_c" 1>&6 -echo "configure:3047: checking for sun" >&5 +echo "configure:2438: checking for sun" >&5 cat > conftest.$ac_ext <&6 -echo "configure:3073: checking for solaris" >&5 +echo "configure:2464: checking for solaris" >&5 if test ! -f /vmunix; then is_solaris=yes RPLAY_TARGET="solaris" @@ -3082,9 +2473,9 @@ if test -z "$RPLAY_TARGET"; then echo $ac_n "checking for linux""... $ac_c" 1>&6 -echo "configure:3086: checking for linux" >&5 +echo "configure:2477: checking for linux" >&5 cat > conftest.$ac_ext <&6 -echo "configure:3114: checking for hpux" >&5 +echo "configure:2505: checking for hpux" >&5 cat > conftest.$ac_ext <&6 -echo "configure:3142: checking for sgi" >&5 +echo "configure:2533: checking for sgi" >&5 cat > conftest.$ac_ext <&6 -echo "configure:3166: checking for multimedia development kit" >&5 +echo "configure:2557: checking for multimedia development kit" >&5 for ac_hdr in audio.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3171: checking for $ac_hdr" >&5 +echo "configure:2562: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3181: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:2572: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" @@ -3213,9 +2604,9 @@ if test -z "$RPLAY_TARGET"; then echo $ac_n "checking for FreeBSD""... $ac_c" 1>&6 -echo "configure:3217: checking for FreeBSD" >&5 +echo "configure:2608: checking for FreeBSD" >&5 cat > conftest.$ac_ext < confcache <<\EOF @@ -3296,7 +2700,7 @@ # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1` in + case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -3363,7 +2767,7 @@ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12" + echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -3374,7 +2778,7 @@ ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo "Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile devrplay/Makefile include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub +s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g @@ -3408,6 +2814,7 @@ s%@CC@%$CC%g s%@CPP@%$CPP%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@LN_S@%$LN_S%g s%@RANLIB@%$RANLIB%g @@ -3417,15 +2824,16 @@ s%@TEXI2DVI@%$TEXI2DVI%g s%@TEXI2HTML@%$TEXI2HTML%g s%@DVIPS@%$DVIPS%g -s%@X_CFLAGS@%$X_CFLAGS%g -s%@X_PRE_LIBS@%$X_PRE_LIBS%g -s%@X_LIBS@%$X_LIBS%g -s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g s%@LIBOBJS@%$LIBOBJS%g +s%@RL_LIBS@%$RL_LIBS%g +s%@GSM_LIBS@%$GSM_LIBS%g +s%@GSM_INCS@%$GSM_INCS%g +s%@RX_LIBS@%$RX_LIBS%g +s%@RX_INCS@%$RX_INCS%g s%@RPLAY_TOP@%$RPLAY_TOP%g s%@RPLAY_TARGET@%$RPLAY_TARGET%g +s%@subdirs@%$subdirs%g s%@BUILD_TARGETS@%$BUILD_TARGETS%g -s%@subdirs@%$subdirs%g CEOF EOF @@ -3467,7 +2875,7 @@ cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then diff --git a/configure.in b/configure.in index ba94193..34f47cc 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.2 1998/08/13 06:13:07 boyns Exp $ +dnl $Id: configure.in,v 1.5 1999/06/09 06:26:28 boyns Exp $ dnl dnl Process this file with autoconf to produce a configure script. dnl @@ -57,8 +57,8 @@ AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_TIME -AC_PATH_XTRA -AC_CHECK_HEADERS(fcntl.h sys/file.h sys/ioctl.h sys/time.h stdlib.h unistd.h memory.h string.h strings.h utime.h limits.h forms.h X11/forms.h) +dnl AC_PATH_XTRA +AC_CHECK_HEADERS(fcntl.h sys/file.h sys/ioctl.h sys/time.h stdlib.h unistd.h memory.h string.h strings.h utime.h limits.h gsm.h gsm/gsm.h rxposix.h rx/rxposix.h) AC_HEADER_SYS_WAIT dnl Check for typedefs, structures, and compiler characteristics. @@ -70,9 +70,34 @@ AC_FUNC_MEMCMP AC_FUNC_VPRINTF AC_TYPE_SIGNAL -AC_CHECK_FUNCS(getcwd gethostname mkdir re_comp regcomp select snprintf socket strdup strerror strstr fstat fchmod fchown utime utimes memmove sigset vsnprintf waitpid) +AC_CHECK_FUNCS(getcwd gethostname mkdir re_comp regcomp select snprintf socket strdup strerror strstr fstat fchmod fchown utime utimes memmove sigset vsnprintf waitpid random srandom) AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"]) AC_CHECK_LIB(nsl, t_accept, [LIBS="$LIBS -lnsl"]) + +AC_CHECK_LIB(readline, readline, [RL_LIBS="-lreadline"]) +AC_SUBST(RL_LIBS) + +AC_CHECK_LIB(gsm, gsm_decode, [HAVE_GSM="yes"]) +if test "$HAVE_GSM" = "yes"; then + GSM_LIBS="-lgsm" + GSM_INCS="" +else + GSM_LIBS="-L../gsm -lgsm" + GSM_INCS="-I\${srcdir}/../gsm" +fi +AC_SUBST(GSM_LIBS) +AC_SUBST(GSM_INCS) + +AC_CHECK_LIB(rx, regncomp, [HAVE_RX="yes"]) +if test "$HAVE_RX" = "yes"; then + RX_LIBS="-lrx" + RX_INCS="" +else + RX_LIBS="-L../rx -lrx" + RX_INCS="-I\${srcdir}/../rx" +fi +AC_SUBST(RX_LIBS) +AC_SUBST(RX_INCS) RPLAY_TOP=`pwd` AC_SUBST(RPLAY_TOP) @@ -225,8 +250,21 @@ fi AC_SUBST(LIBS) -BUILD_TARGETS="include lib rx adpcm gsm librplay rplayd rplay rptp doc" +BUILD_TARGETS="include lib adpcm" +if test "$HAVE_RX" != "yes"; then + BUILD_TARGETS="$BUILD_TARGETS rx" + AC_CONFIG_SUBDIRS(rx) +fi +if test "$HAVE_GSM" != "yes"; then + BUILD_TARGETS="$BUILD_TARGETS gsm" +fi + +BUILD_TARGETS="$BUILD_TARGETS librplay rplayd rplay rptp doc" + +if test $RPLAY_TARGET = "oss"; then + BUILD_TARGETS="$BUILD_TARGETS devrplay" +fi + AC_SUBST(BUILD_TARGETS) -AC_CONFIG_SUBDIRS(rx) -AC_OUTPUT(Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile) +AC_OUTPUT(Makefile.config Makefile include/Makefile lib/Makefile adpcm/Makefile gsm/Makefile librplay/Makefile rplayd/Makefile rplay/Makefile rptp/Makefile doc/Makefile devrplay/Makefile) diff --git a/contrib/CVS/Entries b/contrib/CVS/Entries deleted file mode 100644 index 50d6793..0000000 --- a/contrib/CVS/Entries +++ /dev/null @@ -1,13 +0,0 @@ -/README.crossfire/1.1.1.1/Tue Jul 14 22:35:22 1998// -/mailnoise/1.1.1.1/Tue Jul 14 22:35:22 1998// -D/cdrplay//// -D/fingergoodies//// -D/jukebox-1.3//// -D/mailsound//// -D/pos//// -D/rplaytool-1.1//// -D/tkrplay//// -D/vu//// -D/window_managers//// -D/xjukebox-0.9//// -D/xpilot//// diff --git a/contrib/CVS/Repository b/contrib/CVS/Repository deleted file mode 100644 index 78c0d1c..0000000 --- a/contrib/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib diff --git a/contrib/CVS/Root b/contrib/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/cdrplay/CVS/Entries b/contrib/cdrplay/CVS/Entries deleted file mode 100644 index ff2696b..0000000 --- a/contrib/cdrplay/CVS/Entries +++ /dev/null @@ -1,2 +0,0 @@ -/cdrplay.c/1.2/Thu Aug 13 06:13:18 1998// -D diff --git a/contrib/cdrplay/CVS/Repository b/contrib/cdrplay/CVS/Repository deleted file mode 100644 index da97c7c..0000000 --- a/contrib/cdrplay/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/cdrplay diff --git a/contrib/cdrplay/CVS/Root b/contrib/cdrplay/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/cdrplay/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/cdrplay/cdrplay.c b/contrib/cdrplay/cdrplay.c index 7638829..052931e 100644 --- a/contrib/cdrplay/cdrplay.c +++ b/contrib/cdrplay/cdrplay.c @@ -1,23 +1,24 @@ -/* $Id: cdrplay.c,v 1.2 1998/08/13 06:13:18 boyns Exp $ */ - -/* - * Copyright (C) 1996 Mark Boyns +/* $Id: cdrplay.c,v 1.3 1999/03/10 07:51:42 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * - * This file is part of cdrplay. + * This file is part of rplay. * - * This program is free software; you can redistribute it and/or modify + * rplay is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * rplay is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with rplay; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ /* A lot of the CDDA code is based on read_cdda 1.01 by Jim Mintha diff --git a/contrib/fingergoodies/CVS/Entries b/contrib/fingergoodies/CVS/Entries deleted file mode 100644 index 36e5cbd..0000000 --- a/contrib/fingergoodies/CVS/Entries +++ /dev/null @@ -1,4 +0,0 @@ -/.fingerrc/1.1.1.1/Tue Jul 14 22:35:23 1998// -/getcalleraddr.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/random.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -D diff --git a/contrib/fingergoodies/CVS/Repository b/contrib/fingergoodies/CVS/Repository deleted file mode 100644 index 8360a98..0000000 --- a/contrib/fingergoodies/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/fingergoodies diff --git a/contrib/fingergoodies/CVS/Root b/contrib/fingergoodies/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/fingergoodies/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/jukebox-1.3/CVS/Entries b/contrib/jukebox-1.3/CVS/Entries deleted file mode 100644 index 4b5b5c0..0000000 --- a/contrib/jukebox-1.3/CVS/Entries +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998// -D/man1//// -/jukebox.c/1.1.1.1/Thu Aug 13 06:09:35 1998// diff --git a/contrib/jukebox-1.3/CVS/Repository b/contrib/jukebox-1.3/CVS/Repository deleted file mode 100644 index ad24e90..0000000 --- a/contrib/jukebox-1.3/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/jukebox-1.3 diff --git a/contrib/jukebox-1.3/CVS/Root b/contrib/jukebox-1.3/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/jukebox-1.3/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/jukebox-1.3/man1/CVS/Entries b/contrib/jukebox-1.3/man1/CVS/Entries deleted file mode 100644 index f771759..0000000 --- a/contrib/jukebox-1.3/man1/CVS/Entries +++ /dev/null @@ -1,2 +0,0 @@ -/jukebox.1/1.1.1.1/Tue Jul 14 22:35:23 1998// -D diff --git a/contrib/jukebox-1.3/man1/CVS/Repository b/contrib/jukebox-1.3/man1/CVS/Repository deleted file mode 100644 index 5f300c0..0000000 --- a/contrib/jukebox-1.3/man1/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/jukebox-1.3/man1 diff --git a/contrib/jukebox-1.3/man1/CVS/Root b/contrib/jukebox-1.3/man1/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/jukebox-1.3/man1/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/mailsound/CVS/Entries b/contrib/mailsound/CVS/Entries deleted file mode 100644 index af21648..0000000 --- a/contrib/mailsound/CVS/Entries +++ /dev/null @@ -1,4 +0,0 @@ -/Makefile/1.1.1.1/Tue Jul 14 22:35:22 1998// -/mailsound.1/1.1.1.1/Tue Jul 14 22:35:23 1998// -/mailsound.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -D diff --git a/contrib/mailsound/CVS/Repository b/contrib/mailsound/CVS/Repository deleted file mode 100644 index a9470ec..0000000 --- a/contrib/mailsound/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/mailsound diff --git a/contrib/mailsound/CVS/Root b/contrib/mailsound/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/mailsound/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/pos/CVS/Entries b/contrib/pos/CVS/Entries deleted file mode 100644 index f19344c..0000000 --- a/contrib/pos/CVS/Entries +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998// -/pos.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -D diff --git a/contrib/pos/CVS/Repository b/contrib/pos/CVS/Repository deleted file mode 100644 index f713ca6..0000000 --- a/contrib/pos/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/pos diff --git a/contrib/pos/CVS/Root b/contrib/pos/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/pos/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/rplaytool-1.1/CVS/Entries b/contrib/rplaytool-1.1/CVS/Entries deleted file mode 100644 index 055b792..0000000 --- a/contrib/rplaytool-1.1/CVS/Entries +++ /dev/null @@ -1,20 +0,0 @@ -/COPYING/1.1.1.1/Tue Jul 14 22:35:23 1998// -/ChangeLog/1.1.1.1/Tue Jul 14 22:35:23 1998// -/Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998// -/README/1.1.1.1/Tue Jul 14 22:35:23 1998// -/list/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplaytool.G/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplaytool.P/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplaytool.info/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplaytool.make/1.1.1.1/Tue Jul 14 22:35:23 1998// -D/icons//// -/misc.c/1.2/Thu Aug 13 06:13:19 1998// -/misc.h/1.2/Thu Aug 13 06:13:20 1998// -/rptp.c/1.2/Thu Aug 13 06:13:21 1998// -/rptp.h/1.2/Thu Aug 13 06:13:22 1998// -/getopt.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/getopt.h/1.1.1.1/Thu Aug 13 06:09:35 1998// -/getopt1.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rplaytool_stubs.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rplaytool_ui.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rplaytool_ui.h/1.1.1.1/Thu Aug 13 06:09:35 1998// diff --git a/contrib/rplaytool-1.1/CVS/Repository b/contrib/rplaytool-1.1/CVS/Repository deleted file mode 100644 index 921af5a..0000000 --- a/contrib/rplaytool-1.1/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/rplaytool-1.1 diff --git a/contrib/rplaytool-1.1/CVS/Root b/contrib/rplaytool-1.1/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/rplaytool-1.1/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/rplaytool-1.1/icons/CVS/Entries b/contrib/rplaytool-1.1/icons/CVS/Entries deleted file mode 100644 index 93364b9..0000000 --- a/contrib/rplaytool-1.1/icons/CVS/Entries +++ /dev/null @@ -1,19 +0,0 @@ -/arrow.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/directory.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/file.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/none.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/pause.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/pause1.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/pause2.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/pause3.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/pause4.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/play.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/play1.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/play2.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/play3.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/play4.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplaytool.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplaytool_mask.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/sound.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -/watch.icon/1.1.1.1/Tue Jul 14 22:35:23 1998// -D diff --git a/contrib/rplaytool-1.1/icons/CVS/Repository b/contrib/rplaytool-1.1/icons/CVS/Repository deleted file mode 100644 index 4986db2..0000000 --- a/contrib/rplaytool-1.1/icons/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/rplaytool-1.1/icons diff --git a/contrib/rplaytool-1.1/icons/CVS/Root b/contrib/rplaytool-1.1/icons/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/rplaytool-1.1/icons/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/tkrplay/CVS/Entries b/contrib/tkrplay/CVS/Entries deleted file mode 100644 index 27d30ba..0000000 --- a/contrib/tkrplay/CVS/Entries +++ /dev/null @@ -1,4 +0,0 @@ -/README/1.1.1.1/Tue Jul 14 22:35:23 1998// -/foo/1.1.1.1/Tue Jul 14 22:35:23 1998// -/tkrplay/1.1.1.1/Tue Jul 14 22:35:23 1998// -D diff --git a/contrib/tkrplay/CVS/Repository b/contrib/tkrplay/CVS/Repository deleted file mode 100644 index 9a2813e..0000000 --- a/contrib/tkrplay/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/tkrplay diff --git a/contrib/tkrplay/CVS/Root b/contrib/tkrplay/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/tkrplay/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/vu/CVS/Entries b/contrib/vu/CVS/Entries deleted file mode 100644 index 74c0667..0000000 --- a/contrib/vu/CVS/Entries +++ /dev/null @@ -1,4 +0,0 @@ -/Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998// -/vu.1/1.1.1.1/Tue Jul 14 22:35:23 1998// -/vu.c/1.1.1.1/Thu Aug 13 06:09:36 1998// -D diff --git a/contrib/vu/CVS/Repository b/contrib/vu/CVS/Repository deleted file mode 100644 index dbdc443..0000000 --- a/contrib/vu/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/vu diff --git a/contrib/vu/CVS/Root b/contrib/vu/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/vu/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/window_managers/CVS/Entries b/contrib/window_managers/CVS/Entries deleted file mode 100644 index 779a045..0000000 --- a/contrib/window_managers/CVS/Entries +++ /dev/null @@ -1,5 +0,0 @@ -/ctwm/1.1.1.1/Tue Jul 14 22:35:23 1998// -/fvwm/1.1.1.1/Tue Jul 14 22:35:23 1998// -/tvtwm/1.1.1.1/Tue Jul 14 22:35:23 1998// -/twm/1.1.1.1/Tue Jul 14 22:35:23 1998// -D/olvwm//// diff --git a/contrib/window_managers/CVS/Repository b/contrib/window_managers/CVS/Repository deleted file mode 100644 index 59e80d6..0000000 --- a/contrib/window_managers/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/window_managers diff --git a/contrib/window_managers/CVS/Root b/contrib/window_managers/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/window_managers/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/window_managers/olvwm/CVS/Entries b/contrib/window_managers/olvwm/CVS/Entries deleted file mode 100644 index 2dbc646..0000000 --- a/contrib/window_managers/olvwm/CVS/Entries +++ /dev/null @@ -1,5 +0,0 @@ -/.olvwm-sounds/1.1.1.1/Tue Jul 14 22:35:23 1998// -/README/1.1.1.1/Tue Jul 14 22:35:23 1998// -/olvwm-3.3-patch/1.1.1.1/Tue Jul 14 22:35:23 1998// -/olvwm.events/1.1.1.1/Tue Jul 14 22:35:23 1998// -D diff --git a/contrib/window_managers/olvwm/CVS/Repository b/contrib/window_managers/olvwm/CVS/Repository deleted file mode 100644 index 45c11b4..0000000 --- a/contrib/window_managers/olvwm/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/window_managers/olvwm diff --git a/contrib/window_managers/olvwm/CVS/Root b/contrib/window_managers/olvwm/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/window_managers/olvwm/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/xjukebox-0.9/CVS/Entries b/contrib/xjukebox-0.9/CVS/Entries deleted file mode 100644 index cc2a2b2..0000000 --- a/contrib/xjukebox-0.9/CVS/Entries +++ /dev/null @@ -1,15 +0,0 @@ -/INSTALL/1.1.1.1/Tue Jul 14 22:35:23 1998// -/Imakefile/1.1.1.1/Tue Jul 14 22:35:23 1998// -/Makefile/1.1.1.1/Tue Jul 14 22:35:23 1998// -/README/1.1.1.1/Tue Jul 14 22:35:23 1998// -/TODO/1.1.1.1/Tue Jul 14 22:35:23 1998// -/XJukebox-color.ad/1.1.1.1/Tue Jul 14 22:35:23 1998// -/XJukebox.ad/1.1.1.1/Tue Jul 14 22:35:23 1998// -/ad2c/1.1.1.1/Tue Jul 14 22:35:23 1998// -/xjukebox.xpm/1.1.1.1/Tue Jul 14 22:35:23 1998// -/XJukebox.ad.h/1.1.1.1/Thu Aug 13 06:09:36 1998// -/rptpstuff.c/1.1.1.1/Thu Aug 13 06:09:36 1998// -/widgets.c/1.1.1.1/Thu Aug 13 06:09:36 1998// -/xjukebox.c/1.1.1.1/Thu Aug 13 06:09:36 1998// -/xjukebox.h/1.1.1.1/Thu Aug 13 06:09:36 1998// -D diff --git a/contrib/xjukebox-0.9/CVS/Repository b/contrib/xjukebox-0.9/CVS/Repository deleted file mode 100644 index b142aa4..0000000 --- a/contrib/xjukebox-0.9/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/xjukebox-0.9 diff --git a/contrib/xjukebox-0.9/CVS/Root b/contrib/xjukebox-0.9/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/xjukebox-0.9/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/contrib/xpilot/CVS/Entries b/contrib/xpilot/CVS/Entries deleted file mode 100644 index 8e127e4..0000000 --- a/contrib/xpilot/CVS/Entries +++ /dev/null @@ -1,9 +0,0 @@ -/README/1.1.1.1/Tue Jul 14 22:35:23 1998// -/arnold_sounds/1.1.1.1/Tue Jul 14 22:35:23 1998// -/ren+stimpy_sounds/1.1.1.1/Tue Jul 14 22:35:23 1998// -/sounds/1.1.1.1/Tue Jul 14 22:35:23 1998// -/sounds-3.1.0/1.1.1.1/Tue Jul 14 22:35:23 1998// -/sounds-simpsons/1.1.1.1/Tue Jul 14 22:35:23 1998// -/st_sounds/1.1.1.1/Tue Jul 14 22:35:23 1998// -/sttng_sounds/1.1.1.1/Tue Jul 14 22:35:23 1998// -D diff --git a/contrib/xpilot/CVS/Repository b/contrib/xpilot/CVS/Repository deleted file mode 100644 index 4c727df..0000000 --- a/contrib/xpilot/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/contrib/xpilot diff --git a/contrib/xpilot/CVS/Root b/contrib/xpilot/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/contrib/xpilot/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/devrplay/Makefile.in b/devrplay/Makefile.in new file mode 100644 index 0000000..98083c2 --- /dev/null +++ b/devrplay/Makefile.in @@ -0,0 +1,55 @@ +include @RPLAY_TOP@/Makefile.config + +srcdir = @srcdir@ +VPATH = @srcdir@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +MKINSTALLDIRS= @srcdir@/../mkinstalldirs + +CPPFLAGS= $(CC_OPTIONS) -fPIC -I. -I../include -I@srcdir@/../include @DEFS@ + +.c.o: + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + +LDFLAGS= $(LD_OPTIONS) -shared @LDFLAGS@ @LIBS@ -L../librplay -lrplay -ldl + +TARGET= devrplay.so +SRCS= devrplay.c +OBJS= devrplay.o + +all: $(TARGET) + +#$(TARGET): $(OBJS) ../librplay/librplay.so +# $(CC) -o $@ $(OBJS) ../librplay/rplay.lo ../librplay/rptp.lo $(LDFLAGS) + +$(TARGET): $(OBJS) ../librplay/librplay.so + $(CC) -o $@ $(OBJS) $(LDFLAGS) + +../librplay/librplay.so: + (cd ../librplay; $(MAKE) $(MFLAGS) librplay.so) + +install: all + $(MKINSTALLDIRS) $(libdir) + $(INSTALL_DATA) $(TARGET) $(libdir) + +uninstall: + $(RM) $(libdir)/$(TARGET) + +clean: + $(RM) $(OBJS) $(TARGET) a.out core *~ *.bak *.orig TAGS + +distclean: clean + $(RM) Makefile + +tags: + $(TAGS) *.[ch] + +TAGS: tags + +etags: tags + +depend: + $(MAKEDEPEND) -- $(CPPFLAGS) $(CFLAGS) -- $(SRCS) + diff --git a/devrplay/devrplay.c b/devrplay/devrplay.c new file mode 100644 index 0000000..6e22033 --- /dev/null +++ b/devrplay/devrplay.c @@ -0,0 +1,278 @@ +/* $Id: devrplay.c,v 1.4 1999/03/21 00:44:48 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns + * + * This file is part of rplay. + * + * rplay is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * rplay is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with rplay; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +/* + * based on esddsp.c + * Copyright (C) 1998, 1999 Manish Singh + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "rplay.h" + +#define DEVRPLAY_SOUND "devrplay" + +#ifdef linux + +#include +#include +#define REAL_LIBC RTLD_NEXT + +static int rplay_fd = -1; +static int spool_id = -1; +static int dsp_fmt; +static int dsp_speed; +static int dsp_channels; +static int dsp_speed; +static int dsp_blksize; +static int streaming; + +static char * +getsound() +{ + char *p = getenv("DEVRPLAY_SOUND"); + return p ? p : DEVRPLAY_SOUND; +} + +static char * +getinfo() +{ + char *p = getenv("DEVRPLAY_INFO"); + return p ? p : 0; +} + +static char * +getopts() +{ + char *p = getenv("DEVRPLAY_OPTS"); + return p ? p : 0; +} + +int +open(const char *pathname, int flags,...) +{ + static int (*func)(const char *, int, mode_t) = NULL; + va_list args; + mode_t mode; + char response[RPTP_MAX_LINE]; + + if (!func) + func = (int (*)(const char *, int, mode_t)) dlsym(REAL_LIBC, "open"); + + va_start(args, flags); + mode = va_arg(args, mode_t); + va_end(args); + + if (strcmp(pathname, "/dev/dsp") == 0) + { + rplay_fd = rptp_open(rplay_default_host(), RPTP_PORT, response, + sizeof(response)); + if (rplay_fd < 0) + { + rptp_perror(rplay_default_host()); + } + return rplay_fd; + } + else + { + return (*func)(pathname, flags, mode); + } +} + +static int +dspctl(int fd, int request, void *argp) +{ + int *arg = (int *) argp; + + switch (request) + { + case SNDCTL_DSP_SETFMT: + dsp_fmt = *arg; + break; + + case SNDCTL_DSP_SPEED: + dsp_speed = *arg; + break; + + case SNDCTL_DSP_STEREO: + dsp_channels = *arg ? 2 : 1; + break; + + case SNDCTL_DSP_CHANNELS: + dsp_channels = *arg; + break; + + case SNDCTL_DSP_GETBLKSIZE: + *arg = 65535; + break; + + case SNDCTL_DSP_GETFMTS: + *arg = 0x38; + break; + + case SNDCTL_DSP_GETCAPS: + *arg = 0; + break; + + case SNDCTL_DSP_GETOSPACE: + { + audio_buf_info *info = (audio_buf_info *) argp; + info->fragments = 16; + info->fragstotal = 16; + info->fragsize = 4096; + info->bytes = 44100; + } + break; + + default: + break; + } + + if (spool_id == -1 && dsp_fmt && dsp_speed && dsp_channels) + { + char response[RPTP_MAX_LINE]; + + streaming = 1; + rptp_putline(rplay_fd, + "play input=flow input-info=%s,%d,%d,%d,%s %s sound=\"%s\"", + dsp_fmt == 16 ? "linear16" : "ulinear8", + dsp_speed, + dsp_fmt, + dsp_channels, + "little-endian", + getopts(), + getsound()); + rptp_getline(rplay_fd, response, sizeof(response)); + + spool_id = atoi(1 + rptp_parse(response, "id")); + + rptp_putline(rplay_fd, "put id=#%d size=0", spool_id); + rptp_getline(rplay_fd, response, sizeof(response)); + } + + return 0; +} + +int +ioctl(int fd, int request,...) +{ + static int (*func)(int, int, void *) = NULL; + va_list args; + void *argp; + + if (!func) + func = (int (*)(int, int, void *)) dlsym(REAL_LIBC, "ioctl"); + va_start(args, request); + argp = va_arg(args, void *); + va_end(args); + + if (fd != rplay_fd) + { + return (*func)(fd, request, argp); + } + else if (fd == rplay_fd) + { + return dspctl(fd, request, argp); + } +} + +ssize_t +write(int fd, const void *buf, size_t count) +{ + static int (*func)(int, const void *, size_t) = NULL; + + if (!func) + func = (int (*)(int, const void *, size_t)) dlsym(REAL_LIBC, "write"); + + if (fd == rplay_fd && !streaming) + { + char info[64]; + char response[RPTP_MAX_LINE]; + + info[0] = '\0'; + + /* use dsp defaults if something was specified */ + if (dsp_speed || dsp_fmt || dsp_channels) + { + if (!dsp_speed) dsp_speed = 8000; + if (!dsp_fmt) dsp_fmt = 8; + if (!dsp_channels) dsp_channels = 1; + sprintf(info, "input-info=%s,%d,%d,%d,%s", + dsp_fmt == 16 ? "linear16" : "ulinear8", + dsp_speed, + dsp_fmt, + dsp_channels, + "little-endian"); + } + /* try user specified sound info */ + else if (getinfo()) + { + strncpy(info, getinfo(), sizeof(info)-1); + } + /* otherwise let rplayd figure out the format using + the sound header and/or name. */ + + streaming = 1; + rptp_putline(rplay_fd, "play input=flow %s sound=\"%s\"", + info, getsound()); + rptp_getline(rplay_fd, response, sizeof(response)); + + spool_id = atoi(1 + rptp_parse(response, "id")); + + rptp_putline(rplay_fd, "put id=#%d size=0", spool_id); + rptp_getline(rplay_fd, response, sizeof(response)); + } + + return (*func)(fd, buf, count); +} + +int +close(int fd) +{ + static int (*func)(int) = NULL; + + if (!func) + func = (int (*)(int)) dlsym(REAL_LIBC, "close"); + + if (fd == rplay_fd) + { + rplay_fd = -1; + spool_id = -1; + streaming = 0; + dsp_fmt = dsp_speed = dsp_channels = dsp_speed = dsp_blksize = 0; + } + + return (*func)(fd); +} + +#endif /* linux */ diff --git a/doc/CVS/Entries b/doc/CVS/Entries deleted file mode 100644 index a410a79..0000000 --- a/doc/CVS/Entries +++ /dev/null @@ -1,21 +0,0 @@ -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998// -/RPLAY.info/1.1.1.1/Tue Jul 14 22:35:23 1998// -/RPLAY.texi/1.1.1.1/Tue Jul 14 22:35:23 1998// -/RPTP.info/1.1.1.1/Tue Jul 14 22:35:23 1998// -/RPTP.texi/1.1.1.1/Tue Jul 14 22:35:23 1998// -/genman/1.1.1.1/Tue Jul 14 22:35:23 1998// -/librplay.info/1.1.1.1/Tue Jul 14 22:35:23 1998// -/librplay.texi/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.1/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.1.in/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.conf.5/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.helpers.5/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.hosts.5/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.info/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.servers.5/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.texi/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplayd.8/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplayd.8.in/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rptp.1/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rptp.1.in/1.1.1.1/Tue Jul 14 22:35:23 1998// -D diff --git a/doc/CVS/Repository b/doc/CVS/Repository deleted file mode 100644 index 0d0e4d9..0000000 --- a/doc/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/doc diff --git a/doc/CVS/Root b/doc/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/doc/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/etc/CVS/Entries b/etc/CVS/Entries deleted file mode 100644 index d6d2f66..0000000 --- a/etc/CVS/Entries +++ /dev/null @@ -1,5 +0,0 @@ -/rplay.conf/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.hosts/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.servers/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rplay.helpers/1.2/Tue Oct 6 05:48:44 1998// -D diff --git a/etc/CVS/Repository b/etc/CVS/Repository deleted file mode 100644 index f9a597d..0000000 --- a/etc/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/etc diff --git a/etc/CVS/Root b/etc/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/etc/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/examples/CVS/Entries b/examples/CVS/Entries deleted file mode 100644 index 6ec3346..0000000 --- a/examples/CVS/Entries +++ /dev/null @@ -1,5 +0,0 @@ -/async1.c/1.2/Thu Aug 13 06:13:23 1998// -/async2.c/1.2/Thu Aug 13 06:13:24 1998// -/flow1.c/1.2/Thu Aug 13 06:13:25 1998// -/level.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -D diff --git a/examples/CVS/Repository b/examples/CVS/Repository deleted file mode 100644 index 53775e5..0000000 --- a/examples/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/examples diff --git a/examples/CVS/Root b/examples/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/examples/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/examples/async1.c b/examples/async1.c index 26b27f9..de2bc26 100644 --- a/examples/async1.c +++ b/examples/async1.c @@ -1,44 +1,44 @@ -/* $Id: async1.c,v 1.2 1998/08/13 06:13:23 boyns Exp $ */ +/* $Id: async1.c,v 1.3 1998/11/07 21:15:11 boyns Exp $ */ #include -static void event_callback (int fd, int event, char *line); +static void event_callback(int fd, int event, char *line); -main (int argc, char **argv) +main(int argc, char **argv) { char buf[RPTP_MAX_LINE]; int fd; - fd = rptp_open (rplay_default_host (), RPTP_PORT, buf, sizeof (buf)); + fd = rptp_open(rplay_default_host(), RPTP_PORT, buf, sizeof(buf)); - rptp_async_notify (fd, - RPTP_EVENT_PLAY|RPTP_EVENT_PAUSE|RPTP_EVENT_DONE|RPTP_EVENT_CONTINUE, - event_callback); + rptp_async_notify(fd, + RPTP_EVENT_PLAY | RPTP_EVENT_PAUSE | RPTP_EVENT_DONE | RPTP_EVENT_CONTINUE, + event_callback); - rptp_main_loop (); + rptp_main_loop(); - exit (0); + exit(0); } -static void -event_callback (int fd, int event, char *line) +static void +event_callback(int fd, int event, char *line) { switch (event) { case RPTP_EVENT_PLAY: - printf ("%s is playing\n", rptp_parse (line, "sound")); + printf("%s is playing\n", rptp_parse(line, "sound")); break; case RPTP_EVENT_PAUSE: - printf ("%s is paused\n", rptp_parse (line, "sound")); + printf("%s is paused\n", rptp_parse(line, "sound")); break; case RPTP_EVENT_DONE: - printf ("%s is done\n", rptp_parse (line, "sound")); + printf("%s is done\n", rptp_parse(line, "sound")); break; case RPTP_EVENT_CONTINUE: - printf ("%s continue\n", rptp_parse (line, "sound")); + printf("%s continue\n", rptp_parse(line, "sound")); break; } } diff --git a/examples/async2.c b/examples/async2.c index 0e0cd11..450c5a5 100644 --- a/examples/async2.c +++ b/examples/async2.c @@ -1,66 +1,66 @@ -/* $Id: async2.c,v 1.2 1998/08/13 06:13:24 boyns Exp $ */ +/* $Id: async2.c,v 1.3 1998/11/07 21:15:12 boyns Exp $ */ #include #include -static void process_input (int fd); -static void event_callback (int fd, int event, char *line); +static void process_input(int fd); +static void event_callback(int fd, int event, char *line); static int rptp_fd; -main (int argc, char **argv) +main(int argc, char **argv) { char buf[RPTP_MAX_LINE]; - rptp_fd = rptp_open (rplay_default_host (), RPTP_PORT, buf, sizeof (buf)); + rptp_fd = rptp_open(rplay_default_host(), RPTP_PORT, buf, sizeof(buf)); - rptp_async_register (0, RPTP_ASYNC_READ, process_input); - rptp_async_notify (rptp_fd, RPTP_EVENT_ALL, event_callback); + rptp_async_register(0, RPTP_ASYNC_READ, process_input); + rptp_async_notify(rptp_fd, RPTP_EVENT_ALL, event_callback); - rptp_main_loop (); + rptp_main_loop(); - exit (0); + exit(0); } static void -process_input (int fd) +process_input(int fd) { char buf[BUFSIZ]; - fgets (buf, sizeof (buf), stdin); - buf[strlen (buf) - 1] = '\0'; + fgets(buf, sizeof(buf), stdin); + buf[strlen(buf) - 1] = '\0'; - rptp_async_putline (rptp_fd, NULL, buf); + rptp_async_putline(rptp_fd, NULL, buf); } -static void -event_callback (int fd, int event, char *line) +static void +event_callback(int fd, int event, char *line) { - rptp_parse (line, 0); + rptp_parse(line, 0); switch (event) { case RPTP_EVENT_OK: - break; + break; case RPTP_EVENT_ERROR: - printf ("Error: %s\n", rptp_parse (0, "error")); - break; + printf("Error: %s\n", rptp_parse(0, "error")); + break; case RPTP_EVENT_PLAY: - printf ("[%s] Play %s\n", rptp_parse (0, "id"), rptp_parse (0, "sound")); + printf("[%s] Play %s\n", rptp_parse(0, "id"), rptp_parse(0, "sound")); break; case RPTP_EVENT_PAUSE: - printf ("[%s] Pause %s\n", rptp_parse (0, "id"), rptp_parse (0, "sound")); + printf("[%s] Pause %s\n", rptp_parse(0, "id"), rptp_parse(0, "sound")); break; case RPTP_EVENT_DONE: - printf ("[%s] Done %s\n", rptp_parse (0, "id"), rptp_parse (0, "sound")); + printf("[%s] Done %s\n", rptp_parse(0, "id"), rptp_parse(0, "sound")); break; case RPTP_EVENT_CONTINUE: - printf ("[%s] Continue %s\n", rptp_parse (0, "id"), rptp_parse (0, "sound")); + printf("[%s] Continue %s\n", rptp_parse(0, "id"), rptp_parse(0, "sound")); break; } } diff --git a/examples/flow1.c b/examples/flow1.c index 1c6cabd..1cf165d 100644 --- a/examples/flow1.c +++ b/examples/flow1.c @@ -1,4 +1,4 @@ -/* $Id: flow1.c,v 1.2 1998/08/13 06:13:25 boyns Exp $ */ +/* $Id: flow1.c,v 1.3 1998/11/07 21:15:12 boyns Exp $ */ /* usage: flow1 soundfile */ @@ -7,7 +7,7 @@ #include #include -main (int argc, char **argv) +main(int argc, char **argv) { FILE *fp; int rptp_fd, size, n, nwritten; @@ -18,95 +18,95 @@ char buf[8000]; /* First determine how big the audio file is. */ - if (stat (argv[1], &st) < 0) + if (stat(argv[1], &st) < 0) { - perror (argv[1]); - exit (1); + perror(argv[1]); + exit(1); } size = st.st_size; - fp = fopen (argv[1], "r"); + fp = fopen(argv[1], "r"); if (fp == NULL) { - perror (argv[1]); - exit (1); + perror(argv[1]); + exit(1); } /* Connect to the audio server. */ - rptp_fd = rptp_open (rplay_default_host (), RPTP_PORT, response, sizeof (response)); + rptp_fd = rptp_open(rplay_default_host(), RPTP_PORT, response, sizeof(response)); if (rptp_fd < 0) { - rptp_perror (rplay_default_host ()); - exit (1); + rptp_perror(rplay_default_host()); + exit(1); } /* Start the flow using `input-storage=none'. */ - sprintf (line, "play input=flow input-storage=none sound=%s", argv[1]); - switch (rptp_command (rptp_fd, line, response, sizeof (response))) + sprintf(line, "play input=flow input-storage=none sound=%s", argv[1]); + switch (rptp_command(rptp_fd, line, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - exit (1); + rptp_perror(argv[0]); + exit(1); case 1: - fprintf (stderr, "%s\n", rptp_parse (response, "error")); - exit (1); + fprintf(stderr, "%s\n", rptp_parse(response, "error")); + exit(1); case 0: break; } /* Save the spool id so `put' can use it later. */ - id = rptp_parse (response, "id"); + id = rptp_parse(response, "id"); /* Read chunks of audio from the file and send them to rplayd. rplayd will deal with flow-control. */ while (size > 0) { - n = fread (buf, 1, sizeof (buf), fp); + n = fread(buf, 1, sizeof(buf), fp); /* Use `put' to send the audio data. */ - sprintf (line, "put id=%s size=%d", id, n); - switch (rptp_command (rptp_fd, line, response, sizeof (response))) + sprintf(line, "put id=%s size=%d", id, n); + switch (rptp_command(rptp_fd, line, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - exit (1); + rptp_perror(argv[0]); + exit(1); case 1: - fprintf (stderr, "%s\n", rptp_parse (response, "error")); - exit (1); + fprintf(stderr, "%s\n", rptp_parse(response, "error")); + exit(1); case 0: break; } - nwritten = rptp_write (rptp_fd, buf, n); + nwritten = rptp_write(rptp_fd, buf, n); if (nwritten != n) { - rptp_perror ("flow"); + rptp_perror("flow"); break; } size -= nwritten; } - fclose (fp); + fclose(fp); /* Always send `done' when the flow is over. */ - sprintf (line, "done id=%s", id); - switch (rptp_command (rptp_fd, line, response, sizeof (response))) + sprintf(line, "done id=%s", id); + switch (rptp_command(rptp_fd, line, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - exit (1); + rptp_perror(argv[0]); + exit(1); case 1: - fprintf (stderr, "%s\n", rptp_parse (response, "error")); - exit (1); + fprintf(stderr, "%s\n", rptp_parse(response, "error")); + exit(1); case 0: break; } - exit (0); + exit(0); } diff --git a/examples/level.c b/examples/level.c index 5666704..26efc9a 100644 --- a/examples/level.c +++ b/examples/level.c @@ -1,34 +1,34 @@ #include -static void event_callback (int fd, int event, char *line); +static void event_callback(int fd, int event, char *line); -main (int argc, char **argv) +main(int argc, char **argv) { char buf[RPTP_MAX_LINE]; int fd; - fd = rptp_open (rplay_default_host (), RPTP_PORT, buf, sizeof (buf)); - rptp_async_notify (fd, RPTP_EVENT_LEVEL|RPTP_EVENT_CLOSE, event_callback); - rptp_main_loop (); + fd = rptp_open(rplay_default_host(), RPTP_PORT, buf, sizeof(buf)); + rptp_async_notify(fd, RPTP_EVENT_LEVEL | RPTP_EVENT_CLOSE, event_callback); + rptp_main_loop(); - exit (0); + exit(0); } -static void -event_callback (int fd, int event, char *line) +static void +event_callback(int fd, int event, char *line) { static int i; int left, right; - + switch (event) { case RPTP_EVENT_LEVEL: - left = atoi (rptp_parse (line, "left")); - right = atoi (rptp_parse (0, "right")); - printf ("%3d %3d\n", left, right); + left = atoi(rptp_parse(line, "left")); + right = atoi(rptp_parse(0, "right")); + printf("%3d %3d\n", left, right); break; case RPTP_EVENT_CLOSE: - exit (0); + exit(0); } } diff --git a/gsm/CVS/Entries b/gsm/CVS/Entries deleted file mode 100644 index 089f299..0000000 --- a/gsm/CVS/Entries +++ /dev/null @@ -1,40 +0,0 @@ -/COPYRIGHT/1.1.1.1/Tue Jul 14 22:35:24 1998// -/INSTALL/1.1.1.1/Tue Jul 14 22:35:24 1998// -/MACHINES/1.1.1.1/Tue Jul 14 22:35:24 1998// -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998// -/README/1.1.1.1/Tue Jul 14 22:35:24 1998// -/README.rplay/1.1.1.1/Tue Jul 14 22:35:24 1998// -/gsm.3/1.1.1.1/Tue Jul 14 22:35:24 1998// -/gsm_explode.3/1.1.1.1/Tue Jul 14 22:35:24 1998// -/gsm_option.3/1.1.1.1/Tue Jul 14 22:35:24 1998// -/gsm_print.3/1.1.1.1/Tue Jul 14 22:35:24 1998// -/toast.1/1.1.1.1/Tue Jul 14 22:35:24 1998// -/add.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/code.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/debug.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/decode.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/gsm.h/1.1.1.1/Thu Aug 13 06:09:31 1998// -/gsm_create.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/gsm_decode.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/gsm_destroy.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/gsm_encode.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/gsm_explode.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/gsm_implode.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/gsm_option.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/gsm_print.c/1.1.1.1/Thu Aug 13 06:09:31 1998// -/long_term.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/lpc.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/preprocess.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/private.h/1.1.1.1/Thu Aug 13 06:09:32 1998// -/proto.h/1.1.1.1/Thu Aug 13 06:09:32 1998// -/rpe.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/short_term.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/table.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/toast.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/toast.h/1.1.1.1/Thu Aug 13 06:09:32 1998// -/toast_alaw.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/toast_audio.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/toast_lin.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/toast_ulaw.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/unproto.h/1.1.1.1/Thu Aug 13 06:09:32 1998// -D diff --git a/gsm/CVS/Repository b/gsm/CVS/Repository deleted file mode 100644 index c5852f6..0000000 --- a/gsm/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/gsm diff --git a/gsm/CVS/Root b/gsm/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/gsm/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/include/CVS/Entries b/include/CVS/Entries deleted file mode 100644 index 05cc080..0000000 --- a/include/CVS/Entries +++ /dev/null @@ -1,5 +0,0 @@ -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:22 1998// -/rplay.h/1.2/Thu Aug 13 06:13:26 1998// -/config.h.in/1.2/Thu Aug 13 14:33:54 1998// -/version.h/1.3/Mon Oct 12 16:03:18 1998// -D diff --git a/include/CVS/Repository b/include/CVS/Repository deleted file mode 100644 index ad0faef..0000000 --- a/include/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/include diff --git a/include/CVS/Root b/include/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/include/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/include/config.h.in b/include/config.h.in index 2ad098d..b1a6562 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -1,7 +1,7 @@ -/* $Id: config.h.in,v 1.2 1998/08/13 14:33:54 boyns Exp $ -*- c -*- */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: config.h.in,v 1.4 1999/06/09 06:25:20 boyns Exp $ -*- c -*- */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -189,6 +189,9 @@ #undef HAVE_WAITPID #undef HAVE_SNPRINTF #undef HAVE_VSNPRINTF +#undef HAVE_LIBREADLINE +#undef HAVE_RANDOM +#undef HAVE_SRANDOM #undef HAVE_STDC_HEADERS #undef HAVE_MEMORY_H @@ -202,8 +205,10 @@ #undef HAVE_UTIME_H #undef HAVE_SYS_WAIT_H -#undef HAVE_FORMS_H -#undef HAVE_X11_FORMS_H +#undef HAVE_GSM_H +#undef HAVE_GSM_GSM_H +#undef HAVE_RXPOSIX_H +#undef HAVE_RX_RXPOSIX_H /* Convert HAVE_ to HAS_ for gsm. See gsm/include/config.h.gsm */ #ifdef HAVE_STDLIB_H @@ -259,8 +264,12 @@ * Solaris 2.x using gcc or SunPro cc and HP-UX */ #if (defined(sun) && (defined(__svr4__) || defined(SVR4))) || defined(__hpux) +#ifndef HAVE_RANDOM #define random() lrand48() +#endif +#ifndef HAVE_SRANDOM #define srandom(x) srand48(x) +#endif #endif #ifndef MIN diff --git a/include/rplay.h b/include/rplay.h index 82f9001..643a1c4 100644 --- a/include/rplay.h +++ b/include/rplay.h @@ -1,7 +1,7 @@ -/* $Id: rplay.h,v 1.2 1998/08/13 06:13:26 boyns Exp $ */ +/* $Id: rplay.h,v 1.3 1999/03/10 07:57:27 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/include/version.h b/include/version.h index 345d5ef..d45e189 100644 --- a/include/version.h +++ b/include/version.h @@ -1,7 +1,7 @@ -/* $Id: version.h,v 1.3 1998/10/12 16:03:18 boyns Exp $ */ +/* $Id: version.h,v 1.5 1999/03/10 07:57:27 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -27,7 +27,7 @@ #define RPLAY_MAJOR_VERSION 3 #define RPLAY_MINOR_VERSION 3 -#define RPLAY_PATCHLEVEL 1 +#define RPLAY_PATCHLEVEL 2 #define RPLAY_STATUS "" #endif /* _version_h */ diff --git a/java/CVS/Entries b/java/CVS/Entries deleted file mode 100644 index 381094d..0000000 --- a/java/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D/org//// diff --git a/java/CVS/Repository b/java/CVS/Repository deleted file mode 100644 index 0cc9622..0000000 --- a/java/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/java diff --git a/java/CVS/Root b/java/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/java/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/java/org/CVS/Entries b/java/org/CVS/Entries deleted file mode 100644 index 8f82690..0000000 --- a/java/org/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D/doit//// diff --git a/java/org/CVS/Repository b/java/org/CVS/Repository deleted file mode 100644 index 6b718ef..0000000 --- a/java/org/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/java/org diff --git a/java/org/CVS/Root b/java/org/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/java/org/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/java/org/doit/CVS/Entries b/java/org/doit/CVS/Entries deleted file mode 100644 index 81934df..0000000 --- a/java/org/doit/CVS/Entries +++ /dev/null @@ -1,2 +0,0 @@ -D/io//// -D/rplay//// diff --git a/java/org/doit/CVS/Repository b/java/org/doit/CVS/Repository deleted file mode 100644 index 7efa5f1..0000000 --- a/java/org/doit/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/java/org/doit diff --git a/java/org/doit/CVS/Root b/java/org/doit/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/java/org/doit/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/java/org/doit/io/CVS/Entries b/java/org/doit/io/CVS/Entries deleted file mode 100644 index 73283c3..0000000 --- a/java/org/doit/io/CVS/Entries +++ /dev/null @@ -1,2 +0,0 @@ -/ByteArray.java/1.2/Thu Aug 13 14:33:58 1998// -D diff --git a/java/org/doit/io/CVS/Repository b/java/org/doit/io/CVS/Repository deleted file mode 100644 index 5a1daa6..0000000 --- a/java/org/doit/io/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/java/org/doit/io diff --git a/java/org/doit/io/CVS/Root b/java/org/doit/io/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/java/org/doit/io/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/java/org/doit/rplay/CVS/Entries b/java/org/doit/rplay/CVS/Entries deleted file mode 100644 index 072066e..0000000 --- a/java/org/doit/rplay/CVS/Entries +++ /dev/null @@ -1,2 +0,0 @@ -/RPlay.java/1.3/Thu Aug 13 14:33:59 1998// -D diff --git a/java/org/doit/rplay/CVS/Repository b/java/org/doit/rplay/CVS/Repository deleted file mode 100644 index 5dbf7b7..0000000 --- a/java/org/doit/rplay/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/java/org/doit/rplay diff --git a/java/org/doit/rplay/CVS/Root b/java/org/doit/rplay/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/java/org/doit/rplay/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/lib/CVS/Entries b/lib/CVS/Entries deleted file mode 100644 index 5fe029b..0000000 --- a/lib/CVS/Entries +++ /dev/null @@ -1,13 +0,0 @@ -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998// -/hash.c/1.2/Thu Aug 13 06:13:29 1998// -/hash.h/1.2/Thu Aug 13 06:13:30 1998// -/strdup.c/1.2/Thu Aug 13 06:13:31 1998// -/strdup.h/1.2/Thu Aug 13 06:13:32 1998// -/tilde.c/1.2/Thu Aug 13 06:13:33 1998// -/xmalloc.c/1.2/Thu Aug 13 06:13:34 1998// -/ansidecl.h/1.1.1.1/Thu Aug 13 06:09:32 1998// -/getopt.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/getopt.h/1.1.1.1/Thu Aug 13 06:09:32 1998// -/getopt1.c/1.1.1.1/Thu Aug 13 06:09:32 1998// -/tilde.h/1.1.1.1/Thu Aug 13 06:09:32 1998// -D diff --git a/lib/CVS/Repository b/lib/CVS/Repository deleted file mode 100644 index 68edfa1..0000000 --- a/lib/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/lib diff --git a/lib/CVS/Root b/lib/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/lib/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/lib/strdup.c b/lib/strdup.c index c20c605..f157164 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -1,7 +1,7 @@ -/* $Id: strdup.c,v 1.2 1998/08/13 06:13:31 boyns Exp $ */ +/* $Id: strdup.c,v 1.4 1999/03/10 07:57:53 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,8 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ + - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -31,24 +31,24 @@ #ifndef HAVE_STRDUP #ifdef __STDC__ char * -strdup (char *str) +strdup(char *str) #else char * -strdup (str) - char *str; +strdup(str) + char *str; #endif { - char *p; + char *p; - p = (char *)malloc(strlen(str)+1); - if (p == NULL) - { - return NULL; - } - else - { - strcpy(p, str); - return p; - } + p = (char *) malloc(strlen(str) + 1); + if (p == NULL) + { + return NULL; + } + else + { + strcpy(p, str); + return p; + } } #endif /* HAVE_STRDUP */ diff --git a/lib/strdup.h b/lib/strdup.h index 39690cb..b1b9571 100644 --- a/lib/strdup.h +++ b/lib/strdup.h @@ -1,7 +1,7 @@ -/* $Id: strdup.h,v 1.2 1998/08/13 06:13:32 boyns Exp $ */ +/* $Id: strdup.h,v 1.3 1999/03/10 07:57:53 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/lib/tilde.c b/lib/tilde.c index 534a3e0..c6200c9 100644 --- a/lib/tilde.c +++ b/lib/tilde.c @@ -1,23 +1,25 @@ -/* $Id: tilde.c,v 1.2 1998/08/13 06:13:33 boyns Exp $ */ - -/* Copyright (C) 1988,1989 Free Software Foundation, Inc. - - This file is part of GNU Readline, a library for reading lines - of text with interactive input and history editing. - - Readline is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 1, or (at your option) any - later version. - - Readline is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Readline; see the file COPYING. If not, write to the Free - Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* $Id: tilde.c,v 1.3 1999/03/10 07:57:53 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns + * + * This file is part of rplay. + * + * rplay is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * rplay is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with rplay; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ #if defined (HAVE_CONFIG_H) # include "config.h" diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 6d8b6f7..6dd8895 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -1,23 +1,24 @@ -/* $Id: xmalloc.c,v 1.2 1998/08/13 06:13:34 boyns Exp $ */ +/* $Id: xmalloc.c,v 1.4 1999/03/10 07:57:53 boyns Exp $ */ -/* - * Copyright (C) 1994 Mark Boyns +/* + * Copyright (C) 1993-99 Mark R. Boyns * - * This file is part of rplay + * This file is part of rplay. * - * This program is free software; you can redistribute it and/or modify + * rplay is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * rplay is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with rplay; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #include "ansidecl.h" @@ -31,30 +32,30 @@ #ifdef __STDC__ PTR -xmalloc (size_t size) +xmalloc(size_t size) #else PTR -xmalloc (size) +xmalloc(size) size_t size; #endif { PTR p; - p = (PTR) malloc (size); + p = (PTR) malloc(size); if (p == 0) { - fprintf (stderr, "xmalloc: Virtual memory exhausted.\n"); - exit (1); + fprintf(stderr, "xmalloc: Virtual memory exhausted.\n"); + exit(1); } return p; } #ifdef __STDC__ PTR -xrealloc (PTR oldmem, size_t size) +xrealloc(PTR oldmem, size_t size) #else PTR -xrealloc (oldmem, size) +xrealloc(oldmem, size) PTR oldmem; size_t size; #endif @@ -66,14 +67,13 @@ size = 1; } - newmem = (oldmem) ? (PTR) realloc (oldmem, size) : (PTR) malloc (size); - + newmem = (oldmem) ? (PTR) realloc(oldmem, size) : (PTR) malloc(size); + if (!newmem) { - fprintf (stderr, "xrealloc: Virtual memory exhausted.\n"); - exit (1); + fprintf(stderr, "xrealloc: Virtual memory exhausted.\n"); + exit(1); } return newmem; } - diff --git a/librplay/CVS/Entries b/librplay/CVS/Entries deleted file mode 100644 index e270f4b..0000000 --- a/librplay/CVS/Entries +++ /dev/null @@ -1,5 +0,0 @@ -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:22 1998// -/async.c/1.2/Thu Aug 13 06:13:35 1998// -/rplay.c/1.3/Thu Aug 13 06:13:36 1998// -/rptp.c/1.2/Thu Aug 13 06:13:38 1998// -D diff --git a/librplay/CVS/Repository b/librplay/CVS/Repository deleted file mode 100644 index 7aa105a..0000000 --- a/librplay/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/librplay diff --git a/librplay/CVS/Root b/librplay/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/librplay/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/librplay/Makefile.in b/librplay/Makefile.in index 4cdbcd6..0f96411 100644 --- a/librplay/Makefile.in +++ b/librplay/Makefile.in @@ -9,15 +9,21 @@ MKINSTALLDIRS= @srcdir@/../mkinstalldirs CPPFLAGS= $(CC_OPTIONS) -I. -I../include -I@srcdir@/../include @DEFS@ +LDFLAGS= $(LD_OPTIONS) -shared @LDFLAGS@ .c.o: $(CC) -c $(CPPFLAGS) $(CFLAGS) $< +.SUFFIXES: .lo +.c.lo: + $(CC) -c -fPIC $(CPPFLAGS) $(CFLAGS) -o $@ $< + TARGET= $(LIBRPLAY_NAME) SRCS= rplay.c rptp.c async.c OBJS= rplay.o rptp.o async.o +SHAREDOBJS= rplay.lo rptp.lo async.lo -all: $(TARGET) +all: $(TARGET) librplay.so # # Use the following for SunOS 4.1.x, Solaris 2.x, Linux, NetBSD @@ -25,6 +31,9 @@ $(TARGET): $(OBJS) $(AR) rcv $@ $? $(RANLIB) $@ + +librplay.so: $(SHAREDOBJS) + $(CC) -o $@ $(SHAREDOBJS) $(LDFLAGS) # # For HP-UX comment above and uncomment below. @@ -41,12 +50,14 @@ install: all $(MKINSTALLDIRS) $(libdir) $(INSTALL_DATA) $(TARGET) $(libdir) + $(INSTALL_DATA) librplay.so $(libdir) uninstall: $(RM) $(libdir)/$(TARGET) + $(RM) $(libdir)/librplay.so clean: - $(RM) $(OBJS) $(TARGET) a.out core *~ *.bak *.orig TAGS + $(RM) $(OBJS) $(SHAREDOBJS) $(TARGET) librplay.so a.out core *~ *.bak *.orig TAGS distclean: clean $(RM) Makefile diff --git a/librplay/rplay.c b/librplay/rplay.c index 9de2bb3..6ca439e 100644 --- a/librplay/rplay.c +++ b/librplay/rplay.c @@ -1,7 +1,7 @@ -/* $Id: rplay.c,v 1.3 1998/08/13 06:13:36 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: rplay.c,v 1.6 1999/03/10 07:57:56 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,6 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifdef HAVE_CONFIG_H #include "config.h" @@ -74,33 +72,33 @@ "unknown rplay modifier", /* RPLAY_ERROR_MODIFIER */ }; /* -#ifdef __STDC__ -unsigned long inet_addr (char *rp); -#else -unsigned long inet_addr (); -#endif -*/ + #ifdef __STDC__ + unsigned long inet_addr (char *rp); + #else + unsigned long inet_addr (); + #endif + */ /* A simple version a strdup. */ #ifndef HAVE_STRDUP #ifdef __STDC__ static char * -strdup (char *str) +strdup(char *str) #else static char * -strdup (str) +strdup(str) char *str; #endif { char *p; - p = (char *) malloc (strlen (str) + 1); + p = (char *) malloc(strlen(str) + 1); if (p == NULL) { return NULL; } else { - strcpy (p, str); + strcpy(p, str); return p; } } @@ -111,15 +109,15 @@ */ #ifdef __STDC__ static RPLAY_ATTRS * -rplay_attrs_create (void) +rplay_attrs_create(void) #else static RPLAY_ATTRS * -rplay_attrs_create () +rplay_attrs_create() #endif { RPLAY_ATTRS *attrs; - attrs = (RPLAY_ATTRS *) malloc (sizeof (RPLAY_ATTRS)); + attrs = (RPLAY_ATTRS *) malloc(sizeof(RPLAY_ATTRS)); if (attrs == NULL) { return NULL; @@ -142,26 +140,26 @@ */ #ifdef __STDC__ static void -rplay_attrs_destroy (RPLAY_ATTRS *attrs) +rplay_attrs_destroy(RPLAY_ATTRS *attrs) #else static void -rplay_attrs_destroy (attrs) +rplay_attrs_destroy(attrs) RPLAY_ATTRS *attrs; #endif { if (*attrs->sound) { - free ((char *) attrs->sound); + free((char *) attrs->sound); } if (attrs->rptp_server) { - free ((char *) attrs->rptp_server); + free((char *) attrs->rptp_server); } if (*attrs->client_data) { - free ((char *) attrs->client_data); - } - free ((char *) attrs); + free((char *) attrs->client_data); + } + free((char *) attrs); } #define COPY_SIZE 128 @@ -196,10 +194,10 @@ */ #ifdef __STDC__ int -rplay_pack (RPLAY *rp) -#else -int -rplay_pack (rp) +rplay_pack(RPLAY *rp) +#else +int +rplay_pack(rp) RPLAY *rp; #endif { @@ -212,62 +210,62 @@ rp->len = 0; val = RPLAY_PACKET_ID; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); val = rp->command; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); if (rp->count != RPLAY_DEFAULT_LIST_COUNT) { val = RPLAY_LIST_COUNT; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); val = rp->count; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); } if (rp->priority != RPLAY_DEFAULT_PRIORITY) { val = RPLAY_PRIORITY; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); val = rp->priority; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); } if (*rp->list_name) { val = RPLAY_LIST_NAME; - COPY (rp, &val, sizeof (val)); - len = strlen (rp->list_name) + 1; - COPY (rp, rp->list_name, len); + COPY(rp, &val, sizeof(val)); + len = strlen(rp->list_name) + 1; + COPY(rp, rp->list_name, len); } if (rp->id != RPLAY_NULL) { val = RPLAY_ID; - COPY (rp, &val, sizeof (val)); - val = rp->id; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); + lval = htonl(rp->id); + COPY(rp, &lval, sizeof(lval)); } if (rp->sequence != -1) { val = RPLAY_SEQUENCE; - COPY (rp, &val, sizeof (val)); - lval = htonl (rp->sequence); - COPY (rp, &lval, sizeof (lval)); + COPY(rp, &val, sizeof(val)); + lval = htonl(rp->sequence); + COPY(rp, &lval, sizeof(lval)); } if (rp->data != RPLAY_NULL && rp->data_size > 0) { val = RPLAY_DATA_SIZE; - COPY (rp, &val, sizeof (val)); - sval = htons (rp->data_size); - COPY (rp, &sval, sizeof (sval)); - + COPY(rp, &val, sizeof(val)); + sval = htons(rp->data_size); + COPY(rp, &sval, sizeof(sval)); + val = RPLAY_DATA; - COPY (rp, &val, sizeof (val)); - COPY (rp, rp->data, rp->data_size); - } - + COPY(rp, &val, sizeof(val)); + COPY(rp, rp->data, rp->data_size); + } + for (i = 0, attrs = rp->attrs; attrs; attrs = attrs->next, i++) { if (rp->random_sound != RPLAY_DEFAULT_RANDOM_SOUND) @@ -281,79 +279,79 @@ if (*attrs->sound) { val = RPLAY_SOUND; - COPY (rp, &val, sizeof (val)); - len = strlen (attrs->sound) + 1; - COPY (rp, attrs->sound, len); + COPY(rp, &val, sizeof(val)); + len = strlen(attrs->sound) + 1; + COPY(rp, attrs->sound, len); } if (attrs->volume != RPLAY_DEFAULT_VOLUME) { val = RPLAY_VOLUME; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); val = attrs->volume; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); } if (attrs->count != RPLAY_DEFAULT_COUNT) { val = RPLAY_COUNT; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); val = attrs->count; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); } if (attrs->rptp_server) { val = RPLAY_RPTP_SERVER; - COPY (rp, &val, sizeof (val)); - len = strlen (attrs->rptp_server) + 1; - COPY (rp, attrs->rptp_server, len); + COPY(rp, &val, sizeof(val)); + len = strlen(attrs->rptp_server) + 1; + COPY(rp, attrs->rptp_server, len); } if (attrs->rptp_server_port != RPTP_PORT) { val = RPLAY_RPTP_SERVER_PORT; - COPY (rp, &val, sizeof (val)); - size = htons (attrs->rptp_server_port); - COPY (rp, &size, sizeof (size)); + COPY(rp, &val, sizeof(val)); + size = htons(attrs->rptp_server_port); + COPY(rp, &size, sizeof(size)); } if (attrs->rptp_search == FALSE) { val = RPLAY_RPTP_SEARCH; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); val = attrs->rptp_search; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); } if (attrs->sample_rate != RPLAY_DEFAULT_SAMPLE_RATE) { val = RPLAY_SAMPLE_RATE; - COPY (rp, &val, sizeof (val)); - lval = htonl (attrs->sample_rate); - COPY (rp, &lval, sizeof (lval)); + COPY(rp, &val, sizeof(val)); + lval = htonl(attrs->sample_rate); + COPY(rp, &lval, sizeof(lval)); } if (*attrs->client_data) { val = RPLAY_CLIENT_DATA; - COPY (rp, &val, sizeof (val)); - len = strlen (attrs->client_data) + 1; - COPY (rp, attrs->client_data, len); + COPY(rp, &val, sizeof(val)); + len = strlen(attrs->client_data) + 1; + COPY(rp, attrs->client_data, len); } val = RPLAY_NULL; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); } if (i == 0) { val = RPLAY_NULL; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); } val = RPLAY_NULL; - COPY (rp, &val, sizeof (val)); + COPY(rp, &val, sizeof(val)); return 0; } @@ -363,10 +361,10 @@ */ #ifdef __STDC__ RPLAY * -rplay_unpack (char *packet) +rplay_unpack(char *packet) #else RPLAY * -rplay_unpack (packet) +rplay_unpack(packet) char *packet; #endif { @@ -377,14 +375,14 @@ rplay_errno = RPLAY_ERROR_NONE; version = *packet++; - rp = rplay_create (*packet++); + rp = rplay_create(*packet++); if (rp == NULL) { rplay_errno = RPLAY_ERROR_MEMORY; return NULL; } - *(rp->attrsp) = rplay_attrs_create (); + *(rp->attrsp) = rplay_attrs_create(); if (*(rp->attrsp) == NULL) { rplay_errno = RPLAY_ERROR_MEMORY; @@ -400,17 +398,17 @@ break; case RPLAY_LIST_NAME: - rp->list_name = strdup (packet); - packet += strlen (packet) + 1; + rp->list_name = strdup(packet); + packet += strlen(packet) + 1; break; - + case RPLAY_PRIORITY: rp->priority = (unsigned char) *packet++; break; case RPLAY_SOUND: - (*rp->attrsp)->sound = strdup (packet); - packet += strlen (packet) + 1; + (*rp->attrsp)->sound = strdup(packet); + packet += strlen(packet) + 1; break; case RPLAY_VOLUME: @@ -422,14 +420,14 @@ break; case RPLAY_RPTP_SERVER: - (*rp->attrsp)->rptp_server = strdup (packet); - packet += strlen (packet) + 1; + (*rp->attrsp)->rptp_server = strdup(packet); + packet += strlen(packet) + 1; break; case RPLAY_RPTP_SERVER_PORT: - memcpy ((char *) &(*rp->attrsp)->rptp_server_port, packet, sizeof ((*rp->attrsp)->rptp_server_port)); - (*rp->attrsp)->rptp_server_port = ntohs ((*rp->attrsp)->rptp_server_port); - packet += sizeof ((*rp->attrsp)->rptp_server_port); + memcpy((char *) &(*rp->attrsp)->rptp_server_port, packet, sizeof((*rp->attrsp)->rptp_server_port)); + (*rp->attrsp)->rptp_server_port = ntohs((*rp->attrsp)->rptp_server_port); + packet += sizeof((*rp->attrsp)->rptp_server_port); break; @@ -438,38 +436,41 @@ break; case RPLAY_SAMPLE_RATE: - memcpy ((char *) &(*rp->attrsp)->sample_rate, packet, sizeof ((*rp->attrsp)->sample_rate)); - (*rp->attrsp)->sample_rate = ntohl ((*rp->attrsp)->sample_rate); - packet += sizeof ((*rp->attrsp)->sample_rate); + memcpy((char *) &(*rp->attrsp)->sample_rate, packet, + sizeof((*rp->attrsp)->sample_rate)); + (*rp->attrsp)->sample_rate = ntohl((*rp->attrsp)->sample_rate); + packet += sizeof((*rp->attrsp)->sample_rate); break; case RPLAY_CLIENT_DATA: - (*rp->attrsp)->client_data = strdup (packet); - packet += strlen (packet) + 1; + (*rp->attrsp)->client_data = strdup(packet); + packet += strlen(packet) + 1; break; case RPLAY_ID: - rp->id = (unsigned char) *packet++; + memcpy((char *) &rp->id, packet, sizeof(rp->id)); + rp->id = ntohl(rp->id); + packet += sizeof(rp->id); break; case RPLAY_SEQUENCE: - memcpy ((char *) &rp->sequence, packet, sizeof (rp->sequence)); - rp->sequence = ntohl (rp->sequence); - packet += sizeof (rp->sequence); + memcpy((char *) &rp->sequence, packet, sizeof(rp->sequence)); + rp->sequence = ntohl(rp->sequence); + packet += sizeof(rp->sequence); break; case RPLAY_DATA_SIZE: - memcpy ((char *) &rp->data_size, packet, sizeof (rp->data_size)); - rp->data_size = ntohs (rp->data_size); - packet += sizeof (rp->data_size); + memcpy((char *) &rp->data_size, packet, sizeof(rp->data_size)); + rp->data_size = ntohs(rp->data_size); + packet += sizeof(rp->data_size); break; case RPLAY_DATA: - rp->data = (char *) malloc (rp->data_size); - memcpy (rp->data, packet, rp->data_size); + rp->data = (char *) malloc(rp->data_size); + memcpy(rp->data, packet, rp->data_size); packet += rp->data_size; break; - + case RPLAY_NULL: rp->nsounds++; rp->attrsp = &(*rp->attrsp)->next; @@ -479,7 +480,7 @@ } else { - *(rp->attrsp) = rplay_attrs_create (); + *(rp->attrsp) = rplay_attrs_create(); if (*(rp->attrsp) == NULL) { rplay_errno = RPLAY_ERROR_MEMORY; @@ -491,7 +492,7 @@ default: rplay_errno = RPLAY_ERROR_ATTRIBUTE; #if 1 - printf ("unpack: unknown attr '%d'\n", *packet); + printf("unpack: unknown attr '%d'\n", *packet); #endif return NULL; } @@ -508,10 +509,10 @@ */ #ifdef __STDC__ RPLAY * -rplay_create (int command) +rplay_create(int command) #else RPLAY * -rplay_create (command) +rplay_create(command) int command; #endif { @@ -519,7 +520,7 @@ rplay_errno = RPLAY_ERROR_NONE; - rp = (RPLAY *) malloc (sizeof (RPLAY)); + rp = (RPLAY *) malloc(sizeof(RPLAY)); if (rp == NULL) { rplay_errno = RPLAY_ERROR_MEMORY; @@ -528,7 +529,7 @@ rp->attrs = NULL; rp->attrsp = &rp->attrs; - rp->buf = (char *) malloc (COPY_SIZE); + rp->buf = (char *) malloc(COPY_SIZE); if (rp->buf == NULL) { rplay_errno = RPLAY_ERROR_MEMORY; @@ -547,7 +548,7 @@ rp->sequence = -1; rp->data = NULL; rp->data_size = 0; - + switch (command) { case RPLAY_PLAY: @@ -574,10 +575,10 @@ */ #ifdef __STDC__ static RPLAY_ATTRS * -get_attrs (RPLAY_ATTRS *attrs, int index) +get_attrs(RPLAY_ATTRS *attrs, int index) #else static RPLAY_ATTRS * -get_attrs (attrs, index) +get_attrs(attrs, index) RPLAY_ATTRS *attrs; int index; #endif @@ -602,10 +603,10 @@ */ #ifdef __STDC__ long -rplay_set (RPLAY *rp,...) +rplay_set(RPLAY *rp,...) #else long -rplay_set (va_alist) +rplay_set(va_alist) va_dcl #endif { @@ -616,21 +617,21 @@ time_t seed; #ifdef __STDC__ - va_start (args, rp); + va_start(args, rp); #else RPLAY *rp; - va_start (args); - rp = va_arg (args, RPLAY *); + va_start(args); + rp = va_arg(args, RPLAY *); #endif rplay_errno = RPLAY_ERROR_NONE; - modifier = va_arg (args, long); + modifier = va_arg(args, long); switch (modifier) { case RPLAY_APPEND: - *(rp->attrsp) = attrs = rplay_attrs_create (); + *(rp->attrsp) = attrs = rplay_attrs_create(); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_MEMORY; @@ -641,7 +642,7 @@ break; case RPLAY_INSERT: - index = va_arg (args, long); + index = va_arg(args, long); if (index < 0) { rplay_errno = RPLAY_ERROR_INDEX; @@ -657,7 +658,7 @@ rplay_errno = RPLAY_ERROR_INDEX; return -1; } - attrs = rplay_attrs_create (); + attrs = rplay_attrs_create(); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_MEMORY; @@ -680,7 +681,7 @@ break; case RPLAY_DELETE: - index = va_arg (args, long); + index = va_arg(args, long); if (index < 0) { rplay_errno = RPLAY_ERROR_INDEX; @@ -712,13 +713,13 @@ rp->attrsp = &rp->attrs; } } - rplay_attrs_destroy (curr); + rplay_attrs_destroy(curr); rp->nsounds--; break; case RPLAY_CHANGE: - index = va_arg (args, long); - attrs = get_attrs (rp->attrs, index); + index = va_arg(args, long); + attrs = get_attrs(rp->attrs, index); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_INDEX; @@ -727,33 +728,33 @@ break; case RPLAY_LIST_COUNT: - rp->count = va_arg (args, long); + rp->count = va_arg(args, long); break; case RPLAY_LIST_NAME: if (*rp->list_name) { - free ((char *) rp->list_name); - } - rp->list_name = strdup (va_arg (args, char *)); + free((char *) rp->list_name); + } + rp->list_name = strdup(va_arg(args, char *)); break; - + case RPLAY_PRIORITY: - rp->priority = va_arg (args, long); + rp->priority = va_arg(args, long); break; case RPLAY_RANDOM_SOUND: - seed = time (0); - srandom ((int) seed); - rp->random_sound = (int) (random () % rp->nsounds); + seed = time(0); + srandom((int) seed); + rp->random_sound = (int) (random() % rp->nsounds); break; case RPLAY_ID: - rp->id = va_arg (args, long); + rp->id = va_arg(args, long); break; case RPLAY_SEQUENCE: - rp->sequence = va_arg (args, unsigned long); + rp->sequence = va_arg(args, unsigned long); break; case RPLAY_DATA_SIZE: @@ -763,20 +764,20 @@ case RPLAY_DATA: if (rp->data) { - free ((char *) rp->data); - } - - data = va_arg (args, char *); - rp->data_size = va_arg (args, long); - rp->data = (char *) malloc (rp->data_size); + free((char *) rp->data); + } + + data = va_arg(args, char *); + rp->data_size = va_arg(args, long); + rp->data = (char *) malloc(rp->data_size); if (rp->data == NULL) { rplay_errno = RPLAY_ERROR_MEMORY; return -1; } - memcpy (rp->data, data, rp->data_size); + memcpy(rp->data, data, rp->data_size); break; - + default: rplay_errno = RPLAY_ERROR_MODIFIER; return -1; @@ -786,40 +787,40 @@ { int attribute; - while ((attribute = va_arg (args, long))) + while ((attribute = va_arg(args, long))) { switch (attribute) { case RPLAY_LIST_COUNT: - rp->count = va_arg (args, long); + rp->count = va_arg(args, long); break; case RPLAY_LIST_NAME: if (*rp->list_name) { - free ((char *) rp->list_name); + free((char *) rp->list_name); } - rp->list_name = strdup (va_arg (args, char *)); + rp->list_name = strdup(va_arg(args, char *)); break; - + case RPLAY_PRIORITY: - rp->priority = va_arg (args, long); + rp->priority = va_arg(args, long); break; case RPLAY_SOUND: if (*attrs->sound) { - free ((char *) attrs->sound); + free((char *) attrs->sound); } - attrs->sound = strdup (va_arg (args, char *)); + attrs->sound = strdup(va_arg(args, char *)); break; case RPLAY_VOLUME: - attrs->volume = va_arg (args, long); + attrs->volume = va_arg(args, long); break; case RPLAY_COUNT: - attrs->count = va_arg (args, long); + attrs->count = va_arg(args, long); break; case RPLAY_RPTP_SERVER: @@ -828,12 +829,12 @@ struct hostent *hp; u_long addr; struct sockaddr_in s; - char *host = va_arg (args, char *); + char *host = va_arg(args, char *); char hostname[MAXHOSTNAMELEN]; if (attribute == RPLAY_RPTP_FROM_SENDER) { - if (gethostname (hostname, sizeof (hostname)) < 0) + if (gethostname(hostname, sizeof(hostname)) < 0) { rplay_errno = RPLAY_ERROR_HOST; return -1; @@ -842,49 +843,49 @@ } else { - host = va_arg (args, char *); + host = va_arg(args, char *); } - memset ((char *) &s, 0, sizeof (s)); - addr = inet_addr (host); + memset((char *) &s, 0, sizeof(s)); + addr = inet_addr(host); if (addr == 0xffffffff) { - hp = gethostbyname (host); + hp = gethostbyname(host); if (hp == NULL) { rplay_errno = RPLAY_ERROR_HOST; return -1; } - memcpy ((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); + memcpy((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); } else { - memcpy ((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof (addr)); + memcpy((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof(addr)); } - attrs->rptp_server = strdup ((char *) inet_ntoa (s.sin_addr)); + attrs->rptp_server = strdup((char *) inet_ntoa(s.sin_addr)); break; } case RPLAY_RPTP_SERVER_PORT: - attrs->rptp_server_port = (unsigned short) va_arg (args, long); + attrs->rptp_server_port = (unsigned short) va_arg(args, long); break; case RPLAY_RPTP_SEARCH: - attrs->rptp_search = va_arg (args, long); + attrs->rptp_search = va_arg(args, long); break; case RPLAY_SAMPLE_RATE: - attrs->sample_rate = va_arg (args, unsigned long); + attrs->sample_rate = va_arg(args, unsigned long); break; case RPLAY_CLIENT_DATA: if (*attrs->client_data) { - free ((char *) attrs->client_data); + free((char *) attrs->client_data); } - attrs->client_data = strdup (va_arg (args, char *)); + attrs->client_data = strdup(va_arg(args, char *)); break; - + default: rplay_errno = RPLAY_ERROR_ATTRIBUTE; return -1; @@ -892,7 +893,7 @@ } } - return rplay_pack (rp); + return rplay_pack(rp); } /* @@ -900,10 +901,10 @@ */ #ifdef __STDC__ long -rplay_get (RPLAY *rp,...) +rplay_get(RPLAY *rp,...) #else long -rplay_get (va_alist) +rplay_get(va_alist) va_dcl #endif { @@ -912,15 +913,15 @@ int get, index; #ifdef __STDC__ - va_start (args, rp); + va_start(args, rp); #else RPLAY *rp; - va_start (args); - rp = va_arg (args, RPLAY *); + va_start(args); + rp = va_arg(args, RPLAY *); #endif rplay_errno = RPLAY_ERROR_NONE; - get = va_arg (args, long); + get = va_arg(args, long); switch (get) { @@ -935,7 +936,7 @@ case RPLAY_LIST_NAME: return (long) rp->list_name; - + case RPLAY_PRIORITY: return rp->priority; @@ -953,10 +954,10 @@ case RPLAY_DATA: return (long) rp->data; - + case RPLAY_SOUND: - index = va_arg (args, long); - attrs = get_attrs (rp->attrs, index); + index = va_arg(args, long); + attrs = get_attrs(rp->attrs, index); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_INDEX; @@ -965,8 +966,8 @@ return (long) attrs->sound; case RPLAY_VOLUME: - index = va_arg (args, long); - attrs = get_attrs (rp->attrs, index); + index = va_arg(args, long); + attrs = get_attrs(rp->attrs, index); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_INDEX; @@ -975,8 +976,8 @@ return attrs->volume; case RPLAY_COUNT: - index = va_arg (args, long); - attrs = get_attrs (rp->attrs, index); + index = va_arg(args, long); + attrs = get_attrs(rp->attrs, index); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_INDEX; @@ -985,8 +986,8 @@ return attrs->count; case RPLAY_RPTP_SERVER: - index = va_arg (args, long); - attrs = get_attrs (rp->attrs, index); + index = va_arg(args, long); + attrs = get_attrs(rp->attrs, index); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_INDEX; @@ -995,8 +996,8 @@ return (long) attrs->rptp_server; case RPLAY_RPTP_SERVER_PORT: - index = va_arg (args, long); - attrs = get_attrs (rp->attrs, index); + index = va_arg(args, long); + attrs = get_attrs(rp->attrs, index); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_INDEX; @@ -1005,8 +1006,8 @@ return (long) attrs->rptp_server_port; case RPLAY_RPTP_SEARCH: - index = va_arg (args, long); - attrs = get_attrs (rp->attrs, index); + index = va_arg(args, long); + attrs = get_attrs(rp->attrs, index); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_INDEX; @@ -1015,8 +1016,8 @@ return attrs->rptp_search; case RPLAY_SAMPLE_RATE: - index = va_arg (args, long); - attrs = get_attrs (rp->attrs, index); + index = va_arg(args, long); + attrs = get_attrs(rp->attrs, index); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_INDEX; @@ -1025,15 +1026,15 @@ return attrs->sample_rate; case RPLAY_CLIENT_DATA: - index = va_arg (args, int); - attrs = get_attrs (rp->attrs, index); + index = va_arg(args, int); + attrs = get_attrs(rp->attrs, index); if (attrs == NULL) { rplay_errno = RPLAY_ERROR_INDEX; return -1; } return (long) attrs->client_data; - + default: rplay_errno = RPLAY_ERROR_ATTRIBUTE; return -1; @@ -1045,10 +1046,10 @@ */ #ifdef __STDC__ void -rplay_destroy (RPLAY *rp) +rplay_destroy(RPLAY *rp) #else void -rplay_destroy (rp) +rplay_destroy(rp) RPLAY *rp; #endif { @@ -1056,17 +1057,17 @@ rplay_errno = RPLAY_ERROR_NONE; - for (p = rp->attrs; p; q = p, p = p->next, rplay_attrs_destroy (q)) ; + for (p = rp->attrs; p; q = p, p = p->next, rplay_attrs_destroy(q)) ; if (*rp->list_name) { - free ((char *) rp->list_name); + free((char *) rp->list_name); } if (rp->data) { - free ((char *) rp->data); - } - free ((char *) rp->buf); - free ((char *) rp); + free((char *) rp->data); + } + free((char *) rp->buf); + free((char *) rp); } /* @@ -1075,10 +1076,10 @@ #ifdef OLD_RPLAY #ifdef __STDC__ char * -rplay_convert (char *p) +rplay_convert(char *p) #else char * -rplay_convert (p) +rplay_convert(p) char *p; #endif { @@ -1109,8 +1110,8 @@ do { *q++ = RPLAY_SOUND; - strcpy (q, p); - len = strlen (p) + 1; + strcpy(q, p); + len = strlen(p) + 1; p += len; q += len; *q++ = RPLAY_VOLUME; @@ -1126,15 +1127,15 @@ #endif /* OLD_RPLAY */ static int -default_rplay_port () +default_rplay_port() { struct servent *sp; int port; - sp = getservbyname ("rplay", "udp"); + sp = getservbyname("rplay", "udp"); if (sp) { - port = ntohs (sp->s_port); /* htons is used later */ + port = ntohs(sp->s_port); /* htons is used later */ } else { @@ -1146,18 +1147,18 @@ #ifdef __STDC__ int -rplay_open (char *host) -#else -int -rplay_open (host) +rplay_open(char *host) +#else +int +rplay_open(host) char *host; #endif { int port; - port = default_rplay_port (); - - return rplay_open_port (host, port); + port = default_rplay_port(); + + return rplay_open_port(host, port); } /* @@ -1167,10 +1168,10 @@ */ #ifdef __STDC__ int -rplay_open_port (char *host, int port) -#else -int -rplay_open_port (host, port) +rplay_open_port(char *host, int port) +#else +int +rplay_open_port(host, port) char *host; int port; #endif @@ -1181,43 +1182,43 @@ rplay_errno = RPLAY_ERROR_NONE; - memset ((char *) &s, 0, sizeof (s)); - - addr = inet_addr (host); + memset((char *) &s, 0, sizeof(s)); + + addr = inet_addr(host); if (addr == 0xffffffff) { - hp = gethostbyname (host); + hp = gethostbyname(host); if (hp == NULL) { rplay_errno = RPLAY_ERROR_HOST; return -1; } - memcpy ((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); + memcpy((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); } else { - memcpy ((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof (addr)); - } - - s.sin_port = htons (port); + memcpy((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof(addr)); + } + + s.sin_port = htons(port); s.sin_family = AF_INET; - return rplay_open_sockaddr_in (&s); -} - -#ifdef __STDC__ -int -rplay_open_sockaddr_in (struct sockaddr_in *saddr) -#else -int -rplay_open_sockaddr_in (saddr) + return rplay_open_sockaddr_in(&s); +} + +#ifdef __STDC__ +int +rplay_open_sockaddr_in(struct sockaddr_in *saddr) +#else +int +rplay_open_sockaddr_in(saddr) struct sockaddr_in *saddr; #endif { int rplay_fd; int on = 1; - rplay_fd = socket (AF_INET, SOCK_DGRAM, 0); + rplay_fd = socket(AF_INET, SOCK_DGRAM, 0); if (rplay_fd < 0) { rplay_errno = RPLAY_ERROR_SOCKET; @@ -1227,13 +1228,13 @@ /* * enable broadcasting */ - if (setsockopt (rplay_fd, SOL_SOCKET, SO_BROADCAST, (char *) &on, sizeof (on)) < 0) + if (setsockopt(rplay_fd, SOL_SOCKET, SO_BROADCAST, (char *) &on, sizeof(on)) < 0) { rplay_errno = RPLAY_ERROR_BROADCAST; return -1; } - if (connect (rplay_fd, (struct sockaddr *) saddr, sizeof (*saddr)) < 0) + if (connect(rplay_fd, (struct sockaddr *) saddr, sizeof(*saddr)) < 0) { rplay_errno = RPLAY_ERROR_CONNECT; return -1; @@ -1247,17 +1248,17 @@ */ #ifdef __STDC__ int -rplay (int rplay_fd, RPLAY *rp) -#else -int -rplay (rplay_fd, rp) +rplay(int rplay_fd, RPLAY *rp) +#else +int +rplay(rplay_fd, rp) int rplay_fd; RPLAY *rp; #endif { rplay_errno = RPLAY_ERROR_NONE; - if (write (rplay_fd, rp->buf, rp->len) != rp->len) + if (write(rplay_fd, rp->buf, rp->len) != rp->len) { rplay_errno = RPLAY_ERROR_WRITE; return -1; @@ -1271,16 +1272,16 @@ */ #ifdef __STDC__ int -rplay_close (int rplay_fd) -#else -int -rplay_close (rplay_fd) +rplay_close(int rplay_fd) +#else +int +rplay_close(rplay_fd) int rplay_fd; #endif { rplay_errno = RPLAY_ERROR_NONE; - if (close (rplay_fd) < 0) + if (close(rplay_fd) < 0) { rplay_errno = RPLAY_ERROR_CLOSE; return -1; @@ -1294,14 +1295,14 @@ */ #ifdef __STDC__ void -rplay_perror (char *s) +rplay_perror(char *s) #else void -rplay_perror (s) +rplay_perror(s) char *s; #endif { - fprintf (stderr, "%s: %s\n", s, rplay_errlist[rplay_errno]); + fprintf(stderr, "%s: %s\n", s, rplay_errlist[rplay_errno]); } /* @@ -1310,35 +1311,35 @@ */ #ifdef __STDC__ int -rplay_open_display (void) -#else -int -rplay_open_display () +rplay_open_display(void) +#else +int +rplay_open_display() #endif { char *display, *p; char host[MAXHOSTNAMELEN]; - display = getenv ("DISPLAY"); + display = getenv("DISPLAY"); if (display == NULL || display[0] == ':') { - strcpy (host, "localhost"); + strcpy(host, "localhost"); } else { - strcpy (host, display); - p = strchr (host, ':'); + strcpy(host, display); + p = strchr(host, ':'); if (p) { *p = '\0'; } - if (strcmp (host, "unix") == 0 || strcmp (host, "local") == 0 || strcmp (host, "X") == 0) - { - strcpy (host, "localhost"); - } - } - - return rplay_open (host); + if (strcmp(host, "unix") == 0 || strcmp(host, "local") == 0 || strcmp(host, "X") == 0) + { + strcpy(host, "localhost"); + } + } + + return rplay_open(host); } /* @@ -1346,22 +1347,22 @@ */ #ifdef __STDC__ int -rplay_display (char *sound) -#else -int -rplay_display (sound) +rplay_display(char *sound) +#else +int +rplay_display(sound) char *sound; #endif { int rplay_fd; - rplay_fd = rplay_open_display (); + rplay_fd = rplay_open_display(); if (rplay_fd < 0) { return -1; } - return rplay_sound (rplay_fd, sound); + return rplay_sound(rplay_fd, sound); } /* @@ -1369,14 +1370,14 @@ */ #ifdef __STDC__ int -rplay_local (char *sound) -#else -int -rplay_local (sound) +rplay_local(char *sound) +#else +int +rplay_local(sound) char *sound; #endif { - return rplay_host ("localhost", sound); + return rplay_host("localhost", sound); } /* @@ -1384,23 +1385,23 @@ */ #ifdef __STDC__ int -rplay_host (char *host, char *sound) -#else -int -rplay_host (host, sound) +rplay_host(char *host, char *sound) +#else +int +rplay_host(host, sound) char *host; char *sound; #endif { int rplay_fd; - rplay_fd = rplay_open (host); + rplay_fd = rplay_open(host); if (rplay_fd < 0) { return -1; } - return rplay_sound (rplay_fd, sound); + return rplay_sound(rplay_fd, sound); } /* @@ -1408,33 +1409,33 @@ */ #ifdef __STDC__ int -rplay_sound (int rplay_fd, char *sound) -#else -int -rplay_sound (rplay_fd, sound) +rplay_sound(int rplay_fd, char *sound) +#else +int +rplay_sound(rplay_fd, sound) int rplay_fd; char *sound; #endif { RPLAY *rp; - rp = rplay_create (RPLAY_PLAY); + rp = rplay_create(RPLAY_PLAY); if (rp == NULL) { return -1; } - if (rplay_set (rp, RPLAY_APPEND, RPLAY_SOUND, sound, NULL) < 0) - { - return -1; - } - - if (rplay (rplay_fd, rp) < 0) - { - return -1; - } - - rplay_destroy (rp); + if (rplay_set(rp, RPLAY_APPEND, RPLAY_SOUND, sound, NULL) < 0) + { + return -1; + } + + if (rplay(rplay_fd, rp) < 0) + { + return -1; + } + + rplay_destroy(rp); return 0; } @@ -1444,10 +1445,10 @@ */ #ifdef __STDC__ int -rplay_ping (char *host) -#else -int -rplay_ping (host) +rplay_ping(char *host) +#else +int +rplay_ping(host) char *host; #endif { @@ -1456,13 +1457,13 @@ int error1 = 0, error2 = 0; /* Ping the default port. */ - port = default_rplay_port (); - rplay_fd = rplay_open_port (host, port); + port = default_rplay_port(); + rplay_fd = rplay_open_port(host, port); if (rplay_fd < 0) { return -1; } - error1 = rplay_ping_sockfd (rplay_fd); + error1 = rplay_ping_sockfd(rplay_fd); #ifdef OTHER_RPLAY_PORTS /* Pick an alternative port. */ @@ -1476,12 +1477,12 @@ } /* Ping the alternative port. */ - rplay_fd = rplay_open_port (host, port); + rplay_fd = rplay_open_port(host, port); if (rplay_fd < 0) { return -1; } - error2 = rplay_ping_sockfd (rplay_fd); + error2 = rplay_ping_sockfd(rplay_fd); #endif /* OTHER_RPLAY_PORTS */ /* Only return -1 if both pings fail. */ @@ -1497,55 +1498,55 @@ #ifdef __STDC__ int -rplay_ping_sockfd (int rplay_fd) -#else -int -rplay_ping_sockfd (rplay_fd) +rplay_ping_sockfd(int rplay_fd) +#else +int +rplay_ping_sockfd(rplay_fd) int rplay_fd; #endif { RPLAY *rp; - rp = rplay_create (RPLAY_PING); + rp = rplay_create(RPLAY_PING); if (rp == NULL) { return -1; } - if (rplay_pack (rp) < 0) - { - return -1; - } - - if (rplay (rplay_fd, rp) < 0) - { - return -1; - } - - rplay_close (rplay_fd); - rplay_destroy (rp); + if (rplay_pack(rp) < 0) + { + return -1; + } + + if (rplay(rplay_fd, rp) < 0) + { + return -1; + } + + rplay_close(rplay_fd); + rplay_destroy(rp); return 0; } #ifdef __STDC__ int -rplay_ping_sockaddr_in (struct sockaddr_in *saddr) -#else -int -rplay_ping_sockaddr_in (saddr) +rplay_ping_sockaddr_in(struct sockaddr_in *saddr) +#else +int +rplay_ping_sockaddr_in(saddr) struct sockaddr_in *saddr; #endif { int rplay_fd; - rplay_fd = rplay_open_sockaddr_in (saddr); + rplay_fd = rplay_open_sockaddr_in(saddr); if (rplay_fd < 0) { return -1; } - return rplay_ping_sockfd (rplay_fd); + return rplay_ping_sockfd(rplay_fd); } /* @@ -1553,10 +1554,10 @@ */ #ifdef __STDC__ int -rplay_host_volume (char *host, char *sound, int volume) -#else -int -rplay_host_volume (host, sound, volume) +rplay_host_volume(char *host, char *sound, int volume) +#else +int +rplay_host_volume(host, sound, volume) char *host; char *sound; int volume; @@ -1565,29 +1566,29 @@ int rplay_fd; RPLAY *rp; - rplay_fd = rplay_open (host); + rplay_fd = rplay_open(host); if (rplay_fd < 0) { return -1; } - rp = rplay_create (RPLAY_PLAY); + rp = rplay_create(RPLAY_PLAY); if (rp == NULL) { return -1; } - if (rplay_set (rp, RPLAY_APPEND, RPLAY_SOUND, sound, RPLAY_VOLUME, volume, NULL) < 0) - { - return -1; - } - - if (rplay (rplay_fd, rp) < 0) - { - return -1; - } - - rplay_destroy (rp); + if (rplay_set(rp, RPLAY_APPEND, RPLAY_SOUND, sound, RPLAY_VOLUME, volume, NULL) < 0) + { + return -1; + } + + if (rplay(rplay_fd, rp) < 0) + { + return -1; + } + + rplay_destroy(rp); return 0; } @@ -1597,15 +1598,15 @@ */ #ifdef __STDC__ char * -rplay_default_host (void) +rplay_default_host(void) #else char * -rplay_default_host () +rplay_default_host() #endif { char *host; - host = getenv ("RPLAY_HOST"); + host = getenv("RPLAY_HOST"); return host ? host : "localhost"; } @@ -1615,14 +1616,14 @@ */ #ifdef __STDC__ int -rplay_default (char *sound) -#else -int -rplay_default (sound) +rplay_default(char *sound) +#else +int +rplay_default(sound) char *sound; #endif { - return rplay_host (rplay_default_host (), sound); + return rplay_host(rplay_default_host(), sound); } /* @@ -1630,11 +1631,11 @@ */ #ifdef __STDC__ int -rplay_open_default (void) -#else -int -rplay_open_default () -#endif -{ - return rplay_open (rplay_default_host ()); -} +rplay_open_default(void) +#else +int +rplay_open_default() +#endif +{ + return rplay_open(rplay_default_host()); +} diff --git a/librplay/rptp.c b/librplay/rptp.c index fcb8a0a..7e5aeca 100644 --- a/librplay/rptp.c +++ b/librplay/rptp.c @@ -1,7 +1,7 @@ -/* $Id: rptp.c,v 1.2 1998/08/13 06:13:38 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: rptp.c,v 1.4 1999/03/10 07:57:56 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -64,31 +64,31 @@ }; #ifdef __STDC__ -unsigned long inet_addr (char *rp); -#else -unsigned long inet_addr (); +unsigned long inet_addr(char *rp); +#else +unsigned long inet_addr(); #endif #ifndef HAVE_STRDUP #ifdef __STDC__ static char * -strdup (char *str) +strdup(char *str) #else static char * -strdup (str) +strdup(str) char *str; #endif { char *p; - p = (char *) malloc (strlen (str) + 1); + p = (char *) malloc(strlen(str) + 1); if (p == NULL) { return NULL; } else { - strcpy (p, str); + strcpy(p, str); return p; } } @@ -100,10 +100,10 @@ */ #ifdef __STDC__ int -rptp_open (char *host, int port, char *response, int response_size) -#else -int -rptp_open (host, port, response, response_size) +rptp_open(char *host, int port, char *response, int response_size) +#else +int +rptp_open(host, port, response, response_size) char *host; int port; char *response; @@ -118,49 +118,49 @@ rptp_errno = RPTP_ERROR_NONE; - memset ((char *) &s, 0, sizeof (s)); - - addr = inet_addr (host); + memset((char *) &s, 0, sizeof(s)); + + addr = inet_addr(host); if (addr == 0xffffffff) { - hp = gethostbyname (host); + hp = gethostbyname(host); if (hp == NULL) { rptp_errno = RPTP_ERROR_HOST; return -1; } - memcpy ((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); + memcpy((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); } else { - memcpy ((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof (addr)); - } - - s.sin_port = htons (port); + memcpy((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof(addr)); + } + + s.sin_port = htons(port); s.sin_family = AF_INET; for (i = 0; i < RPTP_CONNECT_ATTEMPTS; i++) { - if (rplay_ping (host) < 0) + if (rplay_ping(host) < 0) { rptp_errno = RPTP_ERROR_PING; return -1; } - rptp_fd = socket (AF_INET, SOCK_STREAM, 0); + rptp_fd = socket(AF_INET, SOCK_STREAM, 0); if (rptp_fd < 0) { rptp_errno = RPTP_ERROR_SOCKET; return -1; } - n = connect (rptp_fd, (struct sockaddr *) &s, sizeof (s)); + n = connect(rptp_fd, (struct sockaddr *) &s, sizeof(s)); if (n == 0) { /* * successful connection */ - rptp_getline (rptp_fd, response, response_size); + rptp_getline(rptp_fd, response, response_size); if (response[0] == RPTP_ERROR) { rptp_errno = RPTP_ERROR_OPEN; @@ -173,10 +173,10 @@ { case ECONNREFUSED: case EINTR: - close (rptp_fd); + close(rptp_fd); if (i + 1 != RPTP_CONNECT_ATTEMPTS) { - sleep (RPTP_PING_DELAY); + sleep(RPTP_PING_DELAY); } break; @@ -201,10 +201,10 @@ */ #ifdef __STDC__ int -rptp_read (int rptp_fd, char *ptr, int nbytes) -#else -int -rptp_read (rptp_fd, ptr, nbytes) +rptp_read(int rptp_fd, char *ptr, int nbytes) +#else +int +rptp_read(rptp_fd, ptr, nbytes) int rptp_fd; char *ptr; int nbytes; @@ -218,7 +218,7 @@ while (nleft > 0) { - nread = read (rptp_fd, ptr, nleft); + nread = read(rptp_fd, ptr, nleft); if (nread < 0) { if (errno == EINTR) @@ -249,10 +249,10 @@ */ #ifdef __STDC__ int -rptp_write (int rptp_fd, char *ptr, int nbytes) -#else -int -rptp_write (rptp_fd, ptr, nbytes) +rptp_write(int rptp_fd, char *ptr, int nbytes) +#else +int +rptp_write(rptp_fd, ptr, nbytes) int rptp_fd; char *ptr; int nbytes; @@ -266,7 +266,7 @@ while (nleft > 0) { - nwritten = write (rptp_fd, ptr, nleft); + nwritten = write(rptp_fd, ptr, nleft); if (nwritten < 0) { if (errno == EINTR) @@ -295,10 +295,10 @@ */ #ifdef __STDC__ int -rptp_putline (int rptp_fd, char *fmt,...) -#else -int -rptp_putline (va_alist) +rptp_putline(int rptp_fd, char *fmt,...) +#else +int +rptp_putline(va_alist) va_dcl #endif { @@ -306,22 +306,22 @@ char buf[RPTP_MAX_LINE]; #ifdef __STDC__ - va_start (args, fmt); + va_start(args, fmt); #else int rptp_fd; char *fmt; - va_start (args); - rptp_fd = va_arg (args, int); - fmt = va_arg (args, char *); + va_start(args); + rptp_fd = va_arg(args, int); + fmt = va_arg(args, char *); #endif rptp_errno = RPTP_ERROR_NONE; - vsprintf (buf, fmt, args); - va_end (args); - strcat (buf, "\r\n"); - - return rptp_write (rptp_fd, buf, strlen (buf)) != strlen (buf) ? -1 : 0; + vsprintf(buf, fmt, args); + va_end(args); + strcat(buf, "\r\n"); + + return rptp_write(rptp_fd, buf, strlen(buf)) != strlen(buf) ? -1 : 0; } /* @@ -331,10 +331,10 @@ */ #ifdef __STDC__ int -rptp_getline (int rptp_fd, char *buf, int nbytes) -#else -int -rptp_getline (rptp_fd, buf, nbytes) +rptp_getline(int rptp_fd, char *buf, int nbytes) +#else +int +rptp_getline(rptp_fd, buf, nbytes) int rptp_fd; char *buf; int nbytes; @@ -355,7 +355,7 @@ * peek at the message so only the necessary data * is actually read */ - n = recv (rptp_fd, ptr, nleft, MSG_PEEK); + n = recv(rptp_fd, ptr, nleft, MSG_PEEK); if (n < 0) { if (errno == EINTR) @@ -384,7 +384,7 @@ } } again: - x = read (rptp_fd, tmp_buf, i == n ? n : i + 1); + x = read(rptp_fd, tmp_buf, i == n ? n : i + 1); if (x < 0) { if (errno == EINTR) @@ -420,10 +420,10 @@ */ #ifdef __STDC__ int -rptp_command (int rptp_fd, char *command, char *response, int response_size) -#else -int -rptp_command (rptp_fd, command, response, response_size) +rptp_command(int rptp_fd, char *command, char *response, int response_size) +#else +int +rptp_command(rptp_fd, command, response, response_size) int rptp_fd; char *command; char *response; @@ -432,11 +432,11 @@ { rptp_errno = RPTP_ERROR_NONE; - if (rptp_putline (rptp_fd, command) < 0) + if (rptp_putline(rptp_fd, command) < 0) { return -1; } - if (rptp_getline (rptp_fd, response, response_size) < 0) + if (rptp_getline(rptp_fd, response, response_size) < 0) { return -1; } @@ -464,16 +464,16 @@ */ #ifdef __STDC__ int -rptp_close (int rptp_fd) -#else -int -rptp_close (rptp_fd) +rptp_close(int rptp_fd) +#else +int +rptp_close(rptp_fd) int rptp_fd; #endif { rptp_errno = RPTP_ERROR_NONE; - close (rptp_fd); + close(rptp_fd); return 0; } @@ -483,14 +483,14 @@ */ #ifdef __STDC__ void -rptp_perror (char *message) +rptp_perror(char *message) #else void -rptp_perror (message) +rptp_perror(message) char *message; #endif { - fprintf (stderr, "%s: %s\n", message, rptp_errlist[rptp_errno]); + fprintf(stderr, "%s: %s\n", message, rptp_errlist[rptp_errno]); } /* @@ -530,10 +530,10 @@ #ifdef __STDC__ char * -rptp_parse (char *response, char *name) +rptp_parse(char *response, char *name) #else char * -rptp_parse (response, name) +rptp_parse(response, name) char *response; char *name; #endif @@ -552,12 +552,12 @@ char *p; char *response_name = "", *response_value = ""; - list_free (); + list_free(); if (buf) { - free ((char *) buf); - } - buf = strdup (response); + free((char *) buf); + } + buf = strdup(response); p = buf; @@ -574,15 +574,15 @@ while (p && *p) { /* Skip white-space. */ - if (isspace (*p)) - { - for (p++; isspace (*p); p++) ; + if (isspace(*p)) + { + for (p++; isspace(*p); p++) ; continue; } /* `name' */ response_name = p; - p = strpbrk (p, "= \t\r\n"); + p = strpbrk(p, "= \t\r\n"); /* `value' */ if (p && *p == '=') @@ -600,11 +600,11 @@ response_value = p; if (quoted) { - p = strchr (p, '"'); + p = strchr(p, '"'); } else { - p = strpbrk (p, " \t\r\n"); + p = strpbrk(p, " \t\r\n"); } if (p) { @@ -616,7 +616,7 @@ *p++ = '\0'; } - list_add (response_name, response_value); + list_add(response_name, response_value); response_name = ""; response_value = ""; } @@ -630,17 +630,17 @@ { LIST *l; char *p; - + /* Skip any leading dashes. */ while (*name == '-') { name++; } - + if (cache_pos) { - for (p = cache_pos->name; *p && *p == '-'; p++) ; /* skip leading dashes */ - if (strcmp (name, p) == 0) + for (p = cache_pos->name; *p && *p == '-'; p++) ; /* skip leading dashes */ + if (strcmp(name, p) == 0) { return cache_pos->value; } @@ -648,8 +648,8 @@ for (l = list; l; l = l->next) { - for (p = l->name; *p && *p == '-'; p++) ; /* skip leading dashes */ - if (strcmp (p, name) == 0) + for (p = l->name; *p && *p == '-'; p++) ; /* skip leading dashes */ + if (strcmp(p, name) == 0) { return l->value; } diff --git a/perl/CVS/Entries b/perl/CVS/Entries deleted file mode 100644 index 4c0f1ce..0000000 --- a/perl/CVS/Entries +++ /dev/null @@ -1,8 +0,0 @@ -/.Mailsounds/1.1.1.1/Tue Jul 14 22:35:24 1998// -/example.pl/1.1.1.1/Tue Jul 14 22:35:24 1998// -/rplay.ph/1.1.1.1/Tue Jul 14 22:35:24 1998// -/RPlay.pm/1.2/Mon Sep 7 01:56:59 1998// -/Mailsound/1.3/Sat Sep 19 18:46:41 1998// -/Mailsound.1/1.2/Sat Sep 19 18:49:33 1998// -/RPTP.pm/1.1/Mon Oct 12 16:07:05 1998// -D diff --git a/perl/CVS/Repository b/perl/CVS/Repository deleted file mode 100644 index 1eb2484..0000000 --- a/perl/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/perl diff --git a/perl/CVS/Root b/perl/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/perl/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/perl/RPTP.pm b/perl/RPTP.pm index 3a4f489..f180abb 100644 --- a/perl/RPTP.pm +++ b/perl/RPTP.pm @@ -1,29 +1,30 @@ -# $Id: RPTP.pm,v 1.1 1998/10/12 16:07:05 boyns Exp $ -*-perl-*- -# -# Copyright (C) 1993-98 Mark R. Boyns -# -# This file is part of rplay. -# -# rplay is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# rplay is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with rplay; see the file COPYING. If not, write to the -# Free Software Foundation, Inc., -# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -# +# $Id: RPTP.pm,v 1.2 1999/03/12 18:51:45 boyns Exp $ -*-perl-*- +# +# Copyright (C) 1993-98 Mark R. Boyns +# +# This file is part of rplay. +# +# rplay is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# rplay is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rplay; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +# + +require "rplay.ph"; +require 5.000; package RPTP; -require 5.000; -require "rplay.ph"; require "shellwords.pl"; use FileHandle; use Socket; @@ -63,7 +64,7 @@ my $tcp = $proto; #($name, $aliases, $port, $proto) = getservbyname ('rplay', 'udp'); - $that_port = &RPTP_PORT; + $that_port = &main::RPTP_PORT; chop ($this_host = `hostname`); ($name, $aliases, $addrtype, $length, $this_addr) = @@ -258,28 +259,30 @@ "!" => "timeout", "@" => "event" ); - + sub mainloop { my $self = shift; - my $emask; - foreach (keys %{$self->{callbacks}}) - { - next if /(ok|error|timeout|event)/; - $emask .= "$_|"; - } - chop $emask; - - $self->writeline("set notify=$emask"); + my $single = shift; + + if (!$self->{initialized}) + { + my $emask; + foreach (keys %{$self->{callbacks}}) + { + next if /(ok|error|timeout|event)/; + $emask .= "$_|"; + } + chop $emask; + $self->writeline("set notify=$emask"); + $self->{initialized} = 1; + } for (;;) { my %hash = $self->readline(); my $type = $proto{$hash{_type}}; - if ($hash{command} eq "set") - { - next; - } + next if ($hash{command} eq "set"); my $func; if (exists($self->{callbacks}{all})) { @@ -294,6 +297,7 @@ $func = $self->{callbacks}{$hash{$type}}; } &$func(%hash) if $func; + last if $single; } } diff --git a/perl/RPlay.pm b/perl/RPlay.pm index 2c56221..c6da2d3 100644 --- a/perl/RPlay.pm +++ b/perl/RPlay.pm @@ -1,29 +1,29 @@ -# $Id: RPlay.pm,v 1.2 1998/08/13 06:18:06 boyns Exp $ -*-perl-*- -# -# Copyright (C) 1993-98 Mark R. Boyns -# -# This file is part of rplay. -# -# rplay is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# rplay is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with rplay; see the file COPYING. If not, write to the -# Free Software Foundation, Inc., -# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -# +# $Id: RPlay.pm,v 1.4 1999/06/10 05:39:06 boyns Exp $ -*-perl-*- +# +# Copyright (C) 1993-98 Mark R. Boyns +# +# This file is part of rplay. +# +# rplay is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# rplay is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rplay; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +# + +require "rplay.ph"; +require 5.000; package RPlay; - -require 5.000; -require "rplay.ph"; use Socket; @@ -55,7 +55,7 @@ if (!$that_port) { - $that_port = $name ? $port : &RPLAY_PORT; + $that_port = $name ? $port : &main::RPLAY_PORT; } chop ($this_host = `hostname`); @@ -82,7 +82,7 @@ sub disconnect { my $self = shift; - + close (RPLAY); $connected = 0; } @@ -130,12 +130,12 @@ my $self = shift; my $command = shift; my @refs = $self->parse (@_); - my (%attrs, $name, $packet); + my (%attrs, $name, $packet, $data_size, $data); die "Not connected - use connect () first." unless $connected; ## Packet header. - $packet = pack ("C", &RPLAY_PACKET_ID); + $packet = pack ("C", &main::RPLAY_PACKET_ID); $packet .= pack ("C", $command); ## Convert name-value hash pairs to RPLAY attributes. @@ -143,7 +143,7 @@ { %attrs = %$_; - if (!$attrs{'sound'}) + if (!$attrs{'sound'} && $command ne &main::RPLAY_PUT) { die "Missing `sound' attribute."; } @@ -151,42 +151,69 @@ { if (/sound/) { - $packet .= pack ("C", &RPLAY_SOUND); + $packet .= pack ("C", &main::RPLAY_SOUND); $packet .= "$attrs{$_}\0"; } elsif (/volume/) { - $packet .= pack ("C", &RPLAY_VOLUME); + $packet .= pack ("C", &main::RPLAY_VOLUME); $packet .= pack ("C", $attrs{$_}); } elsif (/list_count/) { - $packet .= pack ("C", &RPLAY_LIST_COUNT); + $packet .= pack ("C", &main::RPLAY_LIST_COUNT); $packet .= pack ("C", $attrs{$_}); } elsif (/priority/) { - $packet .= pack ("C", &RPLAY_PRIORITY); + $packet .= pack ("C", &main::RPLAY_PRIORITY); $packet .= pack ("C", $attrs{$_}); } elsif (/sample_rate/) { - $packet .= pack ("C", &RPLAY_SAMPLE_RATE); - $packet .= pack ("C", $attrs{$_}); + $packet .= pack ("C", &main::RPLAY_SAMPLE_RATE); + $packet .= pack ("N", $attrs{$_}); } elsif (/list_name/) { - $packet .= pack ("C", &RPLAY_CLIENT_DATA); + $packet .= pack ("C", &main::RPLAY_LIST_NAME); $packet .= "$attrs{$_}\0"; } + elsif (/id/) + { + $packet .= pack ("C", &main::RPLAY_ID); + $packet .= pack ("N", $attrs{$_}); + } + elsif (/sequence/) + { + $packet .= pack ("C", &main::RPLAY_SEQUENCE); + $packet .= pack ("N", $attrs{$_}); + } + elsif (/data_size/) + { + $data_size = $attrs{$_}; + } + elsif (/data/) + { + $data = $attrs{$_}; + } else { #warn "Uknown attribute `$_'"; } } - $packet .= pack ("C", &RPLAY_NULL); - } - $packet .= pack ("C", &RPLAY_NULL); + + if ($data && $data_size) + { + $packet .= pack ("C", &main::RPLAY_DATA_SIZE); + $packet .= pack ("n", $data_size); + $packet .= pack ("C", &main::RPLAY_DATA); + $packet .= $data; + } + + $packet .= pack ("C", &main::RPLAY_NULL); + } + $packet .= pack ("C", &main::RPLAY_NULL); send (RPLAY, $packet, 0) || die "send: $!"; } @@ -195,35 +222,41 @@ sub play { my $self = shift; - $self->doit (&RPLAY_PLAY, @_); + $self->doit (&main::RPLAY_PLAY, @_); } ## Pause sounds. sub pause { my $self = shift; - $self->doit (&RPLAY_PAUSE, @_); + $self->doit (&main::RPLAY_PAUSE, @_); } ## Continue sounds. sub continue { my $self = shift; - $self->doit (&RPLAY_CONTINUE, @_); + $self->doit (&main::RPLAY_CONTINUE, @_); } ## Stop sounds. sub stop { my $self = shift; - $self->doit (&RPLAY_STOP, @_); + $self->doit (&main::RPLAY_STOP, @_); } ## Done sounds. sub done { my $self = shift; - $self->doit (&RPLAY_DONE, @_); + $self->doit (&main::RPLAY_DONE, @_); +} + +sub put +{ + my $self = shift; + $self->doit (&main::RPLAY_PUT, @_); } 1; diff --git a/rplay/CVS/Entries b/rplay/CVS/Entries deleted file mode 100644 index 5396fa4..0000000 --- a/rplay/CVS/Entries +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:22 1998// -/rplay.c/1.4/Thu Oct 15 15:15:25 1998// -D diff --git a/rplay/CVS/Repository b/rplay/CVS/Repository deleted file mode 100644 index 321cfee..0000000 --- a/rplay/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/rplay diff --git a/rplay/CVS/Root b/rplay/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/rplay/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/rplay/Makefile.in b/rplay/Makefile.in index 092156f..1b9497b 100644 --- a/rplay/Makefile.in +++ b/rplay/Makefile.in @@ -24,6 +24,12 @@ $(TARGET): $(OBJS) ../librplay/$(LIBRPLAY_NAME) ../lib/librp.a $(CC) -o $@ $(OBJS) $(LDFLAGS) +../librplay/$(LIBRPLAY_NAME): + (cd ../librplay; $(MAKE) $(MFLAGS)) + +../lib/librp.a: + (cd ../lib; $(MAKE) $(MFLAGS)) + install: all $(MKINSTALLDIRS) $(bindir) $(INSTALL_PROGRAM) $(TARGET) $(bindir)/$(TARGET) diff --git a/rplay/rplay.c b/rplay/rplay.c index 317f39d..49e3f7a 100644 --- a/rplay/rplay.c +++ b/rplay/rplay.c @@ -1,7 +1,7 @@ -/* $Id: rplay.c,v 1.4 1998/10/15 15:15:25 boyns Exp $ */ +/* $Id: rplay.c,v 1.8 1999/03/10 07:57:59 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,6 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifdef HAVE_CONFIG_H #include "config.h" @@ -48,6 +46,7 @@ { {"continue", no_argument, NULL, 'c'}, {"count", required_argument, NULL, 'n'}, + {"flow", required_argument, NULL, 14}, {"help", no_argument, NULL, 3}, {"host", required_argument, NULL, 'h'}, {"hosts", required_argument, NULL, 'h'}, @@ -57,6 +56,7 @@ {"info-cs4231", no_argument, NULL, 10}, {"info-dbri", no_argument, NULL, 9}, {"info-gsm", no_argument, NULL, 13}, + {"info-cd", no_argument, NULL, 15}, {"buffer-size", required_argument, NULL, 'b'}, {"list-count", required_argument, NULL, 'N'}, {"list-name", required_argument, NULL, 7}, @@ -87,10 +87,10 @@ typedef int (*PLAY_FUNC) (); #endif -void doit (), play (), usage (), interrupt (); -int server_has_sound (); -char *info2str (); -int play_with_flow (), play_with_play (); +void doit(), play(), usage(), interrupt(); +int server_has_sound(); +char *info2str(); +int play_with_flow(), play_with_play(); RPLAY *rp; char cwd[MAXPATHLEN]; @@ -100,9 +100,9 @@ int buffer_size = BUFFER_SIZE; #ifdef __STDC__ -main (int argc, char **argv) +main(int argc, char **argv) #else -main (argc, argv) +main(argc, argv) int argc; char **argv; #endif @@ -118,22 +118,22 @@ if (argc < 2) { - usage (); - } - - signal (SIGPIPE, SIG_IGN); - - if (getcwd (cwd, sizeof (cwd)) == NULL) + usage(); + } + + signal(SIGPIPE, SIG_IGN); + + if (getcwd(cwd, sizeof(cwd)) == NULL) { cwd[0] = '\0'; } - + command = RPLAY_PLAY; list_count = RPLAY_DEFAULT_LIST_COUNT; list_name = NULL; priority = RPLAY_DEFAULT_PRIORITY; do_random = 0; - hosts = rplay_default_host (); + hosts = rplay_default_host(); name = NULL; sample_rate = RPLAY_DEFAULT_SAMPLE_RATE; @@ -141,22 +141,22 @@ count = RPLAY_DEFAULT_COUNT; /* First scan the args to see what the command is. */ - opterr = 0; /* disable getopt errors */ - while ((c = getopt_long (argc, argv, OPTIONS, longopts, 0)) != -1) + opterr = 0; /* disable getopt errors */ + while ((c = getopt_long(argc, argv, OPTIONS, longopts, 0)) != -1) { switch (c) { case 2: /* --version */ - printf ("rplay %s\n", RPLAY_VERSION); - exit (0); + printf("rplay %s\n", RPLAY_VERSION); + exit(0); case 3: /* --help */ - usage (); + usage(); case 5: /* --reset */ if (command != RPLAY_PLAY) { - usage (); + usage(); } command = RPLAY_RESET; break; @@ -164,7 +164,7 @@ case 's': if (command != RPLAY_PLAY) { - usage (); + usage(); } command = RPLAY_STOP; break; @@ -172,7 +172,7 @@ case 'p': if (command != RPLAY_PLAY) { - usage (); + usage(); } command = RPLAY_PAUSE; break; @@ -180,7 +180,7 @@ case 'c': if (command != RPLAY_PLAY) { - usage (); + usage(); } command = RPLAY_CONTINUE; break; @@ -190,18 +190,18 @@ optind = optind_val; /* reset optind */ /* Create the RPLAY object. */ - rp = rplay_create (command); + rp = rplay_create(command); if (rp == NULL) { - rplay_perror ("rplay_create"); - exit (1); + rplay_perror("rplay_create"); + exit(1); } /* Build a list of sounds to be played along with their attributes. */ while (argc > 1) { - while ((c = getopt_long (argc, argv, OPTIONS, longopts, 0)) != -1) + while ((c = getopt_long(argc, argv, OPTIONS, longopts, 0)) != -1) { switch (c) { @@ -211,16 +211,16 @@ case 1: break; - + case 2: /* --version */ - printf ("rplay %s\n", RPLAY_VERSION); - exit (0); + printf("rplay %s\n", RPLAY_VERSION); + exit(0); case 3: /* --help */ - usage (); + usage(); case 4: /* --port */ - which_port = atoi (optarg); + which_port = atoi(optarg); break; case 5: /* --reset */ @@ -260,13 +260,18 @@ /* GSM encoded u-law files */ sound_info = "gsm,8000"; break; - + + case 15: /* --info-cd */ + /* cd quality */ + sound_info = "linear16,44100,16,2,little-endian"; + break; + case 'N': - list_count = atoi (optarg); + list_count = atoi(optarg); break; case 'P': - priority = atoi (optarg); + priority = atoi(optarg); break; case 'r': @@ -278,15 +283,15 @@ break; case 'v': - volume = atoi (optarg); + volume = atoi(optarg); break; case 'n': - count = atoi (optarg); + count = atoi(optarg); break; case 'R': - sample_rate = atoi (optarg); + sample_rate = atoi(optarg); break; case 'i': @@ -294,12 +299,12 @@ break; case 'b': - buffer_size = atoi (optarg); + buffer_size = atoi(optarg); break; default: - fprintf (stderr, "Try `rplay --help' for more information.\n"); - exit (1); + fprintf(stderr, "Try `rplay --help' for more information.\n"); + exit(1); } } @@ -307,25 +312,25 @@ { if (command == RPLAY_PLAY) { - usage (); + usage(); } name = "#0"; } /* Convert relative file names to absolute. */ - else if ((*(argv[optind]) != '/') && (strchr (argv[optind], '/'))) + else if ((*(argv[optind]) != '/') && (strchr(argv[optind], '/'))) { if (*cwd) { - name = (char *) malloc (strlen (cwd) + strlen (argv[optind]) + 2); - strcpy (name, cwd); - strcat (name, "/"); - if (strncmp (argv[optind], "./", 2) == 0) + name = (char *) malloc(strlen(cwd) + strlen(argv[optind]) + 2); + strcpy(name, cwd); + strcat(name, "/"); + if (strncmp(argv[optind], "./", 2) == 0) { - strcat (name, argv[optind]+2); + strcat(name, argv[optind] + 2); } else { - strcat (name, argv[optind]); + strcat(name, argv[optind]); } } else @@ -342,81 +347,81 @@ argc -= optind; optind = optind_val; - if (rplay_set (rp, RPLAY_LIST_COUNT, list_count, NULL) < 0) - { - rplay_perror ("rplay_set"); - exit (1); - } - - if (rplay_set (rp, RPLAY_PRIORITY, priority, NULL) < 0) - { - rplay_perror ("rplay_set"); - exit (1); - } - - if (list_name && rplay_set (rp, RPLAY_LIST_NAME, list_name, NULL) < 0) - { - rplay_perror ("rplay_set"); - exit (1); - } - - val = rplay_set (rp, RPLAY_APPEND, - RPLAY_SOUND, name, - RPLAY_VOLUME, volume, - RPLAY_COUNT, count, - RPLAY_SAMPLE_RATE, sample_rate, - RPLAY_CLIENT_DATA, sound_info, - NULL); + if (rplay_set(rp, RPLAY_LIST_COUNT, list_count, NULL) < 0) + { + rplay_perror("rplay_set"); + exit(1); + } + + if (rplay_set(rp, RPLAY_PRIORITY, priority, NULL) < 0) + { + rplay_perror("rplay_set"); + exit(1); + } + + if (list_name && rplay_set(rp, RPLAY_LIST_NAME, list_name, NULL) < 0) + { + rplay_perror("rplay_set"); + exit(1); + } + + val = rplay_set(rp, RPLAY_APPEND, + RPLAY_SOUND, name, + RPLAY_VOLUME, volume, + RPLAY_COUNT, count, + RPLAY_SAMPLE_RATE, sample_rate, + RPLAY_CLIENT_DATA, sound_info, + NULL); if (val < 0) { - rplay_perror ("rplay_set"); - exit (1); + rplay_perror("rplay_set"); + exit(1); } } /* Pick the random sound. */ if (do_random) { - val = rplay_set (rp, RPLAY_RANDOM_SOUND, NULL); + val = rplay_set(rp, RPLAY_RANDOM_SOUND, NULL); if (val < 0) { - rplay_perror ("rplay_set"); - exit (1); - } - } - - doit (hosts); - - exit (0); + rplay_perror("rplay_set"); + exit(1); + } + } + + doit(hosts); + + exit(0); } #ifdef __STDC__ void -doit (char *hostp) +doit(char *hostp) #else void -doit (hostp) +doit(hostp) char *hostp; #endif { PLAY_FUNC *play_table; char *host; - play_table = (PLAY_FUNC *) malloc (rplay_get (rp, RPLAY_NSOUNDS) * sizeof (PLAY_FUNC)); + play_table = (PLAY_FUNC *) malloc(rplay_get(rp, RPLAY_NSOUNDS) * sizeof(PLAY_FUNC)); if (play_table == NULL) { - fprintf (stderr, "rplay: out of memory\n"); - exit (1); - } - + fprintf(stderr, "rplay: out of memory\n"); + exit(1); + } + /* Cycle through each colon-separated host. */ do { int protocol, port; int rplay_fd = -1; - + host = hostp; - hostp = strchr (host, ':'); + hostp = strchr(host, ':'); if (hostp != NULL) { *hostp++ = '\0'; @@ -424,11 +429,11 @@ /* Determine which protocol to use. */ - if (rplay_get (rp, RPLAY_COMMAND) != RPLAY_PLAY) + if (rplay_get(rp, RPLAY_COMMAND) != RPLAY_PLAY) { protocol = PROTOCOL_RPLAY; } - else if (strcmp ((char *) rplay_get (rp, RPLAY_SOUND, 0), "-") == 0) + else if (strcmp((char *) rplay_get(rp, RPLAY_SOUND, 0), "-") == 0) { protocol = PROTOCOL_RPTP; play_table[0] = play_with_flow; @@ -436,7 +441,7 @@ else if (which_protocol == PROTOCOL_GUESS) { char response[RPTP_MAX_LINE]; - rplay_fd = rptp_open (host, RPTP_PORT, response, sizeof (response)); + rplay_fd = rptp_open(host, RPTP_PORT, response, sizeof(response)); if (rplay_fd < 0) { protocol = PROTOCOL_RPLAY; @@ -445,20 +450,20 @@ { int i, n, sounds_not_found = 0; char *sound_name; - + /* Count the number of sounds the server doesn't have */ - n = (int) rplay_get (rp, RPLAY_NSOUNDS); + n = (int) rplay_get(rp, RPLAY_NSOUNDS); for (i = 0; i < n; i++) { struct stat st; - - sound_name = (char *) rplay_get (rp, RPLAY_SOUND, i); - if (stat (sound_name, &st) < 0) + + sound_name = (char *) rplay_get(rp, RPLAY_SOUND, i); + if (stat(sound_name, &st) < 0) { st.st_size = 0; } - - if (!server_has_sound (rplay_fd, sound_name, (int)st.st_size)) + + if (!server_has_sound(rplay_fd, sound_name, (int) st.st_size)) { if (st.st_size) { @@ -468,7 +473,7 @@ else { /* Assume the server can get the sound - from another server. */ + from another server. */ play_table[i] = play_with_play; } } @@ -492,18 +497,18 @@ /* Allow the protocol choice to be overridden. */ if (which_protocol != PROTOCOL_GUESS - && rplay_get (rp, RPLAY_COMMAND) == RPLAY_PLAY) + && rplay_get(rp, RPLAY_COMMAND) == RPLAY_PLAY) { int i, n; - + protocol = which_protocol; - n = (int) rplay_get (rp, RPLAY_NSOUNDS); + n = (int) rplay_get(rp, RPLAY_NSOUNDS); for (i = 0; i < n; i++) { play_table[i] = (protocol == PROTOCOL_RPTP) ? play_with_flow : play_with_play; } } - + port = which_port; if (port == -1) { @@ -512,7 +517,7 @@ case PROTOCOL_RPLAY: port = RPLAY_PORT; break; - + case PROTOCOL_RPTP: port = RPTP_PORT; break; @@ -522,31 +527,31 @@ switch (protocol) { case PROTOCOL_RPTP: - play (rplay_fd, host, port, rp, play_table); + play(rplay_fd, host, port, rp, play_table); break; case PROTOCOL_RPLAY: if (rplay_fd != -1) { - rptp_close (rplay_fd); - } - rplay_fd = rplay_open_port (host, port); + rptp_close(rplay_fd); + } + rplay_fd = rplay_open_port(host, port); if (rplay_fd < 0) { - rplay_perror (host); - exit (1); - } - if (rplay (rplay_fd, rp) < 0) - { - rplay_perror (host); - exit (1); - } - rplay_close (rplay_fd); + rplay_perror(host); + exit(1); + } + if (rplay(rplay_fd, rp) < 0) + { + rplay_perror(host); + exit(1); + } + rplay_close(rplay_fd); break; default: - fprintf (stderr, "unknown protocol\n"); - exit (1); + fprintf(stderr, "unknown protocol\n"); + exit(1); } } while (hostp != NULL); @@ -555,14 +560,14 @@ #ifdef __STDC__ int -server_has_sound (int rplay_fd, char *sound_name, int size) +server_has_sound(int rplay_fd, char *sound_name, int size) #else int -server_has_sound (rplay_fd, sound_name, size) +server_has_sound(rplay_fd, sound_name, size) int rplay_fd; char *sound_name; int size; -#endif +#endif { char command[RPTP_MAX_LINE]; char response[RPTP_MAX_LINE]; @@ -574,21 +579,22 @@ { if (try == 0) { - sprintf (command, "info sound=%s", sound_name); + sprintf(command, "info sound=%s", sound_name); } else { - sprintf (command, "info sound=%s/%s", cwd, sound_name); - } - - if (rptp_command (rplay_fd, command, response, sizeof (response)) < 0) + sprintf(command, "info sound=%s/%s", cwd, sound_name); + } + + if (rptp_command(rplay_fd, command, response, sizeof(response)) < 0) { return 0; } remote_size = -1; - p = rptp_parse (response, "size"); - if (p) remote_size = atoi(p); + p = rptp_parse(response, "size"); + if (p) + remote_size = atoi(p); if (remote_size != -1 && (size == 0 || remote_size == 0 || size == remote_size)) @@ -602,33 +608,33 @@ #ifdef __STDC__ void -play (int rplay_fd, char *host, int port, RPLAY *rp, PLAY_FUNC *play_table) +play(int rplay_fd, char *host, int port, RPLAY *rp, PLAY_FUNC *play_table) #else void -play (rplay_fd, rp, play_table) +play(rplay_fd, rp, play_table) int rplay_fd; RPLAY *rp; PLAY_TABLE *play_table; -#endif +#endif { int i, n; char response[RPTP_MAX_LINE]; - n = rplay_get (rp, RPLAY_NSOUNDS); + n = rplay_get(rp, RPLAY_NSOUNDS); for (i = 0; i < n; i++) { if (rplay_fd < 0) { - rplay_fd = rptp_open (host, port, response, sizeof (response)); + rplay_fd = rptp_open(host, port, response, sizeof(response)); } if (rplay_fd < 0) { - rptp_perror (host); + rptp_perror(host); continue; } - if ((*play_table[i])(rplay_fd, host, port, rp, i) < 0) - { - rptp_close (rplay_fd); + if ((*play_table[i]) (rplay_fd, host, port, rp, i) < 0) + { + rptp_close(rplay_fd); rplay_fd = -1; } } @@ -636,10 +642,10 @@ #ifdef __STDC__ int -play_with_play (int rplay_fd, char *host, int port, RPLAY *rp, int index) +play_with_play(int rplay_fd, char *host, int port, RPLAY *rp, int index) #else int -play_with_play (rplay_fd, host, port, rp, index) +play_with_play(rplay_fd, host, port, rp, index) int rplay_fd; char *host; int port; @@ -651,34 +657,33 @@ char response[RPTP_MAX_LINE]; /* Enable `done' notification. */ - rptp_putline (rplay_fd, "set notify=done,position notify-rate=1.0"); - rptp_getline (rplay_fd, response, sizeof (response)); + rptp_putline(rplay_fd, "set notify=done,position notify-rate=1.0"); + rptp_getline(rplay_fd, response, sizeof(response)); /* Play the sound. */ - rptp_putline (rplay_fd, "play priority=%d sample-rate=%d volume=%d list-name=\"%s\" sound=\"%s\"", - (int) rplay_get (rp, RPLAY_PRIORITY, index), - (int) rplay_get (rp, RPLAY_SAMPLE_RATE, index), - (int) rplay_get (rp, RPLAY_VOLUME, index), - rplay_get (rp, RPLAY_LIST_NAME) ? (char *) rplay_get (rp, RPLAY_LIST_NAME) : "", - (int) rplay_get (rp, RPLAY_SOUND, index)); - n = rptp_getline (rplay_fd, response, sizeof (response)); + rptp_putline(rplay_fd, "play priority=%d sample-rate=%d volume=%d list-name=\"%s\" sound=\"%s\"", + (int) rplay_get(rp, RPLAY_PRIORITY, index), + (int) rplay_get(rp, RPLAY_SAMPLE_RATE, index), + (int) rplay_get(rp, RPLAY_VOLUME, index), + rplay_get(rp, RPLAY_LIST_NAME) ? (char *) rplay_get(rp, RPLAY_LIST_NAME) : "", + (int) rplay_get(rp, RPLAY_SOUND, index)); + n = rptp_getline(rplay_fd, response, sizeof(response)); if (n < 0 || response[0] != RPTP_OK) { - fprintf (stderr, "rplay: can't play `%s'\n", - (int) rplay_get (rp, RPLAY_SOUND, index)); + fprintf(stderr, "rplay: can't play `%s'\n", + (int) rplay_get(rp, RPLAY_SOUND, index)); return -1; } - + /* Grab the spool id. */ - spool_id = atoi (1 + rptp_parse (response, "id")); - + spool_id = atoi(1 + rptp_parse(response, "id")); + /* Wait for the sound to finish playing. */ - signal (SIGINT, interrupt); + signal(SIGINT, interrupt); interrupted = 0; for (;;) { - n = rptp_getline (rplay_fd, response, sizeof (response)); - fprintf(stderr, response); + n = rptp_getline(rplay_fd, response, sizeof(response)); if (interrupted) { break; @@ -689,24 +694,24 @@ } else if (response[0] != RPTP_NOTIFY) { - fprintf (stderr, "rplay: %s\n", response+1); + fprintf(stderr, "rplay: %s\n", response + 1); break; } rptp_parse(response, NULL); - if (strcmp (rptp_parse(NULL, "event"), "done") == 0 - && atoi (1 + rptp_parse (NULL, "id")) == spool_id) - { - break; - } - } - signal (SIGINT, SIG_DFL); + if (strcmp(rptp_parse(NULL, "event"), "done") == 0 + && atoi(1 + rptp_parse(NULL, "id")) == spool_id) + { + break; + } + } + signal(SIGINT, SIG_DFL); /* Eat any events and turn off notification. */ - rptp_putline (rplay_fd, "set notify=none"); + rptp_putline(rplay_fd, "set notify=none"); for (;;) { - n = rptp_getline (rplay_fd, response, sizeof (response)); + n = rptp_getline(rplay_fd, response, sizeof(response)); if (n < 0) { return -1; @@ -722,88 +727,88 @@ #ifdef __STDC__ int -play_with_flow (int rplay_fd, char *host, int port, RPLAY *rp, int index) +play_with_flow(int rplay_fd, char *host, int port, RPLAY *rp, int index) #else int -play_with_flow (rplay_fd, host, port, rp, index) +play_with_flow(rplay_fd, host, port, rp, index) int rplay_fd; char *host; int port; RPLAY *rp; int index; -#endif +#endif { - char *sound_name = (char *) rplay_get (rp, RPLAY_SOUND, index); - char *sound_info = (char *) rplay_get (rp, RPLAY_CLIENT_DATA, index); + char *sound_name = (char *) rplay_get(rp, RPLAY_SOUND, index); + char *sound_info = (char *) rplay_get(rp, RPLAY_CLIENT_DATA, index); char command[RPTP_MAX_LINE]; char response[RPTP_MAX_LINE]; char *buffer; int spool_id, n, fd, flow_fd; - if (strcmp (sound_name, "-") == 0) + if (strcmp(sound_name, "-") == 0) { fd = 0; } else { - fd = open (sound_name, O_RDONLY, 0); + fd = open(sound_name, O_RDONLY, 0); if (fd < 0) { - fprintf (stderr, "rplay: sound `%s' not found\n", sound_name); + fprintf(stderr, "rplay: sound `%s' not found\n", sound_name); return 0; } } /* Open a connection for the flow. */ - flow_fd = rptp_open (host, port, response, sizeof (response)); + flow_fd = rptp_open(host, port, response, sizeof(response)); if (flow_fd < 0) { - rptp_perror (host); + rptp_perror(host); return -1; } - + /* Enable `done' notification. */ - rptp_putline (rplay_fd, "set notify=done"); - rptp_getline (rplay_fd, response, sizeof (response)); + rptp_putline(rplay_fd, "set notify=done"); + rptp_getline(rplay_fd, response, sizeof(response)); /* Send the flow play command. */ - rptp_putline (flow_fd, "play input=flow %s priority=%d sample-rate=%d volume=%d list-name=\"%s\" sound=\"%s\"", - info2str (sound_info), - (int) rplay_get (rp, RPLAY_PRIORITY, index), - (int) rplay_get (rp, RPLAY_SAMPLE_RATE, index), - (int) rplay_get (rp, RPLAY_VOLUME, index), - rplay_get (rp, RPLAY_LIST_NAME) ? (char *) rplay_get (rp, RPLAY_LIST_NAME) : "", - strcmp (sound_name, "-") ? sound_name : "stdin"); - n = rptp_getline (flow_fd, response, sizeof (response)); + rptp_putline(flow_fd, "play input=flow %s priority=%d sample-rate=%d volume=%d list-name=\"%s\" sound=\"%s\"", + info2str(sound_info), + (int) rplay_get(rp, RPLAY_PRIORITY, index), + (int) rplay_get(rp, RPLAY_SAMPLE_RATE, index), + (int) rplay_get(rp, RPLAY_VOLUME, index), + rplay_get(rp, RPLAY_LIST_NAME) ? (char *) rplay_get(rp, RPLAY_LIST_NAME) : "", + strcmp(sound_name, "-") ? sound_name : "stdin"); + n = rptp_getline(flow_fd, response, sizeof(response)); if (n < 0 || response[0] != RPTP_OK) { - fprintf (stderr, "rplay: can't play `%s'\n", - (int) rplay_get (rp, RPLAY_SOUND, index)); + fprintf(stderr, "rplay: can't play `%s'\n", + (int) rplay_get(rp, RPLAY_SOUND, index)); return -1; } /* Grab the spool id. */ - spool_id = atoi (1 + rptp_parse (response, "id")); + spool_id = atoi(1 + rptp_parse(response, "id")); /* Send the put command. */ - rptp_putline (flow_fd, "put id=#%d size=0", spool_id); - n = rptp_getline (flow_fd, response, sizeof (response)); + rptp_putline(flow_fd, "put id=#%d size=0", spool_id); + n = rptp_getline(flow_fd, response, sizeof(response)); if (n < 0 || response[0] != RPTP_OK) { - fprintf (stderr, "rplay: can't play `%s'\n", - (int) rplay_get (rp, RPLAY_SOUND, index)); + fprintf(stderr, "rplay: can't play `%s'\n", + (int) rplay_get(rp, RPLAY_SOUND, index)); return -1; } - + /* Allocate the buffer. */ - buffer = (char *) malloc (buffer_size); + buffer = (char *) malloc(buffer_size); if (buffer == NULL) { - fprintf (stderr, "rplay: out of memory\n"); - exit (1); - } - - signal (SIGINT, interrupt); + fprintf(stderr, "rplay: out of memory\n"); + exit(1); + } + + signal(SIGINT, interrupt); interrupted = 0; for (;;) { @@ -811,25 +816,25 @@ { break; } - n = read (fd, buffer, buffer_size); + n = read(fd, buffer, buffer_size); if (n <= 0) { break; } - if (rptp_write (flow_fd, buffer, n) != n) - { - break; - } - } - - close (fd); - /*sleep (1);*/ - rptp_close (flow_fd); + if (rptp_write(flow_fd, buffer, n) != n) + { + break; + } + } + + close(fd); + /*sleep (1); */ + rptp_close(flow_fd); /* Wait for the sound to finish. */ for (;;) { - n = rptp_getline (rplay_fd, response, sizeof (response)); + n = rptp_getline(rplay_fd, response, sizeof(response)); if (interrupted) { break; @@ -840,22 +845,22 @@ } else if (response[0] != RPTP_NOTIFY) { - fprintf (stderr, "rplay: %s\n", response+1); - break; - } - else if (atoi (1 + rptp_parse (response, "id")) == spool_id) - { - break; - } - } - - signal (SIGINT, SIG_DFL); + fprintf(stderr, "rplay: %s\n", response + 1); + break; + } + else if (atoi(1 + rptp_parse(response, "id")) == spool_id) + { + break; + } + } + + signal(SIGINT, SIG_DFL); /* Eat any events and turn off notification. */ - rptp_putline (rplay_fd, "set notify=none"); + rptp_putline(rplay_fd, "set notify=none"); for (;;) { - n = rptp_getline (rplay_fd, response, sizeof (response)); + n = rptp_getline(rplay_fd, response, sizeof(response)); if (n < 0) { return -1; @@ -871,12 +876,12 @@ #ifdef __STDC__ char * -info2str (char *sound_info) +info2str(char *sound_info) #else char * -info2str (sound_info) +info2str(sound_info) char *sound_info; -#endif +#endif { static char str[1024]; @@ -885,138 +890,144 @@ { char buf[1024]; char *p; - - strcpy (buf, sound_info); + + strcpy(buf, sound_info); /* Example: ulaw,8000,8,1,big-endian,offset */ - p = strtok (buf, ", "); - if (p) sprintf (str + strlen(str), "input-format=%s ", p); - p = strtok (NULL, ", "); - if (p) sprintf (str + strlen(str), "input-sample-rate=%s ", p); - p = strtok (NULL, ", "); - if (p) sprintf (str + strlen(str), "input-bits=%s ", p); - p = strtok (NULL, ", "); - if (p) sprintf (str + strlen(str), "input-channels=%s ", p); - p = strtok (NULL, ", "); - if (p) sprintf (str + strlen(str), "input-byte-order=%s ", p); - p = strtok (NULL, ", "); - if (p) sprintf (str + strlen(str), "input-offset=%s ", p); - } - + p = strtok(buf, ", "); + if (p) + sprintf(str + strlen(str), "input-format=%s ", p); + p = strtok(NULL, ", "); + if (p) + sprintf(str + strlen(str), "input-sample-rate=%s ", p); + p = strtok(NULL, ", "); + if (p) + sprintf(str + strlen(str), "input-bits=%s ", p); + p = strtok(NULL, ", "); + if (p) + sprintf(str + strlen(str), "input-channels=%s ", p); + p = strtok(NULL, ", "); + if (p) + sprintf(str + strlen(str), "input-byte-order=%s ", p); + p = strtok(NULL, ", "); + if (p) + sprintf(str + strlen(str), "input-offset=%s ", p); + } + return str; } void -interrupt () +interrupt() { interrupted++; fprintf(stderr, "rplay: *interrupt*\n"); } void -usage () +usage() { - printf ("\nrplay %s\n\n", RPLAY_VERSION); - printf ("usage: rplay [options] [sound ... ]\n\n"); - - printf ("-b BYTES, --buffer-size=BYTES\n"); - printf ("\tUse of a buffer size of BYTES when playing sounds using RPTP flows.\n"); - printf ("\tThe default is 8K.\n"); - printf ("\n"); - - printf ("-c, --continue\n"); - printf ("\tContinue sounds.\n"); - printf ("\n"); - - printf ("-n N, --count=N\n"); - printf ("\tNumber of times to play the sound, default = %d.\n", - RPLAY_DEFAULT_COUNT); - printf ("\n"); - - printf ("-N N, --list-count=N\n"); - printf ("\tNumber of times to play all the sounds, default = %d.\n", - RPLAY_DEFAULT_LIST_COUNT); - printf ("\n"); - - printf ("--list-name=NAME\n"); - printf ("\tName this list NAME. rplayd appends sounds with the same\n"); - printf ("\tNAME into the same sound list -- it plays them sequentially.\n"); - printf ("\n"); - - printf ("--help\n"); - printf ("\tDisplay helpful information.\n"); - printf ("\n"); - - printf ("-h HOST, --host=HOST, --hosts=HOST\n"); - printf ("\tSpecify the rplay host, default = %s.\n", rplay_default_host ()); - printf ("\n"); - - printf ("-i INFO, --info=INFO\n"); - printf ("\tAudio information for a sound file. This option is intended\n"); - printf ("\tto be used when sounds are read from standard input.\n"); - printf ("\tINFO must be of the form:\n"); - printf ("\t `format,sample-rate,bits,channels,byte-order,offset'\n"); - printf ("\tExamples: ulaw,8000,8,1,big-endian,0\n"); - printf ("\t gsm,8000\n"); - printf ("\tShorthand info is provided for Sun's audio devices using the\n"); - printf ("\tfollowing options: --info-amd, --info-dbri, --info-cs4231.\n"); - printf ("\tThere's also: --info-ulaw and --info-gsm.\n"); - printf ("\n"); - - printf ("-p, --pause\n"); - printf ("\tPause sounds.\n"); - printf ("\n"); - - printf ("--port=PORT\n"); - printf ("\tUse PORT instead of the default RPLAY/UDP or RPTP/TCP port.\n"); - printf ("\n"); - - printf ("-P N, --priority=N\n"); - printf ("\tPlay sounds at priority N (%d <= N <= %d), default = %d.\n", - RPLAY_MIN_PRIORITY, - RPLAY_MAX_PRIORITY, - RPLAY_DEFAULT_PRIORITY); - printf ("\n"); - - printf ("-r, --random\n"); - printf ("\tRandomly choose one of the given sounds.\n"); - printf ("\n"); - - printf ("--reset\n"); - printf ("\tTell the server to reset itself.\n"); - printf ("\n"); - - printf ("--rplay, --RPLAY\n"); - printf ("\tForce the use of the RPLAY protocol.\n"); - printf ("\ + printf("\nrplay %s\n\n", RPLAY_VERSION); + printf("usage: rplay [options] [sound ... ]\n\n"); + + printf("-b BYTES, --buffer-size=BYTES\n"); + printf("\tUse of a buffer size of BYTES when playing sounds using RPTP flows.\n"); + printf("\tThe default is 8K.\n"); + printf("\n"); + + printf("-c, --continue\n"); + printf("\tContinue sounds.\n"); + printf("\n"); + + printf("-n N, --count=N\n"); + printf("\tNumber of times to play the sound, default = %d.\n", + RPLAY_DEFAULT_COUNT); + printf("\n"); + + printf("-N N, --list-count=N\n"); + printf("\tNumber of times to play all the sounds, default = %d.\n", + RPLAY_DEFAULT_LIST_COUNT); + printf("\n"); + + printf("--list-name=NAME\n"); + printf("\tName this list NAME. rplayd appends sounds with the same\n"); + printf("\tNAME into the same sound list -- it plays them sequentially.\n"); + printf("\n"); + + printf("--help\n"); + printf("\tDisplay helpful information.\n"); + printf("\n"); + + printf("-h HOST, --host=HOST, --hosts=HOST\n"); + printf("\tSpecify the rplay host, default = %s.\n", rplay_default_host()); + printf("\n"); + + printf("-i INFO, --info=INFO\n"); + printf("\tAudio information for a sound file. This option is intended\n"); + printf("\tto be used when sounds are read from standard input.\n"); + printf("\tINFO must be of the form:\n"); + printf("\t `format,sample-rate,bits,channels,byte-order,offset'\n"); + printf("\tExamples: ulaw,8000,8,1,big-endian,0\n"); + printf("\t gsm,8000\n"); + printf("\tShorthand info is provided for Sun's audio devices using the\n"); + printf("\tfollowing options: --info-amd, --info-dbri, --info-cs4231.\n"); + printf("\tThere's also: --info-ulaw and --info-gsm.\n"); + printf("\n"); + + printf("-p, --pause\n"); + printf("\tPause sounds.\n"); + printf("\n"); + + printf("--port=PORT\n"); + printf("\tUse PORT instead of the default RPLAY/UDP or RPTP/TCP port.\n"); + printf("\n"); + + printf("-P N, --priority=N\n"); + printf("\tPlay sounds at priority N (%d <= N <= %d), default = %d.\n", + RPLAY_MIN_PRIORITY, + RPLAY_MAX_PRIORITY, + RPLAY_DEFAULT_PRIORITY); + printf("\n"); + + printf("-r, --random\n"); + printf("\tRandomly choose one of the given sounds.\n"); + printf("\n"); + + printf("--reset\n"); + printf("\tTell the server to reset itself.\n"); + printf("\n"); + + printf("--rplay, --RPLAY\n"); + printf("\tForce the use of the RPLAY protocol.\n"); + printf("\ \tThe default protocol to be used is determined by checking whether or not\n\ \tthe server has local access to the specified sounds. RPLAY is used when\n\ \tsounds are accessible, otherwise RPTP and possibly flows are used.\n\ \tRPLAY will also be used when sound accessibility cannot be determined.\n"); - printf ("\n"); - - printf ("--rptp, --RPTP\n"); - printf ("\tForce the use of the RPTP protocol.\n"); - printf ("\tSee `--rplay' for more information about protocols.\n"); - printf ("\n"); - - printf ("-R N, --sample-rate=N\n"); - printf ("\tPlay sounds at sample rate N, default = %d.\n", - RPLAY_DEFAULT_SAMPLE_RATE); - printf ("\n"); - - printf ("-s, --stop\n"); - printf ("\tStop sounds.\n"); - printf ("\n"); - - printf ("--version\n"); - printf ("\tPrint the rplay version and exit.\n"); - printf ("\n"); - - printf ("-v N, --volume=N\n"); - printf ("\tPlay sounds at volume N (%d <= N <= %d), default = %d.\n", - RPLAY_MIN_VOLUME, - RPLAY_MAX_VOLUME, - RPLAY_DEFAULT_VOLUME); - - exit (1); + printf("\n"); + + printf("--rptp, --RPTP\n"); + printf("\tForce the use of the RPTP protocol.\n"); + printf("\tSee `--rplay' for more information about protocols.\n"); + printf("\n"); + + printf("-R N, --sample-rate=N\n"); + printf("\tPlay sounds at sample rate N, default = %d.\n", + RPLAY_DEFAULT_SAMPLE_RATE); + printf("\n"); + + printf("-s, --stop\n"); + printf("\tStop sounds.\n"); + printf("\n"); + + printf("--version\n"); + printf("\tPrint the rplay version and exit.\n"); + printf("\n"); + + printf("-v N, --volume=N\n"); + printf("\tPlay sounds at volume N (%d <= N <= %d), default = %d.\n", + RPLAY_MIN_VOLUME, + RPLAY_MAX_VOLUME, + RPLAY_DEFAULT_VOLUME); + + exit(1); } diff --git a/rplayd/CVS/Entries b/rplayd/CVS/Entries deleted file mode 100644 index cf3c7bb..0000000 --- a/rplayd/CVS/Entries +++ /dev/null @@ -1,36 +0,0 @@ -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998// -D/audio//// -/buffer.c/1.2/Thu Aug 13 06:13:40 1998// -/buffer.h/1.2/Thu Aug 13 06:13:41 1998// -/cache.c/1.2/Thu Aug 13 06:13:42 1998// -/cache.h/1.2/Thu Aug 13 06:13:43 1998// -/cdrom.c/1.2/Thu Aug 13 06:13:44 1998// -/cdrom.h/1.2/Thu Aug 13 06:13:45 1998// -/command.c/1.2/Thu Aug 13 06:13:46 1998// -/command.h/1.2/Thu Aug 13 06:13:47 1998// -/connection.h/1.2/Thu Aug 13 06:13:49 1998// -/flange.c/1.2/Thu Aug 13 06:13:50 1998// -/flange.h/1.2/Thu Aug 13 06:13:51 1998// -/helper.c/1.2/Thu Aug 13 06:13:52 1998// -/helper.h/1.2/Thu Aug 13 06:13:53 1998// -/host.c/1.2/Thu Aug 13 06:13:54 1998// -/host.h/1.2/Thu Aug 13 06:13:55 1998// -/misc.c/1.2/Thu Aug 13 06:13:56 1998// -/misc.h/1.2/Thu Aug 13 06:13:57 1998// -/native.c/1.2/Thu Aug 13 06:13:58 1998// -/native.h/1.2/Thu Aug 13 06:14:00 1998// -/rplayd.c/1.2/Thu Aug 13 06:14:01 1998// -/rplayd.h/1.2/Thu Aug 13 06:14:02 1998// -/server.c/1.2/Thu Aug 13 06:14:03 1998// -/server.h/1.2/Thu Aug 13 06:14:04 1998// -/sound.h/1.2/Thu Aug 13 06:14:06 1998// -/spool.c/1.2/Thu Aug 13 06:14:07 1998// -/spool.h/1.2/Thu Aug 13 06:14:08 1998// -/timer.c/1.2/Thu Aug 13 06:14:09 1998// -/timer.h/1.2/Thu Aug 13 06:14:10 1998// -/ulaw.c/1.2/Thu Aug 13 06:14:11 1998// -/ulaw.h/1.2/Thu Aug 13 06:14:12 1998// -/xhash.c/1.2/Thu Aug 13 06:14:13 1998// -/xhash.h/1.2/Thu Aug 13 06:14:14 1998// -/connection.c/1.3/Mon Oct 12 16:03:20 1998// -/sound.c/1.6/Thu Oct 15 15:15:25 1998// diff --git a/rplayd/CVS/Repository b/rplayd/CVS/Repository deleted file mode 100644 index 56c0c80..0000000 --- a/rplayd/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/rplayd diff --git a/rplayd/CVS/Root b/rplayd/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/rplayd/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/rplayd/Makefile.in b/rplayd/Makefile.in index fee3e39..04ee513 100644 --- a/rplayd/Makefile.in +++ b/rplayd/Makefile.in @@ -9,7 +9,10 @@ INSTALL_DATA = @INSTALL_DATA@ MKINSTALLDIRS= @srcdir@/../mkinstalldirs -CPPFLAGS = $(CC_OPTIONS) -I. -I../include -I@srcdir@ -I@srcdir@/../include -I@srcdir@/../lib -I@srcdir@/../adpcm -I@srcdir@/../gsm -I@srcdir@/../rx @DEFS@ \ +CPPFLAGS = $(CC_OPTIONS) -I. -I../include -I${srcdir} -I${srcdir}/../include \ + -I${srcdir}/../lib -I${srcdir}/../adpcm \ + @GSM_INCS@ \ + @RX_INCS@ @DEFS@ \ -DRPLAY_CONF=\"${sysconfdir}/rplay.conf\" \ -DRPLAY_HOSTS=\"${sysconfdir}/rplay.hosts\" \ -DRPLAY_SERVERS=\"${sysconfdir}/rplay.servers\" \ @@ -22,7 +25,7 @@ $(CC) -c $(CPPFLAGS) $(CFLAGS) $< LDFLAGS= $(LD_OPTIONS) -L../librplay -lrplay -L../lib -lrp \ - -L../adpcm -ladpcm -L../gsm -lgsm -L../rx -lrx @LDFLAGS@ @LIBS@ -lm + -L../adpcm -ladpcm @GSM_LIBS@ -L../rx -lrx @LDFLAGS@ @LIBS@ -lm TARGET= rplayd @@ -36,8 +39,17 @@ all: $(TARGET) -$(TARGET): $(OBJS) ../librplay/$(LIBRPLAY_NAME) ../lib/librp.a ../adpcm/libadpcm.a ../rx/librx.a +$(TARGET): $(OBJS) ../librplay/$(LIBRPLAY_NAME) ../lib/librp.a ../adpcm/libadpcm.a $(CC) -o $@ $(OBJS) $(LDFLAGS) + +../librplay/$(LIBRPLAY_NAME): + (cd ../librplay; $(MAKE) $(MFLAGS)) + +../lib/librp.a: + (cd ../lib; $(MAKE) $(MFLAGS)) + +../adpcm/libadpcm.a: + (cd ../adpcm; $(MAKE) $(MFLAGS)) install: all $(MKINSTALLDIRS) $(sbindir) diff --git a/rplayd/audio/CVS/Entries b/rplayd/audio/CVS/Entries deleted file mode 100644 index 3ef33b2..0000000 --- a/rplayd/audio/CVS/Entries +++ /dev/null @@ -1,16 +0,0 @@ -/README/1.1.1.1/Tue Jul 14 22:35:23 1998// -/audio_FreeBSD.h/1.2/Thu Aug 13 06:14:16 1998// -/audio_generic.h/1.2/Thu Aug 13 06:14:18 1998// -/audio_oss.h/1.2/Thu Aug 13 06:14:20 1998// -/audio_sgi.c/1.2/Thu Aug 13 06:14:21 1998// -/audio_sgi.h/1.2/Thu Aug 13 06:14:22 1998// -/audio_solaris.h/1.2/Thu Aug 13 06:14:25 1998// -/audio_sun.h/1.2/Thu Aug 13 06:14:27 1998// -/audio_hpux.h/1.1.1.1/Thu Aug 13 06:09:36 1998// -/audio_FreeBSD.c/1.3/Thu Sep 3 06:08:44 1998// -/audio_generic.c/1.3/Thu Sep 3 06:08:45 1998// -/audio_hpux.c/1.2/Thu Sep 3 05:48:37 1998// -/audio_oss.c/1.3/Thu Sep 3 06:08:47 1998// -/audio_solaris.c/1.3/Thu Sep 3 06:08:48 1998// -/audio_sun.c/1.3/Thu Sep 3 06:08:49 1998// -D diff --git a/rplayd/audio/CVS/Repository b/rplayd/audio/CVS/Repository deleted file mode 100644 index fac8aa6..0000000 --- a/rplayd/audio/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/rplayd/audio diff --git a/rplayd/audio/CVS/Root b/rplayd/audio/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/rplayd/audio/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/rplayd/audio/audio_FreeBSD.c b/rplayd/audio/audio_FreeBSD.c index f44c29e..290cb5b 100644 --- a/rplayd/audio/audio_FreeBSD.c +++ b/rplayd/audio/audio_FreeBSD.c @@ -1,7 +1,7 @@ -/* $Id: audio_FreeBSD.c,v 1.3 1998/09/03 06:08:44 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: audio_FreeBSD.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -86,16 +86,16 @@ * Return 0 on success and -1 on error. */ -int -rplay_audio_init (void) +int +rplay_audio_init(void) { int n; if (rplay_audio_fd == -1) { - if (rplay_audio_open () == -1) + if (rplay_audio_open() == -1) { - report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n", rplay_audio_device); + report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n", rplay_audio_device); return -1; } } @@ -111,17 +111,17 @@ */ n = rplay_audio_precision; - if (ioctl (rplay_audio_fd, SNDCTL_DSP_SAMPLESIZE, &n) == -1) - { - report (REPORT_ERROR, "rplay_audio_init: can't set audio precision to %d (%d)\n", - rplay_audio_precision, n); + if (ioctl(rplay_audio_fd, SNDCTL_DSP_SAMPLESIZE, &n) == -1) + { + report(REPORT_ERROR, "rplay_audio_init: can't set audio precision to %d (%d)\n", + rplay_audio_precision, n); return -1; } if (n != rplay_audio_precision) { - report (REPORT_NOTICE, "rplay_audio_init: audio precision changed from %d to %d\n", - rplay_audio_precision, n); + report(REPORT_NOTICE, "rplay_audio_init: audio precision changed from %d to %d\n", + rplay_audio_precision, n); rplay_audio_precision = n; } @@ -130,17 +130,17 @@ */ n = rplay_audio_channels; - if (ioctl (rplay_audio_fd, SOUND_PCM_WRITE_CHANNELS, &n) == -1) - { - report (REPORT_ERROR, "rplay_audio_init: can't set audio channels to %d (%d)\n", - rplay_audio_channels, n); + if (ioctl(rplay_audio_fd, SOUND_PCM_WRITE_CHANNELS, &n) == -1) + { + report(REPORT_ERROR, "rplay_audio_init: can't set audio channels to %d (%d)\n", + rplay_audio_channels, n); return -1; } if (n != rplay_audio_channels) { - report (REPORT_NOTICE, "rplay_audio_init: audio channels changed from %d to %d\n", - rplay_audio_channels, n); + report(REPORT_NOTICE, "rplay_audio_init: audio channels changed from %d to %d\n", + rplay_audio_channels, n); rplay_audio_channels = n; } @@ -150,17 +150,17 @@ n = rplay_audio_sample_rate; - if (ioctl (rplay_audio_fd, SNDCTL_DSP_SPEED, &n) == -1) - { - report (REPORT_ERROR, "rplay_audio_init: can't set audio sample rate to %d (%d)\n", - rplay_audio_sample_rate, n); + if (ioctl(rplay_audio_fd, SNDCTL_DSP_SPEED, &n) == -1) + { + report(REPORT_ERROR, "rplay_audio_init: can't set audio sample rate to %d (%d)\n", + rplay_audio_sample_rate, n); return (-1); } if (n != rplay_audio_sample_rate) { - report (REPORT_NOTICE, "rplay_audio_init: audio sample rate changed from %d to %d\n", - rplay_audio_sample_rate, n); + report(REPORT_NOTICE, "rplay_audio_init: audio sample rate changed from %d to %d\n", + rplay_audio_sample_rate, n); rplay_audio_sample_rate = n; } @@ -192,13 +192,13 @@ n = AFMT_IMA_ADPCM; break; default: - report (REPORT_ERROR, "rplay_audio_init: unknown audio format (%d)\n", rplay_audio_format); - return (-1); - } - - if (ioctl (rplay_audio_fd, SNDCTL_DSP_SETFMT, &n) == -1) - { - report (REPORT_ERROR, "rplay_audio_init: can't set audio format\n"); + report(REPORT_ERROR, "rplay_audio_init: unknown audio format (%d)\n", rplay_audio_format); + return (-1); + } + + if (ioctl(rplay_audio_fd, SNDCTL_DSP_SETFMT, &n) == -1) + { + report(REPORT_ERROR, "rplay_audio_init: can't set audio format\n"); return (-1); } @@ -207,12 +207,12 @@ */ if (n = curr_bufsize) { - if (ioctl (rplay_audio_fd, SNDCTL_DSP_SETBLKSIZE, &n) == -1) + if (ioctl(rplay_audio_fd, SNDCTL_DSP_SETBLKSIZE, &n) == -1) { - report (REPORT_ERROR, "rplay_audio_init: can't set audio blocksize to %d\n", curr_bufsize); + report(REPORT_ERROR, "rplay_audio_init: can't set audio blocksize to %d\n", curr_bufsize); return (-1); } - report (REPORT_DEBUG, "rplay_audio_init: device blksize set to %d\n", n); + report(REPORT_DEBUG, "rplay_audio_init: device blksize set to %d\n", n); } rplay_audio_port = RPLAY_AUDIO_PORT_SPEAKER; @@ -225,21 +225,21 @@ * * Return 0 on success and -1 on error. */ -int -rplay_audio_open (void) -{ - if ((rplay_audio_fd = open (rplay_audio_device, (O_WRONLY | O_NONBLOCK), 0)) < 0) +int +rplay_audio_open(void) +{ + if ((rplay_audio_fd = open(rplay_audio_device, (O_WRONLY | O_NONBLOCK), 0)) < 0) return -1; - if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0) - { - report (REPORT_ERROR, - "rplay_audio_open: close-on-exec %d\n", - sys_err_str(errno)); + if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0) + { + report(REPORT_ERROR, + "rplay_audio_open: close-on-exec %d\n", + sys_err_str(errno)); /* return -1; */ } - if (rplay_audio_init () < 0) + if (rplay_audio_init() < 0) return -1; return 0; @@ -250,8 +250,8 @@ * * Return 1 for true and 0 for false. */ -int -rplay_audio_isopen (void) +int +rplay_audio_isopen(void) { return (rplay_audio_fd != -1); } @@ -262,11 +262,11 @@ * Return 0 on success and -1 on error. */ -int -rplay_audio_flush (void) +int +rplay_audio_flush(void) { if (rplay_audio_fd != -1) - return (ioctl (rplay_audio_fd, SNDCTL_DSP_POST, 0)); + return (ioctl(rplay_audio_fd, SNDCTL_DSP_POST, 0)); return 0; } @@ -276,22 +276,22 @@ * * Return bytes written on success and -1 on error. */ -int -rplay_audio_write (char *buf, int nbytes) +int +rplay_audio_write(char *buf, int nbytes) { int remain = nbytes; int xr; while (remain > 0) { - if ((xr = write (rplay_audio_fd, buf, remain)) == -1) + if ((xr = write(rplay_audio_fd, buf, remain)) == -1) { switch (errno) { case EWOULDBLOCK: continue; default: - report (REPORT_ERROR, "Error while writing to audio device (%s)\n", strerror (errno)); + report(REPORT_ERROR, "Error while writing to audio device (%s)\n", strerror(errno)); return (-1); } } @@ -309,12 +309,12 @@ * * Return 0 on success and -1 on error. */ -int -rplay_audio_close (void) +int +rplay_audio_close(void) { if (rplay_audio_fd != -1) { - close (rplay_audio_fd); + close(rplay_audio_fd); } rplay_audio_fd = -1; @@ -327,11 +327,11 @@ * * Return 0-255 or -1 on error. */ -int -rplay_audio_get_volume (void) +int +rplay_audio_get_volume(void) { #ifndef FAKE_VOLUME - + int mx; int mxdevmask; int left_vol; @@ -340,30 +340,30 @@ vol = left_vol = right_vol = 0; - if ((mx = open (RPLAY_MIXER_DEVICE, O_RDONLY)) == -1) - { - report (REPORT_ERROR, "rplay_audio_get_volume: unable to open mixer device\n"); - return (-1); - } - - if (ioctl (mx, SOUND_MIXER_READ_DEVMASK, &mxdevmask) == -1) - { - report (REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer device mask\n"); - close (mx); + if ((mx = open(RPLAY_MIXER_DEVICE, O_RDONLY)) == -1) + { + report(REPORT_ERROR, "rplay_audio_get_volume: unable to open mixer device\n"); + return (-1); + } + + if (ioctl(mx, SOUND_MIXER_READ_DEVMASK, &mxdevmask) == -1) + { + report(REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer device mask\n"); + close(mx); return (-1); } if (!(mxdevmask & SOUND_MIXER_PCM)) { - report (REPORT_ERROR, "rplay_audio_get_volume: pcm mixer device not installed\n"); - close (mx); - return (-1); - } - - if (ioctl (mx, SOUND_MIXER_READ_PCM, &vol) == -1) - { - report (REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer volume\n"); - close (mx); + report(REPORT_ERROR, "rplay_audio_get_volume: pcm mixer device not installed\n"); + close(mx); + return (-1); + } + + if (ioctl(mx, SOUND_MIXER_READ_PCM, &vol) == -1) + { + report(REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer volume\n"); + close(mx); return (-1); } else @@ -373,10 +373,10 @@ vol = (int) ((left_vol + right_vol) / 2); - report (REPORT_DEBUG, "current pcm-volume: %d:%d => %d\n", left_vol, right_vol, vol); - } - - close (mx); + report(REPORT_DEBUG, "current pcm-volume: %d:%d => %d\n", left_vol, right_vol, vol); + } + + close(mx); return (vol); @@ -391,8 +391,8 @@ * * Return the volume of the audio device 0-255 or -1. */ -int -rplay_audio_set_volume (int volume) +int +rplay_audio_set_volume(int volume) { #ifndef FAKE_VOLUME @@ -404,30 +404,30 @@ vol |= ((vol & 0x00ff) << 8); - if ((mx = open (RPLAY_MIXER_DEVICE, O_RDONLY)) == -1) - { - report (REPORT_ERROR, "rplay_audio_set_volume: unable to open mixer device\n"); - return (-1); - } - - if (ioctl (mx, SOUND_MIXER_READ_DEVMASK, &mxdevmask) == -1) - { - report (REPORT_ERROR, "rplay_audio_set_volume: unable to get mixer device mask\n"); - close (mx); + if ((mx = open(RPLAY_MIXER_DEVICE, O_RDONLY)) == -1) + { + report(REPORT_ERROR, "rplay_audio_set_volume: unable to open mixer device\n"); + return (-1); + } + + if (ioctl(mx, SOUND_MIXER_READ_DEVMASK, &mxdevmask) == -1) + { + report(REPORT_ERROR, "rplay_audio_set_volume: unable to get mixer device mask\n"); + close(mx); return (-1); } if (!(mxdevmask & SOUND_MIXER_PCM)) { - report (REPORT_ERROR, "rplay_audio_set_volume: pcm mixer device not installed\n"); - close (mx); - return (-1); - } - - if (ioctl (mx, SOUND_MIXER_WRITE_PCM, &vol) == -1) - { - report (REPORT_ERROR, "rplay_audio_set_volume: unable to set mixer volume\n"); - close (mx); + report(REPORT_ERROR, "rplay_audio_set_volume: pcm mixer device not installed\n"); + close(mx); + return (-1); + } + + if (ioctl(mx, SOUND_MIXER_WRITE_PCM, &vol) == -1) + { + report(REPORT_ERROR, "rplay_audio_set_volume: unable to set mixer volume\n"); + close(mx); return (-1); } else @@ -437,14 +437,14 @@ vol = (int) ((left_vol + right_vol) / 2); - report (REPORT_DEBUG, "rplay_audio_set_volume: pcm-volume set to %d:%d => %d\n", - left_vol, right_vol, vol); - } - - close (mx); + report(REPORT_DEBUG, "rplay_audio_set_volume: pcm-volume set to %d:%d => %d\n", + left_vol, right_vol, vol); + } + + close(mx); rplay_audio_volume = vol; - + return rplay_audio_volume; #else diff --git a/rplayd/audio/audio_FreeBSD.h b/rplayd/audio/audio_FreeBSD.h index 7f842c1..48ec5b1 100644 --- a/rplayd/audio/audio_FreeBSD.h +++ b/rplayd/audio/audio_FreeBSD.h @@ -1,7 +1,7 @@ -/* $Id: audio_FreeBSD.h,v 1.2 1998/08/13 06:14:16 boyns Exp $ */ +/* $Id: audio_FreeBSD.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/audio/audio_generic.c b/rplayd/audio/audio_generic.c index c0f3332..83868f1 100644 --- a/rplayd/audio/audio_generic.c +++ b/rplayd/audio/audio_generic.c @@ -1,7 +1,7 @@ -/* $Id: audio_generic.c,v 1.3 1998/09/03 06:08:45 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: audio_generic.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #include "rplayd.h" /* @@ -85,15 +85,15 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_init () +rplay_audio_init() { if (rplay_audio_fd == -1) { - rplay_audio_open (); + rplay_audio_open(); if (rplay_audio_fd == -1) { - report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n", - rplay_audio_device); + report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n", + rplay_audio_device); return -1; } } @@ -114,25 +114,25 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_open () +rplay_audio_open() { int flags; - rplay_audio_fd = open (rplay_audio_device, O_WRONLY | O_NDELAY, 0); + rplay_audio_fd = open(rplay_audio_device, O_WRONLY | O_NDELAY, 0); if (rplay_audio_fd < 0) { return -1; } - if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0) - { - report (REPORT_ERROR, - "rplay_audio_open: close-on-exec %d\n", - sys_err_str(errno)); + if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0) + { + report(REPORT_ERROR, + "rplay_audio_open: close-on-exec %d\n", + sys_err_str(errno)); /* return -1; */ } - if (rplay_audio_init () < 0) + if (rplay_audio_init() < 0) { return -1; } @@ -140,13 +140,13 @@ /* * Make sure the audio device writes are non-blocking. */ - flags = fcntl (rplay_audio_fd, F_GETFL, 0); + flags = fcntl(rplay_audio_fd, F_GETFL, 0); if (flags < 0) { return -1; } flags |= FNDELAY; - if (fcntl (rplay_audio_fd, F_SETFL, flags) < 0) + if (fcntl(rplay_audio_fd, F_SETFL, flags) < 0) { return -1; } @@ -160,7 +160,7 @@ * Return 1 for true and 0 for false. */ int -rplay_audio_isopen () +rplay_audio_isopen() { return rplay_audio_fd != -1; } @@ -171,7 +171,7 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_flush () +rplay_audio_flush() { return 0; } @@ -183,10 +183,10 @@ */ #ifdef __STDC__ int -rplay_audio_write (char *buf, int nbytes) +rplay_audio_write(char *buf, int nbytes) #else int -rplay_audio_write (buf, nbytes) +rplay_audio_write(buf, nbytes) char *buf; int nbytes; #endif @@ -199,7 +199,7 @@ for (p = buf; nleft > 0; nleft -= n, p += n) { - n = write (rplay_audio_fd, p, nleft); + n = write(rplay_audio_fd, p, nleft); if (n < 0) { if (errno == EWOULDBLOCK) @@ -227,11 +227,11 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_close () +rplay_audio_close() { if (rplay_audio_fd != -1) { - close (rplay_audio_fd); + close(rplay_audio_fd); } rplay_audio_fd = -1; @@ -245,7 +245,7 @@ * Return 0-255 or -1 on error. */ int -rplay_audio_get_volume () +rplay_audio_get_volume() { #ifdef FAKE_VOLUME return rplay_audio_volume; @@ -262,10 +262,10 @@ */ #ifdef __STDC__ int -rplay_audio_set_volume (int volume) +rplay_audio_set_volume(int volume) #else int -rplay_audio_set_volume (volume) +rplay_audio_set_volume(volume) int volume; #endif { diff --git a/rplayd/audio/audio_generic.h b/rplayd/audio/audio_generic.h index 070deae..3e4c913 100644 --- a/rplayd/audio/audio_generic.h +++ b/rplayd/audio/audio_generic.h @@ -1,7 +1,7 @@ -/* $Id: audio_generic.h,v 1.2 1998/08/13 06:14:18 boyns Exp $ */ +/* $Id: audio_generic.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/audio/audio_hpux.c b/rplayd/audio/audio_hpux.c index 61366e2..f8782d7 100644 --- a/rplayd/audio/audio_hpux.c +++ b/rplayd/audio/audio_hpux.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -80,7 +80,7 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_init () +rplay_audio_init() { struct audio_describe ad; struct audio_status as; @@ -92,66 +92,66 @@ /* Open the audio device */ if (rplay_audio_fd == -1) { - rplay_audio_open (); + rplay_audio_open(); if (rplay_audio_fd == -1) { - report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n", - rplay_audio_device); + report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n", + rplay_audio_device); return -1; } } /* Reset the audio device */ - if (ioctl (rplay_audio_fd, AUDIO_RESET, RESET_RX_BUF | RESET_TX_BUF | RESET_RX_OVF | RESET_TX_UNF) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_RESET: %s\n", sys_err_str (errno)); + if (ioctl(rplay_audio_fd, AUDIO_RESET, RESET_RX_BUF | RESET_TX_BUF | RESET_RX_OVF | RESET_TX_UNF) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_RESET: %s\n", sys_err_str(errno)); return -1; } /* Interrogate the audio device */ - if (ioctl (rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_DESCRIBE: %s\n", sys_err_str (errno)); - return -1; - } - - if (ioctl (rplay_audio_fd, AUDIO_GET_STATUS, &as) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_GET_STATUS: %s\n", sys_err_str (errno)); - return -1; - } - if (ioctl (rplay_audio_fd, AUDIO_GET_SAMPLE_RATE, &ar) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_GET_SAMPLE_RATE: %s\n", sys_err_str (errno)); - return -1; - } - if (ioctl (rplay_audio_fd, AUDIO_GET_DATA_FORMAT, &af) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_GET_DATA_FORMAT: %s\n", sys_err_str (errno)); - return -1; - } - if (ioctl (rplay_audio_fd, AUDIO_GET_OUTPUT, &ao) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_GET_OUTPUT: %s\n", sys_err_str (errno)); + if (ioctl(rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_DESCRIBE: %s\n", sys_err_str(errno)); + return -1; + } + + if (ioctl(rplay_audio_fd, AUDIO_GET_STATUS, &as) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_GET_STATUS: %s\n", sys_err_str(errno)); + return -1; + } + if (ioctl(rplay_audio_fd, AUDIO_GET_SAMPLE_RATE, &ar) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_GET_SAMPLE_RATE: %s\n", sys_err_str(errno)); + return -1; + } + if (ioctl(rplay_audio_fd, AUDIO_GET_DATA_FORMAT, &af) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_GET_DATA_FORMAT: %s\n", sys_err_str(errno)); + return -1; + } + if (ioctl(rplay_audio_fd, AUDIO_GET_OUTPUT, &ao) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_GET_OUTPUT: %s\n", sys_err_str(errno)); return -1; } #ifdef DEBUG - printf ("*** AUDIO_DESCRIBE DATA ***\n"); - printf ("audio_id:\t\t%d\tnrates:\t\t\t%d\tflags:\t%X\n", - ad.audio_id, ad.nrates, ad.flags); - printf ("max_bits_per_sample:\t%d\tnchannels:\t\t%d\n", - ad.max_bits_per_sample, ad.nchannels); - printf ("min_receive_gain:\t%d\tmin_transmit_gain:\t%d\tmin_monitor_gain:\t%d\n", - ad.min_receive_gain, ad.min_transmit_gain, ad.min_monitor_gain); - printf ("max_receive_gain:\t%d\tmax_transmit_gain:\t%d\tmax_monitor_gain:\t%d\n", - ad.max_receive_gain, ad.max_transmit_gain, ad.max_monitor_gain); - printf ("*** AUDIO_STATUS DATA ***\n"); - printf ("receive_status: %x\treceive_buffer_count: %d\treceive_overflow_count: %d\n", - as.receive_status, as.receive_buffer_count, as.receive_overflow_count); - printf ("transmit_status: %x\ttransmit_buffer_count: %d\ttransmit_underflow_count: %d\n", - as.transmit_status, as.transmit_buffer_count, as.transmit_underflow_count); - printf ("*** END DATA ***\n"); + printf("*** AUDIO_DESCRIBE DATA ***\n"); + printf("audio_id:\t\t%d\tnrates:\t\t\t%d\tflags:\t%X\n", + ad.audio_id, ad.nrates, ad.flags); + printf("max_bits_per_sample:\t%d\tnchannels:\t\t%d\n", + ad.max_bits_per_sample, ad.nchannels); + printf("min_receive_gain:\t%d\tmin_transmit_gain:\t%d\tmin_monitor_gain:\t%d\n", + ad.min_receive_gain, ad.min_transmit_gain, ad.min_monitor_gain); + printf("max_receive_gain:\t%d\tmax_transmit_gain:\t%d\tmax_monitor_gain:\t%d\n", + ad.max_receive_gain, ad.max_transmit_gain, ad.max_monitor_gain); + printf("*** AUDIO_STATUS DATA ***\n"); + printf("receive_status: %x\treceive_buffer_count: %d\treceive_overflow_count: %d\n", + as.receive_status, as.receive_buffer_count, as.receive_overflow_count); + printf("transmit_status: %x\ttransmit_buffer_count: %d\ttransmit_underflow_count: %d\n", + as.transmit_status, as.transmit_buffer_count, as.transmit_underflow_count); + printf("*** END DATA ***\n"); #endif /* Set internal configuration */ @@ -169,7 +169,7 @@ /* Only Ulaw, Alaw and linear 16-bit formats are allowed - anyone know what Alaw is ? */ rplay_audio_format = optional_format ? ((optional_format == RPLAY_FORMAT_ULAW) ? RPLAY_FORMAT_ULAW : - RPLAY_FORMAT_LINEAR_16) : RPLAY_FORMAT_LINEAR_16; + RPLAY_FORMAT_LINEAR_16) : RPLAY_FORMAT_LINEAR_16; af = (rplay_audio_format == RPLAY_FORMAT_ULAW) ? AUDIO_FORMAT_ULAW : AUDIO_FORMAT_LINEAR16BIT; @@ -178,45 +178,45 @@ /* Set the output device - how should this be specified ? */ rplay_audio_port = optional_port ? optional_port : - RPLAY_AUDIO_PORT_SPEAKER | RPLAY_AUDIO_PORT_HEADPHONE; /* default ports */ + RPLAY_AUDIO_PORT_SPEAKER | RPLAY_AUDIO_PORT_HEADPHONE; /* default ports */ ao = 0; - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT)) + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT)) { #ifdef AUDIO_LINE_OUT - SET_BIT (ao, AUDIO_LINE_OUT); + SET_BIT(ao, AUDIO_LINE_OUT); #endif #ifdef AUDIO_OUT_LINE - SET_BIT (ao, AUDIO_OUT_LINE); -#endif - } - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE)) - { - SET_BIT (ao, AUDIO_OUT_HEADPHONE); - } - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) - { - SET_BIT (ao, AUDIO_OUT_SPEAKER); + SET_BIT(ao, AUDIO_OUT_LINE); +#endif + } + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE)) + { + SET_BIT(ao, AUDIO_OUT_HEADPHONE); + } + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) + { + SET_BIT(ao, AUDIO_OUT_SPEAKER); } /* Program the audio device */ - if (ioctl (rplay_audio_fd, AUDIO_SET_SAMPLE_RATE, ar) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_SET_SAMPLE_RATE: %s\n", sys_err_str (errno)); - return -1; - } - if (ioctl (rplay_audio_fd, AUDIO_SET_CHANNELS, ac) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_SET_CHANNELS: %s\n", sys_err_str (errno)); - return -1; - } - if (ioctl (rplay_audio_fd, AUDIO_SET_DATA_FORMAT, af) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_SET_DATA_FORMAT: %s\n", sys_err_str (errno)); - return -1; - } - if (ioctl (rplay_audio_fd, AUDIO_SET_OUTPUT, ao) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_SET_OUTPUTT: %s\n", sys_err_str (errno)); + if (ioctl(rplay_audio_fd, AUDIO_SET_SAMPLE_RATE, ar) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_SET_SAMPLE_RATE: %s\n", sys_err_str(errno)); + return -1; + } + if (ioctl(rplay_audio_fd, AUDIO_SET_CHANNELS, ac) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_SET_CHANNELS: %s\n", sys_err_str(errno)); + return -1; + } + if (ioctl(rplay_audio_fd, AUDIO_SET_DATA_FORMAT, af) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_SET_DATA_FORMAT: %s\n", sys_err_str(errno)); + return -1; + } + if (ioctl(rplay_audio_fd, AUDIO_SET_OUTPUT, ao) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_SET_OUTPUTT: %s\n", sys_err_str(errno)); return -1; } @@ -229,27 +229,27 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_open () +rplay_audio_open() { int flags; - report (REPORT_DEBUG, "opening device >%s<\n", rplay_audio_device); - - rplay_audio_fd = open (rplay_audio_device, O_WRONLY | O_NDELAY, 0); + report(REPORT_DEBUG, "opening device >%s<\n", rplay_audio_device); + + rplay_audio_fd = open(rplay_audio_device, O_WRONLY | O_NDELAY, 0); if (rplay_audio_fd < 0) { return -1; } - if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0) - { - report (REPORT_ERROR, - "rplay_audio_open: close-on-exec %d\n", - sys_err_str(errno)); + if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0) + { + report(REPORT_ERROR, + "rplay_audio_open: close-on-exec %d\n", + sys_err_str(errno)); /* return -1; */ } - if (rplay_audio_init () < 0) + if (rplay_audio_init() < 0) { return -1; } @@ -257,13 +257,13 @@ /* * Make sure the audio device writes are non-blocking. */ - flags = fcntl (rplay_audio_fd, F_GETFL, 0); + flags = fcntl(rplay_audio_fd, F_GETFL, 0); if (flags < 0) { return -1; } flags |= FNDELAY; - if (fcntl (rplay_audio_fd, F_SETFL, flags) < 0) + if (fcntl(rplay_audio_fd, F_SETFL, flags) < 0) { return -1; } @@ -277,7 +277,7 @@ * Return 1 for true and 0 for false. */ int -rplay_audio_isopen () +rplay_audio_isopen() { return (rplay_audio_fd != -1); } @@ -288,13 +288,13 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_flush () +rplay_audio_flush() { if (rplay_audio_fd != -1) { - if (ioctl (rplay_audio_fd, AUDIO_DRAIN, 0) < 0) + if (ioctl(rplay_audio_fd, AUDIO_DRAIN, 0) < 0) { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_DRAIN: %s\n", sys_err_str (errno)); + report(REPORT_ERROR, "rplay_audio_init: AUDIO_DRAIN: %s\n", sys_err_str(errno)); } } @@ -308,10 +308,10 @@ */ #ifdef __STDC__ int -rplay_audio_write (char *buf, int nbytes) +rplay_audio_write(char *buf, int nbytes) #else int -rplay_audio_write (buf, nbytes) +rplay_audio_write(buf, nbytes) char *buf; int nbytes; #endif @@ -324,7 +324,7 @@ for (p = buf; nleft > 0; nleft -= n, p += n) { - if ((n = write (rplay_audio_fd, p, nleft)) < 0) + if ((n = write(rplay_audio_fd, p, nleft)) < 0) { /* report(RPLAY_DEBUG, "rplay_audio_write: %s\n", sys_err_str(errno)); */ @@ -334,7 +334,7 @@ } else if (errno != EINTR) { - report (REPORT_ERROR, "rplay_audio_write: %s\n", sys_err_str (errno)); + report(REPORT_ERROR, "rplay_audio_write: %s\n", sys_err_str(errno)); return -1; } n = 0; @@ -354,11 +354,11 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_close () +rplay_audio_close() { if (rplay_audio_fd != -1) { - close (rplay_audio_fd); + close(rplay_audio_fd); } rplay_audio_fd = -1; @@ -372,7 +372,7 @@ * Return 0-255 or -1 on error. */ int -rplay_audio_get_volume () +rplay_audio_get_volume() { #ifdef FAKE_VOLUME return rplay_audio_volume; @@ -382,35 +382,35 @@ if (rplay_audio_fd < 0) { - rplay_audio_open (); + rplay_audio_open(); } if (rplay_audio_fd < 0) { return -1; } - if (ioctl (rplay_audio_fd, AUDIO_GET_GAINS, &ag) < 0) - { - report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_GET_GAINS: %s\n", sys_err_str (errno)); - return -1; - } - if (ioctl (rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0) - { - report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_DESCRIBE: %s\n", sys_err_str (errno)); + if (ioctl(rplay_audio_fd, AUDIO_GET_GAINS, &ag) < 0) + { + report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_GET_GAINS: %s\n", sys_err_str(errno)); + return -1; + } + if (ioctl(rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0) + { + report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_DESCRIBE: %s\n", sys_err_str(errno)); return -1; } #ifdef DEBUG - printf ("audio.c: ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n", - ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain); - printf ("audio.c: ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n", - ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain); - printf ("audio.c: channel_mask: %d\n", ag.channel_mask); + printf("audio.c: ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n", + ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain); + printf("audio.c: ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n", + ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain); + printf("audio.c: channel_mask: %d\n", ag.channel_mask); #endif return ((unsigned char) ( - ((double) ag.cgain[1].transmit_gain - ad.min_transmit_gain) - / (ad.max_transmit_gain - ad.min_transmit_gain) - * 256)); + ((double) ag.cgain[1].transmit_gain - ad.min_transmit_gain) + / (ad.max_transmit_gain - ad.min_transmit_gain) + * 256)); #endif /* not FAKE_VOLUME */ } @@ -422,10 +422,10 @@ */ #ifdef __STDC__ int -rplay_audio_set_volume (int volume) +rplay_audio_set_volume(int volume) #else int -rplay_audio_set_volume (volume) +rplay_audio_set_volume(volume) int volume; #endif { @@ -449,52 +449,52 @@ if (rplay_audio_fd < 0) { - rplay_audio_open (); + rplay_audio_open(); } if (rplay_audio_fd < 0) { return -1; } - if (ioctl (rplay_audio_fd, AUDIO_GET_GAINS, &ag) < 0) - { - report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_GET_GAINS: %s\n", sys_err_str (errno)); - return -1; - } - if (ioctl (rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0) - { - report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_DESCRIBE: %s\n", sys_err_str (errno)); + if (ioctl(rplay_audio_fd, AUDIO_GET_GAINS, &ag) < 0) + { + report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_GET_GAINS: %s\n", sys_err_str(errno)); + return -1; + } + if (ioctl(rplay_audio_fd, AUDIO_DESCRIBE, &ad) < 0) + { + report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_DESCRIBE: %s\n", sys_err_str(errno)); return -1; } #ifdef DEBUG - printf ("ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n", - ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain); - printf ("ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n", - ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain); - printf ("channel_mask: %d\n", ag.channel_mask); + printf("ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n", + ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain); + printf("ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n", + ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain); + printf("channel_mask: %d\n", ag.channel_mask); #endif ag.cgain[1].transmit_gain = ((int) ( - (((double) volume) - * (ad.max_transmit_gain - ad.min_transmit_gain) - / 256) - + ad.min_transmit_gain)); - -#ifdef DEBUG - printf ("ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n", - ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain); - printf ("ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n", - ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain); - printf ("channel_mask: %d\n", ag.channel_mask); -#endif - - if (ioctl (rplay_audio_fd, AUDIO_SET_GAINS, ag) < 0) - { - report (REPORT_ERROR, "rplay_audio_get_volume: AUDIO_SET_GAINS: %s\n", sys_err_str (errno)); - return -1; - } - - rplay_audio_volume = rplay_audio_get_volume (); + (((double) volume) + * (ad.max_transmit_gain - ad.min_transmit_gain) + / 256) + + ad.min_transmit_gain)); + +#ifdef DEBUG + printf("ag.cgain[1].receive_gain: %d\tag.cgain[1].transmit_gain: %d\tag.cgain[1].monitor_gain: %d\n", + ag.cgain[1].receive_gain, ag.cgain[1].transmit_gain, ag.cgain[1].monitor_gain); + printf("ag.cgain[2].receive_gain: %d\tag.cgain[2].transmit_gain: %d\tag.cgain[2].monitor_gain: %d\n", + ag.cgain[2].receive_gain, ag.cgain[2].transmit_gain, ag.cgain[2].monitor_gain); + printf("channel_mask: %d\n", ag.channel_mask); +#endif + + if (ioctl(rplay_audio_fd, AUDIO_SET_GAINS, ag) < 0) + { + report(REPORT_ERROR, "rplay_audio_get_volume: AUDIO_SET_GAINS: %s\n", sys_err_str(errno)); + return -1; + } + + rplay_audio_volume = rplay_audio_get_volume(); return rplay_audio_volume; #endif /* not FAKE_VOLUME */ diff --git a/rplayd/audio/audio_hpux.h b/rplayd/audio/audio_hpux.h index 4652a86..2712fef 100644 --- a/rplayd/audio/audio_hpux.h +++ b/rplayd/audio/audio_hpux.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/audio/audio_oss.c b/rplayd/audio/audio_oss.c index 25f01f5..7c8678b 100644 --- a/rplayd/audio/audio_oss.c +++ b/rplayd/audio/audio_oss.c @@ -1,7 +1,7 @@ -/* $Id: audio_oss.c,v 1.3 1998/09/03 06:08:47 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: audio_oss.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #include "rplayd.h" /* @@ -78,80 +78,80 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_init () +rplay_audio_init() { int n; if (rplay_audio_fd == -1) { - rplay_audio_open (); + rplay_audio_open(); if (rplay_audio_fd == -1) { - report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n", rplay_audio_device); + report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n", rplay_audio_device); return -1; } } /* /dev/audio */ - if (strcmp (rplay_audio_device, "/dev/audio") == 0) + if (strcmp(rplay_audio_device, "/dev/audio") == 0) { rplay_audio_sample_rate = 8000; rplay_audio_precision = 8; rplay_audio_channels = 1; rplay_audio_format = RPLAY_FORMAT_ULAW; - rplay_audio_set_port (); + rplay_audio_set_port(); } /* /dev/dsp */ - else if (strcmp (rplay_audio_device, "/dev/dsp") == 0) + else if (strcmp(rplay_audio_device, "/dev/dsp") == 0) { rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 44100; rplay_audio_precision = optional_precision ? optional_precision : 16; rplay_audio_channels = optional_channels ? optional_channels : 2; - rplay_audio_set_port (); + rplay_audio_set_port(); /* Precision */ n = rplay_audio_precision; - if (ioctl (rplay_audio_fd, SNDCTL_DSP_SETFMT, &n) == -1) - { - report (REPORT_ERROR, "rplay_audio_init: can't set audio precision to %d (%d)\n", - rplay_audio_precision, n); + if (ioctl(rplay_audio_fd, SNDCTL_DSP_SETFMT, &n) == -1) + { + report(REPORT_ERROR, "rplay_audio_init: can't set audio precision to %d (%d)\n", + rplay_audio_precision, n); return -1; } if (n != rplay_audio_precision) { - report (REPORT_NOTICE, "rplay_audio_init: audio precision changed from %d to %d\n", - rplay_audio_precision, n); + report(REPORT_NOTICE, "rplay_audio_init: audio precision changed from %d to %d\n", + rplay_audio_precision, n); rplay_audio_precision = n; } /* Channels */ n = rplay_audio_channels; - if (ioctl (rplay_audio_fd, SNDCTL_DSP_CHANNELS, &n) == -1) - { - report (REPORT_ERROR, "rplay_audio_init: can't set audio channels to %d (%d)\n", - rplay_audio_channels, n); + if (ioctl(rplay_audio_fd, SNDCTL_DSP_CHANNELS, &n) == -1) + { + report(REPORT_ERROR, "rplay_audio_init: can't set audio channels to %d (%d)\n", + rplay_audio_channels, n); return -1; } if (n != rplay_audio_channels) { - report (REPORT_NOTICE, "rplay_audio_init: audio channels changed from %d to %d\n", - rplay_audio_channels, n); + report(REPORT_NOTICE, "rplay_audio_init: audio channels changed from %d to %d\n", + rplay_audio_channels, n); rplay_audio_channels = n; } /* Sample rate */ n = rplay_audio_sample_rate; - ioctl (rplay_audio_fd, SNDCTL_DSP_SYNC, NULL); - if (ioctl (rplay_audio_fd, SNDCTL_DSP_SPEED, &n) == -1) - { - report (REPORT_ERROR, "rplay_audio_init: can't set audio sample rate to %d (%d)\n", - rplay_audio_sample_rate, n); + ioctl(rplay_audio_fd, SNDCTL_DSP_SYNC, NULL); + if (ioctl(rplay_audio_fd, SNDCTL_DSP_SPEED, &n) == -1) + { + report(REPORT_ERROR, "rplay_audio_init: can't set audio sample rate to %d (%d)\n", + rplay_audio_sample_rate, n); return -1; } if (n != rplay_audio_sample_rate) { - report (REPORT_NOTICE, "rplay_audio_init: audio sample rate changed from %d to %d\n", - rplay_audio_sample_rate, n); + report(REPORT_NOTICE, "rplay_audio_init: audio sample rate changed from %d to %d\n", + rplay_audio_sample_rate, n); rplay_audio_sample_rate = n; } @@ -161,8 +161,8 @@ } else { - report (REPORT_ERROR, "rplay_audio_init: `%s' unknown audio device\n", - rplay_audio_device); + report(REPORT_ERROR, "rplay_audio_init: `%s' unknown audio device\n", + rplay_audio_device); return -1; } @@ -175,44 +175,44 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_open () +rplay_audio_open() { int flags; audio_buf_info info; int n, i; - rplay_audio_fd = open (rplay_audio_device, O_WRONLY, 0); + rplay_audio_fd = open(rplay_audio_device, O_WRONLY, 0); if (rplay_audio_fd < 0) { return -1; } - if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0) - { - report (REPORT_ERROR, - "rplay_audio_open: close-on-exec %d\n", - sys_err_str(errno)); + if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0) + { + report(REPORT_ERROR, + "rplay_audio_open: close-on-exec %d\n", + sys_err_str(errno)); /* return -1; */ } /* - From the OSS driver docs: - - Argument of this call is an integer encoded as 0xMMMMSSSS (in hex). - - The 16 least significant bits determine the fragment size. The size is - 2SSSS. For example SSSS=0008 gives fragment size of 256 bytes (28). - The minimum is 16 bytes (SSSS=4) and the maximum is - total_buffer_size/2. Some devices or processor architectures may - require larger fragments in this case the requested fragment size is - automatically increased. - - The 16 most significant bits (MMMM) determine maximum number of - fragments. By default the deriver computes this based on available - buffer space. The minimum value is 2 and the maximum depends on the - situation. Set MMMM=0x7fff if you don't want to limit the number of - fragments. - */ + From the OSS driver docs: + + Argument of this call is an integer encoded as 0xMMMMSSSS (in hex). + + The 16 least significant bits determine the fragment size. The size is + 2SSSS. For example SSSS=0008 gives fragment size of 256 bytes (28). + The minimum is 16 bytes (SSSS=4) and the maximum is + total_buffer_size/2. Some devices or processor architectures may + require larger fragments in this case the requested fragment size is + automatically increased. + + The 16 most significant bits (MMMM) determine maximum number of + fragments. By default the deriver computes this based on available + buffer space. The minimum value is 2 and the maximum depends on the + situation. Set MMMM=0x7fff if you don't want to limit the number of + fragments. + */ /* Set the audio buffer fragment size. Default to zero which lets the driver pick. */ @@ -225,21 +225,21 @@ { n = 4096; } - + for (i = 0; n > 1; i++) { n >>= 1; } - rplay_audio_setfragsize ((0x7fff << 16) | i); - - ioctl (rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info); - report (REPORT_DEBUG, "OSS info: fragments=%d totalfrags=%d fragsize=%d DSP=%d\n", - info.fragments, info.fragstotal, info.fragsize, info.fragsize*info.fragstotal); + rplay_audio_setfragsize((0x7fff << 16) | i); + + ioctl(rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info); + report(REPORT_DEBUG, "OSS info: fragments=%d totalfrags=%d fragsize=%d DSP=%d\n", + info.fragments, info.fragstotal, info.fragsize, info.fragsize * info.fragstotal); rplay_audio_fragsize = info.fragsize; - - if (rplay_audio_init () < 0) + + if (rplay_audio_init() < 0) { return -1; } @@ -253,7 +253,7 @@ * Return 1 for true and 0 for false. */ int -rplay_audio_isopen () +rplay_audio_isopen() { return rplay_audio_fd != -1; } @@ -264,11 +264,11 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_flush () +rplay_audio_flush() { if (rplay_audio_fd != -1) { - ioctl (rplay_audio_fd, SNDCTL_DSP_SYNC, 0); + ioctl(rplay_audio_fd, SNDCTL_DSP_SYNC, 0); } return 0; @@ -281,15 +281,15 @@ */ #ifdef __STDC__ int -rplay_audio_write (char *buf, int nbytes) +rplay_audio_write(char *buf, int nbytes) #else int -rplay_audio_write (buf, nbytes) +rplay_audio_write(buf, nbytes) char *buf; int nbytes; #endif { - return write (rplay_audio_fd, buf, nbytes); + return write(rplay_audio_fd, buf, nbytes); } /* @@ -298,11 +298,11 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_close () +rplay_audio_close() { if (rplay_audio_fd != -1) { - close (rplay_audio_fd); + close(rplay_audio_fd); } rplay_audio_fd = -1; @@ -311,81 +311,81 @@ } int -rplay_audio_set_port () +rplay_audio_set_port() { int mask = 0; int vol = 0; - + if (rplay_audio_mixer_fd == -1) { - if (rplay_audio_mixer_open () < 0) + if (rplay_audio_mixer_open() < 0) { return -1; } } - if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0) - { - return -1; - } - + if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0) + { + return -1; + } + rplay_audio_port = optional_port ? optional_port : RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_SPEAKER | RPLAY_AUDIO_PORT_HEADPHONE; /* Clear any ports that aren't available. */ - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT|RPLAY_AUDIO_PORT_HEADPHONE)) - { - if (! (mask & SOUND_MASK_VOLUME)) - { - CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT|RPLAY_AUDIO_PORT_HEADPHONE); - } - } - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) - { - if (! (mask & SOUND_MASK_SPEAKER)) - { - CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER); - } - } - - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT|RPLAY_AUDIO_PORT_HEADPHONE)) - { - rplay_audio_port |= RPLAY_AUDIO_PORT_LINEOUT|RPLAY_AUDIO_PORT_HEADPHONE; + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_HEADPHONE)) + { + if (!(mask & SOUND_MASK_VOLUME)) + { + CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_HEADPHONE); + } + } + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) + { + if (!(mask & SOUND_MASK_SPEAKER)) + { + CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER); + } + } + + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_HEADPHONE)) + { + rplay_audio_port |= RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_HEADPHONE; /* Make sure the volume isn't zero. */ vol = 0; - ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_VOLUME , &vol); + ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_VOLUME, &vol); if (vol == 0) { vol = 50; vol |= ((vol & 0x00ff) << 8); - ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_VOLUME , &vol); + ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_VOLUME, &vol); } } else { /* Zero the volume. */ vol = 0; - ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_VOLUME , &vol); - } - - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) + ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_VOLUME, &vol); + } + + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) { vol = 0; - ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_SPEAKER , &vol); + ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_SPEAKER, &vol); /* Make sure the volume isn't zero. */ if (vol == 0) { vol = 50; vol |= ((vol & 0x00ff) << 8); - ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_SPEAKER , &vol); + ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_SPEAKER, &vol); } } else { /* Zero the volume. */ vol = 0; - ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_SPEAKER , &vol); + ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_SPEAKER, &vol); } } @@ -395,7 +395,7 @@ * Return 0-255 or -1 on error. */ int -rplay_audio_get_volume () +rplay_audio_get_volume() { #ifdef FAKE_VOLUME return rplay_audio_volume; @@ -409,27 +409,27 @@ if (rplay_audio_mixer_fd == -1) { - if (rplay_audio_mixer_open () < 0) + if (rplay_audio_mixer_open() < 0) { return -1; } } - - if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0) - { - report (REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer device mask\n"); + + if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0) + { + report(REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer device mask\n"); return -1; } if (!(mask & SOUND_MASK_PCM)) { - report (REPORT_ERROR, "rplay_audio_get_volume: pcm mixer device not installed\n"); - return -1; - } - - if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_PCM, &vol) < 0) - { - report (REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer volume\n"); + report(REPORT_ERROR, "rplay_audio_get_volume: pcm mixer device not installed\n"); + return -1; + } + + if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_PCM, &vol) < 0) + { + report(REPORT_ERROR, "rplay_audio_get_volume: unable to get mixer volume\n"); return -1; } else @@ -451,10 +451,10 @@ */ #ifdef __STDC__ int -rplay_audio_set_volume (int volume) +rplay_audio_set_volume(int volume) #else int -rplay_audio_set_volume (volume) +rplay_audio_set_volume(volume) int volume; #endif { @@ -480,27 +480,27 @@ if (rplay_audio_mixer_fd == -1) { - if (rplay_audio_mixer_open () < 0) + if (rplay_audio_mixer_open() < 0) { return -1; } } - if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0) - { - report (REPORT_ERROR, "rplay_audio_set_volume: unable to get mixer device mask\n"); + if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_READ_DEVMASK, &mask) < 0) + { + report(REPORT_ERROR, "rplay_audio_set_volume: unable to get mixer device mask\n"); return -1; } if (!(mask & SOUND_MASK_PCM)) { - report (REPORT_ERROR, "rplay_audio_set_volume: pcm mixer device not installed\n"); - return -1; - } - - if (ioctl (rplay_audio_mixer_fd, SOUND_MIXER_WRITE_PCM , &vol) < 0) - { - report (REPORT_ERROR, "rplay_audio_set_volume: unable to set mixer volume\n"); + report(REPORT_ERROR, "rplay_audio_set_volume: pcm mixer device not installed\n"); + return -1; + } + + if (ioctl(rplay_audio_mixer_fd, SOUND_MIXER_WRITE_PCM, &vol) < 0) + { + report(REPORT_ERROR, "rplay_audio_set_volume: unable to set mixer volume\n"); return -1; } else @@ -511,24 +511,24 @@ } rplay_audio_volume = vol; - + return rplay_audio_volume; #endif /* not FAKE_VOLUME */ } int -rplay_audio_getblksize () +rplay_audio_getblksize() { int blksize; - + if (rplay_audio_fd == -1) { return -1; } - if (ioctl (rplay_audio_fd, SNDCTL_DSP_GETBLKSIZE, &blksize) < 0) - { - report (REPORT_NOTICE, "DSP_GETBLKSIZE failed\n"); + if (ioctl(rplay_audio_fd, SNDCTL_DSP_GETBLKSIZE, &blksize) < 0) + { + report(REPORT_NOTICE, "DSP_GETBLKSIZE failed\n"); return -1; } else @@ -539,10 +539,10 @@ #ifdef __STDC__ int -rplay_audio_setfragsize (int frag) +rplay_audio_setfragsize(int frag) #else int -rplay_audio_setfragsize (frag) +rplay_audio_setfragsize(frag) int frag; #endif { @@ -553,18 +553,18 @@ return -1; } - n = ioctl (rplay_audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag); + n = ioctl(rplay_audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag); if (n < 0) { - report (REPORT_NOTICE, "DSP_SETFRAGMENT failed n = %d\n", n); - return -1; - } - + report(REPORT_NOTICE, "DSP_SETFRAGMENT failed n = %d\n", n); + return -1; + } + return 0; } int -rplay_audio_getospace_bytes () +rplay_audio_getospace_bytes() { audio_buf_info info; @@ -572,14 +572,14 @@ { return 0; } - ioctl (rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info); + ioctl(rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info); /* printf ("frags=%d fragtotal=%d fragsize=%d bytes=%d\n", */ -/* info.fragments, info.fragstotal, info.fragsize, info.bytes); */ +/* info.fragments, info.fragstotal, info.fragsize, info.bytes); */ return info.bytes; } int -rplay_audio_getospace_fragsize () +rplay_audio_getospace_fragsize() { audio_buf_info info; @@ -587,23 +587,23 @@ { return 0; } - ioctl (rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info); + ioctl(rplay_audio_fd, SNDCTL_DSP_GETOSPACE, &info); return info.fragsize; } int -rplay_audio_getfd () +rplay_audio_getfd() { return rplay_audio_fd; } int -rplay_audio_mixer_open () -{ - rplay_audio_mixer_fd = open (RPLAY_AUDIO_MIXER_DEVICE, O_RDONLY); +rplay_audio_mixer_open() +{ + rplay_audio_mixer_fd = open(RPLAY_AUDIO_MIXER_DEVICE, O_RDONLY); if (rplay_audio_mixer_fd < 0) { - report (REPORT_ERROR, "rplay_audio_mixer_open: unable to open mixer device\n"); + report(REPORT_ERROR, "rplay_audio_mixer_open: unable to open mixer device\n"); return -1; } @@ -611,18 +611,17 @@ } int -rplay_audio_mixer_close () +rplay_audio_mixer_close() { if (rplay_audio_mixer_fd != -1) { - close (rplay_audio_mixer_fd); + close(rplay_audio_mixer_fd); rplay_audio_mixer_fd = -1; } } int -rplay_audio_mixer_isopen () +rplay_audio_mixer_isopen() { return rplay_audio_mixer_fd != -1; } - diff --git a/rplayd/audio/audio_oss.h b/rplayd/audio/audio_oss.h index 5445d0e..8df7256 100644 --- a/rplayd/audio/audio_oss.h +++ b/rplayd/audio/audio_oss.h @@ -1,7 +1,7 @@ -/* $Id: audio_oss.h,v 1.2 1998/08/13 06:14:20 boyns Exp $ */ +/* $Id: audio_oss.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/audio/audio_sgi.c b/rplayd/audio/audio_sgi.c index 7050588..7fa966c 100644 --- a/rplayd/audio/audio_sgi.c +++ b/rplayd/audio/audio_sgi.c @@ -1,7 +1,8 @@ -/* $Id: audio_sgi.c,v 1.2 1998/08/13 06:14:21 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns + +/* $Id: audio_sgi.c,v 1.4 1999/03/10 07:58:10 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -80,7 +81,7 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_init () +rplay_audio_init() { ALconfig SGIconfig; long PVbuffer[4]; @@ -97,11 +98,11 @@ */ if (rplay_audio_fd == NULL) { - SGIconfig = ALnewconfig (); + SGIconfig = ALnewconfig(); } else { - SGIconfig = ALgetconfig (rplay_audio_fd); + SGIconfig = ALgetconfig(rplay_audio_fd); } if (SGIconfig == NULL) { @@ -116,14 +117,14 @@ switch (rplay_audio_precision) { case 8: - ALsetwidth (SGIconfig, AL_SAMPLE_8); + ALsetwidth(SGIconfig, AL_SAMPLE_8); if (errno != 0) { return -1; } break; case 16: - ALsetwidth (SGIconfig, AL_SAMPLE_16); + ALsetwidth(SGIconfig, AL_SAMPLE_16); if (errno != 0) { return -1; @@ -139,7 +140,7 @@ */ rplay_audio_format = (rplay_audio_precision == 16) ? RPLAY_FORMAT_LINEAR_16 : RPLAY_FORMAT_LINEAR_8; #ifdef AL_SAMPFMT_TWOSCOMP - if (ALsetsampfmt (SGIconfig, AL_SAMPFMT_TWOSCOMP) < 0) + if (ALsetsampfmt(SGIconfig, AL_SAMPFMT_TWOSCOMP) < 0) if (errno != 0) { return -1; @@ -154,14 +155,14 @@ switch (rplay_audio_channels) { case 1: - ALsetchannels (SGIconfig, AL_MONO); + ALsetchannels(SGIconfig, AL_MONO); if (errno != 0) { return -1; } break; case 2: - ALsetchannels (SGIconfig, AL_STEREO); + ALsetchannels(SGIconfig, AL_STEREO); if (errno != 0) { return -1; @@ -174,12 +175,12 @@ /* * Open the audio port. */ - rplay_audio_fd = ALopenport ("rplayd", "w", SGIconfig); - if (rplay_audio_fd == NULL) - { - return -1; - } - ALfreeconfig (SGIconfig); + rplay_audio_fd = ALopenport("rplayd", "w", SGIconfig); + if (rplay_audio_fd == NULL) + { + return -1; + } + ALfreeconfig(SGIconfig); /* * Set the sample rate of the output port. This defaults to 44100Khz @@ -188,7 +189,7 @@ rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 44100; PVbuffer[0] = AL_OUTPUT_RATE; PVbuffer[1] = rplay_audio_sample_rate; - ALsetparams (AL_DEFAULT_DEVICE, PVbuffer, 2); + ALsetparams(AL_DEFAULT_DEVICE, PVbuffer, 2); if (errno != 0) { return -1; @@ -209,9 +210,9 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_open () -{ - if (rplay_audio_init () < 0) +rplay_audio_open() +{ + if (rplay_audio_init() < 0) { return -1; } @@ -225,7 +226,7 @@ * Return 1 for true and 0 for false. */ int -rplay_audio_isopen () +rplay_audio_isopen() { return rplay_audio_fd != NULL; } @@ -236,7 +237,7 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_flush () +rplay_audio_flush() { return 0; } @@ -248,10 +249,10 @@ */ #ifdef __STDC__ int -rplay_audio_write (char *buf, int nbytes) +rplay_audio_write(char *buf, int nbytes) #else int -rplay_audio_write (buf, nbytes) +rplay_audio_write(buf, nbytes) char *buf; int nbytes; #endif @@ -260,7 +261,7 @@ if (rplay_audio_fd == NULL) { - if (rplay_audio_open () < 0) + if (rplay_audio_open() < 0) { return -1; } @@ -274,7 +275,7 @@ /* * Write the samples to the audio port. */ - ALwritesamps (rplay_audio_fd, buf, samples); + ALwritesamps(rplay_audio_fd, buf, samples); if (errno != 0) { return nbytes; @@ -288,11 +289,11 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_close () +rplay_audio_close() { if (rplay_audio_fd != NULL) { - ALcloseport (rplay_audio_fd); + ALcloseport(rplay_audio_fd); } rplay_audio_fd = NULL; @@ -306,7 +307,7 @@ * Return 0-255 or -1 on error. */ int -rplay_audio_get_volume () +rplay_audio_get_volume() { long PVbuffer[4]; @@ -315,7 +316,7 @@ #else /* not FAKE_VOLUME */ if (rplay_audio_fd == NULL) { - rplay_audio_open (); + rplay_audio_open(); } if (rplay_audio_fd == NULL) { @@ -323,7 +324,7 @@ } PVbuffer[0] = AL_LEFT_SPEAKER_GAIN; PVbuffer[2] = AL_RIGHT_SPEAKER_GAIN; - ALgetparams (AL_DEFAULT_DEVICE, PVbuffer, 4); + ALgetparams(AL_DEFAULT_DEVICE, PVbuffer, 4); if (errno != 0) { return -1; @@ -340,10 +341,10 @@ */ #ifdef __STDC__ int -rplay_audio_set_volume (int volume) +rplay_audio_set_volume(int volume) #else int -rplay_audio_set_volume (volume) +rplay_audio_set_volume(volume) int volume; #endif { @@ -367,7 +368,7 @@ if (rplay_audio_fd == NULL) { - rplay_audio_open (); + rplay_audio_open(); } if (rplay_audio_fd == NULL) { @@ -377,13 +378,13 @@ PVbuffer[1] = volume; PVbuffer[2] = AL_RIGHT_SPEAKER_GAIN; PVbuffer[3] = volume; - ALsetparams (AL_DEFAULT_DEVICE, PVbuffer, 4); + ALsetparams(AL_DEFAULT_DEVICE, PVbuffer, 4); if (errno != 0) { return -1; } - rplay_audio_volume = rplay_audio_get_volume (); + rplay_audio_volume = rplay_audio_get_volume(); return rplay_audio_volume; #endif /* not FAKE_VOLUME */ diff --git a/rplayd/audio/audio_sgi.h b/rplayd/audio/audio_sgi.h index dffba09..20338fe 100644 --- a/rplayd/audio/audio_sgi.h +++ b/rplayd/audio/audio_sgi.h @@ -1,7 +1,7 @@ -/* $Id: audio_sgi.h,v 1.2 1998/08/13 06:14:22 boyns Exp $ */ +/* $Id: audio_sgi.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/audio/audio_solaris.c b/rplayd/audio/audio_solaris.c index fac3a71..fa0f1b7 100644 --- a/rplayd/audio/audio_solaris.c +++ b/rplayd/audio/audio_solaris.c @@ -1,7 +1,7 @@ -/* $Id: audio_solaris.c,v 1.3 1998/09/03 06:08:48 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: audio_solaris.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #include "rplayd.h" /* @@ -64,31 +64,31 @@ static RPLAY_AUDIO_TABLE dbri_table[] = { - { 6615, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 6615, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 8000, RPLAY_FORMAT_ULAW , 8, 1 }, - { 8000, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 8000, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 9600, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 9600, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 11025, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 11025, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 16000, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 16000, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 18900, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 18900, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 22050, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 22050, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 32000, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 32000, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 33075, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 33075, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 37800, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 37800, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 44100, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 44100, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 48000, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 48000, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, + {6615, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {6615, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {8000, RPLAY_FORMAT_ULAW, 8, 1}, + {8000, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {8000, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {9600, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {9600, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {11025, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {11025, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {16000, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {16000, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {18900, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {18900, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {22050, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {22050, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {32000, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {32000, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {33075, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {33075, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {37800, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {37800, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {44100, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {44100, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {48000, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {48000, RPLAY_FORMAT_LINEAR_16, 16, 2}, {0, 0, 0, 0} }; @@ -113,32 +113,32 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_init () +rplay_audio_init() { audio_info_t a; audio_device_t d; if (rplay_audio_fd == -1) { - rplay_audio_open (); + rplay_audio_open(); if (rplay_audio_fd == -1) { - report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n", - rplay_audio_device); + report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n", + rplay_audio_device); return -1; } } - if (ioctl (rplay_audio_fd, AUDIO_GETDEV, &d) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_GETDEV: %s\n", - sys_err_str (errno)); - return -1; - } - - if (strcmp (d.name, "SUNW,dbri") == 0) - { - report (REPORT_DEBUG, "%s device detected\n", d.name); + if (ioctl(rplay_audio_fd, AUDIO_GETDEV, &d) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_GETDEV: %s\n", + sys_err_str(errno)); + return -1; + } + + if (strcmp(d.name, "SUNW,dbri") == 0) + { + report(REPORT_DEBUG, "%s device detected\n", d.name); rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 11025; rplay_audio_precision = optional_precision ? optional_precision : 16; rplay_audio_channels = optional_channels ? optional_channels : 1; @@ -147,20 +147,20 @@ rplay_audio_port = optional_port ? optional_port : RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_SPEAKER; rplay_audio_table = dbri_table; } - else if (strcmp (d.name, "SUNW,CS4231") == 0) - { - report (REPORT_DEBUG, "%s device detected\n", d.name); + else if (strcmp(d.name, "SUNW,CS4231") == 0) + { + report(REPORT_DEBUG, "%s device detected\n", d.name); rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 11025; rplay_audio_precision = optional_precision ? optional_precision : 16; rplay_audio_channels = optional_channels ? optional_channels : 1; rplay_audio_format = optional_format ? optional_format : rplay_audio_precision == 16 ? RPLAY_FORMAT_LINEAR_16 : RPLAY_FORMAT_LINEAR_8; rplay_audio_port = optional_port ? optional_port : RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_SPEAKER; - rplay_audio_table = dbri_table; /* use the dbri table */ - } - else if (strcmp (d.name, "SUNW,am79c30") == 0) - { - report (REPORT_DEBUG, "%s device detected\n", d.name); + rplay_audio_table = dbri_table; /* use the dbri table */ + } + else if (strcmp(d.name, "SUNW,am79c30") == 0) + { + report(REPORT_DEBUG, "%s device detected\n", d.name); rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 8000; rplay_audio_precision = optional_precision ? optional_precision : 8; rplay_audio_channels = optional_channels ? optional_channels : 1; @@ -168,20 +168,20 @@ rplay_audio_port = optional_port ? optional_port : RPLAY_AUDIO_PORT_SPEAKER; rplay_audio_table = amd_table; } - else if (strcmp (d.name, "SUNW,sb16") == 0) - { - report (REPORT_DEBUG, "%s device detected\n", d.name); + else if (strcmp(d.name, "SUNW,sb16") == 0) + { + report(REPORT_DEBUG, "%s device detected\n", d.name); rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 44100; rplay_audio_precision = optional_precision ? optional_precision : 16; rplay_audio_channels = optional_channels ? optional_channels : 2; rplay_audio_format = optional_format ? optional_format : rplay_audio_precision == 16 ? RPLAY_FORMAT_LINEAR_16 : RPLAY_FORMAT_LINEAR_8; rplay_audio_port = optional_port ? optional_port : RPLAY_AUDIO_PORT_LINEOUT | RPLAY_AUDIO_PORT_SPEAKER; - rplay_audio_table = dbri_table; /* use the dbri table */ + rplay_audio_table = dbri_table; /* use the dbri table */ } else { - report (REPORT_ERROR, "`%s' unknown audio device detected\n", d.name); + report(REPORT_ERROR, "`%s' unknown audio device detected\n", d.name); return -1; } @@ -192,8 +192,8 @@ if (rplay_audio_format != RPLAY_FORMAT_ULAW && rplay_audio_format != RPLAY_FORMAT_LINEAR_8) { - report (REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n", - rplay_audio_precision, rplay_audio_format); + report(REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n", + rplay_audio_precision, rplay_audio_format); return -1; } break; @@ -201,15 +201,15 @@ case 16: if (rplay_audio_format != RPLAY_FORMAT_LINEAR_16) { - report (REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n", - rplay_audio_precision, rplay_audio_format); + report(REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n", + rplay_audio_precision, rplay_audio_format); return -1; } break; default: - report (REPORT_ERROR, "rplay_audio_init: `%d' unsupported audio precision\n", - rplay_audio_precision); + report(REPORT_ERROR, "rplay_audio_init: `%d' unsupported audio precision\n", + rplay_audio_precision); return -1; } @@ -227,39 +227,39 @@ break; default: - report (REPORT_ERROR, "rplay_audio_init: unsupported audio format `%d'\n", - rplay_audio_format); + report(REPORT_ERROR, "rplay_audio_init: unsupported audio format `%d'\n", + rplay_audio_format); return -1; } /* Audio port. */ if (rplay_audio_port == RPLAY_AUDIO_PORT_NONE) { - a.play.port = ~0; /* see AUDIO_INITINFO in /usr/include/sys/audioio.h. */ + a.play.port = ~0; /* see AUDIO_INITINFO in /usr/include/sys/audioio.h. */ } else { a.play.port = 0; - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT)) + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT)) { #ifdef AUDIO_LINE_OUT - SET_BIT (a.play.port, AUDIO_LINE_OUT); + SET_BIT(a.play.port, AUDIO_LINE_OUT); #else - CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT); + CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT); #endif } - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE)) + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE)) { #ifdef AUDIO_HEADPHONE - SET_BIT (a.play.port, AUDIO_HEADPHONE); + SET_BIT(a.play.port, AUDIO_HEADPHONE); #else - CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE); + CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE); #endif } - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) { #ifdef AUDIO_SPEAKER - SET_BIT (a.play.port, AUDIO_SPEAKER); + SET_BIT(a.play.port, AUDIO_SPEAKER); #endif /* Assume speaker is okay. */ } @@ -269,9 +269,9 @@ a.play.precision = rplay_audio_precision; a.play.channels = rplay_audio_channels; - if (ioctl (rplay_audio_fd, AUDIO_SETINFO, &a) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_SETINFO: %s\n", sys_err_str (errno)); + if (ioctl(rplay_audio_fd, AUDIO_SETINFO, &a) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_SETINFO: %s\n", sys_err_str(errno)); return -1; } @@ -284,25 +284,25 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_open () +rplay_audio_open() { int flags; - rplay_audio_fd = open (rplay_audio_device, O_WRONLY | O_NDELAY, 0); + rplay_audio_fd = open(rplay_audio_device, O_WRONLY | O_NDELAY, 0); if (rplay_audio_fd < 0) { return -1; } - if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0) - { - report (REPORT_ERROR, - "rplay_audio_open: close-on-exec %d\n", - sys_err_str(errno)); + if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0) + { + report(REPORT_ERROR, + "rplay_audio_open: close-on-exec %d\n", + sys_err_str(errno)); /* return -1; */ } - if (rplay_audio_init () < 0) + if (rplay_audio_init() < 0) { return -1; } @@ -310,13 +310,13 @@ /* * Make sure the audio device writes are non-blocking. */ - flags = fcntl (rplay_audio_fd, F_GETFL, 0); + flags = fcntl(rplay_audio_fd, F_GETFL, 0); if (flags < 0) { return -1; } flags |= FNDELAY; - if (fcntl (rplay_audio_fd, F_SETFL, flags) < 0) + if (fcntl(rplay_audio_fd, F_SETFL, flags) < 0) { return -1; } @@ -330,7 +330,7 @@ * Return 1 for true and 0 for false. */ int -rplay_audio_isopen () +rplay_audio_isopen() { return rplay_audio_fd != -1; } @@ -341,11 +341,11 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_flush () +rplay_audio_flush() { if (rplay_audio_fd != -1) { - ioctl (rplay_audio_fd, AUDIO_DRAIN, 0); + ioctl(rplay_audio_fd, AUDIO_DRAIN, 0); } return 0; @@ -358,10 +358,10 @@ */ #ifdef __STDC__ int -rplay_audio_write (char *buf, int nbytes) +rplay_audio_write(char *buf, int nbytes) #else int -rplay_audio_write (buf, nbytes) +rplay_audio_write(buf, nbytes) char *buf; int nbytes; #endif @@ -374,7 +374,7 @@ for (p = buf; nleft > 0; nleft -= n, p += n) { - n = write (rplay_audio_fd, p, nleft); + n = write(rplay_audio_fd, p, nleft); if (n < 0) { if (errno == EWOULDBLOCK) @@ -402,11 +402,11 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_close () +rplay_audio_close() { if (rplay_audio_fd != -1) { - close (rplay_audio_fd); + close(rplay_audio_fd); } rplay_audio_fd = -1; @@ -420,7 +420,7 @@ * Return 0-255 or -1 on error. */ int -rplay_audio_get_volume () +rplay_audio_get_volume() { #ifdef FAKE_VOLUME return rplay_audio_volume; @@ -429,13 +429,13 @@ if (rplay_audio_fd < 0) { - rplay_audio_open (); + rplay_audio_open(); } if (rplay_audio_fd < 0) { return -1; } - if (ioctl (rplay_audio_fd, AUDIO_GETINFO, &a) < 0) + if (ioctl(rplay_audio_fd, AUDIO_GETINFO, &a) < 0) { return -1; } @@ -454,10 +454,10 @@ */ #ifdef __STDC__ int -rplay_audio_set_volume (int volume) +rplay_audio_set_volume(int volume) #else int -rplay_audio_set_volume (volume) +rplay_audio_set_volume(volume) int volume; #endif { @@ -480,7 +480,7 @@ if (rplay_audio_fd < 0) { - rplay_audio_open (); + rplay_audio_open(); } if (rplay_audio_fd < 0) { @@ -489,12 +489,12 @@ AUDIO_INITINFO(&a); a.play.gain = volume; - if (ioctl (rplay_audio_fd, AUDIO_SETINFO, &a) < 0) - { - return -1; - } - - rplay_audio_volume = rplay_audio_get_volume (); + if (ioctl(rplay_audio_fd, AUDIO_SETINFO, &a) < 0) + { + return -1; + } + + rplay_audio_volume = rplay_audio_get_volume(); return rplay_audio_volume; #endif /* not FAKE_VOLUME */ diff --git a/rplayd/audio/audio_solaris.h b/rplayd/audio/audio_solaris.h index 33860b0..fbb18b7 100644 --- a/rplayd/audio/audio_solaris.h +++ b/rplayd/audio/audio_solaris.h @@ -1,7 +1,7 @@ -/* $Id: audio_solaris.h,v 1.2 1998/08/13 06:14:25 boyns Exp $ */ +/* $Id: audio_solaris.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/audio/audio_sun.c b/rplayd/audio/audio_sun.c index 062c5d8..ce5177f 100644 --- a/rplayd/audio/audio_sun.c +++ b/rplayd/audio/audio_sun.c @@ -1,7 +1,7 @@ -/* $Id: audio_sun.c,v 1.3 1998/09/03 06:08:49 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: audio_sun.c,v 1.5 1999/03/10 07:58:10 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #include "rplayd.h" /* @@ -64,31 +64,31 @@ static RPLAY_AUDIO_TABLE dbri_table[] = { - { 6615, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 6615, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 8000, RPLAY_FORMAT_ULAW , 8, 1 }, - { 8000, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 8000, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 9600, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 9600, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 11025, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 11025, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 16000, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 16000, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 18900, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 18900, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 22050, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 22050, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 32000, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 32000, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 33075, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 33075, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 37800, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 37800, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 44100, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 44100, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, - { 48000, RPLAY_FORMAT_LINEAR_16 , 16, 1 }, - { 48000, RPLAY_FORMAT_LINEAR_16 , 16, 2 }, + {6615, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {6615, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {8000, RPLAY_FORMAT_ULAW, 8, 1}, + {8000, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {8000, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {9600, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {9600, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {11025, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {11025, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {16000, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {16000, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {18900, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {18900, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {22050, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {22050, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {32000, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {32000, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {33075, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {33075, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {37800, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {37800, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {44100, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {44100, RPLAY_FORMAT_LINEAR_16, 16, 2}, + {48000, RPLAY_FORMAT_LINEAR_16, 16, 1}, + {48000, RPLAY_FORMAT_LINEAR_16, 16, 2}, {0, 0, 0, 0} }; @@ -113,18 +113,18 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_init () +rplay_audio_init() { int d; audio_info_t a; if (rplay_audio_fd == -1) { - rplay_audio_open (); + rplay_audio_open(); if (rplay_audio_fd == -1) { - report (REPORT_ERROR, "rplay_audio_init: cannot open %s\n", - rplay_audio_device); + report(REPORT_ERROR, "rplay_audio_init: cannot open %s\n", + rplay_audio_device); return -1; } } @@ -134,15 +134,15 @@ */ #ifdef AUDIO_GETDEV #ifdef AUDIO_DEV_SPEAKERBOX - if (ioctl (rplay_audio_fd, AUDIO_GETDEV, &d) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_GETDEV: %s\n", sys_err_str (errno)); + if (ioctl(rplay_audio_fd, AUDIO_GETDEV, &d) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_GETDEV: %s\n", sys_err_str(errno)); return -1; } if (d == AUDIO_DEV_SPEAKERBOX || d == AUDIO_DEV_CODEC) { - report (REPORT_DEBUG, "dbri device detected\n"); + report(REPORT_DEBUG, "dbri device detected\n"); rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 11025; rplay_audio_precision = optional_precision ? optional_precision : 16; rplay_audio_channels = optional_channels ? optional_channels : 1; @@ -153,7 +153,7 @@ } else if (d == AUDIO_DEV_AMD) { - report (REPORT_DEBUG, "amd device detected\n"); + report(REPORT_DEBUG, "amd device detected\n"); rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 8000; rplay_audio_precision = optional_precision ? optional_precision : 8; rplay_audio_channels = optional_channels ? optional_channels : 1; @@ -167,7 +167,7 @@ #endif else if (d == AUDIO_DEV_CS4231) { - report (REPORT_DEBUG, "cs4231 device detected\n"); + report(REPORT_DEBUG, "cs4231 device detected\n"); rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 11025; rplay_audio_precision = optional_precision ? optional_precision : 16; rplay_audio_channels = optional_channels ? optional_channels : 1; @@ -180,7 +180,7 @@ #endif /* not AUDIO_DEV_SPEAKERBOX */ #endif /* not AUDIO_GETDEV */ { - report (REPORT_DEBUG, "assuming amd device\n"); + report(REPORT_DEBUG, "assuming amd device\n"); rplay_audio_sample_rate = optional_sample_rate ? optional_sample_rate : 8000; rplay_audio_precision = optional_precision ? optional_precision : 8; rplay_audio_channels = optional_channels ? optional_channels : 1; @@ -196,8 +196,8 @@ if (rplay_audio_format != RPLAY_FORMAT_ULAW && rplay_audio_format != RPLAY_FORMAT_LINEAR_8) { - report (REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n", - rplay_audio_precision, rplay_audio_format); + report(REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n", + rplay_audio_precision, rplay_audio_format); return -1; } break; @@ -205,15 +205,15 @@ case 16: if (rplay_audio_format != RPLAY_FORMAT_LINEAR_16) { - report (REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n", - rplay_audio_precision, rplay_audio_format); + report(REPORT_ERROR, "rplay_audio_init: can't use %d bits with format=%d\n", + rplay_audio_precision, rplay_audio_format); return -1; } break; default: - report (REPORT_ERROR, "rplay_audio_init: `%d' unsupported audio precision\n", - rplay_audio_precision); + report(REPORT_ERROR, "rplay_audio_init: `%d' unsupported audio precision\n", + rplay_audio_precision); return -1; } @@ -231,39 +231,39 @@ break; default: - report (REPORT_ERROR, "rplay_audio_init: unsupported audio format `%d'\n", - rplay_audio_format); + report(REPORT_ERROR, "rplay_audio_init: unsupported audio format `%d'\n", + rplay_audio_format); return -1; } /* Audio port. */ if (rplay_audio_port == RPLAY_AUDIO_PORT_NONE) { - a.play.port = ~0; /* see AUDIO_INITINFO in /usr/include/sun/audioio.h. */ + a.play.port = ~0; /* see AUDIO_INITINFO in /usr/include/sun/audioio.h. */ } else { a.play.port = 0; - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT)) + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT)) { #ifdef AUDIO_LINE_OUT - SET_BIT (a.play.port, AUDIO_LINE_OUT); + SET_BIT(a.play.port, AUDIO_LINE_OUT); #else - CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT); + CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_LINEOUT); #endif } - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE)) + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE)) { #ifdef AUDIO_HEADPHONE - SET_BIT (a.play.port, AUDIO_HEADPHONE); + SET_BIT(a.play.port, AUDIO_HEADPHONE); #else - CLR_BIT (rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE); + CLR_BIT(rplay_audio_port, RPLAY_AUDIO_PORT_HEADPHONE); #endif } - if (BIT (rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) + if (BIT(rplay_audio_port, RPLAY_AUDIO_PORT_SPEAKER)) { #ifdef AUDIO_SPEAKER - SET_BIT (a.play.port, AUDIO_SPEAKER); + SET_BIT(a.play.port, AUDIO_SPEAKER); #endif /* Assume speaker is okay. */ } @@ -273,9 +273,9 @@ a.play.precision = rplay_audio_precision; a.play.channels = rplay_audio_channels; - if (ioctl (rplay_audio_fd, AUDIO_SETINFO, &a) < 0) - { - report (REPORT_ERROR, "rplay_audio_init: AUDIO_SETINFO: %s\n", sys_err_str (errno)); + if (ioctl(rplay_audio_fd, AUDIO_SETINFO, &a) < 0) + { + report(REPORT_ERROR, "rplay_audio_init: AUDIO_SETINFO: %s\n", sys_err_str(errno)); return -1; } @@ -288,25 +288,25 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_open () +rplay_audio_open() { int flags; - rplay_audio_fd = open (rplay_audio_device, O_WRONLY | O_NDELAY, 0); + rplay_audio_fd = open(rplay_audio_device, O_WRONLY | O_NDELAY, 0); if (rplay_audio_fd < 0) { return -1; } - if (fcntl (rplay_audio_fd, F_SETFD, 1) < 0) - { - report (REPORT_ERROR, - "rplay_audio_open: close-on-exec %d\n", - sys_err_str(errno)); + if (fcntl(rplay_audio_fd, F_SETFD, 1) < 0) + { + report(REPORT_ERROR, + "rplay_audio_open: close-on-exec %d\n", + sys_err_str(errno)); /* return -1; */ } - if (rplay_audio_init () < 0) + if (rplay_audio_init() < 0) { return -1; } @@ -314,13 +314,13 @@ /* * Make sure the audio device writes are non-blocking. */ - flags = fcntl (rplay_audio_fd, F_GETFL, 0); + flags = fcntl(rplay_audio_fd, F_GETFL, 0); if (flags < 0) { return -1; } flags |= FNDELAY; - if (fcntl (rplay_audio_fd, F_SETFL, flags) < 0) + if (fcntl(rplay_audio_fd, F_SETFL, flags) < 0) { return -1; } @@ -334,7 +334,7 @@ * Return 1 for true and 0 for false. */ int -rplay_audio_isopen () +rplay_audio_isopen() { return rplay_audio_fd != -1; } @@ -345,11 +345,11 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_flush () +rplay_audio_flush() { if (rplay_audio_fd != -1) { - ioctl (rplay_audio_fd, AUDIO_DRAIN, 0); + ioctl(rplay_audio_fd, AUDIO_DRAIN, 0); } return 0; @@ -362,10 +362,10 @@ */ #ifdef __STDC__ int -rplay_audio_write (char *buf, int nbytes) +rplay_audio_write(char *buf, int nbytes) #else int -rplay_audio_write (buf, nbytes) +rplay_audio_write(buf, nbytes) char *buf; int nbytes; #endif @@ -378,7 +378,7 @@ for (p = buf; nleft > 0; nleft -= n, p += n) { - n = write (rplay_audio_fd, p, nleft); + n = write(rplay_audio_fd, p, nleft); if (n < 0) { if (errno == EWOULDBLOCK) @@ -406,11 +406,11 @@ * Return 0 on success and -1 on error. */ int -rplay_audio_close () +rplay_audio_close() { if (rplay_audio_fd != -1) { - close (rplay_audio_fd); + close(rplay_audio_fd); } rplay_audio_fd = -1; @@ -424,7 +424,7 @@ * Return 0-255 or -1 on error. */ int -rplay_audio_get_volume () +rplay_audio_get_volume() { #ifdef FAKE_VOLUME return rplay_audio_volume; @@ -433,13 +433,13 @@ if (rplay_audio_fd < 0) { - rplay_audio_open (); + rplay_audio_open(); } if (rplay_audio_fd < 0) { return -1; } - if (ioctl (rplay_audio_fd, AUDIO_GETINFO, &a) < 0) + if (ioctl(rplay_audio_fd, AUDIO_GETINFO, &a) < 0) { return -1; } @@ -458,10 +458,10 @@ */ #ifdef __STDC__ int -rplay_audio_set_volume (int volume) +rplay_audio_set_volume(int volume) #else int -rplay_audio_set_volume (volume) +rplay_audio_set_volume(volume) int volume; #endif { @@ -484,7 +484,7 @@ if (rplay_audio_fd < 0) { - rplay_audio_open (); + rplay_audio_open(); } if (rplay_audio_fd < 0) { @@ -493,12 +493,12 @@ AUDIO_INITINFO(&a); a.play.gain = volume; - if (ioctl (rplay_audio_fd, AUDIO_SETINFO, &a) < 0) - { - return -1; - } - - rplay_audio_volume = rplay_audio_get_volume (); + if (ioctl(rplay_audio_fd, AUDIO_SETINFO, &a) < 0) + { + return -1; + } + + rplay_audio_volume = rplay_audio_get_volume(); return rplay_audio_volume; #endif /* not FAKE_VOLUME */ diff --git a/rplayd/audio/audio_sun.h b/rplayd/audio/audio_sun.h index 621ed89..7fb14ba 100644 --- a/rplayd/audio/audio_sun.h +++ b/rplayd/audio/audio_sun.h @@ -1,7 +1,7 @@ -/* $Id: audio_sun.h,v 1.2 1998/08/13 06:14:27 boyns Exp $ */ +/* $Id: audio_sun.h,v 1.3 1999/03/10 07:58:10 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/buffer.c b/rplayd/buffer.c index 45e0916..d3771e7 100644 --- a/rplayd/buffer.c +++ b/rplayd/buffer.c @@ -1,7 +1,7 @@ -/* $Id: buffer.c,v 1.2 1998/08/13 06:13:40 boyns Exp $ */ +/* $Id: buffer.c,v 1.4 1999/03/10 07:58:02 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -37,21 +37,21 @@ #ifdef __STDC__ BUFFER * -buffer_create (void) -#else -BUFFER * -buffer_create () +buffer_create(void) +#else +BUFFER * +buffer_create() #endif { BUFFER *b; if (buffers == NULL) { - b = (BUFFER *) malloc (sizeof (BUFFER)); + b = (BUFFER *) malloc(sizeof(BUFFER)); if (b == NULL) { - report (REPORT_ERROR, "buffer_create: out of memory\n"); - done (1); + report(REPORT_ERROR, "buffer_create: out of memory\n"); + done(1); } b->id = ++next_id; } @@ -73,10 +73,10 @@ #ifdef __STDC__ void -buffer_destroy (BUFFER *b) -#else -void -buffer_destroy (b) +buffer_destroy(BUFFER *b) +#else +void +buffer_destroy(b) BUFFER *b; #endif { @@ -89,7 +89,7 @@ { /* Always put REUSE buffers on the free list. This will probably cause rplayd to grow bigger, but it prevents - problems with calling free () inside the timer + problems with calling free() inside the timer interrupt. */ nbuffers++; b->next = buffers; @@ -98,7 +98,7 @@ else { /* Free the buffer. */ - free ((char *) b); + free((char *) b); } } @@ -107,10 +107,10 @@ */ #ifdef __STDC__ BUFFER * -buffer_alloc (int nbytes, int type) -#else -BUFFER * -buffer_alloc (nbytes, type) +buffer_alloc(int nbytes, int type) +#else +BUFFER * +buffer_alloc(nbytes, type) int nbytes; int type; #endif @@ -119,7 +119,7 @@ do { - *next = buffer_create (); + *next = buffer_create(); nbytes -= BUFFER_SIZE; (*next)->status = type; next = &(*next)->next; @@ -133,10 +133,10 @@ #ifdef __STDC__ void -buffer_dealloc (BUFFER *b, int force) -#else -void -buffer_dealloc (b, force) +buffer_dealloc(BUFFER *b, int force) +#else +void +buffer_dealloc(b, force) BUFFER *b; int force; #endif @@ -150,31 +150,51 @@ { b->status = BUFFER_FREE; } - buffer_destroy (b); + buffer_destroy(b); b = next; } } #ifdef __STDC__ void -buffer_cleanup (void) -#else -void -buffer_cleanup () -#endif -{ - BUFFER *b; - - report (REPORT_DEBUG, "cleaning up buffers - %d bytes\n", nbuffers * BUFFER_SIZE); +buffer_cleanup(void) +#else +void +buffer_cleanup() +#endif +{ + BUFFER *b; + + report(REPORT_DEBUG, "cleaning up buffers - %d bytes\n", nbuffers * BUFFER_SIZE); while (buffers) { b = buffers; buffers = buffers->next; - free ((char *) b); + free((char *) b); } buffers = NULL; nbuffers = 0; next_id = 0; } + +#ifdef __STDC__ +int +buffer_nbytes(BUFFER *b) +#else +int +buffer_nbytes(b) + BUFFER *b; +#endif +{ + int n = 0; + + while (b) + { + n += b->nbytes; + b = b->next; + } + + return n; +} diff --git a/rplayd/buffer.h b/rplayd/buffer.h index 2590650..905cb11 100644 --- a/rplayd/buffer.h +++ b/rplayd/buffer.h @@ -1,7 +1,7 @@ -/* $Id: buffer.h,v 1.2 1998/08/13 06:13:41 boyns Exp $ */ +/* $Id: buffer.h,v 1.3 1999/03/10 07:58:02 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -38,7 +38,7 @@ */ #define BUFFER_MAX_FREE 64 -#define BUFFER_FREE 0 /* temporary buffer - put on free list or destroyed */ +#define BUFFER_FREE 0 /* temporary buffer - put on free list or destroy */ #define BUFFER_KEEP 1 /* permanent buffer - not put on free list */ #define BUFFER_REUSE 2 /* temporary buffer - always put on free list */ diff --git a/rplayd/cache.c b/rplayd/cache.c index 8fc2cee..907c3e6 100644 --- a/rplayd/cache.c +++ b/rplayd/cache.c @@ -1,7 +1,7 @@ -/* $Id: cache.c,v 1.2 1998/08/13 06:13:42 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: cache.c,v 1.4 1999/03/10 07:58:02 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -59,28 +59,28 @@ */ #ifdef __STDC__ void -cache_init (char *dir_name) +cache_init(char *dir_name) #else void -cache_init (dir_name) +cache_init(dir_name) char *dir_name; #endif { struct stat st; - strcpy (cache_directory, dir_name); - if (stat (cache_directory, &st) < 0) - { - report (REPORT_DEBUG, "creating cache directory `%s'\n", cache_directory); - if (mkdir (cache_directory, 0777) < 0) - { - report (REPORT_ERROR, "cache_init: cannot create cache directory '%s'\n", cache_directory); - } - } - else if (!S_ISDIR (st.st_mode)) - { - report (REPORT_ERROR, "cache_init: %s not a directory\n", cache_directory); - done (1); + strcpy(cache_directory, dir_name); + if (stat(cache_directory, &st) < 0) + { + report(REPORT_DEBUG, "creating cache directory `%s'\n", cache_directory); + if (mkdir(cache_directory, 0777) < 0) + { + report(REPORT_ERROR, "cache_init: cannot create cache directory '%s'\n", cache_directory); + } + } + else if (!S_ISDIR(st.st_mode)) + { + report(REPORT_ERROR, "cache_init: %s not a directory\n", cache_directory); + done(1); } } @@ -88,46 +88,46 @@ * return the name of the first cache entry */ char * -cache_first () +cache_first() { if (cache_dir) { - rewinddir (cache_dir); + rewinddir(cache_dir); } else { - cache_dir = opendir (cache_directory); + cache_dir = opendir(cache_directory); if (cache_dir == NULL) { - report (REPORT_ERROR, "cache_first: opendir %s: %s\n", cache_directory, sys_err_str (errno)); + report(REPORT_ERROR, "cache_first: opendir %s: %s\n", cache_directory, sys_err_str(errno)); return NULL; } } - return cache_next (); + return cache_next(); } /* * return the name of the next cache entry */ char * -cache_next () +cache_next() { struct dirent *dp; do { - dp = readdir (cache_dir); + dp = readdir(cache_dir); if (dp == NULL) { - closedir (cache_dir); + closedir(cache_dir); cache_dir = NULL; return ""; } } - while (strcmp (dp->d_name, ".") == 0 || strcmp (dp->d_name, "..") == 0); - - SNPRINTF (SIZE(cache_path,sizeof(cache_path)), "%s/%s", cache_directory, dp->d_name); + while (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0); + + SNPRINTF(SIZE(cache_path, sizeof(cache_path)), "%s/%s", cache_directory, dp->d_name); return cache_path; } @@ -136,17 +136,17 @@ * calculate the size of the cache */ int -cache_size () +cache_size() { struct stat st; int size = 0; char *file; - for (file = cache_first (); file && *file; file = cache_next ()) - { - if (stat (file, &st) < 0) - { - report (REPORT_ERROR, "cache_size: stat %s: %s\n", file, sys_err_str (errno)); + for (file = cache_first(); file && *file; file = cache_next()) + { + if (stat(file, &st) < 0) + { + report(REPORT_ERROR, "cache_size: stat %s: %s\n", file, sys_err_str(errno)); return -1; } size += (int) st.st_size; @@ -159,13 +159,13 @@ * load files that are already in the cache */ void -cache_read () +cache_read() { char *file; - for (file = cache_first (); file && *file; file = cache_next ()) - { - sound_insert (file, SOUND_READY, SOUND_FILE); + for (file = cache_first(); file && *file; file = cache_next()) + { + sound_insert(file, SOUND_READY, SOUND_FILE); } } @@ -176,16 +176,16 @@ */ #ifdef __STDC__ char * -cache_name (char *sound) +cache_name(char *sound) #else char * -cache_name (sound) +cache_name(sound) char *sound; #endif { static char _cache_path[MAXPATHLEN]; - SNPRINTF (SIZE(_cache_path,sizeof(_cache_path)), "%s/%s", cache_directory, sound); + SNPRINTF(SIZE(_cache_path, sizeof(_cache_path)), "%s/%s", cache_directory, sound); return _cache_path; } @@ -195,10 +195,10 @@ */ #ifdef __STDC__ int -cache_free (int size) -#else -int -cache_free (size) +cache_free(int size) +#else +int +cache_free(size) int size; #endif { @@ -215,13 +215,13 @@ if (size > cache_max_size) { - report (REPORT_DEBUG, "%d bytes cannot fit in the cache\n", size); - return -1; - } - - curr_size = cache_size (); - - report (REPORT_DEBUG, "sound_count = %d, current cache size = %d bytes\n", sound_count, curr_size); + report(REPORT_DEBUG, "%d bytes cannot fit in the cache\n", size); + return -1; + } + + curr_size = cache_size(); + + report(REPORT_DEBUG, "sound_count = %d, current cache size = %d bytes\n", sound_count, curr_size); if (size + curr_size <= cache_max_size) { @@ -235,26 +235,26 @@ for (;;) { - report (REPORT_DEBUG, "removing cache entries (limit = %d)\n", limit); - - for (file = cache_first (); file && *file; file = cache_next ()) - { - s = sound_lookup (file, SOUND_DONT_COUNT, NULL); + report(REPORT_DEBUG, "removing cache entries (limit = %d)\n", limit); + + for (file = cache_first(); file && *file; file = cache_next()) + { + s = sound_lookup(file, SOUND_DONT_COUNT, NULL); if (s == NULL || s->status != SOUND_READY) { continue; } if (s->count < limit) { - if (stat (file, &st) < 0) + if (stat(file, &st) < 0) { - report (REPORT_ERROR, "cache_free: stat %s: %s\n", file, sys_err_str (errno)); + report(REPORT_ERROR, "cache_free: stat %s: %s\n", file, sys_err_str(errno)); continue; } curr_size -= (int) st.st_size; - spool_remove (s); - sound_delete (s, 1); - report (REPORT_DEBUG, "removed %s size=%d count=%d\n", file, st.st_size, s->count); + spool_remove(s); + sound_delete(s, 1); + report(REPORT_DEBUG, "removed %s size=%d count=%d\n", file, st.st_size, s->count); } } @@ -264,14 +264,14 @@ } else if (limit == sound_count) { - report (REPORT_ERROR, "cache_free: cannot make room for %d bytes in the cache\n", size); + report(REPORT_ERROR, "cache_free: cannot make room for %d bytes in the cache\n", size); return -1; } else { n = limit / 4; limit += n ? n : 1; - limit = MIN (limit, sound_count); + limit = MIN(limit, sound_count); } } @@ -283,44 +283,44 @@ */ #ifdef __STDC__ int -cache_create (char *name, int size) -#else -int -cache_create (name, size) +cache_create(char *name, int size) +#else +int +cache_create(name, size) char *name; int size; #endif { int fd; - fd = open (name, O_RDWR | O_CREAT, 0666); + fd = open(name, O_RDWR | O_CREAT, 0666); if (fd < 0) { - report (REPORT_ERROR, "cache_create: open: %s\n", sys_err_str (errno)); - return -1; - } - - if (lseek (fd, size - 1, SEEK_SET) < 0) - { - report (REPORT_ERROR, "cache_create: lseek: %d %s\n", sys_err_str (errno)); + report(REPORT_ERROR, "cache_create: open: %s\n", sys_err_str(errno)); + return -1; + } + + if (lseek(fd, size - 1, SEEK_SET) < 0) + { + report(REPORT_ERROR, "cache_create: lseek: %d %s\n", sys_err_str(errno)); return -1; } restart: - if (write (fd, "", 1) != 1) + if (write(fd, "", 1) != 1) { if (errno == EINTR || errno == EAGAIN) { goto restart; } - report (REPORT_ERROR, "cache_create: write: %s\n", sys_err_str (errno)); - return -1; - } - - if (lseek (fd, 0, SEEK_SET) < 0) - { - report (REPORT_ERROR, "cache_create: lseek: 0 %s\n", sys_err_str (errno)); - unlink (name); + report(REPORT_ERROR, "cache_create: write: %s\n", sys_err_str(errno)); + return -1; + } + + if (lseek(fd, 0, SEEK_SET) < 0) + { + report(REPORT_ERROR, "cache_create: lseek: 0 %s\n", sys_err_str(errno)); + unlink(name); return -1; } @@ -329,33 +329,33 @@ /* Optionally remove the cache directory and all its contents. */ void -cache_cleanup () +cache_cleanup() { int size; char *file; - if (*cache_directory == '\0') /* cache_init wasn't called */ + if (*cache_directory == '\0') /* cache_init wasn't called */ { return; } - - size = cache_size (); + + size = cache_size(); if (size == 0 || cache_remove) { - report (REPORT_DEBUG, "cleaning `%s'\n", cache_directory); - for (file = cache_first (); file && *file; file = cache_next ()) - { - if (unlink (file) < 0) + report(REPORT_DEBUG, "cleaning `%s'\n", cache_directory); + for (file = cache_first(); file && *file; file = cache_next()) + { + if (unlink(file) < 0) { - report (REPORT_ERROR, "cache_cleanup: unlink %s: %s\n", - file, sys_err_str (errno)); + report(REPORT_ERROR, "cache_cleanup: unlink %s: %s\n", + file, sys_err_str(errno)); } } - - if (rmdir (cache_directory) < 0) - { - report (REPORT_ERROR, "cache_cleanup: rmdir %s: %s\n", - cache_directory, sys_err_str (errno)); - } - } -} + + if (rmdir(cache_directory) < 0) + { + report(REPORT_ERROR, "cache_cleanup: rmdir %s: %s\n", + cache_directory, sys_err_str(errno)); + } + } +} diff --git a/rplayd/cache.h b/rplayd/cache.h index febe89d..e32c283 100644 --- a/rplayd/cache.h +++ b/rplayd/cache.h @@ -1,7 +1,7 @@ -/* $Id: cache.h,v 1.2 1998/08/13 06:13:43 boyns Exp $ */ +/* $Id: cache.h,v 1.3 1999/03/10 07:58:02 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/cdrom.c b/rplayd/cdrom.c index 8fa3ecc..3f326bd 100644 --- a/rplayd/cdrom.c +++ b/rplayd/cdrom.c @@ -1,7 +1,7 @@ -/* $Id: cdrom.c,v 1.2 1998/08/13 06:13:44 boyns Exp $ */ +/* $Id: cdrom.c,v 1.4 1999/03/10 07:58:02 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -24,8 +24,8 @@ /* A lot of the CDDA code is based on read_cdda 1.01 by Jim Mintha - (mintha@geog.ubc.ca) which seems to have borrowed code from Workman - sources written by Steven Grimm (koreth@hyperion.com). */ + (mintha@geog.ubc.ca) which seems to have borrowed code from Workman + sources written by Steven Grimm (koreth@hyperion.com). */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -40,21 +40,21 @@ CDROM_TABLE cdrom_table[MAX_CDROMS] = { -#if defined (sun) && defined (SVR4) /* Solaris 2.x */ - { "cdrom:", "/vol/dev/aliases/cdrom0", 0, 0 }, - { "cdrom0:", "/vol/dev/aliases/cdrom0", 0, 0 }, - { "cdrom1:", "/vol/dev/aliases/cdrom1", 0, 0 }, - { "cdrom2:", "/vol/dev/aliases/cdrom2", 0, 0 }, - { "cdrom3:", "/vol/dev/aliases/cdrom3", 0, 0 }, -#else /* not solaris */ +#if defined (sun) && defined (SVR4) /* Solaris 2.x */ + {"cdrom:", "/vol/dev/aliases/cdrom0", 0, 0}, + {"cdrom0:", "/vol/dev/aliases/cdrom0", 0, 0}, + {"cdrom1:", "/vol/dev/aliases/cdrom1", 0, 0}, + {"cdrom2:", "/vol/dev/aliases/cdrom2", 0, 0}, + {"cdrom3:", "/vol/dev/aliases/cdrom3", 0, 0}, +#else /* not solaris */ #if defined (linux) - { "cdrom:", "/dev/cdrom", 0, 0 }, - { "cdrom0:", "/dev/cdrom0", 0, 0 }, - { "cdrom1:", "/dev/cdrom1", 0, 0 }, - { "cdrom2:", "/dev/cdrom2", 0, 0 }, - { "cdrom3:", "/dev/cdrom3", 0, 0 }, -#endif /* linux */ -#endif + {"cdrom:", "/dev/cdrom", 0, 0}, + {"cdrom0:", "/dev/cdrom0", 0, 0}, + {"cdrom1:", "/dev/cdrom1", 0, 0}, + {"cdrom2:", "/dev/cdrom2", 0, 0}, + {"cdrom3:", "/dev/cdrom3", 0, 0}, +#endif /* linux */ +#endif }; typedef struct @@ -75,53 +75,53 @@ /* Internal prototypes. */ #ifdef HAVE_CDDA #ifdef __STDC__ -static void cdda_cdrom_reader (CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd); -#else -static void cdda_cdrom_reader (/* CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd */); +static void cdda_cdrom_reader(CDROM_TABLE * cdt, int starting_track, int ending_track, int output_fd); +#else +static void cdda_cdrom_reader( /* CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd */ ); #endif #endif /* HAVE_CDDA */ #ifdef linux #ifdef __STDC__ -static void linux_cdrom_reader (CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd); -#else -static void linux_cdrom_reader (/* CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd */); +static void linux_cdrom_reader(CDROM_TABLE * cdt, int starting_track, int ending_track, int output_fd); +#else +static void linux_cdrom_reader( /* CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd */ ); #endif #endif /* linux */ /* starting_track and ending_track can be 0 which means first and last */ #ifdef __STDC__ void -cdrom_reader (int index, int starting_track, int ending_track, int output_fd) +cdrom_reader(int index, int starting_track, int ending_track, int output_fd) #else void -cdrom_reader (index, starting_track, ending_track, output_fd) +cdrom_reader(index, starting_track, ending_track, output_fd) int index; int starting_track; int ending_track; int output_fd; -#endif +#endif { CDROM_TABLE *cdt; cdt = &cdrom_table[index]; - - report (REPORT_DEBUG, "cdrom_reader: %s%s tracks %d..%d\n", - cdt->name, cdt->device, starting_track, ending_track); - - rplay_audio_close (); /* prevent device busy problems */ + + report(REPORT_DEBUG, "cdrom_reader: %s%s tracks %d..%d\n", + cdt->name, cdt->device, starting_track, ending_track); + + rplay_audio_close(); /* prevent device busy problems */ #ifdef HAVE_CDDA - cdda_cdrom_reader (cdt, starting_track, ending_track, output_fd); + cdda_cdrom_reader(cdt, starting_track, ending_track, output_fd); #else #ifdef linux - linux_cdrom_reader (cdt, starting_track, ending_track, output_fd); -#endif /* linux */ + linux_cdrom_reader(cdt, starting_track, ending_track, output_fd); +#endif /* linux */ #endif /* HAVE_CDDA */ /* Add more cdrom readers here. */ - - exit (0); + + exit(0); } @@ -136,29 +136,29 @@ #define CDDA_BLOCK_SIZE 2368 #define CDDA_BLOCK_IGNORE 16 -static int cdda_open (CDROM_INFO *info); -static int cdda_read (CDROM_INFO *info); -static int cdda_close (CDROM_INFO *info); -static int internal_cdda_init (CDROM_INFO *info); -static int internal_cdda_read (CDROM_INFO *info); -static int internal_cdda_toc (CDROM_INFO *info); +static int cdda_open(CDROM_INFO * info); +static int cdda_read(CDROM_INFO * info); +static int cdda_close(CDROM_INFO * info); +static int internal_cdda_init(CDROM_INFO * info); +static int internal_cdda_read(CDROM_INFO * info); +static int internal_cdda_toc(CDROM_INFO * info); #ifdef __STDC__ static void -cdda_cdrom_reader (CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd) +cdda_cdrom_reader(CDROM_TABLE * cdt, int starting_track, int ending_track, int output_fd) #else static void -cdda_cdrom_reader (cdt, starting_track, ending_track, output_fd) +cdda_cdrom_reader(cdt, starting_track, ending_track, output_fd) CDROM_TABLE *cdt; int starting_track; int ending_track; int output_fd; -#endif +#endif { CDROM_INFO info; int n, i; char *p; - + info.device = cdt->device; info.starting_track = starting_track; info.ending_track = ending_track; @@ -166,14 +166,14 @@ info.fd = -1; info.buffer = NULL; - if (cdda_open (&info) < 0) + if (cdda_open(&info) < 0) { return; } for (;;) { - n = cdda_read (&info); + n = cdda_read(&info); if (n <= 0) { break; @@ -182,46 +182,46 @@ p = info.buffer; for (i = 0; i < info.num_blocks; i++) { - write (output_fd, p, CDDA_BLOCK_SIZE - CDDA_BLOCK_IGNORE); + write(output_fd, p, CDDA_BLOCK_SIZE - CDDA_BLOCK_IGNORE); p += CDDA_BLOCK_SIZE; } } - cdda_close (&info); -} - -#ifdef __STDC__ -static int -cdda_open (CDROM_INFO *info) -#else -static int -cdda_open (info) + cdda_close(&info); +} + +#ifdef __STDC__ +static int +cdda_open(CDROM_INFO * info) +#else +static int +cdda_open(info) CDROM_INFO *info; -#endif +#endif { if (info->fd < 0) { - if (internal_cdda_init (info) < 0) + if (internal_cdda_init(info) < 0) { return -1; } } - return internal_cdda_toc (info); -} - -#ifdef __STDC__ -static int -cdda_read (CDROM_INFO *info) -#else -static int -cdda_read (info) + return internal_cdda_toc(info); +} + +#ifdef __STDC__ +static int +cdda_read(CDROM_INFO * info) +#else +static int +cdda_read(info) CDROM_INFO *info; -#endif +#endif { int n; - n = internal_cdda_read (info); + n = internal_cdda_read(info); if (n < 0) { return -1; @@ -232,18 +232,18 @@ #ifdef __STDC__ static int -cdda_close (CDROM_INFO *info) -#else -static int -cdda_close (info) +cdda_close(CDROM_INFO * info) +#else +static int +cdda_close(info) CDROM_INFO *info; -#endif -{ - close (info->fd); +#endif +{ + close(info->fd); info->fd = -1; if (info->buffer) { - free ((char *) info->buffer); + free((char *) info->buffer); } info->buffer = NULL; return 0; @@ -264,26 +264,26 @@ #ifdef __STDC__ static int -internal_cdda_init (CDROM_INFO *info) -#else -static int -internal_cdda_init (info) +internal_cdda_init(CDROM_INFO * info) +#else +static int +internal_cdda_init(info) CDROM_INFO *info; -#endif +#endif { struct cdrom_cdda cdda; - info->fd = open (info->device, 0); + info->fd = open(info->device, 0); if (info->fd < 0) { - perror (info->device); - return -1; - } - - info->buffer = (char *) malloc (info->num_blocks * CDDABLKSIZE + CDDABLKSIZE); + perror(info->device); + return -1; + } + + info->buffer = (char *) malloc(info->num_blocks * CDDABLKSIZE + CDDABLKSIZE); if (info->buffer == NULL) { - fprintf (stderr, "malloc: out of memory\n"); + fprintf(stderr, "malloc: out of memory\n"); return -1; } @@ -294,12 +294,12 @@ cdda.cdda_data = info->buffer; cdda.cdda_subcode = CDROM_DA_SUBQ; - if (ioctl (info->fd, CDROMCDDA, &cdda) < 0) - { - perror ("ioctl: CDROMCDDA"); - free ((char *) info->buffer); + if (ioctl(info->fd, CDROMCDDA, &cdda) < 0) + { + perror("ioctl: CDROMCDDA"); + free((char *) info->buffer); info->buffer = NULL; - close (info->fd); + close(info->fd); return -1; } @@ -308,12 +308,12 @@ #ifdef __STDC__ static int -internal_cdda_read (CDROM_INFO *info) -#else -static int -internal_cdda_read (info) +internal_cdda_read(CDROM_INFO * info) +#else +static int +internal_cdda_read(info) CDROM_INFO *info; -#endif +#endif { struct cdrom_cdda cdda; int blk; @@ -333,15 +333,15 @@ { cdda.cdda_length = info->num_blocks; } - + cdda.cdda_data = info->buffer; cdda.cdda_subcode = CDROM_DA_SUBQ; - if (ioctl (info->fd, CDROMCDDA, &cdda) < 0) + if (ioctl(info->fd, CDROMCDDA, &cdda) < 0) { if (errno == ENXIO) { - perror ("ioctl: CDROMCDDA: CD ejected"); + perror("ioctl: CDROMCDDA: CD ejected"); return -1; } @@ -350,13 +350,13 @@ return 0; } - if (ioctl (info->fd, CDROMCDDA, &cdda) < 0) - { - if (ioctl (info->fd, CDROMCDDA, &cdda) < 0) + if (ioctl(info->fd, CDROMCDDA, &cdda) < 0) + { + if (ioctl(info->fd, CDROMCDDA, &cdda) < 0) { - if (ioctl (info->fd, CDROMCDDA, &cdda) < 0) + if (ioctl(info->fd, CDROMCDDA, &cdda) < 0) { - perror ("ioctl: CDROMCDDA"); + perror("ioctl: CDROMCDDA"); return -1; } } @@ -370,20 +370,20 @@ #ifdef __STDC__ static int -internal_cdda_toc (CDROM_INFO *info) -#else -static int -internal_cdda_toc (info) +internal_cdda_toc(CDROM_INFO * info) +#else +static int +internal_cdda_toc(info) CDROM_INFO *info; -#endif +#endif { struct cdrom_tochdr hdr; struct cdrom_tocentry entry; int i; - if (ioctl (info->fd, CDROMREADTOCHDR, &hdr) < 0) - { - perror ("ioctl: CDROMREADTOCHDR"); + if (ioctl(info->fd, CDROMREADTOCHDR, &hdr) < 0) + { + perror("ioctl: CDROMREADTOCHDR"); return -1; } @@ -404,9 +404,9 @@ entry.cdte_track = i; entry.cdte_format = CDROM_MSF; - if (ioctl (info->fd, CDROMREADTOCENTRY, &entry) < 0) - { - perror ("ioctl: CDROMREADTOCENTRY"); + if (ioctl(info->fd, CDROMREADTOCENTRY, &entry) < 0) + { + perror("ioctl: CDROMREADTOCENTRY"); return -1; } @@ -426,9 +426,9 @@ entry.cdte_track = CDROM_LEADOUT; entry.cdte_format = CDROM_MSF; - if (ioctl (info->fd, CDROMREADTOCENTRY, &entry) < 0) - { - perror ("ioctl: CDROMREADTOCENTRY"); + if (ioctl(info->fd, CDROMREADTOCENTRY, &entry) < 0) + { + perror("ioctl: CDROMREADTOCENTRY"); return -1; } @@ -441,7 +441,7 @@ /* Move back two seconds - don't know why but works */ info->starting_block -= 150; info->ending_block -= 150; - + info->current_block = info->starting_block; return 0; @@ -457,20 +457,20 @@ #ifdef __STDC__ static int -linux_read_toc (CDROM_INFO *info) -#else -static int -linux_read_toc (info) +linux_read_toc(CDROM_INFO * info) +#else +static int +linux_read_toc(info) CDROM_INFO *info; -#endif +#endif { struct cdrom_tochdr hdr; struct cdrom_tocentry entry; int i; - if (ioctl (info->fd, CDROMREADTOCHDR, &hdr) < 0) - { - perror ("ioctl: CDROMREADTOCHDR"); + if (ioctl(info->fd, CDROMREADTOCHDR, &hdr) < 0) + { + perror("ioctl: CDROMREADTOCHDR"); return -1; } @@ -491,9 +491,9 @@ entry.cdte_track = i; entry.cdte_format = CDROM_MSF; - if (ioctl (info->fd, CDROMREADTOCENTRY, &entry) < 0) - { - perror ("ioctl: CDROMREADTOCENTRY"); + if (ioctl(info->fd, CDROMREADTOCENTRY, &entry) < 0) + { + perror("ioctl: CDROMREADTOCENTRY"); return -1; } @@ -513,9 +513,9 @@ entry.cdte_track = CDROM_LEADOUT; entry.cdte_format = CDROM_MSF; - if (ioctl (info->fd, CDROMREADTOCENTRY, &entry) < 0) - { - perror ("ioctl: CDROMREADTOCENTRY"); + if (ioctl(info->fd, CDROMREADTOCENTRY, &entry) < 0) + { + perror("ioctl: CDROMREADTOCENTRY"); return -1; } @@ -528,7 +528,7 @@ /* Move back two seconds - don't know why but works */ info->starting_block -= 150; info->ending_block -= 150; - + info->current_block = info->starting_block; return 0; @@ -536,20 +536,20 @@ #ifdef __STDC__ static void -linux_cdrom_reader (CDROM_TABLE *cdt, int starting_track, int ending_track, int output_fd) +linux_cdrom_reader(CDROM_TABLE * cdt, int starting_track, int ending_track, int output_fd) #else static void -linux_cdrom_reader (cdt, starting_track, ending_track, output_fd) +linux_cdrom_reader(cdt, starting_track, ending_track, output_fd) CDROM_TABLE *cdt; int starting_track; int ending_track; int output_fd; -#endif +#endif { CDROM_INFO info; int n, i; char *p; - + info.device = cdt->device; info.starting_track = starting_track; info.ending_track = ending_track; @@ -557,21 +557,21 @@ info.fd = -1; info.buffer = NULL; - info.fd = open (info.device, 0); + info.fd = open(info.device, 0); if (info.fd < 0) { - perror (info.device); + perror(info.device); return; } - info.buffer = (char *) malloc (info.num_blocks * CD_FRAMESIZE_RAW + CD_FRAMESIZE_RAW); + info.buffer = (char *) malloc(info.num_blocks * CD_FRAMESIZE_RAW + CD_FRAMESIZE_RAW); if (info.buffer == NULL) { - fprintf (stderr, "malloc: out of memory\n"); + fprintf(stderr, "malloc: out of memory\n"); return; } - linux_read_toc (&info); + linux_read_toc(&info); /* printf ("start track=%d block=%d\n", info.starting_track, info.starting_block); */ /* printf ("end track=%d block=%d\n", info.ending_track, info.ending_block); */ @@ -593,33 +593,33 @@ for (i = 0; i < max_retries; i++) { struct cdrom_read_audio audio; - + audio.addr_format = CDROM_LBA; audio.addr.lba = info.current_block; audio.nframes = frames; audio.buf = info.buffer; - if (ioctl (info.fd, CDROMREADAUDIO, &audio) >= 0) + if (ioctl(info.fd, CDROMREADAUDIO, &audio) >= 0) { break; } } if (i == max_retries) { - perror (info.device); + perror(info.device); break; } - - if (write (output_fd, info.buffer, CD_FRAMESIZE_RAW * frames) < 0) + + if (write(output_fd, info.buffer, CD_FRAMESIZE_RAW * frames) < 0) { break; } info.current_block += frames; } - - free (info.buffer); - close (info.fd); + + free(info.buffer); + close(info.fd); } #endif /* linux */ diff --git a/rplayd/cdrom.h b/rplayd/cdrom.h index 48c132b..ee14be9 100644 --- a/rplayd/cdrom.h +++ b/rplayd/cdrom.h @@ -1,7 +1,7 @@ -/* $Id: cdrom.h,v 1.2 1998/08/13 06:13:45 boyns Exp $ */ +/* $Id: cdrom.h,v 1.3 1999/03/10 07:58:02 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/command.c b/rplayd/command.c index 94c95e2..2d0a4dd 100644 --- a/rplayd/command.c +++ b/rplayd/command.c @@ -1,7 +1,7 @@ -/* $Id: command.c,v 1.2 1998/08/13 06:13:46 boyns Exp $ */ +/* $Id: command.c,v 1.6 1999/03/10 07:58:02 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,6 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifdef HAVE_CONFIG_H #include "config.h" @@ -71,53 +69,55 @@ COMMAND; #ifdef __STDC__ -static int do_command (CONNECTION *c, int argc, char **argv); -static int command_quit (CONNECTION *c, int argc, char **argv); -static int command_unknown (CONNECTION *c, int argc, char **argv); -static int command_help (CONNECTION *c, int argc, char **argv); -static int command_get (CONNECTION *c, int argc, char **argv); -static int command_put (CONNECTION *c, int argc, char **argv); -static int command_list (CONNECTION *c, int argc, char **argv); -static int command_find (CONNECTION *c, int argc, char **argv); -static int command_execute (CONNECTION *c, int argc, char **argv); -static int command_access (CONNECTION *c, int argc, char **argv); -static int command_volume (CONNECTION *c, int argc, char **argv); -static int command_info (CONNECTION *c, int argc, char **argv); -static int command_version (CONNECTION *c, int argc, char **argv); -static int command_wait (CONNECTION *c, int argc, char **argv); -static int do_execute (CONNECTION *c, int argc, char **argv); -static int command_status (CONNECTION *c, int argc, char **argv); -static int command_application (CONNECTION *c, int argc, char **argv); -static int command_reset (CONNECTION *c, int argc, char **argv); -static int command_skip (CONNECTION *c, int argc, char **argv); -static int command_set (CONNECTION *c, int argc, char **argv); -static int command_modify (CONNECTION *c, int argc, char **argv); -#else -static int do_command ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_quit ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_unknown ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_help ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_get ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_put ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_list ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_find ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_execute ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_access ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_volume ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_info ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_version ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_wait ( /* CONNECTION *c, int argc, char **argv */ ); -static int do_execute ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_status ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_application ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_reset ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_skip ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_set ( /* CONNECTION *c, int argc, char **argv */ ); -static int command_modify ( /* CONNECTION *c, int argc, char **argv */ ); +static int do_command(CONNECTION *c, int argc, char **argv); +static int command_quit(CONNECTION *c, int argc, char **argv); +static int command_unknown(CONNECTION *c, int argc, char **argv); +static int command_help(CONNECTION *c, int argc, char **argv); +static int command_get(CONNECTION *c, int argc, char **argv); +static int command_put(CONNECTION *c, int argc, char **argv); +static int command_list(CONNECTION *c, int argc, char **argv); +static int command_find(CONNECTION *c, int argc, char **argv); +static int command_execute(CONNECTION *c, int argc, char **argv); +static int command_access(CONNECTION *c, int argc, char **argv); +static int command_volume(CONNECTION *c, int argc, char **argv); +static int command_info(CONNECTION *c, int argc, char **argv); +static int command_version(CONNECTION *c, int argc, char **argv); +static int command_wait(CONNECTION *c, int argc, char **argv); +static int do_execute(CONNECTION *c, int argc, char **argv); +static int command_status(CONNECTION *c, int argc, char **argv); +static int command_application(CONNECTION *c, int argc, char **argv); +static int command_reset(CONNECTION *c, int argc, char **argv); +static int command_skip(CONNECTION *c, int argc, char **argv); +static int command_set(CONNECTION *c, int argc, char **argv); +static int command_modify(CONNECTION *c, int argc, char **argv); +static int command_monitor(CONNECTION *c, int argc, char **argv); +#else +static int do_command( /* CONNECTION *c, int argc, char **argv */ ); +static int command_quit( /* CONNECTION *c, int argc, char **argv */ ); +static int command_unknown( /* CONNECTION *c, int argc, char **argv */ ); +static int command_help( /* CONNECTION *c, int argc, char **argv */ ); +static int command_get( /* CONNECTION *c, int argc, char **argv */ ); +static int command_put( /* CONNECTION *c, int argc, char **argv */ ); +static int command_list( /* CONNECTION *c, int argc, char **argv */ ); +static int command_find( /* CONNECTION *c, int argc, char **argv */ ); +static int command_execute( /* CONNECTION *c, int argc, char **argv */ ); +static int command_access( /* CONNECTION *c, int argc, char **argv */ ); +static int command_volume( /* CONNECTION *c, int argc, char **argv */ ); +static int command_info( /* CONNECTION *c, int argc, char **argv */ ); +static int command_version( /* CONNECTION *c, int argc, char **argv */ ); +static int command_wait( /* CONNECTION *c, int argc, char **argv */ ); +static int do_execute( /* CONNECTION *c, int argc, char **argv */ ); +static int command_status( /* CONNECTION *c, int argc, char **argv */ ); +static int command_application( /* CONNECTION *c, int argc, char **argv */ ); +static int command_reset( /* CONNECTION *c, int argc, char **argv */ ); +static int command_skip( /* CONNECTION *c, int argc, char **argv */ ); +static int command_set( /* CONNECTION *c, int argc, char **argv */ ); +static int command_modify( /* CONNECTION *c, int argc, char **argv */ ); +static int command_monitor( /* CONNECTION *c, int argc, char **argv */ ); #endif #ifdef DEBUG -extern int command_die ( /* CONNECTION *c, int argc, char **argv */ ); +extern int command_die( /* CONNECTION *c, int argc, char **argv */ ); #endif static COMMAND commands[] = @@ -142,6 +142,7 @@ {"list", 0, 1, "[connections|servers|sounds}", command_list}, #endif /* AUTH */ {"modify", 2, -1, "id [count|list-count|priority|sample-rate|volume] ...", command_modify}, + {"monitor", -1, -1, "", command_monitor}, {"pause", 1, -1, "id|sound ...", command_execute}, {"play", 1, -1, "sound ...", command_execute}, {"put", 2, -1, "id|sound size", command_put}, @@ -164,10 +165,10 @@ #ifdef __STDC__ int -command (CONNECTION *c, char *buf) +command(CONNECTION *c, char *buf) #else int -command (c, buf) +command(c, buf) CONNECTION *c; char *buf; #endif @@ -175,13 +176,17 @@ char *argv[RPTP_MAX_ARGS], *p; int argc = 0, first = 1; - report (REPORT_INFO, "%s command=\"%s\"\n", inet_ntoa (c->sin.sin_addr), buf); - strncpy (command_buffer, buf, sizeof(command_buffer)); - - while ((p = strtok (first ? buf : NULL, " \t"))) + report(REPORT_INFO, "%s command=\"%s\"\n", inet_ntoa(c->sin.sin_addr), buf); + strncpy(command_buffer, buf, sizeof(command_buffer)); + + while ((p = strtok(first ? buf : NULL, " \t"))) { argv[argc++] = p; first = 0; + if (argc == RPTP_MAX_ARGS - 1) + { + break; + } } argv[argc] = NULL; @@ -191,16 +196,16 @@ } else { - return do_command (c, argc, argv); - } -} - -#ifdef __STDC__ -static int -do_command (CONNECTION *c, int argc, char **argv) -#else -static int -do_command (c, argc, argv) + return do_command(c, argc, argv); + } +} + +#ifdef __STDC__ +static int +do_command(CONNECTION *c, int argc, char **argv) +#else +static int +do_command(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -210,13 +215,13 @@ for (i = 0; i < NCOMMANDS; i++) { - if (strcmp (commands[i].name, argv[0]) == 0) + if (strcmp(commands[i].name, argv[0]) == 0) { if ((commands[i].min_args >= 0 && argc - 1 < commands[i].min_args) || (commands[i].max_args >= 0 && argc - 1 > commands[i].max_args)) { - connection_reply (c, "%cerror=\"usage: %s %s\"", - RPTP_ERROR, commands[i].name, commands[i].usage); + connection_reply(c, "%cerror=\"usage: %s %s\"", + RPTP_ERROR, commands[i].name, commands[i].usage); return 0; } else @@ -226,15 +231,15 @@ } } - return command_unknown (c, argc, argv); -} - -#ifdef __STDC__ -static int -command_quit (CONNECTION *c, int argc, char **argv) -#else -static int -command_quit (c, argc, argv) + return command_unknown(c, argc, argv); +} + +#ifdef __STDC__ +static int +command_quit(CONNECTION *c, int argc, char **argv) +#else +static int +command_quit(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -246,35 +251,35 @@ #ifdef __STDC__ static int -command_unknown (CONNECTION *c, int argc, char **argv) -#else -static int -command_unknown (c, argc, argv) +command_unknown(CONNECTION *c, int argc, char **argv) +#else +static int +command_unknown(c, argc, argv) CONNECTION *c; int argc; char **argv; #endif { char *client_data; - - client_data = rptp_parse (command_buffer, "client-data"); + + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; } - connection_reply (c, "%cerror=\"unknown command `%s'\" command=\"%s\" client-data=\"%s\"", - RPTP_ERROR, argv[0], argv[0], client_data); - + connection_reply(c, "%cerror=\"unknown command `%s'\" command=\"%s\" client-data=\"%s\"", + RPTP_ERROR, argv[0], argv[0], client_data); + return 0; } #ifdef __STDC__ static int -command_help (CONNECTION *c, int argc, char **argv) -#else -static int -command_help (c, argc, argv) +command_help(CONNECTION *c, int argc, char **argv) +#else +static int +command_help(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -287,30 +292,32 @@ if (b == NULL) { - b = buffer_create (); + b = buffer_create(); b->status = BUFFER_KEEP; - SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "%cmessage=\"command summary\" command=help\r\n", RPTP_OK); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "%cmessage=\"command summary\" command=help\r\n", RPTP_OK); + b->nbytes += strlen(b->buf); for (i = 0; i < NCOMMANDS; i++) { - SNPRINTF (SIZE(fmt,sizeof(fmt)), "%-8s %s\r\n", commands[i].name, commands[i].usage); - SNPRINTF (SIZE(b->buf+strlen(b->buf),BUFFER_SIZE), fmt); - } - SNPRINTF (SIZE(b->buf+strlen(b->buf),BUFFER_SIZE), ".\r\n"); - b->nbytes = strlen (b->buf); - } - - e = event_create (EVENT_WRITE, b); - event_insert (c, e); + SNPRINTF(SIZE(fmt, sizeof(fmt)), "%-8s %s\r\n", commands[i].name, commands[i].usage); + SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), fmt); + b->nbytes += strlen(fmt); + } + SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), ".\r\n"); + b->nbytes += 3; + } + + e = event_create(EVENT_WRITE, b); + event_insert(c, e); return 0; } #ifdef __STDC__ static int -command_get (CONNECTION *c, int argc, char **argv) -#else -static int -command_get (c, argc, argv) +command_get(CONNECTION *c, int argc, char **argv) +#else +static int +command_get(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -321,11 +328,11 @@ char *sound_name = NULL; int old_style = 0; char *client_data = default_client_data; - - if (strchr (command_buffer, '=')) - { - sound_name = rptp_parse (command_buffer, "sound"); - client_data = rptp_parse (0, "client-data"); + + if (strchr(command_buffer, '=')) + { + sound_name = rptp_parse(command_buffer, "sound"); + client_data = rptp_parse(0, "client-data"); if (!client_data) { client_data = default_client_data; @@ -338,54 +345,54 @@ } #ifdef AUTH - if (!host_access (c->sin, HOST_READ)) - { - report (REPORT_NOTICE, "%s get %s - read access denied\n", - inet_ntoa (c->sin.sin_addr), - argv[1]); - connection_reply (c, "%cerror=\"access denied\" command=get client-data=\"%s\"", - RPTP_ERROR, client_data); + if (!host_access(c->sin, HOST_READ)) + { + report(REPORT_NOTICE, "%s get %s - read access denied\n", + inet_ntoa(c->sin.sin_addr), + argv[1]); + connection_reply(c, "%cerror=\"access denied\" command=get client-data=\"%s\"", + RPTP_ERROR, client_data); return 0; } #endif /* AUTH */ - s = sound_lookup (sound_name, SOUND_DONT_FIND, NULL); + s = sound_lookup(sound_name, SOUND_DONT_FIND, NULL); if (s == NULL || s->status != SOUND_READY) { - report (REPORT_NOTICE, "%s get %s - not found\n", - inet_ntoa (c->sin.sin_addr), sound_name); - connection_reply (c, "%cerror=\"%s not found\" command=get client-data=\"%s\"", - RPTP_ERROR, sound_name, client_data); + report(REPORT_NOTICE, "%s get %s - not found\n", + inet_ntoa(c->sin.sin_addr), sound_name); + connection_reply(c, "%cerror=\"%s not found\" command=get client-data=\"%s\"", + RPTP_ERROR, sound_name, client_data); } else if (s->type != SOUND_FILE) { - connection_reply (c, "%cerror=\"%s not a file\" command=get client-data=\"%s\"", - RPTP_ERROR, s->name, client_data); + connection_reply(c, "%cerror=\"%s not a file\" command=get client-data=\"%s\"", + RPTP_ERROR, s->name, client_data); } else { - e = event_create (EVENT_WRITE_SOUND, s); + e = event_create(EVENT_WRITE_SOUND, s); if (e == NULL) { - report (REPORT_NOTICE, "%s get %s - cannot open\n", - inet_ntoa (c->sin.sin_addr), s->name); - connection_reply (c, "%cerror=\"cannot open %s\" command=get client-data=\"%s\"", - RPTP_ERROR, s->name, client_data); + report(REPORT_NOTICE, "%s get %s - cannot open\n", + inet_ntoa(c->sin.sin_addr), s->name); + connection_reply(c, "%cerror=\"cannot open %s\" command=get client-data=\"%s\"", + RPTP_ERROR, s->name, client_data); } else { - report (REPORT_NOTICE, "%s get %s %d\n", - inet_ntoa (c->sin.sin_addr), s->name, s->size); + report(REPORT_NOTICE, "%s get %s %d\n", + inet_ntoa(c->sin.sin_addr), s->name, s->size); if (old_style) { - connection_reply (c, "%c%s %d", RPTP_OK, s->name, s->size); + connection_reply(c, "%c%s %d", RPTP_OK, s->name, s->size); } else { - connection_reply (c, "%csound=\"%s\" size=%d command=get client-data=\"%s\"", - RPTP_OK, s->name, s->size, client_data); - } - event_insert (c, e); + connection_reply(c, "%csound=\"%s\" size=%d command=get client-data=\"%s\"", + RPTP_OK, s->name, s->size, client_data); + } + event_insert(c, e); } } @@ -394,10 +401,10 @@ #ifdef __STDC__ static int -command_put (CONNECTION *c, int argc, char **argv) -#else -static int -command_put (c, argc, argv) +command_put(CONNECTION *c, int argc, char **argv) +#else +static int +command_put(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -411,10 +418,10 @@ int old_style = 0; int spool_id = 0; char *client_data = default_client_data; - - if (strchr (command_buffer, '=')) - { - client_data = rptp_parse (command_buffer, "client-data"); + + if (strchr(command_buffer, '=')) + { + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; @@ -424,15 +431,15 @@ { old_style++; } - + #ifdef AUTH - if (!host_access (c->sin, HOST_WRITE)) - { - report (REPORT_NOTICE, "%s put %s - write access denied\n", - inet_ntoa (c->sin.sin_addr), - argv[1]); - connection_reply (c, "%cerror=\"access denied\" command=put client-data=\"%s\"", - RPTP_ERROR, client_data); + if (!host_access(c->sin, HOST_WRITE)) + { + report(REPORT_NOTICE, "%s put %s - write access denied\n", + inet_ntoa(c->sin.sin_addr), + argv[1]); + connection_reply(c, "%cerror=\"access denied\" command=put client-data=\"%s\"", + RPTP_ERROR, client_data); return 0; } #endif /* AUTH */ @@ -440,80 +447,75 @@ if (!old_style) { char *p; - - sound_name = rptp_parse (0, "sound"); - - p = rptp_parse (0, "size"); + + sound_name = rptp_parse(0, "sound"); + + p = rptp_parse(0, "size"); if (!p) { - connection_reply (c, "%cerror=\"missing `size='\" command=put client-data=\"%s\"", - RPTP_ERROR, client_data); + connection_reply(c, "%cerror=\"missing `size='\" command=put client-data=\"%s\"", + RPTP_ERROR, client_data); return 0; } - sound_size = atoi (p); - - p = rptp_parse (0, "id"); + sound_size = atoi(p); + + p = rptp_parse(0, "id"); if (p && *p && p[0] == '#') { - spool_id = atoi (p+1); - } - else - { - connection_reply (c, "%cerror=\"invalid `id'\" command=put client-data=\"%s\"", - RPTP_ERROR, client_data); + spool_id = atoi(p + 1); + } + } + else + /* old-style */ + { + sound_name = argv[1]; + sound_size = atoi(argv[2]); + old_style++; + } + + if (spool_id) + { + SPOOL *sp; +#ifdef HAVE_HELPERS + HELPER *hp; +#endif + + sp = spool_find(spool_id); + if (!sp) + { + connection_reply(c, "%cerror=\"`%d' no such spool id\" command=put client-data=\"%s\"", + RPTP_ERROR, spool_id, client_data); return 0; } - } - else /* old-style */ - { - sound_name = argv[1]; - sound_size = atoi (argv[2]); - old_style++; - } - - if (spool_id) - { - SPOOL *sp; -#ifdef HAVE_HELPERS - HELPER *hp; -#endif - - sp = spool_find (spool_id); - if (!sp) - { - connection_reply (c, "%cerror=\"`%d' no such spool id\" command=put client-data=\"%s\"", - RPTP_ERROR, spool_id, client_data); + else if (sp->sound[sp->curr_sound]->type != SOUND_FLOW) + { + connection_reply(c, "%cerror=\"`%d' spool id is not a flow\" command=put client-data=\"%s\"", + RPTP_ERROR, spool_id, client_data); return 0; } - else if (sp->sound[sp->curr_sound]->type != SOUND_FLOW) - { - connection_reply (c, "%cerror=\"`%d' spool id is not a flow\" command=put client-data=\"%s\"", - RPTP_ERROR, spool_id, client_data); - return 0; - } - - connection_reply (c, "%cid=#%d size=%d command=put client-data=\"%s\"", - RPTP_OK, spool_id, sound_size, client_data); - -#ifdef HAVE_HELPERS + + connection_reply(c, "%cid=#%d size=%d command=put client-data=\"%s\"", + RPTP_OK, spool_id, sound_size, client_data); + +#ifdef HAVE_HELPERS /* XXX - it isn't known yet whether or not this sound will need a helper. Check here too. */ - hp = helper_lookup (sp->sound[sp->curr_sound]->path); + hp = helper_lookup(sp->sound[sp->curr_sound]->path); if (hp) { SOUND *s = sp->sound[sp->curr_sound]; - e = event_create (EVENT_PIPE_FLOW, spool_id, s); - event_insert (c, e); + e = event_create(EVENT_PIPE_FLOW, spool_id, s); + event_insert(c, e); s->status = SOUND_READY; - sound_map (s); - spool_ready (s); + sound_map(s); + spool_ready(s); } else -#endif /* HAVE_HELPERS */ - { - e = event_create (EVENT_READ_FLOW, spool_id, sound_size); - event_insert (c, e); +#endif /* HAVE_HELPERS */ + { + e = event_create(EVENT_READ_FLOW, spool_id, sound_size); + event_insert(c, e); } return 0; @@ -521,63 +523,63 @@ else { /* strip pathnames -- files can only be put in the cache directory */ - p = strrchr (sound_name, '/'); + p = strrchr(sound_name, '/'); if (p) { sound_name = p + 1; } - name = cache_name (sound_name); - - s = sound_lookup (name, SOUND_DONT_FIND, NULL); + name = cache_name(sound_name); + + s = sound_lookup(name, SOUND_DONT_FIND, NULL); if (s != NULL) { - connection_reply (c, "%cerror=\"%s already is in the cache\" command=put client-data=\"%s\"", - RPTP_ERROR, sound_name, client_data); + connection_reply(c, "%cerror=\"%s already is in the cache\" command=put client-data=\"%s\"", + RPTP_ERROR, sound_name, client_data); return 0; } - if (cache_free (sound_size) < 0) - { - connection_reply (c, "%cerror=\"the cache is full\" command=put client-data=\"%s\"", - RPTP_ERROR, client_data); + if (cache_free(sound_size) < 0) + { + connection_reply(c, "%cerror=\"the cache is full\" command=put client-data=\"%s\"", + RPTP_ERROR, client_data); } else { - fd = cache_create (name, sound_size); + fd = cache_create(name, sound_size); if (fd < 0) { - connection_reply (c, "%cerror=\"cache error\" command=put client-data=\"%s\"", - RPTP_ERROR, client_data); + connection_reply(c, "%cerror=\"cache error\" command=put client-data=\"%s\"", + RPTP_ERROR, client_data); } else { - report (REPORT_NOTICE, "%s put %s %d\n", - inet_ntoa (c->sin.sin_addr), sound_name, sound_size); - s = sound_insert (name, SOUND_NOT_READY, SOUND_FILE); + report(REPORT_NOTICE, "%s put %s %d\n", + inet_ntoa(c->sin.sin_addr), sound_name, sound_size); + s = sound_insert(name, SOUND_NOT_READY, SOUND_FILE); if (old_style) { - connection_reply (c, "%c%s %d", RPTP_OK, sound_name, sound_size); + connection_reply(c, "%c%s %d", RPTP_OK, sound_name, sound_size); } else { - connection_reply (c, "%csound=\"%s\" size=%d command=put client-data=\"%s\"", - RPTP_OK, sound_name, sound_size, client_data); + connection_reply(c, "%csound=\"%s\" size=%d command=put client-data=\"%s\"", + RPTP_OK, sound_name, sound_size, client_data); } - e = event_create (EVENT_READ_SOUND, fd, buffer_create (), sound_size, s); - event_insert (c, e); - } - } - + e = event_create(EVENT_READ_SOUND, fd, buffer_create(), sound_size, s); + event_insert(c, e); + } + } + return 0; } } #ifdef __STDC__ static int -command_list (CONNECTION *c, int argc, char **argv) -#else -static int -command_list (c, argc, argv) +command_list(CONNECTION *c, int argc, char **argv) +#else +static int +command_list(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -586,91 +588,91 @@ EVENT *e; char *client_data = default_client_data; BUFFER *b; - - if (strchr (command_buffer, '=')) - { - client_data = rptp_parse (command_buffer, "client-data"); + + if (strchr(command_buffer, '=')) + { + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; } } - if (argv[1] == NULL || strcmp (argv[1], "sounds") == 0) - { - b = sound_list_create (); + if (argv[1] == NULL || strcmp(argv[1], "sounds") == 0) + { + b = sound_list_create(); if (b) { - e = event_create (EVENT_WRITE, b); - event_insert (c, e); + e = event_create(EVENT_WRITE, b); + event_insert(c, e); } else { - connection_reply (c, "%cerror=\"no sounds available\" command=list client-data=\"%s\"", - RPTP_ERROR, client_data); - } - } - else if (strcmp (argv[1], "connections") == 0) - { - b = connection_list_create (); + connection_reply(c, "%cerror=\"no sounds available\" command=list client-data=\"%s\"", + RPTP_ERROR, client_data); + } + } + else if (strcmp(argv[1], "connections") == 0) + { + b = connection_list_create(); if (b) { - e = event_create (EVENT_WRITE, b); - event_insert (c, e); + e = event_create(EVENT_WRITE, b); + event_insert(c, e); } else { - connection_reply (c, "%cerror=\"no connections available\" command=list client-data=\"%s\"", - RPTP_ERROR, client_data); - } - } - else if (strcmp (argv[1], "servers") == 0) + connection_reply(c, "%cerror=\"no connections available\" command=list client-data=\"%s\"", + RPTP_ERROR, client_data); + } + } + else if (strcmp(argv[1], "servers") == 0) { if (server_list) { - e = event_create (EVENT_WRITE, server_list); - event_insert (c, e); + e = event_create(EVENT_WRITE, server_list); + event_insert(c, e); } else { - connection_reply (c, "%cerror=\"no servers available\" command=list client-data=\"%s\"", - RPTP_ERROR, client_data); - } - } - else if (strcmp (argv[1], "spool") == 0) - { - b = spool_list_create (); + connection_reply(c, "%cerror=\"no servers available\" command=list client-data=\"%s\"", + RPTP_ERROR, client_data); + } + } + else if (strcmp(argv[1], "spool") == 0) + { + b = spool_list_create(); if (b) { - e = event_create (EVENT_WRITE, b); - event_insert (c, e); + e = event_create(EVENT_WRITE, b); + event_insert(c, e); } else { - connection_reply (c, "%cerror=\"no spool available\" command=list client-data=\"%s\"", - RPTP_ERROR, client_data); + connection_reply(c, "%cerror=\"no spool available\" command=list client-data=\"%s\"", + RPTP_ERROR, client_data); } } #ifdef AUTH - else if (strcmp (argv[1], "hosts") == 0) + else if (strcmp(argv[1], "hosts") == 0) { b = host_list; if (b) { - e = event_create (EVENT_WRITE, b); - event_insert (c, e); + e = event_create(EVENT_WRITE, b); + event_insert(c, e); } else { - connection_reply (c, "%cerror=\"no hosts available\" command=list client-data=\"%s\"", - RPTP_ERROR, client_data); + connection_reply(c, "%cerror=\"no hosts available\" command=list client-data=\"%s\"", + RPTP_ERROR, client_data); } } #endif /* AUTH */ else { - connection_reply (c, "%cerror=\"cannot list `%s'\" command=list client-data=\"%s\"", - RPTP_ERROR, argv[1], client_data); + connection_reply(c, "%cerror=\"cannot list `%s'\" command=list client-data=\"%s\"", + RPTP_ERROR, argv[1], client_data); } return 0; @@ -678,10 +680,10 @@ #ifdef __STDC__ static int -command_find (CONNECTION *c, int argc, char **argv) -#else -static int -command_find (c, argc, argv) +command_find(CONNECTION *c, int argc, char **argv) +#else +static int +command_find(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -691,11 +693,11 @@ char *sound_name = NULL; int old_style = 0; char *client_data = default_client_data; - - if (strchr (command_buffer, '=')) - { - sound_name = rptp_parse (command_buffer, "sound"); - client_data = rptp_parse (0, "client-data"); + + if (strchr(command_buffer, '=')) + { + sound_name = rptp_parse(command_buffer, "sound"); + client_data = rptp_parse(0, "client-data"); if (!client_data) { client_data = default_client_data; @@ -707,26 +709,26 @@ old_style++; } - s = sound_lookup (sound_name, SOUND_DONT_FIND, NULL); + s = sound_lookup(sound_name, SOUND_DONT_FIND, NULL); if (s == NULL || s->status != SOUND_READY) { - report (REPORT_NOTICE, "%s find %s - not found\n", - inet_ntoa (c->sin.sin_addr), sound_name); - connection_reply (c, "%cerror=\"%s not found\" command=find client-data=\"%s\"", - RPTP_ERROR, sound_name, client_data); + report(REPORT_NOTICE, "%s find %s - not found\n", + inet_ntoa(c->sin.sin_addr), sound_name); + connection_reply(c, "%cerror=\"%s not found\" command=find client-data=\"%s\"", + RPTP_ERROR, sound_name, client_data); } else { - report (REPORT_NOTICE, "%s find %s %d\n", - inet_ntoa (c->sin.sin_addr), sound_name, s->size); + report(REPORT_NOTICE, "%s find %s %d\n", + inet_ntoa(c->sin.sin_addr), sound_name, s->size); if (old_style) { - connection_reply (c, "%c%s %d", RPTP_OK, s->name, s->size); + connection_reply(c, "%c%s %d", RPTP_OK, s->name, s->size); } else { - connection_reply (c, "%csound=\"%s\" size=%d command=find client-data=\"%s\"", - RPTP_OK, s->name, s->size, client_data); + connection_reply(c, "%csound=\"%s\" size=%d command=find client-data=\"%s\"", + RPTP_OK, s->name, s->size, client_data); } } @@ -735,10 +737,10 @@ #ifdef __STDC__ static int -command_access (CONNECTION *c, int argc, char **argv) -#else -static int -command_access (c, argc, argv) +command_access(CONNECTION *c, int argc, char **argv) +#else +static int +command_access(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -746,63 +748,63 @@ { char buf[4]; char *client_data = default_client_data; - - if (strchr (command_buffer, '=')) - { - client_data = rptp_parse (command_buffer, "client-data"); + + if (strchr(command_buffer, '=')) + { + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; } } - + buf[0] = '\0'; #ifdef AUTH - if (host_access (c->sin, HOST_READ)) - { - strcat (buf, "r"); - } - if (host_access (c->sin, HOST_WRITE)) - { - strcat (buf, "w"); - } - if (host_access (c->sin, HOST_EXECUTE)) - { - strcat (buf, "x"); + if (host_access(c->sin, HOST_READ)) + { + strcat(buf, "r"); + } + if (host_access(c->sin, HOST_WRITE)) + { + strcat(buf, "w"); + } + if (host_access(c->sin, HOST_EXECUTE)) + { + strcat(buf, "x"); } #else /* AUTH */ - strcat (buf, "rwx"); + strcat(buf, "rwx"); #endif /* AUTH */ - connection_reply (c, "%caccess=%s command=access client-data=\"%s\"", - RPTP_OK, buf, client_data); + connection_reply(c, "%caccess=%s command=access client-data=\"%s\"", + RPTP_OK, buf, client_data); return 0; } #ifdef __STDC__ static int -command_execute (CONNECTION *c, int argc, char **argv) -#else -static int -command_execute (c, argc, argv) +command_execute(CONNECTION *c, int argc, char **argv) +#else +static int +command_execute(c, argc, argv) CONNECTION *c; int argc; char **argv; #endif { SPOOL *sp; - int id = do_execute (c, argc, argv); + int id = do_execute(c, argc, argv); if (id > 0) { - sp = spool_find (id); - connection_reply (c, "%cid=#%d sound=\"%s\" command=%s client-data=\"%s\" list-name=\"%s\"", - RPTP_OK, id, - sp->curr_attrs->sound, - argv[0], - sp->curr_attrs->client_data, - sp->rp->list_name); + sp = spool_find(id); + connection_reply(c, "%cid=#%d sound=\"%s\" command=%s client-data=\"%s\" list-name=\"%s\"", + RPTP_OK, id, + sp->curr_attrs->sound, + argv[0], + sp->curr_attrs->client_data, + sp->rp->list_name); } return 0; @@ -814,10 +816,10 @@ */ #ifdef __STDC__ static int -do_execute (CONNECTION *c, int argc, char **argv) -#else -static int -do_execute (c, argc, argv) +do_execute(CONNECTION *c, int argc, char **argv) +#else +static int +do_execute(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -828,7 +830,7 @@ RPLAY *rp; int volume, list_count, count, priority, sample_rate; int do_random = 0; - int do_search = 1; /* search by default */ + int do_search = 1; /* search by default */ int input = SOUND_FILE; int input_offset = 0; int input_format = 0; @@ -836,34 +838,34 @@ int input_sample_rate = 0; float input_precision = 0; int input_channels = 0; - int input_storage = SOUND_STORAGE_NONE; /* Don't store flows by default. */ + int input_storage = SOUND_STORAGE_NONE; /* Don't store flows by default. */ char *client_data = default_client_data; char *list_name = NULL; - - if (strcmp (argv[0], "play") == 0) + + if (strcmp(argv[0], "play") == 0) { command = RPLAY_PLAY; } - else if (strcmp (argv[0], "stop") == 0) + else if (strcmp(argv[0], "stop") == 0) { command = RPLAY_STOP; } - else if (strcmp (argv[0], "pause") == 0) + else if (strcmp(argv[0], "pause") == 0) { command = RPLAY_PAUSE; } - else if (strcmp (argv[0], "continue") == 0) + else if (strcmp(argv[0], "continue") == 0) { command = RPLAY_CONTINUE; } - else if (strcmp (argv[0], "done") == 0) + else if (strcmp(argv[0], "done") == 0) { command = RPLAY_DONE; } - if (strchr (command_buffer, '=')) - { - client_data = rptp_parse (command_buffer, "client-data"); + if (strchr(command_buffer, '=')) + { + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; @@ -873,23 +875,23 @@ { old_style++; } - + #ifdef AUTH - if (!host_access (c->sin, HOST_EXECUTE)) - { - report (REPORT_NOTICE, "%s %s access denied\n", argv[0], - inet_ntoa (c->sin.sin_addr)); - connection_reply (c, "%cerror=\"access denied\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], client_data); + if (!host_access(c->sin, HOST_EXECUTE)) + { + report(REPORT_NOTICE, "%s %s access denied\n", argv[0], + inet_ntoa(c->sin.sin_addr)); + connection_reply(c, "%cerror=\"access denied\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], client_data); return -1; } #endif /* AUTH */ - rp = rplay_create (command); + rp = rplay_create(command); if (rp == NULL) { - connection_reply (c, "%cerror=\"%s failed\" command=%s client_data=\"%s\"", - RPTP_ERROR, argv[0], argv[0], client_data); + connection_reply(c, "%cerror=\"%s failed\" command=%s client_data=\"%s\"", + RPTP_ERROR, argv[0], argv[0], client_data); return -1; } @@ -903,132 +905,153 @@ { char *name, *value; - rptp_parse (command_buffer, 0); - while (name = rptp_parse (0, 0)) - { - value = rptp_parse (0, name); + rptp_parse(command_buffer, 0); + while (name = rptp_parse(0, 0)) + { + value = rptp_parse(0, name); if (!value || !*value) { continue; } - else if (strcmp (name, "sound") == 0 - || (command != RPLAY_PLAY && strcmp (name, "id") == 0)) - { - val = rplay_set (rp, RPLAY_APPEND, - RPLAY_SOUND, value, - RPLAY_VOLUME, volume, - RPLAY_COUNT, count, - RPLAY_SAMPLE_RATE, sample_rate, - RPLAY_RPTP_SEARCH, do_search, - RPLAY_CLIENT_DATA, client_data, - NULL); + else if (strcmp(name, "sound") == 0 + || (command != RPLAY_PLAY && strcmp(name, "id") == 0)) + { + val = rplay_set(rp, RPLAY_APPEND, + RPLAY_SOUND, value, + RPLAY_VOLUME, volume, + RPLAY_COUNT, count, + RPLAY_SAMPLE_RATE, sample_rate, + RPLAY_RPTP_SEARCH, do_search, + RPLAY_CLIENT_DATA, client_data, + NULL); if (val < 0) { - connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], argv[0], client_data); + connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], argv[0], client_data); return -1; } } - else if (strcmp (name, "client-data") == 0) + else if (strcmp(name, "client-data") == 0) { client_data = value; } - else if (strcmp (name, "volume") == 0) - { - volume = atoi (value); - } - else if (strcmp (name, "count") == 0) - { - count = atoi (value); - } - else if (strcmp (name, "list-count") == 0) - { - list_count = atoi (value); - } - else if (strcmp (name, "priority") == 0) - { - priority = atoi (value); - } - else if (strcmp (name, "sample-rate") == 0) - { - sample_rate = atoi (value); - } - else if (strcmp (name, "search") == 0 - || strcmp (name, "rptp-search") == 0) - { - do_search = is_true (value); - } - else if (strcmp (name, "random") == 0) - { - do_random = is_true (value); - } - else if (strcmp (name, "list-name") == 0) + else if (strcmp(name, "volume") == 0) + { + volume = atoi(value); + } + else if (strcmp(name, "count") == 0) + { + count = atoi(value); + } + else if (strcmp(name, "list-count") == 0) + { + list_count = atoi(value); + } + else if (strcmp(name, "priority") == 0) + { + priority = atoi(value); + } + else if (strcmp(name, "sample-rate") == 0) + { + sample_rate = atoi(value); + } + else if (strcmp(name, "search") == 0 + || strcmp(name, "rptp-search") == 0) + { + do_search = is_true(value); + } + else if (strcmp(name, "random") == 0) + { + do_random = is_true(value); + } + else if (strcmp(name, "list-name") == 0) { list_name = value; } - else if (strcmp (name, "input") == 0) - { - input = string_to_input (value); - } - else if (strcmp (name, "input-offset") == 0) - { - input_offset = atoi (value); - } - else if (strcmp (name, "input-format") == 0) - { - input_format = string_to_audio_format (value); - } - else if (strcmp (name, "input-byte-order") == 0) - { - input_byte_order = string_to_byte_order (value); - } - else if (strcmp (name, "input-sample-rate") == 0) - { - input_sample_rate = atoi (value); - } - else if (strcmp (name, "input-bits") == 0) - { - input_precision = atof (value); - } - else if (strcmp (name, "input-channels") == 0) - { - input_channels = atoi (value); - } - else if (strcmp (name, "input-storage") == 0) - { - input_storage = string_to_storage (value); - } - } - } - else /* old-style */ + else if (strcmp(name, "input") == 0) + { + input = string_to_input(value); + } + else if (strcmp(name, "input-offset") == 0) + { + input_offset = atoi(value); + } + else if (strcmp(name, "input-format") == 0) + { + input_format = string_to_audio_format(value); + } + else if (strcmp(name, "input-byte-order") == 0) + { + input_byte_order = string_to_byte_order(value); + } + else if (strcmp(name, "input-sample-rate") == 0) + { + input_sample_rate = atoi(value); + } + else if (strcmp(name, "input-bits") == 0) + { + input_precision = atof(value); + } + else if (strcmp(name, "input-channels") == 0) + { + input_channels = atoi(value); + } + else if (strcmp(name, "input-storage") == 0) + { + input_storage = string_to_storage(value); + } + else if (strcmp(name, "input-info") == 0) + { + char *p = strtok(value, ","); + if (p) input_format = string_to_audio_format(p); + + p = strtok(NULL, ","); + if (p) input_sample_rate = atoi(p); + + p = strtok(NULL, ","); + if (p) input_precision = atoi(p); + + p = strtok(NULL, ","); + if (p) input_channels = atoi(p); + + p = strtok(NULL, ","); + if (p) input_byte_order = string_to_byte_order(p); + + p = strtok(NULL, ","); + if (p) input_offset = atoi(p); + } + } + } + else + /* old-style */ { extern char *optarg; extern int optind; optind = 0; - while ((n = getopt (argc, argv, "+P:R:N:n:v:")) != -1) + while ((n = getopt(argc, argv, "+P:R:N:n:v:")) != -1) { switch (n) { case 'v': - volume = atoi (optarg); + volume = atoi(optarg); break; case 'n': - count = atoi (optarg); + count = atoi(optarg); break; case 'N': - list_count = atoi (optarg); + list_count = atoi(optarg); break; case 'P': - priority = atoi (optarg); + priority = atoi(optarg); break; case 'R': - sample_rate = atoi (optarg); + sample_rate = atoi(optarg); break; default: @@ -1041,11 +1064,11 @@ { for (i = 0; i < NCOMMANDS; i++) { - if (strcmp (commands[i].name, argv[0]) == 0) + if (strcmp(commands[i].name, argv[0]) == 0) { - connection_reply (c, "%cerror=\"usage: %s %s\" command=%s", - RPTP_ERROR, commands[i].name, commands[i].usage, - argv[0]); + connection_reply(c, "%cerror=\"usage: %s %s\" command=%s", + RPTP_ERROR, commands[i].name, commands[i].usage, + argv[0]); return -1; } } @@ -1053,50 +1076,50 @@ while (argv[optind] != NULL) { - val = rplay_set (rp, RPLAY_APPEND, - RPLAY_SOUND, argv[optind++], - RPLAY_VOLUME, volume, - RPLAY_COUNT, count, - RPLAY_SAMPLE_RATE, sample_rate, - RPLAY_RPTP_SEARCH, do_search, - NULL); + val = rplay_set(rp, RPLAY_APPEND, + RPLAY_SOUND, argv[optind++], + RPLAY_VOLUME, volume, + RPLAY_COUNT, count, + RPLAY_SAMPLE_RATE, sample_rate, + RPLAY_RPTP_SEARCH, do_search, + NULL); if (val < 0) { - connection_reply (c, "%cerror=\"%s failed\" command=%s", - RPTP_ERROR, argv[0], argv[0]); + connection_reply(c, "%cerror=\"%s failed\" command=%s", + RPTP_ERROR, argv[0], argv[0]); return -1; } } } - if (rplay_set (rp, RPLAY_LIST_COUNT, list_count, NULL) < 0) - { - connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], argv[0], client_data); + if (rplay_set(rp, RPLAY_LIST_COUNT, list_count, NULL) < 0) + { + connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], argv[0], client_data); return -1; } - if (rplay_set (rp, RPLAY_PRIORITY, priority, NULL) < 0) - { - connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], argv[0], client_data); + if (rplay_set(rp, RPLAY_PRIORITY, priority, NULL) < 0) + { + connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], argv[0], client_data); return -1; } - if (do_random && rplay_set (rp, RPLAY_RANDOM_SOUND, NULL) < 0) - { - connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], argv[0], client_data); + if (do_random && rplay_set(rp, RPLAY_RANDOM_SOUND, NULL) < 0) + { + connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], argv[0], client_data); return -1; } - if (list_name && rplay_set (rp, RPLAY_LIST_NAME, list_name, NULL) < 0) - { - connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], argv[0], client_data); + if (list_name && rplay_set(rp, RPLAY_LIST_NAME, list_name, NULL) < 0) + { + connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], argv[0], client_data); return -1; } - + /* Flows */ if (input == SOUND_FLOW && command == RPLAY_PLAY) { @@ -1107,25 +1130,25 @@ #ifdef AUTH /* Flows require `write' access along with the previously checked `execute' access. */ - if (!host_access (c->sin, HOST_WRITE)) - { - report (REPORT_NOTICE, "%s %s access denied\n", argv[0], - inet_ntoa (c->sin.sin_addr)); - connection_reply (c, "%cerror=\"access denied\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], client_data); + if (!host_access(c->sin, HOST_WRITE)) + { + report(REPORT_NOTICE, "%s %s access denied\n", argv[0], + inet_ntoa(c->sin.sin_addr)); + connection_reply(c, "%cerror=\"access denied\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], client_data); return -1; } #endif /* AUTH */ - + /* Generate a unique sound name. */ - sound_name = (char *) rplay_get (rp, RPLAY_SOUND, 0); + sound_name = (char *) rplay_get(rp, RPLAY_SOUND, 0); if (!sound_name) { - connection_reply (c, "%cerror=\"missing required `sound' attribute\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], client_data); + connection_reply(c, "%cerror=\"missing required `sound' attribute\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], client_data); return -1; } - p = strrchr (sound_name, '/'); + p = strrchr(sound_name, '/'); if (p) { sound_name = p + 1; @@ -1135,26 +1158,26 @@ { if (i) { - SNPRINTF (SIZE(buf,sizeof(buf)), "rplay%d-%s", i, sound_name); + SNPRINTF(SIZE(buf, sizeof(buf)), "rplay%d-%s", i, sound_name); } else { - SNPRINTF (SIZE(buf,sizeof(buf)), sound_name); + SNPRINTF(SIZE(buf, sizeof(buf)), sound_name); } i++; } - while (sound_lookup (buf, SOUND_DONT_FIND, NULL)); - - sound_name = cache_name (buf); - rplay_set (rp, RPLAY_CHANGE, 0, - RPLAY_SOUND, sound_name, - RPLAY_RPTP_SEARCH, FALSE, /* never search */ - NULL); - s = sound_insert (sound_name, SOUND_NOT_READY, SOUND_FLOW); + while (sound_lookup(buf, SOUND_DONT_FIND, NULL)); + + sound_name = cache_name(buf); + rplay_set(rp, RPLAY_CHANGE, 0, + RPLAY_SOUND, sound_name, + RPLAY_RPTP_SEARCH, FALSE, /* never search */ + NULL); + s = sound_insert(sound_name, SOUND_NOT_READY, SOUND_FLOW); if (!s) { - connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], argv[0], client_data); + connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], argv[0], client_data); return -1; } @@ -1168,18 +1191,18 @@ s->storage = input_storage; /* Grab a spool entry. */ - spool_id = rplayd_play (rp, c->sin); + spool_id = rplayd_play(rp, c->sin); if (spool_id < 0) { - connection_reply (c, "%cerror=\"spool full\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], client_data); - sound_delete (s, 0); + connection_reply(c, "%cerror=\"spool full\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], client_data); + sound_delete(s, 0); return -1; } - connection_reply (c, "%cid=#%d sound=\"%s\" command=%s client-data=\"%s\"", - RPTP_OK, spool_id, buf, argv[0], client_data); - + connection_reply(c, "%cid=#%d sound=\"%s\" command=%s client-data=\"%s\"", + RPTP_OK, spool_id, buf, argv[0], client_data); + return 0; } else @@ -1187,35 +1210,35 @@ switch (command) { case RPLAY_PLAY: - val = rplayd_play (rp, c->sin); + val = rplayd_play(rp, c->sin); break; case RPLAY_STOP: - val = rplayd_stop (rp, c->sin); + val = rplayd_stop(rp, c->sin); break; case RPLAY_PAUSE: - val = rplayd_pause (rp, c->sin); + val = rplayd_pause(rp, c->sin); break; case RPLAY_CONTINUE: - val = rplayd_continue (rp, c->sin); + val = rplayd_continue(rp, c->sin); break; case RPLAY_DONE: - val = rplayd_done (rp, c->sin); + val = rplayd_done(rp, c->sin); break; } if (val == 0) { - connection_reply (c, "%cmessage=\"%s successful\" command=%s client-data=\"%s\"", - RPTP_OK, argv[0], argv[0], client_data); + connection_reply(c, "%cmessage=\"%s successful\" command=%s client-data=\"%s\"", + RPTP_OK, argv[0], argv[0], client_data); } else if (val < 0) { - connection_reply (c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", - RPTP_ERROR, argv[0], argv[0], client_data); + connection_reply(c, "%cerror=\"%s failed\" command=%s client-data=\"%s\"", + RPTP_ERROR, argv[0], argv[0], client_data); } return val; @@ -1225,10 +1248,10 @@ /* OBSOLETE */ #ifdef __STDC__ static int -command_volume (CONNECTION *c, int argc, char **argv) -#else -static int -command_volume (c, argc, argv) +command_volume(CONNECTION *c, int argc, char **argv) +#else +static int +command_volume(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -1238,79 +1261,79 @@ int n; #ifdef AUTH - if (!host_access (c->sin, HOST_EXECUTE)) - { - report (REPORT_NOTICE, "%s volume access denied\n", - inet_ntoa (c->sin.sin_addr)); - connection_reply (c, "%cerror=\"access denied\" command=volume", RPTP_ERROR); + if (!host_access(c->sin, HOST_EXECUTE)) + { + report(REPORT_NOTICE, "%s volume access denied\n", + inet_ntoa(c->sin.sin_addr)); + connection_reply(c, "%cerror=\"access denied\" command=volume", RPTP_ERROR); return 0; } #endif /* AUTH */ if (argv[1] == NULL) { - volume = rplay_audio_get_volume (); + volume = rplay_audio_get_volume(); if (volume >= 0) { - connection_reply (c, "%c%d", RPTP_OK, volume); + connection_reply(c, "%c%d", RPTP_OK, volume); } else { - connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); + connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); } } else if (*argv[1] == '+') { - volume = rplay_audio_get_volume (); + volume = rplay_audio_get_volume(); if (volume < 0) { - connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); - } - - volume += atoi (argv[1] + 1); - n = rplay_audio_set_volume (volume); + connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); + } + + volume += atoi(argv[1] + 1); + n = rplay_audio_set_volume(volume); if (n >= 0) { - connection_reply (c, "%c%d", RPTP_OK, n); - connection_notify (0, NOTIFY_VOLUME, n); + connection_reply(c, "%c%d", RPTP_OK, n); + connection_notify(0, NOTIFY_VOLUME, n); } else { - connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); + connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); } } else if (*argv[1] == '-') { - volume = rplay_audio_get_volume (); + volume = rplay_audio_get_volume(); if (volume < 0) { - connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); - } - - volume -= atoi (argv[1] + 1); - n = rplay_audio_set_volume (volume); + connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); + } + + volume -= atoi(argv[1] + 1); + n = rplay_audio_set_volume(volume); if (n >= 0) { - connection_reply (c, "%c%d", RPTP_OK, n); - connection_notify (0, NOTIFY_VOLUME, n); + connection_reply(c, "%c%d", RPTP_OK, n); + connection_notify(0, NOTIFY_VOLUME, n); } else { - connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); + connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); } } else { - volume = atoi (argv[1]); - n = rplay_audio_set_volume (volume); + volume = atoi(argv[1]); + n = rplay_audio_set_volume(volume); if (n >= 0) { - connection_reply (c, "%c%d", RPTP_OK, n); - connection_notify (0, NOTIFY_VOLUME, n); + connection_reply(c, "%c%d", RPTP_OK, n); + connection_notify(0, NOTIFY_VOLUME, n); } else { - connection_reply (c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); + connection_reply(c, "%cerror=\"volume failed\" command=volume", RPTP_ERROR); } } @@ -1319,10 +1342,10 @@ #ifdef __STDC__ static int -command_info (CONNECTION *c, int argc, char **argv) -#else -static int -command_info (c, argc, argv) +command_info(CONNECTION *c, int argc, char **argv) +#else +static int +command_info(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -1331,22 +1354,22 @@ SOUND *s; char *sound_name = NULL; char *client_data = default_client_data; - + #ifdef AUTH - if (!host_access (c->sin, HOST_READ)) - { - report (REPORT_NOTICE, "%s info %s - read access denied\n", - inet_ntoa (c->sin.sin_addr), argv[1]); - connection_reply (c, "%cerror=\"access denied\" command=info client-data=\"%s\"", - RPTP_ERROR, client_data); + if (!host_access(c->sin, HOST_READ)) + { + report(REPORT_NOTICE, "%s info %s - read access denied\n", + inet_ntoa(c->sin.sin_addr), argv[1]); + connection_reply(c, "%cerror=\"access denied\" command=info client-data=\"%s\"", + RPTP_ERROR, client_data); return 0; } #endif /* AUTH */ - if (strchr (command_buffer, '=')) - { - sound_name = rptp_parse (command_buffer, "sound"); - client_data = rptp_parse (0, "client-data"); + if (strchr(command_buffer, '=')) + { + sound_name = rptp_parse(command_buffer, "sound"); + client_data = rptp_parse(0, "client-data"); if (!client_data) { client_data = default_client_data; @@ -1358,29 +1381,29 @@ } /* s = sound_lookup (sound_name, SOUND_CREATE, NULL); */ - s = sound_lookup (sound_name, SOUND_LOAD, NULL); + s = sound_lookup(sound_name, SOUND_LOAD, NULL); if (s == NULL || s->status != SOUND_READY) { - report (REPORT_NOTICE, "%s info %s - not found\n", - inet_ntoa (c->sin.sin_addr), sound_name); - connection_reply (c, "%cerror=\"%s not found\" command=info client-data=\"%s\"", - RPTP_ERROR, sound_name, client_data); + report(REPORT_NOTICE, "%s info %s - not found\n", + inet_ntoa(c->sin.sin_addr), sound_name); + connection_reply(c, "%cerror=\"%s not found\" command=info client-data=\"%s\"", + RPTP_ERROR, sound_name, client_data); } else { - connection_reply (c, "\ + connection_reply(c, "\ %csound=\"%s\" size=%d bits=%g sample-rate=%d channels=%d format=%s byte-order=%s input=%s seconds=%.2f command=info client-data=\"%s\"", - RPTP_OK, - s->name, - s->size, - s->input_precision, - s->sample_rate, - s->channels, - audio_format_to_string (s->format), - byte_order_to_string (s->byte_order), - input_to_string (s->type), - s->sample_rate && s->samples ? (double) s->samples / s->sample_rate : 0, - client_data); + RPTP_OK, + s->name, + s->size, + s->input_precision, + s->sample_rate, + s->channels, + audio_format_to_string(s->format), + byte_order_to_string(s->byte_order), + input_to_string(s->type), + s->sample_rate && s->samples ? (double) s->samples / s->sample_rate : 0, + client_data); } return 0; @@ -1388,35 +1411,35 @@ #ifdef __STDC__ static int -command_version (CONNECTION *c, int argc, char **argv) -#else -static int -command_version (c, argc, argv) +command_version(CONNECTION *c, int argc, char **argv) +#else +static int +command_version(c, argc, argv) CONNECTION *c; int argc; char **argv; #endif { char *client_data; - - client_data = rptp_parse (command_buffer, "client-data"); + + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; } - - connection_reply (c, "%cversion=%s command=version client-data=\"%s\"", - RPTP_OK, RPLAY_VERSION, client_data); + + connection_reply(c, "%cversion=%s command=version client-data=\"%s\"", + RPTP_OK, RPLAY_VERSION, client_data); return 0; } #ifdef __STDC__ static void -do_events (char *event_string, int *mask, int *spool_id) +do_events(char *event_string, int *mask, int *spool_id) #else static void -do_events (event_string, mask, spool_id) +do_events(event_string, mask, spool_id) char *event_string; int *mask; int *spool_id; @@ -1428,15 +1451,15 @@ int operator, bit; *spool_id = 0; - - strncpy (buf, event_string, sizeof(buf)); - - while (p = strtok (first ? buf : NULL, ",| ")) + + strncpy(buf, event_string, sizeof(buf)); + + while (p = strtok(first ? buf : NULL, ",| ")) { first = 0; bit = 0; operator = 0; - + if (*p == '+') { operator = 0; @@ -1447,75 +1470,75 @@ operator = 1; p++; } - - if (strcmp (p, "all") == 0 || strcmp (p, "any") == 0) + + if (strcmp(p, "all") == 0 || strcmp(p, "any") == 0) { bit = NOTIFY_ANY; } - else if (strcmp (p, "none") == 0) + else if (strcmp(p, "none") == 0) { *mask = 0; } - else if (strcmp (p, "play") == 0) + else if (strcmp(p, "play") == 0) { bit = NOTIFY_PLAY; } - else if (strcmp (p, "stop") == 0) + else if (strcmp(p, "stop") == 0) { bit = NOTIFY_STOP; } - else if (strcmp (p, "pause") == 0) + else if (strcmp(p, "pause") == 0) { bit = NOTIFY_PAUSE; } - else if (strcmp (p, "continue") == 0) + else if (strcmp(p, "continue") == 0) { bit = NOTIFY_CONTINUE; } - else if (strcmp (p, "volume") == 0) + else if (strcmp(p, "volume") == 0) { bit = NOTIFY_VOLUME; } - else if (strcmp (p, "done") == 0) + else if (strcmp(p, "done") == 0) { bit = NOTIFY_DONE; } - else if (strcmp (p, "skip") == 0) + else if (strcmp(p, "skip") == 0) { bit = NOTIFY_SKIP; } - else if (strcmp (p, "state") == 0) + else if (strcmp(p, "state") == 0) { bit = NOTIFY_STATE; } - else if (strcmp (p, "flow") == 0) + else if (strcmp(p, "flow") == 0) { bit = NOTIFY_FLOW; } else if (p[0] == '#') { - *spool_id = atoi (p+1); - } - else if (strcmp (p, "modify") == 0) + *spool_id = atoi(p + 1); + } + else if (strcmp(p, "modify") == 0) { bit = NOTIFY_MODIFY; } - else if (strcmp (p, "level") == 0) + else if (strcmp(p, "level") == 0) { bit = NOTIFY_LEVEL; } - else if (strcmp (p, "position") == 0) + else if (strcmp(p, "position") == 0) { bit = NOTIFY_POSITION; } - + if (operator == 0) { - SET_BIT (*mask, bit); + SET_BIT(*mask, bit); } else { - CLR_BIT (*mask, bit); + CLR_BIT(*mask, bit); } } @@ -1524,16 +1547,16 @@ spool entry. */ if (*spool_id && !*mask) { - SET_BIT (*mask, NOTIFY_SPOOL); - } -} - -#ifdef __STDC__ -static int -command_wait (CONNECTION *c, int argc, char **argv) -#else -static int -command_wait (c, argc, argv) + SET_BIT(*mask, NOTIFY_SPOOL); + } +} + +#ifdef __STDC__ +static int +command_wait(CONNECTION *c, int argc, char **argv) +#else +static int +command_wait(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -1541,61 +1564,61 @@ { EVENT *e; char *client_data; - - client_data = rptp_parse (command_buffer, "client-data"); + + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; } - + /* `wait' - wait for anything */ if (argc == 1) { - e = event_create (EVENT_NOTIFY); - SET_BIT (e->wait_mask, NOTIFY_ANY); - event_insert (c, e); + e = event_create(EVENT_NOTIFY); + SET_BIT(e->wait_mask, NOTIFY_ANY); + event_insert(c, e); return 0; } /* `wait id=#spool-id' or `wait event=event,event,event' */ - else if (argc == 2 && strchr (argv[1], '=')) + else if (argc == 2 && strchr(argv[1], '=')) { char *value; - value = rptp_parse (argv[1], "id"); + value = rptp_parse(argv[1], "id"); if (value && *value) { - e = event_create (EVENT_NOTIFY); - SET_BIT (e->wait_mask, NOTIFY_DONE); - e->id = atoi (value + 1); - event_insert (c, e); + e = event_create(EVENT_NOTIFY); + SET_BIT(e->wait_mask, NOTIFY_DONE); + e->id = atoi(value + 1); + event_insert(c, e); return 0; } - value = rptp_parse (argv[1], "event"); + value = rptp_parse(argv[1], "event"); if (value && *value) { - e = event_create (EVENT_NOTIFY); - do_events (value, &e->wait_mask, &e->id); - event_insert (c, e); + e = event_create(EVENT_NOTIFY); + do_events(value, &e->wait_mask, &e->id); + event_insert(c, e); return 0; } - connection_reply (c, "%cerror=\"unknown wait attribute `%s'\" command=wait client-data=\"%s\"", - RPTP_ERROR, argv[1], client_data); + connection_reply(c, "%cerror=\"unknown wait attribute `%s'\" command=wait client-data=\"%s\"", + RPTP_ERROR, argv[1], client_data); return 0; } /* `wait play ...' */ - else if (strcmp (argv[1], "play") == 0) + else if (strcmp(argv[1], "play") == 0) { int id; - id = do_execute (c, argc - 1, argv + 1); + id = do_execute(c, argc - 1, argv + 1); if (id > 0) { - e = event_create (EVENT_NOTIFY); - SET_BIT (e->wait_mask, NOTIFY_DONE); + e = event_create(EVENT_NOTIFY); + SET_BIT(e->wait_mask, NOTIFY_DONE); e->id = id; - event_insert (c, e); + event_insert(c, e); } return 0; @@ -1603,27 +1626,30 @@ else { /* XXX: Need to fix command_buffer */ - int i; + int i, n; command_buffer[0] = '\0'; + n = 0; for (i = 1; i < argc; i++) { - SNPRINTF (SIZE(command_buffer+strlen(command_buffer),sizeof(command_buffer)), argv[i]); + SNPRINTF(SIZE(command_buffer + n, sizeof(command_buffer) - n), argv[i]); + n += strlen(argv[i]); if (i + 1 != argc) { - SNPRINTF (SIZE(command_buffer+strlen(command_buffer),sizeof(command_buffer)), " "); - } - } - - return do_command (c, argc - 1, argv + 1); - } -} - -#ifdef __STDC__ -static int -command_status (CONNECTION *c, int argc, char **argv) -#else -static int -command_status (c, argc, argv) + SNPRINTF(SIZE(command_buffer + n, sizeof(command_buffer) - n), " "); + n++; + } + } + + return do_command(c, argc - 1, argv + 1); + } +} + +#ifdef __STDC__ +static int +command_status(CONNECTION *c, int argc, char **argv) +#else +static int +command_status(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -1631,8 +1657,8 @@ { EVENT *e; - e = event_create (EVENT_WRITE, rplayd_status ()); - event_insert (c, e); + e = event_create(EVENT_WRITE, rplayd_status()); + event_insert(c, e); return 0; } @@ -1640,36 +1666,39 @@ /* OBSOLETE */ #ifdef __STDC__ static int -command_application (CONNECTION *c, int argc, char **argv) -#else -static int -command_application (c, argc, argv) +command_application(CONNECTION *c, int argc, char **argv) +#else +static int +command_application(c, argc, argv) CONNECTION *c; int argc; char **argv; #endif { - int i; + int i, n; char buf[RPTP_MAX_LINE]; buf[0] = '\0'; + n = 0; for (i = 1; i < argc; i++) { - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), argv[i]); + SNPRINTF(SIZE(buf + n, sizeof(buf) - n), argv[i]); + n += strlen(argv[i]); if (i + 1 != argc) { - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), " "); + SNPRINTF(SIZE(buf + n, sizeof(buf) - n), " "); + n++; } } if (c->application) { - free (c->application); - } - - c->application = strdup (buf); - - connection_reply (c, "%c%s", RPTP_OK, c->application); + free(c->application); + } + + c->application = strdup(buf); + + connection_reply(c, "%c%s", RPTP_OK, c->application); return 0; } @@ -1677,65 +1706,65 @@ #ifdef DEBUG #ifdef __STDC__ static int -command_die (CONNECTION *c, int argc, char **argv) -#else -static int -command_die (c, argc, argv) +command_die(CONNECTION *c, int argc, char **argv) +#else +static int +command_die(c, argc, argv) CONNECTION *c; int argc; char **argv; #endif { - report (REPORT_DEBUG, "time to die...\n"); - connection_close (c); - done (0); + report(REPORT_DEBUG, "time to die...\n"); + connection_close(c); + done(0); return -1; /* not reached */ } #endif /* DEBUG */ #ifdef __STDC__ static int -command_reset (CONNECTION *c, int argc, char **argv) -#else -static int -command_reset (c, argc, argv) +command_reset(CONNECTION *c, int argc, char **argv) +#else +static int +command_reset(c, argc, argv) CONNECTION *c; int argc; char **argv; #endif { char *client_data; - - client_data = rptp_parse (command_buffer, "client-data"); + + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; } #ifdef AUTH - if (!host_access (c->sin, HOST_EXECUTE)) - { - report (REPORT_NOTICE, "%s reset access denied\n", inet_ntoa (c->sin.sin_addr)); - connection_reply (c, "%cerror=\"access denied\" command=reset client-data=\"%s\"", - RPTP_ERROR, client_data); + if (!host_access(c->sin, HOST_EXECUTE)) + { + report(REPORT_NOTICE, "%s reset access denied\n", inet_ntoa(c->sin.sin_addr)); + connection_reply(c, "%cerror=\"access denied\" command=reset client-data=\"%s\"", + RPTP_ERROR, client_data); return 0; } #endif /* AUTH */ - need_reset (); - - connection_reply (c, "%cmessage=\"reset successful\" command=reset client-data=\"%s\"", - RPTP_OK, client_data); + need_reset(); + + connection_reply(c, "%cmessage=\"reset successful\" command=reset client-data=\"%s\"", + RPTP_OK, client_data); return 0; } #ifdef __STDC__ static int -command_skip (CONNECTION *c, int argc, char **argv) -#else -static int -command_skip (c, argc, argv) +command_skip(CONNECTION *c, int argc, char **argv) +#else +static int +command_skip(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -1746,52 +1775,52 @@ int nskipped = 0; char *p; char *client_data; - - client_data = rptp_parse (command_buffer, "client-data"); + + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; } #ifdef AUTH - if (!host_access (c->sin, HOST_EXECUTE)) - { - report (REPORT_NOTICE, "%s skip access denied\n", inet_ntoa (c->sin.sin_addr)); - connection_reply (c, "%cerror=\"access denied\" command=skip client-data=\"%s\"", - RPTP_ERROR, client_data); + if (!host_access(c->sin, HOST_EXECUTE)) + { + report(REPORT_NOTICE, "%s skip access denied\n", inet_ntoa(c->sin.sin_addr)); + connection_reply(c, "%cerror=\"access denied\" command=skip client-data=\"%s\"", + RPTP_ERROR, client_data); return 0; } #endif /* AUTH */ - p = rptp_parse (0, "id"); + p = rptp_parse(0, "id"); if (p) { - id = atoi (p + 1); - } - p = rptp_parse (0, "count"); + id = atoi(p + 1); + } + p = rptp_parse(0, "count"); if (p) { - count = atoi (p); + count = atoi(p); } for (sp = spool; sp; sp = sp->next) { if (!id || sp->id == id) { - spool_skip (sp, count); + spool_skip(sp, count); nskipped++; } } if (nskipped) { - connection_reply (c, "%cmessage=\"skipped\" command=skip client-data=\"%s\"", - RPTP_OK, client_data); + connection_reply(c, "%cmessage=\"skipped\" command=skip client-data=\"%s\"", + RPTP_OK, client_data); } else { - connection_reply (c, "%cerror=\"skip failed\" command=skip client-data=\"%s\"", - RPTP_ERROR, client_data); + connection_reply(c, "%cerror=\"skip failed\" command=skip client-data=\"%s\"", + RPTP_ERROR, client_data); } return 0; @@ -1799,10 +1828,10 @@ #ifdef __STDC__ static int -command_set (CONNECTION *c, int argc, char **argv) -#else -static int -command_set (c, argc, argv) +command_set(CONNECTION *c, int argc, char **argv) +#else +static int +command_set(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -1819,108 +1848,120 @@ int notify_mask = 0; int notify_id = 0; char *client_data; - - client_data = rptp_parse (command_buffer, "client-data"); + char buf[RPTP_MAX_LINE]; + + client_data = rptp_parse(command_buffer, "client-data"); if (!client_data) { client_data = default_client_data; } #ifdef AUTH - if (!host_access (c->sin, HOST_EXECUTE)) - { - report (REPORT_NOTICE, "%s set access denied\n", inet_ntoa (c->sin.sin_addr)); - connection_reply (c, "%cerror=\"access denied\" command=set client-data=\"%s\"", - RPTP_ERROR, client_data); + if (!host_access(c->sin, HOST_EXECUTE)) + { + report(REPORT_NOTICE, "%s set access denied\n", inet_ntoa(c->sin.sin_addr)); + connection_reply(c, "%cerror=\"access denied\" command=set client-data=\"%s\"", + RPTP_ERROR, client_data); return 0; } #endif /* AUTH */ - b = buffer_create (); + b = buffer_create(); b->buf[0] = RPTP_OK; b->buf[1] = '\0'; - - rptp_parse (command_buffer, 0); - while (name = rptp_parse (0, 0)) - { - value = rptp_parse (0, name); - - if (strcmp (name, "application") == 0) /* `application=value' */ + b->nbytes = 1; + + rptp_parse(command_buffer, 0); + while (name = rptp_parse(0, 0)) + { + value = rptp_parse(0, name); + + if (strcmp(name, "application") == 0) /* `application=value' */ { if (value && *value) { if (c->application) { - free (c->application); + free(c->application); } - c->application = strdup (value); - } - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "application=\"%s\"", + c->application = strdup(value); + } + SNPRINTF(SIZE(buf, sizeof(buf)), "application=\"%s\"", c->application ? c->application : "-1"); - } - else if (strcmp (name, "notify") == 0) /* `notify=[event,...]' */ + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + else if (strcmp(name, "notify") == 0) /* `notify=[event,...]' */ { if (value) { - do_events (value, &c->notify_mask, &c->notify_id); - } - + do_events(value, &c->notify_mask, &c->notify_id); + } + if (!c->notify_mask) { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "notify=none"); + SNPRINTF(SIZE(buf, sizeof(buf)), "notify=none"); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); } else { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "notify=\"%s\"", value); + SNPRINTF(SIZE(buf, sizeof(buf)), "notify=\"%s\"", value); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); notify_enabled++; } } - else if (strcmp (name, "volume") == 0) /* `volume=[+|-]value' */ - { - int volume = rplay_audio_get_volume (); + else if (strcmp(name, "volume") == 0) /* `volume=[+|-]value' */ + { + int volume = rplay_audio_get_volume(); if (value && *value) { switch (value[0]) { case '+': - volume += atoi (value + 1); + volume += atoi(value + 1); break; case '-': - volume -= atoi (value + 1); + volume -= atoi(value + 1); break; case '*': - volume *= atoi (value + 1); + volume *= atoi(value + 1); break; case '/': - volume /= atoi (value + 1); + volume /= atoi(value + 1); break; default: - volume = atoi (value); + volume = atoi(value); } - volume = rplay_audio_set_volume (volume); + volume = rplay_audio_set_volume(volume); } if (volume >= 0) { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "volume=%d", volume); + SNPRINTF(SIZE(buf, sizeof(buf)), "volume=%d", volume); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); volume_changed++; } else { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "volume=-1"); - } - } - else if (strcmp (name, "priority-threshold") == 0) /* `priority-threshold=value' */ + SNPRINTF(SIZE(buf, sizeof(buf)), "volume=-1"); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + } + else if (strcmp(name, "priority-threshold") == 0) /* `priority-threshold=value' */ { if (value && *value) { - rplay_priority_threshold = atoi (value); + rplay_priority_threshold = atoi(value); if (rplay_priority_threshold < RPLAY_MIN_PRIORITY) { rplay_priority_threshold = RPLAY_MIN_PRIORITY; @@ -1932,77 +1973,85 @@ priority_threshold_changed++; } - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "priority-threshold=%d", + SNPRINTF(SIZE(buf, sizeof(buf)), "priority-threshold=%d", rplay_priority_threshold); - } - else if (strcmp (name, "notify-rate") == 0) /* `notify-rate=value' */ + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + else if (strcmp(name, "notify-rate") == 0) /* `notify-rate=value' */ { if (value && *value) { int i; double rate; - - rate = atof (value); - + + rate = atof(value); + for (i = 0; i < NOTIFY_RATE_MAX; i++) { c->notify_rate[i].rate = rate; c->notify_rate[i].next = 0.0; } } - - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "level-notify-rate=%.2f position-notify-rate=%.2f", + + SNPRINTF(SIZE(buf, sizeof(buf)), "level-notify-rate=%.2f position-notify-rate=%.2f", c->notify_rate[NOTIFY_RATE_LEVEL].rate, c->notify_rate[NOTIFY_RATE_POSITION].rate); - } - else if (strcmp (name, "level-notify-rate") == 0) + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + else if (strcmp(name, "level-notify-rate") == 0) { if (value && *value) { - c->notify_rate[NOTIFY_RATE_LEVEL].rate = atof (value); + c->notify_rate[NOTIFY_RATE_LEVEL].rate = atof(value); c->notify_rate[NOTIFY_RATE_LEVEL].next = 0.0; } - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "level-notify-rate=%.2f", + SNPRINTF(SIZE(buf, sizeof(buf)), "level-notify-rate=%.2f", c->notify_rate[NOTIFY_RATE_LEVEL].rate); - } - else if (strcmp (name, "position-notify-rate") == 0) + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + else if (strcmp(name, "position-notify-rate") == 0) { if (value && *value) { - c->notify_rate[NOTIFY_RATE_POSITION].rate = atof (value); + c->notify_rate[NOTIFY_RATE_POSITION].rate = atof(value); c->notify_rate[NOTIFY_RATE_POSITION].next = 0.0; } - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "position-notify-rate=%.2f", + SNPRINTF(SIZE(buf, sizeof(buf)), "position-notify-rate=%.2f", c->notify_rate[NOTIFY_RATE_POSITION].rate); - } - else if (strcmp (name, "audio-port") == 0) + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + else if (strcmp(name, "audio-port") == 0) { int n; - + optional_port = rplay_audio_port; - - if (strstr (value, "none")) + + if (strstr(value, "none")) { optional_port = 0; } - if (strstr (value, "speaker")) - { - SET_BIT (optional_port, RPLAY_AUDIO_PORT_SPEAKER); - } - if (strstr (value, "headphone")) - { - SET_BIT (optional_port, RPLAY_AUDIO_PORT_HEADPHONE); - } - if (strstr (value, "lineout")) - { - SET_BIT (optional_port, RPLAY_AUDIO_PORT_LINEOUT); + if (strstr(value, "speaker")) + { + SET_BIT(optional_port, RPLAY_AUDIO_PORT_SPEAKER); + } + if (strstr(value, "headphone")) + { + SET_BIT(optional_port, RPLAY_AUDIO_PORT_HEADPHONE); + } + if (strstr(value, "lineout")) + { + SET_BIT(optional_port, RPLAY_AUDIO_PORT_LINEOUT); } if (optional_port != rplay_audio_port) { - n = rplay_audio_init (); + n = rplay_audio_init(); if (n >= 0) { audio_port_changed++; @@ -2012,17 +2061,21 @@ { n = 0; } - + if (n < 0) { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "audio-port=-1"); + SNPRINTF(SIZE(buf, sizeof(buf)), "audio-port=-1"); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); } else { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "audio-port=%s", value); - } - } - else if (strcmp (name, "audio-info") == 0) + SNPRINTF(SIZE(buf, sizeof(buf)), "audio-port=%s", value); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + } + else if (strcmp(name, "audio-info") == 0) { char info[1024], *p; SPOOL *sp, *sp_next; @@ -2032,54 +2085,79 @@ for (sp = spool; sp; sp = sp_next) { sp_next = sp->next; - spool_stop (sp); - } - + spool_stop(sp); + } + /* Example: ulaw,8000,8,1 */ - strncpy (info, value, sizeof(info)); - p = strtok (info, ", "); - if (p) optional_format = string_to_audio_format (p); - p = strtok (NULL, ","); - if (p) optional_sample_rate = atoi (p); - p = strtok (NULL, ","); - if (p) optional_precision = atoi (p); - p = strtok (NULL, ","); - if (p) optional_channels = atoi (p); - -#ifndef HAVE_OSS - bufsize = rplay_audio_bufsize; /* XXX: force recalculation */ + strncpy(info, value, sizeof(info)); + p = strtok(info, ", "); + if (p) + optional_format = string_to_audio_format(p); + p = strtok(NULL, ","); + if (p) + optional_sample_rate = atoi(p); + p = strtok(NULL, ","); + if (p) + optional_precision = atoi(p); + p = strtok(NULL, ","); + if (p) + optional_channels = atoi(p); + +#ifndef HAVE_OSS + bufsize = rplay_audio_bufsize; /* XXX: force recalculation */ rplay_audio_bufsize = 0; -#endif /* !HAVE_OSS */ +#endif /* !HAVE_OSS */ rate = rplay_audio_rate; rplay_audio_rate = 0; - - if (rplayd_audio_init () < 0) - { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "audio-info=-1"); -#ifndef HAVE_OSS + + if (rplayd_audio_init() < 0) + { + SNPRINTF(SIZE(buf, sizeof(buf)), "audio-info=-1"); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); +#ifndef HAVE_OSS rplay_audio_bufsize = bufsize; -#endif /* !HAVE_OSS */ +#endif /* !HAVE_OSS */ rplay_audio_rate = rate; } else { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "audio-info=%s", value); + SNPRINTF(SIZE(buf, sizeof(buf)), "audio-info=%s", value); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + } + else if (strcmp(name, "audio-close") == 0) + { + if (value && *value) + { + extern int rplay_audio_timeout; + rplay_audio_timeout = atoi(value); + SNPRINTF(SIZE(buf, sizeof(buf)), "audio-close=%d", rplay_audio_timeout); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); } } else { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "%s=-1", name); - } - - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " "); - } - - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "command=set client-data=\"%s\"\r\n", client_data); - b->nbytes = strlen (b->buf); - - e = event_create (EVENT_WRITE, b); - event_insert (c, e); + SNPRINTF(SIZE(buf, sizeof(buf)), "%s=-1", name); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + + SNPRINTF(SIZE(buf, sizeof(buf)), " "); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + } + + SNPRINTF(SIZE(buf, sizeof(buf)), "command=set client-data=\"%s\"\r\n", + client_data); + strncat(b->buf + b->nbytes, buf, BUFFER_SIZE - b->nbytes); + b->nbytes += strlen(buf); + + e = event_create(EVENT_WRITE, b); + event_insert(c, e); if (notify_enabled) { @@ -2089,33 +2167,35 @@ switch (sp->state) { case SPOOL_PLAY: - connection_notify (c, NOTIFY_PLAY, sp); + connection_notify(c, NOTIFY_PLAY, sp); break; case SPOOL_PAUSE: - connection_notify (c, NOTIFY_PAUSE, sp); + connection_notify(c, NOTIFY_PAUSE, sp); break; } } - connection_notify (c, NOTIFY_VOLUME, rplay_audio_volume); - - e = event_create (EVENT_NOTIFY); - event_insert (c, e); - } + connection_notify(c, NOTIFY_VOLUME, rplay_audio_volume); + + e = event_create(EVENT_NOTIFY); + event_insert(c, e); + } + if (volume_changed) { - connection_notify (0, NOTIFY_VOLUME, rplay_audio_volume); - } + connection_notify(0, NOTIFY_VOLUME, rplay_audio_volume); + } + if (priority_threshold_changed || audio_port_changed) { - connection_notify (0, NOTIFY_STATE); + connection_notify(0, NOTIFY_STATE); } connection_want_level_notify = 0; for (c = connections; c; c = c->next) { - if (BIT (c->notify_mask, NOTIFY_LEVEL) - || (c->event && BIT (c->event->wait_mask, NOTIFY_LEVEL))) + if (BIT(c->notify_mask, NOTIFY_LEVEL) + || (c->event && BIT(c->event->wait_mask, NOTIFY_LEVEL))) { connection_want_level_notify++; } @@ -2126,10 +2206,10 @@ #ifdef __STDC__ static int -command_modify (CONNECTION *c, int argc, char **argv) -#else -static int -command_modify (c, argc, argv) +command_modify(CONNECTION *c, int argc, char **argv) +#else +static int +command_modify(c, argc, argv) CONNECTION *c; int argc; char **argv; @@ -2145,112 +2225,156 @@ int new_list_count = -1; char *new_client_data = NULL; int modified, total_modified = 0; + +#ifdef AUTH + if (!host_access(c->sin, HOST_EXECUTE)) + { + report(REPORT_NOTICE, "%s modify access denied\n", inet_ntoa(c->sin.sin_addr)); + connection_reply(c, "%cerror=\"access denied\" command=modify", RPTP_ERROR); + return 0; + } +#endif /* AUTH */ + + p = rptp_parse(command_buffer, "id"); + if (!p || !*p) + { + connection_reply(c, "%cerror=\"missing `id'\" command=modify", RPTP_ERROR); + return 0; + } + id = atoi(p + 1); + + p = rptp_parse(0, "count"); + if (p) + { + new_count = atoi(p); + } + + p = rptp_parse(0, "list-count"); + if (p) + { + new_list_count = atoi(p); + } + + p = rptp_parse(0, "priority"); + if (p) + { + new_priority = atoi(p); + } + + p = rptp_parse(0, "sample-rate"); + if (p) + { + new_sample_rate = atoi(p); + } + + p = rptp_parse(0, "volume"); + if (p) + { + new_volume = atoi(p); + } + + p = rptp_parse(0, "client-data"); + if (p) + { + new_client_data = p; + } + + for (sp = spool; sp; sp = sp->next) + { + if (!id || sp->id == id) + { + modified = 0; + if (new_count != -1) + { + spool_set_count(sp, new_count); + modified++; + } + if (new_list_count != -1) + { + spool_set_list_count(sp, new_list_count); + modified++; + } + if (new_priority != -1) + { + spool_set_priority(sp, new_priority); + modified++; + } + if (new_sample_rate != -1) + { + spool_set_sample_rate(sp, new_sample_rate); + modified++; + } + if (new_volume != -1) + { + spool_set_volume(sp, new_volume); + modified++; + } + if (new_client_data) + { + spool_set_client_data(sp, new_client_data); + modified++; + } + + if (modified) + { + connection_notify(c, NOTIFY_MODIFY, sp); + total_modified++; + } + } + } + + if (total_modified) + { + connection_reply(c, "%cmessage=\"modified\" command=modify", RPTP_OK); + } + else + { + connection_reply(c, "%cerror=\"nothing modified\" command=modify", RPTP_ERROR); + } + + return 0; +} + +#ifdef __STDC__ +static int +command_monitor(CONNECTION *c, int argc, char **argv) +#else +static int +command_monitor(c, argc, argv) + CONNECTION *c; + int argc; + char **argv; +#endif +{ + EVENT *e; #ifdef AUTH - if (!host_access (c->sin, HOST_EXECUTE)) - { - report (REPORT_NOTICE, "%s modify access denied\n", inet_ntoa (c->sin.sin_addr)); - connection_reply (c, "%cerror=\"access denied\" command=modify", RPTP_ERROR); + if (!host_access(c->sin, HOST_MONITOR)) + { + report(REPORT_NOTICE, "%s monitor - monitor access denied\n", + inet_ntoa(c->sin.sin_addr)); + connection_reply(c, "%cerror=\"access denied\" command=monitor", + RPTP_ERROR); return 0; } #endif /* AUTH */ - p = rptp_parse (command_buffer, "id"); - if (!p || !*p) - { - connection_reply (c, "%cerror=\"missing `id'\" command=modify", RPTP_ERROR); - return 0; - } - id = atoi (p + 1); - - p = rptp_parse (0, "count"); - if (p) - { - new_count = atoi (p); - } - - p = rptp_parse (0, "list-count"); - if (p) - { - new_list_count = atoi (p); - } - - p = rptp_parse (0, "priority"); - if (p) - { - new_priority = atoi (p); - } - - p = rptp_parse (0, "sample-rate"); - if (p) - { - new_sample_rate = atoi (p); - } - - p = rptp_parse (0, "volume"); - if (p) - { - new_volume = atoi (p); - } - - p = rptp_parse (0, "client-data"); - if (p) - { - new_client_data = p; - } - - for (sp = spool; sp; sp = sp->next) - { - if (!id || sp->id == id) - { - modified = 0; - if (new_count != -1) - { - spool_set_count (sp, new_count); - modified++; - } - if (new_list_count != -1) - { - spool_set_list_count (sp, new_list_count); - modified++; - } - if (new_priority != -1) - { - spool_set_priority (sp, new_priority); - modified++; - } - if (new_sample_rate != -1) - { - spool_set_sample_rate (sp, new_sample_rate); - modified++; - } - if (new_volume != -1) - { - spool_set_volume (sp, new_volume); - modified++; - } - if (new_client_data) - { - spool_set_client_data (sp, new_client_data); - modified++; - } - - if (modified) - { - connection_notify (c, NOTIFY_MODIFY, sp); - total_modified++; - } - } - } - - if (total_modified) - { - connection_reply (c, "%cmessage=\"modified\" command=modify", RPTP_OK); - } - else - { - connection_reply (c, "%cerror=\"nothing modified\" command=modify", RPTP_ERROR); - } + if (monitor_count == 0) + { + monitor_alloc(); + } + monitor_count++; + + connection_reply(c, "%caudio-info=\"%s,%d,%d,%d,%s\"", RPTP_OK, + audio_format_to_string(rplay_audio_format), + rplay_audio_sample_rate, + rplay_audio_precision, + rplay_audio_channels, + byte_order_to_string(RPLAY_AUDIO_BYTE_ORDER)); + e = event_create(EVENT_WAIT_MONITOR); + event_insert(c, e); + + c->monitor = 1; return 0; } diff --git a/rplayd/command.h b/rplayd/command.h index d679157..7c7da8b 100644 --- a/rplayd/command.h +++ b/rplayd/command.h @@ -1,7 +1,7 @@ -/* $Id: command.h,v 1.2 1998/08/13 06:13:47 boyns Exp $ */ +/* $Id: command.h,v 1.3 1999/03/10 07:58:02 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/connection.c b/rplayd/connection.c index 18ba17a..5a2771b 100644 --- a/rplayd/connection.c +++ b/rplayd/connection.c @@ -1,7 +1,7 @@ -/* $Id: connection.c,v 1.3 1998/10/12 16:03:20 boyns Exp $ */ +/* $Id: connection.c,v 1.6 1999/03/10 07:58:03 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,6 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifdef HAVE_CONFIG_H #include "config.h" @@ -59,7 +57,7 @@ #undef EVENT_DEBUG #ifdef EVENT_DEBUG -static void event_print (CONNECTION *c, char *message); +static void event_print(CONNECTION *c, char *message); #endif /* @@ -68,28 +66,28 @@ */ #ifdef __STDC__ CONNECTION * -connection_create (int type) +connection_create(int type) #else CONNECTION * -connection_create (type) +connection_create(type) int type; #endif { CONNECTION *c; int i; - - c = (CONNECTION *) malloc (sizeof (CONNECTION)); + + c = (CONNECTION *) malloc(sizeof(CONNECTION)); if (c == NULL) { - report (REPORT_ERROR, "connection_create: out of memory\n"); - done (1); + report(REPORT_ERROR, "connection_create: out of memory\n"); + done(1); } c->type = type; c->fd = -1; c->event = NULL; c->ep = &c->event; c->server = NULL; - c->time = time (0); + c->time = time(0); c->application = NULL; c->notify_mask = 0; c->notify_id = 0; @@ -98,6 +96,7 @@ c->notify_rate[i].rate = 0.0; c->notify_rate[i].next = 0.0; } + c->monitor = 0; /* * insert new connection into the connection list @@ -123,10 +122,10 @@ */ #ifdef __STDC__ void -connection_destroy (CONNECTION *c) -#else -void -connection_destroy (c) +connection_destroy(CONNECTION *c) +#else +void +connection_destroy(c) CONNECTION *c; #endif { @@ -148,15 +147,15 @@ } if (c->application) { - free (c->application); - } - free ((char *) c); + free(c->application); + } + free((char *) c); connection_want_level_notify = 0; for (c = connections; c; c = c->next) { - if (BIT (c->notify_mask, NOTIFY_LEVEL) - || (c->event && BIT (c->event->wait_mask, NOTIFY_LEVEL))) + if (BIT(c->notify_mask, NOTIFY_LEVEL) + || (c->event && BIT(c->event->wait_mask, NOTIFY_LEVEL))) { connection_want_level_notify++; } @@ -171,10 +170,10 @@ */ #ifdef __STDC__ CONNECTION * -connection_server_open (SERVER *server, SOUND *sound) +connection_server_open(SERVER *server, SOUND *sound) #else CONNECTION * -connection_server_open (server, sound) +connection_server_open(server, sound) SERVER *server; SOUND *sound; #endif @@ -195,33 +194,33 @@ } if (c == NULL) { - c = connection_create (CONNECTION_SERVER); + c = connection_create(CONNECTION_SERVER); c->server = server; c->sin = server->sin; } if (c->fd == -1) { - c->fd = socket (AF_INET, SOCK_STREAM, 0); + c->fd = socket(AF_INET, SOCK_STREAM, 0); if (c->fd < 0) { - report (REPORT_ERROR, "connection_open_server: socket: %s\n", sys_err_str (errno)); - done (1); - } - fd_nonblock (c->fd); + report(REPORT_ERROR, "connection_open_server: socket: %s\n", sys_err_str(errno)); + done(1); + } + fd_nonblock(c->fd); /* * ping the server */ - connection_server_ping (c); + connection_server_ping(c); /* * try to connect to the server immediately */ - report (REPORT_DEBUG, "%s server connection attempt\n", inet_ntoa (c->server->sin.sin_addr)); - n = connect (c->fd, (struct sockaddr *) &c->server->sin, sizeof (c->server->sin)); - e = event_create (EVENT_CONNECT); - e->time = time (0); - event_insert (c, e); + report(REPORT_DEBUG, "%s server connection attempt\n", inet_ntoa(c->server->sin.sin_addr)); + n = connect(c->fd, (struct sockaddr *) &c->server->sin, sizeof(c->server->sin)); + e = event_create(EVENT_CONNECT); + e->time = time(0); + event_insert(c, e); } /* @@ -231,11 +230,11 @@ { BUFFER *b; - b = buffer_create (); - SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "find %s\r\n", sound->name); - b->nbytes = strlen (b->buf); - e = event_create (EVENT_WRITE_FIND, b, sound); - event_insert (c, e); + b = buffer_create(); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", sound->name); + b->nbytes = strlen(b->buf); + e = event_create(EVENT_WRITE_FIND, b, sound); + event_insert(c, e); } return c; @@ -243,29 +242,29 @@ #ifdef __STDC__ void -connection_server_reopen (CONNECTION *c) -#else -void -connection_server_reopen (c) +connection_server_reopen(CONNECTION *c) +#else +void +connection_server_reopen(c) CONNECTION *c; #endif { EVENT *e; CONNECTION *server; - close (c->fd); + close(c->fd); c->fd = -1; e = c->event; c->event = NULL; c->ep = &c->event; - server = connection_server_open (c->server, NULL); + server = connection_server_open(c->server, NULL); if (server != c) { - report (REPORT_ERROR, "connection_server_reopen: server != c\n"); - done (1); - } - event_insert (server, e); + report(REPORT_ERROR, "connection_server_reopen: server != c\n"); + done(1); + } + event_insert(server, e); } /* @@ -273,18 +272,18 @@ */ #ifdef __STDC__ void -connection_server_ping (CONNECTION *c) -#else -void -connection_server_ping (c) +connection_server_ping(CONNECTION *c) +#else +void +connection_server_ping(c) CONNECTION *c; #endif { struct sockaddr_in ping_addr; - memcpy ((char *) &ping_addr, (char *) &c->server->sin, sizeof (ping_addr)); - ping_addr.sin_port = htons (RPLAY_PORT); - rplay_ping_sockaddr_in (&ping_addr); + memcpy((char *) &ping_addr, (char *) &c->server->sin, sizeof(ping_addr)); + ping_addr.sin_port = htons(RPLAY_PORT); + rplay_ping_sockaddr_in(&ping_addr); } /* @@ -292,41 +291,41 @@ */ #ifdef __STDC__ void -connection_client_open (int sock_fd) -#else -void -connection_client_open (sock_fd) +connection_client_open(int sock_fd) +#else +void +connection_client_open(sock_fd) int sock_fd; #endif { struct sockaddr_in f; - int fd, flen = sizeof (f); + int fd, flen = sizeof(f); CONNECTION *c; EVENT *e; char line[RPTP_MAX_LINE]; - fd = accept (sock_fd, (struct sockaddr *) &f, &flen); + fd = accept(sock_fd, (struct sockaddr *) &f, &flen); if (fd < 0) { - report (REPORT_ERROR, "accept: %s\n", sys_err_str (errno)); + report(REPORT_ERROR, "accept: %s\n", sys_err_str(errno)); return; } #ifdef DEBUG - report (REPORT_DEBUG, "%s client connection request\n", inet_ntoa (f.sin_addr)); + report(REPORT_DEBUG, "%s client connection request\n", inet_ntoa(f.sin_addr)); #endif #ifdef AUTH /* * see if this host has any access */ - if (!host_access (f, HOST_READ) && !host_access (f, HOST_WRITE) - && !host_access (f, HOST_WRITE)) - { - report (REPORT_NOTICE, "%s RPTP access denied\n", inet_ntoa (f.sin_addr)); - SNPRINTF (SIZE(line,sizeof(line)), "%cerror=\"connection refused\"\r\n", RPTP_ERROR); - write (fd, line, strlen (line)); - close (fd); + if (!host_access(f, HOST_READ) && !host_access(f, HOST_WRITE) + && !host_access(f, HOST_WRITE)) + { + report(REPORT_NOTICE, "%s RPTP access denied\n", inet_ntoa(f.sin_addr)); + SNPRINTF(SIZE(line, sizeof(line)), "%cerror=\"connection refused\"\r\n", RPTP_ERROR); + write(fd, line, strlen(line)); + close(fd); return; } #endif /* AUTH */ @@ -336,24 +335,24 @@ */ if (nconnections + 1 == RPTP_MAX_CONNECTIONS) { - SNPRINTF (SIZE(line,sizeof(line)), "%cerror=\"connection refused\"\r\n", RPTP_ERROR); - write (fd, line, strlen (line)); - close (fd); + SNPRINTF(SIZE(line, sizeof(line)), "%cerror=\"connection refused\"\r\n", RPTP_ERROR); + write(fd, line, strlen(line)); + close(fd); return; } - c = connection_create (CONNECTION_CLIENT); + c = connection_create(CONNECTION_CLIENT); c->fd = fd; - fd_nonblock (c->fd); + fd_nonblock(c->fd); c->sin = f; #if 1 - report (REPORT_NOTICE, "%s client connection established\n", inet_ntoa (c->sin.sin_addr)); + report(REPORT_NOTICE, "%s client connection established\n", inet_ntoa(c->sin.sin_addr)); #endif /* Greet the connection with the server's status. */ - e = event_create (EVENT_WRITE, rplayd_status ()); - event_insert (c, e); + e = event_create(EVENT_WRITE, rplayd_status()); + event_insert(c, e); } /* @@ -364,15 +363,15 @@ */ #ifdef __STDC__ void -connection_update (fd_set * read_fds, fd_set * write_fds) -#else -void -connection_update (read_fds, write_fds) +connection_update(fd_set * read_fds, fd_set * write_fds) +#else +void +connection_update(read_fds, write_fds) fd_set *read_fds; fd_set *write_fds; #endif { - int i, n; + int i, n, size; CONNECTION *c; struct timeval tv; fd_set rfds, wfds; @@ -382,7 +381,7 @@ SOUND *s; SPOOL *sp; fd_set cmask; - + if (read_fds == NULL && write_fds == NULL) { int nfds; @@ -391,11 +390,11 @@ tv.tv_usec = 0; rfds = read_mask; wfds = write_mask; - FD_CLR (rplay_fd, &rfds); + FD_CLR(rplay_fd, &rfds); #ifdef __hpux - nfds = select (FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0, &tv); -#else - nfds = select (FD_SETSIZE, &rfds, &wfds, 0, &tv); + nfds = select(FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0, &tv); +#else + nfds = select(FD_SETSIZE, &rfds, &wfds, 0, &tv); #endif if (nfds == 0) { @@ -404,9 +403,9 @@ } else if (nfds < 0) { - report (REPORT_ERROR, "connection_update: select: %s\n", - sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "connection_update: select: %s\n", + sys_err_str(errno)); + done(1); } } else @@ -418,18 +417,18 @@ /* * Check for new RPTP connections. */ - if (FD_ISSET (rptp_fd, &rfds)) - { - connection_client_open (rptp_fd); + if (FD_ISSET(rptp_fd, &rfds)) + { + connection_client_open(rptp_fd); } #ifdef OTHER_RPLAY_PORTS - if (FD_ISSET (other_rptp_fd, &rfds)) - { - connection_client_open (other_rptp_fd); - } -#endif - - t = time (0); + if (FD_ISSET(other_rptp_fd, &rfds)) + { + connection_client_open(other_rptp_fd); + } +#endif + + t = time(0); /* It's not safe to simply traverse the connection list since connections can be closed during this loop. @@ -450,7 +449,7 @@ break; } FD_SET(c->fd, &cmask); - + /* connection has no events */ if (c->event == NULL) { @@ -460,7 +459,7 @@ /* * read events */ - if (FD_ISSET (c->fd, &rfds)) + if (FD_ISSET(c->fd, &rfds)) { c->time = t; @@ -468,28 +467,28 @@ { case EVENT_READ_SOUND: restart: - n = read (c->fd, c->event->buffer->buf, - MIN (c->event->nleft, sizeof (c->event->buffer->buf))); + n = read(c->fd, c->event->buffer->buf, + MIN(c->event->nleft, sizeof(c->event->buffer->buf))); if (n < 0 && (errno == EINTR || errno == EAGAIN)) { goto restart; } #ifdef DEBUG - report (REPORT_DEBUG, "- %s read %d (%d)\n", - inet_ntoa (c->sin.sin_addr), - n, c->event->nleft); + report(REPORT_DEBUG, "- %s read %d (%d)\n", + inet_ntoa(c->sin.sin_addr), + n, c->event->nleft); #endif if (n <= 0) { - event_update (c); + event_update(c); } else { int r; restart1: - r = write (c->event->fd, c->event->buffer->buf, n); + r = write(c->event->fd, c->event->buffer->buf, n); if (r < 0 && (errno == EINTR || errno == EAGAIN)) { goto restart1; @@ -499,49 +498,49 @@ if (c->event->nleft == 0) { c->event->success++; - event_update (c); + event_update(c); } } break; case EVENT_READ_FLOW: /* Find the spool entry. */ - sp = spool_find (c->event->id); + sp = spool_find(c->event->id); if (!sp) { - if (c->event->nbytes == -1) /* single-put flow */ + if (c->event->nbytes == -1) /* single-put flow */ { - event_update (c); + event_update(c); break; } - + /* The spool entry no longer exists. The rest of this flow must be read -- the next `put' will fail. */ - c->event->buffer = buffer_create (); + c->event->buffer = buffer_create(); retry: - n = read (c->fd, c->event->buffer->buf, - MIN (BUFFER_SIZE, c->event->nleft)); + n = read(c->fd, c->event->buffer->buf, + MIN(BUFFER_SIZE, c->event->nleft)); if (n < 0 && (errno == EINTR || errno == EAGAIN)) { goto retry; } #if 0 - report (REPORT_DEBUG, "eating %d flow bytes (%d), id=#%d\n", - n, c->event->nleft, c->event->id); -#endif - buffer_destroy (c->event->buffer); /* Eat the flow. */ + report(REPORT_DEBUG, "eating %d flow bytes (%d), id=#%d\n", + n, c->event->nleft, c->event->id); +#endif + buffer_destroy(c->event->buffer); /* Eat the flow. */ c->event->buffer = NULL; if (n <= 0) { - event_update (c); + event_update(c); break; } c->event->nleft -= n; if (c->event->nleft <= 0) { c->event->success++; - event_update (c); + event_update(c); break; } break; @@ -549,47 +548,52 @@ /* Pause the connection if the high_water_mark has been exceeded. */ if (sp->si - && ((sp->si->water_mark - sp->si->offset) > sp->si->high_water_mark)) - { - connection_notify (0, NOTIFY_FLOW, sp); - connection_flow_pause (sp); + && ((sp->si->water_mark - sp->si->offset) >= sp->si->high_water_mark)) + { + connection_notify(0, NOTIFY_FLOW, sp); + connection_flow_pause(sp); break; } /* Read data from the flow. single-put flows will always try to read BUFFER_SIZE. */ - c->event->buffer = buffer_create (); - redo: - n = read (c->fd, c->event->buffer->buf, - MIN (BUFFER_SIZE, - c->event->nbytes == -1 ? BUFFER_SIZE : c->event->nleft)); + c->event->buffer = buffer_create(); + + /* calculate the number of bytes to read without + going over the high_water_mark. */ +#if 1 + size = MIN(BUFFER_SIZE, + sp->si ? sp->si->high_water_mark - (sp->si->water_mark - sp->si->offset) + : BUFFER_SIZE); +#else + size = MIN(BUFFER_SIZE, c->event->nbytes == -1 ? BUFFER_SIZE : c->event->nleft); +#endif + redo: + n = read(c->fd, c->event->buffer->buf, size); if (n < 0 && (errno == EINTR || errno == EAGAIN)) { goto redo; } -#if 0 - report (REPORT_DEBUG, "- %s flow-read %d\n", inet_ntoa (c->sin.sin_addr), n); -#endif if (n <= 0) { /* End of a single-put flow */ if (c->event->nbytes == -1) { - spool_done (sp); - connection_close (c); + spool_done(sp); + connection_close(c); } else { - event_update (c); + event_update(c); } break; } /* Add the buffer to the sound's flow. */ c->event->buffer->nbytes = n; - if (spool_flow_insert (sp, c->event->buffer) < 0) - { - c->event->buffer = NULL; /* efence */ + if (spool_flow_insert(sp, c->event->buffer) < 0) + { + c->event->buffer = NULL; /* efence */ break; } c->event->buffer = NULL; @@ -603,32 +607,32 @@ if (c->event->nbytes != -1 && c->event->nleft <= 0) { c->event->success++; - event_update (c); + event_update(c); } break; case EVENT_NOTIFY: /* Replace the current notify event with a read_command. */ - e = event_create (EVENT_READ_COMMAND, buffer_create ()); - event_replace (c, e); + e = event_create(EVENT_READ_COMMAND, buffer_create()); + event_replace(c, e); /* fall fall fall */ default: /* Read a command. */ restart2: - n = recv (c->fd, c->event->ptr, c->event->nleft, MSG_PEEK); + n = recv(c->fd, c->event->ptr, c->event->nleft, MSG_PEEK); if (n < 0 && (errno == EINTR || errno == EAGAIN)) { goto restart2; } #if 0 - report (REPORT_DEBUG, "- %s recv %d (%d)\n", - inet_ntoa (c->sin.sin_addr), - n, c->event->nleft); + report(REPORT_DEBUG, "- %s recv %d (%d)\n", + inet_ntoa(c->sin.sin_addr), + n, c->event->nleft); #endif if (n <= 0) { - event_update (c); + event_update(c); } else { @@ -649,7 +653,7 @@ } } restart3: - n = read (c->fd, buf, i == n ? n : i + 1); + n = read(c->fd, buf, i == n ? n : i + 1); if (n < 0 && (errno == EINTR || errno == EAGAIN)) { goto restart3; @@ -657,16 +661,16 @@ if (n <= 0) { c->event->success = 0; - event_update (c); + event_update(c); } else { c->event->ptr += n; c->event->nleft -= n; - if (c->event->success || c->event->nleft == 0) - { - event_update (c); - } + if (c->event->success || c->event->nleft == 0) + { + event_update(c); + } } } break; @@ -675,23 +679,23 @@ /* * write events */ - else if (FD_ISSET (c->fd, &wfds)) + else if (FD_ISSET(c->fd, &wfds)) { c->time = t; switch (c->event->type) { case EVENT_CONNECT: - event_update (c); + event_update(c); break; default: - again: - n = write (c->fd, c->event->ptr, c->event->nleft); -#ifdef DEBUG - report (REPORT_DEBUG, "- %s write %d (%d)\n", - inet_ntoa (c->sin.sin_addr), n, - c->event->nleft); + again: + n = write(c->fd, c->event->ptr, c->event->nleft); +#if 0 + report(REPORT_DEBUG, "- %s write %d (%d)\n", + inet_ntoa(c->sin.sin_addr), n, + c->event->nleft); #endif if (n <= 0) { @@ -699,7 +703,7 @@ { goto again; } - event_update (c); + event_update(c); } else { @@ -710,7 +714,7 @@ { if (c->event->type == EVENT_WRITE_SOUND) { - n = sound_fill (c->event->si, c->event->buffer, 1); + n = sound_fill(c->event->si, c->event->buffer, 1); if (n > 0) { c->event->nleft = c->event->buffer->nbytes; @@ -719,16 +723,16 @@ } else { - sound_close (c->event->si); - c->event->si = NULL; /* efence */ + sound_close(c->event->si); + c->event->si = NULL; /* efence */ c->event->success++; - event_update (c); + event_update(c); } } else { c->event->success++; - event_update (c); + event_update(c); } } } @@ -743,10 +747,10 @@ */ #ifdef __STDC__ void -connection_close (CONNECTION *c) -#else -void -connection_close (c) +connection_close(CONNECTION *c) +#else +void +connection_close(c) CONNECTION *c; #endif { @@ -757,18 +761,23 @@ switch (c->type) { case CONNECTION_CLIENT: - report (REPORT_NOTICE, "%s client connection closed\n", inet_ntoa (c->sin.sin_addr)); + report(REPORT_NOTICE, "%s client connection closed\n", inet_ntoa(c->sin.sin_addr)); break; case CONNECTION_SERVER: - report (REPORT_NOTICE, "%s server connection closed\n", inet_ntoa (c->sin.sin_addr)); - break; - } - - FD_CLR (c->fd, &read_mask); - FD_CLR (c->fd, &write_mask); - - close (c->fd); + report(REPORT_NOTICE, "%s server connection closed\n", inet_ntoa(c->sin.sin_addr)); + break; + } + + FD_CLR(c->fd, &read_mask); + FD_CLR(c->fd, &write_mask); + + if (c->monitor) + { + monitor_count--; + } + + close(c->fd); /* * destroy any events that are left @@ -783,8 +792,8 @@ case EVENT_WRITE_GET: case EVENT_READ_GET_REPLY: case EVENT_READ_SOUND: - spool_remove (e->sound); - sound_delete (e->sound, 1); + spool_remove(e->sound); + sound_delete(e->sound, 1); break; case EVENT_READ_FLOW: @@ -792,20 +801,20 @@ case EVENT_PIPE_FLOW: /* Dunno if this should happen: */ #if 0 - sp = spool_find (e->id); + sp = spool_find(e->id); s = sp->sound[sp->curr_sound]; - spool_remove (s); - sound_delete (s, 0); + spool_remove(s); + sound_delete(s, 0); #endif break; } - event_destroy (e); + event_destroy(e); } c->event = NULL; c->ep = &c->event; - connection_destroy (c); + connection_destroy(c); } /* @@ -813,15 +822,15 @@ */ #ifdef __STDC__ void -connection_update_fdset (CONNECTION *c) -#else -void -connection_update_fdset (c) +connection_update_fdset(CONNECTION *c) +#else +void +connection_update_fdset(c) CONNECTION *c; #endif { - FD_CLR (c->fd, &read_mask); - FD_CLR (c->fd, &write_mask); + FD_CLR(c->fd, &read_mask); + FD_CLR(c->fd, &write_mask); if (c->event == NULL) { @@ -837,7 +846,8 @@ case EVENT_READ_GET_REPLY: case EVENT_NOTIFY: case EVENT_READ_FLOW: - FD_SET (c->fd, &read_mask); + case EVENT_WAIT_MONITOR: + FD_SET(c->fd, &read_mask); break; case EVENT_WRITE: @@ -846,7 +856,8 @@ case EVENT_WRITE_GET: case EVENT_CONNECT: case EVENT_WRITE_TIMEOUT: - FD_SET (c->fd, &write_mask); + case EVENT_WRITE_MONITOR: + FD_SET(c->fd, &write_mask); break; case EVENT_WAIT_FLOW: @@ -855,8 +866,8 @@ break; default: - report (REPORT_ERROR, "connection_update_fdset: unknown event type '%d'\n", c->event->type); - done (1); + report(REPORT_ERROR, "connection_update_fdset: unknown event type '%d'\n", c->event->type); + done(1); } } @@ -865,10 +876,10 @@ */ #ifdef __STDC__ void -connection_reply (CONNECTION *c, char *fmt,...) -#else -void -connection_reply (va_alist) +connection_reply(CONNECTION *c, char *fmt,...) +#else +void +connection_reply(va_alist) va_dcl #endif { @@ -877,38 +888,39 @@ BUFFER *b; #ifdef __STDC__ - va_start (args, fmt); + va_start(args, fmt); #else CONNECTION *c; char *fmt; - va_start (args); - c = va_arg (args, CONNECTION *); - fmt = va_arg (args, char *); -#endif - - b = buffer_create (); - - VSNPRINTF (SIZE(b->buf,BUFFER_SIZE), fmt, args); - va_end (args); - SNPRINTF (SIZE(b->buf+strlen(b->buf),BUFFER_SIZE), "\r\n"); - b->nbytes += strlen (b->buf); - - e = event_create (EVENT_WRITE, b); - event_first (c, e); + va_start(args); + c = va_arg(args, CONNECTION *); + fmt = va_arg(args, char *); +#endif + + b = buffer_create(); + + VSNPRINTF(SIZE(b->buf, BUFFER_SIZE), fmt, args); + va_end(args); + b->nbytes = strlen(b->buf); + SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), "\r\n"); + b->nbytes += 2; + + e = event_create(EVENT_WRITE, b); + event_first(c, e); } /* * close all connections */ void -connection_cleanup () +connection_cleanup() { CONNECTION *c, *c_next; for (c = connections; c; c = c_next) { c_next = c->next; - connection_close (c); + connection_close(c); } } @@ -916,14 +928,15 @@ * Check all connections to see if rplayd can enter idle mode. */ int -connection_idle () +connection_idle() { CONNECTION *c; int idle = 1; for (c = connections; c && idle; c = c->next) { - if (c->event && c->event->type != EVENT_NOTIFY) + if (c->event && c->event->type != EVENT_NOTIFY + && !c->monitor) { idle = 0; } @@ -936,7 +949,7 @@ * timeout all idle connections */ void -connection_check_timeout () +connection_check_timeout() { time_t t; CONNECTION *c, *next; @@ -946,13 +959,13 @@ return; } - t = time (0); + t = time(0); for (c = connections; c; c = next) { next = c->next; if (t - c->time >= rptp_timeout) { - connection_timeout (c); + connection_timeout(c); } } } @@ -962,10 +975,10 @@ */ #ifdef __STDC__ void -connection_timeout (CONNECTION *c) -#else -void -connection_timeout (c) +connection_timeout(CONNECTION *c) +#else +void +connection_timeout(c) CONNECTION *c; #endif { @@ -980,23 +993,24 @@ switch (c->event->type) { case EVENT_NOTIFY: + case EVENT_WAIT_MONITOR: return; } } if (c->type == CONNECTION_SERVER) { - report (REPORT_DEBUG, "%s server connection timeout\n", inet_ntoa (c->sin.sin_addr)); - connection_close (c); + report(REPORT_DEBUG, "%s server connection timeout\n", inet_ntoa(c->sin.sin_addr)); + connection_close(c); } else { - b = buffer_create (); - SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "%cmessage=\"Connection timed out after %d idle seconds.\"\r\n", - RPTP_TIMEOUT, rptp_timeout); - b->nbytes += strlen (b->buf); - e = event_create (EVENT_WRITE_TIMEOUT, b); - event_replace (c, e); + b = buffer_create(); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "%cmessage=\"Connection timed out after %d idle seconds.\"\r\n", + RPTP_TIMEOUT, rptp_timeout); + b->nbytes += strlen(b->buf); + e = event_create(EVENT_WRITE_TIMEOUT, b); + event_replace(c, e); } } @@ -1005,10 +1019,10 @@ */ #ifdef __STDC__ void -connection_server_forward_sound (CONNECTION *c, SOUND *s) -#else -void -connection_server_forward_sound (c, s) +connection_server_forward_sound(CONNECTION *c, SOUND *s) +#else +void +connection_server_forward_sound(c, s) CONNECTION *c; SOUND *s; #endif @@ -1017,12 +1031,12 @@ if (c->server->next) { - server = connection_server_open (c->server->next, s); + server = connection_server_open(c->server->next, s); } else { - spool_remove (s); - sound_delete (s, 1); + spool_remove(s); + sound_delete(s, 1); } } @@ -1031,10 +1045,10 @@ */ #ifdef __STDC__ void -connection_server_forward (CONNECTION *c) -#else -void -connection_server_forward (c) +connection_server_forward(CONNECTION *c) +#else +void +connection_server_forward(c) CONNECTION *c; #endif { @@ -1043,8 +1057,8 @@ if (c->server->next) { - server = connection_server_open (c->server->next, NULL); - event_insert (server, c->event); + server = connection_server_open(c->server->next, NULL); + event_insert(server, c->event); } else { @@ -1058,11 +1072,11 @@ case EVENT_WRITE_GET: case EVENT_READ_GET_REPLY: case EVENT_READ_SOUND: - spool_remove (e->sound); - sound_delete (e->sound, 1); + spool_remove(e->sound); + sound_delete(e->sound, 1); break; } - event_destroy (e); + event_destroy(e); } } c->event = NULL; @@ -1070,134 +1084,162 @@ } BUFFER * -connection_list_create () +connection_list_create() { CONNECTION *c; BUFFER *b, *connection_list; + char line[RPTP_MAX_LINE]; char buf[RPTP_MAX_LINE]; - int n; + int n, length; time_t t; - b = buffer_create (); + b = buffer_create(); connection_list = b; - SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "+message=\"connections\"\r\n"); - b->nbytes += strlen (b->buf); - - t = time (0); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "+message=\"connections\"\r\n"); + b->nbytes += strlen(b->buf); + + t = time(0); for (c = connections; c; c = c->next) { - SNPRINTF (SIZE(buf,sizeof(buf)), "host=%s", inet_ntoa (c->sin.sin_addr)); - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), " type="); + length = 0; + line[0] = '\0'; + + SNPRINTF(SIZE(buf, sizeof(buf)), "host=%s", inet_ntoa(c->sin.sin_addr)); + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); + + SNPRINTF(SIZE(buf, sizeof(buf)), " type="); + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); + + buf[0] = '\0'; switch (c->type) { case CONNECTION_SERVER: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "server"); + SNPRINTF(SIZE(buf, sizeof(buf)), "server"); break; case CONNECTION_CLIENT: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "client"); + SNPRINTF(SIZE(buf, sizeof(buf)), "client"); break; } + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); if (c->event != NULL) { - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), " what="); + SNPRINTF(SIZE(buf, sizeof(buf)), " what="); + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); + + buf[0] = '\0'; switch (c->event->type) { case EVENT_READ_COMMAND: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "idle"); + SNPRINTF(SIZE(buf, sizeof(buf)), "idle"); break; case EVENT_CONNECT: case EVENT_READ_CONNECT_REPLY: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "connect"); + SNPRINTF(SIZE(buf, sizeof(buf)), "connect"); break; case EVENT_WRITE_FIND: case EVENT_READ_FIND_REPLY: - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"find %s\"", c->event->sound->name); + SNPRINTF(SIZE(buf, sizeof(buf)), "\"find %s\"", c->event->sound->name); break; case EVENT_WRITE_GET: case EVENT_READ_GET_REPLY: - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"get %s\"", c->event->sound->name); + SNPRINTF(SIZE(buf, sizeof(buf)), "\"get %s\"", c->event->sound->name); break; case EVENT_READ_SOUND: if (c->type == CONNECTION_SERVER) - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"get %s (%d/%d)\"", - c->event->sound->name, - c->event->byte_offset, - c->event->nbytes); + SNPRINTF(SIZE(buf, sizeof(buf)), "\"get %s (%d/%d)\"", + c->event->sound->name, + c->event->byte_offset, + c->event->nbytes); else - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"put %s (%d/%d)\"", - c->event->sound->name, - c->event->byte_offset, - c->event->nbytes); + SNPRINTF(SIZE(buf, sizeof(buf)), "\"put %s (%d/%d)\"", + c->event->sound->name, + c->event->byte_offset, + c->event->nbytes); break; case EVENT_WRITE: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "write"); + SNPRINTF(SIZE(buf, sizeof(buf)), "write"); break; case EVENT_WRITE_SOUND: - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"get %s (%d/%d)\"", - c->event->sound->name, - c->event->byte_offset, - c->event->nbytes); + SNPRINTF(SIZE(buf, sizeof(buf)), "\"get %s (%d/%d)\"", + c->event->sound->name, + c->event->byte_offset, + c->event->nbytes); break; case EVENT_NOTIFY: if (c->notify_mask) - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"notify %08x\"", c->notify_mask); + SNPRINTF(SIZE(buf, sizeof(buf)), "\"notify %08x\"", + c->notify_mask); else - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"wait %08x\"", c->event->wait_mask); + SNPRINTF(SIZE(buf, sizeof(buf)), "\"wait %08x\"", + c->event->wait_mask); break; case EVENT_READ_FLOW: case EVENT_WAIT_FLOW: - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"put #%d (%d/%d)\"", - c->event->id, - c->event->byte_offset, - c->event->nbytes); + SNPRINTF(SIZE(buf, sizeof(buf)), "\"put #%d (%d/%d)\"", + c->event->id, + c->event->byte_offset, + c->event->nbytes); break; case EVENT_PIPE_FLOW: - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\"pipe #%d\"", - c->event->id); + SNPRINTF(SIZE(buf, sizeof(buf)), "\"pipe #%d\"", + c->event->id); break; } + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); } if (t - c->time) { - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), " idle=%s", time2string (t - c->time)); + SNPRINTF(SIZE(buf, sizeof(buf)), " idle=%s", time2string(t - c->time)); + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); } if (c->application) { - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), " application=\"%s\"", c->application); - } - - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "\r\n"); - - n = strlen (buf); - if (b->nbytes + n > BUFFER_SIZE) - { - b->next = buffer_create (); + SNPRINTF(SIZE(buf, sizeof(buf)), " application=\"%s\"", c->application); + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); + } + + SNPRINTF(SIZE(buf, sizeof(buf)), "\r\n"); + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); + + if (b->nbytes + length > BUFFER_SIZE) + { + b->next = buffer_create(); b = b->next; } - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), buf); - b->nbytes += n; + + strncat(b->buf + b->nbytes, line, BUFFER_SIZE - b->nbytes); + b->nbytes += length; } if (b->nbytes + 3 > BUFFER_SIZE) { - b->next = buffer_create (); + b->next = buffer_create(); b = b->next; } - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n"); + + strncat(b->buf + b->nbytes, ".\r\n", BUFFER_SIZE - b->nbytes); b->nbytes += 3; return connection_list; @@ -1205,10 +1247,10 @@ #ifdef __STDC__ void -connection_notify (CONNECTION *notify_connection, int notify_event,...) -#else -void -connection_notify (va_alist) +connection_notify(CONNECTION *notify_connection, int notify_event,...) +#else +void +connection_notify(va_alist) va_dcl #endif { @@ -1225,20 +1267,20 @@ va_list args; #ifdef __STDC__ - va_start (args, notify_event); + va_start(args, notify_event); #else CONNECTION *notify_connection; int notify_event; - va_start (args); - notify_connection = va_arg (args, CONNECTION *); - notify_event = va_arg (args, int); + va_start(args); + notify_connection = va_arg(args, CONNECTION *); + notify_event = va_arg(args, int); #endif /* Extract event parameters. */ switch (notify_event) { case NOTIFY_VOLUME: /* (int) */ - new_volume = va_arg (args, int); + new_volume = va_arg(args, int); break; case NOTIFY_PLAY: /* (SPOOL *) */ @@ -1250,20 +1292,20 @@ case NOTIFY_FLOW: case NOTIFY_MODIFY: case NOTIFY_POSITION: - sp = va_arg (args, SPOOL *); + sp = va_arg(args, SPOOL *); break; case NOTIFY_STATE: /* none */ break; - + case NOTIFY_LEVEL: /* int */ - force_notify = va_arg (args, int); - break; - } - - va_end (args); - - t = time (0); + force_notify = va_arg(args, int); + break; + } + + va_end(args); + + t = time(0); c = notify_connection ? notify_connection : connections; for (; c; c = c->next) @@ -1273,10 +1315,11 @@ break; } - if (BIT (c->notify_mask, notify_event) - || (c->event && BIT (c->event->wait_mask, notify_event))) - { - strcpy (buf, "?event="); + if (BIT(c->notify_mask, notify_event) + || (c->event && BIT(c->event->wait_mask, notify_event))) + { + strcpy(buf, "?event="); + length = strlen(buf); switch (notify_event) { @@ -1289,8 +1332,9 @@ { n--; } - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "done id=#%d sound=\"%s\" client-data=\"%s\"", - sp->id, sp->sound[n]->name, sp->curr_attrs->client_data); + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), + "done id=#%d sound=\"%s\" client-data=\"%s\"", + sp->id, sp->sound[n]->name, sp->curr_attrs->client_data); } else { @@ -1299,7 +1343,7 @@ break; case NOTIFY_VOLUME: - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "volume volume=%d", + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "volume volume=%d", new_volume); break; @@ -1308,13 +1352,13 @@ || (c->event && c->event->id == sp->id)) { SOUND *s = sp->sound[sp->curr_sound]; - - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "play\ + + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "play\ id=#%d sound=\"%s\" host=%s volume=%d priority=%d count=%d seconds=%.2f size=%d\ sample-rate=%d channels=%d bits=%g input=%s client-data=\"%s\"", sp->id, sp->curr_attrs->sound, - inet_ntoa (sp->sin.sin_addr), + inet_ntoa(sp->sin.sin_addr), sp->curr_attrs->volume, sp->rp->priority, sp->curr_attrs->count, @@ -1323,7 +1367,7 @@ sp->sample_rate, s->channels, s->input_precision, - input_to_string (s->type), + input_to_string(s->type), sp->curr_attrs->client_data); } else @@ -1336,7 +1380,8 @@ if ((!c->notify_id || c->notify_id == sp->id) || (c->event && c->event->id == sp->id)) { - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "stop id=#%d sound=\"%s\" client-data=\"%s\"", + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), + "stop id=#%d sound=\"%s\" client-data=\"%s\"", sp->id, sp->curr_attrs->sound, sp->curr_attrs->client_data); } else @@ -1349,7 +1394,8 @@ if ((!c->notify_id || c->notify_id == sp->id) || (c->event && c->event->id == sp->id)) { - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "pause id=#%d sound=\"%s\" client-data=\"%s\"", + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), + "pause id=#%d sound=\"%s\" client-data=\"%s\"", sp->id, sp->curr_attrs->sound, sp->curr_attrs->client_data); } else @@ -1362,7 +1408,8 @@ if ((!c->notify_id || c->notify_id == sp->id) || (c->event && c->event->id == sp->id)) { - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "continue id=#%d sound=\"%s\" client-data=\"%s\"", + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), + "continue id=#%d sound=\"%s\" client-data=\"%s\"", sp->id, sp->curr_attrs->sound, sp->curr_attrs->client_data); } else @@ -1375,7 +1422,8 @@ if ((!c->notify_id || c->notify_id == sp->id) || (c->event && c->event->id == sp->id)) { - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "skip id=#%d sound=\"%s\" client-data=\"%s\"", + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), + "skip id=#%d sound=\"%s\" client-data=\"%s\"", sp->id, sp->curr_attrs->sound, sp->curr_attrs->client_data); } else @@ -1385,19 +1433,19 @@ break; case NOTIFY_STATE: - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\ -state play=%d pause=%d volume=%d priority-threshold=%d audio-port=%s", + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), + "state play=%d pause=%d volume=%d priority-threshold=%d audio-port=%s", spool_nplaying, spool_npaused, rplay_audio_volume, rplay_priority_threshold, - audio_port_to_string (rplay_audio_port)); + audio_port_to_string(rplay_audio_port)); break; case NOTIFY_FLOW: if ((!c->notify_id || c->notify_id == sp->id) || (c->event && c->event->id == sp->id)) { - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "\ -flow id=#%d sound=\"%s\" mark=%d low=%d high=%d client-data=\"%s\"", + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), + "flow id=#%d sound=\"%s\" mark=%d low=%d high=%d client-data=\"%s\"", sp->id, sp->curr_attrs->sound, sp->si->water_mark - sp->si->offset, @@ -1415,7 +1463,7 @@ if ((!c->notify_id || c->notify_id == sp->id) || (c->event && c->event->id == sp->id)) { - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "modify \ + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "modify \ id=#%d count=%d list-count=%d priority=%d sample-rate=%d volume=%d client-data=\"%s\"", sp->id, sp->curr_count, @@ -1435,21 +1483,22 @@ if (c->notify_rate[NOTIFY_RATE_LEVEL].rate) { if (!force_notify - && c->notify_rate[NOTIFY_RATE_LEVEL].next > timer_count) + && c->notify_rate[NOTIFY_RATE_LEVEL].next > timer_count) { continue; } - + c->notify_rate[NOTIFY_RATE_LEVEL].next = timer_count + c->notify_rate[NOTIFY_RATE_LEVEL].rate; } - - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "level volume=%d left=%d right=%d", + + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), + "level volume=%d left=%d right=%d", rplay_audio_volume, - rplay_audio_left_level, + rplay_audio_left_level, rplay_audio_right_level); break; - + case NOTIFY_POSITION: if ((!c->notify_id || c->notify_id == sp->id) || (c->event && c->event->id == sp->id)) @@ -1462,12 +1511,12 @@ { continue; } - + c->notify_rate[NOTIFY_RATE_POSITION].next = timer_count + c->notify_rate[NOTIFY_RATE_POSITION].rate; } - - SNPRINTF (SIZE (buf + strlen (buf), BUFFER_SIZE), "position \ + + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "position \ id=#%d position=%.2f remain=%.2f seconds=%.2f sample=%d samples=%d client-data=\"%s\"", sp->id, sp->sample_rate && s->samples ? sp->sample_index / sp->sample_rate : 0, @@ -1483,16 +1532,17 @@ } } - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "\r\n"); - length = strlen (buf); + length = strlen(buf); + SNPRINTF(SIZE(buf + length, sizeof(buf) - length), "\r\n"); + length = strlen(buf); /* Build the head array with the necessary RPTP headers. */ n = 0; - if (c->event && BIT (c->event->wait_mask, notify_event)) + if (c->event && BIT(c->event->wait_mask, notify_event)) { head[n++] = RPTP_OK; } - if (BIT (c->notify_mask, notify_event)) + if (BIT(c->notify_mask, notify_event)) { head[n++] = RPTP_NOTIFY; } @@ -1510,32 +1560,32 @@ if (e && e->type == EVENT_WRITE && e->buffer->nbytes + length <= BUFFER_SIZE) { - strcpy (e->buffer->buf + e->buffer->nbytes, buf); + strcpy(e->buffer->buf + e->buffer->nbytes, buf); e->buffer->nbytes += length; e->nbytes += length; e->nleft += length; } else { - b = buffer_create (); - strcpy (b->buf + b->nbytes, buf); + b = buffer_create(); + strcpy(b->buf + b->nbytes, buf); b->nbytes += length; - e = event_create (EVENT_WRITE, b); + e = event_create(EVENT_WRITE, b); if (c->event && c->event->type == EVENT_NOTIFY) { - event_replace (c, e); + event_replace(c, e); } else { - event_insert_before (c, e, - EVENT_READ_COMMAND - |EVENT_READ_SOUND - |EVENT_READ_CONNECT_REPLY - |EVENT_READ_FIND_REPLY - |EVENT_READ_GET_REPLY - |EVENT_READ_FLOW - |EVENT_WAIT_FLOW - |EVENT_PIPE_FLOW); + event_insert_before(c, e, + EVENT_READ_COMMAND + | EVENT_READ_SOUND + | EVENT_READ_CONNECT_REPLY + | EVENT_READ_FIND_REPLY + | EVENT_READ_GET_REPLY + | EVENT_READ_FLOW + | EVENT_WAIT_FLOW + | EVENT_PIPE_FLOW); } } } @@ -1558,7 +1608,7 @@ prev_pause = spool_npaused; prev_volume = rplay_audio_volume; /* Recursion is your friend. */ - connection_notify (notify_connection, NOTIFY_STATE); + connection_notify(notify_connection, NOTIFY_STATE); } break; @@ -1569,10 +1619,10 @@ #ifdef __STDC__ void -connection_flow_pause (SPOOL *sp) -#else -void -connection_flow_pause (sp) +connection_flow_pause(SPOOL *sp) +#else +void +connection_flow_pause(sp) SPOOL *sp; #endif { @@ -1588,7 +1638,7 @@ e->type = EVENT_WAIT_FLOW; if (c->event == e) { - connection_update_fdset (c); + connection_update_fdset(c); } break; } @@ -1598,16 +1648,16 @@ #ifdef __STDC__ void -connection_flow_continue (SPOOL *sp) -#else -void -connection_flow_continue (sp) +connection_flow_continue(SPOOL *sp) +#else +void +connection_flow_continue(sp) SPOOL *sp; #endif { CONNECTION *c; EVENT *e; - + for (c = connections; c; c = c->next) { for (e = c->event; e; e = e->next) @@ -1617,7 +1667,7 @@ e->type = EVENT_READ_FLOW; if (c->event == e) { - connection_update_fdset (c); + connection_update_fdset(c); } break; } @@ -1627,10 +1677,49 @@ #ifdef __STDC__ void -event_update (CONNECTION *c) -#else -void -event_update (c) +connection_monitor_pause(CONNECTION *c) +#else +void +connection_monitor_pause(c) + CONNECTION *c; +#endif +{ + if (c->event && c->event->type == EVENT_WRITE_MONITOR) + { + c->event->type = EVENT_WAIT_MONITOR; + connection_update_fdset(c); + } +} + +void +connection_monitor_continue() +{ + CONNECTION *c; + EVENT *e; + + for (c = connections; c; c = c->next) + { + for (e = c->event; e; e = e->next) + { + if (e->type == EVENT_WAIT_MONITOR) + { + e->type = EVENT_WRITE_MONITOR; + if (c->event == e) + { + connection_update_fdset(c); + } + break; + } + } + } +} + +#ifdef __STDC__ +void +event_update(CONNECTION *c) +#else +void +event_update(c) CONNECTION *c; #endif { @@ -1652,26 +1741,26 @@ if (c->event->success) { if (c->event->start[0] != '\0' - && isascii (c->event->start[0])) + && isascii(c->event->start[0])) { - b = c->event->buffer; /* save the event's buffer */ + b = c->event->buffer; /* save the event's buffer */ c->event->buffer = NULL; - event_delete (c, 0); - - if (command (c, b->buf) != 0) - { - connection_close (c); - } - buffer_destroy (b); + event_delete(c, 0); + + if (command(c, b->buf) != 0) + { + connection_close(c); + } + buffer_destroy(b); } else { - event_delete (c, 1); + event_delete(c, 1); } } else { - connection_close (c); + connection_close(c); } break; @@ -1679,7 +1768,7 @@ /* * check the time to delay between connect attempts */ - t = time (0); + t = time(0); if (t - c->event->time < RPTP_PING_DELAY) { break; @@ -1689,19 +1778,19 @@ /* * check the socket to see if it is connected */ - n = connect (c->fd, (struct sockaddr *) &c->server->sin, sizeof (c->server->sin)); + n = connect(c->fd, (struct sockaddr *) &c->server->sin, sizeof(c->server->sin)); if (n == 0 || errno == EISCONN) { /* * got a connection */ - report (REPORT_NOTICE, "%s server connection established\n", inet_ntoa (c->server->sin.sin_addr)); + report(REPORT_NOTICE, "%s server connection established\n", inet_ntoa(c->server->sin.sin_addr)); /* * prepare to read the connect reply, this must replace the * connect event */ - e = event_create (EVENT_READ_CONNECT_REPLY, buffer_create ()); - event_replace (c, e); + e = event_create(EVENT_READ_CONNECT_REPLY, buffer_create()); + event_replace(c, e); } else { @@ -1709,9 +1798,9 @@ * socket is not connected */ c->event->nconnects++; - report (REPORT_DEBUG, "%s server connection failed attempt #%d\n", - inet_ntoa (c->server->sin.sin_addr), - c->event->nconnects); + report(REPORT_DEBUG, "%s server connection failed attempt #%d\n", + inet_ntoa(c->server->sin.sin_addr), + c->event->nconnects); if (c->event->nconnects < RPTP_CONNECT_ATTEMPTS) { switch (errno) @@ -1724,19 +1813,19 @@ /* * ping the server again */ - connection_server_ping (c); - - FD_CLR (c->fd, &read_mask); - FD_CLR (c->fd, &write_mask); - close (c->fd); - c->fd = socket (AF_INET, SOCK_STREAM, 0); - fd_nonblock (c->fd); + connection_server_ping(c); + + FD_CLR(c->fd, &read_mask); + FD_CLR(c->fd, &write_mask); + close(c->fd); + c->fd = socket(AF_INET, SOCK_STREAM, 0); + fd_nonblock(c->fd); /* * try and connect again */ - connect (c->fd, (struct sockaddr *) &c->server->sin, sizeof (c->server->sin)); - connection_update_fdset (c); + connect(c->fd, (struct sockaddr *) &c->server->sin, sizeof(c->server->sin)); + connection_update_fdset(c); return; default: @@ -1748,10 +1837,10 @@ * connection failed, remove connect event and forward all other * events to the next server */ - report (REPORT_NOTICE, "%s server connection failed\n", inet_ntoa (c->server->sin.sin_addr)); - event_delete (c, 1); - connection_server_forward (c); - connection_close (c); + report(REPORT_NOTICE, "%s server connection failed\n", inet_ntoa(c->server->sin.sin_addr)); + event_delete(c, 1); + connection_server_forward(c); + connection_close(c); } break; @@ -1760,35 +1849,35 @@ { if (c->event->start[0] == RPTP_OK) { - event_delete (c, 1); + event_delete(c, 1); } else { - event_delete (c, 1); - connection_server_forward (c); - connection_close (c); + event_delete(c, 1); + connection_server_forward(c); + connection_close(c); } } else { - report (REPORT_NOTICE, "cannot read connect reply from %s\n", - inet_ntoa (c->server->sin.sin_addr)); - event_delete (c, 1); - connection_server_forward (c); - connection_close (c); + report(REPORT_NOTICE, "cannot read connect reply from %s\n", + inet_ntoa(c->server->sin.sin_addr)); + event_delete(c, 1); + connection_server_forward(c); + connection_close(c); } break; case EVENT_WRITE_FIND: if (c->event->success) { - e = event_create (EVENT_READ_FIND_REPLY, buffer_create (), c->event->sound); - event_replace (c, e); + e = event_create(EVENT_READ_FIND_REPLY, buffer_create(), c->event->sound); + event_replace(c, e); } else { - connection_server_forward (c); - connection_close (c); + connection_server_forward(c); + connection_close(c); } break; @@ -1798,87 +1887,87 @@ switch (c->event->start[0]) { case RPTP_OK: - if (strchr (c->event->start, '=')) - { - size = atoi (rptp_parse (c->event->start, "size")); + if (strchr(c->event->start, '=')) + { + size = atoi(rptp_parse(c->event->start, "size")); } else /* old-style */ { - p = strtok (c->event->start, " "); - size = atoi (strtok (NULL, "\r\n")); + p = strtok(c->event->start, " "); + size = atoi(strtok(NULL, "\r\n")); } /* * see if the sound will fit in the cache */ - if (cache_free (size) < 0) + if (cache_free(size) < 0) { /* * the sound is too big for the cache */ - spool_remove (c->event->sound); - sound_delete (c->event->sound, 1); - event_delete (c, 1); + spool_remove(c->event->sound); + sound_delete(c->event->sound, 1); + event_delete(c, 1); break; } - b = buffer_create (); - SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "get %s\r\n", c->event->sound->name); /* old-style */ - b->nbytes = strlen (b->buf); - e = event_create (EVENT_WRITE_GET, b, c->event->sound); - event_replace (c, e); + b = buffer_create(); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "get %s\r\n", c->event->sound->name); /* old-style */ + b->nbytes = strlen(b->buf); + e = event_create(EVENT_WRITE_GET, b, c->event->sound); + event_replace(c, e); break; case RPTP_ERROR: - report (REPORT_NOTICE, "%s server does not have %s\n", - inet_ntoa (c->sin.sin_addr), c->event->sound->name); - connection_server_forward_sound (c, c->event->sound); - event_delete (c, 1); + report(REPORT_NOTICE, "%s server does not have %s\n", + inet_ntoa(c->sin.sin_addr), c->event->sound->name); + connection_server_forward_sound(c, c->event->sound); + event_delete(c, 1); break; case RPTP_TIMEOUT: - report (REPORT_NOTICE, "%s server connection timed out\n", - inet_ntoa (c->sin.sin_addr)); - b = buffer_create (); - SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ - b->nbytes = strlen (b->buf); - e = event_create (EVENT_WRITE_FIND, b, c->event->sound); - event_replace (c, e); - connection_server_reopen (c); + report(REPORT_NOTICE, "%s server connection timed out\n", + inet_ntoa(c->sin.sin_addr)); + b = buffer_create(); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ + b->nbytes = strlen(b->buf); + e = event_create(EVENT_WRITE_FIND, b, c->event->sound); + event_replace(c, e); + connection_server_reopen(c); break; default: - report (REPORT_ERROR, "event_update: unknown find reply '%c'\n", c->event->start[0]); - done (1); + report(REPORT_ERROR, "event_update: unknown find reply '%c'\n", c->event->start[0]); + done(1); } } else { - report (REPORT_NOTICE, "cannot read find reply from %s\n", inet_ntoa (c->sin.sin_addr)); - b = buffer_create (); - SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ - b->nbytes = strlen (b->buf); - e = event_create (EVENT_WRITE_FIND, b, c->event->sound); - event_replace (c, e); - connection_server_forward (c); - connection_close (c); + report(REPORT_NOTICE, "cannot read find reply from %s\n", inet_ntoa(c->sin.sin_addr)); + b = buffer_create(); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ + b->nbytes = strlen(b->buf); + e = event_create(EVENT_WRITE_FIND, b, c->event->sound); + event_replace(c, e); + connection_server_forward(c); + connection_close(c); } break; case EVENT_WRITE_GET: if (c->event->success) { - e = event_create (EVENT_READ_GET_REPLY, buffer_create (), c->event->sound); - event_replace (c, e); + e = event_create(EVENT_READ_GET_REPLY, buffer_create(), c->event->sound); + event_replace(c, e); } else { - b = buffer_create (); - SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ - b->nbytes = strlen (b->buf); - e = event_create (EVENT_WRITE_FIND, b, c->event->sound); - event_replace (c, e); - connection_server_forward (c); - connection_close (c); + b = buffer_create(); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ + b->nbytes = strlen(b->buf); + e = event_create(EVENT_WRITE_FIND, b, c->event->sound); + event_replace(c, e); + connection_server_forward(c); + connection_close(c); } break; @@ -1890,114 +1979,114 @@ switch (c->event->start[0]) { case RPTP_OK: - if (strchr (c->event->start, '=')) - { - sound_name = rptp_parse (c->event->start, "sound"); - size = atoi (rptp_parse (0, "size")); + if (strchr(c->event->start, '=')) + { + sound_name = rptp_parse(c->event->start, "sound"); + size = atoi(rptp_parse(0, "size")); } else /* old-style */ { - p = strtok (c->event->start, " "); + p = strtok(c->event->start, " "); p++; sound_name = p; - size = atoi (strtok (NULL, "\r\n")); - } - - free ((char *) c->event->sound->path); - c->event->sound->path = strdup (cache_name (sound_name)); + size = atoi(strtok(NULL, "\r\n")); + } + + free((char *) c->event->sound->path); + c->event->sound->path = strdup(cache_name(sound_name)); c->event->sound->name = c->event->sound->path[0] == '/' ? - strrchr (c->event->sound->path, '/') + 1 : + strrchr(c->event->sound->path, '/') + 1 : c->event->sound->path; - fd = cache_create (c->event->sound->path, size); + fd = cache_create(c->event->sound->path, size); if (fd < 0) { - spool_remove (c->event->sound); - sound_delete (c->event->sound, 1); - event_delete (c, 1); + spool_remove(c->event->sound); + sound_delete(c->event->sound, 1); + event_delete(c, 1); } else { - e = event_create (EVENT_READ_SOUND, fd, buffer_create (), - size, c->event->sound); + e = event_create(EVENT_READ_SOUND, fd, buffer_create(), + size, c->event->sound); c->event->sound->status = SOUND_NOT_READY; - event_replace (c, e); + event_replace(c, e); } break; case RPTP_ERROR: - report (REPORT_NOTICE, "%s server does not have %s\n", - inet_ntoa (c->sin.sin_addr), c->event->sound->name); - connection_server_forward_sound (c, c->event->sound); - event_delete (c, 1); + report(REPORT_NOTICE, "%s server does not have %s\n", + inet_ntoa(c->sin.sin_addr), c->event->sound->name); + connection_server_forward_sound(c, c->event->sound); + event_delete(c, 1); break; case RPTP_TIMEOUT: - report (REPORT_NOTICE, "%s server connection timed out\n", - inet_ntoa (c->sin.sin_addr)); - b = buffer_create (); - SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "get %s\r\n", c->event->sound->name); /* old-style */ - b->nbytes = strlen (b->buf); - e = event_create (EVENT_WRITE_GET, b, c->event->sound); - event_replace (c, e); - connection_server_reopen (c); + report(REPORT_NOTICE, "%s server connection timed out\n", + inet_ntoa(c->sin.sin_addr)); + b = buffer_create(); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "get %s\r\n", c->event->sound->name); /* old-style */ + b->nbytes = strlen(b->buf); + e = event_create(EVENT_WRITE_GET, b, c->event->sound); + event_replace(c, e); + connection_server_reopen(c); break; default: - report (REPORT_ERROR, "event_update: unknown get reply '%c'\n", - c->event->start[0]); - done (1); + report(REPORT_ERROR, "event_update: unknown get reply '%c'\n", + c->event->start[0]); + done(1); } } else { - report (REPORT_NOTICE, "cannot read get reply from %s\n", - inet_ntoa (c->server->sin.sin_addr)); - b = buffer_create (); - SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ - b->nbytes = strlen (b->buf); - e = event_create (EVENT_WRITE_FIND, b, c->event->sound); - event_replace (c, e); - connection_server_forward (c); - connection_close (c); + report(REPORT_NOTICE, "cannot read get reply from %s\n", + inet_ntoa(c->server->sin.sin_addr)); + b = buffer_create(); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ + b->nbytes = strlen(b->buf); + e = event_create(EVENT_WRITE_FIND, b, c->event->sound); + event_replace(c, e); + connection_server_forward(c); + connection_close(c); } break; case EVENT_READ_SOUND: if (c->event->success) { - close (c->event->fd); - sound_map (c->event->sound); - spool_ready (c->event->sound); + close(c->event->fd); + sound_map(c->event->sound); + spool_ready(c->event->sound); c->event->sound->status = SOUND_READY; - report (REPORT_DEBUG, "sound %s is ready\n", c->event->sound->name); - event_delete (c, 1); + report(REPORT_DEBUG, "sound %s is ready\n", c->event->sound->name); + event_delete(c, 1); } else { - report (REPORT_NOTICE, "cannot read sound %s from %s\n", c->event->sound->name, - inet_ntoa (c->sin.sin_addr)); + report(REPORT_NOTICE, "cannot read sound %s from %s\n", c->event->sound->name, + inet_ntoa(c->sin.sin_addr)); if (c->type == CONNECTION_SERVER) { - b = buffer_create (); - SNPRINTF (SIZE (b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ - b->nbytes = strlen (b->buf); - e = event_create (EVENT_WRITE_FIND, b, c->event->sound); - event_replace (c, e); - connection_server_forward (c); + b = buffer_create(); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "find %s\r\n", c->event->sound->name); /* old-style */ + b->nbytes = strlen(b->buf); + e = event_create(EVENT_WRITE_FIND, b, c->event->sound); + event_replace(c, e); + connection_server_forward(c); } - connection_close (c); + connection_close(c); } break; case EVENT_WRITE_SOUND: if (c->event->success) { - event_delete (c, 1); + event_delete(c, 1); } else { - connection_close (c); + connection_close(c); } break; @@ -2008,7 +2097,7 @@ c->event->buffer = c->event->buffer->next; if (b->status == BUFFER_FREE) { - buffer_destroy (b); + buffer_destroy(b); } if (c->event->buffer) { @@ -2020,18 +2109,18 @@ } else { - event_delete (c, 1); + event_delete(c, 1); } } else { - connection_close (c); + connection_close(c); } break; case EVENT_WRITE_TIMEOUT: - report (REPORT_DEBUG, "%s client connection timeout\n", inet_ntoa (c->sin.sin_addr)); - connection_close (c); + report(REPORT_DEBUG, "%s client connection timeout\n", inet_ntoa(c->sin.sin_addr)); + connection_close(c); break; case EVENT_READ_FLOW: @@ -2039,30 +2128,57 @@ case EVENT_PIPE_FLOW: if (c->event->success) { - event_delete (c, 1); + event_delete(c, 1); } else { - connection_close (c); + connection_close(c); } break; case EVENT_NOTIFY: - report (REPORT_DEBUG, "event_update: `%d' update?\n", c->event->type); - break; - + report(REPORT_DEBUG, "event_update: `%d' update?\n", c->event->type); + break; + + case EVENT_WRITE_MONITOR: + if (c->event->success) + { + /* move to the next monitor buffer */ + c->event->buffer = c->event->buffer->next; + c->event->start = c->event->buffer->buf; + c->event->ptr = c->event->start; + c->event->nleft = c->event->buffer->nbytes; + c->event->nbytes = c->event->nleft; + c->event->success = 0; + + /* need to wait for the buffer to be complete */ + if (c->event->buffer == monitor_buffers) + { + connection_monitor_pause(c); + } + } + else + { + connection_close(c); + } + break; + + case EVENT_WAIT_MONITOR: + connection_close(c); + break; + default: - report (REPORT_ERROR, "event_update: unknown event `%d'\n", c->event->type); - done (1); - } -} - -#ifdef __STDC__ -void -event_first (CONNECTION *c, EVENT *e) -#else -void -event_first (c, e) + report(REPORT_ERROR, "event_update: unknown event `%d'\n", c->event->type); + done(1); + } +} + +#ifdef __STDC__ +void +event_first(CONNECTION *c, EVENT *e) +#else +void +event_first(c, e) CONNECTION *c; EVENT *e; #endif @@ -2073,25 +2189,25 @@ tail->next = c->event; c->event = e; - + if (!c->event->next) { c->ep = &c->event->next; } - connection_update_fdset (c); - -#ifdef EVENT_DEBUG - event_print (c, "first"); -#endif -} - -#ifdef __STDC__ -void -event_insert_before (CONNECTION *c, EVENT *e, int mask) -#else -void -event_insert_before (c, e, mask) + connection_update_fdset(c); + +#ifdef EVENT_DEBUG + event_print(c, "first"); +#endif +} + +#ifdef __STDC__ +void +event_insert_before(CONNECTION *c, EVENT *e, int mask) +#else +void +event_insert_before(c, e, mask) CONNECTION *c; EVENT *e; int mask; @@ -2099,14 +2215,14 @@ { if (!c->event || (c->event->type & mask)) { - event_first (c, e); + event_first(c, e); } else { EVENT *tail, *event; for (tail = e; tail->next; tail = tail->next) ; - + for (event = c->event; event->next; event = event->next) { if (event->next->type & mask) @@ -2125,21 +2241,21 @@ if (c->event == e) { - connection_update_fdset (c); - } - -#ifdef EVENT_DEBUG - event_print (c, "before"); -#endif - } -} - -#ifdef __STDC__ -void -event_insert (CONNECTION *c, EVENT *e) -#else -void -event_insert (c, e) + connection_update_fdset(c); + } + +#ifdef EVENT_DEBUG + event_print(c, "before"); +#endif + } +} + +#ifdef __STDC__ +void +event_insert(CONNECTION *c, EVENT *e) +#else +void +event_insert(c, e) CONNECTION *c; EVENT *e; #endif @@ -2153,20 +2269,20 @@ if (c->event == e) { - connection_update_fdset (c); - } - -#ifdef EVENT_DEBUG - event_print (c, "insert"); -#endif -} - -#ifdef __STDC__ -void -event_replace (CONNECTION *c, EVENT *e) -#else -void -event_replace (c, e) + connection_update_fdset(c); + } + +#ifdef EVENT_DEBUG + event_print(c, "insert"); +#endif +} + +#ifdef __STDC__ +void +event_replace(CONNECTION *c, EVENT *e) +#else +void +event_replace(c, e) CONNECTION *c; EVENT *e; #endif @@ -2174,26 +2290,26 @@ if (c->event) { e->next = c->event->next; - event_destroy (c->event); + event_destroy(c->event); } c->event = e; if (c->event->next == NULL) { c->ep = &c->event->next; } - connection_update_fdset (c); - -#ifdef EVENT_DEBUG - event_print (c, "replace"); -#endif -} - -#ifdef __STDC__ -void -event_delete (CONNECTION *c, int replace) -#else -void -event_delete (c, replace) + connection_update_fdset(c); + +#ifdef EVENT_DEBUG + event_print(c, "replace"); +#endif +} + +#ifdef __STDC__ +void +event_delete(CONNECTION *c, int replace) +#else +void +event_delete(c, replace) CONNECTION *c; int replace; #endif @@ -2202,14 +2318,14 @@ if (c->event == NULL) { - connection_update_fdset (c); + connection_update_fdset(c); return; } e = c->event; c->event = c->event->next; - event_destroy (e); + event_destroy(e); if (c->event == NULL) { @@ -2220,21 +2336,21 @@ { if (c->notify_mask) { - e = event_create (EVENT_NOTIFY); + e = event_create(EVENT_NOTIFY); } else { - e = event_create (EVENT_READ_COMMAND, buffer_create ()); + e = event_create(EVENT_READ_COMMAND, buffer_create()); } - event_insert (c, e); - } - } - - connection_update_fdset (c); - -#ifdef EVENT_DEBUG - event_print (c, "delete"); -#endif + event_insert(c, e); + } + } + + connection_update_fdset(c); + +#ifdef EVENT_DEBUG + event_print(c, "delete"); +#endif } /* @@ -2253,10 +2369,10 @@ */ #ifdef __STDC__ EVENT * -event_create (int type,...) +event_create(int type,...) #else EVENT * -event_create (va_alist) +event_create(va_alist) va_dcl #endif { @@ -2264,18 +2380,18 @@ va_list args; #ifdef __STDC__ - va_start (args, type); + va_start(args, type); #else int type; - va_start (args); - type = va_arg (args, int); -#endif - - e = (EVENT *) malloc (sizeof (EVENT)); + va_start(args); + type = va_arg(args, int); +#endif + + e = (EVENT *) malloc(sizeof(EVENT)); if (e == NULL) { - report (REPORT_ERROR, "event_create: out of memory\n"); - done (1); + report(REPORT_ERROR, "event_create: out of memory\n"); + done(1); } /* @@ -2302,7 +2418,7 @@ { case EVENT_READ_COMMAND: case EVENT_READ_CONNECT_REPLY: - e->buffer = va_arg (args, BUFFER *); + e->buffer = va_arg(args, BUFFER *); e->nleft = RPTP_MAX_LINE; e->nbytes = e->nleft; e->ptr = e->buffer->buf; @@ -2314,44 +2430,44 @@ case EVENT_WRITE_FIND: case EVENT_WRITE_GET: - e->buffer = va_arg (args, BUFFER *); + e->buffer = va_arg(args, BUFFER *); e->nleft = e->buffer->nbytes; e->nbytes = e->nleft; e->ptr = e->buffer->buf; e->start = e->ptr; - e->sound = va_arg (args, SOUND *); + e->sound = va_arg(args, SOUND *); break; case EVENT_READ_FIND_REPLY: case EVENT_READ_GET_REPLY: - e->buffer = va_arg (args, BUFFER *); + e->buffer = va_arg(args, BUFFER *); e->nleft = RPTP_MAX_LINE; e->nbytes = e->nleft; e->ptr = e->buffer->buf; e->start = e->ptr; - e->sound = va_arg (args, SOUND *); + e->sound = va_arg(args, SOUND *); break; case EVENT_READ_SOUND: - e->fd = va_arg (args, int); - e->buffer = va_arg (args, BUFFER *); - e->nbytes = va_arg (args, int); + e->fd = va_arg(args, int); + e->buffer = va_arg(args, BUFFER *); + e->nbytes = va_arg(args, int); e->nleft = e->nbytes; - e->sound = va_arg (args, SOUND *); + e->sound = va_arg(args, SOUND *); break; case EVENT_WRITE_SOUND: - e->sound = va_arg (args, SOUND *); - e->buffer = buffer_create (); - e->si = sound_open (e->sound, 0); + e->sound = va_arg(args, SOUND *); + e->buffer = buffer_create(); + e->si = sound_open(e->sound, 0); if (e->si == NULL) { - event_destroy (e); + event_destroy(e); return NULL; } - if (sound_fill (e->si, e->buffer, 1) <= 0) - { - event_destroy (e); + if (sound_fill(e->si, e->buffer, 1) <= 0) + { + event_destroy(e); return NULL; } e->nbytes = e->sound->size; /* total number of bytes */ @@ -2362,7 +2478,7 @@ case EVENT_WRITE: case EVENT_WRITE_TIMEOUT: - e->buffer = va_arg (args, BUFFER *); + e->buffer = va_arg(args, BUFFER *); e->ptr = e->buffer->buf; e->start = e->ptr; e->nleft = e->buffer->nbytes; @@ -2373,8 +2489,8 @@ break; case EVENT_READ_FLOW: - e->id = va_arg (args, int); - e->nbytes = va_arg (args, int); + e->id = va_arg(args, int); + e->nbytes = va_arg(args, int); if (e->nbytes == 0) { e->nbytes = -1; @@ -2387,123 +2503,131 @@ break; case EVENT_PIPE_FLOW: - e->id = va_arg (args, int); - e->sound = va_arg (args, SOUND *); - break; - } - - va_end (args); + e->id = va_arg(args, int); + e->sound = va_arg(args, SOUND *); + break; + + case EVENT_WAIT_MONITOR: + e->buffer = monitor_buffers; + e->ptr = e->buffer->buf; + e->start = e->ptr; + e->nleft = e->buffer->nbytes; + e->nbytes = e->nleft; + break; + } + + va_end(args); return e; } #ifdef __STDC__ void -event_destroy (EVENT *e) -#else -void -event_destroy (e) +event_destroy(EVENT *e) +#else +void +event_destroy(e) EVENT *e; #endif { if (e->buffer && e->buffer->status == BUFFER_FREE) { - buffer_destroy (e->buffer); + buffer_destroy(e->buffer); } if (e->si) { - sound_close (e->si); - } - free ((char *) e); + sound_close(e->si); + } + free((char *) e); } #ifdef EVENT_DEBUG static void -event_print (CONNECTION *c, char *message) +event_print(CONNECTION *c, char *message) { EVENT *e; - printf ("%8s %s (%s) -> ", message, c->application, inet_ntoa (c->sin.sin_addr)); + printf("%8s %s (%s) -> ", message, c->application, inet_ntoa(c->sin.sin_addr)); e = c->event; for (; e; e = e->next) { switch (e->type) { case EVENT_READ_COMMAND: - printf ("read_command "); + printf("read_command "); break; case EVENT_CONNECT: - printf ("connect "); + printf("connect "); break; case EVENT_READ_CONNECT_REPLY: - printf ("read_connect_reply "); + printf("read_connect_reply "); break; case EVENT_WRITE_FIND: - printf ("write_find "); + printf("write_find "); break; case EVENT_READ_FIND_REPLY: - printf ("read_find_reply "); + printf("read_find_reply "); break; case EVENT_WRITE_GET: - printf ("write_get "); + printf("write_get "); break; case EVENT_READ_GET_REPLY: - printf ("read_get_reply "); + printf("read_get_reply "); break; case EVENT_READ_SOUND: - printf ("read_sound "); + printf("read_sound "); break; case EVENT_WRITE: - printf ("write "); + printf("write "); break; case EVENT_WRITE_SOUND: - printf ("write_sound "); + printf("write_sound "); break; case EVENT_WRITE_TIMEOUT: - printf ("write_timeout "); + printf("write_timeout "); break; case EVENT_NOTIFY: - printf ("notify "); + printf("notify "); break; case EVENT_READ_FLOW: - printf ("read_flow "); + printf("read_flow "); break; case EVENT_WAIT_FLOW: - printf ("wait_flow "); + printf("wait_flow "); break; case EVENT_PIPE_FLOW: - printf ("pipe_flow "); + printf("pipe_flow "); break; default: - printf ("`%d' ", e->type); + printf("`%d' ", e->type); break; } } - if (FD_ISSET (c->fd, &write_mask)) - { - printf ("[write] "); - } - if (FD_ISSET (c->fd, &read_mask)) - { - printf ("[read] "); - } - - printf ("\n"); -} -#endif + if (FD_ISSET(c->fd, &write_mask)) + { + printf("[write] "); + } + if (FD_ISSET(c->fd, &read_mask)) + { + printf("[read] "); + } + + printf("\n"); +} +#endif diff --git a/rplayd/connection.h b/rplayd/connection.h index 5b47944..6f6e87b 100644 --- a/rplayd/connection.h +++ b/rplayd/connection.h @@ -1,7 +1,7 @@ -/* $Id: connection.h,v 1.2 1998/08/13 06:13:49 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: connection.h,v 1.3 1999/03/10 07:58:03 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -56,6 +56,8 @@ #define EVENT_READ_FLOW (1<<12) /* read a flow */ #define EVENT_WAIT_FLOW (1<<13) /* pause the incoming flow data */ #define EVENT_PIPE_FLOW (1<<14) /* piped flow data */ +#define EVENT_WRITE_MONITOR (1<<15) /* write audio monitor data */ +#define EVENT_WAIT_MONITOR (1<<16) /* write audio monitor data */ /* * notify events @@ -73,6 +75,7 @@ #define NOTIFY_MODIFY (1<<9) #define NOTIFY_LEVEL (1<<10) #define NOTIFY_POSITION (1<<11) +#define NOTIFY_MONITOR (1<<12) #define NOTIFY_ANY (0xffffffff) #define NOTIFY_SPOOL (NOTIFY_PLAY|NOTIFY_PAUSE|NOTIFY_CONTINUE|NOTIFY_STOP|NOTIFY_DONE|NOTIFY_SKIP|NOTIFY_MODIFY|NOTIFY_FLOW) @@ -130,6 +133,7 @@ int notify_mask; int notify_id; NOTIFY_RATE notify_rate[NOTIFY_RATE_MAX]; + int monitor; } CONNECTION; diff --git a/rplayd/flange.c b/rplayd/flange.c index 9f859ab..3cf79d0 100644 --- a/rplayd/flange.c +++ b/rplayd/flange.c @@ -1,7 +1,7 @@ -/* $Id: flange.c,v 1.2 1998/08/13 06:13:50 boyns Exp $ */ +/* $Id: flange.c,v 1.4 1999/03/10 07:58:03 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ + - #include "rplayd.h" #ifdef TEST_FLANGE @@ -63,7 +63,7 @@ wl; void -flange (char *native_buf, int nsamples, int nchannels) +flange(char *native_buf, int nsamples, int nchannels) { short *sample = (short *) native_buf; short *flanged = (short *) native_buf; @@ -86,7 +86,7 @@ min_sweep = max_sweep - depth; if (min_sweep < 0) { - exit (1); + exit(1); } sweep.w[0] = (min_sweep + max_sweep) / 2; @@ -95,8 +95,8 @@ } #if 0 - printf ("step = %d, depth = %d, delay = %d\n", step, depth, delay); - printf ("max_sweep = %d, min_sweep = %d\n", max_sweep, min_sweep); + printf("step = %d, depth = %d, delay = %d\n", step, depth, delay); + printf("max_sweep = %d, min_sweep = %d\n", max_sweep, min_sweep); #endif for (i = 0; i < size; i++) diff --git a/rplayd/flange.h b/rplayd/flange.h index 40396da..45b2403 100644 --- a/rplayd/flange.h +++ b/rplayd/flange.h @@ -1,7 +1,7 @@ -/* $Id: flange.h,v 1.2 1998/08/13 06:13:51 boyns Exp $ */ +/* $Id: flange.h,v 1.3 1999/03/10 07:58:03 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/helper.c b/rplayd/helper.c index 8d57567..289bdf0 100644 --- a/rplayd/helper.c +++ b/rplayd/helper.c @@ -1,7 +1,7 @@ -/* $Id: helper.c,v 1.2 1998/08/13 06:13:52 boyns Exp $ */ +/* $Id: helper.c,v 1.4 1999/03/10 07:58:03 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -48,10 +48,10 @@ #ifdef __STDC__ void -helper_read (char *filename) -#else -void -helper_read (filename) +helper_read(char *filename) +#else +void +helper_read(filename) char *filename; #endif { @@ -62,18 +62,18 @@ int line = 0; int error; - helper_read_time = time (0); - - fp = fopen (filename, "r"); + helper_read_time = time(0); + + fp = fopen(filename, "r"); if (fp == NULL) { return; } - while (fgets (buf, sizeof (buf), fp) != NULL) + while (fgets(buf, sizeof(buf), fp) != NULL) { line++; - + switch (buf[0]) { case '#': @@ -82,17 +82,17 @@ case '\n': continue; } - p = strchr (buf, '\n'); + p = strchr(buf, '\n'); if (p) { *p = '\0'; } - hp = (HELPER *) malloc (sizeof (HELPER)); + hp = (HELPER *) malloc(sizeof(HELPER)); if (hp == NULL) { - report (REPORT_ERROR, "helper_read: out of memory\n"); - done (1); + report(REPORT_ERROR, "helper_read: out of memory\n"); + done(1); } hp->next = NULL; hp->program = NULL; @@ -103,57 +103,62 @@ hp->byte_order = 0; /* pattern */ - pat = strtok (buf, " \t"); + pat = strtok(buf, " \t"); if (!pat) { - report (REPORT_ERROR, "helper_read: parse error line %d\n", line); - done (1); + report(REPORT_ERROR, "helper_read: parse error line %d\n", line); + done(1); } //memset ((char *) &hp->pattern, 0, sizeof (hp->pattern)); - error = regncomp (&hp->pattern, pat, strlen (pat), REG_ICASE | REG_NOSUB); + error = regncomp(&hp->pattern, pat, strlen(pat), REG_ICASE | REG_NOSUB); if (error) { - report (REPORT_ERROR, "helper_read: %d line %d\n", error, line); - done (1); + report(REPORT_ERROR, "helper_read: %d line %d\n", error, line); + done(1); } /* info */ - info = strtok (NULL, " \t"); + info = strtok(NULL, " \t"); if (!info) { - report (REPORT_ERROR, "helper_read: parse error line %d\n", line); - done (1); - } - for (; *info && (*info == ' ' || *info == '\t'); info++); - + report(REPORT_ERROR, "helper_read: parse error line %d\n", line); + done(1); + } + for (; *info && (*info == ' ' || *info == '\t'); info++) ; + /* program */ - prog = strtok (NULL, ""); + prog = strtok(NULL, ""); if (!prog) { - report (REPORT_ERROR, "helper_read: parse error line %d\n", line); - done (1); - } - for (; *prog && (*prog == ' ' || *prog == '\t'); prog++); - hp->program = strdup (prog); + report(REPORT_ERROR, "helper_read: parse error line %d\n", line); + done(1); + } + for (; *prog && (*prog == ' ' || *prog == '\t'); prog++) ; + hp->program = strdup(prog); /* parse info */ - p = strtok (info, ","); - if (p) hp->format = string_to_audio_format (p); - p = strtok (NULL, ","); - if (p) hp->sample_rate = atoi (p); - p = strtok (NULL, ","); - if (p) hp->precision = atoi (p); - p = strtok (NULL, ","); - if (p) hp->channels = atoi (p); - p = strtok (NULL, ","); - if (p) hp->byte_order = string_to_byte_order (p); + p = strtok(info, ","); + if (p) + hp->format = string_to_audio_format(p); + p = strtok(NULL, ","); + if (p) + hp->sample_rate = atoi(p); + p = strtok(NULL, ","); + if (p) + hp->precision = atoi(p); + p = strtok(NULL, ","); + if (p) + hp->channels = atoi(p); + p = strtok(NULL, ","); + if (p) + hp->byte_order = string_to_byte_order(p); if (!hp->format || !hp->sample_rate || !hp->precision || !hp->channels || !hp->byte_order) { - report (REPORT_ERROR, "helper_read: parse error line %d\n", line); - done (1); - } - - report (REPORT_DEBUG, "adding helper for \"%s\"\n", pat); + report(REPORT_ERROR, "helper_read: parse error line %d\n", line); + done(1); + } + + report(REPORT_DEBUG, "adding helper for \"%s\"\n", pat); if (helpers == NULL) { @@ -167,23 +172,23 @@ } } - fclose (fp); + fclose(fp); } #ifdef __STDC__ HELPER * -helper_lookup (char *sound) +helper_lookup(char *sound) #else HELPER * -helper_lookup (sound) +helper_lookup(sound) char *sound; -#endif +#endif { HELPER *hp; - + for (hp = helpers; hp; hp = hp->next) { - if (regnexec (&hp->pattern, sound, strlen (sound), 0, 0, 0) == 0) + if (regnexec(&hp->pattern, sound, strlen(sound), 0, 0, 0) == 0) { return hp; } @@ -193,40 +198,40 @@ #ifdef __STDC__ void -helper_reread (char *filename) -#else -void -helper_reread (filename) +helper_reread(char *filename) +#else +void +helper_reread(filename) char *filename; #endif { HELPER *hp, *hp_next; - - report (REPORT_DEBUG, "re-reading helpers\n"); - + + report(REPORT_DEBUG, "re-reading helpers\n"); + for (hp = helpers; hp; hp = hp_next) { hp_next = hp->next; - regfree (&hp->pattern); - free (hp->program); + regfree(&hp->pattern); + free(hp->program); } helpers = NULL; - helper_read (filename); -} - -#ifdef __STDC__ -void -helper_stat (char *filename) -#else -void -helper_stat (filename) + helper_read(filename); +} + +#ifdef __STDC__ +void +helper_stat(char *filename) +#else +void +helper_stat(filename) char *filename; #endif { - if (modified (filename, helper_read_time)) - { - helper_reread (filename); + if (modified(filename, helper_read_time)) + { + helper_reread(filename); } } diff --git a/rplayd/helper.h b/rplayd/helper.h index 0088b19..9bd5003 100644 --- a/rplayd/helper.h +++ b/rplayd/helper.h @@ -1,7 +1,7 @@ -/* $Id: helper.h,v 1.2 1998/08/13 06:13:53 boyns Exp $ */ +/* $Id: helper.h,v 1.4 1999/06/09 06:27:44 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,15 +20,21 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifndef _helper_h #define _helper_h #ifdef HAVE_HELPERS +#ifdef HAVE_RX_RXPOSIX_H +#include +#else +#ifdef HAVE_RXPOSIX_H +#include +#else #include "rxposix.h" +#endif +#endif typedef struct _helper { diff --git a/rplayd/host.c b/rplayd/host.c index b9f30be..7c276bc 100644 --- a/rplayd/host.c +++ b/rplayd/host.c @@ -1,7 +1,7 @@ -/* $Id: host.c,v 1.2 1998/08/13 06:13:54 boyns Exp $ */ +/* $Id: host.c,v 1.6 1999/06/09 06:27:44 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,6 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifdef HAVE_CONFIG_H #include "config.h" @@ -33,13 +31,21 @@ #include #endif #include "host.h" -#include "rxposix.h" #include "buffer.h" #include "misc.h" +#ifdef HAVE_RX_RXPOSIX_H +#include +#else +#ifdef HAVE_RXPOSIX_H +#include +#else +#include "rxposix.h" +#endif +#endif #ifdef AUTH -static regex_t access_read, access_write, access_execute; +static regex_t access_read, access_write, access_execute, access_monitor; BUFFER *host_list = NULL; BUFFER *b; @@ -54,10 +60,10 @@ */ #ifdef __STDC__ void -host_read (char *filename) -#else -void -host_read (filename) +host_read(char *filename) +#else +void +host_read(filename) char *filename; #endif { @@ -66,40 +72,42 @@ char expr_read[HOST_EXPR_SIZE]; char expr_write[HOST_EXPR_SIZE]; char expr_execute[HOST_EXPR_SIZE]; + char expr_monitor[HOST_EXPR_SIZE]; int error = 0; - host_read_time = time (0); - - fp = fopen (filename, "r"); + host_read_time = time(0); + + fp = fopen(filename, "r"); if (fp == NULL) { - report (REPORT_ERROR, "host_read: cannot open %s\n", filename); + report(REPORT_ERROR, "host_read: cannot open %s\n", filename); /* Don't exit anymore. Localhost will be added automatically later. */ } - b = buffer_create (); + b = buffer_create(); b->status = BUFFER_KEEP; - strcpy (b->buf, "+message=\"hosts\"\r\n"); - b->nbytes += strlen (b->buf); + strcpy(b->buf, "+message=\"hosts\"\r\n"); + b->nbytes += strlen(b->buf); host_list = b; //memset ((char *) &access_read, 0, sizeof (access_read)); //memset ((char *) &access_write, 0, sizeof (access_write)); //memset ((char *) &access_execute, 0, sizeof (access_execute)); - strcpy (expr_read, "^\\("); - strcpy (expr_write, "^\\("); - strcpy (expr_execute, "^\\("); + strcpy(expr_read, "^\\("); + strcpy(expr_write, "^\\("); + strcpy(expr_execute, "^\\("); + strcpy(expr_monitor, "^\\("); do { if (fp) { - p = fgets (buf, sizeof (buf), fp); + p = fgets(buf, sizeof(buf), fp); if (!p) { - fclose (fp); + fclose(fp); break; } } @@ -107,10 +115,10 @@ { /* rplay.hosts wasn't found and AUTH was defined in config.h. Assume that only the localhost should have access. */ - SNPRINTF (SIZE(buf,sizeof(buf)), "%s:rwx", hostaddr); - report (REPORT_NOTICE, "host_read: adding %s\n", buf); - } - + SNPRINTF(SIZE(buf, sizeof(buf)), "%s:rwx", hostaddr); + report(REPORT_NOTICE, "host_read: adding %s\n", buf); + } + switch (buf[0]) { case '#': @@ -120,14 +128,14 @@ continue; } - p = strchr (buf, '\n'); + p = strchr(buf, '\n'); if (p) { *p = '\0'; } name = buf; - perms = strchr (buf, ':'); + perms = strchr(buf, ':'); if (perms) { *perms = '\0'; @@ -138,121 +146,139 @@ perms = HOST_DEFAULT_ACCESS; } - host_insert (expr_read, expr_write, expr_execute, name, perms); + host_insert(expr_read, expr_write, expr_execute, expr_monitor, + name, perms); } while (fp); if (b->nbytes + 3 > BUFFER_SIZE) /* room for .\r\n */ { - b->next = buffer_create (); + b->next = buffer_create(); b = b->next; b->status = BUFFER_KEEP; } - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n"); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE - b->nbytes), ".\r\n"); b->nbytes += 3; - if (strlen (expr_read) == 3) - { - strcat (expr_read, "\\)"); + if (strlen(expr_read) == 3) + { + strcat(expr_read, "\\)"); } else { - expr_read[strlen (expr_read) - 1] = ')'; - } - strcat (expr_read, "$"); - if (strlen (expr_write) == 3) - { - strcat (expr_write, "\\)"); + expr_read[strlen(expr_read) - 1] = ')'; + } + strcat(expr_read, "$"); + if (strlen(expr_write) == 3) + { + strcat(expr_write, "\\)"); } else { - expr_write[strlen (expr_write) - 1] = ')'; - } - strcat (expr_write, "$"); - if (strlen (expr_execute) == 3) - { - strcat (expr_execute, "\\)"); + expr_write[strlen(expr_write) - 1] = ')'; + } + strcat(expr_write, "$"); + if (strlen(expr_execute) == 3) + { + strcat(expr_execute, "\\)"); } else { - expr_execute[strlen (expr_execute) - 1] = ')'; - } - strcat (expr_execute, "$"); - -#if 0 - report (REPORT_DEBUG, "expr_read: %s\n", expr_read); - report (REPORT_DEBUG, "expr_write: %s\n", expr_write); - report (REPORT_DEBUG, "expr_execute: %s\n", expr_execute); -#endif - - error = regncomp (&access_read, expr_read, strlen (expr_read), REG_ICASE | REG_NOSUB); + expr_execute[strlen(expr_execute) - 1] = ')'; + } + strcat(expr_execute, "$"); + if (strlen(expr_monitor) == 3) + { + strcat(expr_monitor, "\\)"); + } + else + { + expr_monitor[strlen(expr_monitor) - 1] = ')'; + } + strcat(expr_monitor, "$"); + + error = regncomp(&access_read, expr_read, strlen(expr_read), + REG_ICASE | REG_NOSUB); if (error) { - report (REPORT_ERROR, "host_read: regncomp: %d\n", error); - done (1); - } - - error= regncomp (&access_write, expr_write, strlen (expr_write), REG_ICASE | REG_NOSUB); + report(REPORT_ERROR, "host_read: regncomp: %d\n", error); + done(1); + } + + error = regncomp(&access_write, expr_write, strlen(expr_write), + REG_ICASE | REG_NOSUB); if (error) { - report (REPORT_ERROR, "host_read: regncomp: %d\n", error); - done (1); - } - - error = regncomp (&access_execute, expr_execute, strlen (expr_execute), REG_ICASE | REG_NOSUB); + report(REPORT_ERROR, "host_read: regncomp: %d\n", error); + done(1); + } + + error = regncomp(&access_execute, expr_execute, strlen(expr_execute), + REG_ICASE | REG_NOSUB); if (error) { - report (REPORT_ERROR, "host_read: regncomp: %d\n", error); - done (1); - } -} - -#ifdef __STDC__ -void -host_reread (char *filename) -#else -void -host_reread (filename) + report(REPORT_ERROR, "host_read: regncomp: %d\n", error); + done(1); + } + + error = regncomp(&access_monitor, expr_monitor, strlen(expr_monitor), + REG_ICASE | REG_NOSUB); + if (error) + { + report(REPORT_ERROR, "host_read: regncomp: %d\n", error); + done(1); + } +} + +#ifdef __STDC__ +void +host_reread(char *filename) +#else +void +host_reread(filename) char *filename; #endif { BUFFER *b, *bb; - report (REPORT_DEBUG, "re-reading hosts\n"); + report(REPORT_DEBUG, "re-reading hosts\n"); /* * Free the old host buffer list. */ - for (b = host_list; b; bb = b, b = b->next, bb->status = BUFFER_FREE, buffer_destroy (bb)) ; + for (b = host_list; b; + bb = b, b = b->next, bb->status = BUFFER_FREE, buffer_destroy(bb)) ; host_list = NULL; - host_read (filename); -} - -#ifdef __STDC__ -void -host_stat (char *filename) -#else -void -host_stat (filename) + host_read(filename); +} + +#ifdef __STDC__ +void +host_stat(char *filename) +#else +void +host_stat(filename) char *filename; #endif { - if (modified (filename, host_read_time)) - { - host_reread (filename); - } -} - -#ifdef __STDC__ -void -host_insert (char *expr_read, char *expr_write, char *expr_execute, char *name, char *perms) -#else -void -host_insert (expr_read, expr_write, expr_execute, name, perms) + if (modified(filename, host_read_time)) + { + host_reread(filename); + } +} + +#ifdef __STDC__ +void +host_insert(char *expr_read, char *expr_write, char *expr_execute, char *expr_monitor, + char *name, char *perms) +#else +void +host_insert(expr_read, expr_write, expr_execute, expr_monitor, name, perms) char *expr_read; char *expr_write; char *expr_execute; + char *expr_monitor; char *name; char *perms; #endif @@ -265,32 +291,32 @@ char *re_name = 0; char line[RPTP_MAX_LINE]; - SNPRINTF (SIZE(line,sizeof(line)), "host=%s access=%s\r\n", name, perms); - n = strlen (line); + SNPRINTF(SIZE(line, sizeof(line)), "host=%s access=%s\r\n", name, perms); + n = strlen(line); if (b->nbytes + n > BUFFER_SIZE) { - b->next = buffer_create (); + b->next = buffer_create(); b = b->next; b->status = BUFFER_KEEP; } - strcat (b->buf, line); + strcat(b->buf, line); b->nbytes += n; - if (strchr (name, '*')) - { - re_name = host_ip_to_regex (name); + if (strchr(name, '*')) + { + re_name = host_ip_to_regex(name); } else { - addr = inet_addr (name); + addr = inet_addr(name); if (addr == 0xffffffff) { - hp = gethostbyname (name); + hp = gethostbyname(name); if (hp == NULL) { - report (REPORT_NOTICE, "warning: %s unknown host\n", name); + report(REPORT_NOTICE, "warning: %s unknown host\n", name); return; } /* @@ -298,26 +324,27 @@ */ for (ap = hp->h_addr_list + 1; *ap; ap++) { - memcpy ((char *) &addr_in, *ap, hp->h_length); - host_insert (expr_read, expr_write, expr_execute, inet_ntoa (addr_in), perms); + memcpy((char *) &addr_in, *ap, hp->h_length); + host_insert(expr_read, expr_write, expr_execute, expr_monitor, + inet_ntoa(addr_in), perms); } - memcpy ((char *) &addr_in, (char *) hp->h_addr, sizeof (addr_in)); - re_name = host_ip_to_regex (inet_ntoa (addr_in)); + memcpy((char *) &addr_in, (char *) hp->h_addr, sizeof(addr_in)); + re_name = host_ip_to_regex(inet_ntoa(addr_in)); } else { - memcpy ((char *) &addr_in, (char *) &addr, sizeof (addr_in)); - re_name = host_ip_to_regex (inet_ntoa (addr_in)); + memcpy((char *) &addr_in, (char *) &addr, sizeof(addr_in)); + re_name = host_ip_to_regex(inet_ntoa(addr_in)); } /* * Add localhost automatically. */ - if (strcmp (hostaddr, "127.0.0.1") != 0 - && strcmp (inet_ntoa (addr_in), hostaddr) == 0) - { - report (REPORT_DEBUG, "host_insert: adding localhost (127.0.0.1)\n"); - host_insert (expr_read, expr_write, expr_execute, "127.0.0.1", perms); + if (strcmp(hostaddr, "127.0.0.1") != 0 + && strcmp(inet_ntoa(addr_in), hostaddr) == 0) + { + report(REPORT_DEBUG, "host_insert: adding localhost (127.0.0.1)\n"); + host_insert(expr_read, expr_write, expr_execute, expr_monitor, "127.0.0.1", perms); } } @@ -326,39 +353,44 @@ switch (*p) { case HOST_READ: - strcat (expr_read, re_name); - strcat (expr_read, "\\|"); + strcat(expr_read, re_name); + strcat(expr_read, "\\|"); break; case HOST_WRITE: - strcat (expr_write, re_name); - strcat (expr_write, "\\|"); + strcat(expr_write, re_name); + strcat(expr_write, "\\|"); break; case HOST_EXECUTE: - strcat (expr_execute, re_name); - strcat (expr_execute, "\\|"); + strcat(expr_execute, re_name); + strcat(expr_execute, "\\|"); + break; + + case HOST_MONITOR: + strcat(expr_monitor, re_name); + strcat(expr_monitor, "\\|"); break; default: - report (REPORT_ERROR, "host_insert: '%c' unknown host access permission\n", *p); - done (1); + report(REPORT_ERROR, "host_insert: '%c' unknown host access permission\n", *p); + done(1); } } if (re_name) { - free (re_name); + free(re_name); } } /* return 1 if allowed */ #ifdef __STDC__ int -host_access (struct sockaddr_in sin, char access_mode) +host_access(struct sockaddr_in sin, char access_mode) #else int -host_access (sin, access_mode) +host_access(sin, access_mode) struct sockaddr_in sin; char access_mode; #endif @@ -375,7 +407,7 @@ return 1; } - p = inet_ntoa (sin.sin_addr); + p = inet_ntoa(sin.sin_addr); switch (access_mode) { @@ -391,22 +423,26 @@ re = &access_execute; break; + case HOST_MONITOR: + re = &access_monitor; + break; + default: - report (REPORT_ERROR, "host_access: unknown access mode '%s'\n", access_mode); - done (1); - } - - n = regnexec (re, p, strlen (p), 0, 0, 0); + report(REPORT_ERROR, "host_access: unknown access mode '%s'\n", access_mode); + done(1); + } + + n = regnexec(re, p, strlen(p), 0, 0, 0); return !n; } #ifdef __STDC__ char * -host_ip_to_regex (char *p) +host_ip_to_regex(char *p) #else char * -host_ip_to_regex (p) +host_ip_to_regex(p) char *p; #endif { @@ -434,7 +470,7 @@ *q = '\0'; - return strdup (buf); + return strdup(buf); } #endif /* AUTH */ diff --git a/rplayd/host.h b/rplayd/host.h index e46ae10..170fd36 100644 --- a/rplayd/host.h +++ b/rplayd/host.h @@ -1,7 +1,7 @@ -/* $Id: host.h,v 1.2 1998/08/13 06:13:55 boyns Exp $ */ +/* $Id: host.h,v 1.3 1999/03/10 07:58:03 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -37,6 +37,7 @@ #define HOST_READ 'r' #define HOST_WRITE 'w' #define HOST_EXECUTE 'x' +#define HOST_MONITOR 'm' #define HOST_DEFAULT_ACCESS "rx" extern BUFFER *host_list; @@ -47,14 +48,15 @@ extern void host_stat (char *filename); extern char *host_ip_to_regex (char *ip_addr); extern int host_access (struct sockaddr_in sin, char access_mode); -extern void host_insert (char *expr_read, char *expr_write, char *expr_execute, char *name, char *perms); +extern void host_insert (char *expr_read, char *expr_write, char *expr_execute, + char *expr_monitor, char *name, char *perms); #else extern void host_read ( /* char *filename */ ); extern void host_reread ( /* char *filename */ ); extern void host_stat ( /* char *filename */ ); extern char *host_ip_to_regex ( /* char *ip_addr */ ); extern int host_access ( /* struct sockaddr_in sin, char access_mode */ ); -extern void host_insert ( /* char *expr_read, char *expr_write, char *expr_execute, char *name, char *perms */ ); +extern void host_insert (); #endif #endif /* AUTH */ diff --git a/rplayd/misc.c b/rplayd/misc.c index 25215f6..da18b91 100644 --- a/rplayd/misc.c +++ b/rplayd/misc.c @@ -1,7 +1,7 @@ -/* $Id: misc.c,v 1.2 1998/08/13 06:13:56 boyns Exp $ */ +/* $Id: misc.c,v 1.5 1999/03/10 07:58:03 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -45,15 +45,15 @@ #ifdef __STDC__ char * -sys_err_str (int error) -#else -char * -sys_err_str (error) +sys_err_str(int error) +#else +char * +sys_err_str(error) int error; #endif { #ifdef HAVE_STRERROR - return (char *) strerror (error); + return (char *) strerror(error); #else extern char *sys_errlist[]; return sys_errlist[error]; @@ -62,31 +62,31 @@ #ifdef __STDC__ int -udp_socket (int port) -#else -int -udp_socket (port) +udp_socket(int port) +#else +int +udp_socket(port) int port; #endif { int fd; struct sockaddr_in s; - fd = socket (AF_INET, SOCK_DGRAM, 0); + fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { - report (REPORT_ERROR, "socket: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "socket: %s\n", sys_err_str(errno)); + done(1); } s.sin_family = AF_INET; - s.sin_port = htons (port); + s.sin_port = htons(port); s.sin_addr.s_addr = INADDR_ANY; - if (bind (fd, (struct sockaddr *) &s, sizeof (s)) < 0) - { - report (REPORT_ERROR, "bind: %s\n", sys_err_str (errno)); - done (1); + if (bind(fd, (struct sockaddr *) &s, sizeof(s)) < 0) + { + report(REPORT_ERROR, "bind: %s\n", sys_err_str(errno)); + done(1); } return fd; @@ -94,10 +94,10 @@ #ifdef __STDC__ int -tcp_socket (int port) -#else -int -tcp_socket (port) +tcp_socket(int port) +#else +int +tcp_socket(port) int port; #endif { @@ -105,33 +105,33 @@ struct sockaddr_in s; int on = 1; - fd = socket (AF_INET, SOCK_STREAM, 0); + fd = socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) { - report (REPORT_ERROR, "socket: %s\n", sys_err_str (errno)); - done (1); - } - - if (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on)) < 0) - { - report (REPORT_ERROR, "setsockopt: SO_REUSEADDR: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "socket: %s\n", sys_err_str(errno)); + done(1); + } + + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)) < 0) + { + report(REPORT_ERROR, "setsockopt: SO_REUSEADDR: %s\n", sys_err_str(errno)); + done(1); } s.sin_family = AF_INET; - s.sin_port = htons (port); + s.sin_port = htons(port); s.sin_addr.s_addr = INADDR_ANY; - if (bind (fd, (struct sockaddr *) &s, sizeof (s)) < 0) - { - report (REPORT_ERROR, "bind: %s\n", sys_err_str (errno)); - done (1); - } - - if (listen (fd, 5) < 0) - { - report (REPORT_ERROR, "listen: %s\n", sys_err_str (errno)); - done (1); + if (bind(fd, (struct sockaddr *) &s, sizeof(s)) < 0) + { + report(REPORT_ERROR, "bind: %s\n", sys_err_str(errno)); + done(1); + } + + if (listen(fd, 5) < 0) + { + report(REPORT_ERROR, "listen: %s\n", sys_err_str(errno)); + done(1); } return fd; @@ -142,30 +142,30 @@ */ #ifdef __STDC__ void -fd_nonblock (int fd) +fd_nonblock(int fd) #else void -fd_nonblock (fd) +fd_nonblock(fd) int fd; #endif { int flags; - flags = fcntl (fd, F_GETFL, 0); + flags = fcntl(fd, F_GETFL, 0); if (flags < 0) { - report (REPORT_ERROR, "fd_nonblock: F_GETFL fcntl: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "fd_nonblock: F_GETFL fcntl: %s\n", sys_err_str(errno)); + done(1); } #ifdef linux flags |= O_NONBLOCK; #else flags |= FNDELAY; #endif - if (fcntl (fd, F_SETFL, flags) < 0) - { - report (REPORT_ERROR, "fd_nonblock: F_SETFL fcntl: %s\n", sys_err_str (errno)); - done (1); + if (fcntl(fd, F_SETFL, flags) < 0) + { + report(REPORT_ERROR, "fd_nonblock: F_SETFL fcntl: %s\n", sys_err_str(errno)); + done(1); } } @@ -174,48 +174,48 @@ */ #ifdef __STDC__ void -fd_block (int fd) +fd_block(int fd) #else void -fd_block (fd) +fd_block(fd) int fd; #endif { int flags; - flags = fcntl (fd, F_GETFL, 0); + flags = fcntl(fd, F_GETFL, 0); if (flags < 0) { - report (REPORT_ERROR, "fd_block: F_GETFL fcntl: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "fd_block: F_GETFL fcntl: %s\n", sys_err_str(errno)); + done(1); } #ifdef linux flags &= ~O_NONBLOCK; #else flags &= ~FNDELAY; #endif - if (fcntl (fd, F_SETFL, flags) < 0) - { - report (REPORT_ERROR, "fd_block: F_SETFL fcntl: %s\n", sys_err_str (errno)); - done (1); - } -} - -#ifdef __STDC__ -int -modified (char *filename, time_t since) -#else -int -modified (filename, since) + if (fcntl(fd, F_SETFL, flags) < 0) + { + report(REPORT_ERROR, "fd_block: F_SETFL fcntl: %s\n", sys_err_str(errno)); + done(1); + } +} + +#ifdef __STDC__ +int +modified(char *filename, time_t since) +#else +int +modified(filename, since) char *filename; time_t since; #endif { struct stat st; - if (stat (filename, &st) < 0) - { - report (REPORT_ERROR, "%s: %s\n", filename, sys_err_str (errno)); + if (stat(filename, &st) < 0) + { + report(REPORT_ERROR, "%s: %s\n", filename, sys_err_str(errno)); return 0; } @@ -224,10 +224,10 @@ #ifdef __STDC__ char * -time2string (time_t t) -#else -char * -time2string (t) +time2string(time_t t) +#else +char * +time2string(t) time_t t; #endif { @@ -246,10 +246,10 @@ if (days > 0) { - SNPRINTF (SIZE(buf,sizeof(buf)), "%d+", days); - } - - SNPRINTF (SIZE(buf + strlen (buf),sizeof(buf)), "%02d:%02d:%02d", hours, mins, secs); + SNPRINTF(SIZE(buf, sizeof(buf)), "%d+", days); + } + + SNPRINTF(SIZE(buf + strlen(buf), sizeof(buf) - strlen(buf)), "%02d:%02d:%02d", hours, mins, secs); return buf; } @@ -257,10 +257,10 @@ #ifdef __STDC__ char * -audio_format_to_string (int format) -#else -char * -audio_format_to_string (format) +audio_format_to_string(int format) +#else +char * +audio_format_to_string(format) int format; #endif { @@ -274,7 +274,7 @@ case RPLAY_FORMAT_ULINEAR_8: return "ulinear-8"; - + case RPLAY_FORMAT_LINEAR_16: return "linear-16"; @@ -282,17 +282,17 @@ return "ulinear-16"; case RPLAY_FORMAT_G721: - return "g721"; + return "g721"; case RPLAY_FORMAT_G723_3: - return "g723-3"; + return "g723-3"; case RPLAY_FORMAT_G723_5: - return "g723-5"; + return "g723-5"; case RPLAY_FORMAT_GSM: return "gsm"; - + default: return "unknown"; } @@ -300,59 +300,59 @@ #ifdef __STDC__ int -string_to_audio_format (char *string) -#else -int -string_to_audio_format (string) +string_to_audio_format(char *string) +#else +int +string_to_audio_format(string) char *string; #endif { - if (strcmp (string, "ulaw") == 0 - || strcmp (string, "u_law") == 0 - || strcmp (string, "u-law") == 0) + if (strcmp(string, "ulaw") == 0 + || strcmp(string, "u_law") == 0 + || strcmp(string, "u-law") == 0) { return RPLAY_FORMAT_ULAW; } - else if (strcmp (string, "linear-16") == 0 - || strcmp (string, "linear_16") == 0 - || strcmp (string, "linear16") == 0) + else if (strcmp(string, "linear-16") == 0 + || strcmp(string, "linear_16") == 0 + || strcmp(string, "linear16") == 0) { return RPLAY_FORMAT_LINEAR_16; } - else if (strcmp (string, "ulinear-16") == 0 - || strcmp (string, "ulinear_16") == 0 - || strcmp (string, "ulinear16") == 0) + else if (strcmp(string, "ulinear-16") == 0 + || strcmp(string, "ulinear_16") == 0 + || strcmp(string, "ulinear16") == 0) { return RPLAY_FORMAT_ULINEAR_16; } - else if (strcmp (string, "linear-8") == 0 - || strcmp (string, "linear_8") == 0 - || strcmp (string, "linear8") == 0) + else if (strcmp(string, "linear-8") == 0 + || strcmp(string, "linear_8") == 0 + || strcmp(string, "linear8") == 0) { return RPLAY_FORMAT_LINEAR_8; } - else if (strcmp (string, "ulinear-8") == 0 - || strcmp (string, "ulinear_8") == 0 - || strcmp (string, "ulinear8") == 0) + else if (strcmp(string, "ulinear-8") == 0 + || strcmp(string, "ulinear_8") == 0 + || strcmp(string, "ulinear8") == 0) { return RPLAY_FORMAT_ULINEAR_8; } - else if (strcmp (string, "g721") == 0) + else if (strcmp(string, "g721") == 0) { return RPLAY_FORMAT_G721; } - else if (strcmp (string, "g723-3") == 0 - || strcmp (string, "g723_3") == 0) + else if (strcmp(string, "g723-3") == 0 + || strcmp(string, "g723_3") == 0) { return RPLAY_FORMAT_G723_3; } - else if (strcmp (string, "g723-5") == 0 - || strcmp (string, "g723_5") == 0) + else if (strcmp(string, "g723-5") == 0 + || strcmp(string, "g723_5") == 0) { return RPLAY_FORMAT_G723_5; } - else if (strcmp (string, "gsm") == 0 - || strcmp (string, "GSM") == 0) + else if (strcmp(string, "gsm") == 0 + || strcmp(string, "GSM") == 0) { return RPLAY_FORMAT_GSM; } @@ -364,10 +364,10 @@ #ifdef __STDC__ char * -byte_order_to_string (int byte_order) -#else -char * -byte_order_to_string (byte_order) +byte_order_to_string(int byte_order) +#else +char * +byte_order_to_string(byte_order) int byte_order; #endif { @@ -386,20 +386,20 @@ #ifdef __STDC__ int -string_to_byte_order (char *string) -#else -int -string_to_byte_order (string) +string_to_byte_order(char *string) +#else +int +string_to_byte_order(string) char *string; #endif { - if (strcmp (string, "big-endian") == 0 - || strcmp (string, "big") == 0) + if (strcmp(string, "big-endian") == 0 + || strcmp(string, "big") == 0) { return RPLAY_BIG_ENDIAN; } - else if (strcmp (string, "little-endian") == 0 - || strcmp (string, "little") == 0) + else if (strcmp(string, "little-endian") == 0 + || strcmp(string, "little") == 0) { return RPLAY_LITTLE_ENDIAN; } @@ -411,10 +411,10 @@ #ifdef __STDC__ char * -storage_to_string (int storage) -#else -char * -storage_to_string (storage) +storage_to_string(int storage) +#else +char * +storage_to_string(storage) int storage; #endif { @@ -436,22 +436,22 @@ #ifdef __STDC__ int -string_to_storage (char *string) -#else -int -string_to_storage (string) +string_to_storage(char *string) +#else +int +string_to_storage(string) char *string; #endif { - if (strcmp (string, "none") == 0) + if (strcmp(string, "none") == 0) { return SOUND_STORAGE_NONE; } - else if (strcmp (string, "disk") == 0) + else if (strcmp(string, "disk") == 0) { return SOUND_STORAGE_DISK; } - else if (strcmp (string, "memory") == 0) + else if (strcmp(string, "memory") == 0) { return SOUND_STORAGE_MEMORY; } @@ -463,10 +463,10 @@ #ifdef __STDC__ char * -input_to_string (int input) -#else -char * -input_to_string (input) +input_to_string(int input) +#else +char * +input_to_string(input) int input; #endif { @@ -481,7 +481,7 @@ #ifdef HAVE_CDROM case SOUND_CDROM: return "cdrom"; -#endif /* HAVE_CDROM */ +#endif /* HAVE_CDROM */ case SOUND_VIRTUAL: return "virtual"; @@ -493,18 +493,18 @@ #ifdef __STDC__ int -string_to_input (char *string) -#else -int -string_to_input (string) +string_to_input(char *string) +#else +int +string_to_input(string) char *string; #endif { - if (strcmp (string, "file") == 0) + if (strcmp(string, "file") == 0) { return SOUND_FILE; } - else if (strcmp (string, "flow") == 0) + else if (strcmp(string, "flow") == 0) { return SOUND_FLOW; } @@ -516,39 +516,40 @@ #ifdef __STDC__ char * -audio_port_to_string (int port) -#else -char * -audio_port_to_string (port) +audio_port_to_string(int port) +#else +char * +audio_port_to_string(port) int port; #endif { static char string[128]; + int n; string[0] = '\0'; - if (BIT (port, RPLAY_AUDIO_PORT_NONE)) - { - SNPRINTF (SIZE(string+strlen(string),sizeof(string)), "none,"); - } - if (BIT (port, RPLAY_AUDIO_PORT_SPEAKER)) - { - SNPRINTF (SIZE(string+strlen(string),sizeof(string)), "speaker,"); - } - if (BIT (port, RPLAY_AUDIO_PORT_HEADPHONE)) - { - SNPRINTF (SIZE(string+strlen(string),sizeof(string)), "headphone,"); - } - if (BIT (port, RPLAY_AUDIO_PORT_LINEOUT)) - { - SNPRINTF (SIZE(string+strlen(string),sizeof(string)), "lineout,"); - } - string[strlen (string) - 1] = '\0'; + if (BIT(port, RPLAY_AUDIO_PORT_NONE)) + { + strncat(string, "none,", sizeof(string) - strlen(string)); + } + if (BIT(port, RPLAY_AUDIO_PORT_SPEAKER)) + { + strncat(string, "speaker,", sizeof(string) - strlen(string)); + } + if (BIT(port, RPLAY_AUDIO_PORT_HEADPHONE)) + { + strncat(string, "headphone,", sizeof(string) - strlen(string)); + } + if (BIT(port, RPLAY_AUDIO_PORT_LINEOUT)) + { + strncat(string, "lineout,", sizeof(string) - strlen(string)); + } + string[strlen(string) - 1] = '\0'; return string; } unsigned short -little_short (p) +little_short(p) char *p; { return (((unsigned long) (((unsigned char *) p)[1])) << 8) | @@ -556,7 +557,7 @@ } unsigned short -big_short (p) +big_short(p) char *p; { return (((unsigned long) (((unsigned char *) p)[0])) << 8) | @@ -564,7 +565,7 @@ } unsigned long -little_long (p) +little_long(p) char *p; { return (((unsigned long) (((unsigned char *) p)[3])) << 24) | @@ -574,7 +575,7 @@ } unsigned long -big_long (p) +big_long(p) char *p; { return (((unsigned long) (((unsigned char *) p)[0])) << 24) | @@ -630,7 +631,7 @@ ****************************************************************/ double -ConvertFromIeeeExtended (bytes) +ConvertFromIeeeExtended(bytes) unsigned char *bytes; /* LCN */ { double f; @@ -660,8 +661,8 @@ else { expon -= 16383; - f = ldexp (UnsignedToFloat (hiMant), expon -= 31); - f += ldexp (UnsignedToFloat (loMant), expon -= 32); + f = ldexp(UnsignedToFloat(hiMant), expon -= 31); + f += ldexp(UnsignedToFloat(loMant), expon -= 32); } } diff --git a/rplayd/misc.h b/rplayd/misc.h index 39f9411..01c0789 100644 --- a/rplayd/misc.h +++ b/rplayd/misc.h @@ -1,7 +1,7 @@ -/* $Id: misc.h,v 1.2 1998/08/13 06:13:57 boyns Exp $ */ +/* $Id: misc.h,v 1.3 1999/03/10 07:58:03 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/native.c b/rplayd/native.c index 4441131..d049004 100644 --- a/rplayd/native.c +++ b/rplayd/native.c @@ -1,7 +1,7 @@ -/* $Id: native.c,v 1.2 1998/08/13 06:13:58 boyns Exp $ */ +/* $Id: native.c,v 1.4 1999/03/10 07:58:03 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -35,56 +35,76 @@ /* Native means 16-bit signed. */ -static int ulaw_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); -static int s8_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); -static int u8_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); -static int big_s16_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); -static int big_u16_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); -static int little_s16_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); -static int little_u16_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); -static int native_to_native ( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); -static int native_to_ulaw ( /* char *native_buf, int nsamples, int nchannels */ ); -static int native_to_s8 ( /* char *native_buf, int nsamples, int nchannels */ ); -static int native_to_u8 ( /* char *native_buf, int nsamples, int nchannels */ ); -static int native_to_s16 ( /* char *native_buf, int nsamples, int nchannels */ ); -static int native_to_u16 ( /* char *native_buf, int nsamples, int nchannels */ ); -static int native_to_g721 ( /* char *native_buf, int nsamples, int nchannels */ ); -static int native_to_g723_3 ( /* char *native_buf, int nsamples, int nchannels */ ); -static int native_to_g723_5 ( /* char *native_buf, int nsamples, int nchannels */ ); -static int native_to_gsm ( /* char *native_buf, int nsamples, int nchannels */ ); +static int ulaw_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); +static int s8_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); +static int u8_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); +static int big_s16_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); +static int big_u16_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); +static int little_s16_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); +static int little_u16_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); +static int native_to_native( /* SPOOL *sp, char *native_buf, int nsamples, int nchannels */ ); +static int native_to_ulaw( /* char *native_buf, int nsamples, int nchannels */ ); +static int native_to_s8( /* char *native_buf, int nsamples, int nchannels */ ); +static int native_to_u8( /* char *native_buf, int nsamples, int nchannels */ ); +static int native_to_s16( /* char *native_buf, int nsamples, int nchannels */ ); +static int native_to_u16( /* char *native_buf, int nsamples, int nchannels */ ); +static int native_to_g721( /* char *native_buf, int nsamples, int nchannels */ ); +static int native_to_g723_3( /* char *native_buf, int nsamples, int nchannels */ ); +static int native_to_g723_5( /* char *native_buf, int nsamples, int nchannels */ ); +static int native_to_gsm( /* char *native_buf, int nsamples, int nchannels */ ); /* Setup the to and from native table. */ NATIVE_TABLE native_table[] = { - {{0, 0}, {0, 0}}, - {{s8_to_native, s8_to_native}, {native_to_s8, native_to_s8}}, - {{u8_to_native, u8_to_native}, {native_to_u8, native_to_u8}}, - {{big_s16_to_native, little_s16_to_native}, {native_to_s16, native_to_s16}}, - {{big_u16_to_native, little_u16_to_native}, {native_to_u16, native_to_u16}}, - {{ulaw_to_native, ulaw_to_native}, {native_to_ulaw, native_to_ulaw}}, -#ifdef HAVE_ADPCM - {{native_to_native, native_to_native}, {native_to_g721, native_to_g721}}, - {{native_to_native, native_to_native}, {native_to_g723_3, native_to_g723_5}}, - {{native_to_native, native_to_native}, {native_to_g723_3, native_to_g723_5}}, -#endif /* HAVE_ADPCM */ + { + {0, 0}, + {0, 0}}, + { + {s8_to_native, s8_to_native}, + {native_to_s8, native_to_s8}}, + { + {u8_to_native, u8_to_native}, + {native_to_u8, native_to_u8}}, + { + {big_s16_to_native, little_s16_to_native}, + {native_to_s16, native_to_s16}}, + { + {big_u16_to_native, little_u16_to_native}, + {native_to_u16, native_to_u16}}, + { + {ulaw_to_native, ulaw_to_native}, + {native_to_ulaw, native_to_ulaw}}, +#ifdef HAVE_ADPCM + { + {native_to_native, native_to_native}, + {native_to_g721, native_to_g721}}, + { + {native_to_native, native_to_native}, + {native_to_g723_3, native_to_g723_5}}, + { + {native_to_native, native_to_native}, + {native_to_g723_3, native_to_g723_5}}, +#endif /* HAVE_ADPCM */ #ifdef HAVE_GSM - {{native_to_native, native_to_native}, {native_to_gsm, native_to_gsm}}, -#endif /* HAVE_GSM */ + { + {native_to_native, native_to_native}, + {native_to_gsm, native_to_gsm}}, +#endif /* HAVE_GSM */ }; /* Initialize the native audio buffer. */ void -zero_native (native_buf, nsamples, nchannels) - char *native_buf; - int nsamples; - int nchannels; -{ - memset (native_buf, 0, nsamples * nchannels * 2); /* 2 == 16-bit */ +zero_native(native_buf, nsamples, nchannels) + char *native_buf; + int nsamples; + int nchannels; +{ + memset(native_buf, 0, nsamples * nchannels * 2); /* 2 == 16-bit */ } void -level (native_buf, nsamples, nchannels) +level(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -94,7 +114,7 @@ long left_max = 0, right_max = 0; /* Optimize the cases for stereo and mono output. */ - + if (nchannels == 2) /* stereo */ { while (n--) @@ -103,7 +123,7 @@ sample = (*p++ >> 7); #else sample = (*p++ * rplay_audio_volume) >> 14; -#endif +#endif if (n & 1) { if (sample > right_max) @@ -120,7 +140,8 @@ } } } - else /* mono */ + else + /* mono */ { while (n--) { @@ -128,7 +149,7 @@ sample = (*p++ >> 7); #else sample = (*p++ * rplay_audio_volume) >> 14; -#endif +#endif if (sample > left_max) { left_max = sample; @@ -145,7 +166,7 @@ #ifdef FAKE_VOLUME /* Simulate hardware volume control. */ void -fake_volume (native_buf, nsamples, nchannels) +fake_volume(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -318,63 +339,63 @@ /* ulaw */ x_to_native ( - ulaw_to_native, - linear = ulaw_to_linear (*(sp->ptr + curr_channel)) + ulaw_to_native, + linear = ulaw_to_linear(*(sp->ptr + curr_channel)) ) /* signed 8-bit */ x_to_native ( - s8_to_native, - linear = (char) *(sp->ptr + curr_channel); - linear <<= 8 + s8_to_native, + linear = (char) *(sp->ptr + curr_channel); + linear <<= 8 ) /* unsigned 8-bit */ x_to_native ( - u8_to_native, - linear = (unsigned char) *(sp->ptr + curr_channel) ^ 0x80; - linear <<= 8 + u8_to_native, + linear = (unsigned char) *(sp->ptr + curr_channel) ^ 0x80; + linear <<= 8 ) /* signed 16-bit big-endian */ x_to_native ( - big_s16_to_native, - linear = (short) (sp->ptr[curr_channel << 1] << 8 | sp->ptr[(curr_channel << 1) + 1]) + big_s16_to_native, + linear = (short) (sp->ptr[curr_channel << 1] << 8 | sp->ptr[(curr_channel << 1) + 1]) ) /* signed 16-bit little-endian */ x_to_native ( - little_s16_to_native, - linear = (short) (sp->ptr[(curr_channel << 1) + 1] << 8 | sp->ptr[curr_channel << 1]) + little_s16_to_native, + linear = (short) (sp->ptr[(curr_channel << 1) + 1] << 8 | sp->ptr[curr_channel << 1]) ) /* unsigned 16-bit big-endian */ x_to_native ( - big_u16_to_native, - linear = (short) (sp->ptr[curr_channel << 1] << 8 | sp->ptr[(curr_channel << 1) + 1]) ^ 0x8000; + big_u16_to_native, + linear = (short) (sp->ptr[curr_channel << 1] << 8 | sp->ptr[(curr_channel << 1) + 1]) ^ 0x8000; ) /* unsigned 16-bit little-endian */ x_to_native ( - little_u16_to_native, - linear = (short) (sp->ptr[(curr_channel << 1) + 1] << 8 | sp->ptr[curr_channel << 1]) ^ 0x8000; + little_u16_to_native, + linear = (short) (sp->ptr[(curr_channel << 1) + 1] << 8 | sp->ptr[curr_channel << 1]) ^ 0x8000; ) /* native to native */ x_to_native ( - native_to_native, - linear = ( *((short *) sp->ptr + curr_channel) ) -) - -static int -native_to_ulaw (native_buf, nsamples, nchannels) + native_to_native, + linear = (*((short *) sp->ptr + curr_channel)) +) + + static int + native_to_ulaw(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -385,14 +406,14 @@ while (n--) { - *to++ = linear_to_ulaw (*from++); - } - - return 0; -} - -static int -native_to_s8 (native_buf, nsamples, nchannels) + *to++ = linear_to_ulaw(*from++); + } + + return 0; +} + +static int +native_to_s8(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -410,7 +431,7 @@ } static int -native_to_u8 (native_buf, nsamples, nchannels) +native_to_u8(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -428,7 +449,7 @@ } static int -native_to_s16 (native_buf, nsamples, nchannels) +native_to_s16(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -438,7 +459,7 @@ } static int -native_to_u16 (native_buf, nsamples, nchannels) +native_to_u16(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -457,7 +478,7 @@ #ifdef HAVE_ADPCM static int -native_to_g721 (native_buf, nsamples, nchannels) +native_to_g721(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -467,7 +488,7 @@ } static int -native_to_g723_3 (native_buf, nsamples, nchannels) +native_to_g723_3(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -477,7 +498,7 @@ } static int -native_to_g723_5 (native_buf, nsamples, nchannels) +native_to_g723_5(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; @@ -489,7 +510,7 @@ #ifdef HAVE_GSM static int -native_to_gsm (native_buf, nsamples, nchannels) +native_to_gsm(native_buf, nsamples, nchannels) char *native_buf; int nsamples; int nchannels; diff --git a/rplayd/native.h b/rplayd/native.h index d28e2bc..53fed34 100644 --- a/rplayd/native.h +++ b/rplayd/native.h @@ -1,7 +1,7 @@ -/* $Id: native.h,v 1.2 1998/08/13 06:14:00 boyns Exp $ */ +/* $Id: native.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/rplayd.c b/rplayd/rplayd.c index c1f544a..cf3596a 100644 --- a/rplayd/rplayd.c +++ b/rplayd/rplayd.c @@ -1,7 +1,7 @@ -/* $Id: rplayd.c,v 1.2 1998/08/13 06:14:01 boyns Exp $ */ +/* $Id: rplayd.c,v 1.8 1999/03/10 07:58:04 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,6 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifdef HAVE_CONFIG_H #include "config.h" @@ -105,7 +103,7 @@ #ifdef AUTH int auth_enabled = 1; /* Host authentication. (--auth, --no-auth) */ #endif /* AUTH */ -int rplay_priority_threshold = RPLAY_DEFAULT_PRIORITY; /* Default priority level allowed. */ +int rplay_priority_threshold = RPLAY_DEFAULT_PRIORITY; /* Default priority level allowed. */ /* Global audio-specific variables */ char *rplay_audio_device = RPLAY_AUDIO_DEVICE; /* Which audio device to use. */ @@ -152,12 +150,17 @@ int rplay_audio_left_level = 0; int rplay_audio_right_level = 0; -static int rplay_audio_timeout = RPLAY_AUDIO_TIMEOUT; +static int monitor_total_bytes = 176400 * 5; /* 5 seconds */ +static int monitor_update = 0; +int monitor_count = 0; +BUFFER *monitor_buffers = NULL; + +int rplay_audio_timeout = RPLAY_AUDIO_TIMEOUT; static int rplay_audio_flush_timeout = RPLAY_AUDIO_FLUSH_TIMEOUT; -static int rplayd_timeout = RPLAYD_TIMEOUT; /* seconds */ -static int sound_cleanup_timeout = 10; /* seconds */ -static int buffer_cleanup_timeout = 10; /* seconds */ -static int spool_cleanup_timeout = 0; /* seconds -- disabled for now */ +static int rplayd_timeout = RPLAYD_TIMEOUT; /* seconds */ +static int sound_cleanup_timeout = 10; /* seconds */ +static int buffer_cleanup_timeout = 10; /* seconds */ +static int spool_cleanup_timeout = 0; /* seconds -- disabled for now */ static int need_to_reset = 0; static char *progname; static char *sounds_file = NULL; @@ -203,17 +206,17 @@ static struct option longopts[] = { {"audio-device", required_argument, NULL, 'A'}, -#ifndef HAVE_OSS +#ifndef HAVE_OSS {"audio-bufsize", required_argument, NULL, 'b'}, -#endif /* !HAVE_OSS */ +#endif /* !HAVE_OSS */ {"audio-bits", required_argument, NULL, 'B'}, {"audio-channels", required_argument, NULL, 1}, {"audio-close", required_argument, NULL, 'c'}, {"audio-flush", required_argument, NULL, 'F'}, {"audio-format", required_argument, NULL, 3}, -#ifdef HAVE_OSS +#ifdef HAVE_OSS {"audio-fragsize", required_argument, NULL, 18}, -#endif /* HAVE_OSS */ +#endif /* HAVE_OSS */ {"audio-info", required_argument, NULL, 'i'}, {"audio-info-ulaw", no_argument, NULL, 13}, {"audio-match", no_argument, &rplay_audio_match, 1}, @@ -227,12 +230,12 @@ {"cache-directory", required_argument, NULL, 'D'}, {"cache-remove", no_argument, NULL, 12}, {"cache-size", required_argument, NULL, 's'}, -#ifdef HAVE_CDROM +#ifdef HAVE_CDROM {"cdrom0", required_argument, NULL, 14}, {"cdrom1", required_argument, NULL, 15}, {"cdrom2", required_argument, NULL, 16}, {"cdrom3", required_argument, NULL, 17}, -#endif /* HAVE_CDROM */ +#endif /* HAVE_CDROM */ {"conf", required_argument, NULL, 'C'}, {"connection-timeout", required_argument, NULL, 'T'}, {"debug", no_argument, NULL, 'd'}, @@ -240,9 +243,9 @@ {"forward", required_argument, NULL, 'f'}, {"group", required_argument, NULL, 21}, {"help", no_argument, NULL, 2}, -#ifdef HAVE_HELPERS +#ifdef HAVE_HELPERS {"helpers", required_argument, NULL, 20}, -#endif /* HAVE_HELPERS */ +#endif /* HAVE_HELPERS */ #ifdef AUTH {"hosts", required_argument, NULL, 'H'}, #endif @@ -277,33 +280,33 @@ #ifdef sun #ifdef __STDC__ -extern int gethostname (char *name, int namelen); -#else -extern int gethostname ( /* char *name, int namelen */ ); -#endif -#endif - -extern char *ctime (); +extern int gethostname(char *name, int namelen); +#else +extern int gethostname( /* char *name, int namelen */ ); +#endif +#endif + +extern char *ctime(); #ifdef __STDC__ -static void do_option_file (char *option_file); -static void do_option (int option_value); -#else -static void do_option_file ( /* char *option_file */ ); -static void do_option ( /* int option_value */ ); -#endif -static void doit (); -static void handle_signals (); -static void handle_sighup (); -static void handle_sigint (); -static void handle_sigchld (); -static void reset (); -static void audio_test (); +static void do_option_file(char *option_file); +static void do_option(int option_value); +#else +static void do_option_file( /* char *option_file */ ); +static void do_option( /* int option_value */ ); +#endif +static void doit(); +static void handle_signals(); +static void handle_sighup(); +static void handle_sigint(); +static void handle_sigchld(); +static void reset(); +static void audio_test(); #if defined(HAVE_CDROM) || defined(HAVE_HELPERS) #ifdef __STDC__ -void rplayd_pipe_read (/* fd_set *rfds */); -#else -void rplayd_pipe_read (/* fd_set *rfds */); +void rplayd_pipe_read( /* fd_set *rfds */ ); +#else +void rplayd_pipe_read( /* fd_set *rfds */ ); #endif #endif @@ -314,9 +317,9 @@ #endif #ifdef __STDC__ -main (int argc, char **argv) -#else -main (argc, argv) +main(int argc, char **argv) +#else +main(argc, argv) int argc; char **argv; #endif @@ -326,20 +329,20 @@ struct in_addr addr; char *rplaydrc; - starttime = time (0); + starttime = time(0); progname = argv[0]; - servers_file = tilde_expand (RPLAY_SERVERS); -#ifdef HAVE_HELPERS - helpers_file = tilde_expand (RPLAY_HELPERS); -#endif /* HAVE_HELPERS */ - sounds_file = tilde_expand (RPLAY_CONF); + servers_file = tilde_expand(RPLAY_SERVERS); +#ifdef HAVE_HELPERS + helpers_file = tilde_expand(RPLAY_HELPERS); +#endif /* HAVE_HELPERS */ + sounds_file = tilde_expand(RPLAY_CONF); #ifdef AUTH - hosts_file = tilde_expand (RPLAY_HOSTS); + hosts_file = tilde_expand(RPLAY_HOSTS); #endif /* AUTH */ - cache_dir = tilde_expand (RPLAY_CACHE); - log_file = tilde_expand (RPLAY_LOG); + cache_dir = tilde_expand(RPLAY_CACHE); + log_file = tilde_expand(RPLAY_LOG); #ifdef RPLAYD_ALWAYS_LOG report_level = RPLAYD_LOG_LEVEL; @@ -352,61 +355,61 @@ #endif /* Parse RPLAYDRC. */ - rplaydrc = tilde_expand (RPLAYDRC); + rplaydrc = tilde_expand(RPLAYDRC); if (rplaydrc) { struct stat st; - - if (stat (rplaydrc, &st) == 0 && S_ISREG (st.st_mode)) - { - do_option_file (rplaydrc); - } - - free (rplaydrc); - } - + + if (stat(rplaydrc, &st) == 0 && S_ISREG(st.st_mode)) + { + do_option_file(rplaydrc); + } + + free(rplaydrc); + } + /* Parse command line options. */ - while ((c = getopt_long (argc, argv, OPTIONS, longopts, 0)) != -1) - { - do_option (c); + while ((c = getopt_long(argc, argv, OPTIONS, longopts, 0)) != -1) + { + do_option(c); } if (audio_test_mode) { report_level = 0; /* don't want debug output */ - audio_test (); - done (0); + audio_test(); + done(0); } if (run_as_group && *run_as_group) { - struct group *gr = getgrnam (run_as_group); + struct group *gr = getgrnam(run_as_group); if (!gr) { - fprintf (stderr, "Unknown group `%s'.\n", run_as_group); - done (1); - } - if (setgid (gr->gr_gid) < 0) - { - report (REPORT_ERROR, "setgid: %s\n", sys_err_str (errno)); - done (1); - } - report (REPORT_DEBUG, "running as group %s (%d)\n", run_as_group, gr->gr_gid); + fprintf(stderr, "Unknown group `%s'.\n", run_as_group); + done(1); + } + if (setgid(gr->gr_gid) < 0) + { + report(REPORT_ERROR, "setgid: %s\n", sys_err_str(errno)); + done(1); + } + report(REPORT_DEBUG, "running as group %s (%d)\n", run_as_group, gr->gr_gid); } if (run_as_user && *run_as_user) { - struct passwd *pw = getpwnam (run_as_user); + struct passwd *pw = getpwnam(run_as_user); if (!pw) { - fprintf (stderr, "Unknown user `%s'.\n", run_as_user); - done (1); - } - if (setuid (pw->pw_uid) < 0) - { - report (REPORT_ERROR, "setuid: %s\n", sys_err_str (errno)); - done (1); - } - report (REPORT_DEBUG, "running as user %s (%d)\n", run_as_user, pw->pw_uid); + fprintf(stderr, "Unknown user `%s'.\n", run_as_user); + done(1); + } + if (setuid(pw->pw_uid) < 0) + { + report(REPORT_ERROR, "setuid: %s\n", sys_err_str(errno)); + done(1); + } + report(REPORT_DEBUG, "running as user %s (%d)\n", run_as_user, pw->pw_uid); } if (debug) @@ -418,51 +421,51 @@ /* Fork */ if (do_fork) { - int pid = fork (); + int pid = fork(); if (pid != 0) { - exit (0); - } - } - - if (gethostname (hostname, sizeof (hostname)) < 0) - { - report (REPORT_ERROR, "gethostname: %s\n", sys_err_str (errno)); - done (1); - } - - hp = gethostbyname (hostname); + exit(0); + } + } + + if (gethostname(hostname, sizeof(hostname)) < 0) + { + report(REPORT_ERROR, "gethostname: %s\n", sys_err_str(errno)); + done(1); + } + + hp = gethostbyname(hostname); if (hp == NULL) { - report (REPORT_ERROR, "gethostbyname: cannot resolve hostname: %s\n", hostname); - done (1); - } - memcpy ((char *) &addr, (char *) hp->h_addr, hp->h_length); - hostaddr = strdup (inet_ntoa (addr)); - - rplayd_pid = getpid (); - - handle_signals (); - + report(REPORT_ERROR, "gethostbyname: cannot resolve hostname: %s\n", hostname); + done(1); + } + memcpy((char *) &addr, (char *) hp->h_addr, hp->h_length); + hostaddr = strdup(inet_ntoa(addr)); + + rplayd_pid = getpid(); + + handle_signals(); + /* Call all the initialization routines. */ - rplayd_init (); + rplayd_init(); #ifdef HAVE_HELPERS - helper_read (helpers_file); + helper_read(helpers_file); #endif /* HAVE_HELPERS */ - sound_read (sounds_file); - cache_init (cache_dir); - cache_read (); + sound_read(sounds_file); + cache_init(cache_dir); + cache_read(); #ifdef AUTH - host_read (hosts_file); + host_read(hosts_file); #endif /* AUTH */ - server_read (servers_file); - spool_init (); - timer_init (); - if (rplayd_audio_init () < 0) + server_read(servers_file); + spool_init(); + timer_init(); + if (rplayd_audio_init() < 0) { /* Disable audio. */ audio_enabled = 0; - report (REPORT_DEBUG, "audio disabled\n"); + report(REPORT_DEBUG, "audio disabled\n"); } else { @@ -478,27 +481,27 @@ } #ifdef AUTH - report (REPORT_DEBUG, "authentication %s\n", auth_enabled ? "enabled" : "disabled"); -#else - report (REPORT_DEBUG, "no authentication\n"); + report(REPORT_DEBUG, "authentication %s\n", auth_enabled ? "enabled" : "disabled"); +#else + report(REPORT_DEBUG, "no authentication\n"); #endif if (forward) { - report (REPORT_DEBUG, "forwarding sounds to %s\n", forward); - } - - report (REPORT_DEBUG, "%s rplayd %s ready.\n", hostname, RPLAY_VERSION); - - doit (); + report(REPORT_DEBUG, "forwarding sounds to %s\n", forward); + } + + report(REPORT_DEBUG, "%s rplayd %s ready.\n", hostname, RPLAY_VERSION); + + doit(); } #ifdef __STDC__ static void -do_option_file (char *option_file) +do_option_file(char *option_file) #else static void -do_option_file (option_file) +do_option_file(option_file) char *option_file; #endif { @@ -506,23 +509,23 @@ char buf[BUFSIZ], *p; FILE *fp; int saved_optind; - char *argv[1024]; /* that should be enough */ + char *argv[1024]; /* that should be enough */ int argc = 0; - fp = fopen (option_file, "r"); + fp = fopen(option_file, "r"); if (fp == NULL) { - report (REPORT_ERROR, "cannot open `%s'.\n", option_file); + report(REPORT_ERROR, "cannot open `%s'.\n", option_file); return; } - + argv[argc++] = progname; - tilde_additional_prefixes = (char **) xmalloc (2 * sizeof (char *)); + tilde_additional_prefixes = (char **) xmalloc(2 * sizeof(char *)); tilde_additional_prefixes[0] = "=~"; tilde_additional_prefixes[1] = (char *) NULL; - - while (fgets (buf, sizeof (buf), fp)) + + while (fgets(buf, sizeof(buf), fp)) { switch (buf[0]) { @@ -532,25 +535,25 @@ case '\t': continue; } - + first = 1; - while (p = (char *) strtok (first ? buf : NULL, " \t\n")) + while (p = (char *) strtok(first ? buf : NULL, " \t\n")) { first = 0; - argv[argc++] = tilde_expand (p); - } - } - - fclose (fp); - free ((char *) tilde_additional_prefixes); + argv[argc++] = tilde_expand(p); + } + } + + fclose(fp); + free((char *) tilde_additional_prefixes); tilde_additional_prefixes = NULL; argv[argc] = NULL; saved_optind = optind; /* save optind */ - optind = 1; /* reset optind */ - while ((c = getopt_long (argc, argv, OPTIONS, longopts, 0)) != -1) - { - do_option (c); + optind = 1; /* reset optind */ + while ((c = getopt_long(argc, argv, OPTIONS, longopts, 0)) != -1) + { + do_option(c); } optind = saved_optind; /* restore optind */ } @@ -558,10 +561,10 @@ #ifdef __STDC__ static void -do_option (int option_value) +do_option(int option_value) #else static void -do_option (option_value) +do_option(option_value) int option_value; #endif { @@ -578,83 +581,83 @@ case 1: /* --audio-channels */ - optional_channels = atoi (optarg); + optional_channels = atoi(optarg); if (optional_channels != 1 && optional_channels != 2) { - usage (); - done (1); + usage(); + done(1); } break; case 2: /* --help */ - usage (); - done (1); + usage(); + done(1); case 3: /* --audio-format */ - optional_format = string_to_audio_format (optarg); + optional_format = string_to_audio_format(optarg); if (optional_format < 0) { - usage (); - done (1); + usage(); + done(1); } break; case 4: /* --memory-cache-size */ - sound_cache_max_size = atoi (optarg); + sound_cache_max_size = atoi(optarg); break; case 5: /* --memory-cache-sound-size */ - sound_cache_max_sound_size = atoi (optarg); + sound_cache_max_sound_size = atoi(optarg); break; case 6: /* --port or --rplay-port */ - rplay_port = atoi (optarg); + rplay_port = atoi(optarg); break; case 7: /* --rptp-port */ - rptp_port = atoi (optarg); + rptp_port = atoi(optarg); break; #ifdef OTHER_RPLAY_PORTS case 8: /* --other-rplay-port */ - other_rplay_port = atoi (optarg); + other_rplay_port = atoi(optarg); break; case 9: /* --other-rptp-port */ - other_rptp_port = atoi (optarg); + other_rptp_port = atoi(optarg); break; #endif /* OTHER_RPTP_PORTS */ case 10: /* --audio-port */ - if (strstr (optarg, "none")) - { - SET_BIT (optional_port, RPLAY_AUDIO_PORT_NONE); - } - if (strstr (optarg, "speaker")) - { - SET_BIT (optional_port, RPLAY_AUDIO_PORT_SPEAKER); - } - if (strstr (optarg, "headphone")) - { - SET_BIT (optional_port, RPLAY_AUDIO_PORT_HEADPHONE); - } - if (strstr (optarg, "lineout")) - { - SET_BIT (optional_port, RPLAY_AUDIO_PORT_LINEOUT); + if (strstr(optarg, "none")) + { + SET_BIT(optional_port, RPLAY_AUDIO_PORT_NONE); + } + if (strstr(optarg, "speaker")) + { + SET_BIT(optional_port, RPLAY_AUDIO_PORT_SPEAKER); + } + if (strstr(optarg, "headphone")) + { + SET_BIT(optional_port, RPLAY_AUDIO_PORT_HEADPHONE); + } + if (strstr(optarg, "lineout")) + { + SET_BIT(optional_port, RPLAY_AUDIO_PORT_LINEOUT); } break; case 11: - do_option_file (optarg); + do_option_file(optarg); break; case 12: /* --cache-remove */ @@ -668,55 +671,55 @@ optional_channels = 1; break; -#ifdef HAVE_CDROM +#ifdef HAVE_CDROM case 14: /* cdrom0 */ for (i = 0; i < MAX_CDROMS; i++) { - if (strncmp (cdrom_table[i].name, "cdrom0", 6) == 0) + if (strncmp(cdrom_table[i].name, "cdrom0", 6) == 0) { cdrom_table[i].device = optarg; break; } - } + } break; case 15: /* cdrom1 */ for (i = 0; i < MAX_CDROMS; i++) { - if (strncmp (cdrom_table[i].name, "cdrom1", 6) == 0) + if (strncmp(cdrom_table[i].name, "cdrom1", 6) == 0) { cdrom_table[i].device = optarg; break; } - } - break; - + } + break; + case 16: /* cdrom2 */ for (i = 0; i < MAX_CDROMS; i++) { - if (strncmp (cdrom_table[i].name, "cdrom2", 6) == 0) + if (strncmp(cdrom_table[i].name, "cdrom2", 6) == 0) { cdrom_table[i].device = optarg; break; } - } + } break; case 17: /* cdrom3 */ for (i = 0; i < MAX_CDROMS; i++) { - if (strncmp (cdrom_table[i].name, "cdrom3", 6) == 0) + if (strncmp(cdrom_table[i].name, "cdrom3", 6) == 0) { cdrom_table[i].device = optarg; break; } - } + } break; #endif /* HAVE_CDROM */ #ifdef HAVE_OSS case 18: /* audio-fragsize */ - optional_fragsize = atoi (optarg); + optional_fragsize = atoi(optarg); break; #endif /* HAVE_OSS */ @@ -740,23 +743,23 @@ rplay_audio_device = optarg; break; -#ifndef HAVE_OSS +#ifndef HAVE_OSS case 'b': - rplay_audio_bufsize = atoi (optarg); + rplay_audio_bufsize = atoi(optarg); break; #endif /* !HAVE_OSS */ case 'B': - optional_precision = atoi (optarg); + optional_precision = atoi(optarg); if (optional_precision != 8 && optional_precision != 16) { - usage (); - done (1); + usage(); + done(1); } break; case 'c': - rplay_audio_timeout = atoi (optarg); + rplay_audio_timeout = atoi(optarg); break; case 'C': @@ -777,7 +780,7 @@ break; case 'F': - rplay_audio_flush_timeout = atoi (optarg); + rplay_audio_flush_timeout = atoi(optarg); break; #ifdef AUTH @@ -788,19 +791,23 @@ case 'i': /* --audio-info, --info */ /* Example: ulaw,8000,8,1 */ - p = strtok (optarg, ", "); - if (p) optional_format = string_to_audio_format (p); - p = strtok (NULL, ","); - if (p) optional_sample_rate = atoi (p); - p = strtok (NULL, ","); - if (p) optional_precision = atoi (p); - p = strtok (NULL, ","); - if (p) optional_channels = atoi (p); - break; - + p = strtok(optarg, ", "); + if (p) + optional_format = string_to_audio_format(p); + p = strtok(NULL, ","); + if (p) + optional_sample_rate = atoi(p); + p = strtok(NULL, ","); + if (p) + optional_precision = atoi(p); + p = strtok(NULL, ","); + if (p) + optional_channels = atoi(p); + break; + case 'l': logging++; - report_level = atoi (optarg); + report_level = atoi(optarg); break; case 'L': @@ -816,15 +823,15 @@ break; case 'r': - rplay_audio_rate = atoi (optarg); + rplay_audio_rate = atoi(optarg); break; case 'R': - optional_sample_rate = atoi (optarg); + optional_sample_rate = atoi(optarg); break; case 's': - cache_max_size = atoi (optarg); + cache_max_size = atoi(optarg); break; case 'S': @@ -832,21 +839,21 @@ break; case 't': - rplayd_timeout = atoi (optarg); + rplayd_timeout = atoi(optarg); break; case 'T': - rptp_timeout = atoi (optarg); + rptp_timeout = atoi(optarg); break; case 'v': - printf ("rplay %s\n", RPLAY_VERSION); - done (0); + printf("rplay %s\n", RPLAY_VERSION); + done(0); break; default: - fprintf (stderr, "Try `%s --help' for more information.\n", progname); - done (1); + fprintf(stderr, "Try `%s --help' for more information.\n", progname); + done(1); } } @@ -854,7 +861,7 @@ * The main loop of rplayd. */ static void -doit () +doit() { int nfds, icount = 0; int idle = 1; @@ -862,22 +869,22 @@ fd_set rfds, wfds; SPOOL *sp; /* Initialize the fd_sets before starting. */ - FD_ZERO (&rfds); - FD_ZERO (&wfds); - FD_ZERO (&read_mask); - FD_ZERO (&write_mask); - FD_SET (rplay_fd, &read_mask); - FD_SET (rptp_fd, &read_mask); + FD_ZERO(&rfds); + FD_ZERO(&wfds); + FD_ZERO(&read_mask); + FD_ZERO(&write_mask); + FD_SET(rplay_fd, &read_mask); + FD_SET(rptp_fd, &read_mask); #ifdef OTHER_RPLAY_PORTS - FD_SET (other_rplay_fd, &read_mask); - FD_SET (other_rptp_fd, &read_mask); + FD_SET(other_rplay_fd, &read_mask); + FD_SET(other_rptp_fd, &read_mask); #endif for (;;) { if (need_to_reset) { - reset (); + reset(); need_to_reset = 0; } @@ -887,13 +894,13 @@ { if (!spool_nplaying) { - timer_stop (); + timer_stop(); rplay_audio_size = 0; if (rplay_audio_flush_timeout == -1) { - report (REPORT_DEBUG, "flushing %s\n", rplay_audio_device); - rplay_audio_flush (); + report(REPORT_DEBUG, "flushing %s\n", rplay_audio_device); + rplay_audio_flush(); } /* Notify the final zero levels. */ @@ -901,20 +908,20 @@ rplay_audio_right_level = 0; if (connection_want_level_notify) { - connection_notify (0, NOTIFY_LEVEL, 1); /* force notification */ + connection_notify(0, NOTIFY_LEVEL, 1); /* force notification */ } } else { /* keep trying to open */ - if (!rplay_audio_isopen ()) + if (!rplay_audio_isopen()) { - rplay_audio_open (); + rplay_audio_open(); } - + if (connection_level_notify) { - connection_notify (0, NOTIFY_LEVEL, 0); + connection_notify(0, NOTIFY_LEVEL, 0); connection_level_notify = 0; } @@ -922,36 +929,43 @@ { if (sp->notify_position) { - connection_notify (0, NOTIFY_POSITION, sp); + connection_notify(0, NOTIFY_POSITION, sp); sp->notify_position = 0; } + } + + if (monitor_count && monitor_update) + { + connection_monitor_continue(); + monitor_update = 0; } } } else if (spool_nplaying) { - if (!rplay_audio_isopen ()) + if (!rplay_audio_isopen()) { - report (REPORT_DEBUG, "opening %s\n", rplay_audio_device); - if (rplay_audio_open () < 0) + report(REPORT_DEBUG, "opening %s\n", rplay_audio_device); + if (rplay_audio_open() < 0) { - report (REPORT_ERROR, "rplay_audio_open: %s: %s (will keep trying)\n", - rplay_audio_device, sys_err_str (errno)); + report(REPORT_ERROR, + "rplay_audio_open: %s: %s (will keep trying)\n", + rplay_audio_device, sys_err_str(errno)); } } - /* start the time even if the audio device isn't open */ - timer_start (curr_rate); + /* start the timer even if the audio device isn't open */ + timer_start(curr_rate); } if (spool_needs_update) { - spool_update (); + spool_update(); } } if (connections) { - connection_check_timeout (); + connection_check_timeout(); } rfds = read_mask; @@ -959,30 +973,30 @@ if (idle) { - report (REPORT_DEBUG, "entering idle mode\n"); + report(REPORT_DEBUG, "entering idle mode\n"); select_timeout.tv_sec = rplayd_timeout; select_timeout.tv_usec = 0; #ifdef __hpux - nfds = select (FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0, - rplayd_timeout ? &select_timeout : 0); -#else - nfds = select (FD_SETSIZE, &rfds, &wfds, 0, - rplayd_timeout ? &select_timeout : 0); + nfds = select(FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0, + rplayd_timeout ? &select_timeout : 0); +#else + nfds = select(FD_SETSIZE, &rfds, &wfds, 0, + rplayd_timeout ? &select_timeout : 0); #endif if (nfds == 0) { - done (0); + done(0); } #ifdef AUTO_REREAD #ifdef HAVE_HELPERS - helper_stat (helpers_file); -#endif /* HAVE_HELPERS */ - sound_stat (sounds_file); + helper_stat(helpers_file); +#endif /* HAVE_HELPERS */ + sound_stat(sounds_file); #ifdef AUTH - host_stat (hosts_file); + host_stat(hosts_file); #endif /* AUTH */ - server_stat (servers_file); + server_stat(servers_file); #endif /* AUTO_REREAD */ idle = 0; @@ -993,11 +1007,11 @@ select_timeout.tv_sec = 1; select_timeout.tv_usec = 0; #ifdef __hpux - nfds = select (FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0, - &select_timeout); -#else - nfds = select (FD_SETSIZE, &rfds, &wfds, 0, - &select_timeout); + nfds = select(FD_SETSIZE, (int *) &rfds, (int *) &wfds, 0, + &select_timeout); +#else + nfds = select(FD_SETSIZE, &rfds, &wfds, 0, + &select_timeout); #endif } @@ -1006,8 +1020,8 @@ case -1: if (errno != EINTR && errno != EAGAIN) { - report (REPORT_ERROR, "select: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "select: %s\n", sys_err_str(errno)); + done(1); } break; @@ -1020,61 +1034,75 @@ if (!spool_nplaying && !rplay_audio_size) { if (audio_enabled && rplay_audio_timeout && icount == rplay_audio_timeout - && rplay_audio_isopen ()) + && rplay_audio_isopen()) { - report (REPORT_DEBUG, "closing %s\n", rplay_audio_device); - rplay_audio_close (); + report(REPORT_DEBUG, "closing %s\n", rplay_audio_device); + rplay_audio_close(); } if (audio_enabled && rplay_audio_flush_timeout > 0 - && icount == rplay_audio_flush_timeout && rplay_audio_isopen ()) + && icount == rplay_audio_flush_timeout && rplay_audio_isopen()) { - report (REPORT_DEBUG, "flushing %s\n", rplay_audio_device); - rplay_audio_flush (); + report(REPORT_DEBUG, "flushing %s\n", rplay_audio_device); + rplay_audio_flush(); } if (sound_cleanup_timeout && icount == sound_cleanup_timeout) { - sound_cleanup (); + sound_cleanup(); } if (buffer_cleanup_timeout && icount == buffer_cleanup_timeout) { - buffer_cleanup (); + buffer_cleanup(); } if (spool_cleanup_timeout && icount == spool_cleanup_timeout) { - spool_cleanup (); + spool_cleanup(); } - + /* * See if rplayd should enter idle mode. * Idle mode should only be entered when *nothing* * is happening. */ if (icount >= rplay_audio_timeout - && connection_idle () + && connection_idle() && icount >= rplay_audio_flush_timeout && icount >= sound_cleanup_timeout && icount >= buffer_cleanup_timeout && icount >= spool_cleanup_timeout) { idle = 1; + if (monitor_buffers) + { + if (!monitor_count) + { + report(REPORT_DEBUG, "cleaning monitor buffers - %d bytes\n", + monitor_total_bytes); + monitor_cleanup(); + } + else + { + report(REPORT_DEBUG, "keeping monitor buffers - %d bytes\n", + monitor_total_bytes); + } + } } } break; default: - if (FD_ISSET (rplay_fd, &rfds)) + if (FD_ISSET(rplay_fd, &rfds)) { - rplayd_read (rplay_fd); + rplayd_read(rplay_fd); } #ifdef OTHER_RPLAY_PORTS - if (FD_ISSET (other_rplay_fd, &rfds)) + if (FD_ISSET(other_rplay_fd, &rfds)) { - rplayd_read (other_rplay_fd); + rplayd_read(other_rplay_fd); } #endif - connection_update (&rfds, &wfds); + connection_update(&rfds, &wfds); #if defined(HAVE_CDROM) || defined(HAVE_HELPERS) - rplayd_pipe_read (&rfds); + rplayd_pipe_read(&rfds); #endif icount = 0; break; @@ -1087,7 +1115,7 @@ * Set up the sockets to receive RPLAY packets and RPTP connections. */ void -rplayd_init () +rplayd_init() { struct sockaddr_in s; struct servent *sp; @@ -1097,92 +1125,92 @@ rplay_fd = 0; #ifdef OTHER_RPLAY_PORTS /* Try to figure out which port is being used by inetd. */ - sp = getservbyname ("rplay", "udp"); + sp = getservbyname("rplay", "udp"); if (sp == NULL) { - report (REPORT_ERROR, "can't find rplay/udp service\n"); - done (1); - } - - if (ntohs (sp->s_port) == RPLAY_PORT) - { - other_rplay_fd = udp_socket (other_rplay_port ? other_rplay_port : OLD_RPLAY_PORT); + report(REPORT_ERROR, "can't find rplay/udp service\n"); + done(1); + } + + if (ntohs(sp->s_port) == RPLAY_PORT) + { + other_rplay_fd = udp_socket(other_rplay_port ? other_rplay_port : OLD_RPLAY_PORT); } else { - other_rplay_fd = udp_socket (other_rplay_port ? other_rplay_port : RPLAY_PORT); + other_rplay_fd = udp_socket(other_rplay_port ? other_rplay_port : RPLAY_PORT); } #endif } else { - rplay_fd = udp_socket (rplay_port ? rplay_port : RPLAY_PORT); + rplay_fd = udp_socket(rplay_port ? rplay_port : RPLAY_PORT); #ifdef OTHER_RPLAY_PORTS - other_rplay_fd = udp_socket (other_rplay_port ? other_rplay_port : OLD_RPLAY_PORT); + other_rplay_fd = udp_socket(other_rplay_port ? other_rplay_port : OLD_RPLAY_PORT); #endif } /* * Make the RPLAY sockets non-blocking. */ - fd_nonblock (rplay_fd); + fd_nonblock(rplay_fd); #ifdef OTHER_RPLAY_PORTS - fd_nonblock (other_rplay_fd); + fd_nonblock(other_rplay_fd); #endif if (forward) { - unsigned long addr = inet_addr (forward); - - memset ((char *) &s, 0, sizeof (s)); + unsigned long addr = inet_addr(forward); + + memset((char *) &s, 0, sizeof(s)); s.sin_family = AF_INET; - s.sin_port = htons (RPLAY_PORT); + s.sin_port = htons(RPLAY_PORT); if (addr == 0xffffffff) { - struct hostent *hp = gethostbyname (forward); + struct hostent *hp = gethostbyname(forward); if (hp == NULL) { - report (REPORT_ERROR, "gethostbyname: %s unknown host\n", forward); - done (1); + report(REPORT_ERROR, "gethostbyname: %s unknown host\n", forward); + done(1); } - memcpy ((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); + memcpy((char *) &s.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); } else { - memcpy ((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof (addr)); - } - - forward_fd = socket (AF_INET, SOCK_DGRAM, 0); + memcpy((char *) &s.sin_addr.s_addr, (char *) &addr, sizeof(addr)); + } + + forward_fd = socket(AF_INET, SOCK_DGRAM, 0); if (forward_fd < 0) { - report (REPORT_ERROR, "socket: %s\n", sys_err_str (errno)); - done (1); - } - - if (connect (forward_fd, (struct sockaddr *) &s, sizeof (s)) < 0) - { - report (REPORT_ERROR, "connect: %s\n", sys_err_str (errno)); - done (1); - } - } - - rptp_fd = tcp_socket (rptp_port ? rptp_port : RPTP_PORT); + report(REPORT_ERROR, "socket: %s\n", sys_err_str(errno)); + done(1); + } + + if (connect(forward_fd, (struct sockaddr *) &s, sizeof(s)) < 0) + { + report(REPORT_ERROR, "connect: %s\n", sys_err_str(errno)); + done(1); + } + } + + rptp_fd = tcp_socket(rptp_port ? rptp_port : RPTP_PORT); #ifdef OTHER_RPLAY_PORTS - other_rptp_fd = tcp_socket (other_rptp_port ? other_rptp_port : OLD_RPTP_PORT); + other_rptp_fd = tcp_socket(other_rptp_port ? other_rptp_port : OLD_RPTP_PORT); #endif /* * Make the RPTP sockets non-blocking. */ - fd_nonblock (rptp_fd); + fd_nonblock(rptp_fd); #ifdef OTHER_RPLAY_PORTS - fd_nonblock (other_rptp_fd); + fd_nonblock(other_rptp_fd); #endif } int -rplayd_audio_init () +rplayd_audio_init() { int sample_size; @@ -1198,7 +1226,7 @@ /* Call rplay_audio_init() which sets all the rplay_audio variables. */ rplay_audio_table = NULL; /* will be set by rplay_audio_init() */ - if (rplay_audio_init () < 0) + if (rplay_audio_init() < 0) { return -1; } @@ -1218,7 +1246,7 @@ } curr_rate = rplay_audio_rate; -#ifndef HAVE_OSS +#ifndef HAVE_OSS /* Click prevention: Make sure curr_rate won't split up samples. If it will, it's easiest right now to modify the rate and not the sample_rate. */ @@ -1230,8 +1258,8 @@ curr_rate--; /* Slow it down. */ } - report (REPORT_DEBUG, "changed curr_rate from %d to %d\n", - rplay_audio_rate, curr_rate); + report(REPORT_DEBUG, "changed curr_rate from %d to %d\n", + rplay_audio_rate, curr_rate); } if (rplay_audio_match || rplay_audio_bufsize == 0) @@ -1250,47 +1278,47 @@ curr_bufsize++; /* Add a little. */ } - report (REPORT_DEBUG, "changed curr_bufsize from %d to %d\n", - rplay_audio_bufsize, curr_bufsize); - } -#endif /* !HAVE_OSS */ + report(REPORT_DEBUG, "changed curr_bufsize from %d to %d\n", + rplay_audio_bufsize, curr_bufsize); + } +#endif /* !HAVE_OSS */ /* * Create the audio buffer which holds at most 1 second of 16-bit * stereo audio data sampled at MAX_SAMPLE_RATE Hz. */ - max_rplay_audio_bufsize = MAX_SAMPLE_RATE * 2 /* 16-bit */ * 2 /* stereo */ ; + max_rplay_audio_bufsize = MAX_SAMPLE_RATE * 2 /* 16-bit */ * 2 /* stereo */ ; if (rplay_audio_buf) { - free ((char *) rplay_audio_buf); - } - rplay_audio_buf = (char *) malloc (max_rplay_audio_bufsize); + free((char *) rplay_audio_buf); + } + rplay_audio_buf = (char *) malloc(max_rplay_audio_bufsize); if (rplay_audio_buf == NULL) { - report (REPORT_ERROR, "cannot allocate rplay_audio_buf, size=%d\n", - max_rplay_audio_bufsize); - done (1); + report(REPORT_ERROR, "cannot allocate rplay_audio_buf, size=%d\n", + max_rplay_audio_bufsize); + done(1); } /* * Update the volume of the audio device. */ - rplay_audio_volume = rplay_audio_get_volume (); + rplay_audio_volume = rplay_audio_get_volume(); if (rplay_audio_volume < 0) { rplay_audio_volume = 0; } - report (REPORT_DEBUG, "\ + report(REPORT_DEBUG, "\ audio: bits=%d sample-rate=%d channels=%d format=%s volume=%d port-mask=%0x\n", - rplay_audio_precision, rplay_audio_sample_rate, rplay_audio_channels, - audio_format_to_string (rplay_audio_format), rplay_audio_volume, rplay_audio_port); + rplay_audio_precision, rplay_audio_sample_rate, rplay_audio_channels, + audio_format_to_string(rplay_audio_format), rplay_audio_volume, rplay_audio_port); #ifdef HAVE_OSS - report (REPORT_DEBUG, "timer: rate=%d, min bytes/sec=%d\n", curr_rate, - (rplay_audio_sample_rate / curr_rate * sample_size)); -#else - report (REPORT_DEBUG, "timer: rate=%d, bufsize=%d\n", curr_rate, curr_bufsize); + report(REPORT_DEBUG, "timer: rate=%d, min bytes/sec=%d\n", curr_rate, + (rplay_audio_sample_rate / curr_rate * sample_size)); +#else + report(REPORT_DEBUG, "timer: rate=%d, bufsize=%d\n", curr_rate, curr_bufsize); #endif return 0; @@ -1300,10 +1328,10 @@ in `sp'. Currenly only the sample-rate is matched. */ #ifdef __STDC__ void -rplayd_audio_match (SPOOL *match_sp) +rplayd_audio_match(SPOOL *match_sp) #else void -rplayd_audio_match (match_sp) +rplayd_audio_match(match_sp) SPOOL *match_sp; #endif { @@ -1327,7 +1355,7 @@ break; } else if (optional_sample_rate >= prev_sample_rate - && optional_sample_rate <= t->sample_rate) + && optional_sample_rate <= t->sample_rate) { if ((t->sample_rate - optional_sample_rate) > (optional_sample_rate - prev_sample_rate)) @@ -1343,18 +1371,18 @@ prev_sample_rate = t->sample_rate; } - report (REPORT_DEBUG, "matched %d with %d\n", match_sp->sample_rate, - optional_sample_rate); - - if (rplayd_audio_init () < 0) + report(REPORT_DEBUG, "matched %d with %d\n", match_sp->sample_rate, + optional_sample_rate); + + if (rplayd_audio_init() < 0) { /* That sample rate didn't work -- Use the default instead. */ optional_sample_rate = default_sample_rate; - rplayd_audio_init (); + rplayd_audio_init(); } if (timer_enabled) { - timer_restart (curr_rate); + timer_restart(curr_rate); } /* Update the spool entries with the new sample-rate. */ @@ -1364,41 +1392,98 @@ } } } + +monitor_alloc() +{ + if (!monitor_buffers) + { + BUFFER *b, *end; + monitor_buffers = buffer_alloc(monitor_total_bytes, BUFFER_KEEP); + for (b = monitor_buffers; b; b = b->next) + { + /* these will always be full buffers */ + b->nbytes = BUFFER_SIZE; + if (!b->next) + { + end = b; + } + } + /* make the list of buffer cyclic */ + end->next = monitor_buffers; + } + + monitor_update = 0; +} + +monitor_cleanup() +{ + BUFFER *b, *b_next; + + for (b = monitor_buffers; b->next != monitor_buffers; b = b->next); + b->next = NULL; + buffer_dealloc(monitor_buffers, 1); + monitor_buffers = NULL; +} + /* * Write nbytes of audio data from the audio buffer to the audio device. */ #ifdef __STDC__ void -rplayd_write (int nbytes) +rplayd_write(int nbytes) #else void -rplayd_write (nbytes) +rplayd_write(nbytes) int nbytes; #endif { int nwritten = 0; /* Insert `nbytes' of audio data from the spool into `rplay_audio_buf'. */ - spool_process (rplay_audio_buf, nbytes); + spool_process(rplay_audio_buf, nbytes); /* * Write the audio data if the audio device is open. * Otherwise forget about the data. */ - if (rplay_audio_size && rplay_audio_isopen ()) - { - nwritten = rplay_audio_write (rplay_audio_buf, rplay_audio_size); + if (rplay_audio_size && rplay_audio_isopen()) + { + nwritten = rplay_audio_write(rplay_audio_buf, rplay_audio_size); #if 0 - report (REPORT_DEBUG, "audio_write: %d -> %d\n", rplay_audio_size, nwritten); + report(REPORT_DEBUG, "audio_write: %d -> %d\n", rplay_audio_size, nwritten); #endif /* Flush after every write? */ if (rplay_audio_flush_timeout == -2) { - report (REPORT_DEBUG, "flushing %s\n", rplay_audio_device); - rplay_audio_flush (); - } - } + report(REPORT_DEBUG, "flushing %s\n", rplay_audio_device); + rplay_audio_flush(); + } + } + + if (monitor_count) + { + char *buf = rplay_audio_buf; + int size = rplay_audio_size; + int n; + + while (size) + { + n = MIN(BUFFER_SIZE - monitor_buffers->offset, size); + memcpy(monitor_buffers->buf + monitor_buffers->offset, buf, n); + monitor_buffers->offset += n; + buf += n; + size -= n; + + if (monitor_buffers->offset == BUFFER_SIZE) + { + monitor_buffers = monitor_buffers->next; + monitor_buffers->offset = 0; + monitor_update++; + } + } + } + rplay_audio_size = 0; /* Flush when the audio stream has ended. */ @@ -1406,8 +1491,8 @@ { if (rplay_audio_flush_timeout == -1) { - report (REPORT_DEBUG, "flushing %s\n", rplay_audio_device); - rplay_audio_flush (); + report(REPORT_DEBUG, "flushing %s\n", rplay_audio_device); + rplay_audio_flush(); } } } @@ -1417,10 +1502,10 @@ */ #ifdef __STDC__ void -rplayd_read (int fd) +rplayd_read(int fd) #else void -rplayd_read (fd) +rplayd_read(fd) int fd; #endif { @@ -1432,9 +1517,9 @@ for (j = 0; j < SPOOL_SIZE; j++) { - flen = sizeof (f); - - n = recvfrom (fd, recv_buf, sizeof (recv_buf), 0, (struct sockaddr *) &f, &flen); + flen = sizeof(f); + + n = recvfrom(fd, recv_buf, sizeof(recv_buf), 0, (struct sockaddr *) &f, &flen); if (n <= 0) { continue; @@ -1442,16 +1527,16 @@ if (forward) { - write (forward_fd, recv_buf, n); + write(forward_fd, recv_buf, n); continue; } #ifdef AUTH - if (!host_access (f, HOST_EXECUTE)) - { - if (!host_access (f, HOST_READ) && !host_access (f, HOST_WRITE)) + if (!host_access(f, HOST_EXECUTE)) + { + if (!host_access(f, HOST_READ) && !host_access(f, HOST_WRITE)) { - report (REPORT_NOTICE, "%s permission denied\n", inet_ntoa (f.sin_addr)); + report(REPORT_NOTICE, "%s permission denied\n", inet_ntoa(f.sin_addr)); } continue; } @@ -1466,14 +1551,14 @@ case OLD_RPLAY_STOP: case OLD_RPLAY_PAUSE: case OLD_RPLAY_CONTINUE: - packet = rplay_convert (recv_buf); + packet = rplay_convert(recv_buf); #endif /* OLD_RPLAY */ case RPLAY_PACKET_ID: - rp = rplay_unpack (packet); + rp = rplay_unpack(packet); if (rp == NULL) { - report (REPORT_ERROR, "rplay_unpack: %s\n", rplay_errlist[rplay_errno]); + report(REPORT_ERROR, "rplay_unpack: %s\n", rplay_errlist[rplay_errno]); break; } @@ -1481,66 +1566,66 @@ { case RPLAY_PING: #ifdef DEBUG - report (REPORT_DEBUG, "received a ping packet\n"); -#endif - rplay_destroy (rp); + report(REPORT_DEBUG, "received a ping packet\n"); +#endif + rplay_destroy(rp); break; case RPLAY_PLAY: - report (REPORT_INFO, "%s play %s\n", - inet_ntoa (f.sin_addr), - (char *) rplay_get (rp, RPLAY_SOUND, 0)); - rplayd_play (rp, f); + report(REPORT_INFO, "%s play %s\n", + inet_ntoa(f.sin_addr), + (char *) rplay_get(rp, RPLAY_SOUND, 0)); + rplayd_play(rp, f); break; case RPLAY_STOP: - report (REPORT_INFO, "%s stop %s\n", - inet_ntoa (f.sin_addr), - (char *) rplay_get (rp, RPLAY_SOUND, 0)); - rplayd_stop (rp, f); + report(REPORT_INFO, "%s stop %s\n", + inet_ntoa(f.sin_addr), + (char *) rplay_get(rp, RPLAY_SOUND, 0)); + rplayd_stop(rp, f); break; case RPLAY_PAUSE: - report (REPORT_INFO, "%s pause %s\n", - inet_ntoa (f.sin_addr), - (char *) rplay_get (rp, RPLAY_SOUND, 0)); - rplayd_pause (rp, f); + report(REPORT_INFO, "%s pause %s\n", + inet_ntoa(f.sin_addr), + (char *) rplay_get(rp, RPLAY_SOUND, 0)); + rplayd_pause(rp, f); break; case RPLAY_CONTINUE: - report (REPORT_INFO, "%s continue %s\n", - inet_ntoa (f.sin_addr), - (char *) rplay_get (rp, RPLAY_SOUND, 0)); - rplayd_continue (rp, f); + report(REPORT_INFO, "%s continue %s\n", + inet_ntoa(f.sin_addr), + (char *) rplay_get(rp, RPLAY_SOUND, 0)); + rplayd_continue(rp, f); break; case RPLAY_RESET: - report (REPORT_INFO, "received a reset packet\n"); - need_reset (); - rplay_destroy (rp); + report(REPORT_INFO, "received a reset packet\n"); + need_reset(); + rplay_destroy(rp); break; case RPLAY_DONE: - report (REPORT_INFO, "%s done %s\n", - inet_ntoa (f.sin_addr), - (char *) rplay_get (rp, RPLAY_SOUND, 0)); - rplayd_done (rp, f); + report(REPORT_INFO, "%s done %s\n", + inet_ntoa(f.sin_addr), + (char *) rplay_get(rp, RPLAY_SOUND, 0)); + rplayd_done(rp, f); break; case RPLAY_PUT: - report (REPORT_INFO, "%s put id=%d sequence=%d size=%d\n", - inet_ntoa (f.sin_addr), - rp->id, - rp->sequence, - rp->data_size); - rplayd_put (rp, f); + report(REPORT_INFO, "%s put id=%d sequence=%d size=%d\n", + inet_ntoa(f.sin_addr), + rp->id, + rp->sequence, + rp->data_size); + rplayd_put(rp, f); break; } break; default: - report (REPORT_ERROR, "unknown RPLAY packet received from %s\n", - inet_ntoa (f.sin_addr)); + report(REPORT_ERROR, "unknown RPLAY packet received from %s\n", + inet_ntoa(f.sin_addr)); break; } } @@ -1551,15 +1636,15 @@ This is done using rplayd main select loop for efficiency. */ #ifdef __STDC__ void -rplayd_pipe_read (fd_set *rfds) +rplayd_pipe_read(fd_set * rfds) #else void -rplayd_pipe_read (rfds) +rplayd_pipe_read(rfds) fd_set *rfds; -#endif +#endif { SPOOL *sp, *sp_next; - extern BUFFER *sound_pipe_read (SINDEX *si); + extern BUFFER *sound_pipe_read(SINDEX *si); for (sp = spool; sp; sp = sp_next) { @@ -1569,38 +1654,38 @@ continue; } -#ifdef HAVE_CDROM - if (sp->si->sound->type == SOUND_CDROM && FD_ISSET (sp->si->fd, rfds)) - { - BUFFER *b = sound_pipe_read (sp->si); +#ifdef HAVE_CDROM + if (sp->si->sound->type == SOUND_CDROM && FD_ISSET(sp->si->fd, rfds)) + { + BUFFER *b = sound_pipe_read(sp->si); if (b) { - spool_flow_insert (sp, b); + spool_flow_insert(sp, b); } } -#endif +#endif #ifdef HAVE_HELPERS - if (sp->si->sound->needs_helper && FD_ISSET (sp->si->fd, rfds)) - { - BUFFER *b = sound_pipe_read (sp->si); + if (sp->si->sound->needs_helper && FD_ISSET(sp->si->fd, rfds)) + { + BUFFER *b = sound_pipe_read(sp->si); if (b) { - spool_flow_insert (sp, b); + spool_flow_insert(sp, b); } } -#endif - +#endif + } } #endif #ifdef __STDC__ int -rplayd_play (RPLAY *rp, struct sockaddr_in sin) +rplayd_play(RPLAY *rp, struct sockaddr_in sin) #else int -rplayd_play (rp, sin) +rplayd_play(rp, sin) RPLAY *rp; struct sockaddr_in sin; #endif @@ -1621,14 +1706,14 @@ for (sp = spool; sp; sp = sp->next) { if (*sp->rp->list_name - && strcmp (rp->list_name, sp->rp->list_name) == 0) + && strcmp(rp->list_name, sp->rp->list_name) == 0) { break; } } if (sp) { - *(sp->rp->attrsp) = rp->attrs; /* Append the new attrs. */ + *(sp->rp->attrsp) = rp->attrs; /* Append the new attrs. */ sp->rp->attrsp = rp->attrsp; start_sound = sp->rp->nsounds; sp->rp->nsounds += rp->nsounds; @@ -1644,17 +1729,17 @@ with priorities less than rplay_priority_threshold. */ if (rp->priority < rplay_priority_threshold) { - report (REPORT_DEBUG, "sound at priority %d ignored\n", - rp->priority); - rplay_destroy (rp); + report(REPORT_DEBUG, "sound at priority %d ignored\n", + rp->priority); + rplay_destroy(rp); return -1; } - - sp = spool_next (rp->priority); + + sp = spool_next(rp->priority); if (!sp) { - report (REPORT_DEBUG, "spool full\n"); - rplay_destroy (rp); + report(REPORT_DEBUG, "spool full\n"); + rplay_destroy(rp); return -1; } start_sound = 0; @@ -1665,9 +1750,9 @@ /* Gotta have attributes! */ if (!rp->attrs) { - report (REPORT_DEBUG, "`rp' missing attributes\n"); - rplay_destroy (rp); - spool_destroy (sp); + report(REPORT_DEBUG, "`rp' missing attributes\n"); + rplay_destroy(rp); + spool_destroy(sp); return -1; } @@ -1681,24 +1766,24 @@ { SERVER *s; - s = (SERVER *) malloc (sizeof (SERVER)); + s = (SERVER *) malloc(sizeof(SERVER)); s->next = NULL; s->sin.sin_family = AF_INET; - s->sin.sin_port = htons (attrs->rptp_server_port); - s->sin.sin_addr.s_addr = inet_addr (attrs->rptp_server); - sp->sound[i] = sound_lookup (attrs->sound, - attrs->rptp_search ? SOUND_FIND : SOUND_DONT_FIND, s); + s->sin.sin_port = htons(attrs->rptp_server_port); + s->sin.sin_addr.s_addr = inet_addr(attrs->rptp_server); + sp->sound[i] = sound_lookup(attrs->sound, + attrs->rptp_search ? SOUND_FIND : SOUND_DONT_FIND, s); } else { - sp->sound[i] = sound_lookup (attrs->sound, - attrs->rptp_search ? SOUND_FIND : SOUND_DONT_FIND, NULL); + sp->sound[i] = sound_lookup(attrs->sound, + attrs->rptp_search ? SOUND_FIND : SOUND_DONT_FIND, NULL); } if (sp->sound[i] == NULL) { - rplay_destroy (rp); - spool_destroy (sp); + rplay_destroy(rp); + spool_destroy(sp); return -1; } @@ -1724,19 +1809,19 @@ } else { - spool_play (sp); - } - } - + spool_play(sp); + } + } + return sp->id; } #ifdef __STDC__ int -rplayd_stop (RPLAY *rp, struct sockaddr_in sin) +rplayd_stop(RPLAY *rp, struct sockaddr_in sin) #else int -rplayd_stop (rp, sin) +rplayd_stop(rp, sin) RPLAY *rp; struct sockaddr_in sin; #endif @@ -1745,22 +1830,22 @@ if (!audio_enabled) { - rplay_destroy (rp); + rplay_destroy(rp); return -1; } - n = spool_match (rp, spool_stop, sin); - rplay_destroy (rp); + n = spool_match(rp, spool_stop, sin); + rplay_destroy(rp); return n > 0 ? 0 : -1; } #ifdef __STDC__ int -rplayd_pause (RPLAY *rp, struct sockaddr_in sin) +rplayd_pause(RPLAY *rp, struct sockaddr_in sin) #else int -rplayd_pause (rp, sin) +rplayd_pause(rp, sin) RPLAY *rp; struct sockaddr_in sin; #endif @@ -1769,22 +1854,22 @@ if (!audio_enabled) { - rplay_destroy (rp); + rplay_destroy(rp); return -1; } - n = spool_match (rp, spool_pause, sin); - rplay_destroy (rp); + n = spool_match(rp, spool_pause, sin); + rplay_destroy(rp); return n > 0 ? 0 : -1; } #ifdef __STDC__ int -rplayd_continue (RPLAY *rp, struct sockaddr_in sin) +rplayd_continue(RPLAY *rp, struct sockaddr_in sin) #else int -rplayd_continue (rp, sin) +rplayd_continue(rp, sin) RPLAY *rp; struct sockaddr_in sin; #endif @@ -1793,22 +1878,22 @@ if (!audio_enabled) { - rplay_destroy (rp); + rplay_destroy(rp); return -1; } - n = spool_match (rp, spool_continue, sin); - rplay_destroy (rp); + n = spool_match(rp, spool_continue, sin); + rplay_destroy(rp); return n > 0 ? 0 : -1; } #ifdef __STDC__ int -rplayd_done (RPLAY *rp, struct sockaddr_in sin) +rplayd_done(RPLAY *rp, struct sockaddr_in sin) #else int -rplayd_done (rp, sin) +rplayd_done(rp, sin) RPLAY *rp; struct sockaddr_in sin; #endif @@ -1817,22 +1902,22 @@ if (!audio_enabled) { - rplay_destroy (rp); + rplay_destroy(rp); return -1; } - n = spool_match (rp, spool_done, sin); - rplay_destroy (rp); + n = spool_match(rp, spool_done, sin); + rplay_destroy(rp); return n > 0 ? 0 : -1; } #ifdef __STDC__ int -rplayd_put (RPLAY *rp, struct sockaddr_in sin) +rplayd_put(RPLAY *rp, struct sockaddr_in sin) #else int -rplayd_put (rp, sin) +rplayd_put(rp, sin) RPLAY *rp; struct sockaddr_in sin; #endif @@ -1842,161 +1927,166 @@ if (!audio_enabled) { - rplay_destroy (rp); + rplay_destroy(rp); return -1; } /* Find the spool entry. */ - sp = spool_find (rp->id); + sp = spool_find(rp->id); if (!sp) { - report (REPORT_DEBUG, "put: `%d' no such spool id\n", rp->id); - rplay_destroy (rp); + report(REPORT_DEBUG, "put: `%d' no such spool id\n", rp->id); + rplay_destroy(rp); return -1; } /* Create a buffer and insert the flow data. */ - b = buffer_create (); + b = buffer_create(); b->nbytes = rp->data_size; - memcpy (b->buf, rp->data, b->nbytes); - spool_flow_insert (sp, b); - - rplay_destroy (rp); + memcpy(b->buf, rp->data, b->nbytes); + spool_flow_insert(sp, b); + + rplay_destroy(rp); return 0; } BUFFER * -rplayd_status () +rplayd_status() { BUFFER *b; - b = buffer_create (); + b = buffer_create(); b->buf[0] = RPTP_OK; b->buf[1] = '\0'; - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "host=%s", hostname); - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " version=%s", RPLAY_VERSION); - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " uptime=%s", time2string (time (0) - starttime)); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), "host=%s", hostname); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " version=%s", RPLAY_VERSION); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " uptime=%s", time2string(time(0) - starttime)); if (audio_enabled) { - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-bits=%d", rplay_audio_precision); -#ifndef HAVE_OSS - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-bufsize=%d", rplay_audio_bufsize); -#endif /* !HAVE_OSS */ - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-byte-order=%s", - byte_order_to_string (RPLAY_AUDIO_BYTE_ORDER)); - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-channels=%d", rplay_audio_channels); - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-device=%s", rplay_audio_device); - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-format=%s", - audio_format_to_string (rplay_audio_format)); -#ifdef HAVE_OSS - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-fragsize=%d", rplay_audio_fragsize); -#endif /* HAVE_OSS */ - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-port=%s", - audio_port_to_string (rplay_audio_port)); - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-rate=%d", rplay_audio_rate); - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " audio-sample-rate=%d", rplay_audio_sample_rate); - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " volume=%d", rplay_audio_volume); -#ifndef HAVE_OSS - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " curr-bufsize=%d", curr_bufsize); -#endif /* !HAVE_OSS */ - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " curr-rate=%d", curr_rate); - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), " priority-threshold=%d", rplay_priority_threshold); - } - - SNPRINTF (SIZE (b->buf + strlen (b->buf), BUFFER_SIZE), "\r\n"); - - b->nbytes = strlen (b->buf); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-bits=%d", rplay_audio_precision); +#ifndef HAVE_OSS + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-bufsize=%d", rplay_audio_bufsize); +#endif /* !HAVE_OSS */ + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-byte-order=%s", + byte_order_to_string(RPLAY_AUDIO_BYTE_ORDER)); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-channels=%d", rplay_audio_channels); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-device=%s", rplay_audio_device); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-format=%s", + audio_format_to_string(rplay_audio_format)); +#ifdef HAVE_OSS + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-fragsize=%d", rplay_audio_fragsize); +#endif /* HAVE_OSS */ + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-port=%s", + audio_port_to_string(rplay_audio_port)); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-rate=%d", rplay_audio_rate); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-sample-rate=%d", rplay_audio_sample_rate); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " volume=%d", rplay_audio_volume); +#ifndef HAVE_OSS + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " curr-bufsize=%d", curr_bufsize); +#endif /* !HAVE_OSS */ + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " curr-rate=%d", curr_rate); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " priority-threshold=%d", + rplay_priority_threshold); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-close=%d", + rplay_audio_timeout); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), " audio-device-status=%s", + rplay_audio_isopen() ? "open" : "closed"); + } + + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), "\r\n"); + + b->nbytes = strlen(b->buf); return b; } void -need_reset () +need_reset() { need_to_reset++; } /* Reset rplayd's state. */ static void -reset () +reset() { int was_enabled = timer_enabled; if (was_enabled) { - timer_stop (); - } - spool_init (); - connection_cleanup (); + timer_stop(); + } + spool_init(); + connection_cleanup(); #ifdef HAVE_HELPERS - helper_reread (helpers_file); -#endif /* HAVE_HELPERS */ - sound_reread (sounds_file); - cache_init (cache_dir); - cache_read (); + helper_reread(helpers_file); +#endif /* HAVE_HELPERS */ + sound_reread(sounds_file); + cache_init(cache_dir); + cache_read(); #ifdef AUTH - host_reread (hosts_file); + host_reread(hosts_file); #endif /* AUTH */ - server_reread (servers_file); + server_reread(servers_file); if (was_enabled) { - timer_start (curr_rate); + timer_start(curr_rate); } } static void -handle_signals () +handle_signals() { /* Ingore SIGPIPE since read will handle closed TCP connections. Handle SIGHUP, SIGINT, and SIGCHLD. */ #ifdef HAVE_SIGSET - sigset (SIGPIPE, SIG_IGN); - sigset (SIGHUP, handle_sighup); - sigset (SIGINT, handle_sigint); - sigset (SIGCHLD, handle_sigchld); -#else - signal (SIGPIPE, SIG_IGN); - signal (SIGHUP, handle_sighup); - signal (SIGINT, handle_sigint); - signal (SIGCHLD, handle_sigchld); + sigset(SIGPIPE, SIG_IGN); + sigset(SIGHUP, handle_sighup); + sigset(SIGINT, handle_sigint); + sigset(SIGCHLD, handle_sigchld); +#else + signal(SIGPIPE, SIG_IGN); + signal(SIGHUP, handle_sighup); + signal(SIGINT, handle_sigint); + signal(SIGCHLD, handle_sigchld); #endif } static void -handle_sighup () -{ - report (REPORT_DEBUG, "received SIGHUP signal\n"); - need_reset (); +handle_sighup() +{ + report(REPORT_DEBUG, "received SIGHUP signal\n"); + need_reset(); } static void -handle_sigint () -{ - report (REPORT_DEBUG, "received SIGINT signal\n"); - done (0); +handle_sigint() +{ + report(REPORT_DEBUG, "received SIGINT signal\n"); + done(0); } static void -handle_sigchld () +handle_sigchld() { pid_t pid; SPOOL *sp; #ifdef linux - handle_signals (); -#endif - - report (REPORT_DEBUG, "received SIGCHLD signal\n"); - -#ifdef HAVE_WAITPID - pid = waitpid ((pid_t)-1, NULL, WNOHANG); + handle_signals(); +#endif + + report(REPORT_DEBUG, "received SIGCHLD signal\n"); + +#ifdef HAVE_WAITPID + pid = waitpid((pid_t) - 1, NULL, WNOHANG); #else /* not HAVE_WAITPID */ - pid = wait (NULL); + pid = wait(NULL); #endif /* not HAVE_WAITPID */ if (pid <= 0) { @@ -2005,13 +2095,13 @@ } static void -audio_test () +audio_test() { static char *spin = "|\\-/"; static int spin_pos; - - printf ("Testing supported audio configurations (this may take a long time)...\n"); - for (optional_sample_rate = 4000; optional_sample_rate <= 48000; optional_sample_rate += 5) + + printf("Testing supported audio configurations (this may take a long time)...\n"); + for (optional_sample_rate = 4000; optional_sample_rate <= 48000; optional_sample_rate += 5) for (optional_precision = 8; optional_precision <= 16; optional_precision += 8) for (optional_channels = 1; optional_channels <= 2; optional_channels++) for (optional_format = 1; optional_format <= 5; optional_format++) @@ -2020,29 +2110,29 @@ { spin_pos = 0; } - fprintf (stderr, "%c\r", spin[spin_pos++]); - - if (rplay_audio_init () >= 0) + fprintf(stderr, "%c\r", spin[spin_pos++]); + + if (rplay_audio_init() >= 0) { - printf (" { %5d, %-24s, %2d, %d },\n", - rplay_audio_sample_rate, - rplay_audio_format == RPLAY_FORMAT_ULAW ? "RPLAY_FORMAT_ULAW" : - rplay_audio_format == RPLAY_FORMAT_LINEAR_8 ? "RPLAY_FORMAT_LINEAR_8" : - rplay_audio_format == RPLAY_FORMAT_ULINEAR_8 ? "RPLAY_FORMAT_ULINEAR_8" : - rplay_audio_format == RPLAY_FORMAT_LINEAR_16 ? "RPLAY_FORMAT_LINEAR_16" : - rplay_audio_format == RPLAY_FORMAT_ULINEAR_16 ? "RPLAY_FORMAT_ULINEAR_16" : "?", - rplay_audio_precision, - rplay_audio_channels); + printf(" { %5d, %-24s, %2d, %d },\n", + rplay_audio_sample_rate, + rplay_audio_format == RPLAY_FORMAT_ULAW ? "RPLAY_FORMAT_ULAW" : + rplay_audio_format == RPLAY_FORMAT_LINEAR_8 ? "RPLAY_FORMAT_LINEAR_8" : + rplay_audio_format == RPLAY_FORMAT_ULINEAR_8 ? "RPLAY_FORMAT_ULINEAR_8" : + rplay_audio_format == RPLAY_FORMAT_LINEAR_16 ? "RPLAY_FORMAT_LINEAR_16" : + rplay_audio_format == RPLAY_FORMAT_ULINEAR_16 ? "RPLAY_FORMAT_ULINEAR_16" : "?", + rplay_audio_precision, + rplay_audio_channels); } } } #ifdef __STDC__ void -done (int exit_value) +done(int exit_value) #else void -done (exit_value) +done(exit_value) int exit_value; #endif { @@ -2051,40 +2141,40 @@ /* #ifdef HAVE_CDROM */ /* for (sp = spool; sp; sp = sp->next) */ /* { */ -/* if (sp->si && sp->si->pid > 0) */ -/* { */ -/* report (REPORT_DEBUG, "killing process %d\n", sp->si->pid); */ -/* if (kill (sp->si->pid, SIGKILL) < 0) */ -/* { */ -/* report (REPORT_DEBUG, "kill %d: %s\n", sp->si->pid, sys_err_str (errno)); */ -/* } */ -/* } */ +/* if (sp->si && sp->si->pid > 0) */ +/* { */ +/* report (REPORT_DEBUG, "killing process %d\n", sp->si->pid); */ +/* if (kill (sp->si->pid, SIGKILL) < 0) */ +/* { */ +/* report (REPORT_DEBUG, "kill %d: %s\n", sp->si->pid, sys_err_str (errno)); */ +/* } */ +/* } */ /* } */ /* #endif */ /* connection_cleanup (); */ - cache_cleanup (); - rplay_audio_close (); - close (rplay_fd); - close (rptp_fd); + cache_cleanup(); + rplay_audio_close(); + close(rplay_fd); + close(rptp_fd); #ifdef OTHER_RPLAY_PORTS - close (other_rplay_fd); - close (other_rptp_fd); -#endif - report (REPORT_DEBUG, "exit(%d)\n", exit_value); + close(other_rplay_fd); + close(other_rptp_fd); +#endif + report(REPORT_DEBUG, "exit(%d)\n", exit_value); if (logging && log_fd >= 0) { - close (log_fd); - } - exit (exit_value); + close(log_fd); + } + exit(exit_value); } #ifdef __STDC__ void -report (int level, char *fmt,...) +report(int level, char *fmt,...) #else void -report (va_alist) +report(va_alist) va_dcl #endif { @@ -2096,25 +2186,25 @@ static char message[2048]; /* XXX: largest message */ #ifdef __STDC__ - va_start (args, fmt); + va_start(args, fmt); #else char *fmt; int level; - va_start (args); - level = va_arg (args, int); - fmt = va_arg (args, char *); + va_start(args); + level = va_arg(args, int); + fmt = va_arg(args, char *); #endif if (report_level >= level) { - VSNPRINTF (SIZE(message,sizeof(message)), fmt, args); + VSNPRINTF(SIZE(message, sizeof(message)), fmt, args); iov[1].iov_base = message; - iov[1].iov_len = strlen (message); + iov[1].iov_len = strlen(message); if (logging) { - now = time (0); - p = ctime (&now); + now = time(0); + p = ctime(&now); p += 4; p[15] = '\0'; @@ -2123,11 +2213,11 @@ #ifndef O_SYNC #define O_SYNC 0 #endif - log_fd = open (log_file, O_WRONLY | O_CREAT | O_APPEND | O_SYNC, 0644); + log_fd = open(log_file, O_WRONLY | O_CREAT | O_APPEND | O_SYNC, 0644); if (log_fd < 0) { - fprintf (stderr, "%s: cannot open logfile `%s': %s\n", - progname, log_file, sys_err_str (errno)); + fprintf(stderr, "%s: cannot open logfile `%s': %s\n", + progname, log_file, sys_err_str(errno)); /* * Turn off logging to avoid further problems. */ @@ -2137,257 +2227,257 @@ } } - SNPRINTF (SIZE(header,sizeof(header)), "%s %s rplayd[%d]: ", p, hostname, rplayd_pid); + SNPRINTF(SIZE(header, sizeof(header)), "%s %s rplayd[%d]: ", p, hostname, rplayd_pid); iov[0].iov_base = header; - iov[0].iov_len = strlen (header); - - if (writev (log_fd, iov, 2) < 0) + iov[0].iov_len = strlen(header); + + if (writev(log_fd, iov, 2) < 0) { - fprintf (stderr, "%s: cannot write to log file `%s': %s\n", - progname, log_file, sys_err_str (errno)); + fprintf(stderr, "%s: cannot write to log file `%s': %s\n", + progname, log_file, sys_err_str(errno)); logging = 0; log_fd = -1; - fprintf (stderr, "%s: logging disabled\n", progname); + fprintf(stderr, "%s: logging disabled\n", progname); } } if (debug || level == REPORT_ERROR) { - SNPRINTF (SIZE(header,sizeof(header)), "%s: ", progname); + SNPRINTF(SIZE(header, sizeof(header)), "%s: ", progname); iov[0].iov_base = header; - iov[0].iov_len = strlen (header); + iov[0].iov_len = strlen(header); #ifndef STDERR_FILENO #define STDERR_FILENO 2 #endif - writev (STDERR_FILENO, iov, 2); - } - - } - - va_end (args); + writev(STDERR_FILENO, iov, 2); + } + + } + + va_end(args); } void -usage () -{ - printf ("\n"); - printf ("rplay %s\n", RPLAY_VERSION); - printf ("\n"); - printf ("usage: %s [options]\n", progname); - printf ("\n"); - - printf ("-A DEVICE, --audio-device=DEVICE\n"); - printf ("\tUse DEVICE for the audio device (%s).\n", rplay_audio_device); - printf ("\n"); +usage() +{ + printf("\n"); + printf("rplay %s\n", RPLAY_VERSION); + printf("\n"); + printf("usage: %s [options]\n", progname); + printf("\n"); + + printf("-A DEVICE, --audio-device=DEVICE\n"); + printf("\tUse DEVICE for the audio device (%s).\n", rplay_audio_device); + printf("\n"); #ifndef HAVE_OSS - printf ("-b N, --audio-bufsize=N\n"); - printf ("\tAudio buffer size (%d).\n", rplay_audio_bufsize); - printf ("\n"); -#endif /* !HAVE_OSS */ - - printf ("-B N, --audio-bits=N\n"); - printf ("\tAudio device bits per sample, 8 or 16.\n"); - printf ("\n"); - - printf ("--audio-channels=N\n"); - printf ("\tNumber of audio channels to use, 1 == mono, 2 == stereo.\n"); - printf ("\n"); - - printf ("-c N, --audio-close=N\n"); - printf ("\tClose %s after N idle seconds, disabled with 0 (%d).\n", - RPLAY_AUDIO_DEVICE, rplay_audio_timeout); - printf ("\n"); - - printf ("-F N, --audio_flush=N\n"); - printf ("\tFlush %s after N idle seconds, disabled with 0 (%d).\n", - RPLAY_AUDIO_DEVICE, rplay_audio_flush_timeout); - printf ("\tN = -1 : flush when spool is empty.\n"); - printf ("\tN = -2 : flush after each audio write. (not recommended)\n"); - printf ("\tN should be <= to the audio close timeout.\n"); - printf ("\n"); - - printf ("--audio-format=FORMAT\n"); - printf ("\tTell rplayd to write audio data using FORMAT, where FORMAT\n"); - printf ("\tcan be ulaw, linear-8, ulinear-8, linear-16, or ulinear-16.\n"); - printf ("\t(linear = signed, ulinear = unsigned)\n"); - printf ("\n"); - -#ifdef HAVE_OSS - printf ("--audio-fragsize=N\n"); - printf ("\tAudio fragment size (%d). The default size is zero which lets\n", - rplay_audio_fragsize); - printf ("\tthe audio driver pick the \"best\" size. The size specified must\n"); - printf ("\tbe a power of 2 greater than 16. Example: 256, 1024, 4096.\n"); - printf ("\n"); + printf("-b N, --audio-bufsize=N\n"); + printf("\tAudio buffer size (%d).\n", rplay_audio_bufsize); + printf("\n"); +#endif /* !HAVE_OSS */ + + printf("-B N, --audio-bits=N\n"); + printf("\tAudio device bits per sample, 8 or 16.\n"); + printf("\n"); + + printf("--audio-channels=N\n"); + printf("\tNumber of audio channels to use, 1 == mono, 2 == stereo.\n"); + printf("\n"); + + printf("-c N, --audio-close=N\n"); + printf("\tClose %s after N idle seconds, disabled with 0 (%d).\n", + RPLAY_AUDIO_DEVICE, rplay_audio_timeout); + printf("\n"); + + printf("-F N, --audio_flush=N\n"); + printf("\tFlush %s after N idle seconds, disabled with 0 (%d).\n", + RPLAY_AUDIO_DEVICE, rplay_audio_flush_timeout); + printf("\tN = -1 : flush when spool is empty.\n"); + printf("\tN = -2 : flush after each audio write. (not recommended)\n"); + printf("\tN should be <= to the audio close timeout.\n"); + printf("\n"); + + printf("--audio-format=FORMAT\n"); + printf("\tTell rplayd to write audio data using FORMAT, where FORMAT\n"); + printf("\tcan be ulaw, linear-8, ulinear-8, linear-16, or ulinear-16.\n"); + printf("\t(linear = signed, ulinear = unsigned)\n"); + printf("\n"); + +#ifdef HAVE_OSS + printf("--audio-fragsize=N\n"); + printf("\tAudio fragment size (%d). The default size is zero which lets\n", + rplay_audio_fragsize); + printf("\tthe audio driver pick the \"best\" size. The size specified must\n"); + printf("\tbe a power of 2 greater than 16. Example: 256, 1024, 4096.\n"); + printf("\n"); #endif /* HAVE_OSS */ - - printf ("--audio-info=INFO, --info=INFO, -i INFO\n"); - printf ("\tSpecify complete audio device information with one option.\n"); - printf ("\tINFO is of the form: format,sample-rate,bits,channels\n"); - printf ("\tExamples: `ulaw,8000,8,1' and `linear-16,44100,16,2'\n"); - printf ("\tAlso provided are:\n"); - printf ("\t --audio-info-ulaw, --info-ulaw -> ulaw,8000,8,1\n"); - printf ("\n"); - - printf ("--audio-match\n"); - printf ("\tAttempt to match the sample rate of the audio device with\n"); - printf ("\tthe sample rate of the current sound when no other sounds\n"); - printf ("\tare playing. If the match fails, --audio-sample-rate is used.\n"); - printf ("\tThis option overrides --audio-bufsize.\n"); - printf ("\n"); - - printf ("--audio-port=PORT[,PORT...]\n"); - printf ("\tOutput audio to the specified audio port(s).\n"); - printf ("\tValid ports are `speaker', `headphone', and `lineout'.\n"); - printf ("\tMultiple ports can be specified using `speaker,headphone,lineout'\n"); - printf ("\n"); - - printf ("-r N, --audio-rate=N\n"); - printf ("\tWrite the audio buffer N times per second (%d).\n", rplay_audio_rate); - printf ("\n"); - - printf ("-R N, --audio-sample-rate=N\n"); - printf ("\tSample rate of the audio device.\n"); - printf ("\n"); + + printf("--audio-info=INFO, --info=INFO, -i INFO\n"); + printf("\tSpecify complete audio device information with one option.\n"); + printf("\tINFO is of the form: format,sample-rate,bits,channels\n"); + printf("\tExamples: `ulaw,8000,8,1' and `linear-16,44100,16,2'\n"); + printf("\tAlso provided are:\n"); + printf("\t --audio-info-ulaw, --info-ulaw -> ulaw,8000,8,1\n"); + printf("\n"); + + printf("--audio-match\n"); + printf("\tAttempt to match the sample rate of the audio device with\n"); + printf("\tthe sample rate of the current sound when no other sounds\n"); + printf("\tare playing. If the match fails, --audio-sample-rate is used.\n"); + printf("\tThis option overrides --audio-bufsize.\n"); + printf("\n"); + + printf("--audio-port=PORT[,PORT...]\n"); + printf("\tOutput audio to the specified audio port(s).\n"); + printf("\tValid ports are `speaker', `headphone', and `lineout'.\n"); + printf("\tMultiple ports can be specified using `speaker,headphone,lineout'\n"); + printf("\n"); + + printf("-r N, --audio-rate=N\n"); + printf("\tWrite the audio buffer N times per second (%d).\n", rplay_audio_rate); + printf("\n"); + + printf("-R N, --audio-sample-rate=N\n"); + printf("\tSample rate of the audio device.\n"); + printf("\n"); #ifdef AUTH - printf ("--auth\n"); - printf ("\tEnable host access authentication.\n"); - printf ("\n"); -#endif - - printf ("-D DIR, --cache-directory=DIR\n"); - printf ("\tUse DIR for rplay.cache (%s).\n", RPLAY_CACHE); - printf ("\n"); - - printf ("--cache-remove\n"); - printf ("\tRemove the cache directory and all its contents when rplayd exists.\n"); - printf ("\n"); - - printf ("-s N, --cache-size=N\n"); - printf ("\tMaximum size in bytes of the rplay cache, disabled with 0 (%d).\n", - RPLAY_CACHE_SIZE); - printf ("\n"); - -#ifdef HAVE_CDROM - printf ("--cdrom0=DEVICE, --cdrom1=DEVICE, --cdrom2=DEVICE, --cdrom3=DEVICE\n"); - printf ("\tSpecify the cdrom[0-3] to DEVICE mapping. For Solaris 2.x the default\n"); - printf ("\tmapping is cdrom[0-3] -> /vol/dev/aliases/cdrom[0-3].\n"); - printf ("\tLinux uses cdrom[0-3] -> /dev/cdrom[0-3].\n"); - printf ("\n"); -#endif /* HAVE_CDROM */ - - printf ("-C FILE, --conf=FILE\n"); - printf ("\tUse FILE for rplay.conf (%s).\n", RPLAY_CONF); - printf ("\n"); - - printf ("-T N, --connection-timeout=N\n"); - printf ("\tClose idle RPTP connections after N seconds, disabled with 0 (%d).\n", - rptp_timeout); - printf ("\n"); - - printf ("-d, --debug\n"); - printf ("\tEnable debug mode.\n"); - printf ("\n"); - - printf ("-f HOST, --forward=HOST\n"); - printf ("\tForward all RPLAY packets to HOST.\n"); - printf ("\n"); - - printf ("--fork\n"); - printf ("\tEnable backgrounding rplayd at startup. (%s)\n", - do_fork ? "enabled" : "disabled"); - printf ("\n"); - - printf ("--group=GROUP\n"); - printf ("\tRun with GROUP privs. (%s)\n", run_as_group); - printf ("\n"); - - printf ("--help\n"); - printf ("\tDisplay helpful information.\n"); - printf ("\n"); + printf("--auth\n"); + printf("\tEnable host access authentication.\n"); + printf("\n"); +#endif + + printf("-D DIR, --cache-directory=DIR\n"); + printf("\tUse DIR for rplay.cache (%s).\n", RPLAY_CACHE); + printf("\n"); + + printf("--cache-remove\n"); + printf("\tRemove the cache directory and all its contents when rplayd exists.\n"); + printf("\n"); + + printf("-s N, --cache-size=N\n"); + printf("\tMaximum size in bytes of the rplay cache, disabled with 0 (%d).\n", + RPLAY_CACHE_SIZE); + printf("\n"); + +#ifdef HAVE_CDROM + printf("--cdrom0=DEVICE, --cdrom1=DEVICE, --cdrom2=DEVICE, --cdrom3=DEVICE\n"); + printf("\tSpecify the cdrom[0-3] to DEVICE mapping. For Solaris 2.x the default\n"); + printf("\tmapping is cdrom[0-3] -> /vol/dev/aliases/cdrom[0-3].\n"); + printf("\tLinux uses cdrom[0-3] -> /dev/cdrom[0-3].\n"); + printf("\n"); +#endif /* HAVE_CDROM */ + + printf("-C FILE, --conf=FILE\n"); + printf("\tUse FILE for rplay.conf (%s).\n", RPLAY_CONF); + printf("\n"); + + printf("-T N, --connection-timeout=N\n"); + printf("\tClose idle RPTP connections after N seconds, disabled with 0 (%d).\n", + rptp_timeout); + printf("\n"); + + printf("-d, --debug\n"); + printf("\tEnable debug mode.\n"); + printf("\n"); + + printf("-f HOST, --forward=HOST\n"); + printf("\tForward all RPLAY packets to HOST.\n"); + printf("\n"); + + printf("--fork\n"); + printf("\tEnable backgrounding rplayd at startup. (%s)\n", + do_fork ? "enabled" : "disabled"); + printf("\n"); + + printf("--group=GROUP\n"); + printf("\tRun with GROUP privs. (%s)\n", run_as_group); + printf("\n"); + + printf("--help\n"); + printf("\tDisplay helpful information.\n"); + printf("\n"); #ifdef HAVE_HELPERS - printf ("--helpers=FILE\n"); - printf ("\tUse FILE for rplay.helpers (%s).\n", RPLAY_HELPERS); - printf ("\n"); + printf("--helpers=FILE\n"); + printf("\tUse FILE for rplay.helpers (%s).\n", RPLAY_HELPERS); + printf("\n"); #endif /* HAVE_HELPERS */ #ifdef AUTH - printf ("-H FILE, --hosts=FILE\n"); - printf ("\tUse FILE for rplay.hosts (%s).\n", RPLAY_HOSTS); - printf ("\n"); + printf("-H FILE, --hosts=FILE\n"); + printf("\tUse FILE for rplay.hosts (%s).\n", RPLAY_HOSTS); + printf("\n"); #endif /* AUTH */ - printf ("--inetd\n"); - printf ("\tEnable inetd mode. (%s)\n", inetd ? "enabled" : "disabled"); - printf ("\n"); - - printf ("-L FILE, --log-file=FILE\n"); - printf ("\tUse file for rplay.log (%s).\n", RPLAY_LOG); - printf ("\n"); - - printf ("-l N, --log-level=N\n"); - printf ("\tUse logging level N where %d <= n <= %d.\n", REPORT_MIN, REPORT_MAX); - printf ("\n"); - - printf ("--memory-cache-size=N\n"); - printf ("\tMaximum size in bytes of the memory cache, disable caching with 0 (%d).\n", - MEMORY_CACHE_SIZE); - printf ("\n"); - - printf ("--memory-cache-sound-size=N\n"); - printf ("\tMaximum size in bytes of a sound that can be cached in memory.\n"); - printf ("\tA value of 0 means to try and cache all sounds. (%d)\n", - MEMORY_CACHE_SOUND_SIZE); - printf ("\n"); - - printf ("-N, --no-audio\n"); - printf ("\tDisable audio, RPTP file server mode.\n"); - printf ("\n"); + printf("--inetd\n"); + printf("\tEnable inetd mode. (%s)\n", inetd ? "enabled" : "disabled"); + printf("\n"); + + printf("-L FILE, --log-file=FILE\n"); + printf("\tUse file for rplay.log (%s).\n", RPLAY_LOG); + printf("\n"); + + printf("-l N, --log-level=N\n"); + printf("\tUse logging level N where %d <= n <= %d.\n", REPORT_MIN, REPORT_MAX); + printf("\n"); + + printf("--memory-cache-size=N\n"); + printf("\tMaximum size in bytes of the memory cache, disable caching with 0 (%d).\n", + MEMORY_CACHE_SIZE); + printf("\n"); + + printf("--memory-cache-sound-size=N\n"); + printf("\tMaximum size in bytes of a sound that can be cached in memory.\n"); + printf("\tA value of 0 means to try and cache all sounds. (%d)\n", + MEMORY_CACHE_SOUND_SIZE); + printf("\n"); + + printf("-N, --no-audio\n"); + printf("\tDisable audio, RPTP file server mode.\n"); + printf("\n"); #ifdef AUTH - printf ("--no-auth\n"); - printf ("\tDisable host access authentication.\n"); - printf ("\n"); -#endif - - printf ("-n, --no-inetd\n"); - printf ("\tDisable inetd mode. (%s)\n", inetd ? "enabled" : "disabled"); - printf ("\n"); - - printf ("--no-fork\n"); - printf ("\tDisable backgrounding rplayd at startup. (%s)\n", - do_fork ? "enabled" : "disabled"); - printf ("\n"); - - printf ("--options-file=FILE\n"); - printf ("\tRead rplayd options from FILE.\n"); - printf ("\n"); - - printf ("--port=PORT, --rplay-port=PORT\n"); - printf ("\tUse PORT as the RPLAY/UDP port. (%d)\n", RPLAY_PORT); - printf ("\t(--other-rplay-port may also be available)\n"); - printf ("\n"); - - printf ("--rptp-port=PORT\n"); - printf ("\tUse PORT as the RPTP/TCP port. (%d)\n", RPTP_PORT); - printf ("\t(--other-rptp-port may also be available)\n"); - printf ("\n"); - - printf ("-S FILE, --servers=FILE\n"); - printf ("\tUse FILE for rplay.servers (%s).\n", RPLAY_SERVERS); - printf ("\n"); - - printf ("-t N, --timeout=N\n"); - printf ("\tExit after N idle seconds, disabled with 0 (%d).\n", rplayd_timeout); - printf ("\n"); - - printf ("--user=USER\n"); - printf ("\tRun with USER privs. (%s)\n", run_as_user); - printf ("\n"); - - printf ("-v, --version\n"); - printf ("\tPrint the rplay version and exit.\n"); -} + printf("--no-auth\n"); + printf("\tDisable host access authentication.\n"); + printf("\n"); +#endif + + printf("-n, --no-inetd\n"); + printf("\tDisable inetd mode. (%s)\n", inetd ? "enabled" : "disabled"); + printf("\n"); + + printf("--no-fork\n"); + printf("\tDisable backgrounding rplayd at startup. (%s)\n", + do_fork ? "enabled" : "disabled"); + printf("\n"); + + printf("--options-file=FILE\n"); + printf("\tRead rplayd options from FILE.\n"); + printf("\n"); + + printf("--port=PORT, --rplay-port=PORT\n"); + printf("\tUse PORT as the RPLAY/UDP port. (%d)\n", RPLAY_PORT); + printf("\t(--other-rplay-port may also be available)\n"); + printf("\n"); + + printf("--rptp-port=PORT\n"); + printf("\tUse PORT as the RPTP/TCP port. (%d)\n", RPTP_PORT); + printf("\t(--other-rptp-port may also be available)\n"); + printf("\n"); + + printf("-S FILE, --servers=FILE\n"); + printf("\tUse FILE for rplay.servers (%s).\n", RPLAY_SERVERS); + printf("\n"); + + printf("-t N, --timeout=N\n"); + printf("\tExit after N idle seconds, disabled with 0 (%d).\n", rplayd_timeout); + printf("\n"); + + printf("--user=USER\n"); + printf("\tRun with USER privs. (%s)\n", run_as_user); + printf("\n"); + + printf("-v, --version\n"); + printf("\tPrint the rplay version and exit.\n"); +} diff --git a/rplayd/rplayd.h b/rplayd/rplayd.h index a7055d5..e7c94f3 100644 --- a/rplayd/rplayd.h +++ b/rplayd/rplayd.h @@ -1,7 +1,7 @@ -/* $Id: rplayd.h,v 1.2 1998/08/13 06:14:02 boyns Exp $ */ +/* $Id: rplayd.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,6 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifndef _rplayd_h #define _rplayd_h @@ -46,7 +44,7 @@ #define REPORT_MIN 0 #define REPORT_MAX 4 -/* $Id: rplayd.h,v 1.2 1998/08/13 06:14:02 boyns Exp $ */ +/* $Id: rplayd.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */ #define SET_BIT(w, bit) ( (w) |= (bit) ) #define CLR_BIT(w, bit) ( (w) &= ~(bit) ) #define BIT(w, bit) ( (w) & (bit) ) @@ -132,6 +130,8 @@ extern int default_fragsize; #endif /* HAVE_OSS */ +extern int monitor_count; +extern BUFFER *monitor_buffers; extern int errno; diff --git a/rplayd/server.c b/rplayd/server.c index 5dde0e3..0d9b4df 100644 --- a/rplayd/server.c +++ b/rplayd/server.c @@ -1,7 +1,7 @@ -/* $Id: server.c,v 1.2 1998/08/13 06:14:03 boyns Exp $ */ +/* $Id: server.c,v 1.5 1999/03/10 07:58:04 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -46,10 +46,10 @@ #ifdef __STDC__ void -server_read (char *filename) +server_read(char *filename) #else void -server_read (filename) +server_read(filename) char *filename; #endif { @@ -63,34 +63,34 @@ SERVER **s = &servers; BUFFER *b; - server_read_time = time (0); - - fp = fopen (filename, "r"); + server_read_time = time(0); + + fp = fopen(filename, "r"); if (fp == NULL) { /* * I guess it's ok to not have any servers. */ - report (REPORT_NOTICE, "warning: cannot open %s\n", filename); + report(REPORT_NOTICE, "warning: cannot open %s\n", filename); return; } - local_hp = gethostbyname (hostname); + local_hp = gethostbyname(hostname); if (local_hp == NULL) { - report (REPORT_ERROR, "server_read: %s unknown host?!\n", hostname); - done (1); - - } - memcpy ((char *) &local_addr, (char *) local_hp->h_addr, local_hp->h_length); - - b = buffer_create (); - strcpy (b->buf, "+message=\"servers\"\r\n"); - b->nbytes += strlen (b->buf); + report(REPORT_ERROR, "server_read: %s unknown host?!\n", hostname); + done(1); + + } + memcpy((char *) &local_addr, (char *) local_hp->h_addr, local_hp->h_length); + + b = buffer_create(); + strcpy(b->buf, "+message=\"servers\"\r\n"); + b->nbytes += strlen(b->buf); b->status = BUFFER_KEEP; server_list = b; - while (fgets (buf, sizeof (buf), fp)) + while (fgets(buf, sizeof(buf), fp)) { switch (buf[0]) { @@ -101,40 +101,40 @@ continue; } - p = strchr (buf, '\n'); + p = strchr(buf, '\n'); if (p) { *p = '\0'; } - p = strchr (buf, ':'); + p = strchr(buf, ':'); if (p) { *p = '\0'; - port = atoi (p + 1); + port = atoi(p + 1); } else { port = RPTP_PORT; } - addr = inet_addr (buf); - memset ((char *) &sin, 0, sizeof (sin)); + addr = inet_addr(buf); + memset((char *) &sin, 0, sizeof(sin)); if (addr == 0xffffffff) { - hp = gethostbyname (buf); + hp = gethostbyname(buf); if (hp == NULL) { - report (REPORT_NOTICE, "warning: %s unknown host in %s\n", buf, filename); + report(REPORT_NOTICE, "warning: %s unknown host in %s\n", buf, filename); continue; } - memcpy ((char *) &sin.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); + memcpy((char *) &sin.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); } else { - memcpy ((char *) &sin.sin_addr.s_addr, (char *) &addr, sizeof (addr)); - } - - if (memcmp ((char *) &sin.sin_addr.s_addr, (char *) &local_addr, sizeof (local_addr)) == 0) + memcpy((char *) &sin.sin_addr.s_addr, (char *) &addr, sizeof(addr)); + } + + if (memcmp((char *) &sin.sin_addr.s_addr, (char *) &local_addr, sizeof(local_addr)) == 0) { /* * ignore the server if it's the local host @@ -142,86 +142,86 @@ continue; } - *s = (SERVER *) malloc (sizeof (SERVER)); + *s = (SERVER *) malloc(sizeof(SERVER)); if (*s == NULL) { - report (REPORT_ERROR, "server_read: out of memory\n"); - done (1); + report(REPORT_ERROR, "server_read: out of memory\n"); + done(1); } sin.sin_family = AF_INET; - sin.sin_port = htons (port); - - SNPRINTF (SIZE(line,sizeof(line)), "host=%s port=%d\r\n", buf, port); - n = strlen (line); + sin.sin_port = htons(port); + + SNPRINTF(SIZE(line, sizeof(line)), "host=%s port=%d\r\n", buf, port); + n = strlen(line); if (b->nbytes + n > BUFFER_SIZE) { - b->next = buffer_create (); + b->next = buffer_create(); b = b->next; b->status = BUFFER_KEEP; } - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), line); + SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), line); b->nbytes += n; (*s)->sin = sin; s = &(*s)->next; - report (REPORT_DEBUG, "server %s port %d\n", inet_ntoa (sin.sin_addr), port); + report(REPORT_DEBUG, "server %s port %d\n", inet_ntoa(sin.sin_addr), port); } *s = NULL; - fclose (fp); + fclose(fp); if (b->nbytes + 3 > BUFFER_SIZE) { - b->next = buffer_create (); + b->next = buffer_create(); b = b->next; b->status = BUFFER_KEEP; } - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n"); + SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), ".\r\n"); b->nbytes += 3; } #ifdef __STDC__ void -server_reread (char *filename) +server_reread(char *filename) #else void -server_reread (filename) +server_reread(filename) char *filename; #endif { BUFFER *b, *bb; SERVER *s, *ss; - report (REPORT_DEBUG, "re-reading servers\n"); + report(REPORT_DEBUG, "re-reading servers\n"); /* * Free the server_list buffers. */ - for (b = server_list; b; bb = b, b = b->next, bb->status = BUFFER_FREE, buffer_destroy (bb)) ; + for (b = server_list; b; bb = b, b = b->next, bb->status = BUFFER_FREE, buffer_destroy(bb)) ; /* * Free the servers list. */ - for (s = servers; s; ss = s, s = s->next, free ((char *) ss)) ; + for (s = servers; s; ss = s, s = s->next, free((char *) ss)) ; server_list = NULL; servers = NULL; - server_read (filename); + server_read(filename); } #ifdef __STDC__ void -server_stat (char *filename) +server_stat(char *filename) #else void -server_stat (filename) +server_stat(filename) char *filename; #endif { - if (modified (filename, server_read_time)) - { - server_reread (filename); + if (modified(filename, server_read_time)) + { + server_reread(filename); } } diff --git a/rplayd/server.h b/rplayd/server.h index 1224b16..7f0f3d8 100644 --- a/rplayd/server.h +++ b/rplayd/server.h @@ -1,7 +1,7 @@ -/* $Id: server.h,v 1.2 1998/08/13 06:14:04 boyns Exp $ */ +/* $Id: server.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/sound.c b/rplayd/sound.c index 78ca1f7..b6b1bdc 100644 --- a/rplayd/sound.c +++ b/rplayd/sound.c @@ -1,7 +1,7 @@ -/* $Id: sound.c,v 1.6 1998/10/15 15:15:25 boyns Exp $ */ +/* $Id: sound.c,v 1.10 1999/06/09 06:27:44 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -57,7 +57,6 @@ #include "connection.h" #include "misc.h" #include "strdup.h" -#include "rxposix.h" #include "spool.h" #ifdef HAVE_CDROM #include "cdrom.h" @@ -65,6 +64,15 @@ #ifdef HAVE_HELPERS #include "helper.h" #endif /* HAVE_HELPERS */ +#ifdef HAVE_RX_RXPOSIX_H +#include +#else +#ifdef HAVE_RXPOSIX_H +#include +#else +#include "rxposix.h" +#endif +#endif SOUND *sounds = NULL; int sound_count = 0; @@ -79,40 +87,40 @@ /* Prepare `bad_dirs'. */ static void -bad_dirs_init () +bad_dirs_init() { static char *buf; char *p; char *dirs; int first, length; - dirs = strdup (BAD_DIRS); /* XXX */ - - length = strlen ("^\\(") + strlen ("\\)") + strlen (dirs) + 1; + dirs = strdup(BAD_DIRS); /* XXX */ + + length = strlen("^\\(") + strlen("\\)") + strlen(dirs) + 1; //length += strlen ("^"); for (p = dirs; *p; p++) { if (*p == ':') { - length += strlen ("\\|") - strlen (":"); + length += strlen("\\|") - strlen(":"); } } if (buf) { - free (buf); - } - buf = (char *) malloc (length); + free(buf); + } + buf = (char *) malloc(length); if (buf == NULL) { - report (REPORT_ERROR, "bad_dir_init: out of memory\n"); - done (1); + report(REPORT_ERROR, "bad_dir_init: out of memory\n"); + done(1); } first = 1; - strcpy (buf, "^\\("); - while (p = (char *) strtok (first ? dirs : 0, ":")) + strcpy(buf, "^\\("); + while (p = (char *) strtok(first ? dirs : 0, ":")) { if (first) { @@ -122,72 +130,72 @@ else { //strcat (buf, "\\|^"); - strcat (buf, "\\|"); - } - strcat (buf, p); - } - strcat (buf, "\\)"); + strcat(buf, "\\|"); + } + strcat(buf, p); + } + strcat(buf, "\\)"); #if 0 - report (REPORT_DEBUG, "bad_dirs=%s, strlen=%d, length=%d\n", - buf, strlen (buf), length); + report(REPORT_DEBUG, "bad_dirs=%s, strlen=%d, length=%d\n", + buf, strlen(buf), length); #endif //memset ((char *) &bad_dirs, 0, sizeof (bad_dirs)); - if (regncomp (&bad_dirs, buf, strlen (buf), REG_ICASE | REG_NOSUB)) - { - report (REPORT_ERROR, "bad_dirs: regncomp failed\n"); - done (1); - } - - free (dirs); + if (regncomp(&bad_dirs, buf, strlen(buf), REG_ICASE | REG_NOSUB)) + { + report(REPORT_ERROR, "bad_dirs: regncomp failed\n"); + done(1); + } + + free(dirs); } #ifdef __STDC__ static int -bad_dir (char *dir) +bad_dir(char *dir) #else static int -bad_dir (dir) +bad_dir(dir) char *dir; #endif { /* return 1 if bad */ - return regnexec (&bad_dirs, dir, strlen (dir), 0, 0, 0) ? 0 : 1; + return regnexec(&bad_dirs, dir, strlen(dir), 0, 0, 0) ? 0 : 1; } #endif /* BAD_DIRS */ #ifdef __STDC__ void -sound_read_directory (char *dirname) +sound_read_directory(char *dirname) #else void -sound_read_directory (dirname) +sound_read_directory(dirname) char *dirname; #endif { char soundname[MAXPATHLEN]; struct dirent *dp; - DIR *dir = opendir (dirname); + DIR *dir = opendir(dirname); if (dir == NULL) { - report (REPORT_ERROR, "opendir %s: %s", sys_err_str (errno)); + report(REPORT_ERROR, "opendir %s: %s", sys_err_str(errno)); return; } - while ((dp = readdir (dir)) != NULL) - { - if (strcmp (dp->d_name, ".") == 0 || strcmp (dp->d_name, "..") == 0) + while ((dp = readdir(dir)) != NULL) + { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) { continue; } - sprintf (soundname, "%s/%s", dirname, dp->d_name); - sound_insert (soundname, SOUND_READY, SOUND_FILE); - } - - closedir (dir); + sprintf(soundname, "%s/%s", dirname, dp->d_name); + sound_insert(soundname, SOUND_READY, SOUND_FILE); + } + + closedir(dir); } @@ -196,10 +204,10 @@ */ #ifdef __STDC__ void -sound_read (char *filename) +sound_read(char *filename) #else void -sound_read (filename) +sound_read(filename) char *filename; #endif { @@ -207,10 +215,10 @@ char buf[MAXPATHLEN], *p; struct stat st; - xhash_init (MAX_SOUNDS); + xhash_init(MAX_SOUNDS); #ifdef BAD_DIRS - bad_dirs_init (); + bad_dirs_init(); #endif #ifdef HAVE_CDROM @@ -219,24 +227,24 @@ int i; for (i = 0; i < MAX_CDROMS; i++) { - sound_insert (cdrom_table[i].name, SOUND_READY, SOUND_CDROM); - } - } -#endif /* HAVE_CDROM */ - - sound_read_time = time (0); - - fp = fopen (filename, "r"); + sound_insert(cdrom_table[i].name, SOUND_READY, SOUND_CDROM); + } + } +#endif /* HAVE_CDROM */ + + sound_read_time = time(0); + + fp = fopen(filename, "r"); if (fp == NULL) { - report (REPORT_NOTICE, "warning: cannot open %s\n", filename); + report(REPORT_NOTICE, "warning: cannot open %s\n", filename); /* * no local sounds */ return; } - while (fgets (buf, sizeof (buf), fp) != NULL) + while (fgets(buf, sizeof(buf), fp) != NULL) { switch (buf[0]) { @@ -246,45 +254,45 @@ case '\n': continue; } - p = strchr (buf, '\n'); + p = strchr(buf, '\n'); if (p) { *p = '\0'; } - if (stat (buf, &st) < 0) - { - report (REPORT_ERROR, "sound_read: %s: %s\n", buf, sys_err_str (errno)); + if (stat(buf, &st) < 0) + { + report(REPORT_ERROR, "sound_read: %s: %s\n", buf, sys_err_str(errno)); continue; } - - if (S_ISDIR (st.st_mode)) - { - sound_read_directory (buf); + + if (S_ISDIR(st.st_mode)) + { + sound_read_directory(buf); } else { - sound_insert (buf, SOUND_READY, SOUND_FILE); - } - } - - fclose (fp); + sound_insert(buf, SOUND_READY, SOUND_FILE); + } + } + + fclose(fp); } #ifdef __STDC__ static char * -destroy (char *hash_string, char *hash_value) +destroy(char *hash_string, char *hash_value) #else static char * -destroy (hash_string, hash_value) +destroy(hash_string, hash_value) char *hash_string; char *hash_value; #endif { SOUND *s = (SOUND *) hash_value; - sound_free (s); - free ((char *) s); + sound_free(s); + free((char *) s); return NULL; } @@ -294,16 +302,16 @@ */ #ifdef __STDC__ void -sound_reread (char *filename) +sound_reread(char *filename) #else void -sound_reread (filename) +sound_reread(filename) char *filename; #endif { SOUND *s1, *s1_next, *s2, *s2_next; - report (REPORT_DEBUG, "re-reading sounds\n"); + report(REPORT_DEBUG, "re-reading sounds\n"); /* * Delete all the sounds. @@ -316,16 +324,16 @@ { s2_next = s2->next; /* xhash_delete(s2->hash_key); */ - sound_free (s2); - free ((char *) s2); + sound_free(s2); + free((char *) s2); } } #else - xhash_apply (destroy); -#endif - - xhash_die (); - xhash_init (MAX_SOUNDS); + xhash_apply(destroy); +#endif + + xhash_die(); + xhash_init(MAX_SOUNDS); sounds = NULL; sound_count = 0; @@ -333,41 +341,41 @@ /* * and now load the sounds */ - sound_read (filename); + sound_read(filename); /* * don't forget the cache... */ - cache_read (); + cache_read(); } #ifdef __STDC__ void -sound_stat (char *filename) +sound_stat(char *filename) #else void -sound_stat (filename) +sound_stat(filename) char *filename; #endif { - if (modified (filename, sound_read_time)) - { - sound_reread (filename); + if (modified(filename, sound_read_time)) + { + sound_reread(filename); } } BUFFER * -sound_list_create () +sound_list_create() { SOUND *s; int n; BUFFER *start, *b; char line[RPTP_MAX_LINE]; - b = buffer_create (); + b = buffer_create(); start = b; - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), "+message=\"sounds\"\r\n"); - b->nbytes += strlen (b->buf); + SNPRINTF(SIZE(b->buf + strlen(b->buf), BUFFER_SIZE), "+message=\"sounds\"\r\n"); + b->nbytes += strlen(b->buf); for (s = sounds; s; s = s->list) { @@ -378,33 +386,33 @@ if (s->mapped) { - SNPRINTF (SIZE(line,sizeof(line)), "\ + SNPRINTF(SIZE(line, sizeof(line)), "\ sound=\"%s\" size=%d bits=%g sample_rate=%d channels=%d samples=%d\r\n", - s->name, s->size, s->input_precision, s->sample_rate, s->channels, - s->samples); + s->name, s->size, s->input_precision, s->sample_rate, s->channels, + s->samples); } else { - SNPRINTF (SIZE(line,sizeof(line)), "sound=\"%s\"\r\n", s->name); - } - - n = strlen (line); + SNPRINTF(SIZE(line, sizeof(line)), "sound=\"%s\"\r\n", s->name); + } + + n = strlen(line); if (b->nbytes + n > BUFFER_SIZE) { - b->next = buffer_create (); + b->next = buffer_create(); b = b->next; } - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), line); + strncat(b->buf + b->nbytes, line, BUFFER_SIZE - b->nbytes); b->nbytes += n; } if (b->nbytes + 3 > BUFFER_SIZE) { - b->next = buffer_create (); + b->next = buffer_create(); b = b->next; } - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n"); + SNPRINTF(SIZE(b->buf + b->nbytes, BUFFER_SIZE - b->nbytes), ".\r\n"); b->nbytes += 3; return start; @@ -412,10 +420,10 @@ #ifdef __STDC__ SOUND * -sound_insert (char *path, int status, int type) +sound_insert(char *path, int status, int type) #else SOUND * -sound_insert (path, status, type) +sound_insert(path, status, type) char *path; int status; int type; @@ -425,41 +433,41 @@ char *hash_val; #ifdef BAD_DIRS - if (bad_dir (path)) - { - report (REPORT_NOTICE, "bad_dir: attempt to load %s\n", path); + if (bad_dir(path)) + { + report(REPORT_NOTICE, "bad_dir: attempt to load %s\n", path); return NULL; } #endif - s = sound_create (); + s = sound_create(); if (s == NULL) { - report (REPORT_ERROR, "sound_insert: out of memory\n"); - done (1); + report(REPORT_ERROR, "sound_insert: out of memory\n"); + done(1); } s->type = type; - s->path = strdup (path); + s->path = strdup(path); if (s->path == NULL) { - report (REPORT_ERROR, "sound_insert: out of memory\n"); - done (1); - } - s->hash_key = strdup (xhash_name (s->path)); + report(REPORT_ERROR, "sound_insert: out of memory\n"); + done(1); + } + s->hash_key = strdup(xhash_name(s->path)); if (s->hash_key == NULL) { - report (REPORT_ERROR, "sound_insert: out of memory\n"); - done (1); - } - s->name = s->path[0] == '/' ? strrchr (s->path, '/') + 1 : s->path; + report(REPORT_ERROR, "sound_insert: out of memory\n"); + done(1); + } + s->name = s->path[0] == '/' ? strrchr(s->path, '/') + 1 : s->path; s->status = status; - hash_val = xhash_get (s->hash_key); + hash_val = xhash_get(s->hash_key); if (hash_val == NULL) { - xhash_put (s->hash_key, (char *) s); + xhash_put(s->hash_key, (char *) s); s->list_prev = NULL; s->list = sounds; @@ -475,9 +483,9 @@ for (ss = (SOUND *) hash_val; ss; prev = ss, ss = ss->next) { - if (strcmp (ss->path, s->path) == 0) - { - free ((char *) s); + if (strcmp(ss->path, s->path) == 0) + { + free((char *) s); return ss; } } @@ -493,15 +501,15 @@ */ #ifdef __STDC__ SOUND * -sound_create (void) +sound_create(void) #else SOUND * -sound_create () +sound_create() #endif { SOUND *s; - s = (SOUND *) malloc (sizeof (SOUND)); + s = (SOUND *) malloc(sizeof(SOUND)); if (s == NULL) { return s; @@ -551,10 +559,10 @@ */ #ifdef __STDC__ SOUND * -sound_lookup (char *name, int mode, SERVER *lookup_server) +sound_lookup(char *name, int mode, SERVER *lookup_server) #else SOUND * -sound_lookup (name, mode, lookup_server) +sound_lookup(name, mode, lookup_server) char *name; int mode; SERVER *lookup_server; @@ -564,30 +572,30 @@ int has_extension = 0, has_pathname = 0; struct stat st; int i; - + #ifdef HAVE_CDROM /* Map sounds with cdrom prefixes to the cdrom itself. */ for (i = 0; i < MAX_CDROMS; i++) { - if (strncmp (name, cdrom_table[i].name, strlen (cdrom_table[i].name)) == 0) + if (strncmp(name, cdrom_table[i].name, strlen(cdrom_table[i].name)) == 0) { break; } } if (i < MAX_CDROMS) { - s = (SOUND *) xhash_get (xhash_name (cdrom_table[i].name)); + s = (SOUND *) xhash_get(xhash_name(cdrom_table[i].name)); } #endif /* HAVE_CDROM */ if (s == NULL) { - s = (SOUND *) xhash_get (xhash_name (name)); + s = (SOUND *) xhash_get(xhash_name(name)); } if (s == NULL) { - report (REPORT_DEBUG, "%s not in hash table\n", name); + report(REPORT_DEBUG, "%s not in hash table\n", name); if (mode == SOUND_DONT_FIND || mode == SOUND_DONT_COUNT) { @@ -597,10 +605,10 @@ /* * see if a local file can be loaded (mode == SOUND_LOAD) */ - if (stat (name, &st) == 0) - { - report (REPORT_DEBUG, "loading local file %s\n", name); - s = sound_insert (name, SOUND_READY, SOUND_FILE); + if (stat(name, &st) == 0) + { + report(REPORT_DEBUG, "loading local file %s\n", name); + s = sound_insert(name, SOUND_READY, SOUND_FILE); if (s == NULL) { return NULL; @@ -608,39 +616,39 @@ } #if 0 /* virtual sounds cause searching problems */ -#ifdef HAVE_HELPERS - else if (mode == SOUND_CREATE && helper_lookup (name)) - { - s = sound_insert (name, SOUND_READY, SOUND_VIRTUAL); - } -#endif -#endif +#ifdef HAVE_HELPERS + else if (mode == SOUND_CREATE && helper_lookup(name)) + { + s = sound_insert(name, SOUND_READY, SOUND_VIRTUAL); + } +#endif +#endif else if (mode == SOUND_FIND) { if (name[0] == '/') { - report (REPORT_DEBUG, "not searching for %s\n", name); + report(REPORT_DEBUG, "not searching for %s\n", name); return NULL; } if (lookup_server) { - report (REPORT_DEBUG, "searching for %s\n", name); - s = sound_insert (cache_name (name), SOUND_SEARCH, SOUND_FILE); + report(REPORT_DEBUG, "searching for %s\n", name); + s = sound_insert(cache_name(name), SOUND_SEARCH, SOUND_FILE); if (s == NULL) { return NULL; } - connection_server_open (lookup_server, s); + connection_server_open(lookup_server, s); } else if (servers) { - report (REPORT_DEBUG, "searching for %s\n", name); - s = sound_insert (cache_name (name), SOUND_SEARCH, SOUND_FILE); + report(REPORT_DEBUG, "searching for %s\n", name); + s = sound_insert(cache_name(name), SOUND_SEARCH, SOUND_FILE); if (s == NULL) { return NULL; } - connection_server_open (servers, s); + connection_server_open(servers, s); } else { @@ -662,17 +670,17 @@ { has_pathname++; } - else if (strrchr (name, '.')) + else if (strrchr(name, '.')) { has_extension++; } for (; s; s = s->next) { - if (has_pathname && (!s->path || strcmp (name, s->path) != 0)) + if (has_pathname && (!s->path || strcmp(name, s->path) != 0)) { continue; } - if (has_extension && (!s->path || strcmp (name, s->name) != 0)) + if (has_extension && (!s->path || strcmp(name, s->name) != 0)) { continue; } @@ -682,11 +690,11 @@ { if (has_pathname) { - report (REPORT_DEBUG, "`%s' file name not in hash table\n", name); - if (stat (name, &st) == 0) + report(REPORT_DEBUG, "`%s' file name not in hash table\n", name); + if (stat(name, &st) == 0) { - report (REPORT_DEBUG, "loading local file `%s'\n", name); - s = sound_insert (name, SOUND_READY, SOUND_FILE); + report(REPORT_DEBUG, "loading local file `%s'\n", name); + s = sound_insert(name, SOUND_READY, SOUND_FILE); if (s == NULL) { return NULL; @@ -699,7 +707,7 @@ } else if (has_extension) { - report (REPORT_DEBUG, "`%s' extension not in hash table\n", name); + report(REPORT_DEBUG, "`%s' extension not in hash table\n", name); return NULL; } } @@ -724,7 +732,7 @@ if (!s->mapped) { - return sound_map (s) == 0 ? s : NULL; + return sound_map(s) == 0 ? s : NULL; } else { @@ -737,10 +745,10 @@ */ #ifdef __STDC__ int -sound_map (SOUND *s) +sound_map(SOUND *s) #else int -sound_map (s) +sound_map(s) SOUND *s; #endif { @@ -777,23 +785,23 @@ optional_storage = s->storage; #ifdef HAVE_HELPERS - helper = helper_lookup (s->path); + helper = helper_lookup(s->path); if (helper) { s->needs_helper++; - strcpy (buf, "HELPER"); /* XXX: not used; see below */ + strcpy(buf, "HELPER"); /* XXX: not used; see below */ } else #endif /* HAVE_HELPERS */ #ifdef HAVE_CDROM if (s->type == SOUND_CDROM) { - strcpy (buf, "CDROM"); + strcpy(buf, "CDROM"); } else #endif /* HAVE_CDROM */ { - si = sound_open (s, 1); + si = sound_open(s, 1); if (si == NULL) { return -1; @@ -803,25 +811,25 @@ sort of sound this is. */ storage = s->storage; s->storage = SOUND_STORAGE_MEMORY; - b = buffer_alloc (SOUND_MAX_HEADER_SIZE, BUFFER_FREE); - n = sound_fill (si, b, 1); + b = buffer_alloc(SOUND_MAX_HEADER_SIZE, BUFFER_FREE); + n = sound_fill(si, b, 1); s->storage = storage; if (n <= 0) { - report (REPORT_DEBUG, "sound_map: sound_fill %d\n", n); - buffer_dealloc (b, 1); + report(REPORT_DEBUG, "sound_map: sound_fill %d\n", n); + buffer_dealloc(b, 1); return -1; } - sound_close (si); + sound_close(si); /* Copy the buffer contents to `buf' so `b' can be destroyed. */ - memcpy (buf, b->buf, MIN (sizeof (buf), b->nbytes)); - buffer_dealloc (b, 1); + memcpy(buf, b->buf, MIN(sizeof(buf), b->nbytes)); + buffer_dealloc(b, 1); } /* u-law */ - if (strncmp (buf, ".snd", 4) == 0) + if (strncmp(buf, ".snd", 4) == 0) { long ulaw_hdr_size; int encoding; @@ -830,11 +838,11 @@ p = buf + 4; - ulaw_hdr_size = big_long (p); + ulaw_hdr_size = big_long(p); p += 4; if (ulaw_hdr_size < ULAW_HDRSIZE) { - report (REPORT_DEBUG, "%s not a ulaw file\n", s->path); + report(REPORT_DEBUG, "%s not a ulaw file\n", s->path); return -1; } @@ -842,10 +850,10 @@ * The audio data size which may be ~0. * This value is ignored. */ - data_size = big_long (p); + data_size = big_long(p); p += 4; - encoding = big_long (p); + encoding = big_long(p); p += 4; switch (encoding) { @@ -867,29 +875,29 @@ s->output_precision = 16; break; -#ifdef HAVE_ADPCM +#ifdef HAVE_ADPCM case ULAW_G721: s->format = RPLAY_FORMAT_G721; s->input_precision = 4; - s->output_precision = 16; /* uncompressed to 16-bit */ + s->output_precision = 16; /* uncompressed to 16-bit */ break; case ULAW_G723_3: s->format = RPLAY_FORMAT_G723_3; s->input_precision = 3; - s->output_precision = 16; /* uncompressed to 16-bit */ + s->output_precision = 16; /* uncompressed to 16-bit */ break; case ULAW_G723_5: s->format = RPLAY_FORMAT_G723_5; s->input_precision = 5; - s->output_precision = 16; /* uncompressed to 16-bit */ + s->output_precision = 16; /* uncompressed to 16-bit */ break; #endif /* HAVE_ADPCM */ - + default: - report (REPORT_DEBUG, "%s: %d - unsupported ulaw encoding\n", - s->path, encoding); + report(REPORT_DEBUG, "%s: %d - unsupported ulaw encoding\n", + s->path, encoding); return -1; } @@ -901,13 +909,13 @@ /* * Sample rate. */ - s->sample_rate = big_long (p); + s->sample_rate = big_long(p); p += 4; /* * Number of channels. */ - s->channels = big_long (p); + s->channels = big_long(p); p += 4; s->offset = ulaw_hdr_size; @@ -922,7 +930,7 @@ } } /* aiff */ - else if (strncmp (buf, "FORM", 4) == 0) + else if (strncmp(buf, "FORM", 4) == 0) { unsigned long total_size; unsigned long chunk_size; @@ -937,10 +945,10 @@ p = buf + 4; - total_size = big_long (p); + total_size = big_long(p); p += 4; - if (memcmp (p, "AIFF", 4) != 0) + if (memcmp(p, "AIFF", 4) != 0) { return -1; } @@ -954,42 +962,42 @@ /* * Chunk id. */ - memcpy (id, p, 4); + memcpy(id, p, 4); id[4] = '\0'; p += 4; /* * Chunk size. */ - chunk_size = big_long (p); + chunk_size = big_long(p); p += 4; /* * COMM Chunk. */ - if (memcmp (id, "COMM", 4) == 0) - { - channels = big_short (p); + if (memcmp(id, "COMM", 4) == 0) + { + channels = big_short(p); p += 2; - frames = big_long (p); + frames = big_long(p); p += 4; - bits = big_short (p); + bits = big_short(p); p += 2; - rate = ConvertFromIeeeExtended ((unsigned char *) p); + rate = ConvertFromIeeeExtended((unsigned char *) p); p += 10; } /* * SSN Chunk. */ - else if (memcmp (id, "SSND", 4) == 0) - { - offset = big_long (p); + else if (memcmp(id, "SSND", 4) == 0) + { + offset = big_long(p); p += 4; - block_size = big_long (p); + block_size = big_long(p); sound_chunk_size = block_size; p += 4; break; @@ -1020,7 +1028,7 @@ s->output_precision = bits; s->channels = channels; - switch ((int)s->input_precision) + switch ((int) s->input_precision) { case 8: s->format = RPLAY_FORMAT_LINEAR_8; @@ -1031,17 +1039,17 @@ break; default: - report (REPORT_ERROR, "unsupported aiff precision `%g'\n", - s->input_precision); + report(REPORT_ERROR, "unsupported aiff precision `%g'\n", + s->input_precision); return -1; } } /* deadsnd files */ - else if (*((long *)&buf) == 0x4a02b6d2) - { - DSID *dsid = (DSID *)&buf; - - s->offset = sizeof (DSID); + else if (*((long *) &buf) == 0x4a02b6d2) + { + DSID *dsid = (DSID *) & buf; + + s->offset = sizeof(DSID); s->sample_rate = dsid->freq; s->input_precision = s->output_precision = dsid->bps; s->channels = (dsid->mode + 1); @@ -1052,18 +1060,18 @@ case 8: s->format = RPLAY_FORMAT_ULINEAR_8; break; - + case 16: s->format = RPLAY_FORMAT_LINEAR_16; break; - + default: - report (REPORT_ERROR, "unsupported deadsnd precision `%d'\n", dsid->bps); + report(REPORT_ERROR, "unsupported deadsnd precision `%d'\n", dsid->bps); return -1; } } /* wave */ - else if (strncmp (buf, "RIFF", 4) == 0) + else if (strncmp(buf, "RIFF", 4) == 0) { unsigned long chunk_size; short chunk_type; @@ -1076,9 +1084,9 @@ p = buf + 4; p += 4; - if (memcmp (p, "WAVE", 4) != 0) - { - report (REPORT_ERROR, "wave file missing `WAVE' header\n"); + if (memcmp(p, "WAVE", 4) != 0) + { + report(REPORT_ERROR, "wave file missing `WAVE' header\n"); return -1; } p += 4; @@ -1091,38 +1099,41 @@ /* * Chunk id. */ - memcpy (id, p, 4); + memcpy(id, p, 4); id[4] = '\0'; p += 4; /* * Chunk size. */ - chunk_size = little_long (p); + chunk_size = little_long(p); p += 4; /* * 'fmt ' Chunk. */ - if (memcmp (id, "fmt ", 4) == 0) + if (memcmp(id, "fmt ", 4) == 0) { char *start_of_chunk = p; - chunk_type = little_short (p); + chunk_type = little_short(p); p += 2; /* * Only one wave format is supported. */ if (chunk_type == 0x0001) { - channels = little_short (p); p += 2; - rate = little_long (p); p += 4; - p += 4; /* bytes/second ? */ - p += 2; /* block align ? */ - bits = little_short (p); p += 2; + channels = little_short(p); + p += 2; + rate = little_long(p); + p += 4; + p += 4; /* bytes/second ? */ + p += 2; /* block align ? */ + bits = little_short(p); + p += 2; } else { - report (REPORT_ERROR, "unknown wave chunk `%x'\n", chunk_type); + report(REPORT_ERROR, "unknown wave chunk `%x'\n", chunk_type); return -1; } p = start_of_chunk + chunk_size; @@ -1130,7 +1141,7 @@ /* * data Chunk. */ - else if (memcmp (id, "data", 4) == 0) + else if (memcmp(id, "data", 4) == 0) { /* size */ sound_chunk_size = chunk_size; @@ -1141,8 +1152,8 @@ */ else { - report (REPORT_DEBUG, "ignoring chunk - %s (%d)\n", - id, chunk_size); + report(REPORT_DEBUG, "ignoring chunk - %s (%d)\n", + id, chunk_size); p += chunk_size; /* * skip the pad byte, if necessary @@ -1158,7 +1169,7 @@ s->output_precision = bits; s->channels = channels; - switch ((int)s->input_precision) + switch ((int) s->input_precision) { case 8: s->format = RPLAY_FORMAT_ULINEAR_8; @@ -1169,8 +1180,8 @@ break; default: - report (REPORT_ERROR, "unsupported wave precision `%g'\n", - s->input_precision); + report(REPORT_ERROR, "unsupported wave precision `%g'\n", + s->input_precision); return -1; } @@ -1180,7 +1191,7 @@ s->byte_order = RPLAY_LITTLE_ENDIAN; } /* voc */ - else if (strncmp (buf, "Creative Voice File\032", 20) == 0) + else if (strncmp(buf, "Creative Voice File\032", 20) == 0) { char *p; short header_size; @@ -1189,11 +1200,11 @@ p = buf + 20; - header_size = little_short (p); /* sizeof header */ + header_size = little_short(p); /* sizeof header */ p += 2; /* major/minor version + checksum of version */ - p += 2 * sizeof (short); + p += 2 * sizeof(short); for (;;) { @@ -1220,11 +1231,11 @@ s->channels = 1; break; } - else if (block_id == 9) /* VOC_DATA_16 */ + else if (block_id == 9) /* VOC_DATA_16 */ { //sound_chunk_size = block_length; - s->sample_rate = little_long (p); + s->sample_rate = little_long(p); p += 4; switch (*p) @@ -1233,28 +1244,28 @@ s->input_precision = 8; s->output_precision = 8; break; - + case 16: s->input_precision = 16; s->output_precision = 16; break; default: - report (REPORT_ERROR, "unsupported voc_data_16 precision `%d'\n", - *p); + report(REPORT_ERROR, "unsupported voc_data_16 precision `%d'\n", + *p); return -1; } *p++; - + s->channels = *p++; - - p++; /* unknown */ - p++; /* not used */ - p++; /* not used */ - p++; /* not used */ - p++; /* not used */ - p++; /* not used */ - + + p++; /* unknown */ + p++; /* not used */ + p++; /* not used */ + p++; /* not used */ + p++; /* not used */ + p++; /* not used */ + break; } @@ -1264,7 +1275,7 @@ s->offset = p - buf; s->byte_order = RPLAY_LITTLE_ENDIAN; - switch ((int)s->input_precision) + switch ((int) s->input_precision) { case 8: s->format = RPLAY_FORMAT_ULINEAR_8; @@ -1275,8 +1286,8 @@ break; default: - report (REPORT_ERROR, "unsupported voc precision `%d'\n", - s->input_precision); + report(REPORT_ERROR, "unsupported voc precision `%d'\n", + s->input_precision); return -1; } } @@ -1286,7 +1297,7 @@ { s->offset = 0; s->format = RPLAY_FORMAT_GSM; - s->byte_order = RPLAY_BIG_ENDIAN; /* ??? */ + s->byte_order = RPLAY_BIG_ENDIAN; /* ??? */ s->sample_rate = 8000; s->input_precision = 1.65; s->output_precision = 16; @@ -1294,7 +1305,7 @@ } #endif /* HAVE_GSM */ #ifdef HAVE_CDROM - else if (strcmp (buf, "CDROM") == 0) + else if (strcmp(buf, "CDROM") == 0) { s->offset = 0; s->format = RPLAY_FORMAT_LINEAR_16; @@ -1305,15 +1316,15 @@ s->channels = 2; s->storage = SOUND_STORAGE_NONE; } -#endif /* HAVE_CDROM */ +#endif /* HAVE_CDROM */ /* Unknown audio header -- try to use the extension. */ else { char *p; - report (REPORT_DEBUG, "%s missing sound header; trying helper or extension\n", s->path); - p = strrchr (s->path, '.'); -#ifdef HAVE_HELPERS + report(REPORT_DEBUG, "%s missing sound header; trying helper or extension\n", s->path); + p = strrchr(s->path, '.'); +#ifdef HAVE_HELPERS if (s->needs_helper) { s->offset = 0; @@ -1326,10 +1337,10 @@ s->storage = SOUND_STORAGE_NONE; } else -#endif - if (p && strcmp (p, ".ub") == 0) - { - report (REPORT_DEBUG, "%s assuming ub\n", s->path); +#endif + if (p && strcmp(p, ".ub") == 0) + { + report(REPORT_DEBUG, "%s assuming ub\n", s->path); s->offset = 0; s->format = RPLAY_FORMAT_ULINEAR_8; s->byte_order = RPLAY_BIG_ENDIAN; @@ -1338,9 +1349,9 @@ s->output_precision = 8; s->channels = 1; } - else if (p && (strcmp (p, ".au") == 0 || strcmp (p, ".ul") == 0)) - { - report (REPORT_DEBUG, "%s assuming ulaw\n", s->path); + else if (p && (strcmp(p, ".au") == 0 || strcmp(p, ".ul") == 0)) + { + report(REPORT_DEBUG, "%s assuming ulaw\n", s->path); s->offset = 0; s->format = RPLAY_FORMAT_ULAW; s->byte_order = RPLAY_BIG_ENDIAN; @@ -1349,13 +1360,13 @@ s->output_precision = 8; s->channels = 1; } -#ifdef HAVE_GSM - else if (p && (strcmp (p, ".gsm") == 0 || strcmp (p, ".GSM") == 0)) - { - report (REPORT_DEBUG, "%s assuming gsm\n", s->path); +#ifdef HAVE_GSM + else if (p && (strcmp(p, ".gsm") == 0 || strcmp(p, ".GSM") == 0)) + { + report(REPORT_DEBUG, "%s assuming gsm\n", s->path); s->offset = 0; s->format = RPLAY_FORMAT_GSM; - s->byte_order = RPLAY_BIG_ENDIAN; /* ??? */ + s->byte_order = RPLAY_BIG_ENDIAN; /* ??? */ s->sample_rate = 8000; s->input_precision = 1.65; s->output_precision = 16; @@ -1368,7 +1379,7 @@ && !optional_input_precision && !optional_channels) { - report (REPORT_ERROR, "`%s' unknown audio file\n", s->path); + report(REPORT_ERROR, "`%s' unknown audio file\n", s->path); return -1; } } @@ -1393,7 +1404,7 @@ switch (s->format) { #ifdef HAVE_ADPCM - /* G.72X files *must* have 16-bit output. */ + /* G.72X files *must* have 16-bit output. */ case RPLAY_FORMAT_G721: case RPLAY_FORMAT_G723_3: case RPLAY_FORMAT_G723_5: @@ -1402,7 +1413,7 @@ #endif /* HAVE_ADPCM */ #ifdef HAVE_GSM - /* Fix-up GSM info. */ + /* Fix-up GSM info. */ case RPLAY_FORMAT_GSM: s->output_precision = 16; s->input_precision = 1.65; @@ -1411,7 +1422,7 @@ s->offset = 0; break; #endif /* HAVE_GSM */ - + default: break; } @@ -1419,7 +1430,7 @@ if (!s->format || !s->byte_order || !s->sample_rate || !s->input_precision || !s->output_precision || !s->channels) { - report (REPORT_ERROR, "`%s' invalid audio parameters\n", s->path); + report(REPORT_ERROR, "`%s' invalid audio parameters\n", s->path); return -1; } @@ -1432,7 +1443,7 @@ if (sound_chunk_size > 0) { /* Make sure sound_chunk_size is valid */ - if (s->size == 0 || sound_chunk_size < s->size) /* size==0 for flows */ + if (s->size == 0 || sound_chunk_size < s->size) /* size==0 for flows */ { s->chunk_size = sound_chunk_size; } @@ -1450,10 +1461,10 @@ s->chunk_size = s->size - s->offset; } -#if 0 - printf ("SOUND: %s size=%d chunk=%d tail=%d offset=%d\n", - s->name, s->size, s->chunk_size, s->tail, s->offset); -#endif +#if 0 + printf("SOUND: %s size=%d chunk=%d tail=%d offset=%d\n", + s->name, s->size, s->chunk_size, s->tail, s->offset); +#endif if (s->type != SOUND_FILE) { @@ -1467,24 +1478,25 @@ s->size = 0; s->samples = 0; } -#endif +#endif else { - s->samples = number_of_samples (s, 0); // NUMBER_OF_SAMPLES (s); + s->samples = number_of_samples(s, 0); // NUMBER_OF_SAMPLES (s); + } s->mapped = 1; - report (REPORT_DEBUG, "\ + report(REPORT_DEBUG, "\ %s input=%s bits=%g sample-rate=%d channels=%d samples=%d format=%s byte-order=%s\n", - s->name, - input_to_string (s->type), - s->input_precision, - s->sample_rate, - s->channels, - s->samples, - audio_format_to_string (s->format), - byte_order_to_string (s->byte_order)); + s->name, + input_to_string(s->type), + s->input_precision, + s->sample_rate, + s->channels, + s->samples, + audio_format_to_string(s->format), + byte_order_to_string(s->byte_order)); return 0; } @@ -1494,10 +1506,10 @@ */ #ifdef __STDC__ int -sound_unmap (SOUND *s) +sound_unmap(SOUND *s) #else int -sound_unmap (s) +sound_unmap(s) SOUND *s; #endif { @@ -1506,18 +1518,18 @@ if (s->cache) { #ifdef HAVE_MMAP - munmap (s->cache, s->size); + munmap(s->cache, s->size); #else /* not HAVE_MMAP */ - free ((char *) s->cache); + free((char *) s->cache); #endif /* not HAVE_MMAP */ s->cache = NULL; sound_cache_size -= s->size; } } - + if (s->type == SOUND_FLOW || s->needs_helper) { - buffer_dealloc (s->flow, 1); + buffer_dealloc(s->flow, 1); s->flow = NULL; s->flowp = &s->flow; } @@ -1530,18 +1542,18 @@ /* Free *all* memory used by a sound. */ #ifdef __STDC__ int -sound_free (SOUND *s) +sound_free(SOUND *s) #else int -sound_free (s) +sound_free(s) SOUND *s; #endif { - sound_unmap (s); - - free ((char *) s->path); + sound_unmap(s); + + free((char *) s->path); s->path = NULL; - free ((char *) s->hash_key); + free((char *) s->hash_key); s->hash_key = NULL; return 0; @@ -1550,10 +1562,10 @@ /* Delete a sound from the list of sounds. */ #ifdef __STDC__ void -sound_delete (SOUND *s, int remove) +sound_delete(SOUND *s, int remove) #else void -sound_delete (s, remove) +sound_delete(s, remove) SOUND *s; int remove; #endif @@ -1564,7 +1576,7 @@ { if (s->hash_key) { - xhash_delete (s->hash_key); + xhash_delete(s->hash_key); } if (s->list_prev) { @@ -1610,8 +1622,8 @@ /* Copy the list links. */ s->next->list = s->list; s->next->list_prev = s->list_prev; - - xhash_replace (s->next->hash_key, (char *) s->next); + + xhash_replace(s->next->hash_key, (char *) s->next); } } @@ -1619,34 +1631,34 @@ { struct stat st; - if (stat (s->path, &st) == 0) - { - if (unlink (s->path) < 0) - { - report (REPORT_ERROR, "sound_delete: unlink %s: %s\n", s->path, - sys_err_str (errno)); - } - } - } - - sound_free (s); - free ((char *) s); + if (stat(s->path, &st) == 0) + { + if (unlink(s->path) < 0) + { + report(REPORT_ERROR, "sound_delete: unlink %s: %s\n", s->path, + sys_err_str(errno)); + } + } + } + + sound_free(s); + free((char *) s); } /* * Free cached sounds and delete sound flows. */ void -sound_cleanup () +sound_cleanup() { SOUND *s1, *s1_next, *s, *s_next; EVENT *e; CONNECTION *c; SPOOL *sp; int n; - - report (REPORT_DEBUG, "cleaning up sounds\n"); - + + report(REPORT_DEBUG, "cleaning up sounds\n"); + for (s1 = sounds; s1; s1 = s1_next) { s1_next = s1->list; @@ -1690,7 +1702,7 @@ } if (n == 0) { - sound_unmap (s); + sound_unmap(s); } } /* Flows */ @@ -1707,11 +1719,11 @@ } if (n != 0) { - report (REPORT_DEBUG, "sound_clean: not cleaning flow `%s'\n", s->name); + report(REPORT_DEBUG, "sound_clean: not cleaning flow `%s'\n", s->name); } else { - sound_clean (s); + sound_clean(s); } } #ifdef HAVE_CDROM @@ -1727,11 +1739,11 @@ } if (n != 0) { - report (REPORT_DEBUG, "sound_clean: not cleaning cdrom `%s'\n", s->name); + report(REPORT_DEBUG, "sound_clean: not cleaning cdrom `%s'\n", s->name); } else { - sound_clean (s); + sound_clean(s); } } #endif /* HAVE_CDROM */ @@ -1743,12 +1755,12 @@ #ifdef __STDC__ void -sound_clean (SOUND *s) +sound_clean(SOUND *s) #else void -sound_clean (s) +sound_clean(s) SOUND *s; -#endif +#endif { BUFFER *b; int n, fd; @@ -1761,7 +1773,7 @@ s->size = 0; if (s->flow) { - buffer_dealloc (s->flow, 1); + buffer_dealloc(s->flow, 1); } s->flow = NULL; s->flowp = &s->flow; @@ -1781,7 +1793,7 @@ s->size = 0; if (s->flow) { - buffer_dealloc (s->flow, 1); + buffer_dealloc(s->flow, 1); } s->flow = NULL; s->flowp = &s->flow; @@ -1793,38 +1805,38 @@ { case SOUND_STORAGE_NONE: /* nothing to free -- delete it */ - report (REPORT_DEBUG, "sound_clean: deleting flow `%s'\n", s->name); - sound_delete (s, 0); + report(REPORT_DEBUG, "sound_clean: deleting flow `%s'\n", s->name); + sound_delete(s, 0); break; case SOUND_STORAGE_MEMORY: /* keep it in memory? */ - report (REPORT_DEBUG, "sound_clean: keeping flow `%s' in memory\n", s->name); + report(REPORT_DEBUG, "sound_clean: keeping flow `%s' in memory\n", s->name); break; - + case SOUND_STORAGE_DISK: /* Save the flow in the disk cache. */ - if (cache_free (s->size) < 0) - { - report (REPORT_ERROR, "sound_clean: can't cache_free %d bytes\n", s->size); - sound_delete (s, 0); /* delete it */ + if (cache_free(s->size) < 0) + { + report(REPORT_ERROR, "sound_clean: can't cache_free %d bytes\n", s->size); + sound_delete(s, 0); /* delete it */ break; } - fd = cache_create (s->path, s->size); + fd = cache_create(s->path, s->size); if (fd < 0) { - report (REPORT_ERROR, "sound_clean: can't cache_create %d bytes\n", s->size); - sound_delete (s, 0); + report(REPORT_ERROR, "sound_clean: can't cache_create %d bytes\n", s->size); + sound_delete(s, 0); break; } /* Dump the flow buffers to disk. */ - report (REPORT_DEBUG, "sound_clean: storing %s\n", s->path); + report(REPORT_DEBUG, "sound_clean: storing %s\n", s->path); for (b = s->flow; b; b = b->next) { - retry: - n = write (fd, b->buf, b->nbytes); + retry: + n = write(fd, b->buf, b->nbytes); if (n < 0) { if (errno == EINTR || errno == EINTR) @@ -1833,19 +1845,19 @@ } else { - report (REPORT_ERROR, "sound_clean: write: %s\n", sys_err_str (errno)); - sound_delete (s, 1); + report(REPORT_ERROR, "sound_clean: write: %s\n", sys_err_str(errno)); + sound_delete(s, 1); s = NULL; break; } } } - close (fd); + close(fd); if (s) { /* The flow is now a file. */ - sound_unmap (s); + sound_unmap(s); s->type = SOUND_FILE; } break; @@ -1854,10 +1866,10 @@ #ifdef __STDC__ SINDEX * -sound_open (SOUND *s, int use_helper) +sound_open(SOUND *s, int use_helper) #else SINDEX * -sound_open (s, use_helper) +sound_open(s, use_helper) SOUND *s; int use_helper; #endif @@ -1865,7 +1877,7 @@ SINDEX *si; int n; - si = (SINDEX *) malloc (sizeof (SINDEX)); + si = (SINDEX *) malloc(sizeof(SINDEX)); if (si == NULL) { return NULL; @@ -1886,15 +1898,15 @@ #if defined (HAVE_CDROM) || defined (HAVE_HELPERS) si->pid = -1; #endif - + switch (s->format) { #ifdef HAVE_ADPCM case RPLAY_FORMAT_G721: case RPLAY_FORMAT_G723_3: case RPLAY_FORMAT_G723_5: - g72x_init_state (&si->adpcm_state[0]); - g72x_init_state (&si->adpcm_state[1]); + g72x_init_state(&si->adpcm_state[0]); + g72x_init_state(&si->adpcm_state[1]); si->adpcm_in_buffer = 0; si->adpcm_in_bits = 0; break; @@ -1902,12 +1914,12 @@ #ifdef HAVE_GSM case RPLAY_FORMAT_GSM: - si->gsm_object = gsm_create (); + si->gsm_object = gsm_create(); si->gsm_bit_frame_bytes = 0; si->gsm_fixed_buffer_size = 0; break; #endif /* HAVE_GSM */ - + default: break; } @@ -1918,46 +1930,46 @@ int fds[2]; HELPER *helper; - helper = helper_lookup (s->path); + helper = helper_lookup(s->path); if (!helper) { - report (REPORT_ERROR, "%s helper not found\n", s->path); - done (1); + report(REPORT_ERROR, "%s helper not found\n", s->path); + done(1); } si->is_flow = 1; si->flowp = &s->flow; - - if (pipe (fds) < 0) - { - report (REPORT_ERROR, "helper pipe: %s\n", sys_err_str (errno)); - sound_close (si); + + if (pipe(fds) < 0) + { + report(REPORT_ERROR, "helper pipe: %s\n", sys_err_str(errno)); + sound_close(si); return NULL; } - si->pid = fork (); + si->pid = fork(); if (si->pid < 0) { - report (REPORT_ERROR, "helper fork: %s\n", sys_err_str (errno)); - sound_close (si); + report(REPORT_ERROR, "helper fork: %s\n", sys_err_str(errno)); + sound_close(si); return NULL; } if (si->pid == 0) /* child */ { int first; - char *argv[64]; /* XXX */ + char *argv[64]; /* XXX */ int argc = 0; char buf[MAXPATHLEN], *p; int input_fd = -1; if (s->type == SOUND_FILE) { - input_fd = open (s->path, O_RDONLY /* | O_NDELAY */, 0); + input_fd = open(s->path, O_RDONLY /* | O_NDELAY */ , 0); if (input_fd < 0) { - report (REPORT_ERROR, "can't open %s: %s\n", s->path, sys_err_str (errno)); - exit (1); + report(REPORT_ERROR, "can't open %s: %s\n", s->path, sys_err_str(errno)); + exit(1); } } else if (s->type == SOUND_FLOW) @@ -1971,7 +1983,7 @@ if (e->type == EVENT_PIPE_FLOW && e->sound == s) { input_fd = c->fd; - fd_block (input_fd); + fd_block(input_fd); break; } } @@ -1980,83 +1992,83 @@ if (input_fd == -1) { - report (REPORT_ERROR, "No input for helper, type=%d.\n", s->type); - exit (1); + report(REPORT_ERROR, "No input for helper, type=%d.\n", s->type); + exit(1); } first = 1; - while (p = (char *) strtok (first ? helper->program : NULL, " \t\n")) + while (p = (char *) strtok(first ? helper->program : NULL, " \t\n")) { first = 0; argv[argc++] = p; } argv[argc] = NULL; - close (fds[0]); + close(fds[0]); if (input_fd != -1) { - if (dup2 (input_fd, 0) != 0) /* input for the helper */ + if (dup2(input_fd, 0) != 0) /* input for the helper */ { - report (REPORT_ERROR, "can't dup2 stdin: %s\n", sys_err_str (errno)); - exit (1); + report(REPORT_ERROR, "can't dup2 stdin: %s\n", sys_err_str(errno)); + exit(1); } } - if (dup2 (fds[1], 1) != 1) /* output for rplayd */ - { - report (REPORT_ERROR, "can't dup2 stdout: %s\n", sys_err_str (errno)); - exit (1); - } - - execv (argv[0], argv); - - report (REPORT_ERROR, "can't execute %s: %s\n", argv[0], sys_err_str (errno)); - exit (1); - } - - report (REPORT_DEBUG, "forked helper process %d\n", si->pid); - close (fds[1]); + if (dup2(fds[1], 1) != 1) /* output for rplayd */ + { + report(REPORT_ERROR, "can't dup2 stdout: %s\n", sys_err_str(errno)); + exit(1); + } + + execv(argv[0], argv); + + report(REPORT_ERROR, "can't execute %s: %s\n", argv[0], sys_err_str(errno)); + exit(1); + } + + report(REPORT_DEBUG, "forked helper process %d\n", si->pid); + close(fds[1]); si->fd = fds[0]; - FD_SET (si->fd, &read_mask); + FD_SET(si->fd, &read_mask); } #else - if (0) + if (0) { /* hack */ } -#endif /* HAVE_HELPERS */ +#endif /* HAVE_HELPERS */ else if (s->type == SOUND_FILE) { if (!s->cache) { struct stat st; - si->fd = open (s->path, O_RDONLY | O_NDELAY, 0); + si->fd = open(s->path, O_RDONLY | O_NDELAY, 0); if (si->fd < 0) { - report (REPORT_DEBUG, "sound_open: open %s: %s\n", s->path, - sys_err_str (errno)); - sound_close (si); + report(REPORT_DEBUG, "sound_open: open %s: %s\n", s->path, + sys_err_str(errno)); + sound_close(si); return NULL; } - fd_nonblock (si->fd); + fd_nonblock(si->fd); if (!s->mapped || (s->mapped && !s->size)) { - if (fstat (si->fd, &st) < 0) + if (fstat(si->fd, &st) < 0) { - report (REPORT_ERROR, "sound_open: fstat %s: %s\n", - s->path, sys_err_str (errno)); - sound_close (si); + report(REPORT_ERROR, "sound_open: fstat %s: %s\n", + s->path, sys_err_str(errno)); + sound_close(si); return NULL; } - if (S_ISDIR (st.st_mode)) + if (S_ISDIR(st.st_mode)) { - report (REPORT_ERROR, "sound_open: %s is a directory\n", - s->path); - sound_close (si); + report(REPORT_ERROR, "sound_open: %s is a directory\n", + s->path); + sound_close(si); return NULL; } @@ -2064,7 +2076,7 @@ /* See if the entire sound can be cached. */ if (sound_cache_max_size - && !helper_lookup (s->path) + && !helper_lookup(s->path) && (sound_cache_max_sound_size == 0 || (s->size <= sound_cache_max_sound_size)) && (sound_cache_size + s->size <= sound_cache_max_size)) { @@ -2074,49 +2086,49 @@ #ifndef MAP_FILE #define MAP_FILE 0 #endif - s->cache = mmap (0, s->size, PROT_READ, MAP_SHARED | MAP_FILE, si->fd, 0); - if (s->cache == (caddr_t) -1) + s->cache = mmap(0, s->size, PROT_READ, MAP_SHARED | MAP_FILE, si->fd, 0); + if (s->cache == (caddr_t) - 1) { - report (REPORT_ERROR, "sound_open: %s size=%d mmap: %s\n", - s->path, s->size, sys_err_str (errno)); - sound_close (si); + report(REPORT_ERROR, "sound_open: %s size=%d mmap: %s\n", + s->path, s->size, sys_err_str(errno)); + sound_close(si); return NULL; } #else /* not HAVE_MMAP */ /* Use malloc+read to load the entire sound. */ - s->cache = (char *) malloc (s->size); + s->cache = (char *) malloc(s->size); if (s->cache == NULL) { - report (REPORT_ERROR, "sound_open: %s size=%d malloc: %s\n", - s->path, s->size, sys_err_str (errno)); - sound_close (si); + report(REPORT_ERROR, "sound_open: %s size=%d malloc: %s\n", + s->path, s->size, sys_err_str(errno)); + sound_close(si); return NULL; } again: - n = read (si->fd, s->cache, s->size); + n = read(si->fd, s->cache, s->size); if (n < 0 && (errno == EINTR || errno == EAGAIN)) { goto again; } if (n != s->size) { - report (REPORT_ERROR, "sound_open: read %s %d: %s\n", - s->path, s->size, sys_err_str (errno)); - free ((char *) s->cache); + report(REPORT_ERROR, "sound_open: read %s %d: %s\n", + s->path, s->size, sys_err_str(errno)); + free((char *) s->cache); s->cache = NULL; - sound_close (si); + sound_close(si); return NULL; } #endif /* not HAVE_MMAP */ sound_cache_size += s->size; #if 0 - report (REPORT_DEBUG, "- cached %s %d, cache_size=%d\n", - s->path, s->size, sound_cache_size); + report(REPORT_DEBUG, "- cached %s %d, cache_size=%d\n", + s->path, s->size, sound_cache_size); #endif /* Cached sounds won't need the file descriptor. */ - close (si->fd); + close(si->fd); si->fd = 0; } } @@ -2145,19 +2157,19 @@ si->is_flow = 1; si->flowp = &s->flow; - - if (pipe (fds) < 0) - { - report (REPORT_ERROR, "cdrom pipe: %s\n", sys_err_str (errno)); - sound_close (si); + + if (pipe(fds) < 0) + { + report(REPORT_ERROR, "cdrom pipe: %s\n", sys_err_str(errno)); + sound_close(si); return NULL; } - si->pid = fork (); + si->pid = fork(); if (si->pid < 0) { - report (REPORT_ERROR, "cdrom fork: %s\n", sys_err_str (errno)); - sound_close (si); + report(REPORT_ERROR, "cdrom fork: %s\n", sys_err_str(errno)); + sound_close(si); return NULL; } @@ -2165,48 +2177,48 @@ { int i; - close (fds[0]); + close(fds[0]); #ifdef HAVE_SIGSET - sigset (SIGHUP, SIG_DFL); - sigset (SIGINT, SIG_DFL); - sigset (SIGCHLD, SIG_DFL); + sigset(SIGHUP, SIG_DFL); + sigset(SIGINT, SIG_DFL); + sigset(SIGCHLD, SIG_DFL); #else - signal (SIGHUP, SIG_DFL); - signal (SIGINT, SIG_DFL); - signal (SIGCHLD, SIG_DFL); + signal(SIGHUP, SIG_DFL); + signal(SIGINT, SIG_DFL); + signal(SIGCHLD, SIG_DFL); #endif for (i = 0; i < MAX_CDROMS; i++) { - if (strcmp (cdrom_table[i].name, si->sound->name) == 0) + if (strcmp(cdrom_table[i].name, si->sound->name) == 0) { - cdrom_reader (i, si->sound->starting_track, si->sound->ending_track, fds[1]); - exit (0); + cdrom_reader(i, si->sound->starting_track, si->sound->ending_track, fds[1]); + exit(0); } } - - report (REPORT_DEBUG, "cdrom `%s' not found\n", si->sound->name); - exit (1); - } - - report (REPORT_DEBUG, "forked cdrom process %d\n", si->pid); - close (fds[1]); + + report(REPORT_DEBUG, "cdrom `%s' not found\n", si->sound->name); + exit(1); + } + + report(REPORT_DEBUG, "forked cdrom process %d\n", si->pid); + close(fds[1]); si->fd = fds[0]; - - FD_SET (si->fd, &read_mask); - } -#endif /* HAVE_CDROM */ + + FD_SET(si->fd, &read_mask); + } +#endif /* HAVE_CDROM */ return si; } #ifdef __STDC__ int -sound_close (SINDEX *si) +sound_close(SINDEX *si) #else int -sound_close (si) +sound_close(si) SINDEX *si; #endif { @@ -2215,16 +2227,16 @@ { if (si->pid != -1) { - report (REPORT_DEBUG, "killing helper process %d\n", si->pid); - if (kill (si->pid, SIGKILL) < 0) - { - report (REPORT_DEBUG, "kill %d: %s\n", si->pid, sys_err_str (errno)); + report(REPORT_DEBUG, "killing helper process %d\n", si->pid); + if (kill(si->pid, SIGKILL) < 0) + { + report(REPORT_DEBUG, "kill %d: %s\n", si->pid, sys_err_str(errno)); } } if (si->fd != 0) { - FD_CLR (si->fd, &read_mask); - close (si->fd); + FD_CLR(si->fd, &read_mask); + close(si->fd); } if (si->sound->type == SOUND_FLOW) { @@ -2237,7 +2249,7 @@ { if (e->type == EVENT_PIPE_FLOW && e->sound == si->sound) { - connection_close (c); + connection_close(c); break; } } @@ -2251,7 +2263,7 @@ { if (!si->is_cached) { - close (si->fd); + close(si->fd); } } #ifdef HAVE_CDROM @@ -2259,16 +2271,16 @@ { if (si->pid != -1) { - report (REPORT_DEBUG, "killing cdrom process %d\n", si->pid); - if (kill (si->pid, SIGKILL) < 0) - { - report (REPORT_DEBUG, "kill %d: %s\n", si->pid, sys_err_str (errno)); + report(REPORT_DEBUG, "killing cdrom process %d\n", si->pid); + if (kill(si->pid, SIGKILL) < 0) + { + report(REPORT_DEBUG, "kill %d: %s\n", si->pid, sys_err_str(errno)); } } if (si->fd != 0) { - FD_CLR (si->fd, &read_mask); - close (si->fd); + FD_CLR(si->fd, &read_mask); + close(si->fd); } } #endif /* HAVE_CDROM */ @@ -2277,15 +2289,15 @@ { #ifdef HAVE_GSM case RPLAY_FORMAT_GSM: - gsm_destroy (si->gsm_object); + gsm_destroy(si->gsm_object); break; #endif /* HAVE_GSM */ default: break; } - - free ((char *) si); + + free((char *) si); return 0; } @@ -2294,24 +2306,24 @@ /* This routine is based on the unpack_input routine from Sun's CCITT ADPCM decoder. */ static int -adpcm_unpack (si, b, code, bits) +adpcm_unpack(si, b, code, bits) SINDEX *si; BUFFER *b; unsigned char *code; int bits; { unsigned char in_byte; - + if (si->adpcm_in_bits < bits) { - if (b->offset >= b->nbytes) - { - *code = 0; - return -1; - } + if (b->offset >= b->nbytes) + { + *code = 0; + return -1; + } in_byte = b->buf[b->offset++]; - si->adpcm_in_buffer |= (in_byte << si->adpcm_in_bits); - si->adpcm_in_bits += 8; + si->adpcm_in_buffer |= (in_byte << si->adpcm_in_bits); + si->adpcm_in_bits += 8; } *code = si->adpcm_in_buffer & ((1 << bits) - 1); @@ -2323,102 +2335,102 @@ /* Uncompress the `data' buffers into 16-bit linear data. */ static void -adpcm_decode (si, data, decode_routine, decode_bits) +adpcm_decode(si, data, decode_routine, decode_bits) SINDEX *si; BUFFER *data; - int (*decode_routine)(); + int (*decode_routine) (); int decode_bits; { - BUFFER *b = buffer_create (); + BUFFER *b = buffer_create(); short *ptr; unsigned char code; int channel = 0; - + for (; data && data->nbytes; data = data->next) { - memcpy (b->buf, data->buf, data->nbytes); - b->nbytes = data->nbytes; - b->offset = 0; - - ptr = (short *) data->buf; + memcpy(b->buf, data->buf, data->nbytes); + b->nbytes = data->nbytes; + b->offset = 0; + + ptr = (short *) data->buf; data->nbytes = 0; - while (adpcm_unpack (si, b, &code, decode_bits) >= 0) - { - *ptr++ = (*decode_routine) (code, AUDIO_ENCODING_LINEAR, &si->adpcm_state[channel]); + while (adpcm_unpack(si, b, &code, decode_bits) >= 0) + { + *ptr++ = (*decode_routine) (code, AUDIO_ENCODING_LINEAR, &si->adpcm_state[channel]); if (si->sound->channels == 2) { - channel ^= 1; - } - data->nbytes += 2; /* 16-bit */ - } + channel ^= 1; + } + data->nbytes += 2; /* 16-bit */ + } #if 1 - report (REPORT_DEBUG, "adpcm_decode: uncompressed from %d to %d bytes\n", - b->nbytes, data->nbytes); -#endif - } - - buffer_destroy (b); + report(REPORT_DEBUG, "adpcm_decode: uncompressed from %d to %d bytes\n", + b->nbytes, data->nbytes); +#endif + } + + buffer_destroy(b); } #endif /* HAVE_ADPCM */ #ifdef HAVE_GSM /* Uncompress the `data' buffers into 16-bit linear data. */ static void -gsm_uncompress (si, data) +gsm_uncompress(si, data) SINDEX *si; BUFFER *data; { - BUFFER *b = buffer_create (); + BUFFER *b = buffer_create(); gsm_signal sample[160]; int nbytes; for (; data; data = data->next) { - memcpy (b->buf, data->buf, data->nbytes); - b->nbytes = data->nbytes; - b->offset = 0; + memcpy(b->buf, data->buf, data->nbytes); + b->nbytes = data->nbytes; + b->offset = 0; data->nbytes = 0; - + do { - nbytes = MIN (b->nbytes - b->offset, sizeof (si->gsm_bit_frame) - si->gsm_bit_frame_bytes); - memcpy (si->gsm_bit_frame, b->buf + b->offset, nbytes); + nbytes = MIN(b->nbytes - b->offset, sizeof(si->gsm_bit_frame) - si->gsm_bit_frame_bytes); + memcpy(si->gsm_bit_frame, b->buf + b->offset, nbytes); b->offset += nbytes; si->gsm_bit_frame_bytes += nbytes; - if (si->gsm_bit_frame_bytes == sizeof (si->gsm_bit_frame)) /* Only decode complete frames */ - { - gsm_decode (si->gsm_object, si->gsm_bit_frame, sample); - memcpy (data->buf + data->nbytes, (char *) sample, sizeof (sample)); - data->nbytes += sizeof (sample); + if (si->gsm_bit_frame_bytes == sizeof(si->gsm_bit_frame)) /* Only decode complete frames */ + { + gsm_decode(si->gsm_object, si->gsm_bit_frame, sample); + memcpy(data->buf + data->nbytes, (char *) sample, sizeof(sample)); + data->nbytes += sizeof(sample); si->gsm_bit_frame_bytes = 0; } #if 0 - printf ("b->offset=%d data->nbytes=%d gsm_bit_frame_bytes=%d\n", - b->offset, data->nbytes, si->gsm_bit_frame_bytes); -#endif - + printf("b->offset=%d data->nbytes=%d gsm_bit_frame_bytes=%d\n", + b->offset, data->nbytes, si->gsm_bit_frame_bytes); +#endif + } while (b->offset < b->nbytes); - + #if 1 - report (REPORT_DEBUG, "gsm_uncompress: uncompressed from %d to %d bytes\n", - b->nbytes, data->nbytes); -#endif - } - - buffer_destroy (b); + report(REPORT_DEBUG, "gsm_uncompress: uncompressed from %d to %d bytes\n", + b->nbytes, data->nbytes); +#endif + } + + buffer_destroy(b); } #endif /* HAVE_GSM */ #ifdef __STDC__ int -sound_fill (SINDEX *si, BUFFER *data, int as_is) +sound_fill(SINDEX *si, BUFFER *data, int as_is) #else int -sound_fill (si, data, as_is) +sound_fill(si, data, as_is) SINDEX *si; BUFFER *data; int as_is; @@ -2430,7 +2442,7 @@ BUFFER *b; float bit_factor; int max_per_buffer; - + if (si->eof && !si->is_flow) { return 0; @@ -2453,19 +2465,19 @@ if (si->gsm_fixed_buffer_size == 0) { si->gsm_fixed_buffer_size = max_per_buffer; - while (si->gsm_fixed_buffer_size % sizeof (si->gsm_bit_frame)) + while (si->gsm_fixed_buffer_size % sizeof(si->gsm_bit_frame)) { si->gsm_fixed_buffer_size--; } } max_per_buffer = si->gsm_fixed_buffer_size; } - + /* Read from a flow. */ if (si->is_flow) { BUFFER *f, *f_next; - + if (!si->flowp) { return 0; @@ -2491,8 +2503,15 @@ #endif if (!si->high_water_mark) { - si->low_water_mark = LOW_WATER_MARK (si->sound); - si->high_water_mark = HIGH_WATER_MARK (si->sound); +#if 1 + /* XXX test */ + SOUND *s = si->sound; + si->low_water_mark = (s->sample_rate * s->input_sample_size) / 4; + si->high_water_mark = (s->sample_rate * s->input_sample_size) / 2; +#else + si->low_water_mark = LOW_WATER_MARK(si->sound); + si->high_water_mark = HIGH_WATER_MARK(si->sound); +#endif } } @@ -2511,8 +2530,8 @@ else { /* Calculate the number of bytes needed. */ - i = MIN (n, max_per_buffer - b->nbytes); - memcpy (b->buf + b->nbytes, f->buf + si->buffer_offset + si->skip, i); + i = MIN(n, max_per_buffer - b->nbytes); + memcpy(b->buf + b->nbytes, f->buf + si->buffer_offset + si->skip, i); si->skip = 0; b->nbytes += i; total += i; @@ -2532,7 +2551,7 @@ if (si->sound->storage == SOUND_STORAGE_NONE || si->sound->storage == SOUND_STORAGE_NULL) { - buffer_destroy (f); + buffer_destroy(f); } f = f_next; @@ -2563,13 +2582,13 @@ n = si->sound->size - si->offset; for (b = data; b; b = b->next) { - i = MIN (n, max_per_buffer); + i = MIN(n, max_per_buffer); if (i > 0) { #ifdef DEBUG - report (REPORT_DEBUG, "- cache-read %s %d\n", si->sound->name, i); -#endif - memcpy (b->buf, si->sound->cache + si->offset, i); + report(REPORT_DEBUG, "- cache-read %s %d\n", si->sound->name, i); +#endif + memcpy(b->buf, si->sound->cache + si->offset, i); b->nbytes = i; si->offset += i; n -= i; @@ -2595,11 +2614,11 @@ iov[i].iov_len = max_per_buffer; } - n = readv (si->fd, iov, i); + n = readv(si->fd, iov, i); if (n < 0) { - report (REPORT_ERROR, "sound_fill: readv: %s, fd=%d, %s\n", - si->sound->name, si->fd, sys_err_str (errno)); + report(REPORT_ERROR, "sound_fill: readv: %s, fd=%d, %s\n", + si->sound->name, si->fd, sys_err_str(errno)); return -1; } else if (n == 0) @@ -2616,7 +2635,7 @@ { i = 0; } - b->nbytes = MIN (i, max_per_buffer); + b->nbytes = MIN(i, max_per_buffer); } total = n; } @@ -2629,35 +2648,35 @@ { #ifdef HAVE_ADPCM case RPLAY_FORMAT_G721: - adpcm_decode (si, data, g721_decoder, 4); + adpcm_decode(si, data, g721_decoder, 4); break; case RPLAY_FORMAT_G723_3: - adpcm_decode (si, data, g723_24_decoder, 3); + adpcm_decode(si, data, g723_24_decoder, 3); break; case RPLAY_FORMAT_G723_5: - adpcm_decode (si, data, g723_40_decoder, 5); + adpcm_decode(si, data, g723_40_decoder, 5); break; #endif /* HAVE_ADPCM */ #ifdef HAVE_GSM case RPLAY_FORMAT_GSM: - gsm_uncompress (si, data); + gsm_uncompress(si, data); break; #endif /* HAVE_GSM */ } } - + return total; } #ifdef __STDC__ int -sound_seek (SINDEX *si, int offset, int whence) +sound_seek(SINDEX *si, int offset, int whence) #else int -sound_seek (si, offset, whence) +sound_seek(si, offset, whence) SINDEX *si; int offset; int whence; @@ -2665,12 +2684,12 @@ { if (si->is_flow) { - si->skip += offset; /* XXX: whence is ignored */ + si->skip += offset; /* XXX: whence is ignored */ return 0; } else if (si->is_cached) { - si->offset += offset; /* XXX: whence is ignored */ + si->offset += offset; /* XXX: whence is ignored */ return 0; } #ifdef HAVE_CDROM @@ -2678,16 +2697,16 @@ { return 0; } -#endif /* HAVE_CDROM */ +#endif /* HAVE_CDROM */ #ifdef HAVE_HELPERS else if (si->sound->needs_helper) { return 0; } -#endif /* HAVE_HELPERS */ +#endif /* HAVE_HELPERS */ else { - return lseek (si->fd, offset, whence); + return lseek(si->fd, offset, whence); } } @@ -2695,12 +2714,12 @@ /* Read data from the pipe and return the data in a buffer list. */ #ifdef __STDC__ BUFFER * -sound_pipe_read (SINDEX *si) +sound_pipe_read(SINDEX *si) #else BUFFER * -sound_pipe_read (si) +sound_pipe_read(si) SINDEX *si; -#endif +#endif { static struct iovec iov[UIO_MAXIOV]; int i, n, nbytes; @@ -2710,36 +2729,38 @@ /* Pause */ if (si->water_mark - si->offset > si->high_water_mark) { - FD_CLR (si->fd, &read_mask); + FD_CLR(si->fd, &read_mask); return NULL; } /* Determine the number of bytes available in the pipe. */ -#if defined (sun) && defined (SVR4) /* Solaris 2.x */ +#if defined (sun) && defined (SVR4) /* Solaris 2.x */ { struct stat st; - if (fstat (si->fd, &st) < 0) - { - report (REPORT_DEBUG, "sound_pipe_read: fstat: %s\n", - sys_err_str (errno)); + if (fstat(si->fd, &st) < 0) + { + report(REPORT_DEBUG, "sound_pipe_read: fstat: %s\n", + sys_err_str(errno)); return NULL; } nbytes = st.st_size; } #else /* not Solaris */ -#ifdef FIONREAD - if (ioctl (si->fd, FIONREAD, &nbytes) < 0) - { - report (REPORT_DEBUG, "sound_pipe_read: ioctl FIONREAD: %s\n", - sys_err_str (errno)); +#if 0 /* disable FIONREAD for now */ +#ifdef FIONREAD + if (ioctl(si->fd, FIONREAD, &nbytes) < 0) + { + report(REPORT_DEBUG, "sound_pipe_read: ioctl FIONREAD: %s\n", + sys_err_str(errno)); return NULL; } #endif /* not FIONREAD */ +#endif /* guess */ nbytes = (si->sound->sample_rate * si->sound->input_sample_size) / 2; #endif /* not Solaris */ - - data = buffer_alloc (nbytes, BUFFER_FREE); + + data = buffer_alloc(nbytes, BUFFER_FREE); for (b = data, i = 0; b && i < UIO_MAXIOV; b = b->next, i++) { @@ -2747,11 +2768,11 @@ iov[i].iov_len = BUFFER_SIZE; } - n = readv (si->fd, iov, i); + n = readv(si->fd, iov, i); if (n <= 0) { - buffer_dealloc (data, 1); - spool_remove (si->sound); /* XXX */ + buffer_dealloc(data, 1); + spool_remove(si->sound); /* XXX */ return NULL; } @@ -2761,24 +2782,24 @@ { i = 0; } - b->nbytes = MIN (i, BUFFER_SIZE); - } - + b->nbytes = MIN(i, BUFFER_SIZE); + } + return data; } #endif #ifdef __STDC__ static int -bytes_in_sound (SOUND *s) +bytes_in_sound(SOUND *s) #else static int -bytes_in_sound (s) +bytes_in_sound(s) SOUND *s; #endif { int bytes = 0; - + if (s->chunk_size) { bytes = s->chunk_size; @@ -2797,17 +2818,17 @@ #ifdef __STDC__ int -number_of_samples (SOUND *s, int bytes) +number_of_samples(SOUND *s, int bytes) #else int -number_of_samples (s, bytes) +number_of_samples(s, bytes) SOUND *s; int bytes; #endif { if (!bytes) { - bytes = bytes_in_sound (s); + bytes = bytes_in_sound(s); } return (bytes << 3) / (s->input_precision * s->channels); } diff --git a/rplayd/sound.h b/rplayd/sound.h index 6cf0ac7..3d9a9ad 100644 --- a/rplayd/sound.h +++ b/rplayd/sound.h @@ -1,7 +1,7 @@ -/* $Id: sound.h,v 1.2 1998/08/13 06:14:06 boyns Exp $ */ - -/* - * Copyright (C) 1993-98 Mark R. Boyns +/* $Id: sound.h,v 1.4 1999/06/09 06:27:44 boyns Exp $ */ + +/* + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -38,7 +38,15 @@ #include "g72x.h" #endif /* HAVE_ADPCM */ #ifdef HAVE_GSM -#include "gsm.h" +#ifdef HAVE_GSM_GSM_H +#include +#else +#ifdef HAVE_GSM_H +#include +#else +#include "gsm.h" +#endif +#endif #endif /* HAVE_GSM */ #undef NUMBER_OF_SAMPLES diff --git a/rplayd/spool.c b/rplayd/spool.c index 6fee911..0428735 100644 --- a/rplayd/spool.c +++ b/rplayd/spool.c @@ -1,7 +1,7 @@ -/* $Id: spool.c,v 1.2 1998/08/13 06:14:07 boyns Exp $ */ +/* $Id: spool.c,v 1.6 1999/03/10 21:14:38 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - + + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -54,7 +54,7 @@ * initialize the sound spool */ void -spool_init () +spool_init() { SPOOL *sp, *sp_next; @@ -62,7 +62,7 @@ for (sp = spool; sp; sp = sp_next) { sp_next = sp->next; - spool_destroy (sp); + spool_destroy(sp); } spool = NULL; @@ -73,20 +73,20 @@ /* Create a new spool entry. */ SPOOL * -spool_create () -{ - SPOOL *sp = (SPOOL *) malloc (sizeof (SPOOL)); +spool_create() +{ + SPOOL *sp = (SPOOL *) malloc(sizeof(SPOOL)); if (sp == NULL) { - report (REPORT_ERROR, "spool_create: out of memory\n"); - done (1); + report(REPORT_ERROR, "spool_create: out of memory\n"); + done(1); } /* `sp' must be initialized before being reset. */ - memset ((char *) sp, 0, sizeof (SPOOL)); + memset((char *) sp, 0, sizeof(SPOOL)); sp->id = -1; /* XXX */ - spool_reset (sp); + spool_reset(sp); /* Insert the new entry into the spool list. */ sp->next = spool; @@ -105,15 +105,15 @@ /* Destroy the given spool entry. */ #ifdef __STDC__ void -spool_destroy (SPOOL *sp) -#else -void -spool_destroy (sp) +spool_destroy(SPOOL *sp) +#else +void +spool_destroy(sp) SPOOL *sp; #endif { /* Reset `sp' in case any resources are allocated. */ - spool_reset (sp); + spool_reset(sp); /* Remove `sp' from the spool list. */ if (sp->prev) @@ -131,7 +131,7 @@ spool_size--; - free ((char *) sp); + free((char *) sp); } /* @@ -142,10 +142,10 @@ */ #ifdef __STDC__ SPOOL * -spool_next (int priority) +spool_next(int priority) #else SPOOL * -spool_next (priority) +spool_next(priority) int priority; #endif { @@ -156,8 +156,8 @@ /* There's room for a new entry. */ if (spool_size < SPOOL_SIZE) { - sp = spool_create (); - sp->id = spool_id (); + sp = spool_create(); + sp->id = spool_id(); return sp; } @@ -182,13 +182,13 @@ sp = lowest; if (sp->notify_position) { - connection_notify (0, NOTIFY_POSITION, sp); + connection_notify(0, NOTIFY_POSITION, sp); sp->notify_position = 0; } - connection_notify (0, NOTIFY_DONE, sp); - spool_reset (sp); + connection_notify(0, NOTIFY_DONE, sp); + spool_reset(sp); spool_nplaying--; - sp->id = spool_id (); + sp->id = spool_id(); return sp; } else @@ -201,10 +201,10 @@ `next' and `prev' are NOT changed. */ #ifdef __STDC__ void -spool_reset (SPOOL *sp) -#else -void -spool_reset (sp) +spool_reset(SPOOL *sp) +#else +void +spool_reset(sp) SPOOL *sp; #endif { @@ -213,7 +213,7 @@ { /* Wakeup any connections that may be waiting for this spool entry. Their flow data will be ignored. */ - connection_flow_continue (sp); + connection_flow_continue(sp); } sp->id = -1; sp->time = 0; @@ -223,10 +223,10 @@ for (i = 0; i < sp->rp->nsounds; i++) { - sound_clean (sp->sound[i]); - } - - rplay_destroy (sp->rp); + sound_clean(sp->sound[i]); + } + + rplay_destroy(sp->rp); } sp->rp = NULL; sp->ptr = NULL; @@ -240,18 +240,18 @@ sp->oversample_inc[1] = 0; if (sp->curr_buffer) { - buffer_dealloc (sp->curr_buffer, 1); + buffer_dealloc(sp->curr_buffer, 1); } sp->curr_buffer = NULL; if (sp->next_buffer) { - buffer_dealloc (sp->next_buffer, 1); + buffer_dealloc(sp->next_buffer, 1); } sp->next_buffer = NULL; sp->offset = 0; if (sp->si) { - sound_close (sp->si); + sound_close(sp->si); } sp->si = NULL; sp->to_native = NULL; @@ -259,16 +259,16 @@ sp->auto_pause = 0; sp->notify_position = 0; - spool_setprio (); + spool_setprio(); } /* Find the maximum spool priority. */ #ifdef __STDC__ void -spool_setprio (void) -#else -void -spool_setprio () +spool_setprio(void) +#else +void +spool_setprio() #endif { SPOOL *sp; @@ -278,7 +278,7 @@ { if (sp->state == SPOOL_PLAY) { - spool_prio = MAX (spool_prio, sp->rp->priority); + spool_prio = MAX(spool_prio, sp->rp->priority); } } } @@ -286,10 +286,10 @@ /* Find the given RPLAY object in the spool. */ #ifdef __STDC__ int -spool_match (RPLAY *match, void (*action) (SPOOL *), struct sockaddr_in sin) +spool_match(RPLAY *match, void (*action) (SPOOL *), struct sockaddr_in sin) #else int -spool_match (match, action, sin) +spool_match(match, action, sin) RPLAY *match; void (*action) (); struct sockaddr_in sin; @@ -314,7 +314,7 @@ { for (; a2; a2 = a2->next) { - id = atoi (a2->sound + 1); + id = atoi(a2->sound + 1); if (id == 0 || id == sp->id) { sp->sin = sin; @@ -329,7 +329,7 @@ rp = sp->rp; for (a1 = rp->attrs, a2 = match->attrs; a1 && a2; a1 = a1->next, a2 = a2->next) { - if (strcmp (a1->sound, a2->sound)) + if (strcmp(a1->sound, a2->sound)) { break; } @@ -348,10 +348,10 @@ /* Remove any spool entries with `sound' from the spool. */ #ifdef __STDC__ void -spool_remove (SOUND *sound) -#else -void -spool_remove (sound) +spool_remove(SOUND *sound) +#else +void +spool_remove(sound) SOUND *sound; #endif { @@ -377,7 +377,7 @@ } if (n) { - spool_done (sp); + spool_done(sp); } } } @@ -387,10 +387,10 @@ */ #ifdef __STDC__ void -spool_ready (SOUND *sound) -#else -void -spool_ready (sound) +spool_ready(SOUND *sound) +#else +void +spool_ready(sound) SOUND *sound; #endif { @@ -422,10 +422,10 @@ { for (j = 0; j < sp->rp->nsounds; j++) { - sound_map (sp->sound[j]); + sound_map(sp->sound[j]); } - spool_play (sp); + spool_play(sp); } } } @@ -433,56 +433,65 @@ /* Return a buffer list for the `list spool' command. */ BUFFER * -spool_list_create () +spool_list_create() { BUFFER *spool_list, *b; int i, n; char buf[RPTP_MAX_LINE]; + char line[RPTP_MAX_LINE]; SOUND *s; SPOOL *sp; - - b = buffer_create (); + int length; + + b = buffer_create(); spool_list = b; - SNPRINTF (SIZE(b->buf,BUFFER_SIZE), "+message=\"spool\"\r\n"); - b->nbytes += strlen (b->buf); + SNPRINTF(SIZE(b->buf, BUFFER_SIZE), "+message=\"spool\"\r\n"); + b->nbytes += strlen(b->buf); for (sp = spool; sp; sp = sp->next) { - SNPRINTF (SIZE(buf,sizeof(buf)), "id=#%d", sp->id); - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), " state="); + length = 0; + line[0] = '\0'; + + SNPRINTF(SIZE(buf, sizeof(buf)), "id=#%d state=", sp->id); + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); + switch (sp->state) { case SPOOL_PLAY: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "play"); + SNPRINTF(SIZE(buf, sizeof(buf)), "play"); break; case SPOOL_PAUSE: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "pause"); + SNPRINTF(SIZE(buf, sizeof(buf)), "pause"); break; case SPOOL_WAIT: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "wait"); + SNPRINTF(SIZE(buf, sizeof(buf)), "wait"); break; case SPOOL_NEXT: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "next"); + SNPRINTF(SIZE(buf, sizeof(buf)), "next"); break; case SPOOL_SKIP: - SNPRINTF (SIZE(buf+strlen(buf),sizeof(buf)), "skip"); + SNPRINTF(SIZE(buf, sizeof(buf)), "skip"); break; default: continue; } + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); s = sp->sound[sp->curr_sound]; - SNPRINTF (SIZE(buf + strlen (buf),sizeof(buf)), "\ + SNPRINTF(SIZE(buf, sizeof(buf)), "\ sound=\"%s\" host=%s volume=%d priority=%d count=%d position=%.2f remain=%.2f seconds=%.2f size=%d\ sample-rate=%d channels=%d bits=%g input=%s client-data=\"%s\" list-name=\"%s\"\r\n", sp->curr_attrs->sound, - inet_ntoa (sp->sin.sin_addr), + inet_ntoa(sp->sin.sin_addr), sp->curr_attrs->volume, sp->rp->priority, sp->curr_count, @@ -493,27 +502,30 @@ sp->sample_rate, s->channels, s->input_precision, - input_to_string (s->type), + input_to_string(s->type), sp->curr_attrs->client_data, sp->rp->list_name); - n = strlen (buf); - if (b->nbytes + n > BUFFER_SIZE) - { - b->next = buffer_create (); + strncat(line + length, buf, sizeof(line) - length); + length += strlen(buf); + + if (b->nbytes + length > BUFFER_SIZE) + { + b->next = buffer_create(); b = b->next; } - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), buf); - b->nbytes += n; + strncat(b->buf + b->nbytes, line, BUFFER_SIZE - b->nbytes); + b->nbytes += length; } if (b->nbytes + 3 > BUFFER_SIZE) { - b->next = buffer_create (); + b->next = buffer_create(); b = b->next; } - SNPRINTF (SIZE(b->buf+strlen(b->buf), BUFFER_SIZE), ".\r\n"); + + strncat(b->buf + b->nbytes, ".\r\n", BUFFER_SIZE - b->nbytes); b->nbytes += 3; return spool_list; @@ -523,7 +535,7 @@ * Return a unique spool id. */ int -spool_id () +spool_id() { static int id = 0; SPOOL *sp; @@ -551,14 +563,14 @@ #ifdef __STDC__ void -spool_stop (SPOOL *sp) -#else -void -spool_stop (sp) - SPOOL *sp; -#endif -{ - timer_block (); +spool_stop(SPOOL *sp) +#else +void +spool_stop(sp) + SPOOL *sp; +#endif +{ + timer_block(); switch (sp->state) { case SPOOL_PLAY: @@ -574,27 +586,27 @@ } if (sp->notify_position) { - connection_notify (0, NOTIFY_POSITION, sp); + connection_notify(0, NOTIFY_POSITION, sp); sp->notify_position = 0; } - connection_notify (0, NOTIFY_STOP, sp); - connection_notify (0, NOTIFY_DONE, sp); - spool_destroy (sp); + connection_notify(0, NOTIFY_STOP, sp); + connection_notify(0, NOTIFY_DONE, sp); + spool_destroy(sp); break; } - timer_unblock (); -} - -#ifdef __STDC__ -void -spool_pause (SPOOL *sp) -#else -void -spool_pause (sp) - SPOOL *sp; -#endif -{ - timer_block (); + timer_unblock(); +} + +#ifdef __STDC__ +void +spool_pause(SPOOL *sp) +#else +void +spool_pause(sp) + SPOOL *sp; +#endif +{ + timer_block(); if (sp->state == SPOOL_PLAY) { sp->state = SPOOL_PAUSE; @@ -602,49 +614,49 @@ spool_npaused++; if (sp->notify_position) { - connection_notify (0, NOTIFY_POSITION, sp); + connection_notify(0, NOTIFY_POSITION, sp); sp->notify_position = 0; } - connection_notify (0, NOTIFY_PAUSE, sp); - } - timer_unblock (); -} - -#ifdef __STDC__ -void -spool_continue (SPOOL *sp) -#else -void -spool_continue (sp) - SPOOL *sp; -#endif -{ - timer_block (); + connection_notify(0, NOTIFY_PAUSE, sp); + } + timer_unblock(); +} + +#ifdef __STDC__ +void +spool_continue(SPOOL *sp) +#else +void +spool_continue(sp) + SPOOL *sp; +#endif +{ + timer_block(); if (sp->state == SPOOL_PAUSE) { sp->state = SPOOL_PLAY; if (rplay_audio_match) { - rplayd_audio_match (sp); + rplayd_audio_match(sp); } spool_nplaying++; spool_npaused--; spool_needs_update++; - connection_notify (0, NOTIFY_CONTINUE, sp); - } - timer_unblock (); -} - -#ifdef __STDC__ -void -spool_done (SPOOL *sp) -#else -void -spool_done (sp) - SPOOL *sp; -#endif -{ - timer_block (); + connection_notify(0, NOTIFY_CONTINUE, sp); + } + timer_unblock(); +} + +#ifdef __STDC__ +void +spool_done(SPOOL *sp) +#else +void +spool_done(sp) + SPOOL *sp; +#endif +{ + timer_block(); switch (sp->state) { case SPOOL_PLAY: @@ -652,7 +664,7 @@ case SPOOL_WAIT: if (sp->si && sp->si->is_flow && sp->state == SPOOL_PLAY) { - sp->si->eof = 1; /* spool_update will deal with this */ + sp->si->eof = 1; /* spool_update will deal with this */ } else { @@ -666,27 +678,27 @@ } if (sp->notify_position) { - connection_notify (0, NOTIFY_POSITION, sp); + connection_notify(0, NOTIFY_POSITION, sp); sp->notify_position = 0; } - connection_notify (0, NOTIFY_DONE, sp); - spool_destroy (sp); + connection_notify(0, NOTIFY_DONE, sp); + spool_destroy(sp); } break; } - timer_unblock (); -} - -#ifdef __STDC__ -void -spool_flow_pause (SPOOL *sp) -#else -void -spool_flow_pause (sp) - SPOOL *sp; -#endif -{ - timer_block (); + timer_unblock(); +} + +#ifdef __STDC__ +void +spool_flow_pause(SPOOL *sp) +#else +void +spool_flow_pause(sp) + SPOOL *sp; +#endif +{ + timer_block(); if (sp->state == SPOOL_PLAY) { @@ -694,19 +706,19 @@ spool_nplaying--; } - timer_unblock (); -} - -#ifdef __STDC__ -void -spool_flow_continue (SPOOL *sp) -#else -void -spool_flow_continue (sp) - SPOOL *sp; -#endif -{ - timer_block (); + timer_unblock(); +} + +#ifdef __STDC__ +void +spool_flow_continue(SPOOL *sp) +#else +void +spool_flow_continue(sp) + SPOOL *sp; +#endif +{ + timer_block(); if (sp->state == SPOOL_WAIT) { @@ -715,15 +727,15 @@ spool_needs_update++; } - timer_unblock (); + timer_unblock(); } #ifdef __STDC__ int -spool_flow_insert (SPOOL *sp, BUFFER *b) +spool_flow_insert(SPOOL *sp, BUFFER *b) #else int -spool_flow_insert (sp, b) +spool_flow_insert(sp, b) SPOOL *sp; BUFFER *b; #endif @@ -733,21 +745,21 @@ s = sp->sound[sp->curr_sound]; *s->flowp = b; - for (tmp_buf = b; tmp_buf->next; tmp_buf = tmp_buf->next); + for (tmp_buf = b; tmp_buf->next; tmp_buf = tmp_buf->next) ; s->flowp = &tmp_buf->next; /* Enable the sound. */ if (s->status == SOUND_NOT_READY) { s->status = SOUND_READY; - if (sound_map (s) < 0) + if (sound_map(s) < 0) { /* Punt - can't determine what type of sound it is. */ - spool_remove (s); + spool_remove(s); /* spool_remove now deletes the sound - sound_delete (s, 0); */ return -1; } - spool_ready (s); + spool_ready(s); } for (tmp_buf = b; tmp_buf; tmp_buf = tmp_buf->next) @@ -756,12 +768,12 @@ sp->si->water_mark += tmp_buf->nbytes; } - s->samples = number_of_samples (s, sp->si->water_mark); + s->samples = number_of_samples(s, sp->si->water_mark); /* Wakeup the spool entry. */ if (sp->state == SPOOL_WAIT) { - spool_flow_continue (sp); + spool_flow_continue(sp); } return 0; @@ -769,17 +781,17 @@ #ifdef __STDC__ void -spool_skip (SPOOL *sp, int count) -#else -void -spool_skip (sp, count) +spool_skip(SPOOL *sp, int count) +#else +void +spool_skip(sp, count) SPOOL *sp; int count; #endif { SOUND *s; - timer_block (); + timer_block(); s = sp->sound[sp->curr_sound]; /* Only sounds that are playing or paused can be skipped. Flows can't be skipped right now. */ @@ -794,17 +806,17 @@ sp->state = SPOOL_SKIP; sp->skip_count = count; spool_needs_update++; - connection_notify (0, NOTIFY_SKIP, sp); - } - timer_unblock (); -} - -#ifdef __STDC__ -void -spool_play (SPOOL *sp) -#else -void -spool_play (sp) + connection_notify(0, NOTIFY_SKIP, sp); + } + timer_unblock(); +} + +#ifdef __STDC__ +void +spool_play(SPOOL *sp) +#else +void +spool_play(sp) SPOOL *sp; #endif { @@ -818,45 +830,45 @@ { char name_buf[MAXPATHLEN]; char *p; - - strncpy (name_buf, sp->curr_attrs->sound, sizeof(name_buf)); - p = strchr (name_buf, ':'); + + strncpy(name_buf, sp->curr_attrs->sound, sizeof(name_buf)); + p = strchr(name_buf, ':'); if (p == NULL) { - report (REPORT_DEBUG, "spool_play: can't parse cdrom name `%s'\n", s->name); + report(REPORT_DEBUG, "spool_play: can't parse cdrom name `%s'\n", s->name); return; } *p++ = '\0'; - if (strchr (p, '-')) - { - p = strtok (p, "-"); + if (strchr(p, '-')) + { + p = strtok(p, "-"); if (p) { - s->starting_track = atoi (p); - p = strtok (NULL, ""); + s->starting_track = atoi(p); + p = strtok(NULL, ""); if (p) { - s->ending_track = atoi (p); + s->ending_track = atoi(p); } } } else { - s->starting_track = atoi (p); - s->ending_track = atoi (p); - } - } -#endif /* HAVE_CDROM */ - - sp->si = sound_open (s, 1); + s->starting_track = atoi(p); + s->ending_track = atoi(p); + } + } +#endif /* HAVE_CDROM */ + + sp->si = sound_open(s, 1); if (sp->si == NULL) { - spool_destroy (sp); + spool_destroy(sp); return; } - sound_seek (sp->si, s->offset, SEEK_SET); /* skip the audio header */ + sound_seek(sp->si, s->offset, SEEK_SET); /* skip the audio header */ sp->curr_buffer = NULL; sp->next_buffer = NULL; @@ -864,32 +876,32 @@ sp->to_native = native_table[s->format].to_native[s->byte_order - 1]; - spool_set_sample_rate (sp, - (sp->curr_attrs->sample_rate == RPLAY_DEFAULT_SAMPLE_RATE) - ? s->sample_rate : sp->curr_attrs->sample_rate); + spool_set_sample_rate(sp, + (sp->curr_attrs->sample_rate == RPLAY_DEFAULT_SAMPLE_RATE) + ? s->sample_rate : sp->curr_attrs->sample_rate); /* Change the state to SPOOL_PLAY when ALL fields have been assigned. */ sp->state = SPOOL_PLAY; - + spool_nplaying++; - spool_setprio (); + spool_setprio(); spool_needs_update++; - connection_notify (0, NOTIFY_PLAY, sp); - connection_notify (0, NOTIFY_POSITION, sp); + connection_notify(0, NOTIFY_PLAY, sp); + connection_notify(0, NOTIFY_POSITION, sp); if (sp->auto_pause) { - spool_pause (sp); + spool_pause(sp); sp->auto_pause = 0; } } #ifdef __STDC__ void -spool_update (void) -#else -void -spool_update () +spool_update(void) +#else +void +spool_update() #endif { int i, n; @@ -897,10 +909,10 @@ SOUND *s; BUFFER *b; time_t now; - + spool_needs_update = 0; - now = time (0); - + now = time(0); + for (sp = spool; sp; sp = sp_next) { sp_next = sp->next; /* sp may be destroyed */ @@ -917,22 +929,22 @@ case SPOOL_NEXT: if (sp->notify_position) { - connection_notify (0, NOTIFY_POSITION, sp); + connection_notify(0, NOTIFY_POSITION, sp); sp->notify_position = 0; } - + if (!sp->auto_pause) /* something was playing */ { spool_nplaying--; } - + if (sp->si) { - sound_close (sp->si); + sound_close(sp->si); sp->si = NULL; } - buffer_dealloc (sp->curr_buffer, 0); - buffer_dealloc (sp->next_buffer, 0); + buffer_dealloc(sp->curr_buffer, 0); + buffer_dealloc(sp->next_buffer, 0); sp->curr_buffer = NULL; sp->next_buffer = NULL; sp->offset = 0; @@ -940,8 +952,8 @@ if (sp->state == SPOOL_SKIP) { /* The current sound is now `done'. */ - connection_notify (0, NOTIFY_DONE, sp); - + connection_notify(0, NOTIFY_DONE, sp); + if (sp->skip_count == 0) { sp->curr_count++; /* "play it again Sam" */ @@ -1002,14 +1014,15 @@ sp->curr_attrs = sp->rp->attrs; sp->curr_sound = 0; } - else /* The spool entry is finished. */ - { - if (sp->state != SPOOL_SKIP) /* already sent `done' */ + else + /* The spool entry is finished. */ + { + if (sp->state != SPOOL_SKIP) /* already sent `done' */ { - connection_notify (0, NOTIFY_DONE, sp); + connection_notify(0, NOTIFY_DONE, sp); } - spool_destroy (sp); + spool_destroy(sp); continue; } } @@ -1036,7 +1049,7 @@ sp->curr_count = sp->curr_attrs->count; } - spool_play (sp); + spool_play(sp); /* break; */ case SPOOL_PLAY: @@ -1045,21 +1058,21 @@ { s = sp->sound[sp->curr_sound]; -#ifdef HAVE_OSS - b = buffer_alloc (MIN (s->sample_rate * s->output_sample_size, SOUND_FILL_SIZE), - BUFFER_REUSE); -#else - b = buffer_alloc (MIN (MAX (curr_bufsize * curr_rate, - s->sample_rate * s->output_sample_size), - SOUND_FILL_SIZE), - BUFFER_REUSE); -#endif - - n = sound_fill (sp->si, b, 0); - +#ifdef HAVE_OSS + b = buffer_alloc(MIN(s->sample_rate * s->output_sample_size, SOUND_FILL_SIZE), + BUFFER_REUSE); +#else + b = buffer_alloc(MIN(MAX(curr_bufsize * curr_rate, + s->sample_rate * s->output_sample_size), + SOUND_FILL_SIZE), + BUFFER_REUSE); +#endif + + n = sound_fill(sp->si, b, 0); + if (n <= 0) { - buffer_dealloc (b, 1); + buffer_dealloc(b, 1); if (s->needs_helper) { @@ -1067,20 +1080,20 @@ { if (sp->si->eof) { - sound_close (sp->si); - sp->si = NULL; /* rplayd_write will see this as a dead sound */ + sound_close(sp->si); + sp->si = NULL; /* rplayd_write will see this as a dead sound */ spool_needs_update++; } else { - spool_flow_pause (sp); + spool_flow_pause(sp); } } } else if (s->type == SOUND_FILE) { - sound_close (sp->si); - sp->si = NULL; /* rplayd_write will see this as a dead sound */ + sound_close(sp->si); + sp->si = NULL; /* rplayd_write will see this as a dead sound */ } else if (s->type == SOUND_FLOW) { @@ -1088,13 +1101,13 @@ { if (sp->si->eof) { - sound_close (sp->si); - sp->si = NULL; /* rplayd_write will see this as a dead sound */ + sound_close(sp->si); + sp->si = NULL; /* rplayd_write will see this as a dead sound */ spool_needs_update++; } else { - spool_flow_pause (sp); + spool_flow_pause(sp); } } } @@ -1105,13 +1118,13 @@ { if (sp->si->eof) { - sound_close (sp->si); - sp->si = NULL; /* rplayd_write will see this as a dead sound */ + sound_close(sp->si); + sp->si = NULL; /* rplayd_write will see this as a dead sound */ spool_needs_update++; } else { - spool_flow_pause (sp); + spool_flow_pause(sp); } } #endif /* HAVE_CDROM */ @@ -1120,25 +1133,25 @@ else { sp->time = now; - + if (!sp->curr_buffer) { - timer_block (); + timer_block(); sp->ptr = (unsigned char *) b->buf + sp->offset; sp->ptr_end = (unsigned char *) b->buf + b->nbytes; sp->curr_buffer = b; - timer_unblock (); + timer_unblock(); } else { sp->next_buffer = b; } - + #ifdef HAVE_HELPERS if (s->needs_helper && ((sp->si->water_mark - sp->si->offset) < sp->si->low_water_mark)) { - FD_SET (sp->si->fd, &read_mask); + FD_SET(sp->si->fd, &read_mask); } #else if (0) @@ -1147,16 +1160,16 @@ } #endif /* HAVE_HELPERS */ else if (s->type == SOUND_FLOW - && ((sp->si->water_mark - sp->si->offset) < sp->si->low_water_mark)) - { - connection_notify (0, NOTIFY_FLOW, sp); - connection_flow_continue (sp); + && ((sp->si->water_mark - sp->si->offset) < sp->si->low_water_mark)) + { + connection_notify(0, NOTIFY_FLOW, sp); + connection_flow_continue(sp); } #ifdef HAVE_CDROM else if (s->type == SOUND_CDROM && ((sp->si->water_mark - sp->si->offset) < sp->si->low_water_mark)) { - FD_SET (sp->si->fd, &read_mask); + FD_SET(sp->si->fd, &read_mask); } #endif /* HAVE_CDROM */ } @@ -1168,10 +1181,10 @@ #ifdef __STDC__ int -spool_process (char *buf, int nbytes) +spool_process(char *buf, int nbytes) #else int -spool_process (buf, nbytes) +spool_process(buf, nbytes) char *buf; int nbytes; #endif @@ -1183,8 +1196,8 @@ /* Determine the number of samples that need to be processed. */ nsamples = nbytes / ((rplay_audio_precision >> 3) * rplay_audio_channels); - zero_native (rplay_audio_buf, nsamples, rplay_audio_channels); - + zero_native(rplay_audio_buf, nsamples, rplay_audio_channels); + for (sp = spool; sp; sp = sp_next) { sp_next = sp->next; @@ -1201,7 +1214,7 @@ } /* See if more buffers need to be filled by `spool_update'. */ else if (sp->curr_buffer == NULL || - (sp->si && !sp->si->eof && !sp->next_buffer)) + (sp->si && !sp->si->eof && !sp->next_buffer)) { spool_needs_update++; } @@ -1213,19 +1226,19 @@ if (number_playing) { #ifdef TEST_FLANGE - flange (rplay_audio_buf, nsamples, rplay_audio_channels); + flange(rplay_audio_buf, nsamples, rplay_audio_channels); #endif #ifdef FAKE_VOLUME - fake_volume (rplay_audio_buf, nsamples, rplay_audio_channels); -#endif - + fake_volume(rplay_audio_buf, nsamples, rplay_audio_channels); +#endif + /* Only calculate left and right levels if there's a connection that needs the information. */ if (connection_want_level_notify) { - level (rplay_audio_buf, nsamples, rplay_audio_channels); - connection_level_notify++; + level(rplay_audio_buf, nsamples, rplay_audio_channels); + connection_level_notify++; } /* Convert rplay_audio_buf to the audio device format. */ @@ -1238,15 +1251,15 @@ #ifdef __STDC__ SPOOL * -spool_find (int id) +spool_find(int id) #else SPOOL * -spool_find (id) +spool_find(id) int id; #endif { SPOOL *sp; - + for (sp = spool; sp; sp = sp->next) { if (sp->id == id) @@ -1261,35 +1274,35 @@ /* This routine can be used to remove idle flows from the spool. */ #ifdef __STDC__ void -spool_cleanup (void) -#else -void -spool_cleanup () +spool_cleanup(void) +#else +void +spool_cleanup() #endif { SPOOL *sp; int flows_cleaned = 0; - + for (sp = spool; sp; sp = sp->next) { if (sp->state == SPOOL_WAIT && sp->sound[sp->curr_sound]->type == SOUND_FLOW) { - spool_done (sp); + spool_done(sp); flows_cleaned++; } } - report (REPORT_DEBUG, "cleaning up the spool - %d flows\n", - flows_cleaned); -} - -#ifdef __STDC__ -void -spool_set_count (SPOOL *sp, int count) -#else -void -spool_set_count (sp, count) + report(REPORT_DEBUG, "cleaning up the spool - %d flows\n", + flows_cleaned); +} + +#ifdef __STDC__ +void +spool_set_count(SPOOL *sp, int count) +#else +void +spool_set_count(sp, count) SPOOL *sp; int count; #endif @@ -1303,10 +1316,10 @@ #ifdef __STDC__ void -spool_set_list_count (SPOOL *sp, int count) -#else -void -spool_set_list_count (sp, count) +spool_set_list_count(SPOOL *sp, int count) +#else +void +spool_set_list_count(sp, count) SPOOL *sp; int count; #endif @@ -1320,10 +1333,10 @@ #ifdef __STDC__ void -spool_set_priority (SPOOL *sp, int priority) -#else -void -spool_set_priority (sp, priority) +spool_set_priority(SPOOL *sp, int priority) +#else +void +spool_set_priority(sp, priority) SPOOL *sp; int priority; #endif @@ -1331,16 +1344,16 @@ if (sp) { sp->rp->priority = priority; - spool_setprio (); - } -} - -#ifdef __STDC__ -void -spool_set_sample_rate (SPOOL *sp, int sample_rate) -#else -void -spool_set_sample_rate (sp, sample_rate) + spool_setprio(); + } +} + +#ifdef __STDC__ +void +spool_set_sample_rate(SPOOL *sp, int sample_rate) +#else +void +spool_set_sample_rate(sp, sample_rate) SPOOL *sp; int sample_rate; #endif @@ -1353,17 +1366,17 @@ if (rplay_audio_match) { - rplayd_audio_match (sp); - } - } -} - -#ifdef __STDC__ -void -spool_set_volume (SPOOL *sp, int volume) -#else -void -spool_set_volume (sp, volume) + rplayd_audio_match(sp); + } + } +} + +#ifdef __STDC__ +void +spool_set_volume(SPOOL *sp, int volume) +#else +void +spool_set_volume(sp, volume) SPOOL *sp; int volume; #endif @@ -1376,10 +1389,10 @@ #ifdef __STDC__ void -spool_set_client_data (SPOOL *sp, char *client_data) -#else -void -spool_set_client_data (sp, client_data) +spool_set_client_data(SPOOL *sp, char *client_data) +#else +void +spool_set_client_data(sp, client_data) SPOOL *sp; char *client_data; #endif @@ -1388,24 +1401,24 @@ { if (*sp->curr_attrs->client_data) { - free ((char *) sp->curr_attrs->client_data); - } - - sp->curr_attrs->client_data = strdup (client_data); + free((char *) sp->curr_attrs->client_data); + } + + sp->curr_attrs->client_data = strdup(client_data); } } #ifdef __STDC__ SPOOL * -spool_find_pid (int pid) +spool_find_pid(int pid) #else SPOOL * -spool_find_pid (pid) +spool_find_pid(pid) int pid; #endif { SPOOL *sp; - + #if defined(HAVE_CDROM) || defined(HAVE_HELPERS) for (sp = spool; sp; sp = sp->next) { diff --git a/rplayd/spool.h b/rplayd/spool.h index 80eb9f6..2e67a21 100644 --- a/rplayd/spool.h +++ b/rplayd/spool.h @@ -1,7 +1,7 @@ -/* $Id: spool.h,v 1.2 1998/08/13 06:14:08 boyns Exp $ */ +/* $Id: spool.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/timer.c b/rplayd/timer.c index 6b4759c..0f308ba 100644 --- a/rplayd/timer.c +++ b/rplayd/timer.c @@ -1,7 +1,7 @@ -/* $Id: timer.c,v 1.2 1998/08/13 06:14:09 boyns Exp $ */ +/* $Id: timer.c,v 1.4 1999/03/10 07:58:04 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,6 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifdef HAVE_CONFIG_H #include "config.h" @@ -39,31 +37,31 @@ int timer_enabled = 0; void -timer_update () +timer_update() { #ifdef HAVE_OSS - int bytes = rplay_audio_getospace_bytes (); + int bytes = rplay_audio_getospace_bytes(); /* check bytes and sample size? */ if (bytes > 0) { - rplayd_write (bytes); + rplayd_write(bytes); } /* if audio device isn't open, just pretend to keep spool going */ - else if (!rplay_audio_isopen ()) + else if (!rplay_audio_isopen()) { /* approximate the amount to be written */ int sample_size = (rplay_audio_precision >> 3) * rplay_audio_channels; - rplayd_write (rplay_audio_sample_rate / curr_rate * sample_size); + rplayd_write(rplay_audio_sample_rate / curr_rate * sample_size); } -#else - rplayd_write (curr_bufsize); +#else + rplayd_write(curr_bufsize); #endif - + timer_count += timer_rate; } void -timer_init () +timer_init() { struct sigaction sa; @@ -72,53 +70,53 @@ #if defined(SA_RESTART) && ! defined(sgi) sa.sa_flags |= SA_RESTART; #endif - sigemptyset (&sa.sa_mask); - sigaddset (&sa.sa_mask, SIGALRM); - if (sigaction (SIGALRM, &sa, (struct sigaction *) NULL) < 0) + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, SIGALRM); + if (sigaction(SIGALRM, &sa, (struct sigaction *) NULL) < 0) { - report (REPORT_ERROR, "timer_init: sigaction: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "timer_init: sigaction: %s\n", sys_err_str(errno)); + done(1); } timer_enabled = 0; } void -timer_block () +timer_block() { sigset_t sigset; - sigemptyset (&sigset); - sigaddset (&sigset, SIGALRM); + sigemptyset(&sigset); + sigaddset(&sigset, SIGALRM); - if (sigprocmask (SIG_BLOCK, &sigset, NULL) < 0) + if (sigprocmask(SIG_BLOCK, &sigset, NULL) < 0) { - report (REPORT_ERROR, "timer_block: sigsetprocmask: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "timer_block: sigsetprocmask: %s\n", sys_err_str(errno)); + done(1); } } void -timer_unblock () +timer_unblock() { sigset_t sigset; - sigemptyset (&sigset); - sigaddset (&sigset, SIGALRM); + sigemptyset(&sigset); + sigaddset(&sigset, SIGALRM); - if (sigprocmask (SIG_UNBLOCK, &sigset, NULL) < 0) + if (sigprocmask(SIG_UNBLOCK, &sigset, NULL) < 0) { - report (REPORT_ERROR, "timer_block: sigsetprocmask: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "timer_block: sigsetprocmask: %s\n", sys_err_str(errno)); + done(1); } } #ifdef __STDC__ void -timer_restart (int new_rate) +timer_restart(int new_rate) #else void -timer_restart (new_rate) +timer_restart(new_rate) int new_rate; #endif { @@ -128,8 +126,8 @@ if (new_rate <= 0) { - report (REPORT_ERROR, "timer_restart: new_rate=%d, must be >= 1\n", new_rate); - done (1); + report(REPORT_ERROR, "timer_restart: new_rate=%d, must be >= 1\n", new_rate); + done(1); } else if (new_rate == 1) { @@ -142,10 +140,10 @@ it.it_interval.tv_usec = 1000000 / new_rate; } it.it_value = it.it_interval; - if (setitimer (ITIMER_REAL, &it, NULL) < 0) + if (setitimer(ITIMER_REAL, &it, NULL) < 0) { - report (REPORT_ERROR, "timer_restart: setitimer: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "timer_restart: setitimer: %s\n", sys_err_str(errno)); + done(1); } if (it.it_interval.tv_sec) @@ -160,18 +158,18 @@ #ifdef __STDC__ void -timer_start (int new_rate) +timer_start(int new_rate) #else void -timer_start (new_rate) +timer_start(new_rate) int new_rate; #endif { - timer_restart (new_rate); + timer_restart(new_rate); } void -timer_stop () +timer_stop() { struct itimerval it; @@ -180,9 +178,9 @@ it.it_interval.tv_sec = 0; it.it_interval.tv_usec = 0; it.it_value = it.it_interval; - if (setitimer (ITIMER_REAL, &it, NULL) < 0) + if (setitimer(ITIMER_REAL, &it, NULL) < 0) { - report (REPORT_ERROR, "timer_stop: setitimer: %s\n", sys_err_str (errno)); - done (1); + report(REPORT_ERROR, "timer_stop: setitimer: %s\n", sys_err_str(errno)); + done(1); } } diff --git a/rplayd/timer.h b/rplayd/timer.h index 76ca5d0..0b40f5b 100644 --- a/rplayd/timer.h +++ b/rplayd/timer.h @@ -1,7 +1,7 @@ -/* $Id: timer.h,v 1.2 1998/08/13 06:14:10 boyns Exp $ */ +/* $Id: timer.h,v 1.3 1999/03/10 07:58:04 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/ulaw.c b/rplayd/ulaw.c index 660d52a..653c1c5 100644 --- a/rplayd/ulaw.c +++ b/rplayd/ulaw.c @@ -1,7 +1,7 @@ -/* $Id: ulaw.c,v 1.2 1998/08/13 06:14:11 boyns Exp $ */ +/* $Id: ulaw.c,v 1.4 1999/03/10 07:58:04 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ + - #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/rplayd/ulaw.h b/rplayd/ulaw.h index 957fafe..bcdd539 100644 --- a/rplayd/ulaw.h +++ b/rplayd/ulaw.h @@ -1,7 +1,7 @@ -/* $Id: ulaw.h,v 1.2 1998/08/13 06:14:12 boyns Exp $ */ +/* $Id: ulaw.h,v 1.3 1999/03/10 07:58:05 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rplayd/xhash.c b/rplayd/xhash.c index 2cd7a8d..323b6c8 100644 --- a/rplayd/xhash.c +++ b/rplayd/xhash.c @@ -1,7 +1,7 @@ -/* $Id: xhash.c,v 1.2 1998/08/13 06:14:13 boyns Exp $ */ +/* $Id: xhash.c,v 1.4 1999/03/10 07:58:05 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,9 +20,9 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ + - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -40,75 +40,75 @@ #ifdef DEBUG static void -xhash_stats () +xhash_stats() { int statbuf[HASH_STATLENGTH]; - hash_say (htable, statbuf, HASH_STATLENGTH); - printf (" %d size, %d read, %d write, %d collisions, %d used\n", - statbuf[1], statbuf[2], statbuf[3], statbuf[4], statbuf[5]); + hash_say(htable, statbuf, HASH_STATLENGTH); + printf(" %d size, %d read, %d write, %d collisions, %d used\n", + statbuf[1], statbuf[2], statbuf[3], statbuf[4], statbuf[5]); } #endif #ifdef __STDC__ void -xhash_init (int hash_table_size) +xhash_init(int hash_table_size) #else void -xhash_init (hash_table_size) +xhash_init(hash_table_size) int hash_table_size; #endif { - htable = hash_new (); + htable = hash_new(); } #ifdef __STDC__ char * -xhash_get (char *hash_key) +xhash_get(char *hash_key) #else char * -xhash_get (hash_key) +xhash_get(hash_key) char *hash_key; #endif { - return (char *) hash_find (htable, hash_key); + return (char *) hash_find(htable, hash_key); } #ifdef __STDC__ void -xhash_put (char *hash_key, char *data) +xhash_put(char *hash_key, char *data) #else void -xhash_put (hash_key, data) +xhash_put(hash_key, data) char *hash_key; char *data; #endif { - hash_insert (htable, hash_key, data); + hash_insert(htable, hash_key, data); } #ifdef __STDC__ void -xhash_replace (char *hash_key, char *data) +xhash_replace(char *hash_key, char *data) #else void -xhash_replace (hash_key, data) +xhash_replace(hash_key, data) char *hash_key; char *data; #endif { - hash_replace (htable, hash_key, data); + hash_replace(htable, hash_key, data); } #ifdef __STDC__ void -xhash_delete (char *hash_key) +xhash_delete(char *hash_key) #else void -xhash_delete (hash_key) +xhash_delete(hash_key) char *hash_key; #endif { - hash_delete (htable, hash_key); + hash_delete(htable, hash_key); } /* @@ -116,10 +116,10 @@ */ #ifdef __STDC__ char * -xhash_name (char *pathname) +xhash_name(char *pathname) #else char * -xhash_name (pathname) +xhash_name(pathname) char *pathname; #endif { @@ -128,11 +128,11 @@ if (pathname[0] == '/') { - pathname = strrchr (pathname, '/') + 1; + pathname = strrchr(pathname, '/') + 1; } - strncpy (name, pathname, sizeof(name)); - extension = strrchr (name, '.'); + strncpy(name, pathname, sizeof(name)); + extension = strrchr(name, '.'); if (extension) { *extension = '\0'; @@ -143,18 +143,18 @@ #ifdef __STDC__ void -xhash_apply (char *(*func) ()) +xhash_apply(char *(*func) ()) #else void -xhash_apply (func) +xhash_apply(func) char *(*func) (); #endif { - hash_apply (htable, func); + hash_apply(htable, func); } void -xhash_die () +xhash_die() { - hash_die (htable); + hash_die(htable); } diff --git a/rplayd/xhash.h b/rplayd/xhash.h index 49e8916..0a3e9a0 100644 --- a/rplayd/xhash.h +++ b/rplayd/xhash.h @@ -1,7 +1,7 @@ -/* $Id: xhash.h,v 1.2 1998/08/13 06:14:14 boyns Exp $ */ +/* $Id: xhash.h,v 1.3 1999/03/10 07:58:05 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * diff --git a/rptp/CVS/Entries b/rptp/CVS/Entries deleted file mode 100644 index 070b4ef..0000000 --- a/rptp/CVS/Entries +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:23 1998// -/rptp.c/1.2/Thu Aug 13 06:14:28 1998// -D diff --git a/rptp/CVS/Repository b/rptp/CVS/Repository deleted file mode 100644 index b07e62b..0000000 --- a/rptp/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/rptp diff --git a/rptp/CVS/Root b/rptp/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/rptp/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/rptp/Makefile.in b/rptp/Makefile.in index e65abf5..78c1ed7 100644 --- a/rptp/Makefile.in +++ b/rptp/Makefile.in @@ -13,7 +13,7 @@ .c.o: $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -LDFLAGS= $(LD_OPTIONS) -L../librplay -lrplay -L../lib -lrp @LDFLAGS@ @LIBS@ +LDFLAGS= $(LD_OPTIONS) -L../librplay -lrplay -L../lib -lrp @LDFLAGS@ @RL_LIBS@ @LIBS@ TARGET= rptp @@ -25,6 +25,12 @@ $(TARGET): $(OBJS) ../librplay/$(LIBRPLAY_NAME) ../lib/librp.a $(CC) -o $@ $(OBJS) $(LDFLAGS) + +../librplay/$(LIBRPLAY_NAME): + (cd ../librplay; $(MAKE) $(MFLAGS)) + +../lib/librp.a: + (cd ../lib; $(MAKE) $(MFLAGS)) install: all $(MKINSTALLDIRS) $(bindir) diff --git a/rptp/rptp.c b/rptp/rptp.c index 171ad40..cadb52e 100644 --- a/rptp/rptp.c +++ b/rptp/rptp.c @@ -1,7 +1,7 @@ -/* $Id: rptp.c,v 1.2 1998/08/13 06:14:28 boyns Exp $ */ +/* $Id: rptp.c,v 1.6 1999/03/21 00:45:08 boyns Exp $ */ /* - * Copyright (C) 1993-98 Mark R. Boyns + * Copyright (C) 1993-99 Mark R. Boyns * * This file is part of rplay. * @@ -20,8 +20,6 @@ * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ - - #ifdef HAVE_CONFIG_H #include "config.h" @@ -33,6 +31,10 @@ #ifdef HAVE_STRING_H #include #endif +#ifdef HAVE_LIBREADLINE +#include +#include +#endif /* HAVE_LIBREADLINE */ #include "rplay.h" #include "getopt.h" @@ -51,45 +53,50 @@ COMMAND; #ifdef __STDC__ -void command_open (int argc, char **argv); -void command_close (int argc, char **argv); -void command_play (int argc, char **argv); -void command_help (int argc, char **argv); -void command_list (int argc, char **argv); -void command_quit (int argc, char **argv); -void command_put (int argc, char **argv); -void command_get (int argc, char **argv); -void command_unknown (int argc, char **argv); -void command_status (int argc, char **argv); -void command_generic (int argc, char **argv); -void command_volume (int argc, char **argv); -void command_skip (int argc, char **argv); -void argv_to_command (char **argv); -int connected (); -void done (int exit_value); -void usage (); -void do_application (); -void do_error (char *repsonse); -#else -void command_open ( /* int argc, char **argv */ ); -void command_close ( /* int argc, char **argv */ ); -void command_play ( /* int argc, char **argv */ ); -void command_help ( /* int argc, char **argv */ ); -void command_list ( /* int argc, char **argv */ ); -void command_quit ( /* int argc, char **argv */ ); -void command_put ( /* int argc, char **argv */ ); -void command_get ( /* int argc, char **argv */ ); -void command_unknown ( /* int argc, char **argv */ ); -void command_status ( /* int argc, char **argv */ ); -void command_generic ( /* int argc, char **argv */ ); -void command_volume ( /* int argc, char **argv */ ); -void command_skip ( /* int argc, char **argv */ ); -void argv_to_command ( /* char **argv */ ); -int connected (); -void done ( /* int exit_value */ ); -void usage (); -void do_application (); -void do_error ( /* char *repsonse */ ); +void command_open(int argc, char **argv); +void command_close(int argc, char **argv); +void command_play(int argc, char **argv); +void command_help(int argc, char **argv); +void command_list(int argc, char **argv); +void command_quit(int argc, char **argv); +void command_put(int argc, char **argv); +void command_get(int argc, char **argv); +void command_unknown(int argc, char **argv); +void command_set(int argc, char **argv); +void command_status(int argc, char **argv); +void command_generic(int argc, char **argv); +void command_volume(int argc, char **argv); +void command_skip(int argc, char **argv); +void command_set(int argc, char **argv); +void command_monitor(int argc, char **argv); +void argv_to_command(char **argv); +int connected(); +void done(int exit_value); +void usage(); +void do_application(); +void do_error(char *repsonse); +#else +void command_open( /* int argc, char **argv */ ); +void command_close( /* int argc, char **argv */ ); +void command_play( /* int argc, char **argv */ ); +void command_help( /* int argc, char **argv */ ); +void command_list( /* int argc, char **argv */ ); +void command_quit( /* int argc, char **argv */ ); +void command_put( /* int argc, char **argv */ ); +void command_get( /* int argc, char **argv */ ); +void command_unknown( /* int argc, char **argv */ ); +void command_status( /* int argc, char **argv */ ); +void command_generic( /* int argc, char **argv */ ); +void command_volume( /* int argc, char **argv */ ); +void command_skip( /* int argc, char **argv */ ); +void command_set( /* int argc, char **argv */ ); +void command_monitor( /* int argc, char **argv */ ); +void argv_to_command( /* char **argv */ ); +int connected(); +void done( /* int exit_value */ ); +void usage(); +void do_application(); +void do_error( /* char *repsonse */ ); #endif COMMAND commands[] = @@ -102,12 +109,14 @@ "help", 0, 1, "[command]", command_help, "info", 1, 1, "sound", command_generic, "list", 0, 1, "[connections|hosts|servers|spool|sounds]", command_list, + "monitor", 0, 0, "", command_monitor, "open", 1, 2, "hostname [port]", command_open, "pause", 1, -1, "#id|sound ...", command_play, "play", 1, -1, "[options] sound ...", command_play, "put", 1, 1, "sound", command_put, "quit", 0, 0, "", command_quit, "reset", 0, 0, "", command_generic, + "set", 1, -1, "name=value", command_set, "skip", 0, 2, "[#id] [[+|-]count]", command_skip, "status", 0, 0, "", command_status, "stop", 1, -1, "#id|sound ...", command_play, @@ -141,9 +150,9 @@ extern char *optarg; #ifdef __STDC__ -main (int argc, char **argv) -#else -main (argc, argv) +main(int argc, char **argv) +#else +main(argc, argv) int argc; char **argv; #endif @@ -156,7 +165,7 @@ int ac, first; char numeric_string[128]; - while ((c = getopt_long (argc, argv, "+h:p:rv", longopts, 0)) != -1) + while ((c = getopt_long(argc, argv, "+h:p:rv", longopts, 0)) != -1) { switch (c) { @@ -165,8 +174,8 @@ break; case 1: /* --help */ - usage (); - done (0); + usage(); + done(0); case 2: /* --prompt */ prompt = optarg; @@ -177,7 +186,7 @@ break; case 'p': - port = atoi (optarg); + port = atoi(optarg); break; case 'r': @@ -185,12 +194,12 @@ break; case 'v': - printf ("rplay %s\n", RPLAY_VERSION); - done (0); + printf("rplay %s\n", RPLAY_VERSION); + done(0); default: - fprintf (stderr, "Try `rptp --help' for more information.\n"); - exit (1); + fprintf(stderr, "Try `rptp --help' for more information.\n"); + exit(1); } } @@ -201,38 +210,38 @@ if (host == NULL) { - host = rplay_default_host (); - } - - rptp_fd = rptp_open (host, port, response, sizeof (response)); + host = rplay_default_host(); + } + + rptp_fd = rptp_open(host, port, response, sizeof(response)); if (rptp_fd < 0) { - rptp_perror ("open"); + rptp_perror("open"); } else if (interactive) { if (raw) { - printf ("%s\n", response); + printf("%s\n", response); } else { - if (strchr (response, '=')) + if (strchr(response, '=')) { - rptp_parse (response, 0); - printf ("%s rplayd %s connected\n", - rptp_parse (0, "host"), - rptp_parse (0, "version")); + rptp_parse(response, 0); + printf("%s rplayd %s connected\n", + rptp_parse(0, "host"), + rptp_parse(0, "version")); } else { - printf ("Connected to %s port %d.\n", host, port); - printf ("%s\n", response + 1); + printf("Connected to %s port %d.\n", host, port); + printf("%s\n", response + 1); } } } - do_application (); + do_application(); do { @@ -240,16 +249,29 @@ { if (!raw) { - printf (prompt); - fflush (stdout); +#ifdef HAVE_LIBREADLINE + p = readline(prompt); + if (!p) + { + done(0); + } + add_history(p); + strcpy(buf, p); +#else + printf(prompt); + fflush(stdout); +#endif } - if (fgets (buf, sizeof (buf), stdin) == NULL) + +#ifndef HAVE_LIBREADLINE + if (fgets(buf, sizeof(buf), stdin) == NULL) { - done (0); + done(0); } +#endif first = 1; ac = 0; - while ((p = strtok (first ? buf : NULL, " \t\r\n"))) + while ((p = strtok(first ? buf : NULL, " \t\r\n"))) { av[ac++] = p; first = 0; @@ -275,12 +297,12 @@ for (i = 0; i < NCOMMANDS; i++) { - if (strcasecmp (commands[i].name, av[0]) == 0) + if (strcasecmp(commands[i].name, av[0]) == 0) { if ((commands[i].min_args >= 0 && ac - 1 < commands[i].min_args) || (commands[i].max_args >= 0 && ac - 1 > commands[i].max_args)) { - printf ("Usage: %s %s\n", commands[i].name, commands[i].usage); + printf("Usage: %s %s\n", commands[i].name, commands[i].usage); } else { @@ -291,36 +313,36 @@ } if (i == NCOMMANDS) { - command_unknown (ac, av); + command_unknown(ac, av); } } while (interactive); - done (0); -} - -#ifdef __STDC__ -void -argv_to_command (char **argv) -#else -void -argv_to_command (argv) + done(0); +} + +#ifdef __STDC__ +void +argv_to_command(char **argv) +#else +void +argv_to_command(argv) char **argv; #endif { command[0] = '\0'; for (; *argv; argv++) { - strcat (command, *argv); + strcat(command, *argv); if (*(argv + 1)) { - strcat (command, " "); + strcat(command, " "); } } } int -connected () +connected() { if (rptp_fd != -1) { @@ -328,17 +350,17 @@ } else { - printf ("You're not connected, use `open' first.\n"); + printf("You're not connected, use `open' first.\n"); return 0; } } #ifdef __STDC__ void -command_open (int argc, char **argv) -#else -void -command_open (argc, argv) +command_open(int argc, char **argv) +#else +void +command_open(argc, argv) int argc; char **argv; #endif @@ -347,88 +369,88 @@ if (rptp_fd != -1) { - printf ("You're already connected, use `close' first.\n"); + printf("You're already connected, use `close' first.\n"); } else { - port = argc == 3 ? atoi (argv[2]) : RPTP_PORT; - rptp_fd = rptp_open (argv[1], port, response, sizeof (response)); + port = argc == 3 ? atoi(argv[2]) : RPTP_PORT; + rptp_fd = rptp_open(argv[1], port, response, sizeof(response)); if (rptp_fd < 0) { - rptp_perror ("open"); + rptp_perror("open"); } else { if (raw) { - printf ("%s\n", response); + printf("%s\n", response); } else { - if (strchr (response, '=')) + if (strchr(response, '=')) { - printf ("%s rplayd %s connected\n", - rptp_parse (response, "host"), - rptp_parse (0, "version")); + printf("%s rplayd %s connected\n", + rptp_parse(response, "host"), + rptp_parse(0, "version")); } else { - printf ("Connected to %s port %d.\n", argv[1], port); - printf ("%s\n", response + 1); + printf("Connected to %s port %d.\n", argv[1], port); + printf("%s\n", response + 1); } } - do_application (); - } - } -} - -#ifdef __STDC__ -void -command_close (int argc, char **argv) -#else -void -command_close (argc, argv) - int argc; - char **argv; -#endif -{ - if (connected ()) - { - rptp_close (rptp_fd); + do_application(); + } + } +} + +#ifdef __STDC__ +void +command_close(int argc, char **argv) +#else +void +command_close(argc, argv) + int argc; + char **argv; +#endif +{ + if (connected()) + { + rptp_close(rptp_fd); rptp_fd = -1; if (interactive) { - printf ("Connection closed.\n"); - } - } -} - -#ifdef __STDC__ -void -command_play (int argc, char **argv) -#else -void -command_play (argc, argv) - int argc; - char **argv; -#endif -{ - argv_to_command (argv); - - if (!connected ()) - { - return; - } - - switch (rptp_command (rptp_fd, command, response, sizeof (response))) + printf("Connection closed.\n"); + } + } +} + +#ifdef __STDC__ +void +command_play(int argc, char **argv) +#else +void +command_play(argc, argv) + int argc; + char **argv; +#endif +{ + argv_to_command(argv); + + if (!connected()) + { + return; + } + + switch (rptp_command(rptp_fd, command, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - command_close (argc, argv); + rptp_perror(argv[0]); + command_close(argc, argv); return; case 1: - do_error (response); + do_error(response); return; case 0: @@ -437,51 +459,51 @@ if (raw) { - printf ("%s\n", response); - } -} - -#ifdef __STDC__ -void -command_generic (int argc, char **argv) -#else -void -command_generic (argc, argv) - int argc; - char **argv; -#endif -{ - argv_to_command (argv); - - if (!connected ()) - { - return; - } - - switch (rptp_command (rptp_fd, command, response, sizeof (response))) + printf("%s\n", response); + } +} + +#ifdef __STDC__ +void +command_generic(int argc, char **argv) +#else +void +command_generic(argc, argv) + int argc; + char **argv; +#endif +{ + argv_to_command(argv); + + if (!connected()) + { + return; + } + + switch (rptp_command(rptp_fd, command, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - command_close (argc, argv); + rptp_perror(argv[0]); + command_close(argc, argv); return; case 1: - do_error (response); + do_error(response); return; case 0: break; } - printf ("%s\n", raw ? response : response + 1); -} - -#ifdef __STDC__ -void -command_help (int argc, char **argv) -#else -void -command_help (argc, argv) + printf("%s\n", raw ? response : response + 1); +} + +#ifdef __STDC__ +void +command_help(int argc, char **argv) +#else +void +command_help(argc, argv) int argc; char **argv; #endif @@ -492,122 +514,123 @@ { for (i = 0; i < NCOMMANDS; i++) { - if (strcasecmp (commands[i].name, argv[1]) == 0) + if (strcasecmp(commands[i].name, argv[1]) == 0) { - printf ("Usage: %s %s\n", commands[i].name, commands[i].usage); + printf("Usage: %s %s\n", commands[i].name, commands[i].usage); return; } } - command_unknown (argc, argv); + command_unknown(argc, argv); } else { - printf ("access Display remote access permissions.\n"); - printf ("close Close the current server connection.\n"); - printf ("continue Continue paused sounds.\n"); - printf ("find Search for a sound.\n"); - printf ("get Retrieve a sound.\n"); - printf ("help Display help information.\n"); - printf ("info Display sound information.\n"); - printf ("list Display various server information.\n"); - printf ("open Connect to a server.\n"); - printf ("pause Pause sounds that are playing.\n"); - printf ("play Play sounds\n"); - printf ("put Send a sound.\n"); - printf ("quit Terminate the rptp session.\n"); - printf ("reset Tell the server to reset itself.\n"); - printf ("skip Skip sounds in a sound list.\n"); - printf ("status Display server statistics.\n"); - printf ("stop Stop sounds that are playing.\n"); - printf ("version Display the version of the server.\n"); - printf ("volume Get and set the volume of the audio device.\n"); - printf ("wait Wait for a spool id, volume change, or command execution.\n"); - } -} - -#ifdef __STDC__ -void -command_list (int argc, char **argv) -#else -void -command_list (argc, argv) + printf("access Display remote access permissions.\n"); + printf("close Close the current server connection.\n"); + printf("continue Continue paused sounds.\n"); + printf("find Search for a sound.\n"); + printf("get Retrieve a sound.\n"); + printf("help Display help information.\n"); + printf("info Display sound information.\n"); + printf("list Display various server information.\n"); + printf("open Connect to a server.\n"); + printf("pause Pause sounds that are playing.\n"); + printf("play Play sounds\n"); + printf("put Send a sound.\n"); + printf("quit Terminate the rptp session.\n"); + printf("reset Tell the server to reset itself.\n"); + printf("set Change server settings.\n"); + printf("skip Skip sounds in a sound list.\n"); + printf("status Display server statistics.\n"); + printf("stop Stop sounds that are playing.\n"); + printf("version Display the version of the server.\n"); + printf("volume Get and set the volume of the audio device.\n"); + printf("wait Wait for a spool id, volume change, or command execution.\n"); + } +} + +#ifdef __STDC__ +void +command_list(int argc, char **argv) +#else +void +command_list(argc, argv) int argc; char **argv; #endif { int n; - if (!connected ()) - { - return; - } - - argv_to_command (argv); - - switch (rptp_command (rptp_fd, command, response, sizeof (response))) + if (!connected()) + { + return; + } + + argv_to_command(argv); + + switch (rptp_command(rptp_fd, command, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - command_close (argc, argv); + rptp_perror(argv[0]); + command_close(argc, argv); return; case 1: - do_error (response); + do_error(response); return; case 0: if (raw) { - printf ("%s\n", response); + printf("%s\n", response); } break; } for (;;) { - n = rptp_getline (rptp_fd, rptp_buf, sizeof (rptp_buf)); + n = rptp_getline(rptp_fd, rptp_buf, sizeof(rptp_buf)); if (n < 0) { - rptp_perror ("list"); - command_close (argc, argv); + rptp_perror("list"); + command_close(argc, argv); break; } - if (strcmp (rptp_buf, ".") == 0) + if (strcmp(rptp_buf, ".") == 0) { if (raw) { - printf ("%s\n", rptp_buf); + printf("%s\n", rptp_buf); } break; } - printf ("%s\n", rptp_buf); - } -} - -#ifdef __STDC__ -void -command_quit (int argc, char **argv) -#else -void -command_quit (argc, argv) + printf("%s\n", rptp_buf); + } +} + +#ifdef __STDC__ +void +command_quit(int argc, char **argv) +#else +void +command_quit(argc, argv) int argc; char **argv; #endif { if (rptp_fd != -1) { - rptp_close (rptp_fd); - printf ("Connection closed.\n"); - } - done (0); -} - -#ifdef __STDC__ -void -command_put (int argc, char **argv) -#else -void -command_put (argc, argv) + rptp_close(rptp_fd); + printf("Connection closed.\n"); + } + done(0); +} + +#ifdef __STDC__ +void +command_put(int argc, char **argv) +#else +void +command_put(argc, argv) int argc; char **argv; #endif @@ -616,66 +639,76 @@ int size, n, nwritten; struct stat st; char line[RPTP_MAX_LINE]; - - if (!connected ()) - { - return; - } - - if (stat (argv[1], &st) < 0) - { - perror (argv[1]); - return; - } - fp = fopen (argv[1], "r"); + int total_size; + + if (!connected()) + { + return; + } + + if (stat(argv[1], &st) < 0) + { + perror(argv[1]); + return; + } + fp = fopen(argv[1], "r"); if (fp == NULL) { - perror (argv[1]); + perror(argv[1]); return; } size = st.st_size; - sprintf (line, "put sound=%s size=%d", argv[1], size); - - switch (rptp_command (rptp_fd, line, response, sizeof (response))) + sprintf(line, "put sound=%s size=%d", argv[1], size); + + switch (rptp_command(rptp_fd, line, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - command_close (argc, argv); + rptp_perror(argv[0]); + command_close(argc, argv); return; case 1: - do_error (response); + do_error(response); return; case 0: break; } - printf ("%s\n", raw ? response : response + 1); - + if (raw) + { + printf("%s\n", response); + } + + total_size = size; while (size > 0) { - n = fread (rptp_buf, 1, sizeof (rptp_buf), fp); - nwritten = rptp_write (rptp_fd, rptp_buf, n); + n = fread(rptp_buf, 1, sizeof(rptp_buf), fp); + nwritten = rptp_write(rptp_fd, rptp_buf, n); if (nwritten != n) { - rptp_perror ("put"); - command_close (argc, argv); + rptp_perror("put"); + command_close(argc, argv); break; } size -= nwritten; - } - - fclose (fp); -} - -#ifdef __STDC__ -void -command_get (int argc, char **argv) -#else -void -command_get (argc, argv) + + sprintf(line, "\r%s %d/%d %d%%", argv[1], + total_size - size, total_size, + (int)(((float)(total_size-size)/total_size)*100)); + write(2, line, strlen(line)); + } + write(2, "\n", 1); + fclose(fp); +} + +#ifdef __STDC__ +void +command_get(int argc, char **argv) +#else +void +command_get(argc, argv) int argc; char **argv; #endif @@ -683,10 +716,10 @@ FILE *fp; char *filename; char *p; - int size, n, nread; + int size, n, nread, total_size; char line[RPTP_MAX_LINE]; - if (!connected ()) + if (!connected()) { return; } @@ -701,97 +734,104 @@ filename = argv[1]; } - sprintf (line, "get sound=%s", argv[1]); - - switch (rptp_command (rptp_fd, line, response, sizeof (response))) + sprintf(line, "get sound=%s", argv[1]); + + switch (rptp_command(rptp_fd, line, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - command_close (argc, argv); + rptp_perror(argv[0]); + command_close(argc, argv); return; case 1: - do_error (response); + do_error(response); return; case 0: break; } - printf ("%s\n", raw ? response : response + 1); - - fp = fopen (filename, "w"); + if (raw) + printf("%s\n", response); + + fp = fopen(filename, "w"); if (fp == NULL) { - perror (filename); - return; - } - - if (strchr (response, '=')) - { - size = atoi (rptp_parse (response, "size")); + perror(filename); + return; + } + + if (strchr(response, '=')) + { + size = atoi(rptp_parse(response, "size")); } else { - p = strtok (response + 1, " "); - size = atoi (strtok (NULL, "\r\n")); - } - + p = strtok(response + 1, " "); + size = atoi(strtok(NULL, "\r\n")); + } + + total_size = size; while (size > 0) { - n = MIN (sizeof (rptp_buf), size); - nread = rptp_read (rptp_fd, rptp_buf, n); + n = MIN(sizeof(rptp_buf), size); + nread = rptp_read(rptp_fd, rptp_buf, n); if (nread != n) { - rptp_perror ("get"); + rptp_perror("get"); break; } - fwrite (rptp_buf, 1, n, fp); + fwrite(rptp_buf, 1, n, fp); size -= n; - } - - fclose (fp); -} - -#ifdef __STDC__ -void -command_unknown (int argc, char **argv) -#else -void -command_unknown (argc, argv) - int argc; - char **argv; -#endif -{ - printf ("Unknown command `%s'.\n", argv[0]); -} - -#ifdef __STDC__ -void -command_status (int argc, char **argv) -#else -void -command_status (argc, argv) - int argc; - char **argv; -#endif -{ - argv_to_command (argv); - - if (!connected ()) - { - return; - } - - switch (rptp_command (rptp_fd, command, response, sizeof (response))) + + sprintf(line, "\r%s %d/%d %d%%", filename, + total_size - size, total_size, + (int)(((float)(total_size-size)/total_size)*100)); + write(2, line, strlen(line)); + } + write(2, "\n", 1); + fclose(fp); +} + +#ifdef __STDC__ +void +command_unknown(int argc, char **argv) +#else +void +command_unknown(argc, argv) + int argc; + char **argv; +#endif +{ + printf("unknown command `%s'.\n", argv[0]); +} + +#ifdef __STDC__ +void +command_status(int argc, char **argv) +#else +void +command_status(argc, argv) + int argc; + char **argv; +#endif +{ + argv_to_command(argv); + + if (!connected()) + { + return; + } + + switch (rptp_command(rptp_fd, command, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - command_close (argc, argv); + rptp_perror(argv[0]); + command_close(argc, argv); return; case 1: - do_error (response); + do_error(response); return; case 0: @@ -800,149 +840,162 @@ if (raw) { - printf ("%s\n", response); + printf("%s\n", response); } else { int first = 1; char *name, *value; - while (name = rptp_parse (first ? response : 0, 0)) + while (name = rptp_parse(first ? response : 0, 0)) { first = 0; - value = rptp_parse (0, name); - printf ("%s=%s\n", name, value); - } - } -} - -#ifdef __STDC__ -void -command_volume (int argc, char **argv) -#else -void -command_volume (argc, argv) + value = rptp_parse(0, name); + printf("%s=%s\n", name, value); + } + } +} + +#ifdef __STDC__ +void +command_volume(int argc, char **argv) +#else +void +command_volume(argc, argv) int argc; char **argv; #endif { char *volume; - if (!connected ()) + if (!connected()) { return; } if (argc == 2) { - sprintf (command, "set volume=%s", argv[1]); + sprintf(command, "set volume=%s", argv[1]); } else { - sprintf (command, "set volume"); - } - - switch (rptp_command (rptp_fd, command, response, sizeof (response))) + sprintf(command, "set volume"); + } + + switch (rptp_command(rptp_fd, command, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - command_close (argc, argv); + rptp_perror(argv[0]); + command_close(argc, argv); return; case 1: - do_error (response); + do_error(response); return; case 0: break; } - volume = rptp_parse (response, "volume"); + volume = rptp_parse(response, "volume"); if (volume && *volume) { - printf ("volume=%s\n", volume); + printf("volume=%s\n", volume); } else { - printf ("unknown response `%s'\n", response); - } -} - -#ifdef __STDC__ -void -command_skip (int argc, char **argv) -#else -void -command_skip (argc, argv) + printf("unknown response `%s'\n", response); + } +} + +#ifdef __STDC__ +void +command_skip(int argc, char **argv) +#else +void +command_skip(argc, argv) int argc; char **argv; #endif { char *value; - if (!connected ()) - { - return; - } - - if (strchr (command, '=')) + if (!connected()) + { + return; + } + + if (strchr(command, '=')) { /* Leave command alone. */ } else if (argc == 3) { - sprintf (command, "skip id=%s count=%s", argv[1], argv[2]); + sprintf(command, "skip id=%s count=%s", argv[1], argv[2]); } else if (argc == 2) { - sprintf (command, "skip id=%s count=1", argv[1]); + sprintf(command, "skip id=%s count=1", argv[1]); } else { - sprintf (command, "skip id=#0 count=1"); - } - - switch (rptp_command (rptp_fd, command, response, sizeof (response))) + sprintf(command, "skip id=#0 count=1"); + } + + switch (rptp_command(rptp_fd, command, response, sizeof(response))) { case -1: - rptp_perror (argv[0]); - command_close (argc, argv); + rptp_perror(argv[0]); + command_close(argc, argv); return; case 1: - do_error (response); + do_error(response); return; case 0: break; } - value = rptp_parse (response, "message"); + value = rptp_parse(response, "message"); if (value && *value) { - printf ("%s\n", value); + printf("%s\n", value); } else { - printf ("unknown response `%s'\n", response); - } -} - -void -do_application () -{ - sprintf (command, "set application=\"rptp %s\"", RPLAY_VERSION); - - switch (rptp_command (rptp_fd, command, response, sizeof (response))) + printf("unknown response `%s'\n", response); + } +} + +#ifdef __STDC__ +void +command_set(int argc, char **argv) +#else +void +command_set(argc, argv) + int argc; + char **argv; +#endif +{ + char *value; + + if (!connected()) + { + return; + } + + argv_to_command(argv); + + switch (rptp_command(rptp_fd, command, response, sizeof(response))) { case -1: - rptp_perror ("application"); - rptp_close (rptp_fd); - rptp_fd = -1; + rptp_perror(argv[0]); + command_close(argc, argv); return; case 1: - do_error (response); + do_error(response); return; case 0: @@ -952,64 +1005,149 @@ #ifdef __STDC__ void -do_error (char *response) -#else -void -do_error (response) +command_monitor(int argc, char **argv) +#else +void +command_monitor(argc, argv) + int argc; + char **argv; +#endif +{ + char *value, *p; + char buf[8192]; + char line[80]; + int n, size; + int sample_rate, precision, channels, sample_size; + + if (!connected()) + { + return; + } + + sprintf(command, "monitor"); + + switch (rptp_command(rptp_fd, command, response, sizeof(response))) + { + case -1: + rptp_perror(argv[0]); + command_close(argc, argv); + return; + + case 1: + do_error(response); + return; + + case 0: + break; + } + + p = strtok(rptp_parse(response, "audio-info"), ","); + // input_format + + p = strtok(NULL, ","); + if (p) sample_rate = atoi(p); + + p = strtok(NULL, ","); + if (p) precision = atoi(p); + + p = strtok(NULL, ","); + if (p) channels = atoi(p); + + sample_size = precision/8 * channels; + + fprintf(stderr, "%dhz %dbit %s\n", sample_rate, precision, + channels == 2 ? "stereo" : "mono"); + + while ((n = read(rptp_fd, buf, sizeof(buf))) > 0) + { + write(1, buf, n); + size += n; + } + close(rptp_fd); +} + +void +do_application() +{ + sprintf(command, "set application=\"rptp %s\"", RPLAY_VERSION); + + switch (rptp_command(rptp_fd, command, response, sizeof(response))) + { + case -1: + rptp_perror("application"); + rptp_close(rptp_fd); + rptp_fd = -1; + return; + + case 1: + do_error(response); + return; + + case 0: + break; + } +} + +#ifdef __STDC__ +void +do_error(char *response) +#else +void +do_error(response) char *response; #endif { if (raw) { - printf ("%s\n", response); + printf("%s\n", response); } else { char *error; - error = rptp_parse (response, "error"); + error = rptp_parse(response, "error"); if (!error || !*error) { error = response; } - printf ("%s\n", error); - } -} - -void -usage () -{ - printf ("\nrplay %s\n\n", RPLAY_VERSION); - printf ("usage: rptp [options] [command]\n"); - printf ("--help\n"); - printf ("\tDisplay helpful information.\n"); - printf ("\n"); - - printf ("-h HOST, --host=HOST\n"); - printf ("\tSpecify the RPTP host, default = %s.\n", - rplay_default_host ()); - printf ("\n"); - - printf ("-p PORT, --port=PORT\n"); - printf ("\tUse PORT instead of the default RPTP port, default = %d.\n", RPTP_PORT); - printf ("\n"); - - printf ("-r, --raw\n"); - printf ("\tEnable raw RPTP mode.\n"); - printf ("\n"); - - printf ("-v, --version\n"); - printf ("\tDisplay rplay version information.\n"); -} - -#ifdef __STDC__ -void -done (int exit_value) -#else -void -done (exit_value) + printf("%s\n", error); + } +} + +void +usage() +{ + printf("\nrplay %s\n\n", RPLAY_VERSION); + printf("usage: rptp [options] [command]\n"); + printf("--help\n"); + printf("\tDisplay helpful information.\n"); + printf("\n"); + + printf("-h HOST, --host=HOST\n"); + printf("\tSpecify the RPTP host, default = %s.\n", + rplay_default_host()); + printf("\n"); + + printf("-p PORT, --port=PORT\n"); + printf("\tUse PORT instead of the default RPTP port, default = %d.\n", RPTP_PORT); + printf("\n"); + + printf("-r, --raw\n"); + printf("\tEnable raw RPTP mode.\n"); + printf("\n"); + + printf("-v, --version\n"); + printf("\tDisplay rplay version information.\n"); +} + +#ifdef __STDC__ +void +done(int exit_value) +#else +void +done(exit_value) int exit_value; #endif { - exit (exit_value); -} + exit(exit_value); +} diff --git a/rx/CVS/Entries b/rx/CVS/Entries deleted file mode 100644 index d9882a9..0000000 --- a/rx/CVS/Entries +++ /dev/null @@ -1,44 +0,0 @@ -/COPYING.LIB/1.1.1.1/Tue Jul 14 22:35:25 1998// -/ChangeLog/1.1.1.1/Tue Jul 14 22:35:25 1998// -/Makefile.in/1.1.1.1/Tue Jul 14 22:35:25 1998// -/configure/1.1.1.1/Tue Jul 14 22:35:25 1998// -/configure.in/1.1.1.1/Tue Jul 14 22:35:25 1998// -D/PLUGIN//// -/_rx.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/hashrexp.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/inst-rxposix.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rgx.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rx.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rx.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxall.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxanal.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxanal.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxbasic.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxbasic.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxbitset.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxbitset.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxcontext.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxcset.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxcset.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxdbug.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxgnucomp.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxgnucomp.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxhash.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxhash.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxnfa.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxnfa.h/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxnode.c/1.1.1.1/Thu Aug 13 06:09:34 1998// -/rxnode.h/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxposix.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxposix.h/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxproto.h/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxsimp.c/1.1.1.1/Thu Aug 13 06:10:47 1998// -/rxsimp.h/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxspencer.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxspencer.h/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxstr.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxstr.h/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxsuper.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxsuper.h/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxunfa.c/1.1.1.1/Thu Aug 13 06:09:35 1998// -/rxunfa.h/1.1.1.1/Thu Aug 13 06:09:35 1998// diff --git a/rx/CVS/Repository b/rx/CVS/Repository deleted file mode 100644 index 0a73638..0000000 --- a/rx/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/rx diff --git a/rx/CVS/Root b/rx/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/rx/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot diff --git a/rx/PLUGIN/CVS/Entries b/rx/PLUGIN/CVS/Entries deleted file mode 100644 index 9275b0b..0000000 --- a/rx/PLUGIN/CVS/Entries +++ /dev/null @@ -1,7 +0,0 @@ -/OPT/1.1.1.1/Tue Jul 14 22:35:25 1998// -/REQ/1.1.1.1/Tue Jul 14 22:35:25 1998// -/greet/1.1.1.1/Tue Jul 14 22:35:25 1998// -/systas.config/1.1.1.1/Tue Jul 14 22:35:25 1998// -/systas.inits/1.1.1.1/Tue Jul 14 22:35:25 1998// -/systas.libs/1.1.1.1/Tue Jul 14 22:35:25 1998// -D diff --git a/rx/PLUGIN/CVS/Repository b/rx/PLUGIN/CVS/Repository deleted file mode 100644 index c20fcf8..0000000 --- a/rx/PLUGIN/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot/rplay/rx/PLUGIN diff --git a/rx/PLUGIN/CVS/Root b/rx/PLUGIN/CVS/Root deleted file mode 100644 index c07ba68..0000000 --- a/rx/PLUGIN/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -/usr/local/cvsroot