Mercurial > mplayer.hg
annotate asxparser.c @ 30387:30d6f38357c7
If audio was identified as DTS in the PMT do not override that with TrueHD
based only on substream id.
Works with all available DTS and TrueHD samples available (2 each).
author | reimar |
---|---|
date | Sun, 24 Jan 2010 20:54:17 +0000 |
parents | 0f1b5b68af32 |
children | c1a3f1bbba26 |
rev | line source |
---|---|
8164
487cfc28525d
New config system + cleanup of header inter dependency
albeu
parents:
7909
diff
changeset
|
1 #include "config.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
2 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
3 #include <stdlib.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
4 #include <stdio.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
5 #include <stdarg.h> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
6 #include <string.h> |
4050 | 7 #include <unistd.h> |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
8 |
8164
487cfc28525d
New config system + cleanup of header inter dependency
albeu
parents:
7909
diff
changeset
|
9 #include "playtree.h" |
4309 | 10 #include "playtreeparser.h" |
19271
64d82a45a05d
introduce new 'stream' directory for all stream layer related components and split them from libmpdemux
ben
parents:
19104
diff
changeset
|
11 #include "stream/stream.h" |
12223 | 12 #include "libmpdemux/demuxer.h" |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
13 #include "asxparser.h" |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
14 #include "mp_msg.h" |
9744 | 15 #include "m_config.h" |
4820 | 16 |
17 extern m_config_t* mconfig; | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
18 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
19 ////// List utils |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
20 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
21 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
22 asx_list_add(void* list_ptr,void* entry){ |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
23 void** list = *(void***)list_ptr; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
24 int c = 0; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
25 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
26 if(list != NULL) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
27 for( ; list[c] != NULL; c++) ; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
28 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
29 list = (void*)realloc(list,sizeof(void*)*(c+2)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
30 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
31 list[c] = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
32 list[c+1] = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
33 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
34 *(void***)list_ptr = list; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
35 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
36 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
37 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
38 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
39 asx_list_remove(void* list_ptr,void* entry,ASX_FreeFunc free_func) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
40 void** list = *(void***)list_ptr; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
41 int c,e = -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
42 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
43 if(list == NULL) return; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
44 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
45 for(c = 0 ; list[c] != NULL; c++){ |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
46 if(list[c] == entry) e = c; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
47 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
48 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
49 if(e == -1) return; // Not found |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
50 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
51 if(free_func != NULL) free_func(list[e]); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
52 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
53 if(c == 1) { // Only one entry, we drop all |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
54 free(list); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
55 *(void**)list_ptr = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
56 return; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
57 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
58 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
59 if(c > e) // If c==e the memmove is not needed |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
60 memmove(list+e,list+e+1,(c-e)*sizeof(void*)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
61 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
62 list = (void*)realloc(list,(c-1)*sizeof(void*)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
63 list[c-1] = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
64 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
65 *(void***)list_ptr = list; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
66 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
67 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
68 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
69 asx_list_free(void* list_ptr,ASX_FreeFunc free_func) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
70 void** ptr = *(void***)list_ptr; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
71 if(ptr == NULL) return; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
72 if(free_func != NULL) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
73 for( ; *ptr != NULL ; ptr++) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
74 free_func(*ptr); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
75 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
76 free(*(void**)list_ptr); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
77 *(void**)list_ptr = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
78 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
79 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
80 /////// Attribs utils |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
81 |
8170 | 82 char* |
19104
2ec2301183cd
marks several read-only string parameters which aren't modified inside the called function as const. Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
19053
diff
changeset
|
83 asx_get_attrib(const char* attrib,char** attribs) { |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
84 char** ptr; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
85 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
86 if(attrib == NULL || attribs == NULL) return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
87 for(ptr = attribs; ptr[0] != NULL; ptr += 2){ |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
88 if(strcasecmp(ptr[0],attrib) == 0) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
89 return strdup(ptr[1]); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
90 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
91 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
92 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
93 |
8170 | 94 int |
19053
75327b24e06f
marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
18869
diff
changeset
|
95 asx_attrib_to_enum(const char* val,char** valid_vals) { |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
96 char** ptr; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
97 int r = 0; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
98 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
99 if(valid_vals == NULL || val == NULL) return -2; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
100 for(ptr = valid_vals ; ptr[0] != NULL ; ptr++) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
101 if(strcasecmp(val,ptr[0]) == 0) return r; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
102 r++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
103 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
104 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
105 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
106 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
107 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
108 #define asx_warning_attrib_required(p,e,a) mp_msg(MSGT_PLAYTREE,MSGL_WARN,"At line %d : element %s don't have the required attribute %s",p->line,e,a) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
109 #define asx_warning_body_parse_error(p,e) mp_msg(MSGT_PLAYTREE,MSGL_WARN,"At line %d : error while parsing %s body",p->line,e) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
110 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
111 ASX_Parser_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
112 asx_parser_new(void) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
113 ASX_Parser_t* parser = calloc(1,sizeof(ASX_Parser_t)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
114 return parser; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
115 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
116 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
117 void |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
118 asx_parser_free(ASX_Parser_t* parser) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
119 if(!parser) return; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
120 if(parser->ret_stack) free(parser->ret_stack); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
121 free(parser); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
122 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
123 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
124 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
125 #define LETTER "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
126 #define SPACE " \n\t\r" |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
127 |
8170 | 128 int |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
129 asx_parse_attribs(ASX_Parser_t* parser,char* buffer,char*** _attribs) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
130 char *ptr1, *ptr2, *ptr3; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
131 int n_attrib = 0; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
132 char **attribs = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
133 char *attrib, *val; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
134 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
135 ptr1 = buffer; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
136 while(1) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
137 for( ; strchr(SPACE,*ptr1) != NULL; ptr1++) { // Skip space |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
138 if(*ptr1 == '\0') break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
139 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
140 ptr3 = strchr(ptr1,'='); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
141 if(ptr3 == NULL) break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
142 for(ptr2 = ptr3-1; strchr(SPACE,*ptr2) != NULL; ptr2--) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
143 if (ptr2 == ptr1) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
144 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : this should never append, back to attribute begin while skipping end space",parser->line); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
145 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
146 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
147 } |
18869 | 148 attrib = malloc(ptr2-ptr1+2); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
149 strncpy(attrib,ptr1,ptr2-ptr1+1); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
150 attrib[ptr2-ptr1+1] = '\0'; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
151 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
152 ptr1 = strchr(ptr3,'"'); |
9744 | 153 if(ptr1 == NULL || ptr1[1] == '\0') ptr1 = strchr(ptr3,'\''); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
154 if(ptr1 == NULL || ptr1[1] == '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
155 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"At line %d : can't find attribute %s value",parser->line,attrib); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
156 free(attrib); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
157 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
158 } |
9744 | 159 ptr2 = strchr(ptr1+1,ptr1[0]); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
160 if (ptr2 == NULL) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
161 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"At line %d : value of attribute %s isn't finished",parser->line,attrib); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
162 free(attrib); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
163 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
164 } |
9744 | 165 ptr1++; |
18869 | 166 val = malloc(ptr2-ptr1+1); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
167 strncpy(val,ptr1,ptr2-ptr1); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
168 val[ptr2-ptr1] = '\0'; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
169 n_attrib++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
170 |
7909
6f76eebc0318
patch for crashes/memory corruptions in ASX playlist parser.
arpi
parents:
5802
diff
changeset
|
171 attribs = (char**)realloc(attribs,(2*n_attrib+1)*sizeof(char*)); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
172 attribs[n_attrib*2-2] = attrib; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
173 attribs[n_attrib*2-1] = val; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
174 |
7909
6f76eebc0318
patch for crashes/memory corruptions in ASX playlist parser.
arpi
parents:
5802
diff
changeset
|
175 ptr1 = ptr2+1; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
176 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
177 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
178 if(n_attrib > 0) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
179 attribs[n_attrib*2] = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
180 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
181 *_attribs = attribs; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
182 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
183 return n_attrib; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
184 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
185 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
186 /* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
187 * Return -1 on error, 0 when nothing is found, 1 on sucess |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
188 */ |
8170 | 189 int |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
190 asx_get_element(ASX_Parser_t* parser,char** _buffer, |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
191 char** _element,char** _body,char*** _attribs) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
192 char *ptr1,*ptr2, *ptr3, *ptr4; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
193 char *attribs = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
194 char *element = NULL, *body = NULL, *ret = NULL, *buffer; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
195 int n_attrib = 0; |
4820 | 196 int body_line = 0,attrib_line,ret_line,in = 0; |
8170 | 197 int quotes = 0; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
198 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
199 if(_buffer == NULL || _element == NULL || _body == NULL || _attribs == NULL) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
200 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : asx_get_element called with invalid value",parser->line); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
201 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
202 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
203 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
204 *_body = *_element = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
205 *_attribs = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
206 buffer = *_buffer; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
207 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
208 if(buffer == NULL) return 0; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
209 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
210 if(parser->ret_stack && /*parser->last_body && */buffer != parser->last_body) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
211 ASX_LineSave_t* ls = parser->ret_stack; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
212 int i; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
213 for(i = 0 ; i < parser->ret_stack_size ; i++) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
214 if(buffer == ls[i].buffer) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
215 parser->line = ls[i].line; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
216 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
217 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
218 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
219 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
220 if( i < parser->ret_stack_size) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
221 i++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
222 if( i < parser->ret_stack_size) |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
223 memmove(parser->ret_stack,parser->ret_stack+i, (parser->ret_stack_size - i)*sizeof(ASX_LineSave_t)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
224 parser->ret_stack_size -= i; |
5802 | 225 if(parser->ret_stack_size > 0) |
226 parser->ret_stack = (ASX_LineSave_t*)realloc(parser->ret_stack,parser->ret_stack_size*sizeof(ASX_LineSave_t)); | |
227 else { | |
228 free(parser->ret_stack); | |
229 parser->ret_stack = NULL; | |
230 } | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
231 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
232 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
233 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
234 ptr1 = buffer; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
235 while(1) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
236 for( ; ptr1[0] != '<' ; ptr1++) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
237 if(ptr1[0] == '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
238 ptr1 = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
239 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
240 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
241 if(ptr1[0] == '\n') parser->line++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
242 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
243 //ptr1 = strchr(ptr1,'<'); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
244 if(!ptr1 || ptr1[1] == '\0') return 0; // Nothing found |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
245 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
246 if(strncmp(ptr1,"<!--",4) == 0) { // Comments |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
247 for( ; strncmp(ptr1,"-->",3) != 0 ; ptr1++) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
248 if(ptr1[0] == '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
249 ptr1 = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
250 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
251 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
252 if(ptr1[0] == '\n') parser->line++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
253 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
254 //ptr1 = strstr(ptr1,"-->"); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
255 if(!ptr1) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
256 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : unfinished comment",parser->line); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
257 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
258 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
259 } else { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
260 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
261 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
262 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
263 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
264 // Is this space skip very useful ?? |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
265 for(ptr1++; strchr(SPACE,ptr1[0]) != NULL; ptr1++) { // Skip space |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
266 if(ptr1[0] == '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
267 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing element start",parser->line); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
268 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
269 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
270 if(ptr1[0] == '\n') parser->line++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
271 } |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
272 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
273 for(ptr2 = ptr1; strchr(LETTER,*ptr2) != NULL;ptr2++) { // Go to end of name |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
274 if(*ptr2 == '\0'){ |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
275 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing element start",parser->line); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
276 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
277 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
278 if(ptr2[0] == '\n') parser->line++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
279 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
280 |
18869 | 281 element = malloc(ptr2-ptr1+1); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
282 strncpy(element,ptr1,ptr2-ptr1); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
283 element[ptr2-ptr1] = '\0'; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
284 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
285 for( ; strchr(SPACE,*ptr2) != NULL; ptr2++) { // Skip space |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
286 if(ptr2[0] == '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
287 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing element start",parser->line); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
288 free(element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
289 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
290 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
291 if(ptr2[0] == '\n') parser->line++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
292 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
293 attrib_line = parser->line; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
294 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
295 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
296 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
297 for(ptr3 = ptr2; ptr3[0] != '\0'; ptr3++) { // Go to element end |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
298 if(ptr3[0] == '"') quotes ^= 1; |
8170 | 299 if(!quotes && (ptr3[0] == '>' || strncmp(ptr3,"/>",2) == 0)) |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
300 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
301 if(ptr3[0] == '\n') parser->line++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
302 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
303 if(ptr3[0] == '\0' || ptr3[1] == '\0') { // End of file |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
304 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing element start",parser->line); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
305 free(element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
306 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
307 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
308 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
309 // Save attribs string |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
310 if(ptr3-ptr2 > 0) { |
18869 | 311 attribs = malloc(ptr3-ptr2+1); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
312 strncpy(attribs,ptr2,ptr3-ptr2); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
313 attribs[ptr3-ptr2] = '\0'; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
314 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
315 //bs_line = parser->line; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
316 if(ptr3[0] != '/') { // Not Self closed element |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
317 ptr3++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
318 for( ; strchr(SPACE,*ptr3) != NULL; ptr3++) { // Skip space on body begin |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
319 if(*ptr3 == '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
320 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing %s element body",parser->line,element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
321 free(element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
322 if(attribs) free(attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
323 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
324 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
325 if(ptr3[0] == '\n') parser->line++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
326 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
327 ptr4 = ptr3; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
328 body_line = parser->line; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
329 while(1) { // Find closing element |
4820 | 330 for( ; ptr4[0] != '<' ; ptr4++) { |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
331 if(ptr4[0] == '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
332 ptr4 = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
333 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
334 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
335 if(ptr4[0] == '\n') parser->line++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
336 } |
8170 | 337 if(ptr4 && strncmp(ptr4,"<!--",4) == 0) { // Comments |
4820 | 338 for( ; strncmp(ptr4,"-->",3) != 0 ; ptr4++) { |
339 if(ptr4[0] == '\0') { | |
340 ptr4 = NULL; | |
341 break; | |
342 } | |
343 if(ptr1[0] == '\n') parser->line++; | |
344 } | |
345 continue; | |
346 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
347 if(ptr4 == NULL || ptr4[1] == '\0') { |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
348 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing %s element body",parser->line,element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
349 free(element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
350 if(attribs) free(attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
351 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
352 } |
4820 | 353 if(ptr4[1] != '/' && strncasecmp(element,ptr4+1,strlen(element)) == 0) { |
354 in++; | |
355 ptr4+=2; | |
356 continue; | |
357 } else if(strncasecmp(element,ptr4+2,strlen(element)) == 0) { // Extract body | |
358 if(in > 0) { | |
359 in--; | |
360 ptr4 += 2+strlen(element); | |
361 continue; | |
362 } | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
363 ret = ptr4+strlen(element)+3; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
364 if(ptr4 != ptr3) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
365 ptr4--; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
366 for( ; ptr4 != ptr3 && strchr(SPACE,*ptr4) != NULL; ptr4--) ;// Skip space on body end |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
367 // if(ptr4[0] == '\0') parser->line--; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
368 //} |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
369 ptr4++; |
18869 | 370 body = malloc(ptr4-ptr3+1); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
371 strncpy(body,ptr3,ptr4-ptr3); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
372 body[ptr4-ptr3] = '\0'; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
373 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
374 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
375 } else { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
376 ptr4 += 2; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
377 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
378 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
379 } else { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
380 ret = ptr3 + 2; // 2 is for /> |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
381 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
382 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
383 for( ; ret[0] != '\0' && strchr(SPACE,ret[0]) != NULL; ret++) { // Skip space |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
384 if(ret[0] == '\n') parser->line++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
385 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
386 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
387 ret_line = parser->line; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
388 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
389 if(attribs) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
390 parser->line = attrib_line; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
391 n_attrib = asx_parse_attribs(parser,attribs,_attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
392 free(attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
393 if(n_attrib < 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
394 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"At line %d : error while parsing element %s attributes",parser->line,element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
395 free(element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
396 free(body); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
397 return -1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
398 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
399 } else |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
400 *_attribs = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
401 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
402 *_element = element; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
403 *_body = body; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
404 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
405 parser->last_body = body; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
406 parser->ret_stack_size++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
407 parser->ret_stack = (ASX_LineSave_t*)realloc(parser->ret_stack,parser->ret_stack_size*sizeof(ASX_LineSave_t)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
408 if(parser->ret_stack_size > 1) |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
409 memmove(parser->ret_stack+1,parser->ret_stack,(parser->ret_stack_size-1)*sizeof(ASX_LineSave_t)); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
410 parser->ret_stack[0].buffer = ret; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
411 parser->ret_stack[0].line = ret_line; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
412 parser->line = body ? body_line : ret_line; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
413 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
414 *_buffer = ret; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
415 return 1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
416 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
417 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
418 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
419 static void |
4820 | 420 asx_parse_param(ASX_Parser_t* parser, char** attribs, play_tree_t* pt) { |
421 char *name,*val; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
422 |
4820 | 423 name = asx_get_attrib("NAME",attribs); |
424 if(!name) { | |
425 asx_warning_attrib_required(parser,"PARAM" ,"NAME" ); | |
426 return; | |
427 } | |
428 val = asx_get_attrib("VALUE",attribs); | |
429 if(m_config_get_option(mconfig,name) == NULL) { | |
10397 | 430 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Found unknown param in asx: %s",name); |
4820 | 431 if(val) |
432 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"=%s\n",val); | |
433 else | |
434 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"\n"); | |
435 return; | |
436 } | |
437 play_tree_set_param(pt,name,val); | |
9585 | 438 free(name); |
439 if(val) free(val); | |
4820 | 440 } |
441 | |
442 static void | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
443 asx_parse_ref(ASX_Parser_t* parser, char** attribs, play_tree_t* pt) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
444 char *href; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
445 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
446 href = asx_get_attrib("HREF",attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
447 if(href == NULL) { |
4309 | 448 asx_warning_attrib_required(parser,"REF" ,"HREF" ); |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
449 return; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
450 } |
25928
bf21649e15c9
Disable http->mmshttp rewriting hack introduced in r25168,
reimar
parents:
25140
diff
changeset
|
451 #if 0 |
25140 | 452 // replace http my mmshttp to avoid infinite loops |
25928
bf21649e15c9
Disable http->mmshttp rewriting hack introduced in r25168,
reimar
parents:
25140
diff
changeset
|
453 // disabled since some playlists for e.g. WinAMP use asx as well |
bf21649e15c9
Disable http->mmshttp rewriting hack introduced in r25168,
reimar
parents:
25140
diff
changeset
|
454 // "-user-agent NSPlayer/4.1.0.3856" is a possible workaround |
25140 | 455 if (strncmp(href, "http://", 7) == 0) { |
456 char *newref = malloc(3 + strlen(href) + 1); | |
457 strcpy(newref, "mms"); | |
458 strcpy(newref + 3, href); | |
459 free(href); | |
460 href = newref; | |
461 } | |
25928
bf21649e15c9
Disable http->mmshttp rewriting hack introduced in r25168,
reimar
parents:
25140
diff
changeset
|
462 #endif |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
463 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
464 play_tree_add_file(pt,href); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
465 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
466 mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding file %s to element entry\n",href); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
467 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
468 free(href); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
469 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
470 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
471 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
472 static play_tree_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
473 asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs) { |
4309 | 474 play_tree_t* pt; |
475 char *href; | |
476 stream_t* stream; | |
477 play_tree_parser_t* ptp; | |
12223 | 478 int f=DEMUXER_TYPE_UNKNOWN; |
4309 | 479 |
480 if(parser->deep > 0) | |
481 return NULL; | |
482 | |
483 href = asx_get_attrib("HREF",_attribs); | |
484 if(href == NULL) { | |
485 asx_warning_attrib_required(parser,"ENTRYREF" ,"HREF" ); | |
486 return NULL; | |
487 } | |
488 stream=open_stream(href,0,&f); | |
489 if(!stream) { | |
490 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Can't open playlist %s\n",href); | |
9585 | 491 free(href); |
4309 | 492 return NULL; |
493 } | |
494 | |
495 mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding playlist %s to element entryref\n",href); | |
496 | |
497 ptp = play_tree_parser_new(stream,parser->deep+1); | |
498 | |
8925
5c15777f1c07
this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents:
8170
diff
changeset
|
499 pt = play_tree_parser_get_play_tree(ptp, 1); |
4309 | 500 |
501 play_tree_parser_free(ptp); | |
502 free_stream(stream); | |
9585 | 503 free(href); |
4309 | 504 //mp_msg(MSGT_PLAYTREE,MSGL_INFO,"Need to implement entryref\n"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
505 |
4309 | 506 return pt; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
507 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
508 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
509 static play_tree_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
510 asx_parse_entry(ASX_Parser_t* parser,char* buffer,char** _attribs) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
511 char *element,*body,**attribs; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
512 int r,nref=0; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
513 play_tree_t *ref; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
514 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
515 ref = play_tree_new(); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
516 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
517 while(buffer && buffer[0] != '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
518 r = asx_get_element(parser,&buffer,&element,&body,&attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
519 if(r < 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
520 asx_warning_body_parse_error(parser,"ENTRY"); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
521 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
522 } else if (r == 0) { // No more element |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
523 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
524 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
525 if(strcasecmp(element,"REF") == 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
526 asx_parse_ref(parser,attribs,ref); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
527 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to entry\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
528 nref++; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
529 } else |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
530 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
531 if(body) free(body); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
532 asx_free_attribs(attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
533 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
534 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
535 if(nref <= 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
536 play_tree_free(ref,1); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
537 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
538 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
539 return ref; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
540 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
541 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
542 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
543 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
544 static play_tree_t* |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
545 asx_parse_repeat(ASX_Parser_t* parser,char* buffer,char** _attribs) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
546 char *element,*body,**attribs; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
547 play_tree_t *repeat, *list=NULL, *entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
548 char* count; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
549 int r; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
550 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
551 repeat = play_tree_new(); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
552 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
553 count = asx_get_attrib("COUNT",_attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
554 if(count == NULL) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
555 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Setting element repeat loop to infinit\n"); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
556 repeat->loop = -1; // Infinit |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
557 } else { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
558 repeat->loop = atoi(count); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
559 free(count); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
560 if(repeat->loop == 0) repeat->loop = 1; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
561 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Setting element repeat loop to %d\n",repeat->loop); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
562 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
563 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
564 while(buffer && buffer[0] != '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
565 r = asx_get_element(parser,&buffer,&element,&body,&attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
566 if(r < 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
567 asx_warning_body_parse_error(parser,"REPEAT"); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
568 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
569 } else if (r == 0) { // No more element |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
570 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
571 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
572 if(strcasecmp(element,"ENTRY") == 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
573 entry = asx_parse_entry(parser,body,attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
574 if(entry) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
575 if(!list) list = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
576 else play_tree_append_entry(list,entry); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
577 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to repeat\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
578 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
579 } else if(strcasecmp(element,"ENTRYREF") == 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
580 entry = asx_parse_entryref(parser,body,attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
581 if(entry) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
582 if(!list) list = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
583 else play_tree_append_entry(list,entry); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
584 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to repeat\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
585 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
586 } else if(strcasecmp(element,"REPEAT") == 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
587 entry = asx_parse_repeat(parser,body,attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
588 if(entry) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
589 if(!list) list = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
590 else play_tree_append_entry(list,entry); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
591 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to repeat\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
592 } |
4820 | 593 } else if(strcasecmp(element,"PARAM") == 0) { |
594 asx_parse_param(parser,attribs,repeat); | |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
595 } else |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
596 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
597 if(body) free(body); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
598 asx_free_attribs(attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
599 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
600 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
601 if(!list) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
602 play_tree_free(repeat,1); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
603 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
604 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
605 play_tree_set_child(repeat,list); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
606 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
607 return repeat; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
608 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
609 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
610 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
611 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
612 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
613 play_tree_t* |
4309 | 614 asx_parser_build_tree(char* buffer,int deep) { |
17803
51b992a72b17
Fix possible use of body uninitialized. Remove an unneeded free (body
rtognimp
parents:
12223
diff
changeset
|
615 char *element,*asx_body,**asx_attribs,*body = NULL, **attribs; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
616 int r; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
617 play_tree_t *asx,*entry,*list = NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
618 ASX_Parser_t* parser = asx_parser_new(); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
619 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
620 parser->line = 1; |
4309 | 621 parser->deep = deep; |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
622 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
623 r = asx_get_element(parser,&buffer,&element,&asx_body,&asx_attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
624 if(r < 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
625 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : Syntax error ???",parser->line); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
626 asx_parser_free(parser); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
627 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
628 } else if(r == 0) { // No contents |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
629 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"empty asx element"); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
630 asx_parser_free(parser); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
631 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
632 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
633 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
634 if(strcasecmp(element,"ASX") != 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
635 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"first element isn't ASX, it's %s\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
636 asx_free_attribs(asx_attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
637 asx_parser_free(parser); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
638 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
639 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
640 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
641 if(!asx_body) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
642 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"ASX element is empty"); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
643 asx_free_attribs(asx_attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
644 asx_parser_free(parser); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
645 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
646 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
647 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
648 asx = play_tree_new(); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
649 buffer = asx_body; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
650 while(buffer && buffer[0] != '\0') { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
651 r = asx_get_element(parser,&buffer,&element,&body,&attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
652 if(r < 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
653 asx_warning_body_parse_error(parser,"ASX"); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
654 asx_parser_free(parser); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
655 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
656 } else if (r == 0) { // No more element |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
657 break; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
658 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
659 if(strcasecmp(element,"ENTRY") == 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
660 entry = asx_parse_entry(parser,body,attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
661 if(entry) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
662 if(!list) list = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
663 else play_tree_append_entry(list,entry); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
664 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to asx\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
665 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
666 } else if(strcasecmp(element,"ENTRYREF") == 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
667 entry = asx_parse_entryref(parser,body,attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
668 if(entry) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
669 if(!list) list = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
670 else play_tree_append_entry(list,entry); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
671 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to asx\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
672 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
673 } else if(strcasecmp(element,"REPEAT") == 0) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
674 entry = asx_parse_repeat(parser,body,attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
675 if(entry) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
676 if(!list) list = entry; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
677 else play_tree_append_entry(list,entry); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
678 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to asx\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
679 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
680 } else |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
681 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
682 if(body) free(body); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
683 asx_free_attribs(attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
684 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
685 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
686 free(asx_body); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
687 asx_free_attribs(asx_attribs); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
688 asx_parser_free(parser); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
689 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
690 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
691 if(!list) { |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
692 play_tree_free(asx,1); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25928
diff
changeset
|
693 |
4043
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
694 return NULL; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
695 } |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
696 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
697 play_tree_set_child(asx,list); |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
698 |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
699 return asx; |
25590564842f
tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff
changeset
|
700 } |