changeset 15461:7c272bfba96f

fixed file:// syntax using newly introduced -string- urlpart
author nicodvb
date Sat, 14 May 2005 12:50:59 +0000
parents fa8c3f5b7ec2
children 74813a319929
files libmpdemux/stream_file.c
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/stream_file.c	Sat May 14 12:49:18 2005 +0000
+++ b/libmpdemux/stream_file.c	Sat May 14 12:50:59 2005 +0000
@@ -14,7 +14,7 @@
 
 static struct stream_priv_s {
   char* filename;
-  char* dummy_hostname;
+  char *filename2;
 } stream_priv_dflts = {
   NULL, NULL
 };
@@ -22,8 +22,8 @@
 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
 /// URL definition
 static m_option_t stream_opts_fields[] = {
-  {"filename", ST_OFF(filename), CONF_TYPE_STRING, 0, 0 ,0, NULL},
-  {"hostname", ST_OFF(dummy_hostname), CONF_TYPE_STRING, 0, 0, 0, NULL },
+  {"string", ST_OFF(filename), CONF_TYPE_STRING, 0, 0 ,0, NULL},
+  {"filename", ST_OFF(filename2), CONF_TYPE_STRING, 0, 0 ,0, NULL},
   { NULL, NULL, 0, 0, 0, 0,  NULL }
 };
 static struct m_struct_st stream_opts = {
@@ -71,6 +71,7 @@
   int f;
   mode_t m = 0;
   off_t len;
+  unsigned char *filename;
   struct stream_priv_s* p = (struct stream_priv_s*)opts;
 
   if(mode == STREAM_READ)
@@ -83,7 +84,13 @@
     return STREAM_UNSUPORTED;
   }
 
-  if(!p->filename) {
+  if(p->filename)
+    filename = p->filename;
+  else if(p->filename2)
+    filename = p->filename2;
+  else
+    filename = NULL;
+  if(!filename) {
     mp_msg(MSGT_OPEN,MSGL_ERR, "[file] No filename\n");
     m_struct_free(&stream_opts,opts);
     return STREAM_ERROR;
@@ -93,7 +100,7 @@
   m |= O_BINARY;
 #endif    
 
-  if(!strcmp(p->filename,"-")){
+  if(!strcmp(filename,"-")){
     if(mode == STREAM_READ) {
       // read from stdin
       mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN);
@@ -109,9 +116,9 @@
 #endif
     }
   } else {
-    f=open(p->filename,m);
+    f=open(filename,m);
     if(f<0) {
-      mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,p->filename);
+      mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);
       m_struct_free(&stream_opts,opts);
       return STREAM_ERROR;
     }