--- src/userfile.c.orig 2009-09-09 20:34:54.000000000 +0800 +++ src/userfile.c 2009-09-18 00:57:22.000000000 +0800 @@ -19,9 +19,47 @@ */ #include +#ifdef __FreeBSD__ +#include +#endif #include #include +/* + * XXX Something is definitely wrong, very very wrong, here or there. + * Apparently mplayer (so far) is the only app that break, returning + * WRDE_SYNTAX. For now, this simple home/path expansion should work. + * I'll investigate this further in future. + */ +#ifdef __FreeBSD__ +int snd_user_file(const char *file, char **result) +{ + + if (file == NULL) + return -EINVAL; + + if (strlen(file) > 2 && strncmp(file, "~/", 2) == 0) { + char *homedir, *path; + + homedir = getenv("HOME"); + if (homedir == NULL) + return -EINVAL; + + /* offset -1 by removing '~' */ + path = malloc(strlen(homedir) + strlen(file)); + if (path == NULL) + return -ENOMEM; + + strcpy(path, homedir); /* copy home directory */ + strcat(path, file + 1); /* discard '~', start with '/' */ + + *result = path; + } else + *result = strdup(file); + + return 0; +} +#else /** * \brief Get the full file name * \param file The file name string to parse @@ -70,3 +108,4 @@ return 0; } #endif /* HAVE_WORDEXP_H */ +#endif /* __FreeBSD__ */