[xiph-commits] r16537 - in trunk/ezstream: . doc src

moritz at svn.xiph.org moritz at svn.xiph.org
Sun Aug 30 14:55:25 PDT 2009


Author: moritz
Date: 2009-08-30 14:55:24 -0700 (Sun, 30 Aug 2009)
New Revision: 16537

Modified:
   trunk/ezstream/NEWS
   trunk/ezstream/doc/ezstream.1.in.in
   trunk/ezstream/src/ezstream.c
Log:
Teach ezstream a different mode of operation, as a one-shot line shuffling tool.


Modified: trunk/ezstream/NEWS
===================================================================
--- trunk/ezstream/NEWS	2009-08-30 21:46:15 UTC (rev 16536)
+++ trunk/ezstream/NEWS	2009-08-30 21:55:24 UTC (rev 16537)
@@ -12,6 +12,8 @@
              and operation will continue until 100 subsequent errors. Based on
              an idea from dhorton.
              (Ticket #1585)
+   - [NEW]   New command line option -s: Make ezstream function as a line-
+             based shuffling utility.
  * src/playlist.c:
    - [MISC]  Consider no output from a playlist program to be equivalent to an
              empty line, indicating that the end of the playlist is reached.

Modified: trunk/ezstream/doc/ezstream.1.in.in
===================================================================
--- trunk/ezstream/doc/ezstream.1.in.in	2009-08-30 21:46:15 UTC (rev 16536)
+++ trunk/ezstream/doc/ezstream.1.in.in	2009-08-30 21:55:24 UTC (rev 16537)
@@ -27,6 +27,11 @@
 .Op Fl hnqVv
 .Fl c Ar configfile
 .Ek
+.Nm
+.Bk -words
+.Fl s
+.Op Ar playlist
+.Ek
 .Sh DESCRIPTION
 The
 .Nm
@@ -44,7 +49,6 @@
 .It Fl c Ar configfile
 Use the XML configuration in
 .Ar configfile .
-.Pq Mandatory.
 .It Fl h
 Print a summary of available command line parameters with short descriptions
 and exit.
@@ -53,6 +57,18 @@
 .It Fl q
 Be more quiet.
 Suppress the output that external programs send to standard error.
+.It Fl s Op Ar playlist
+Run
+.Nm
+as a line-based shuffling utility.
+If no
+.Ar playlist
+argument is given, a list of media file names is read from standard input
+instead of an input file.
+After successfully reading the entire list, it is shuffled and printed to
+standard output, and
+.Nm
+will exit.
 .It Fl V
 Print the
 .Nm

Modified: trunk/ezstream/src/ezstream.c
===================================================================
--- trunk/ezstream/src/ezstream.c	2009-08-30 21:46:15 UTC (rev 16536)
+++ trunk/ezstream/src/ezstream.c	2009-08-30 21:55:24 UTC (rev 16537)
@@ -51,6 +51,7 @@
 
 int			 nFlag;
 int			 qFlag;
+int			 sFlag;
 int			 vFlag;
 int			 metadataFromProgram;
 
@@ -1073,6 +1074,7 @@
 usage(void)
 {
 	printf("usage: %s [-hnqVv] -c configfile\n", __progname);
+	printf("       %s -s [playlist]\n", __progname);
 }
 
 void
@@ -1083,6 +1085,8 @@
 	printf("  -h             display this additional help and exit\n");
 	printf("  -n             normalize metadata strings\n");
 	printf("  -q             suppress STDERR output from external en-/decoders\n");
+	printf("  -s [playlist]  read lines from playlist (or STDIN), shuffle and print them to\n");
+	printf("                 STDOUT, then exit\n");
 	printf("  -V             print the version number and exit\n");
 	printf("  -v             verbose output (use twice for more effect)\n");
 	printf("\n");
@@ -1120,7 +1124,7 @@
 	qFlag = 0;
 	vFlag = 0;
 
-	while ((c = local_getopt(argc, argv, "c:hnqVv")) != -1) {
+	while ((c = local_getopt(argc, argv, "c:hnqsVv")) != -1) {
 		switch (c) {
 		case 'c':
 			if (configFile != NULL) {
@@ -1140,6 +1144,9 @@
 		case 'q':
 			qFlag = 1;
 			break;
+		case 's':
+			sFlag = 1;
+			break;
 		case 'V':
 			printf("%s\n", PACKAGE_STRING);
 			return (ez_shutdown(0));
@@ -1156,6 +1163,35 @@
 	argc -= optind;
 	argv += optind;
 
+	if (sFlag) {
+		playlist_t	*pl;
+		const char	*entry;
+
+		switch (argc) {
+		case 0:
+			pl = playlist_read(NULL);
+			if (pl == NULL)
+				return (ez_shutdown(1));
+			break;
+		case 1:
+			pl = playlist_read(argv[0]);
+			if (pl == NULL)
+				return (ez_shutdown(1));
+			break;
+		default:
+			printf("Error: Too many arguments.\n");
+			return (ez_shutdown(2));
+		}
+
+		playlist_shuffle(pl);
+		while ((entry = playlist_get_next(pl)) != NULL)
+			printf("%s\n", entry);
+
+		playlist_free(&pl);
+
+		return (ez_shutdown(0));
+	}
+
 	if (configFile == NULL) {
 		printf("You must supply a config file with the -c argument.\n");
 		usage();



More information about the commits mailing list