[xiph-commits] r16536 - trunk/ezstream/src
moritz at svn.xiph.org
moritz at svn.xiph.org
Sun Aug 30 14:46:15 PDT 2009
Author: moritz
Date: 2009-08-30 14:46:15 -0700 (Sun, 30 Aug 2009)
New Revision: 16536
Modified:
trunk/ezstream/src/ezstream.h
trunk/ezstream/src/playlist.c
Log:
Support reading playlists from standard input.
Modified: trunk/ezstream/src/ezstream.h
===================================================================
--- trunk/ezstream/src/ezstream.h 2009-08-30 20:34:03 UTC (rev 16535)
+++ trunk/ezstream/src/ezstream.h 2009-08-30 21:46:15 UTC (rev 16536)
@@ -49,6 +49,10 @@
# include <unistd.h>
#endif
+#ifndef STDIN_FILENO
+# define STDIN_FILENO 0
+#endif /* !STDIN_FILENO */
+
#ifndef _PATH_DEVNULL
# ifdef WIN32
# define _PATH_DEVNULL "nul"
Modified: trunk/ezstream/src/playlist.c
===================================================================
--- trunk/ezstream/src/playlist.c 2009-08-30 20:34:03 UTC (rev 16535)
+++ trunk/ezstream/src/playlist.c 2009-08-30 21:46:15 UTC (rev 16536)
@@ -131,12 +131,22 @@
FILE *filep;
char buf[PATH_MAX];
- pl = playlist_create(filename);
+ if (filename != NULL) {
+ pl = playlist_create(filename);
- if ((filep = fopen(filename, "r")) == NULL) {
- printf("%s: %s: %s\n", __progname, filename, strerror(errno));
- playlist_free(&pl);
- return (NULL);
+ if ((filep = fopen(filename, "r")) == NULL) {
+ printf("%s: %s: %s\n", __progname, filename, strerror(errno));
+ playlist_free(&pl);
+ return (NULL);
+ }
+ } else {
+ pl = playlist_create("stdin");
+
+ if ((filep = fdopen(STDIN_FILENO, "r")) == NULL) {
+ printf("%s: stdin: %s\n", __progname, strerror(errno));
+ playlist_free(&pl);
+ return (NULL);
+ }
}
line = 0;
@@ -147,7 +157,7 @@
char skip_buf[2];
printf("%s[%lu]: File or path name too long\n",
- filename, line);
+ pl->filename, line);
/* Discard any excess chars in that line. */
while (fgets(skip_buf, (int)sizeof(skip_buf), filep) != NULL) {
if (skip_buf[0] == '\n')
@@ -181,7 +191,7 @@
}
if (ferror(filep)) {
printf("%s: playlist_read(): Error while reading %s: %s\n",
- __progname, filename, strerror(errno));
+ __progname, pl->filename, strerror(errno));
fclose(filep);
playlist_free(&pl);
return (NULL);
More information about the commits
mailing list