diff options
Diffstat (limited to 'mpvcore')
-rw-r--r-- | mpvcore/playlist_parser.c | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/mpvcore/playlist_parser.c b/mpvcore/playlist_parser.c index 7c77760df4..4103467f86 100644 --- a/mpvcore/playlist_parser.c +++ b/mpvcore/playlist_parser.c @@ -237,145 +237,6 @@ static bool parse_asx(play_tree_parser_t* p) { return asx_parse(p->buffer,p->pl); } -static char* -pls_entry_get_value(char* line) { - char* i; - - i = strchr(line,'='); - if(!i || i[1] == '\0') - return NULL; - else - return i+1; -} - -typedef struct pls_entry { - char* file; - char* title; - char* length; -} pls_entry_t; - -static int -pls_read_entry(char* line,pls_entry_t** _e,int* _max_entry,char** val) { - int num,max_entry = (*_max_entry); - pls_entry_t* e = (*_e); - int limit = INT_MAX / sizeof(*e); - char* v; - - v = pls_entry_get_value(line); - if(!v) { - mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); - return -1; - } - - num = atoi(line); - if(num <= 0 || num > limit) { - if (max_entry >= limit) { - mp_msg(MSGT_PLAYTREE, MSGL_WARN, "Too many index entries\n"); - return -1; - } - num = max_entry+1; - mp_msg(MSGT_PLAYTREE,MSGL_WARN,"No or invalid entry index in entry %s\nAssuming %d\n",line,num); - } - if(num > max_entry) { - e = realloc(e, num * sizeof(pls_entry_t)); - if (!e) - return -1; - memset(&e[max_entry],0,(num-max_entry)*sizeof(pls_entry_t)); - max_entry = num; - } - (*_e) = e; - (*_max_entry) = max_entry; - (*val) = v; - - return num; -} - - -static bool parse_pls(play_tree_parser_t* p) { - char *line,*v; - pls_entry_t* entries = NULL; - int n_entries = 0,max_entry=0,num; - - mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying Winamp playlist...\n"); - while((line = play_tree_parser_get_line(p))) { - strstrip(line); - if(strlen(line)) - break; - } - if (!line) - return false; - if(strcasecmp(line,"[playlist]")) - return false; - mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected Winamp playlist format\n"); - play_tree_parser_stop_keeping(p); - line = play_tree_parser_get_line(p); - if(!line) - return false; - strstrip(line); - if(strncasecmp(line,"NumberOfEntries",15) == 0) { - v = pls_entry_get_value(line); - n_entries = atoi(v); - if(n_entries < 0) - mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Invalid number of entries: very funny!!!\n"); - else - mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Playlist claims to have %d entries. Let's see.\n",n_entries); - line = play_tree_parser_get_line(p); - } - - while(line) { - strstrip(line); - if(line[0] == '\0') { - line = play_tree_parser_get_line(p); - continue; - } - if(strncasecmp(line,"File",4) == 0) { - num = pls_read_entry(line+4,&entries,&max_entry,&v); - if(num < 0) - mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); - else - entries[num-1].file = strdup(v); - } else if(strncasecmp(line,"Title",5) == 0) { - num = pls_read_entry(line+5,&entries,&max_entry,&v); - if(num < 0) - mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); - else - entries[num-1].title = strdup(v); - } else if(strncasecmp(line,"Length",6) == 0) { - num = pls_read_entry(line+6,&entries,&max_entry,&v); - if(num < 0) - mp_msg(MSGT_PLAYTREE,MSGL_ERR,"No value in entry %s\n",line); - else { - char *end; - long val = strtol(v, &end, 10); - if (*end || (val <= 0 && val != -1)) - mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Invalid length value in entry %s\n",line); - else if (val > 0) - entries[num-1].length = strdup(v); - } - } else - mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Unknown entry type %s\n",line); - line = play_tree_parser_get_line(p); - } - - for(num = 0; num < max_entry ; num++) { - if(entries[num].file == NULL) - mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Entry %d don't have a file !!!!\n",num+1); - else { - mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding entry %s\n",entries[num].file); - playlist_add_file(p->pl,entries[num].file); - if (entries[num].length) - playlist_entry_add_param(p->pl->last, bstr0("end"), bstr0(entries[num].length)); - free(entries[num].file); - } - // When we have info in playtree we add these info - free(entries[num].title); - free(entries[num].length); - } - - free(entries); - return true; -} - static bool parse_smil(play_tree_parser_t* p) { int entrymode=0; char* line,source[512],*pos,*s_start,*s_end,*src_line; @@ -658,7 +519,6 @@ struct playlist *playlist_parse_file(const char *file, struct MPOpts *opts) typedef bool (*parser_fn)(play_tree_parser_t *); static const parser_fn pl_parsers[] = { parse_asx, - parse_pls, parse_smil, parse_nsc, parse_textplain |