[Mplayer-cvslog] CVS: main asxparser.c,1.7,1.8 asxparser.h,1.3,1.4
Alban Bedel CVS
albeu at mplayerhq.hu
Tue Nov 12 15:19:56 CET 2002
Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv27591
Modified Files:
asxparser.c asxparser.h
Log Message:
Allow to use the asx parser for some other purposes
A few 10L fix
Index: asxparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/asxparser.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- asxparser.c 12 Nov 2002 01:56:21 -0000 1.7
+++ asxparser.c 12 Nov 2002 14:19:53 -0000 1.8
@@ -17,8 +17,6 @@
////// List utils
-typedef void (*ASX_FreeFunc)(void* arg);
-
void
asx_list_add(void* list_ptr,void* entry){
void** list = *(void***)list_ptr;
@@ -80,7 +78,7 @@
/////// Attribs utils
-static char*
+char*
asx_get_attrib(char* attrib,char** attribs) {
char** ptr;
@@ -92,7 +90,7 @@
return NULL;
}
-static int
+int
asx_attrib_to_enum(char* val,char** valid_vals) {
char** ptr;
int r = 0;
@@ -150,8 +148,6 @@
return r;
}
-#define asx_free_attribs(a) asx_list_free((void***)&a,free)
-
#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)
#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)
@@ -172,7 +168,7 @@
#define LETTER "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define SPACE " \n\t\r"
-static int
+int
asx_parse_attribs(ASX_Parser_t* parser,char* buffer,char*** _attribs) {
char *ptr1, *ptr2, *ptr3;
int n_attrib = 0;
@@ -232,7 +228,7 @@
/*
* Return -1 on error, 0 when nothing is found, 1 on sucess
*/
-static int
+int
asx_get_element(ASX_Parser_t* parser,char** _buffer,
char** _element,char** _body,char*** _attribs) {
char *ptr1,*ptr2, *ptr3, *ptr4;
@@ -240,6 +236,7 @@
char *element = NULL, *body = NULL, *ret = NULL, *buffer;
int n_attrib = 0;
int body_line = 0,attrib_line,ret_line,in = 0;
+ int quotes = 0;
if(_buffer == NULL || _element == NULL || _body == NULL || _attribs == NULL) {
mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : asx_get_element called with invalid value",parser->line);
@@ -340,7 +337,8 @@
for(ptr3 = ptr2; ptr3[0] != '\0'; ptr3++) { // Go to element end
- if(ptr3[0] == '>' || strncmp(ptr3,"/>",2) == 0)
+ if(ptr3[0] == '"') quotes ^= 1;
+ if(!quotes && (ptr3[0] == '>' || strncmp(ptr3,"/>",2) == 0))
break;
if(ptr3[0] == '\n') parser->line++;
}
@@ -378,7 +376,7 @@
}
if(ptr4[0] == '\n') parser->line++;
}
- if(strncmp(ptr4,"<!--",4) == 0) { // Comments
+ if(ptr4 && strncmp(ptr4,"<!--",4) == 0) { // Comments
for( ; strncmp(ptr4,"-->",3) != 0 ; ptr4++) {
if(ptr4[0] == '\0') {
ptr4 = NULL;
Index: asxparser.h
===================================================================
RCS file: /cvsroot/mplayer/main/asxparser.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- asxparser.h 12 Nov 2002 01:56:21 -0000 1.3
+++ asxparser.h 12 Nov 2002 14:19:53 -0000 1.4
@@ -15,3 +15,35 @@
int deep;
};
+ASX_Parser_t*
+asx_parser_new(void);
+
+void
+asx_parser_free(ASX_Parser_t* parser);
+
+/*
+ * Return -1 on error, 0 when nothing is found, 1 on sucess
+ */
+int
+asx_get_element(ASX_Parser_t* parser,char** _buffer,
+ char** _element,char** _body,char*** _attribs);
+
+int
+asx_parse_attribs(ASX_Parser_t* parser,char* buffer,char*** _attribs);
+
+/////// Attribs utils
+
+char*
+asx_get_attrib(char* attrib,char** attribs);
+
+int
+asx_attrib_to_enum(char* val,char** valid_vals);
+
+#define asx_free_attribs(a) asx_list_free((void***)&a,free)
+
+////// List utils
+
+typedef void (*ASX_FreeFunc)(void* arg);
+
+void
+asx_list_free(void* list_ptr,ASX_FreeFunc free_func);
More information about the MPlayer-cvslog
mailing list