changeset 4309:35b412015c39

Implementation of entryref
author albeu
date Tue, 22 Jan 2002 22:47:17 +0000
parents d752f99fd535
children 1c88d75b446c
files asxparser.c asxparser.h
diffstat 2 files changed, 42 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/asxparser.c	Tue Jan 22 22:46:12 2002 +0000
+++ b/asxparser.c	Tue Jan 22 22:47:17 2002 +0000
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "playtreeparser.h"
 #include "asxparser.h"
 #include "mp_msg.h"
 
@@ -436,7 +437,7 @@
 
   href = asx_get_attrib("HREF",attribs);
   if(href == NULL) {
-    asx_warning_attrib_required(parser,"ENTRYREF" ,"HREF" );
+    asx_warning_attrib_required(parser,"REF" ,"HREF" );
     return;
   }
 
@@ -450,8 +451,43 @@
 
 static play_tree_t*
 asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs) {
-  mp_msg(MSGT_PLAYTREE,MSGL_INFO,"Need to implement entryref\n");
-  return NULL;
+  play_tree_t* pt;
+  char *href;
+  stream_t* stream;
+  play_tree_parser_t* ptp;
+  int f;
+
+  if(parser->deep > 0)
+    return NULL;
+
+  href = asx_get_attrib("HREF",_attribs);
+  if(href == NULL) {
+    asx_warning_attrib_required(parser,"ENTRYREF" ,"HREF" );
+    return NULL;
+  }
+  stream=open_stream(href,0,&f);
+  if(!stream) {
+    mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Can't open playlist %s\n",href);
+    return NULL;
+  }
+  if(stream->type != STREAMTYPE_PLAYLIST) {
+    mp_msg(MSGT_PLAYTREE,MSGL_WARN,"URL %s dont point to a playlist\n",href);
+    free_stream(stream);
+    return NULL;
+  }
+
+  mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding playlist %s to element entryref\n",href);
+
+  ptp = play_tree_parser_new(stream,parser->deep+1);
+
+  pt = play_tree_parser_get_play_tree(ptp);
+
+  play_tree_parser_free(ptp);
+  free_stream(stream);
+
+  //mp_msg(MSGT_PLAYTREE,MSGL_INFO,"Need to implement entryref\n");
+    
+  return pt;
 }
 
 static play_tree_t*
@@ -557,13 +593,14 @@
 
 
 play_tree_t*
-asx_parser_build_tree(char* buffer) {
+asx_parser_build_tree(char* buffer,int deep) {
   char *element,*asx_body,**asx_attribs,*body, **attribs;
   int r;
   play_tree_t *asx,*entry,*list = NULL;
   ASX_Parser_t* parser = asx_parser_new();
 
   parser->line = 1;
+  parser->deep = deep;
 
    r = asx_get_element(parser,&buffer,&element,&asx_body,&asx_attribs);
   if(r < 0) {
--- a/asxparser.h	Tue Jan 22 22:46:12 2002 +0000
+++ b/asxparser.h	Tue Jan 22 22:47:17 2002 +0000
@@ -13,5 +13,6 @@
   ASX_LineSave_t *ret_stack;
   int ret_stack_size;
   char* last_body;
+  int deep;
 };