Mercurial > mplayer.hg
changeset 30901:76a13038105e
Rename get_path.[ch] --> path.[ch].
These files now contain different functions related to path handling.
author | diego |
---|---|
date | Sat, 20 Mar 2010 23:38:27 +0000 |
parents | e907ff9e7e77 |
children | f405a747a35a |
files | Makefile command.c get_path.c get_path.h gui/cfg.c gui/interface.c gui/win32/dialogs.c gui/win32/interface.c gui/win32/wincfg.c input/input.c libaf/af_export.c libass/ass_mp.c libmpcodecs/vd_xanim.c libvo/font_load_ft.c libvo/vo_dxr2.c loader/drv.c loader/elfdll.c loader/module.c loader/registry.c loader/win32.c mencoder.c mplayer.c path.c path.h stream/stream_dvb.c |
diffstat | 25 files changed, 246 insertions(+), 246 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Sat Mar 20 23:27:07 2010 +0000 +++ b/Makefile Sat Mar 20 23:38:27 2010 +0000 @@ -344,12 +344,12 @@ edl.c \ find_sub.c \ fmt-conversion.c \ - get_path.c \ m_config.c \ m_option.c \ m_struct.c \ mpcommon.c \ parser-cfg.c \ + path.c \ playtree.c \ playtreeparser.c \ spudec.c \
--- a/command.c Sat Mar 20 23:27:07 2010 +0000 +++ b/command.c Sat Mar 20 23:38:27 2010 +0000 @@ -46,7 +46,7 @@ #include "libmpcodecs/dec_teletext.h" #include "vobsub.h" #include "spudec.h" -#include "get_path.h" +#include "path.h" #include "stream/tv.h" #include "stream/stream_radio.h" #include "stream/pvr.h"
--- a/get_path.c Sat Mar 20 23:27:07 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,195 +0,0 @@ -/* - * Get path to config dir/file. - * - * Return Values: - * Returns the pointer to the ALLOCATED buffer containing the - * zero terminated path string. This buffer has to be FREED - * by the caller. - * - * 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 "config.h" -#include "mp_msg.h" -#include "get_path.h" - -#ifdef CONFIG_MACOSX_BUNDLE -#include <CoreFoundation/CoreFoundation.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#elif defined(__MINGW32__) -#include <windows.h> -#elif defined(__CYGWIN__) -#include <windows.h> -#include <sys/cygwin.h> -#endif - -#include "osdep/osdep.h" - -char *get_path(const char *filename){ - char *homedir; - char *buff; -#ifdef __MINGW32__ - static char *config_dir = "/mplayer"; -#else - static char *config_dir = "/.mplayer"; -#endif - int len; -#ifdef CONFIG_MACOSX_BUNDLE - struct stat dummy; - CFIndex maxlen=256; - CFURLRef res_url_ref=NULL; - CFURLRef bdl_url_ref=NULL; - char *res_url_path = NULL; - char *bdl_url_path = NULL; -#endif - - if ((homedir = getenv("MPLAYER_HOME")) != NULL) - config_dir = ""; - else if ((homedir = getenv("HOME")) == NULL) -#if defined(__MINGW32__) || defined(__CYGWIN__) - /* Hack to get fonts etc. loaded outside of Cygwin environment. */ - { - int i,imax=0; - char exedir[260]; - GetModuleFileNameA(NULL, exedir, 260); - for (i=0; i< strlen(exedir); i++) - if (exedir[i] =='\\') - {exedir[i]='/'; imax=i;} - exedir[imax]='\0'; - homedir = exedir; - } -#elif defined(__OS2__) - { - PPIB ppib; - char path[260]; - - // Get process info blocks - DosGetInfoBlocks(NULL, &ppib); - - // Get full path of the executable - DosQueryModuleName(ppib->pib_hmte, sizeof( path ), path); - - // Truncate name part including last backslash - *strrchr(path, '\\') = 0; - - // Convert backslash to slash - _fnslashify(path); - - homedir = path; - } -#else - return NULL; -#endif - len = strlen(homedir) + strlen(config_dir) + 1; - if (filename == NULL) { - if ((buff = malloc(len)) == NULL) - return NULL; - sprintf(buff, "%s%s", homedir, config_dir); - } else { - len += strlen(filename) + 1; - if ((buff = malloc(len)) == NULL) - return NULL; - sprintf(buff, "%s%s/%s", homedir, config_dir, filename); - } - -#ifdef CONFIG_MACOSX_BUNDLE - if (stat(buff, &dummy)) { - - res_url_ref=CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); - bdl_url_ref=CFBundleCopyBundleURL(CFBundleGetMainBundle()); - - if (res_url_ref&&bdl_url_ref) { - - res_url_path=malloc(maxlen); - bdl_url_path=malloc(maxlen); - - while (!CFURLGetFileSystemRepresentation(res_url_ref, true, res_url_path, maxlen)) { - maxlen*=2; - res_url_path=realloc(res_url_path, maxlen); - } - CFRelease(res_url_ref); - - while (!CFURLGetFileSystemRepresentation(bdl_url_ref, true, bdl_url_path, maxlen)) { - maxlen*=2; - bdl_url_path=realloc(bdl_url_path, maxlen); - } - CFRelease(bdl_url_ref); - - if (strcmp(res_url_path, bdl_url_path) == 0) - res_url_path = NULL; - } - - if (res_url_path&&filename) { - if ((strlen(filename)+strlen(res_url_path)+2)>maxlen) { - maxlen=strlen(filename)+strlen(res_url_path)+2; - } - free(buff); - buff = malloc(maxlen); - strcpy(buff, res_url_path); - - strcat(buff,"/"); - strcat(buff, filename); - } - } -#endif - mp_msg(MSGT_GLOBAL,MSGL_V,"get_path('%s') -> '%s'\n",filename,buff); - return buff; -} - -#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) -void set_path_env(void) -{ - /*make our codec dirs available for LoadLibraryA()*/ - char win32path[MAX_PATH]; -#ifdef __CYGWIN__ - cygwin_conv_to_full_win32_path(BINARY_CODECS_PATH, win32path); -#else /*__CYGWIN__*/ - /* Expand to absolute path unless it's already absolute */ - if (!strstr(BINARY_CODECS_PATH,":") && BINARY_CODECS_PATH[0] != '\\') { - GetModuleFileNameA(NULL, win32path, MAX_PATH); - strcpy(strrchr(win32path, '\\') + 1, BINARY_CODECS_PATH); - } - else strcpy(win32path, BINARY_CODECS_PATH); -#endif /*__CYGWIN__*/ - mp_msg(MSGT_WIN32, MSGL_V, "Setting PATH to %s\n", win32path); - if (!SetEnvironmentVariableA("PATH", win32path)) - mp_msg(MSGT_WIN32, MSGL_WARN, "Cannot set PATH!"); -} -#endif /* (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) */ - -char *def_path = BINARY_CODECS_PATH; - -static int needs_free = 0; - -void SetCodecPath(const char *path) -{ - if (needs_free) - free(def_path); - if (path == 0) { - def_path = BINARY_CODECS_PATH; - needs_free = 0; - return; - } - def_path = malloc(strlen(path) + 1); - strcpy(def_path, path); - needs_free = 1; -}
--- a/get_path.h Sat Mar 20 23:27:07 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * Get path to config dir/file. - * - * 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. - */ - -#ifndef MPLAYER_GET_PATH_H -#define MPLAYER_GET_PATH_H - -extern char *def_path; - -char *get_path(const char *filename); -void set_path_env(void); -void SetCodecPath(const char *path); - -#endif /* MPLAYER_GET_PATH_H */
--- a/gui/cfg.c Sat Mar 20 23:27:07 2010 +0000 +++ b/gui/cfg.c Sat Mar 20 23:38:27 2010 +0000 @@ -27,7 +27,7 @@ #include "mplayer.h" #include "m_config.h" #include "m_option.h" -#include "get_path.h" +#include "path.h" #include "libmpcodecs/vd.h" #include "libvo/sub.h" #include "libvo/video_out.h"
--- a/gui/interface.c Sat Mar 20 23:27:07 2010 +0000 +++ b/gui/interface.c Sat Mar 20 23:38:27 2010 +0000 @@ -36,7 +36,7 @@ #include "app.h" #include "cfg.h" #include "help_mp.h" -#include "get_path.h" +#include "path.h" #include "mp_core.h" #include "mplayer.h" #include "libmpcodecs/vd.h"
--- a/gui/win32/dialogs.c Sat Mar 20 23:27:07 2010 +0000 +++ b/gui/win32/dialogs.c Sat Mar 20 23:38:27 2010 +0000 @@ -23,7 +23,7 @@ #include <windows.h> #include <commctrl.h> -#include <get_path.h> +#include "path.h" #include "gui/interface.h" #include "mp_msg.h" #include "help_mp.h"
--- a/gui/win32/interface.c Sat Mar 20 23:27:07 2010 +0000 +++ b/gui/win32/interface.c Sat Mar 20 23:38:27 2010 +0000 @@ -22,7 +22,7 @@ */ #include <windows.h> -#include <get_path.h> +#include "path.h" #include "gui/interface.h" #include "m_option.h" #include "mixer.h"
--- a/gui/win32/wincfg.c Sat Mar 20 23:27:07 2010 +0000 +++ b/gui/win32/wincfg.c Sat Mar 20 23:38:27 2010 +0000 @@ -24,7 +24,7 @@ #include <windows.h> #include <stdlib.h> #include <string.h> -#include <get_path.h> +#include "path.h" #include "mplayer.h" #include "mp_msg.h" #include "help_mp.h"
--- a/input/input.c Sat Mar 20 23:27:07 2010 +0000 +++ b/input/input.c Sat Mar 20 23:38:27 2010 +0000 @@ -43,7 +43,7 @@ #include "help_mp.h" #include "m_config.h" #include "m_option.h" -#include "get_path.h" +#include "path.h" #include "joystick.h"
--- a/libaf/af_export.c Sat Mar 20 23:27:07 2010 +0000 +++ b/libaf/af_export.c Sat Mar 20 23:38:27 2010 +0000 @@ -38,7 +38,7 @@ #include <fcntl.h> #include "af.h" -#include "get_path.h" +#include "path.h" #define DEF_SZ 512 // default buffer size (in samples) #define SHARED_FILE "mplayer-af_export" /* default file name
--- a/libass/ass_mp.c Sat Mar 20 23:27:07 2010 +0000 +++ b/libass/ass_mp.c Sat Mar 20 23:38:27 2010 +0000 @@ -25,7 +25,7 @@ #include <stdlib.h> #include "mp_msg.h" -#include "get_path.h" +#include "path.h" #include "ass_mp.h" #include "help_mp.h"
--- a/libmpcodecs/vd_xanim.c Sat Mar 20 23:27:07 2010 +0000 +++ b/libmpcodecs/vd_xanim.c Sat Mar 20 23:38:27 2010 +0000 @@ -29,7 +29,7 @@ #include <string.h> /* strerror */ #include "config.h" -#include "get_path.h" +#include "path.h" #include "mp_msg.h" #include "vd_internal.h"
--- a/libvo/font_load_ft.c Sat Mar 20 23:27:07 2010 +0000 +++ b/libvo/font_load_ft.c Sat Mar 20 23:38:27 2010 +0000 @@ -48,7 +48,7 @@ #include "mp_msg.h" #include "help_mp.h" #include "mplayer.h" -#include "get_path.h" +#include "path.h" #include "osd_font.h" #if (FREETYPE_MAJOR > 2) || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 1)
--- a/libvo/vo_dxr2.c Sat Mar 20 23:27:07 2010 +0000 +++ b/libvo/vo_dxr2.c Sat Mar 20 23:38:27 2010 +0000 @@ -35,7 +35,7 @@ #include "mp_msg.h" #include "m_option.h" #include "sub.h" -#include "get_path.h" +#include "path.h" #include "libmpdemux/mpeg_packetizer.h" #include "x11_common.h"
--- a/loader/drv.c Sat Mar 20 23:27:07 2010 +0000 +++ b/loader/drv.c Sat Mar 20 23:38:27 2010 +0000 @@ -25,7 +25,7 @@ #ifndef __MINGW32__ #include "ext.h" #endif -#include "get_path.h" +#include "path.h" #if 1
--- a/loader/elfdll.c Sat Mar 20 23:27:07 2010 +0000 +++ b/loader/elfdll.c Sat Mar 20 23:38:27 2010 +0000 @@ -18,7 +18,7 @@ #include "wine/debugtools.h" #include "wine/winerror.h" #include "debug.h" -#include "get_path.h" +#include "path.h" //DEFAULT_DEBUG_CHANNEL(elfdll)
--- a/loader/module.c Sat Mar 20 23:27:07 2010 +0000 +++ b/loader/module.c Sat Mar 20 23:38:27 2010 +0000 @@ -46,7 +46,7 @@ #endif #include "win32.h" #include "drv.h" -#include "get_path.h" +#include "path.h" #ifdef EMU_QTX_API #include "wrapper.h"
--- a/loader/registry.c Sat Mar 20 23:27:07 2010 +0000 +++ b/loader/registry.c Sat Mar 20 23:38:27 2010 +0000 @@ -21,7 +21,7 @@ #include "ext.h" #include "registry.h" -#include "get_path.h" +#include "path.h" //#undef TRACE //#define TRACE printf
--- a/loader/win32.c Sat Mar 20 23:27:07 2010 +0000 +++ b/loader/win32.c Sat Mar 20 23:38:27 2010 +0000 @@ -49,7 +49,7 @@ #include "loader.h" #include "com.h" #include "ext.h" -#include "get_path.h" +#include "path.h" #include <stdlib.h> #include <assert.h>
--- a/mencoder.c Sat Mar 20 23:27:07 2010 +0000 +++ b/mencoder.c Sat Mar 20 23:38:27 2010 +0000 @@ -63,7 +63,7 @@ #include "parser-mecmd.h" #include "parser-cfg.h" #include "mp_fifo.h" -#include "get_path.h" +#include "path.h" #include "stream/stream.h" #include "libmpdemux/aviprint.h"
--- a/mplayer.c Sat Mar 20 23:27:07 2010 +0000 +++ b/mplayer.c Sat Mar 20 23:38:27 2010 +0000 @@ -148,7 +148,7 @@ return m_config_parse_config_file(mconfig, filename); } -#include "get_path.h" +#include "path.h" //**************************************************************************// //**************************************************************************//
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/path.c Sat Mar 20 23:38:27 2010 +0000 @@ -0,0 +1,195 @@ +/* + * Get path to config dir/file. + * + * Return Values: + * Returns the pointer to the ALLOCATED buffer containing the + * zero terminated path string. This buffer has to be FREED + * by the caller. + * + * 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 "config.h" +#include "mp_msg.h" +#include "path.h" + +#ifdef CONFIG_MACOSX_BUNDLE +#include <CoreFoundation/CoreFoundation.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#elif defined(__MINGW32__) +#include <windows.h> +#elif defined(__CYGWIN__) +#include <windows.h> +#include <sys/cygwin.h> +#endif + +#include "osdep/osdep.h" + +char *get_path(const char *filename){ + char *homedir; + char *buff; +#ifdef __MINGW32__ + static char *config_dir = "/mplayer"; +#else + static char *config_dir = "/.mplayer"; +#endif + int len; +#ifdef CONFIG_MACOSX_BUNDLE + struct stat dummy; + CFIndex maxlen=256; + CFURLRef res_url_ref=NULL; + CFURLRef bdl_url_ref=NULL; + char *res_url_path = NULL; + char *bdl_url_path = NULL; +#endif + + if ((homedir = getenv("MPLAYER_HOME")) != NULL) + config_dir = ""; + else if ((homedir = getenv("HOME")) == NULL) +#if defined(__MINGW32__) || defined(__CYGWIN__) + /* Hack to get fonts etc. loaded outside of Cygwin environment. */ + { + int i,imax=0; + char exedir[260]; + GetModuleFileNameA(NULL, exedir, 260); + for (i=0; i< strlen(exedir); i++) + if (exedir[i] =='\\') + {exedir[i]='/'; imax=i;} + exedir[imax]='\0'; + homedir = exedir; + } +#elif defined(__OS2__) + { + PPIB ppib; + char path[260]; + + // Get process info blocks + DosGetInfoBlocks(NULL, &ppib); + + // Get full path of the executable + DosQueryModuleName(ppib->pib_hmte, sizeof( path ), path); + + // Truncate name part including last backslash + *strrchr(path, '\\') = 0; + + // Convert backslash to slash + _fnslashify(path); + + homedir = path; + } +#else + return NULL; +#endif + len = strlen(homedir) + strlen(config_dir) + 1; + if (filename == NULL) { + if ((buff = malloc(len)) == NULL) + return NULL; + sprintf(buff, "%s%s", homedir, config_dir); + } else { + len += strlen(filename) + 1; + if ((buff = malloc(len)) == NULL) + return NULL; + sprintf(buff, "%s%s/%s", homedir, config_dir, filename); + } + +#ifdef CONFIG_MACOSX_BUNDLE + if (stat(buff, &dummy)) { + + res_url_ref=CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + bdl_url_ref=CFBundleCopyBundleURL(CFBundleGetMainBundle()); + + if (res_url_ref&&bdl_url_ref) { + + res_url_path=malloc(maxlen); + bdl_url_path=malloc(maxlen); + + while (!CFURLGetFileSystemRepresentation(res_url_ref, true, res_url_path, maxlen)) { + maxlen*=2; + res_url_path=realloc(res_url_path, maxlen); + } + CFRelease(res_url_ref); + + while (!CFURLGetFileSystemRepresentation(bdl_url_ref, true, bdl_url_path, maxlen)) { + maxlen*=2; + bdl_url_path=realloc(bdl_url_path, maxlen); + } + CFRelease(bdl_url_ref); + + if (strcmp(res_url_path, bdl_url_path) == 0) + res_url_path = NULL; + } + + if (res_url_path&&filename) { + if ((strlen(filename)+strlen(res_url_path)+2)>maxlen) { + maxlen=strlen(filename)+strlen(res_url_path)+2; + } + free(buff); + buff = malloc(maxlen); + strcpy(buff, res_url_path); + + strcat(buff,"/"); + strcat(buff, filename); + } + } +#endif + mp_msg(MSGT_GLOBAL,MSGL_V,"get_path('%s') -> '%s'\n",filename,buff); + return buff; +} + +#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) +void set_path_env(void) +{ + /*make our codec dirs available for LoadLibraryA()*/ + char win32path[MAX_PATH]; +#ifdef __CYGWIN__ + cygwin_conv_to_full_win32_path(BINARY_CODECS_PATH, win32path); +#else /*__CYGWIN__*/ + /* Expand to absolute path unless it's already absolute */ + if (!strstr(BINARY_CODECS_PATH,":") && BINARY_CODECS_PATH[0] != '\\') { + GetModuleFileNameA(NULL, win32path, MAX_PATH); + strcpy(strrchr(win32path, '\\') + 1, BINARY_CODECS_PATH); + } + else strcpy(win32path, BINARY_CODECS_PATH); +#endif /*__CYGWIN__*/ + mp_msg(MSGT_WIN32, MSGL_V, "Setting PATH to %s\n", win32path); + if (!SetEnvironmentVariableA("PATH", win32path)) + mp_msg(MSGT_WIN32, MSGL_WARN, "Cannot set PATH!"); +} +#endif /* (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) */ + +char *def_path = BINARY_CODECS_PATH; + +static int needs_free = 0; + +void SetCodecPath(const char *path) +{ + if (needs_free) + free(def_path); + if (path == 0) { + def_path = BINARY_CODECS_PATH; + needs_free = 0; + return; + } + def_path = malloc(strlen(path) + 1); + strcpy(def_path, path); + needs_free = 1; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/path.h Sat Mar 20 23:38:27 2010 +0000 @@ -0,0 +1,30 @@ +/* + * Get path to config dir/file. + * + * 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. + */ + +#ifndef MPLAYER_PATH_H +#define MPLAYER_PATH_H + +extern char *def_path; + +char *get_path(const char *filename); +void set_path_env(void); +void SetCodecPath(const char *path); + +#endif /* MPLAYER_PATH_H */