libbluray | branch: master | hpi1 <[email protected]> | Fri Oct 17 20:13:31 2014 +0300| [b145dc868a0f5035c685058bcf4d68f4acd28c98] | committer: hpi1
mpls_dump: use only public API. Use correct path separators. > http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=b145dc868a0f5035c685058bcf4d68f4acd28c98 --- src/Makefile.am | 3 +-- src/examples/mpls_dump.c | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 9fc4ce6..49971a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -217,8 +217,7 @@ mpls_dump_CFLAGS = $(AM_CFLAGS) mpls_dump_SOURCES = \ examples/mpls_dump.c \ examples/util.c \ - examples/util.h \ - util/strutl.c + examples/util.h mpls_dump_LDADD = libbluray.la clpi_dump_CFLAGS = $(AM_CFLAGS) diff --git a/src/examples/mpls_dump.c b/src/examples/mpls_dump.c index a97ee33..523e444 100644 --- a/src/examples/mpls_dump.c +++ b/src/examples/mpls_dump.c @@ -25,13 +25,20 @@ #include <string.h> #include <libgen.h> -#include "util/strutl.h" - #include "libbluray/bdnav/mpls_parse.h" #include "libbluray/bluray.h" #include "util.h" +#ifdef _WIN32 +# define DIR_SEP "\\" +# define PLAYLIST_DIR "\\BDMV\\PLAYLIST" +#else +# define DIR_SEP "/" +# define PLAYLIST_DIR "/BDMV/PLAYLIST" +#endif + + static int verbose; typedef struct { @@ -146,6 +153,19 @@ _lookup_str(const VALUE_MAP *map, int val) return "?"; } +static char * +_mk_path(const char *base, const char *sub) +{ + size_t n1 = strlen(base); + size_t n2 = strlen(sub); + char *result = malloc(n1 + n2 + 1); + strcpy(result, base); + strcat(result, DIR_SEP); + strcat(result, sub); + + return result; +} + static void _show_stream(MPLS_STREAM *ss, int level) { @@ -720,7 +740,7 @@ main(int argc, char *argv[]) if (S_ISDIR(st.st_mode)) { printf("Directory: %s:\n", argv[ii]); - path = str_printf("%s/BDMV/PLAYLIST", argv[ii]); + path = _mk_path(argv[ii], PLAYLIST_DIR); if (path == NULL) { fprintf(stderr, "Failed to find playlist path: %s\n", argv[ii]); continue; @@ -737,12 +757,12 @@ main(int argc, char *argv[]) struct dirent *ent; int jj = 0; for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) { - dirlist[jj++] = str_dup(ent->d_name); + dirlist[jj++] = strcpy(malloc(strlen(ent->d_name)), ent->d_name); } qsort(dirlist, jj, sizeof(char*), _qsort_str_cmp); for (jj = 0; dirlist[jj] != NULL; jj++) { char *name = NULL; - name = str_printf("%s/%s", path, dirlist[jj]); + name = _mk_path(path, dirlist[jj]); free(dirlist[jj]); if (stat(name, &st)) { free(name); _______________________________________________ libbluray-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libbluray-devel
