annotate asxparser.c @ 36695:4c63b476f848

Fix MSGTR_MPDEMUX_URL_StringAlreadyEscaped. In r16882 the variable names seem to have mistakenly been used as conversion specifications, resulting in a senseless output message.
author ib
date Wed, 05 Feb 2014 16:55:10 +0000
parents 3cd07587a35d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30429
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
1 /*
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
3 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
8 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
13 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
17 */
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
18
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents: 7909
diff changeset
19 #include "config.h"
4043
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 #include <stdlib.h>
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
22 #include <stdio.h>
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
23 #include <stdarg.h>
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
24 #include <string.h>
35903
389d43c448b3 Add missing strings.h #includes for strcasecmp().
diego
parents: 32511
diff changeset
25 #include <strings.h>
4050
da61596bcd87 FreeBSD fix
nexus
parents: 4043
diff changeset
26 #include <unistd.h>
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
27
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents: 7909
diff changeset
28 #include "playtree.h"
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
29 #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
30 #include "stream/stream.h"
12223
e7c8200ffdc5 Respect -playlist for asx streams
rtognimp
parents: 10397
diff changeset
31 #include "libmpdemux/demuxer.h"
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
32 #include "asxparser.h"
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
33 #include "mp_msg.h"
9744
eceac82103f5 Remove STREAMTYPE_PLAYLIST.
albeu
parents: 9585
diff changeset
34 #include "m_config.h"
32063
bfd3e0d9ab9d Move mconfig extern variable declaration to mpcommon.h.
diego
parents: 31077
diff changeset
35 #include "mpcommon.h"
4043
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 ////// List utils
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
38
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
39 void
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
40 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
41 void** ptr = *(void***)list_ptr;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
42 if(ptr == NULL) return;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
43 if(free_func != NULL) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
44 for( ; *ptr != NULL ; ptr++)
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
45 free_func(*ptr);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
46 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
47 free(*(void**)list_ptr);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
48 *(void**)list_ptr = NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
49 }
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 /////// Attribs utils
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
52
8170
1f6ae3d15f19 Allow to use the asx parser for some other purposes
albeu
parents: 8164
diff changeset
53 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
54 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
55 char** ptr;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
56
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
57 if(attrib == NULL || attribs == NULL) return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
58 for(ptr = attribs; ptr[0] != NULL; ptr += 2){
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
59 if(strcasecmp(ptr[0],attrib) == 0)
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
60 return strdup(ptr[1]);
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 return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
63 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
64
8170
1f6ae3d15f19 Allow to use the asx parser for some other purposes
albeu
parents: 8164
diff changeset
65 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
66 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
67 char** ptr;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
68 int r = 0;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
69
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
70 if(valid_vals == NULL || val == NULL) return -2;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
71 for(ptr = valid_vals ; ptr[0] != NULL ; ptr++) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
72 if(strcasecmp(val,ptr[0]) == 0) return r;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
73 r++;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
74 }
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 return -1;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
77 }
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 #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
80 #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
81
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
82 ASX_Parser_t*
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
83 asx_parser_new(void) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
84 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
85 return parser;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
86 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
87
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
88 void
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
89 asx_parser_free(ASX_Parser_t* parser) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
90 if(!parser) return;
32511
b39155e98ac3 Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents: 32063
diff changeset
91 free(parser->ret_stack);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
92 free(parser);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
93
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
94 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
95
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
96 #define LETTER "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
97 #define SPACE " \n\t\r"
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
98
8170
1f6ae3d15f19 Allow to use the asx parser for some other purposes
albeu
parents: 8164
diff changeset
99 int
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
100 asx_parse_attribs(ASX_Parser_t* parser,char* buffer,char*** _attribs) {
36531
3cd07587a35d asxparser: Declare variables in the blocks that need them.
reimar
parents: 36145
diff changeset
101 char *ptr1;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
102 int n_attrib = 0;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
103 char **attribs = NULL;
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 ptr1 = buffer;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
106 while(1) {
36531
3cd07587a35d asxparser: Declare variables in the blocks that need them.
reimar
parents: 36145
diff changeset
107 char *ptr2, *ptr3;
3cd07587a35d asxparser: Declare variables in the blocks that need them.
reimar
parents: 36145
diff changeset
108 char *attrib, *val;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
109 for( ; strchr(SPACE,*ptr1) != NULL; ptr1++) { // Skip space
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
110 if(*ptr1 == '\0') break;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
111 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
112 ptr3 = strchr(ptr1,'=');
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
113 if(ptr3 == NULL) break;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
114 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
115 if (ptr2 == ptr1) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
116 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : this should never append, back to attribute begin while skipping end space",parser->line);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
117 break;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
118 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
119 }
18869
682a16136d6c rm unnecesary void* casts - part 1
reynaldo
parents: 17803
diff changeset
120 attrib = malloc(ptr2-ptr1+2);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
121 strncpy(attrib,ptr1,ptr2-ptr1+1);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
122 attrib[ptr2-ptr1+1] = '\0';
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 ptr1 = strchr(ptr3,'"');
9744
eceac82103f5 Remove STREAMTYPE_PLAYLIST.
albeu
parents: 9585
diff changeset
125 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
126 if(ptr1 == NULL || ptr1[1] == '\0') {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
127 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
128 free(attrib);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
129 break;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
130 }
9744
eceac82103f5 Remove STREAMTYPE_PLAYLIST.
albeu
parents: 9585
diff changeset
131 ptr2 = strchr(ptr1+1,ptr1[0]);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
132 if (ptr2 == NULL) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
133 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
134 free(attrib);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
135 break;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
136 }
9744
eceac82103f5 Remove STREAMTYPE_PLAYLIST.
albeu
parents: 9585
diff changeset
137 ptr1++;
18869
682a16136d6c rm unnecesary void* casts - part 1
reynaldo
parents: 17803
diff changeset
138 val = malloc(ptr2-ptr1+1);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
139 strncpy(val,ptr1,ptr2-ptr1);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
140 val[ptr2-ptr1] = '\0';
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
141 n_attrib++;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
142
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30590
diff changeset
143 attribs = 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
144 attribs[n_attrib*2-2] = attrib;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
145 attribs[n_attrib*2-1] = val;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
146
7909
6f76eebc0318 patch for crashes/memory corruptions in ASX playlist parser.
arpi
parents: 5802
diff changeset
147 ptr1 = ptr2+1;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
148 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
149
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
150 if(n_attrib > 0)
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
151 attribs[n_attrib*2] = NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
152
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
153 *_attribs = attribs;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
154
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
155 return n_attrib;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
156 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
157
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
158 /*
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
159 * 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
160 */
8170
1f6ae3d15f19 Allow to use the asx parser for some other purposes
albeu
parents: 8164
diff changeset
161 int
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
162 asx_get_element(ASX_Parser_t* parser,char** _buffer,
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
163 char** _element,char** _body,char*** _attribs) {
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
164 char *ptr1,*ptr2, *ptr3, *ptr4;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
165 char *attribs = NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
166 char *element = NULL, *body = NULL, *ret = NULL, *buffer;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
167 int n_attrib = 0;
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
168 int body_line = 0,attrib_line,ret_line,in = 0;
8170
1f6ae3d15f19 Allow to use the asx parser for some other purposes
albeu
parents: 8164
diff changeset
169 int quotes = 0;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
170
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
171 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
172 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
173 return -1;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
174 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
175
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
176 *_body = *_element = NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
177 *_attribs = NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
178 buffer = *_buffer;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
179
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
180 if(buffer == NULL) return 0;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
181
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
182 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
183 ASX_LineSave_t* ls = parser->ret_stack;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
184 int i;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
185 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
186 if(buffer == ls[i].buffer) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
187 parser->line = ls[i].line;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
188 break;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
189 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
190
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
191 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
192 if( i < parser->ret_stack_size) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
193 i++;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
194 if( i < parser->ret_stack_size)
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
195 memmove(parser->ret_stack,parser->ret_stack+i, (parser->ret_stack_size - i)*sizeof(ASX_LineSave_t));
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
196 parser->ret_stack_size -= i;
5802
35f19046f809 Portability fix with realloc
albeu
parents: 4820
diff changeset
197 if(parser->ret_stack_size > 0)
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
198 parser->ret_stack = realloc(parser->ret_stack,parser->ret_stack_size*sizeof(ASX_LineSave_t));
5802
35f19046f809 Portability fix with realloc
albeu
parents: 4820
diff changeset
199 else {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
200 free(parser->ret_stack);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
201 parser->ret_stack = NULL;
5802
35f19046f809 Portability fix with realloc
albeu
parents: 4820
diff changeset
202 }
4043
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 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
205
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
206 ptr1 = buffer;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
207 while(1) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
208 for( ; ptr1[0] != '<' ; ptr1++) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
209 if(ptr1[0] == '\0') {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
210 ptr1 = NULL;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
211 break;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
212 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
213 if(ptr1[0] == '\n') parser->line++;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
214 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
215 //ptr1 = strchr(ptr1,'<');
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
216 if(!ptr1 || ptr1[1] == '\0') return 0; // Nothing found
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
217
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
218 if(strncmp(ptr1,"<!--",4) == 0) { // Comments
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
219 for( ; strncmp(ptr1,"-->",3) != 0 ; ptr1++) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
220 if(ptr1[0] == '\0') {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
221 ptr1 = NULL;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
222 break;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
223 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
224 if(ptr1[0] == '\n') parser->line++;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
225 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
226 //ptr1 = strstr(ptr1,"-->");
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
227 if(!ptr1) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
228 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : unfinished comment",parser->line);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
229 return -1;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
230 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
231 } else {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
232 break;
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 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
235
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
236 // Is this space skip very useful ??
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
237 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
238 if(ptr1[0] == '\0') {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
239 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
240 return -1;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
241 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
242 if(ptr1[0] == '\n') parser->line++;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
243 }
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
244
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
245 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
246 if(*ptr2 == '\0'){
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
247 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
248 return -1;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
249 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
250 if(ptr2[0] == '\n') parser->line++;
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
18869
682a16136d6c rm unnecesary void* casts - part 1
reynaldo
parents: 17803
diff changeset
253 element = malloc(ptr2-ptr1+1);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
254 strncpy(element,ptr1,ptr2-ptr1);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
255 element[ptr2-ptr1] = '\0';
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
256
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
257 for( ; strchr(SPACE,*ptr2) != NULL; ptr2++) { // Skip space
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
258 if(ptr2[0] == '\0') {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
259 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
260 free(element);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
261 return -1;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
262 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
263 if(ptr2[0] == '\n') parser->line++;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
264 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
265 attrib_line = parser->line;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
266
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
267
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
268
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
269 for(ptr3 = ptr2; ptr3[0] != '\0'; ptr3++) { // Go to element end
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
270 if(ptr3[0] == '"') quotes ^= 1;
8170
1f6ae3d15f19 Allow to use the asx parser for some other purposes
albeu
parents: 8164
diff changeset
271 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
272 break;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
273 if(ptr3[0] == '\n') parser->line++;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
274 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
275 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
276 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
277 free(element);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
278 return -1;
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
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
281 // Save attribs string
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
282 if(ptr3-ptr2 > 0) {
18869
682a16136d6c rm unnecesary void* casts - part 1
reynaldo
parents: 17803
diff changeset
283 attribs = malloc(ptr3-ptr2+1);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
284 strncpy(attribs,ptr2,ptr3-ptr2);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
285 attribs[ptr3-ptr2] = '\0';
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
286 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
287 //bs_line = parser->line;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
288 if(ptr3[0] != '/') { // Not Self closed element
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
289 ptr3++;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
290 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
291 if(*ptr3 == '\0') {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
292 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing %s element body",parser->line,element);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
293 free(element);
32511
b39155e98ac3 Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents: 32063
diff changeset
294 free(attribs);
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
295 return -1;
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 if(ptr3[0] == '\n') parser->line++;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
298 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
299 ptr4 = ptr3;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
300 body_line = parser->line;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
301 while(1) { // Find closing element
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
302 for( ; ptr4[0] != '<' ; ptr4++) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
303 if(ptr4[0] == '\0') {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
304 ptr4 = NULL;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
305 break;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
306 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
307 if(ptr4[0] == '\n') parser->line++;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
308 }
8170
1f6ae3d15f19 Allow to use the asx parser for some other purposes
albeu
parents: 8164
diff changeset
309 if(ptr4 && strncmp(ptr4,"<!--",4) == 0) { // Comments
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
310 for( ; strncmp(ptr4,"-->",3) != 0 ; ptr4++) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
311 if(ptr4[0] == '\0') {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
312 ptr4 = NULL;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
313 break;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
314 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
315 if(ptr1[0] == '\n') parser->line++;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
316 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
317 continue;
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
318 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
319 if(ptr4 == NULL || ptr4[1] == '\0') {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
320 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing %s element body",parser->line,element);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
321 free(element);
32511
b39155e98ac3 Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents: 32063
diff changeset
322 free(attribs);
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
323 return -1;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
324 }
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
325 if(ptr4[1] != '/' && strncasecmp(element,ptr4+1,strlen(element)) == 0) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
326 in++;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
327 ptr4+=2;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
328 continue;
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
329 } else if(strncasecmp(element,ptr4+2,strlen(element)) == 0) { // Extract body
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
330 if(in > 0) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
331 in--;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
332 ptr4 += 2+strlen(element);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
333 continue;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
334 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
335 ret = ptr4+strlen(element)+3;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
336 if(ptr4 != ptr3) {
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
337 ptr4--;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
338 for( ; ptr4 != ptr3 && strchr(SPACE,*ptr4) != NULL; ptr4--) ;// Skip space on body end
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
339 // if(ptr4[0] == '\0') parser->line--;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
340 //}
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
341 ptr4++;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
342 body = malloc(ptr4-ptr3+1);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
343 strncpy(body,ptr3,ptr4-ptr3);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
344 body[ptr4-ptr3] = '\0';
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
345 }
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
346 break;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
347 } else {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
348 ptr4 += 2;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
349 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
350 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
351 } else {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
352 ret = ptr3 + 2; // 2 is for />
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
353 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
354
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
355 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
356 if(ret[0] == '\n') parser->line++;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
357 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
358
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
359 ret_line = parser->line;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
360
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
361 if(attribs) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
362 parser->line = attrib_line;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
363 n_attrib = asx_parse_attribs(parser,attribs,_attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
364 free(attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
365 if(n_attrib < 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
366 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
367 free(element);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
368 free(body);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
369 return -1;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
370 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
371 } else
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
372 *_attribs = NULL;
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 *_element = element;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
375 *_body = body;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
376
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
377 parser->last_body = body;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
378 parser->ret_stack_size++;
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30590
diff changeset
379 parser->ret_stack = realloc(parser->ret_stack,parser->ret_stack_size*sizeof(ASX_LineSave_t));
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
380 if(parser->ret_stack_size > 1)
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
381 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
382 parser->ret_stack[0].buffer = ret;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
383 parser->ret_stack[0].line = ret_line;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
384 parser->line = body ? body_line : ret_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 *_buffer = ret;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
387 return 1;
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 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
390
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
391 static void
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
392 asx_parse_param(ASX_Parser_t* parser, char** attribs, play_tree_t* pt) {
36145
47edff322a99 Fix memory leak.
reimar
parents: 36144
diff changeset
393 char *name = NULL,*val = NULL;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
394
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
395 name = asx_get_attrib("NAME",attribs);
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
396 if(!name) {
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
397 asx_warning_attrib_required(parser,"PARAM" ,"NAME" );
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
398 return;
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
399 }
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
400 val = asx_get_attrib("VALUE",attribs);
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
401 if(m_config_get_option(mconfig,name) == NULL) {
10397
6180d7558f75 output typo fixes: unknow --> unknown
diego
parents: 9744
diff changeset
402 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Found unknown param in asx: %s",name);
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
403 if(val)
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
404 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"=%s\n",val);
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
405 else
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
406 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"\n");
36145
47edff322a99 Fix memory leak.
reimar
parents: 36144
diff changeset
407 goto err_out;
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
408 }
36144
43bff9dd44be Disable dangerous feature in ASX playlist parser.
reimar
parents: 35903
diff changeset
409 mp_msg(MSGT_PLAYTREE, MSGL_ERR, "Support for specifying parameters in playlists has been disabled.\n");
43bff9dd44be Disable dangerous feature in ASX playlist parser.
reimar
parents: 35903
diff changeset
410 // play_tree_set_param(pt,name,val);
36145
47edff322a99 Fix memory leak.
reimar
parents: 36144
diff changeset
411 err_out:
9585
89a31cf91a05 Fix some memleaks
albeu
parents: 8925
diff changeset
412 free(name);
32511
b39155e98ac3 Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents: 32063
diff changeset
413 free(val);
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
414 }
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
415
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
416 static void
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
417 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
418 char *href;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
419
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
420 href = asx_get_attrib("HREF",attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
421 if(href == NULL) {
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
422 asx_warning_attrib_required(parser,"REF" ,"HREF" );
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
423 return;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
424 }
25928
bf21649e15c9 Disable http->mmshttp rewriting hack introduced in r25168,
reimar
parents: 25140
diff changeset
425 #if 0
25140
6b1f99f9b2f6 Replace http:// URLs in asx files by mmshttp://.
reimar
parents: 23610
diff changeset
426 // replace http my mmshttp to avoid infinite loops
25928
bf21649e15c9 Disable http->mmshttp rewriting hack introduced in r25168,
reimar
parents: 25140
diff changeset
427 // 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
428 // "-user-agent NSPlayer/4.1.0.3856" is a possible workaround
25140
6b1f99f9b2f6 Replace http:// URLs in asx files by mmshttp://.
reimar
parents: 23610
diff changeset
429 if (strncmp(href, "http://", 7) == 0) {
6b1f99f9b2f6 Replace http:// URLs in asx files by mmshttp://.
reimar
parents: 23610
diff changeset
430 char *newref = malloc(3 + strlen(href) + 1);
6b1f99f9b2f6 Replace http:// URLs in asx files by mmshttp://.
reimar
parents: 23610
diff changeset
431 strcpy(newref, "mms");
6b1f99f9b2f6 Replace http:// URLs in asx files by mmshttp://.
reimar
parents: 23610
diff changeset
432 strcpy(newref + 3, href);
6b1f99f9b2f6 Replace http:// URLs in asx files by mmshttp://.
reimar
parents: 23610
diff changeset
433 free(href);
6b1f99f9b2f6 Replace http:// URLs in asx files by mmshttp://.
reimar
parents: 23610
diff changeset
434 href = newref;
6b1f99f9b2f6 Replace http:// URLs in asx files by mmshttp://.
reimar
parents: 23610
diff changeset
435 }
25928
bf21649e15c9 Disable http->mmshttp rewriting hack introduced in r25168,
reimar
parents: 25140
diff changeset
436 #endif
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
437
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
438 play_tree_add_file(pt,href);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
439
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
440 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
441
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
442 free(href);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
443
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
444 }
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 static play_tree_t*
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
447 asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs) {
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
448 play_tree_t* pt;
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
449 char *href;
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
450 stream_t* stream;
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
451 play_tree_parser_t* ptp;
12223
e7c8200ffdc5 Respect -playlist for asx streams
rtognimp
parents: 10397
diff changeset
452 int f=DEMUXER_TYPE_UNKNOWN;
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
453
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
454 if(parser->deep > 0)
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
455 return NULL;
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
456
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
457 href = asx_get_attrib("HREF",_attribs);
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
458 if(href == NULL) {
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
459 asx_warning_attrib_required(parser,"ENTRYREF" ,"HREF" );
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
460 return NULL;
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
461 }
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
462 stream=open_stream(href,0,&f);
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
463 if(!stream) {
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
464 mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Can't open playlist %s\n",href);
9585
89a31cf91a05 Fix some memleaks
albeu
parents: 8925
diff changeset
465 free(href);
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
466 return NULL;
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
467 }
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
468
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
469 mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding playlist %s to element entryref\n",href);
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
470
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
471 ptp = play_tree_parser_new(stream,parser->deep+1);
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
472
8925
5c15777f1c07 this patch adds an fallback to playlist (any but the plaintext-list format)
arpi
parents: 8170
diff changeset
473 pt = play_tree_parser_get_play_tree(ptp, 1);
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
474
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
475 play_tree_parser_free(ptp);
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
476 free_stream(stream);
9585
89a31cf91a05 Fix some memleaks
albeu
parents: 8925
diff changeset
477 free(href);
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
478 //mp_msg(MSGT_PLAYTREE,MSGL_INFO,"Need to implement entryref\n");
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
479
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
480 return pt;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
481 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
482
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
483 static play_tree_t*
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
484 asx_parse_entry(ASX_Parser_t* parser,char* buffer,char** _attribs) {
36531
3cd07587a35d asxparser: Declare variables in the blocks that need them.
reimar
parents: 36145
diff changeset
485 int nref=0;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
486 play_tree_t *ref;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
487
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
488 ref = play_tree_new();
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
489
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
490 while(buffer && buffer[0] != '\0') {
36531
3cd07587a35d asxparser: Declare variables in the blocks that need them.
reimar
parents: 36145
diff changeset
491 char *element,*body,**attribs;
3cd07587a35d asxparser: Declare variables in the blocks that need them.
reimar
parents: 36145
diff changeset
492 int r = asx_get_element(parser,&buffer,&element,&body,&attribs);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
493 if(r < 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
494 asx_warning_body_parse_error(parser,"ENTRY");
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
495 return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
496 } else if (r == 0) { // No more element
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
497 break;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
498 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
499 if(strcasecmp(element,"REF") == 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
500 asx_parse_ref(parser,attribs,ref);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
501 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
502 nref++;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
503 } else
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
504 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element);
32511
b39155e98ac3 Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents: 32063
diff changeset
505 free(body);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
506 asx_free_attribs(attribs);
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 if(nref <= 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
510 play_tree_free(ref,1);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
511 return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
512 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
513 return 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 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
516
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
517
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
518 static play_tree_t*
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
519 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
520 play_tree_t *repeat, *list=NULL, *entry;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
521 char* count;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
522
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
523 repeat = play_tree_new();
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 count = asx_get_attrib("COUNT",_attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
526 if(count == NULL) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
527 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
528 repeat->loop = -1; // Infinit
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 repeat->loop = atoi(count);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
531 free(count);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
532 if(repeat->loop == 0) repeat->loop = 1;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
533 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
534 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
535
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
536 while(buffer && buffer[0] != '\0') {
36531
3cd07587a35d asxparser: Declare variables in the blocks that need them.
reimar
parents: 36145
diff changeset
537 char *element,*body,**attribs;
3cd07587a35d asxparser: Declare variables in the blocks that need them.
reimar
parents: 36145
diff changeset
538 int r = asx_get_element(parser,&buffer,&element,&body,&attribs);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
539 if(r < 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
540 asx_warning_body_parse_error(parser,"REPEAT");
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
541 return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
542 } else if (r == 0) { // No more element
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
543 break;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
544 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
545 if(strcasecmp(element,"ENTRY") == 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
546 entry = asx_parse_entry(parser,body,attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
547 if(entry) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
548 if(!list) list = entry;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
549 else play_tree_append_entry(list,entry);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
550 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to repeat\n",element);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
551 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
552 } else if(strcasecmp(element,"ENTRYREF") == 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
553 entry = asx_parse_entryref(parser,body,attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
554 if(entry) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
555 if(!list) list = entry;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
556 else play_tree_append_entry(list,entry);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
557 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to repeat\n",element);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
558 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
559 } else if(strcasecmp(element,"REPEAT") == 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
560 entry = asx_parse_repeat(parser,body,attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
561 if(entry) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
562 if(!list) list = entry;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
563 else play_tree_append_entry(list,entry);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
564 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to repeat\n",element);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
565 }
4820
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
566 } else if(strcasecmp(element,"PARAM") == 0) {
ab6ceeef3904 Bug fix in entry parsing.
albeu
parents: 4309
diff changeset
567 asx_parse_param(parser,attribs,repeat);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
568 } else
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
569 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element);
32511
b39155e98ac3 Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents: 32063
diff changeset
570 free(body);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
571 asx_free_attribs(attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
572 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
573
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
574 if(!list) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
575 play_tree_free(repeat,1);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
576 return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
577 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
578 play_tree_set_child(repeat,list);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
579
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
580 return repeat;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
581
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
582 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
583
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
584
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 play_tree_t*
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
587 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
588 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
589 int r;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
590 play_tree_t *asx,*entry,*list = NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
591 ASX_Parser_t* parser = asx_parser_new();
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
592
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
593 parser->line = 1;
4309
35b412015c39 Implementation of entryref
albeu
parents: 4050
diff changeset
594 parser->deep = deep;
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
595
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
596 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
597 if(r < 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
598 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
599 asx_parser_free(parser);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
600 return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
601 } else if(r == 0) { // No contents
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
602 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
603 asx_parser_free(parser);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
604 return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
605 }
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 if(strcasecmp(element,"ASX") != 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
608 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
609 asx_free_attribs(asx_attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
610 asx_parser_free(parser);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
611 return NULL;
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
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
614 if(!asx_body) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
615 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
616 asx_free_attribs(asx_attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
617 asx_parser_free(parser);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
618 return NULL;
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
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
621 asx = play_tree_new();
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
622 buffer = asx_body;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
623 while(buffer && buffer[0] != '\0') {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
624 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
625 if(r < 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
626 asx_warning_body_parse_error(parser,"ASX");
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
627 asx_parser_free(parser);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
628 return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
629 } else if (r == 0) { // No more element
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
630 break;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
631 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
632 if(strcasecmp(element,"ENTRY") == 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
633 entry = asx_parse_entry(parser,body,attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
634 if(entry) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
635 if(!list) list = entry;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
636 else play_tree_append_entry(list,entry);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
637 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to asx\n",element);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
638 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
639 } else if(strcasecmp(element,"ENTRYREF") == 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
640 entry = asx_parse_entryref(parser,body,attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
641 if(entry) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
642 if(!list) list = entry;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
643 else play_tree_append_entry(list,entry);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
644 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to asx\n",element);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
645 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
646 } else if(strcasecmp(element,"REPEAT") == 0) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
647 entry = asx_parse_repeat(parser,body,attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
648 if(entry) {
31077
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
649 if(!list) list = entry;
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
650 else play_tree_append_entry(list,entry);
dd7f15a3fb1b the great MPlayer tab removal: part II
diego
parents: 30727
diff changeset
651 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to asx\n",element);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
652 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
653 } else
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
654 mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element);
32511
b39155e98ac3 Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents: 32063
diff changeset
655 free(body);
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
656 asx_free_attribs(attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
657 }
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 free(asx_body);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
660 asx_free_attribs(asx_attribs);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
661 asx_parser_free(parser);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
662
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
663
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
664 if(!list) {
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
665 play_tree_free(asx,1);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25928
diff changeset
666
4043
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
667 return NULL;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
668 }
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
669
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
670 play_tree_set_child(asx,list);
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
671
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
672 return asx;
25590564842f tree-based playlist parser code by Alban Bedel <albeu@free.fr>
arpi
parents:
diff changeset
673 }