[xiph-cvs] cvs commit: ices/src cfgparse.c cfgparse.h audio.c encode.c ices.c im_alsa.c im_oss.c im_playlist.c im_stdinpcm.c im_sun.c input.c input.h metadata.c output.c playlist_basic.c playlist_script.c reencode.c reencode.h signals.c stream.c stream.h stream_shared.c stream_shared.h config.c config.h
Karl Heyes
karl at xiph.org
Fri Mar 21 17:14:36 PST 2003
karl 03/03/21 20:14:36
Modified: src audio.c encode.c ices.c im_alsa.c im_oss.c
im_playlist.c im_stdinpcm.c im_sun.c input.c
input.h metadata.c output.c playlist_basic.c
playlist_script.c reencode.c reencode.h signals.c
stream.c stream.h stream_shared.c stream_shared.h
Added: src cfgparse.c cfgparse.h
Removed: src config.c config.h
Log:
renames the ices config parser to something other than config.h/c as
config.h is the typical name used for autoconf results
Revision Changes Path
1.8 +2 -2 ices/src/audio.c
Index: audio.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/audio.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- audio.c 20 Mar 2003 01:02:48 -0000 1.7
+++ audio.c 22 Mar 2003 01:14:35 -0000 1.8
@@ -2,7 +2,7 @@
* stereo->mono downmixing
* resampling
*
- * $Id: audio.c,v 1.7 2003/03/20 01:02:48 karl Exp $
+ * $Id: audio.c,v 1.8 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -16,7 +16,7 @@
#include <stdlib.h>
#include <string.h>
-#include "config.h"
+#include "cfgparse.h"
#include "audio.h"
#include "resample.h"
<p><p>1.15 +2 -2 ices/src/encode.c
Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/encode.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- encode.c 16 Mar 2003 14:21:48 -0000 1.14
+++ encode.c 22 Mar 2003 01:14:35 -0000 1.15
@@ -1,7 +1,7 @@
/* encode.c
* - runtime encoding of PCM data.
*
- * $Id: encode.c,v 1.14 2003/03/16 14:21:48 msmith Exp $
+ * $Id: encode.c,v 1.15 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -19,7 +19,7 @@
#include <vorbis/codec.h>
#include <vorbis/vorbisenc.h>
-#include "config.h"
+#include "cfgparse.h"
#include "encode.h"
#define MODULE "encode/"
<p><p>1.7 +2 -2 ices/src/ices.c
Index: ices.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/ices.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ices.c 16 Mar 2003 14:21:48 -0000 1.6
+++ ices.c 22 Mar 2003 01:14:35 -0000 1.7
@@ -1,7 +1,7 @@
/* ices.c
* - Main startup, thread launching, and cleanup code.
*
- * $Id: ices.c,v 1.6 2003/03/16 14:21:48 msmith Exp $
+ * $Id: ices.c,v 1.7 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001-2002 Michael Smith <msmith at labyrinth.net.au>
*
@@ -19,7 +19,7 @@
#include "resolver.h"
#include "thread.h"
-#include "config.h"
+#include "cfgparse.h"
#include "stream.h"
#include "signals.h"
#include "input.h"
<p><p>1.3 +2 -2 ices/src/im_alsa.c
Index: im_alsa.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_alsa.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- im_alsa.c 16 Mar 2003 14:21:48 -0000 1.2
+++ im_alsa.c 22 Mar 2003 01:14:35 -0000 1.3
@@ -1,7 +1,7 @@
/* im_alsa.c
* - Raw PCM input from ALSA devices
*
- * $Id: im_alsa.c,v 1.2 2003/03/16 14:21:48 msmith Exp $
+ * $Id: im_alsa.c,v 1.3 2003/03/22 01:14:35 karl Exp $
*
* by Jason Chu <jchu at uvic.ca>, based
* on im_oss.c which is...
@@ -26,7 +26,7 @@
#include "thread.h"
-#include "config.h"
+#include "cfgparse.h"
#include "stream.h"
#include "metadata.h"
#include "inputmodule.h"
<p><p>1.11 +2 -2 ices/src/im_oss.c
Index: im_oss.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_oss.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- im_oss.c 16 Mar 2003 14:21:48 -0000 1.10
+++ im_oss.c 22 Mar 2003 01:14:35 -0000 1.11
@@ -1,7 +1,7 @@
/* im_oss.c
* - Raw PCM input from OSS devices
*
- * $Id: im_oss.c,v 1.10 2003/03/16 14:21:48 msmith Exp $
+ * $Id: im_oss.c,v 1.11 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -24,7 +24,7 @@
#include "thread.h"
-#include "config.h"
+#include "cfgparse.h"
#include "stream.h"
#include "metadata.h"
#include "inputmodule.h"
<p><p>1.9 +2 -2 ices/src/im_playlist.c
Index: im_playlist.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_playlist.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- im_playlist.c 16 Mar 2003 14:21:48 -0000 1.8
+++ im_playlist.c 22 Mar 2003 01:14:35 -0000 1.9
@@ -1,7 +1,7 @@
/* playlist.c
* - Basic playlist functionality
*
- * $Id: im_playlist.c,v 1.8 2003/03/16 14:21:48 msmith Exp $
+ * $Id: im_playlist.c,v 1.9 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -19,7 +19,7 @@
#include "thread.h"
-#include "config.h"
+#include "cfgparse.h"
#include "stream.h"
#include "event.h"
<p><p>1.6 +2 -2 ices/src/im_stdinpcm.c
Index: im_stdinpcm.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_stdinpcm.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- im_stdinpcm.c 16 Mar 2003 14:21:48 -0000 1.5
+++ im_stdinpcm.c 22 Mar 2003 01:14:35 -0000 1.6
@@ -1,7 +1,7 @@
/* im_stdinpcm.c
* - Raw PCM input from stdin
*
- * $Id: im_stdinpcm.c,v 1.5 2003/03/16 14:21:48 msmith Exp $
+ * $Id: im_stdinpcm.c,v 1.6 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -19,7 +19,7 @@
#include "thread.h"
-#include "config.h"
+#include "cfgparse.h"
#include "stream.h"
#include "inputmodule.h"
<p><p>1.9 +2 -2 ices/src/im_sun.c
Index: im_sun.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_sun.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- im_sun.c 16 Mar 2003 14:21:48 -0000 1.8
+++ im_sun.c 22 Mar 2003 01:14:35 -0000 1.9
@@ -1,7 +1,7 @@
/* im_sun.c
* - Raw PCM input from Solaris audio devices
*
- * $Id: im_sun.c,v 1.8 2003/03/16 14:21:48 msmith Exp $
+ * $Id: im_sun.c,v 1.9 2003/03/22 01:14:35 karl Exp $
*
* by Ciaran Anscomb <ciarana at rd.bbc.co.uk>, based
* on im_oss.c which is...
@@ -27,7 +27,7 @@
#include "thread.h"
-#include "config.h"
+#include "cfgparse.h"
#include "stream.h"
#include "inputmodule.h"
#include "metadata.h"
<p><p>1.26 +2 -2 ices/src/input.c
Index: input.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/input.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- input.c 16 Mar 2003 14:21:48 -0000 1.25
+++ input.c 22 Mar 2003 01:14:35 -0000 1.26
@@ -2,7 +2,7 @@
* - Main producer control loop. Fetches data from input modules, and controls
* submission of these to the instance threads. Timing control happens here.
*
- * $Id: input.c,v 1.25 2003/03/16 14:21:48 msmith Exp $
+ * $Id: input.c,v 1.26 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -22,8 +22,8 @@
#include <vorbis/codec.h>
#include <string.h>
+#include "cfgparse.h"
#include "thread/thread.h"
-#include "config.h"
#include "stream.h"
#include "timing.h"
#include "input.h"
<p><p>1.9 +2 -2 ices/src/input.h
Index: input.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/input.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- input.h 16 Mar 2003 14:21:48 -0000 1.8
+++ input.h 22 Mar 2003 01:14:35 -0000 1.9
@@ -1,7 +1,7 @@
/* input.h
* - Input functions
*
- * $Id: input.h,v 1.8 2003/03/16 14:21:48 msmith Exp $
+ * $Id: input.h,v 1.9 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -17,7 +17,7 @@
#include <shout/shout.h>
#include <vorbis/codec.h>
-#include "config.h"
+#include "cfgparse.h"
#include "inputmodule.h"
#include "stream.h"
#include "reencode.h"
<p><p>1.10 +2 -2 ices/src/metadata.c
Index: metadata.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/metadata.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- metadata.c 16 Mar 2003 14:21:48 -0000 1.9
+++ metadata.c 22 Mar 2003 01:14:35 -0000 1.10
@@ -1,7 +1,7 @@
/* metadata.c
* - Metadata manipulation
*
- * $Id: metadata.c,v 1.9 2003/03/16 14:21:48 msmith Exp $
+ * $Id: metadata.c,v 1.10 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -17,7 +17,7 @@
#include <errno.h>
#include <unistd.h>
-#include "config.h"
+#include "cfgparse.h"
#include "inputmodule.h"
#include "event.h"
#include "thread/thread.h"
<p><p>1.4 +2 -2 ices/src/output.c
Index: output.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/output.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- output.c 16 Mar 2003 14:21:48 -0000 1.3
+++ output.c 22 Mar 2003 01:14:35 -0000 1.4
@@ -1,7 +1,7 @@
/* output.c
* - Manage output instances
*
- * $Id: output.c,v 1.3 2003/03/16 14:21:48 msmith Exp $
+ * $Id: output.c,v 1.4 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001-2002 Michael Smith <msmith at labyrinth.net.au>
*
@@ -17,7 +17,7 @@
#include <signal.h>
#include <thread/thread.h>
-#include "config.h"
+#include "cfgparse.h"
#include "input.h"
#include "stream.h"
#include "process.h"
<p><p>1.9 +2 -2 ices/src/playlist_basic.c
Index: playlist_basic.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/playlist_basic.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- playlist_basic.c 16 Mar 2003 14:21:48 -0000 1.8
+++ playlist_basic.c 22 Mar 2003 01:14:35 -0000 1.9
@@ -1,7 +1,7 @@
/* playlist_basic.c
* - Simple built-in unscripted playlist
*
- * $Id: playlist_basic.c,v 1.8 2003/03/16 14:21:48 msmith Exp $
+ * $Id: playlist_basic.c,v 1.9 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -19,7 +19,7 @@
#include <sys/stat.h>
#include <unistd.h>
-#include "config.h"
+#include "cfgparse.h"
#include "inputmodule.h"
#include "im_playlist.h"
#include "playlist_basic.h"
<p><p>1.5 +2 -2 ices/src/playlist_script.c
Index: playlist_script.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/playlist_script.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- playlist_script.c 9 Aug 2002 13:59:02 -0000 1.4
+++ playlist_script.c 22 Mar 2003 01:14:35 -0000 1.5
@@ -2,7 +2,7 @@
* - Gets a filename to play back based on output from a program/shell script
* run each time.
*
- * $Id: playlist_script.c,v 1.4 2002/08/09 13:59:02 msmith Exp $
+ * $Id: playlist_script.c,v 1.5 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -17,7 +17,7 @@
#include <errno.h>
#include <string.h>
-#include "config.h"
+#include "cfgparse.h"
#include "inputmodule.h"
#include "im_playlist.h"
<p><p>1.8 +2 -2 ices/src/reencode.c
Index: reencode.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/reencode.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- reencode.c 16 Mar 2003 14:21:49 -0000 1.7
+++ reencode.c 22 Mar 2003 01:14:35 -0000 1.8
@@ -1,7 +1,7 @@
/* reencode.c
* - runtime reencoding of vorbis audio (usually to lower bitrates).
*
- * $Id: reencode.c,v 1.7 2003/03/16 14:21:49 msmith Exp $
+ * $Id: reencode.c,v 1.8 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -19,7 +19,7 @@
#include <vorbis/codec.h>
#include "reencode.h"
-#include "config.h"
+#include "cfgparse.h"
#include "stream.h"
#include "encode.h"
#include "audio.h"
<p><p>1.6 +2 -2 ices/src/reencode.h
Index: reencode.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/reencode.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- reencode.h 16 Mar 2003 14:21:49 -0000 1.5
+++ reencode.h 22 Mar 2003 01:14:35 -0000 1.6
@@ -1,7 +1,7 @@
/* reencode.h
* - reencoding functions
*
- * $Id: reencode.h,v 1.5 2003/03/16 14:21:49 msmith Exp $
+ * $Id: reencode.h,v 1.6 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -17,7 +17,7 @@
#include <ogg/ogg.h>
#include <vorbis/codec.h>
-#include "config.h"
+#include "cfgparse.h"
#include "stream.h"
#include "encode.h"
#include "audio.h"
<p><p>1.6 +2 -2 ices/src/signals.c
Index: signals.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/signals.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- signals.c 16 Mar 2003 14:21:49 -0000 1.5
+++ signals.c 22 Mar 2003 01:14:35 -0000 1.6
@@ -1,7 +1,7 @@
/* signals.c
* - signal handling/setup
*
- * $Id: signals.c,v 1.5 2003/03/16 14:21:49 msmith Exp $
+ * $Id: signals.c,v 1.6 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -17,7 +17,7 @@
#include "thread.h"
-#include "config.h"
+#include "cfgparse.h"
#include "stream.h"
#include "input.h"
#include "inputmodule.h"
<p><p>1.26 +2 -2 ices/src/stream.c
Index: stream.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- stream.c 16 Mar 2003 14:21:49 -0000 1.25
+++ stream.c 22 Mar 2003 01:14:35 -0000 1.26
@@ -1,7 +1,7 @@
/* stream.c
* - Core streaming functions/main loop.
*
- * $Id: stream.c,v 1.25 2003/03/16 14:21:49 msmith Exp $
+ * $Id: stream.c,v 1.26 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -20,7 +20,7 @@
#include <shout/shout.h>
-#include "config.h"
+#include "cfgparse.h"
#include "input.h"
#include "im_playlist.h"
#include "signals.h"
<p><p>1.4 +2 -2 ices/src/stream.h
Index: stream.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- stream.h 16 Mar 2003 14:21:49 -0000 1.3
+++ stream.h 22 Mar 2003 01:14:35 -0000 1.4
@@ -1,7 +1,7 @@
/* stream.h
* - Core streaming functions/main loop.
*
- * $Id: stream.h,v 1.3 2003/03/16 14:21:49 msmith Exp $
+ * $Id: stream.h,v 1.4 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -18,7 +18,7 @@
#include <shout/shout.h>
#include "thread/thread.h"
-#include "config.h"
+#include "cfgparse.h"
typedef struct {
unsigned char *buf;
<p><p>1.14 +2 -2 ices/src/stream_shared.c
Index: stream_shared.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream_shared.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- stream_shared.c 16 Mar 2003 14:21:49 -0000 1.13
+++ stream_shared.c 22 Mar 2003 01:14:35 -0000 1.14
@@ -1,7 +1,7 @@
/* stream_shared.c
* - Stream utility functions.
*
- * $Id: stream_shared.c,v 1.13 2003/03/16 14:21:49 msmith Exp $
+ * $Id: stream_shared.c,v 1.14 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -16,7 +16,7 @@
#include <unistd.h>
#include <thread/thread.h>
-#include "config.h"
+#include "cfgparse.h"
#include "input.h"
#include "inputmodule.h"
#include "stream_shared.h"
<p><p>1.4 +2 -2 ices/src/stream_shared.h
Index: stream_shared.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream_shared.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- stream_shared.h 25 Sep 2001 12:04:22 -0000 1.3
+++ stream_shared.h 22 Mar 2003 01:14:35 -0000 1.4
@@ -1,7 +1,7 @@
/* stream.h
* - Core streaming functions/main loop.
*
- * $Id: stream_shared.h,v 1.3 2001/09/25 12:04:22 msmith Exp $
+ * $Id: stream_shared.h,v 1.4 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -15,7 +15,7 @@
#define __STREAM_SHARED_H
#include "stream.h"
-#include "config.h"
+#include "cfgparse.h"
#include "input.h"
ref_buffer *stream_wait_for_data(instance_t *stream);
<p><p>1.1 ices/src/cfgparse.c
Index: cfgparse.c
===================================================================
/* cfgparse.c
* - cfgparse file reading code, plus default settings.
*
* $Id: cfgparse.c,v 1.1 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
* This program is distributed under the terms of the GNU General
* Public License, version 2. You may use, modify, and redistribute
* it under the terms of this license. A copy should be included
* with this source.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
/* these might need tweaking for other systems */
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
#include "thread.h"
#include "cfgparse.h"
#include "stream.h"
#include "thread/thread.h"
#define DEFAULT_BACKGROUND 0
#define DEFAULT_LOGPATH "/tmp"
#define DEFAULT_LOGFILE "ices.log"
#define DEFAULT_LOGLEVEL 1
#define DEFAULT_LOG_STDERR 1
#define DEFAULT_STREAM_NAME "unnamed ices stream"
#define DEFAULT_STREAM_GENRE "ices unset"
#define DEFAULT_STREAM_DESCRIPTION "no description set"
#define DEFAULT_PLAYLIST_MODULE "playlist"
#define DEFAULT_HOSTNAME "localhost"
#define DEFAULT_PORT 8000
#define DEFAULT_PASSWORD "password"
#define DEFAULT_USERNAME NULL
#define DEFAULT_MOUNT "/stream.ogg"
#define DEFAULT_MANAGED 0
#define DEFAULT_MIN_BITRATE -1
#define DEFAULT_NOM_BITRATE -1
#define DEFAULT_MAX_BITRATE -1
#define DEFAULT_QUALITY 3
#define DEFAULT_REENCODE 0
#define DEFAULT_DOWNMIX 0
#define DEFAULT_RESAMPLE 0
#define DEFAULT_RECONN_DELAY 2
#define DEFAULT_RECONN_ATTEMPTS 10
#define DEFAULT_MAXQUEUELENGTH 100 /* Make it _BIG_ by default */
#define DEFAULT_SAVEFILENAME NULL /* NULL == don't save */
/* helper macros so we don't have to write the same
** stupid code over and over
*/
#define SET_STRING(x) \
do {\
if (x) free(x);\
(x) = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);\
} while (0)
#define SET_INT(x) \
do {\
char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);\
(x) = atoi(tmp);\
if (tmp) free(tmp);\
} while (0)
#define SET_FLOAT(x) \
do {\
char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);\
(x) = atof(tmp);\
if (tmp) free(tmp);\
} while (0)
#define SET_PARM_STRING(p,x) \
do {\
if (x) free(x);\
(x) = (char *)xmlGetProp(node, p);\
} while (0)
<p>/* this is the global config variable */
config_t *ices_config;
tatic int _using_default_instance = 1;
tatic void _free_instances(instance_t *instance)
{
instance_t *next;
next = NULL;
do
{
config_free_instance(instance);
next = instance->next;
free(instance);
instance = next;
} while (next != NULL);
}
void config_free_instance(instance_t *instance)
{
if (instance->hostname) free(instance->hostname);
if (instance->password) free(instance->password);
if (instance->user) free(instance->user);
if (instance->mount) free(instance->mount);
if (instance->queue)
{
thread_mutex_destroy(&instance->queue->lock);
free(instance->queue);
}
}
tatic void _set_instance_defaults(instance_t *instance)
{
instance->hostname = strdup(DEFAULT_HOSTNAME);
instance->port = DEFAULT_PORT;
instance->password = strdup(DEFAULT_PASSWORD);
instance->user = DEFAULT_USERNAME;
instance->mount = strdup(DEFAULT_MOUNT);
instance->managed = DEFAULT_MANAGED;
instance->min_br = DEFAULT_MIN_BITRATE;
instance->nom_br = DEFAULT_NOM_BITRATE;
instance->max_br = DEFAULT_MAX_BITRATE;
instance->quality = DEFAULT_QUALITY;
instance->encode = DEFAULT_REENCODE;
instance->downmix = DEFAULT_DOWNMIX;
instance->resampleinrate = DEFAULT_RESAMPLE;
instance->resampleoutrate = DEFAULT_RESAMPLE;
instance->reconnect_delay = DEFAULT_RECONN_DELAY;
instance->reconnect_attempts = DEFAULT_RECONN_ATTEMPTS;
instance->max_queue_length = DEFAULT_MAXQUEUELENGTH;
instance->savefilename = DEFAULT_SAVEFILENAME;
instance->queue = calloc(1, sizeof(buffer_queue));
thread_mutex_create(&instance->queue->lock);
instance->serial = rand();
instance->next = NULL;
}
tatic void _parse_resample(instance_t *instance,xmlDocPtr doc, xmlNodePtr node)
{
do {
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if(strcmp(node->name, "in-rate") == 0)
SET_INT(instance->resampleinrate);
else if(strcmp(node->name, "out-rate") == 0)
SET_INT(instance->resampleoutrate);
} while((node = node->next));
}
tatic void _parse_encode(instance_t *instance,xmlDocPtr doc, xmlNodePtr node)
{
instance->encode = 1;
do {
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "nominal-bitrate") == 0)
SET_INT(instance->nom_br);
else if (strcmp(node->name, "minimum-bitrate") == 0)
SET_INT(instance->min_br);
else if (strcmp(node->name, "maximum-bitrate") == 0)
SET_INT(instance->max_br);
else if (strcmp(node->name, "quality") == 0)
SET_FLOAT(instance->quality);
else if (strcmp(node->name, "samplerate") == 0)
SET_INT(instance->samplerate);
else if (strcmp(node->name, "channels") == 0)
SET_INT(instance->channels);
else if (strcmp(node->name, "managed") == 0)
SET_INT(instance->managed);
} while ((node = node->next));
}
tatic void _parse_metadata(instance_t *instance, config_t *config,
xmlDocPtr doc, xmlNodePtr node)
{
do
{
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "name") == 0) {
if(instance)
SET_STRING(instance->stream_name);
else
SET_STRING(config->stream_name);
}
else if (strcmp(node->name, "genre") == 0) {
if(instance)
SET_STRING(instance->stream_genre);
else
SET_STRING(config->stream_genre);
}
else if (strcmp(node->name, "description") == 0) {
if(instance)
SET_STRING(instance->stream_description);
else
SET_STRING(config->stream_description);
}
} while ((node = node->next));
}
tatic void _parse_instance(config_t *config, xmlDocPtr doc, xmlNodePtr node)
{
instance_t *instance, *i;
instance = (instance_t *)calloc(1, sizeof(instance_t));
_set_instance_defaults(instance);
do
{
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "hostname") == 0)
SET_STRING(instance->hostname);
else if (strcmp(node->name, "port") == 0)
SET_INT(instance->port);
else if (strcmp(node->name, "password") == 0)
SET_STRING(instance->password);
else if (strcmp(node->name, "username") == 0)
SET_STRING(instance->user);
else if (strcmp(node->name, "savefile") == 0)
SET_STRING(instance->savefilename);
else if (strcmp(node->name, "mount") == 0)
SET_STRING(instance->mount);
else if(strcmp(node->name, "reconnectdelay") == 0)
SET_INT(instance->reconnect_delay);
else if(strcmp(node->name, "reconnectattempts") == 0)
SET_INT(instance->reconnect_attempts);
else if(strcmp(node->name, "maxqueuelength") == 0)
SET_INT(instance->max_queue_length);
else if(strcmp(node->name, "downmix") == 0)
SET_INT(instance->downmix);
else if(strcmp(node->name, "resample") == 0)
_parse_resample(instance, doc, node->xmlChildrenNode);
else if (strcmp(node->name, "encode") == 0)
_parse_encode(instance, doc, node->xmlChildrenNode);
else if (strcmp(node->name, "metadata") == 0)
_parse_metadata(instance, config, doc, node->xmlChildrenNode);
} while ((node = node->next));
instance->next = NULL;
if (_using_default_instance)
{
_using_default_instance = 0;
_free_instances(config->instances);
config->instances = NULL;
}
if (config->instances == NULL)
{
config->instances = instance;
}
else
{
i = config->instances;
while (i->next != NULL) i = i->next;
i->next = instance;
}
}
tatic void _parse_input(config_t *config, xmlDocPtr doc, xmlNodePtr node)
{
module_param_t *param, *p;
do
{
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "module") == 0)
SET_STRING(config->playlist_module);
else if (strcmp(node->name, "param") == 0) {
param = (module_param_t *)calloc(1, sizeof(module_param_t));
SET_PARM_STRING("name", param->name);
SET_STRING(param->value);
param->next = NULL;
if (config->module_params == NULL)
{
config->module_params = param;
}
else
{
p = config->module_params;
while (p->next != NULL) p = p->next;
p->next = param;
}
}
} while ((node = node->next));
}
tatic void _parse_stream(config_t *config, xmlDocPtr doc, xmlNodePtr node)
{
do
{
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "metadata") == 0)
_parse_metadata(NULL, config, doc, node->xmlChildrenNode);
else if (strcmp(node->name, "input") == 0)
_parse_input(config, doc, node->xmlChildrenNode);
else if (strcmp(node->name, "instance") == 0)
_parse_instance(config, doc, node->xmlChildrenNode);
} while ((node = node->next));
}
tatic void _parse_root(config_t *config, xmlDocPtr doc, xmlNodePtr node)
{
do
{
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "background") == 0)
SET_INT(config->background);
else if (strcmp(node->name, "logpath") == 0)
SET_STRING(config->logpath);
else if (strcmp(node->name, "logfile") == 0)
SET_STRING(config->logfile);
else if (strcmp(node->name, "loglevel") == 0)
SET_INT(config->loglevel);
else if (strcmp(node->name, "consolelog") == 0)
SET_INT(config->log_stderr);
else if (strcmp(node->name, "stream") == 0)
_parse_stream(config, doc, node->xmlChildrenNode);
} while ((node = node->next));
}
tatic void _set_defaults(config_t *c)
{
instance_t *instance;
c->background = DEFAULT_BACKGROUND;
c->logpath = strdup(DEFAULT_LOGPATH);
c->logfile = strdup(DEFAULT_LOGFILE);
c->loglevel = DEFAULT_LOGLEVEL;
c->log_stderr = DEFAULT_LOG_STDERR;
c->stream_name = strdup(DEFAULT_STREAM_NAME);
c->stream_genre = strdup(DEFAULT_STREAM_GENRE);
c->stream_description = strdup(DEFAULT_STREAM_DESCRIPTION);
c->playlist_module = strdup(DEFAULT_PLAYLIST_MODULE);
c->module_params = NULL;
instance = (instance_t *)malloc(sizeof(instance_t));
_set_instance_defaults(instance);
c->instances = instance;
}
tatic void _free_params(module_param_t *param)
{
module_param_t *next;
next = NULL;
do
{
if (param->name) free(param->name);
if (param->value) free(param->value);
next = param->next;
free(param);
param = next;
} while (next != NULL);
}
void config_initialize(void)
{
ices_config = (config_t *)calloc(1, sizeof(config_t));
_set_defaults(ices_config);
srand(time(NULL));
xmlInitParser();
}
void config_shutdown(void)
{
if (ices_config == NULL) return;
if (ices_config->module_params != NULL)
{
_free_params(ices_config->module_params);
ices_config->module_params = NULL;
}
if (ices_config->instances != NULL)
{
_free_instances(ices_config->instances);
ices_config->instances = NULL;
}
free(ices_config);
ices_config = NULL;
xmlCleanupParser();
}
int config_read(const char *fn)
{
xmlDocPtr doc;
xmlNodePtr node;
if (fn == NULL || strcmp(fn, "") == 0) return -1;
doc = xmlParseFile(fn);
if (doc == NULL) return -1;
node = xmlDocGetRootElement(doc);
if (node == NULL || strcmp(node->name, "ices") != 0)
{
xmlFreeDoc(doc);
return 0;
}
_parse_root(ices_config, doc, node->xmlChildrenNode);
xmlFreeDoc(doc);
return 1;
}
void config_dump(void)
{
config_t *c = ices_config;
module_param_t *param;
instance_t *i;
fprintf(stderr, "ices config dump:\n");
fprintf(stderr, "background = %d\n", c->background);
fprintf(stderr, "logpath = %s\n", c->logpath);
fprintf(stderr, "logfile = %s\n", c->logfile);
fprintf(stderr, "loglevel = %d\n", c->loglevel);
fprintf(stderr, "\n");
fprintf(stderr, "stream_name = %s\n", c->stream_name);
fprintf(stderr, "stream_genre = %s\n", c->stream_genre);
fprintf(stderr, "stream_description = %s\n", c->stream_description);
fprintf(stderr, "\n");
fprintf(stderr, "playlist_module = %s\n", c->playlist_module);
param = c->module_params;
while(param)
{
fprintf(stderr, "module_param: %s = %s\n", param->name, param->value);
param = param->next;
}
fprintf(stderr, "\ninstances:\n\n");
i = c->instances;
while (i)
{
fprintf(stderr, "hostname = %s\n", i->hostname);
fprintf(stderr, "port = %d\n", i->port);
fprintf(stderr, "password = %s\n", i->password);
fprintf(stderr, "mount = %s\n", i->mount);
fprintf(stderr, "minimum bitrate = %d\n", i->min_br);
fprintf(stderr, "nominal bitrate = %d\n", i->nom_br);
fprintf(stderr, "maximum bitrate = %d\n", i->max_br);
fprintf(stderr, "quality = %f\n", i->quality);
fprintf(stderr, "managed = %d\n", i->managed);
fprintf(stderr, "reencode = %d\n", i->encode);
fprintf(stderr, "reconnect: %d times at %d second intervals\n",
i->reconnect_attempts, i->reconnect_delay);
fprintf(stderr, "maxqueuelength = %d\n", i->max_queue_length);
fprintf(stderr, "\n");
i = i->next;
}
fprintf(stderr, "\n");
}
<p><p><p><p><p><p><p><p>1.1 ices/src/cfgparse.h
Index: cfgparse.h
===================================================================
/* config.h
* - configuration, and global structures built from config
*
* $Id: cfgparse.h,v 1.1 2003/03/22 01:14:35 karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
* This program is distributed under the terms of the GNU General
* Public License, version 2. You may use, modify, and redistribute
* it under the terms of this license. A copy should be included
* with this source.
*/
#ifndef __CONFIG_H__
#define __CONFIG_H__
#include "stream.h"
#include "inputmodule.h"
#define VERSIONSTRING "IceS 2.0beta2"
typedef struct _module_param_tag
{
char *name;
char *value;
struct _module_param_tag *next;
} module_param_t;
/* FIXME: orward declaraction because my headers are a mess. */
struct buffer_queue;
typedef struct _instance_tag
{
char *hostname;
int port;
char *password;
char *user;
char *mount;
int reconnect_delay;
int reconnect_attempts;
int encode;
int downmix;
int resampleinrate;
int resampleoutrate;
int max_queue_length;
char *savefilename;
/* local metadata */
char *stream_name;
char *stream_genre;
char *stream_description;
/* Parameters for re-encoding */
int managed;
int min_br, nom_br, max_br;
float quality;
int samplerate;
int channels;
/* private */
FILE *savefile;
int serial;
int buffer_failures;
int died;
int kill;
int skip;
int wait_for_critical;
struct buffer_queue *queue;
struct _instance_tag *next;
} instance_t;
typedef struct _config_tag
{
int background;
char *logpath;
char *logfile;
int loglevel;
int log_stderr;
/* <stream> */
/* <metadata> */
char *stream_name;
char *stream_genre;
char *stream_description;
/* <playlist> */
char *playlist_module;
module_param_t *module_params;
/* <instance> */
instance_t *instances;
/* private */
int log_id;
int shutdown;
char *metadata_filename;
cond_t queue_cond;
cond_t event_pending_cond;
mutex_t refcount_lock;
mutex_t flush_lock;
input_module_t *inmod;
struct _config_tag *next;
} config_t;
extern config_t *ices_config;
void config_initialize(void);
void config_shutdown(void);
int config_read(const char *filename);
void config_dump(void);
void config_free_instance(instance_t *instance);
#endif /* __CONFIG_H__ */
<p><p><p><p><p><p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list