summaryrefslogtreecommitdiff
path: root/src/libreal/real_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libreal/real_common.c')
-rw-r--r--src/libreal/real_common.c85
1 files changed, 58 insertions, 27 deletions
diff --git a/src/libreal/real_common.c b/src/libreal/real_common.c
index 371ffd246..88036f169 100644
--- a/src/libreal/real_common.c
+++ b/src/libreal/real_common.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* $Id: real_common.c,v 1.12 2007/03/17 15:45:41 dgp85 Exp $
*
@@ -75,32 +75,63 @@ void _x_real_codecs_init(xine_t *const xine) {
#ifdef REAL_CODEC_PATH
const char *const default_real_codecs_path = REAL_CODEC_PATH;
#else
- const char *default_real_codecs_path = "";
- struct stat s;
-
-#define try_real_path(path) \
- if (!stat (path "/drvc.so", &s)) \
- default_real_codecs_path = path;
-#define try_real_subpath(path) \
- try_real_path("/usr/" path) \
- else try_real_path("/usr/local/" path) \
- else try_real_path("/opt/" path)
-
- /* The priority is for the first found */
- try_real_subpath("lib/win32")
- else try_real_subpath("lib/codecs")
- else try_real_subpath("lib64/real")
- else try_real_subpath("lib/real")
- else try_real_subpath("lib/RealPlayer10GOLD/codecs")
- else try_real_subpath("lib64/RealPlayer10/codecs")
- else try_real_subpath("lib/RealPlayer10/codecs")
- else try_real_subpath("lib64/RealPlayer9/users/Real/Codecs")
- else try_real_subpath("lib/RealPlayer9/users/Real/Codecs")
- else try_real_subpath("lib/RealPlayer8/Codecs")
- else try_real_subpath("RealPlayer8/Codecs");
-
-#undef try_real_path
-#undef try_real_subpath
+ char default_real_codecs_path[256];
+
+ default_real_codecs_path[0] = 0;
+
+#define UL64 0x05 /* /usr/{,local/}lib64 */
+#define UL 0x0A /* /usr/{,local/}lib */
+#define O 0x10 /* /opt */
+#define OL64 0x20 /* /opt/lib64 */
+#define OL 0x40 /* /opt/lib */
+
+ static const char *const prefix[] = {
+ "/usr/lib64", "/usr/local/lib64",
+ "/usr/lib", "/usr/local/lib",
+ "/opt", "/opt/lib64", "/opt/lib",
+ };
+
+ static const struct {
+ int prefix;
+ const char *path;
+ } paths[] = {
+ { O | UL, "win32" },
+ { O | UL, "codecs" },
+ { O | UL | UL64, "real" },
+ { O, "real/RealPlayer/codecs" },
+ { OL | OL64 | UL | UL64, "RealPlayer10GOLD/codecs" },
+ { OL | OL64 | UL | UL64, "RealPlayer10/codecs" },
+ { OL | OL64 | UL | UL64, "RealPlayer9/users/Real/Codecs" },
+ { O | OL | UL, "RealPlayer8/Codecs" },
+ {}
+ };
+
+ int i;
+ for (i = 0; paths[i].prefix; ++i)
+ {
+ int p;
+ for (p = 0; p < sizeof (prefix) / sizeof (prefix[0]); ++p)
+ {
+ if (paths[i].prefix & (1 << p))
+ {
+ void *handle;
+ snprintf (default_real_codecs_path, sizeof (default_real_codecs_path), "%s/%s/drvc.so", prefix[p], paths[i].path);
+ handle = dlopen (default_real_codecs_path, RTLD_NOW);
+ if (handle)
+ {
+ dlclose (handle);
+ snprintf (default_real_codecs_path, sizeof (default_real_codecs_path), "%s/%s", prefix[p], paths[i].path);
+ goto found;
+ }
+ }
+ }
+ }
+
+ /* if this is reached, no valid path was found */
+ default_real_codecs_path[0] = 0;
+
+ found:;
+
#endif
real_codecs_path =