diff -Naur esound-0.2.28-old/esd-config.h esound-0.2.28/esd-config.h
--- esound-0.2.28-old/esd-config.h	Wed Dec 31 19:00:00 1969
+++ esound-0.2.28/esd-config.h	Wed Dec 11 23:19:07 2002
@@ -0,0 +1,20 @@
+#ifndef ESD_CONFIG_H
+#define ESD_CONFIG_H
+
+#include <string.h>
+
+/* these are some defines to use in when reading
+ * esd.conf */
+
+#define LINEBUF_SIZE 1024
+
+/* use strtok_r if available */
+#ifdef HAVE_STRTOK_R
+#define DO_STRTOK(S,DELIM) strtok_r(S,DELIM,strtok_state)
+char *strtok_state[LINEBUF_SIZE];
+#else
+#define DO_STRTOK(S,DELIM) strtok(S,DELIM)
+#endif
+
+#endif
+
diff -Naur esound-0.2.28-old/esd.c esound-0.2.28/esd.c
--- esound-0.2.28-old/esd.c	Wed Dec 11 23:10:12 2002
+++ esound-0.2.28/esd.c	Fri Dec 13 08:56:50 2002
@@ -1,4 +1,5 @@
 #include "esd-server.h"
+#include "esd-config.h"
 
 #include <arpa/inet.h>
 #include <sys/types.h>
@@ -8,6 +9,8 @@
 #include <signal.h>
 #include <time.h>
 
+#include <string.h>
+
 #ifndef HAVE_NANOSLEEP
 #include <sys/time.h>
 #include <sys/types.h>
@@ -504,6 +507,14 @@
 
     char *hostname=NULL;
 
+    /* from esd_config.c */
+    extern char esd_spawn_options[];
+
+    char tmp_str[LINEBUF_SIZE];
+    int num_opts = 0;
+    char **opts;
+    char *tok;
+
     /* begin test scaffolding parameters */
     /* int format = AFMT_U8; AFMT_S16_LE; */
     /* int stereo = 0; */     /* 0=mono, 1=stereo */
@@ -518,100 +529,124 @@
 
     programname = *argv;
 
+    /* read in esd.conf, ~/.esd.conf or ESD_SPAWN_OPTIONS */
+    esd_config_read();
+
+    /* copy esd_spawn_options to tmp_str in case no strtok_r */
+    strncpy(tmp_str, esd_spawn_options, LINEBUF_SIZE);
+	
+    num_opts = 0;
+    tok = DO_STRTOK(tmp_str, " ");
+    while (tok) {
+	opts[num_opts] = tok;
+	num_opts++;
+	tok = DO_STRTOK(NULL, " ");
+    }
+
+    /* now add argv to the end of opts, so command line args take
+     * precedence over config options */
+    for (i = num_opts; i < num_opts + argc - 1; i++)
+        opts[i] = argv[i - num_opts + 1];
+    num_opts = num_opts + argc - 1;
+
+    /* debug */    
+    for (i = 0; i < num_opts; i++)
+    	fprintf(stderr, "esd.c:  [%d] is %s\n", i, opts[i]);
+
     /* parse the command line args */
-    for ( arg = 1 ; arg < argc ; arg++ ) {
-	if ( !strcmp( argv[ arg ], "-d" ) ) {
-	    if ( ++arg != argc ) {
-		esd_audio_device = argv[ arg ];
+    for ( arg = 1 ; arg < num_opts ; arg++ ) {
+	if ( !strcmp( opts[ arg ], "-d" ) ) {
+	    if ( ++arg != num_opts ) {
+		esd_audio_device = opts[ arg ];
 		if ( !esd_audio_device ) {
 		    esd_port = ESD_DEFAULT_PORT;
 		    fprintf( stderr, "- could not read device: %s\n",
-			     argv[ arg ] );
+			     opts[ arg ] );
 		}
 		fprintf( stderr, "- using device %s\n",
 			 esd_audio_device );
 	    }
-	} else if ( !strcmp( argv[ arg ], "-port" ) ) {
-	    if ( ++arg != argc ) {
-		esd_port = atoi( argv[ arg ] );
+	} else if ( !strcmp( opts[ arg ], "-port" ) ) {
+	    if ( ++arg != num_opts ) {
+		esd_port = atoi( opts[ arg ] );
 		if ( !esd_port ) {
 		    esd_port = ESD_DEFAULT_PORT;
 		    fprintf( stderr, "- could not read port: %s\n",
-			     argv[ arg ] );
+			     opts[ arg ] );
 		}
 		fprintf( stderr, "- accepting connections on port %d\n",
 			 esd_port );
 	    }
 
-	} else if ( !strcmp( argv[ arg ], "-bind" ) ) {
-	    if ( ++arg != argc )
+	} else if ( !strcmp( opts[ arg ], "-bind" ) ) {
+	    if ( ++arg != num_opts )
 		{
-			hostname = argv[ arg ];
+			hostname = opts[ arg ];
 		}
 		fprintf( stderr, "- accepting connections on port %d\n",
 			 esd_port );
-	} else if ( !strcmp( argv[ arg ], "-b" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-b" ) ) {
 	    fprintf( stderr, "- server format: 8 bit samples\n" );
 	    default_format &= ~ESD_MASK_BITS; default_format |= ESD_BITS8;
-	} else if ( !strcmp( argv[ arg ], "-r" ) ) {
-	    if ( ++arg != argc ) {
-		default_rate = atoi( argv[ arg ] );
+	} else if ( !strcmp( opts[ arg ], "-r" ) ) {
+	    if ( ++arg != num_opts ) {
+		default_rate = atoi( opts[ arg ] );
 		if ( !default_rate ) {
 		    default_rate = ESD_DEFAULT_RATE;
 		    fprintf( stderr, "- could not read rate: %s\n",
-			     argv[ arg ] );
+			     opts[ arg ] );
 		}
 		fprintf( stderr, "- server format: sample rate = %d Hz\n",
 			 default_rate );
 	    }
-	} else if ( !strcmp( argv[ arg ], "-as" ) ) {
-	    if ( ++arg != argc ) {
-		esd_autostandby_secs = atoi( argv[ arg ] );
+	} else if ( !strcmp( opts[ arg ], "-as" ) ) {
+	    if ( ++arg != num_opts ) {
+		esd_autostandby_secs = atoi( opts[ arg ] );
 		if ( !esd_autostandby_secs ) {
 		    esd_autostandby_secs = ESD_DEFAULT_AUTOSTANDBY_SECS;
 		    fprintf( stderr, "- could not read autostandby timeout: %s\n",
-			     argv[ arg ] );
+			     opts[ arg ] );
 		}
 /*		fprintf( stderr, "- autostandby timeout: %d seconds\n",
 			 esd_autostandby_secs );*/
 	    }
 #ifdef ESDBG
-	} else if ( !strcmp( argv[ arg ], "-vt" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-vt" ) ) {
 	    esdbg_trace = 1;
 	    fprintf( stderr, "- enabling trace diagnostic info\n" );
-	} else if ( !strcmp( argv[ arg ], "-vc" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-vc" ) ) {
 	    esdbg_comms = 1;
 	    fprintf( stderr, "- enabling comms diagnostic info\n" );
-	} else if ( !strcmp( argv[ arg ], "-vm" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-vm" ) ) {
 	    esdbg_mixer = 1;
 	    fprintf( stderr, "- enabling mixer diagnostic info\n" );
 #endif
-	} else if ( !strcmp( argv[ arg ], "-nobeeps" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-nobeeps" ) ) {
 	    esd_beeps = 0;
 /*	    fprintf( stderr, "- disabling startup beeps\n" );*/
-	} else if ( !strcmp( argv[ arg ], "-unix" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-unix" ) ) {
 	    esd_use_tcpip = 0;
-	} else if ( !strcmp( argv[ arg ], "-tcp" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-tcp" ) ) {
 	    esd_use_tcpip = 1;
-	} else if ( !strcmp( argv[ arg ], "-public" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-public" ) ) {
 	    esd_public = 1;
-	} else if ( !strcmp( argv[ arg ], "-promiscuous" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-promiscuous" ) ) {
 	    esd_is_owned = 1;
 	    esd_is_locked = 0;
-	} else if ( !strcmp( argv[ arg ], "-terminate" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-terminate" ) ) {
 	    esd_terminate = 1;
-	} else if ( !strcmp( argv[ arg ], "-spawnpid" ) ) {
-	    if ( ++arg < argc )
-		esd_spawnpid = atoi( argv[ arg ] );
-	} else if ( !strcmp( argv[ arg ], "-spawnfd" ) ) {
-	    if ( ++arg < argc )
-		esd_spawnfd = atoi( argv[ arg ] );
-	} else if ( !strcmp( argv[ arg ], "-trust" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-spawnpid" ) ) {
+	    if ( ++arg < num_opts )
+		esd_spawnpid = atoi( opts[ arg ] );
+	} else if ( !strcmp( opts[ arg ], "-spawnfd" ) ) {
+	    if ( ++arg < num_opts )
+		esd_spawnfd = atoi( opts[ arg ] );
+	} else if ( !strcmp( opts[ arg ], "-trust" ) ) {
 	    esd_trustval = 0;
-	} else if ( !strcmp( argv[ arg ], "-v" ) || !strcmp( argv[ arg ], "--version" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-v" ) || !strcmp( opts[ arg ], "--version" ) ) {
 		fprintf(stderr, "Esound version " VERSION "\n");
 		exit (0);
-	} else if ( !strcmp( argv[ arg ], "-h" ) || !strcmp( argv[ arg ], "--help" ) ) {
+	} else if ( !strcmp( opts[ arg ], "-h" ) || !strcmp( opts[ arg ], "--help" ) ) {
 	    fprintf( stderr, "Usage: esd [options]\n\n" );
 	    fprintf( stderr, "  -d DEVICE     force esd to use sound device DEVICE\n" );
 	    fprintf( stderr, "  -b            run server in 8 bit sound mode\n" );
@@ -635,7 +670,7 @@
 	    fprintf( stderr, "\nPossible devices are:  %s\n", esd_audio_devices() );
 	    exit( 0 );
 	} else {
-	    fprintf( stderr, "unrecognized option: %s\n", argv[ arg ] );
+	    fprintf( stderr, "unrecognized option: %s\n", opts[ arg ] );
 	}
     }
 
diff -Naur esound-0.2.28-old/esd_config.c esound-0.2.28/esd_config.c
--- esound-0.2.28-old/esd_config.c	Wed Jun 19 08:14:24 2002
+++ esound-0.2.28/esd_config.c	Wed Dec 11 23:19:07 2002
@@ -1,17 +1,10 @@
+#include "esd-config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <ctype.h>
 #include <string.h>
-
-#define LINEBUF_SIZE 1024
-
-#ifdef HAVE_STRTOK_R
-#define DO_STRTOK(S,DELIM) strtok_r(S,DELIM,&strtok_state)
-char strtok_state[LINEBUF_SIZE];
-#else
-#define DO_STRTOK(S,DELIM) strtok(S,DELIM)
-#endif
 
 int esd_no_spawn=1; /* If we can't find even the system config file,
 		       things are screwed up - don't try to make things
