+ return subdirs;
+}
+
+/**
+ * Detect subtitle files.
+ *
+ * When called this function will split up the psz_fname string into a
+ * directory, filename and extension. It then opens the directory
+ * in which the file resides and tries to find possible matches of
+ * subtitles files.
+ *
+ * \ingroup Demux
+ * \param p_this the calling \ref input_thread_t
+ * \param psz_path a list of subdirectories (separated by a ',') to look in.
+ * \param psz_fname the complete filename to base the search on.
+ * \return a NULL terminated array of filenames with detected possible subtitles.
+ * The array contains max MAX_SUBTITLE_FILES items and you need to free it after use.
+ */
+char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
+ char *psz_fname )
+{
+ /* variables to be used for derivatives of psz_fname */
+ char *f_dir, *f_fname, *f_fname_noext, *f_fname_trim, *tmp;
+ /* variables to be used for derivatives FILE *f */
+ char *tmp_fname_noext, *tmp_fname_trim, *tmp_fname_ext, *tmpresult;
+ vlc_value_t fuzzy;
+ int len, i, j, i_sub_count, i_result2;
+ subfn *result; /* unsorted results */
+ char **result2; /* sorted results */
+ char **tmp_subdirs, **subdirs; /* list of subdirectories to look in */
+
+ FILE *f;
+ DIR *d;
+ struct dirent *de;
+
+ if( !strncmp( psz_fname, "file://", 7 ) )
+ {
+ psz_fname += 7;
+ }