diff options
author | wm4 <wm4@nowhere> | 2014-12-29 23:09:50 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-12-29 23:09:50 +0100 |
commit | 8eaa63689a25be909dc31c6a2c8c9dad3777943a (patch) | |
tree | a1f760aa7062b252d108003987cd501b9ccb250f /demux/mf.c | |
parent | 97ab40290eaf5d5f2c97a7a7c6678cdee2283e79 (diff) | |
download | mpv-8eaa63689a25be909dc31c6a2c8c9dad3777943a.tar.bz2 mpv-8eaa63689a25be909dc31c6a2c8c9dad3777943a.tar.xz |
demux_mf: move mf.c contents to demux_mf.c
There's no reason why parts of this demuxer would be in a separate
source file. The existence of this code is already somewhat questionable
anyway, so it may as well be dumped into a single file.
Even stranger that demux.c included mf.h for no reason (it was an
artifact from 2002 when the architecture was uncleaner).
Diffstat (limited to 'demux/mf.c')
-rw-r--r-- | demux/mf.c | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/demux/mf.c b/demux/mf.c deleted file mode 100644 index d687c3cb19..0000000000 --- a/demux/mf.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <limits.h> -#include <sys/types.h> - -#include "osdep/io.h" -#include "talloc.h" -#include "common/msg.h" -#include "stream/stream.h" -#include "misc/ctype.h" -#include "options/path.h" - -#include "mf.h" - -static void mf_add(mf_t *mf, const char *fname) -{ - char *entry = talloc_strdup(mf, fname); - MP_TARRAY_APPEND(mf, mf->names, mf->nr_of_files, entry); -} - -mf_t *open_mf_pattern(void *talloc_ctx, struct mp_log *log, char *filename) -{ - int error_count = 0; - int count = 0; - - mf_t *mf = talloc_zero(talloc_ctx, mf_t); - mf->log = log; - - if (filename[0] == '@') { - FILE *lst_f = fopen(filename + 1, "r"); - if (lst_f) { - char *fname = talloc_size(mf, 512); - while (fgets(fname, 512, lst_f)) { - /* remove spaces from end of fname */ - char *t = fname + strlen(fname) - 1; - while (t > fname && mp_isspace(*t)) - *(t--) = 0; - if (!mp_path_exists(fname)) { - mp_verbose(log, "file not found: '%s'\n", fname); - } else { - mf_add(mf, fname); - } - } - fclose(lst_f); - - mp_info(log, "number of files: %d\n", mf->nr_of_files); - goto exit_mf; - } - mp_info(log, "%s is not indirect filelist\n", filename + 1); - } - - if (strchr(filename, ',')) { - mp_info(log, "filelist: %s\n", filename); - bstr bfilename = bstr0(filename); - - while (bfilename.len) { - bstr bfname; - bstr_split_tok(bfilename, ",", &bfname, &bfilename); - char *fname2 = bstrdup0(mf, bfname); - - if (!mp_path_exists(fname2)) - mp_verbose(log, "file not found: '%s'\n", fname2); - else { - mf_add(mf, fname2); - } - talloc_free(fname2); - } - mp_info(log, "number of files: %d\n", mf->nr_of_files); - - goto exit_mf; - } - - char *fname = talloc_size(mf, strlen(filename) + 32); - - if (!strchr(filename, '%')) { - strcpy(fname, filename); - if (!strchr(filename, '*')) - strcat(fname, "*"); - - mp_info(log, "search expr: %s\n", fname); - - glob_t gg; - if (glob(fname, 0, NULL, &gg)) { - talloc_free(mf); - return NULL; - } - - for (int i = 0; i < gg.gl_pathc; i++) { - if (mp_path_isdir(gg.gl_pathv[i])) - continue; - mf_add(mf, gg.gl_pathv[i]); - } - mp_info(log, "number of files: %d\n", mf->nr_of_files); - globfree(&gg); - goto exit_mf; - } - - mp_info(log, "search expr: %s\n", filename); - - while (error_count < 5) { - sprintf(fname, filename, count++); - if (!mp_path_exists(fname)) { - error_count++; - mp_verbose(log, "file not found: '%s'\n", fname); - } else { - mf_add(mf, fname); - } - } - - mp_info(log, "number of files: %d\n", mf->nr_of_files); - -exit_mf: - return mf; -} - -mf_t *open_mf_single(void *talloc_ctx, struct mp_log *log, char *filename) -{ - mf_t *mf = talloc_zero(talloc_ctx, mf_t); - mf->log = log; - mf_add(mf, filename); - return mf; -} |