2004-05-21 20:08:24 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2007-03-29 06:16:00 +00:00
|
|
|
* Copyright (C) 2007 Jonathan Gordon
|
2004-05-21 20:08:24 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program 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.
|
2004-05-21 20:08:24 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
2007-03-29 06:16:00 +00:00
|
|
|
#include "string.h"
|
|
|
|
#include <ctype.h>
|
2004-05-21 20:08:24 +00:00
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "plugin.h"
|
|
|
|
#include "filetypes.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "dir.h"
|
|
|
|
#include "file.h"
|
2005-11-16 15:12:15 +00:00
|
|
|
#include "splash.h"
|
2011-08-30 14:01:33 +00:00
|
|
|
#include "core_alloc.h"
|
2007-06-17 21:16:34 +00:00
|
|
|
#include "icons.h"
|
2022-11-22 03:46:19 +00:00
|
|
|
/*#define LOGF_ENABLE*/
|
2007-06-17 23:10:01 +00:00
|
|
|
#include "logf.h"
|
2004-05-21 20:08:24 +00:00
|
|
|
|
2007-08-12 09:53:41 +00:00
|
|
|
/* max filetypes (plugins & icons stored here) */
|
2010-05-12 12:41:31 +00:00
|
|
|
#define MAX_FILETYPES 192
|
2010-11-09 14:35:19 +00:00
|
|
|
/* max viewer plugins */
|
|
|
|
#define MAX_VIEWERS 56
|
2007-08-12 09:53:41 +00:00
|
|
|
|
2022-12-10 19:36:39 +00:00
|
|
|
static void read_builtin_types_init(void) INIT_ATTR;
|
|
|
|
static void read_viewers_config_init(void) INIT_ATTR;
|
|
|
|
static void read_config_init(int fd) INIT_ATTR;
|
|
|
|
|
2010-11-09 14:35:19 +00:00
|
|
|
/* a table for the known file types */
|
2008-05-24 20:56:19 +00:00
|
|
|
static const struct filetype inbuilt_filetypes[] = {
|
2022-11-22 03:46:19 +00:00
|
|
|
{ "mp3", FILE_ATTR_AUDIO },
|
|
|
|
{ "mp2", FILE_ATTR_AUDIO },
|
|
|
|
{ "mpa", FILE_ATTR_AUDIO },
|
|
|
|
{ "mp1", FILE_ATTR_AUDIO },
|
|
|
|
{ "ogg", FILE_ATTR_AUDIO },
|
|
|
|
{ "oga", FILE_ATTR_AUDIO },
|
|
|
|
{ "wma", FILE_ATTR_AUDIO },
|
|
|
|
{ "wmv", FILE_ATTR_AUDIO },
|
|
|
|
{ "asf", FILE_ATTR_AUDIO },
|
|
|
|
{ "wav", FILE_ATTR_AUDIO },
|
|
|
|
{ "flac", FILE_ATTR_AUDIO },
|
|
|
|
{ "ac3", FILE_ATTR_AUDIO },
|
|
|
|
{ "a52", FILE_ATTR_AUDIO },
|
|
|
|
{ "mpc", FILE_ATTR_AUDIO },
|
|
|
|
{ "wv", FILE_ATTR_AUDIO },
|
|
|
|
{ "m4a", FILE_ATTR_AUDIO },
|
|
|
|
{ "m4b", FILE_ATTR_AUDIO },
|
|
|
|
{ "mp4", FILE_ATTR_AUDIO },
|
|
|
|
{ "mod", FILE_ATTR_AUDIO },
|
|
|
|
{ "mpga", FILE_ATTR_AUDIO },
|
|
|
|
{ "shn", FILE_ATTR_AUDIO },
|
|
|
|
{ "aif", FILE_ATTR_AUDIO },
|
|
|
|
{ "aiff", FILE_ATTR_AUDIO },
|
|
|
|
{ "spx" , FILE_ATTR_AUDIO },
|
|
|
|
{ "opus", FILE_ATTR_AUDIO },
|
|
|
|
{ "sid", FILE_ATTR_AUDIO },
|
|
|
|
{ "adx", FILE_ATTR_AUDIO },
|
|
|
|
{ "nsf", FILE_ATTR_AUDIO },
|
|
|
|
{ "nsfe", FILE_ATTR_AUDIO },
|
|
|
|
{ "spc", FILE_ATTR_AUDIO },
|
|
|
|
{ "ape", FILE_ATTR_AUDIO },
|
|
|
|
{ "mac", FILE_ATTR_AUDIO },
|
|
|
|
{ "sap" , FILE_ATTR_AUDIO },
|
|
|
|
{ "rm", FILE_ATTR_AUDIO },
|
|
|
|
{ "ra", FILE_ATTR_AUDIO },
|
|
|
|
{ "rmvb", FILE_ATTR_AUDIO },
|
|
|
|
{ "cmc", FILE_ATTR_AUDIO },
|
|
|
|
{ "cm3", FILE_ATTR_AUDIO },
|
|
|
|
{ "cmr", FILE_ATTR_AUDIO },
|
|
|
|
{ "cms", FILE_ATTR_AUDIO },
|
|
|
|
{ "dmc", FILE_ATTR_AUDIO },
|
|
|
|
{ "dlt", FILE_ATTR_AUDIO },
|
|
|
|
{ "mpt", FILE_ATTR_AUDIO },
|
|
|
|
{ "mpd", FILE_ATTR_AUDIO },
|
|
|
|
{ "rmt", FILE_ATTR_AUDIO },
|
|
|
|
{ "tmc", FILE_ATTR_AUDIO },
|
|
|
|
{ "tm8", FILE_ATTR_AUDIO },
|
|
|
|
{ "tm2", FILE_ATTR_AUDIO },
|
|
|
|
{ "oma", FILE_ATTR_AUDIO },
|
|
|
|
{ "aa3", FILE_ATTR_AUDIO },
|
|
|
|
{ "at3", FILE_ATTR_AUDIO },
|
|
|
|
{ "mmf", FILE_ATTR_AUDIO },
|
|
|
|
{ "au", FILE_ATTR_AUDIO },
|
|
|
|
{ "snd", FILE_ATTR_AUDIO },
|
|
|
|
{ "vox", FILE_ATTR_AUDIO },
|
|
|
|
{ "w64", FILE_ATTR_AUDIO },
|
|
|
|
{ "tta", FILE_ATTR_AUDIO },
|
|
|
|
{ "ay", FILE_ATTR_AUDIO },
|
|
|
|
{ "vtx", FILE_ATTR_AUDIO },
|
|
|
|
{ "gbs", FILE_ATTR_AUDIO },
|
|
|
|
{ "hes", FILE_ATTR_AUDIO },
|
|
|
|
{ "sgc", FILE_ATTR_AUDIO },
|
|
|
|
{ "vgm", FILE_ATTR_AUDIO },
|
|
|
|
{ "vgz", FILE_ATTR_AUDIO },
|
|
|
|
{ "kss", FILE_ATTR_AUDIO },
|
|
|
|
{ "aac", FILE_ATTR_AUDIO },
|
|
|
|
{ "m3u", FILE_ATTR_M3U },
|
|
|
|
{ "m3u8", FILE_ATTR_M3U },
|
|
|
|
{ "cfg", FILE_ATTR_CFG },
|
|
|
|
{ "wps", FILE_ATTR_WPS },
|
2007-04-18 13:03:01 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2022-11-22 03:46:19 +00:00
|
|
|
{ "rwps", FILE_ATTR_RWPS },
|
2007-04-18 13:03:01 +00:00
|
|
|
#endif
|
|
|
|
#if CONFIG_TUNER
|
2022-11-22 03:46:19 +00:00
|
|
|
{ "fmr", FILE_ATTR_FMR },
|
|
|
|
{ "fms", FILE_ATTR_FMS },
|
|
|
|
#endif
|
2023-04-01 16:32:47 +00:00
|
|
|
{ "log", FILE_ATTR_LOG },
|
2022-11-22 03:46:19 +00:00
|
|
|
{ "lng", FILE_ATTR_LNG },
|
|
|
|
{ "rock", FILE_ATTR_ROCK },
|
|
|
|
{ "lua", FILE_ATTR_LUA },
|
|
|
|
{ "opx", FILE_ATTR_OPX },
|
|
|
|
{ "fnt", FILE_ATTR_FONT },
|
|
|
|
{ "kbd", FILE_ATTR_KBD },
|
|
|
|
{ "bmark",FILE_ATTR_BMARK },
|
|
|
|
{ "cue", FILE_ATTR_CUE },
|
|
|
|
{ "sbs", FILE_ATTR_SBS },
|
2009-10-19 15:28:15 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2022-11-22 03:46:19 +00:00
|
|
|
{ "rsbs", FILE_ATTR_RSBS },
|
2010-05-12 10:38:00 +00:00
|
|
|
#if CONFIG_TUNER
|
2022-11-22 03:46:19 +00:00
|
|
|
{ "rfms", FILE_ATTR_RFMS },
|
2010-11-09 14:35:19 +00:00
|
|
|
#endif
|
2009-10-19 15:28:15 +00:00
|
|
|
#endif
|
2007-04-18 13:03:01 +00:00
|
|
|
#ifdef BOOTFILE_EXT
|
2022-11-22 03:46:19 +00:00
|
|
|
{ BOOTFILE_EXT, FILE_ATTR_MOD },
|
2008-08-15 08:27:39 +00:00
|
|
|
#endif
|
2009-10-10 11:46:23 +00:00
|
|
|
#ifdef BOOTFILE_EXT2
|
2022-11-22 03:46:19 +00:00
|
|
|
{ BOOTFILE_EXT2, FILE_ATTR_MOD },
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2022-11-22 06:41:58 +00:00
|
|
|
struct fileattr_icon_voice {
|
|
|
|
int tree_attr;
|
2022-11-21 07:00:36 +00:00
|
|
|
uint16_t icon;
|
2022-11-22 06:41:58 +00:00
|
|
|
uint16_t voiceclip;
|
2022-11-21 07:00:36 +00:00
|
|
|
};
|
|
|
|
|
2022-11-22 06:41:58 +00:00
|
|
|
/* a table for the known file types icons & voice clips */
|
|
|
|
static const struct fileattr_icon_voice inbuilt_attr_icons_voices[] = {
|
|
|
|
{ FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
|
|
|
|
{ FILE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG },
|
|
|
|
{ FILE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS },
|
2022-11-21 07:00:36 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2022-11-22 06:41:58 +00:00
|
|
|
{FILE_ATTR_RWPS, Icon_Wps, VOICE_EXT_RWPS },
|
2022-11-21 07:00:36 +00:00
|
|
|
#endif
|
|
|
|
#if CONFIG_TUNER
|
2022-11-22 06:41:58 +00:00
|
|
|
{ FILE_ATTR_FMR, Icon_Preset, LANG_FMR },
|
|
|
|
{ FILE_ATTR_FMS, Icon_Wps, VOICE_EXT_FMS },
|
2022-11-21 07:00:36 +00:00
|
|
|
#endif
|
2022-11-22 06:41:58 +00:00
|
|
|
{ FILE_ATTR_LNG, Icon_Language, LANG_LANGUAGE },
|
|
|
|
{ FILE_ATTR_ROCK, Icon_Plugin, VOICE_EXT_ROCK },
|
|
|
|
{ FILE_ATTR_LUA, Icon_Plugin, VOICE_EXT_ROCK },
|
|
|
|
{ FILE_ATTR_OPX, Icon_Plugin, VOICE_EXT_ROCK },
|
|
|
|
{ FILE_ATTR_FONT, Icon_Font, VOICE_EXT_FONT },
|
|
|
|
{ FILE_ATTR_KBD, Icon_Keyboard, VOICE_EXT_KBD },
|
|
|
|
{ FILE_ATTR_BMARK, Icon_Bookmark, VOICE_EXT_BMARK },
|
|
|
|
{ FILE_ATTR_CUE, Icon_Bookmark, VOICE_EXT_CUESHEET },
|
|
|
|
{ FILE_ATTR_SBS, Icon_Wps, VOICE_EXT_SBS },
|
2022-11-21 07:00:36 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2022-11-22 06:41:58 +00:00
|
|
|
{ FILE_ATTR_RSBS, Icon_Wps, VOICE_EXT_RSBS },
|
2022-11-21 07:00:36 +00:00
|
|
|
#if CONFIG_TUNER
|
2022-11-22 06:41:58 +00:00
|
|
|
{ FILE_ATTR_RFMS, Icon_Wps, VOICE_EXT_RFMS },
|
2022-11-21 07:00:36 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if defined(BOOTFILE_EXT) || defined(BOOTFILE_EXT2)
|
2022-11-22 06:41:58 +00:00
|
|
|
{ FILE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ },
|
2009-10-10 11:46:23 +00:00
|
|
|
#endif
|
2007-04-18 13:03:01 +00:00
|
|
|
};
|
|
|
|
|
2022-11-22 06:41:58 +00:00
|
|
|
long tree_get_filetype_voiceclip(int attr)
|
2022-11-22 03:46:19 +00:00
|
|
|
{
|
|
|
|
if (global_settings.talk_filetype)
|
|
|
|
{
|
2022-11-22 06:41:58 +00:00
|
|
|
size_t count = ARRAY_SIZE(inbuilt_attr_icons_voices);
|
2022-11-22 03:46:19 +00:00
|
|
|
/* try to find a voice ID for the extension, if known */
|
2022-11-22 04:28:23 +00:00
|
|
|
attr &= FILE_ATTR_MASK; /* file type */
|
2022-11-22 06:41:58 +00:00
|
|
|
|
|
|
|
for (size_t i = count - 1; i < count; i--)
|
|
|
|
{
|
|
|
|
if (attr == inbuilt_attr_icons_voices[i].tree_attr)
|
2022-11-22 03:46:19 +00:00
|
|
|
{
|
2022-11-22 06:41:58 +00:00
|
|
|
logf("%s found attr %d id %d", __func__, attr,
|
|
|
|
inbuilt_attr_icons_voices[i].voiceclip);
|
|
|
|
return inbuilt_attr_icons_voices[i].voiceclip;
|
2022-11-22 03:46:19 +00:00
|
|
|
}
|
2022-11-22 06:41:58 +00:00
|
|
|
}
|
2022-11-22 03:46:19 +00:00
|
|
|
}
|
2022-11-22 06:41:58 +00:00
|
|
|
logf("%s not found attr %d", __func__, attr);
|
2022-11-22 03:46:19 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-03-29 06:16:00 +00:00
|
|
|
#define ROCK_EXTENSION "rock"
|
|
|
|
|
|
|
|
struct file_type {
|
2011-06-20 19:32:48 +00:00
|
|
|
enum themable_icons icon; /* the icon which shall be used for it, NOICON if unknown */
|
2009-10-28 23:31:45 +00:00
|
|
|
unsigned char attr; /* FILE_ATTR_MASK >> 8 */
|
2007-03-29 06:16:00 +00:00
|
|
|
char* plugin; /* Which plugin to use, NULL if unknown, or builtin */
|
|
|
|
char* extension; /* NULL for none */
|
|
|
|
};
|
2007-08-12 09:53:41 +00:00
|
|
|
static struct file_type filetypes[MAX_FILETYPES];
|
|
|
|
static int custom_filetype_icons[MAX_FILETYPES];
|
2007-04-16 14:33:29 +00:00
|
|
|
static bool custom_icons_loaded = false;
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2013-01-20 11:29:43 +00:00
|
|
|
static int custom_colors[MAX_FILETYPES];
|
2007-06-17 21:16:34 +00:00
|
|
|
#endif
|
2013-01-20 11:29:43 +00:00
|
|
|
struct filetype_unknown {
|
2013-01-20 22:07:04 +00:00
|
|
|
int icon;
|
2013-01-20 11:29:43 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
int color;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
static struct filetype_unknown unknown_file = {
|
|
|
|
.icon = Icon_NOICON,
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
.color = -1,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2010-11-09 14:35:19 +00:00
|
|
|
/* index array to filetypes used in open with list. */
|
|
|
|
static int viewers[MAX_VIEWERS];
|
2007-08-12 09:53:41 +00:00
|
|
|
static int filetype_count = 0;
|
2008-05-24 20:56:19 +00:00
|
|
|
static unsigned char highest_attr = 0;
|
2010-11-09 14:35:19 +00:00
|
|
|
static int viewer_count = 0;
|
2004-05-21 20:08:24 +00:00
|
|
|
|
2021-08-03 02:32:15 +00:00
|
|
|
static int strdup_handle, strdup_cur_idx;
|
|
|
|
static size_t strdup_bufsize;
|
2011-08-30 14:01:45 +00:00
|
|
|
static int move_callback(int handle, void* current, void* new)
|
|
|
|
{
|
|
|
|
/*could compare to strdup_handle, but ops is only used once */
|
|
|
|
(void)handle;
|
|
|
|
size_t diff = new - current;
|
|
|
|
#define FIX_PTR(x) \
|
2011-09-21 13:32:37 +00:00
|
|
|
{ if ((void*)x >= current && (void*)x < (current+strdup_bufsize)) x+= diff; }
|
2011-08-30 14:01:45 +00:00
|
|
|
for(int i = 0; i < filetype_count; i++)
|
|
|
|
{
|
|
|
|
FIX_PTR(filetypes[i].extension);
|
|
|
|
FIX_PTR(filetypes[i].plugin);
|
|
|
|
}
|
|
|
|
return BUFLIB_CB_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct buflib_callbacks ops = {
|
|
|
|
.move_callback = move_callback,
|
|
|
|
.shrink_callback = NULL,
|
|
|
|
};
|
|
|
|
|
2007-03-29 06:16:00 +00:00
|
|
|
static char *filetypes_strdup(char* string)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2011-08-30 14:01:33 +00:00
|
|
|
char *buffer = core_get_data(strdup_handle) + strdup_cur_idx;
|
|
|
|
strdup_cur_idx += strlcpy(buffer, string, strdup_bufsize-strdup_cur_idx)+1;
|
2007-03-29 06:16:00 +00:00
|
|
|
return buffer;
|
2004-05-21 20:08:24 +00:00
|
|
|
}
|
2011-08-30 14:01:33 +00:00
|
|
|
|
2010-11-09 14:35:19 +00:00
|
|
|
static char *filetypes_store_plugin(char *plugin, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
/* if the plugin is in the list already, use it. */
|
|
|
|
for (i=0; i<viewer_count; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp(filetypes[viewers[i]].plugin, plugin))
|
|
|
|
return filetypes[viewers[i]].plugin;
|
|
|
|
}
|
|
|
|
/* otherwise, allocate buffer */
|
|
|
|
if (viewer_count < MAX_VIEWERS)
|
|
|
|
viewers[viewer_count++] = n;
|
|
|
|
return filetypes_strdup(plugin);
|
|
|
|
}
|
2010-11-27 12:57:19 +00:00
|
|
|
|
|
|
|
static int find_extension(const char* extension)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (!extension)
|
|
|
|
return -1;
|
|
|
|
for (i=1; i<filetype_count; i++)
|
|
|
|
{
|
|
|
|
if (filetypes[i].extension &&
|
|
|
|
!strcasecmp(extension, filetypes[i].extension))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
/* Colors file format is similar to icons:
|
|
|
|
* ext:hex_color
|
|
|
|
* load a colors file from a theme with:
|
2007-06-19 04:21:06 +00:00
|
|
|
* filetype colours: filename.colours */
|
2007-06-17 21:16:34 +00:00
|
|
|
void read_color_theme_file(void) {
|
2010-12-06 22:26:31 +00:00
|
|
|
char buffer[MAX_PATH];
|
2007-06-17 21:16:34 +00:00
|
|
|
int fd;
|
|
|
|
char *ext, *color;
|
|
|
|
int i;
|
2013-01-20 11:29:43 +00:00
|
|
|
for (i = 0; i < MAX_FILETYPES; i++) {
|
2007-06-17 21:16:34 +00:00
|
|
|
custom_colors[i] = -1;
|
|
|
|
}
|
2021-03-01 23:39:12 +00:00
|
|
|
unknown_file.color = -1;
|
2021-03-01 09:19:20 +00:00
|
|
|
if (!global_settings.colors_file[0] || global_settings.colors_file[0] == '-')
|
|
|
|
return;
|
2022-11-20 03:39:14 +00:00
|
|
|
|
2022-11-24 02:46:13 +00:00
|
|
|
fd = open_pathfmt(buffer, sizeof(buffer), O_RDONLY,
|
|
|
|
THEME_DIR "/%s.colours", global_settings.colors_file);
|
2007-06-17 21:16:34 +00:00
|
|
|
if (fd < 0)
|
|
|
|
return;
|
|
|
|
while (read_line(fd, buffer, MAX_PATH) > 0)
|
|
|
|
{
|
|
|
|
if (!settings_parseline(buffer, &ext, &color))
|
|
|
|
continue;
|
2007-06-17 23:10:01 +00:00
|
|
|
if (!strcasecmp(ext, "folder"))
|
|
|
|
{
|
2008-03-21 13:41:35 +00:00
|
|
|
hex_to_rgb(color, &custom_colors[0]);
|
2007-06-17 23:10:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-06-18 22:41:39 +00:00
|
|
|
if (!strcasecmp(ext, "???"))
|
|
|
|
{
|
2013-01-20 11:29:43 +00:00
|
|
|
hex_to_rgb(color, &unknown_file.color);
|
2007-06-18 22:41:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-11-27 12:57:19 +00:00
|
|
|
i = find_extension(ext);
|
|
|
|
if (i >= 0)
|
|
|
|
hex_to_rgb(color, &custom_colors[i]);
|
2007-06-17 21:16:34 +00:00
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
#endif
|
2007-04-16 09:14:36 +00:00
|
|
|
void read_viewer_theme_file(void)
|
|
|
|
{
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
int fd;
|
|
|
|
char *ext, *icon;
|
|
|
|
int i;
|
2013-01-20 11:29:43 +00:00
|
|
|
int *icon_dest;
|
2007-04-26 05:30:46 +00:00
|
|
|
global_status.viewer_icon_count = 0;
|
2007-04-16 14:33:29 +00:00
|
|
|
custom_icons_loaded = false;
|
2007-04-16 14:52:47 +00:00
|
|
|
custom_filetype_icons[0] = Icon_Folder;
|
|
|
|
for (i=1; i<filetype_count; i++)
|
2007-04-17 09:17:23 +00:00
|
|
|
{
|
2007-04-22 08:50:24 +00:00
|
|
|
custom_filetype_icons[i] = filetypes[i].icon;
|
2007-04-17 09:17:23 +00:00
|
|
|
}
|
2022-02-01 18:22:08 +00:00
|
|
|
|
2022-11-24 02:46:13 +00:00
|
|
|
fd = open_pathfmt(buffer, sizeof(buffer), O_RDONLY,
|
|
|
|
ICON_DIR "/%s.icons", global_settings.viewers_icon_file);
|
2007-04-16 09:14:36 +00:00
|
|
|
if (fd < 0)
|
|
|
|
return;
|
2022-11-24 02:46:13 +00:00
|
|
|
|
2007-04-16 09:14:36 +00:00
|
|
|
while (read_line(fd, buffer, MAX_PATH) > 0)
|
|
|
|
{
|
|
|
|
if (!settings_parseline(buffer, &ext, &icon))
|
|
|
|
continue;
|
2010-11-27 12:57:19 +00:00
|
|
|
i = find_extension(ext);
|
|
|
|
if (i >= 0)
|
2013-01-20 11:29:43 +00:00
|
|
|
icon_dest = &custom_filetype_icons[i];
|
|
|
|
else if (!strcmp(ext, "???"))
|
|
|
|
icon_dest = &unknown_file.icon;
|
|
|
|
else
|
|
|
|
icon_dest = NULL;
|
|
|
|
|
|
|
|
if (icon_dest)
|
2007-04-16 09:14:36 +00:00
|
|
|
{
|
2010-11-27 12:57:19 +00:00
|
|
|
if (*icon == '*')
|
2013-01-20 11:29:43 +00:00
|
|
|
*icon_dest = atoi(icon+1);
|
2010-11-27 12:57:19 +00:00
|
|
|
else if (*icon == '-')
|
2013-01-20 11:29:43 +00:00
|
|
|
*icon_dest = Icon_NOICON;
|
2010-11-27 12:57:19 +00:00
|
|
|
else if (*icon >= '0' && *icon <= '9')
|
2007-04-16 09:14:36 +00:00
|
|
|
{
|
2010-11-27 12:57:19 +00:00
|
|
|
int number = atoi(icon);
|
|
|
|
if (number > global_status.viewer_icon_count)
|
|
|
|
global_status.viewer_icon_count++;
|
2013-01-20 11:29:43 +00:00
|
|
|
*icon_dest = Icon_Last_Themeable + number;
|
2007-04-16 09:14:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(fd);
|
2007-04-16 14:33:29 +00:00
|
|
|
custom_icons_loaded = true;
|
2007-04-16 09:14:36 +00:00
|
|
|
}
|
2004-05-21 20:08:24 +00:00
|
|
|
|
2022-12-10 19:36:39 +00:00
|
|
|
static void read_viewers_config_init(void)
|
2021-08-21 09:23:29 +00:00
|
|
|
{
|
|
|
|
int fd = open(VIEWERS_CONFIG, O_RDONLY);
|
|
|
|
if(fd < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
off_t filesz = filesize(fd);
|
|
|
|
if(filesz <= 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* estimate bufsize with the filesize, will not be larger */
|
|
|
|
strdup_bufsize = (size_t)filesz;
|
2022-10-15 22:55:39 +00:00
|
|
|
strdup_handle = core_alloc_ex(strdup_bufsize, &ops);
|
2021-08-21 09:23:29 +00:00
|
|
|
if(strdup_handle <= 0)
|
|
|
|
goto out;
|
|
|
|
|
2022-12-10 19:36:39 +00:00
|
|
|
read_config_init(fd);
|
2023-01-13 01:52:29 +00:00
|
|
|
core_shrink(strdup_handle, NULL, strdup_cur_idx);
|
2021-08-21 09:23:29 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
|
2022-12-10 19:36:39 +00:00
|
|
|
void filetype_init(void)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2007-03-29 06:16:00 +00:00
|
|
|
/* set the directory item first */
|
|
|
|
filetypes[0].extension = NULL;
|
|
|
|
filetypes[0].plugin = NULL;
|
|
|
|
filetypes[0].attr = 0;
|
2007-04-16 09:14:36 +00:00
|
|
|
filetypes[0].icon = Icon_Folder;
|
2010-11-09 14:35:19 +00:00
|
|
|
|
|
|
|
viewer_count = 0;
|
2007-03-29 06:16:00 +00:00
|
|
|
filetype_count = 1;
|
2011-08-30 14:01:33 +00:00
|
|
|
|
2022-12-10 19:36:39 +00:00
|
|
|
read_builtin_types_init();
|
|
|
|
read_viewers_config_init();
|
2007-04-16 09:14:36 +00:00
|
|
|
read_viewer_theme_file();
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
read_color_theme_file();
|
|
|
|
#endif
|
2004-05-21 20:08:24 +00:00
|
|
|
}
|
|
|
|
|
2007-03-29 06:16:00 +00:00
|
|
|
/* remove all white spaces from string */
|
|
|
|
static void rm_whitespaces(char* str)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2007-03-29 06:16:00 +00:00
|
|
|
char *s = str;
|
|
|
|
while (*str)
|
2006-03-13 07:33:30 +00:00
|
|
|
{
|
2007-03-29 06:16:00 +00:00
|
|
|
if (!isspace(*str))
|
2006-03-13 07:33:30 +00:00
|
|
|
{
|
2007-03-29 06:16:00 +00:00
|
|
|
*s = *str;
|
|
|
|
s++;
|
2006-03-13 07:33:30 +00:00
|
|
|
}
|
2007-03-29 06:16:00 +00:00
|
|
|
str++;
|
2006-03-13 07:33:30 +00:00
|
|
|
}
|
2007-03-29 06:16:00 +00:00
|
|
|
*s = '\0';
|
2004-05-21 20:08:24 +00:00
|
|
|
}
|
|
|
|
|
2022-12-10 19:36:39 +00:00
|
|
|
static void read_builtin_types_init(void)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2022-11-22 06:41:58 +00:00
|
|
|
int tree_attr;
|
|
|
|
size_t count = ARRAY_SIZE(inbuilt_filetypes);
|
|
|
|
size_t icon_count = ARRAY_SIZE(inbuilt_attr_icons_voices);
|
|
|
|
for(size_t i = 0; (i < count) && (filetype_count < MAX_FILETYPES); i++)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2007-04-18 13:03:01 +00:00
|
|
|
filetypes[filetype_count].extension = inbuilt_filetypes[i].extension;
|
2007-03-29 06:16:00 +00:00
|
|
|
filetypes[filetype_count].plugin = NULL;
|
2022-11-21 07:00:36 +00:00
|
|
|
|
|
|
|
tree_attr = inbuilt_filetypes[i].tree_attr;
|
|
|
|
filetypes[filetype_count].attr = tree_attr>>8;
|
2008-05-24 20:56:19 +00:00
|
|
|
if (filetypes[filetype_count].attr > highest_attr)
|
|
|
|
highest_attr = filetypes[filetype_count].attr;
|
2022-11-21 07:00:36 +00:00
|
|
|
|
|
|
|
filetypes[filetype_count].icon = unknown_file.icon;
|
2022-11-22 06:41:58 +00:00
|
|
|
for (size_t j = icon_count - 1; j < icon_count; j--)
|
2022-11-21 07:00:36 +00:00
|
|
|
{
|
2022-11-22 06:41:58 +00:00
|
|
|
if (tree_attr == inbuilt_attr_icons_voices[j].tree_attr)
|
2022-11-21 07:00:36 +00:00
|
|
|
{
|
2022-11-22 06:41:58 +00:00
|
|
|
filetypes[filetype_count].icon = inbuilt_attr_icons_voices[j].icon;
|
2022-11-21 07:00:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-03-29 06:16:00 +00:00
|
|
|
filetype_count++;
|
2004-05-21 20:08:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-10 19:36:39 +00:00
|
|
|
static void read_config_init(int fd)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2007-03-29 06:16:00 +00:00
|
|
|
char line[64], *s, *e;
|
2010-11-09 14:35:19 +00:00
|
|
|
char *extension, *plugin;
|
|
|
|
/* config file is in the format
|
2007-03-29 06:16:00 +00:00
|
|
|
<extension>,<plugin>,<icon code>
|
|
|
|
ignore line if either of the first two are missing */
|
2010-11-09 14:35:19 +00:00
|
|
|
while (read_line(fd, line, sizeof line) > 0)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2007-08-12 09:53:41 +00:00
|
|
|
if (filetype_count >= MAX_FILETYPES)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ, ID2P(LANG_FILETYPES_FULL));
|
2004-05-21 20:08:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-03-29 06:16:00 +00:00
|
|
|
rm_whitespaces(line);
|
2010-11-27 12:57:19 +00:00
|
|
|
/* get the extension */
|
2007-03-29 06:16:00 +00:00
|
|
|
s = line;
|
|
|
|
e = strchr(s, ',');
|
|
|
|
if (!e)
|
2004-05-21 20:08:24 +00:00
|
|
|
continue;
|
2007-03-29 06:16:00 +00:00
|
|
|
*e = '\0';
|
2010-11-09 14:35:19 +00:00
|
|
|
extension = s;
|
|
|
|
|
2007-03-29 06:16:00 +00:00
|
|
|
/* get the plugin */
|
|
|
|
s = e+1;
|
|
|
|
e = strchr(s, ',');
|
|
|
|
if (!e)
|
2004-05-21 20:08:24 +00:00
|
|
|
continue;
|
2007-03-29 06:16:00 +00:00
|
|
|
*e = '\0';
|
2010-11-09 14:35:19 +00:00
|
|
|
plugin = s;
|
|
|
|
|
2013-01-20 11:29:43 +00:00
|
|
|
if (!strcmp("???", extension))
|
|
|
|
{
|
|
|
|
/* get the icon */
|
|
|
|
s = e+1;
|
|
|
|
if (*s == '*')
|
|
|
|
unknown_file.icon = atoi(s+1);
|
|
|
|
else if (*s == '-')
|
|
|
|
unknown_file.icon = Icon_NOICON;
|
|
|
|
else if (*s >= '0' && *s <= '9')
|
|
|
|
unknown_file.icon = Icon_Last_Themeable + atoi(s);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-03-29 06:16:00 +00:00
|
|
|
/* ok, store this plugin/extension, check icon after */
|
2010-11-09 14:35:19 +00:00
|
|
|
struct file_type *file_type = &filetypes[filetype_count];
|
|
|
|
file_type->extension = filetypes_strdup(extension);
|
|
|
|
file_type->plugin = filetypes_store_plugin(plugin, filetype_count);
|
|
|
|
file_type->attr = highest_attr +1;
|
|
|
|
file_type->icon = Icon_Questionmark;
|
2008-05-24 20:56:19 +00:00
|
|
|
highest_attr++;
|
2007-03-29 06:16:00 +00:00
|
|
|
/* get the icon */
|
|
|
|
s = e+1;
|
2007-04-16 09:14:36 +00:00
|
|
|
if (*s == '*')
|
2010-11-09 14:35:19 +00:00
|
|
|
file_type->icon = atoi(s+1);
|
2007-04-16 09:14:36 +00:00
|
|
|
else if (*s == '-')
|
2010-11-09 14:35:19 +00:00
|
|
|
file_type->icon = Icon_NOICON;
|
2007-04-16 12:26:49 +00:00
|
|
|
else if (*s >= '0' && *s <= '9')
|
2010-11-09 14:35:19 +00:00
|
|
|
file_type->icon = Icon_Last_Themeable + atoi(s);
|
2007-03-29 06:16:00 +00:00
|
|
|
filetype_count++;
|
2004-05-21 20:08:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-29 06:16:00 +00:00
|
|
|
int filetype_get_attr(const char* file)
|
2005-03-07 20:40:36 +00:00
|
|
|
{
|
2007-03-29 06:16:00 +00:00
|
|
|
char *extension = strrchr(file, '.');
|
2005-03-07 20:40:36 +00:00
|
|
|
int i;
|
2007-03-29 06:16:00 +00:00
|
|
|
if (!extension)
|
2005-03-07 20:40:36 +00:00
|
|
|
return 0;
|
2007-03-29 06:16:00 +00:00
|
|
|
extension++;
|
2010-11-27 12:57:19 +00:00
|
|
|
|
|
|
|
i = find_extension(extension);
|
|
|
|
if (i >= 0)
|
|
|
|
return (filetypes[i].attr<<8)&FILE_ATTR_MASK;
|
2007-03-29 06:16:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-03-07 20:40:36 +00:00
|
|
|
|
2007-03-29 06:16:00 +00:00
|
|
|
static int find_attr(int attr)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
/* skip the directory item */
|
|
|
|
if ((attr & ATTR_DIRECTORY)==ATTR_DIRECTORY)
|
2005-03-07 20:40:36 +00:00
|
|
|
return 0;
|
2007-03-29 06:16:00 +00:00
|
|
|
for (i=1; i<filetype_count; i++)
|
|
|
|
{
|
|
|
|
if ((attr>>8) == filetypes[i].attr)
|
|
|
|
return i;
|
2005-03-07 20:40:36 +00:00
|
|
|
}
|
2007-03-29 06:16:00 +00:00
|
|
|
return -1;
|
2005-03-07 20:40:36 +00:00
|
|
|
}
|
|
|
|
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2007-06-17 23:10:01 +00:00
|
|
|
int filetype_get_color(const char * name, int attr)
|
2007-06-17 21:16:34 +00:00
|
|
|
{
|
2007-06-17 23:10:01 +00:00
|
|
|
char *extension;
|
|
|
|
int i;
|
|
|
|
if ((attr & ATTR_DIRECTORY)==ATTR_DIRECTORY)
|
|
|
|
return custom_colors[0];
|
|
|
|
extension = strrchr(name, '.');
|
|
|
|
if (!extension)
|
2013-06-05 22:35:09 +00:00
|
|
|
return unknown_file.color;
|
2007-06-17 23:10:01 +00:00
|
|
|
extension++;
|
2010-11-27 12:57:19 +00:00
|
|
|
|
|
|
|
i = find_extension(extension);
|
|
|
|
if (i >= 0)
|
|
|
|
return custom_colors[i];
|
2013-01-20 11:29:43 +00:00
|
|
|
return unknown_file.color;
|
2007-06-17 21:16:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-04-16 09:14:36 +00:00
|
|
|
int filetype_get_icon(int attr)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2007-03-29 06:16:00 +00:00
|
|
|
int index = find_attr(attr);
|
|
|
|
if (index < 0)
|
2013-01-20 11:29:43 +00:00
|
|
|
return unknown_file.icon;
|
2007-04-16 14:33:29 +00:00
|
|
|
if (custom_icons_loaded)
|
|
|
|
return custom_filetype_icons[index];
|
2007-04-16 09:14:36 +00:00
|
|
|
return filetypes[index].icon;
|
2007-03-29 06:16:00 +00:00
|
|
|
}
|
2004-05-21 20:08:24 +00:00
|
|
|
|
2021-10-20 20:05:21 +00:00
|
|
|
char* filetype_get_plugin(const struct entry* file, char *buffer, size_t buffer_len)
|
2007-03-29 06:16:00 +00:00
|
|
|
{
|
|
|
|
int index = find_attr(file->attr);
|
2021-10-20 20:05:21 +00:00
|
|
|
if (index < 0 || !buffer)
|
2007-03-29 06:16:00 +00:00
|
|
|
return NULL;
|
2021-10-21 04:03:52 +00:00
|
|
|
struct file_type *ft_indexed = &filetypes[index];
|
|
|
|
|
|
|
|
/* attempt to find a suitable viewer by file extension */
|
|
|
|
if(ft_indexed->plugin == NULL && ft_indexed->extension != NULL)
|
|
|
|
{
|
|
|
|
struct file_type *ft;
|
|
|
|
int i = filetype_count;
|
|
|
|
while (--i > index)
|
|
|
|
{
|
|
|
|
ft = &filetypes[i];
|
|
|
|
if (ft->plugin == NULL || ft->extension == NULL)
|
|
|
|
continue;
|
|
|
|
else if (strcmp(ft->extension, ft_indexed->extension) == 0)
|
|
|
|
{
|
|
|
|
/*splashf(HZ*3, "Found %d %s %s", i, ft->extension, ft->plugin);*/
|
|
|
|
ft_indexed = ft;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ft_indexed->plugin == NULL)
|
2007-04-16 11:01:41 +00:00
|
|
|
return NULL;
|
2021-10-21 04:03:52 +00:00
|
|
|
|
|
|
|
snprintf(buffer, buffer_len, "%s/%s." ROCK_EXTENSION,
|
|
|
|
PLUGIN_DIR, ft_indexed->plugin);
|
2021-10-20 20:05:21 +00:00
|
|
|
return buffer;
|
2007-03-29 06:16:00 +00:00
|
|
|
}
|
2004-05-21 20:08:24 +00:00
|
|
|
|
2010-11-09 14:35:19 +00:00
|
|
|
bool filetype_supported(int attr)
|
2007-03-29 06:16:00 +00:00
|
|
|
{
|
|
|
|
return find_attr(attr) >= 0;
|
|
|
|
}
|
2004-05-21 20:08:24 +00:00
|
|
|
|
2007-08-07 07:55:18 +00:00
|
|
|
/**** Open With Screen ****/
|
2007-10-21 00:11:47 +00:00
|
|
|
struct cb_data {
|
2008-05-24 20:56:19 +00:00
|
|
|
const char *current_file;
|
2007-10-21 00:11:47 +00:00
|
|
|
};
|
2008-04-09 15:25:17 +00:00
|
|
|
|
|
|
|
static enum themable_icons openwith_get_icon(int selected_item, void * data)
|
2007-08-07 07:55:18 +00:00
|
|
|
{
|
2010-11-09 14:35:19 +00:00
|
|
|
(void)data;
|
|
|
|
return filetypes[viewers[selected_item]].icon;
|
2007-08-07 07:55:18 +00:00
|
|
|
}
|
2008-04-09 15:25:17 +00:00
|
|
|
|
2009-08-20 16:47:44 +00:00
|
|
|
static const char* openwith_get_name(int selected_item, void * data,
|
|
|
|
char * buffer, size_t buffer_len)
|
2007-08-07 07:55:18 +00:00
|
|
|
{
|
2010-11-09 14:35:19 +00:00
|
|
|
(void)data; (void)buffer; (void)buffer_len;
|
|
|
|
const char *s = strrchr(filetypes[viewers[selected_item]].plugin, '/');
|
2007-08-07 07:55:18 +00:00
|
|
|
if (s)
|
|
|
|
return s+1;
|
2010-11-09 14:35:19 +00:00
|
|
|
else return filetypes[viewers[selected_item]].plugin;
|
2007-08-07 07:55:18 +00:00
|
|
|
}
|
2008-04-09 15:25:17 +00:00
|
|
|
|
2018-10-30 13:45:26 +00:00
|
|
|
static int openwith_get_talk(int selected_item, void * data)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
char viewer_filename[MAX_FILENAME];
|
2021-10-21 04:03:52 +00:00
|
|
|
snprintf(viewer_filename, MAX_FILENAME, "%s." ROCK_EXTENSION,
|
|
|
|
filetypes[viewers[selected_item]].plugin);
|
2018-10-30 13:45:26 +00:00
|
|
|
talk_file_or_spell(PLUGIN_DIR, viewer_filename,
|
|
|
|
NULL, false);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-29 06:16:00 +00:00
|
|
|
int filetype_list_viewers(const char* current_file)
|
|
|
|
{
|
2007-10-21 00:11:47 +00:00
|
|
|
struct simplelist_info info;
|
2021-10-21 07:10:56 +00:00
|
|
|
simplelist_info_init(&info, str(LANG_ONPLAY_OPEN_WITH), viewer_count, NULL);
|
2007-10-21 00:11:47 +00:00
|
|
|
info.get_name = openwith_get_name;
|
2009-12-16 08:36:46 +00:00
|
|
|
info.get_icon = global_settings.show_icons?openwith_get_icon:NULL;
|
2018-10-30 13:45:26 +00:00
|
|
|
info.get_talk = openwith_get_talk;
|
2021-10-21 07:10:56 +00:00
|
|
|
|
|
|
|
int ret = simplelist_show_list(&info);
|
|
|
|
|
|
|
|
if (info.selection >= 0) /* run user selected viewer */
|
|
|
|
{
|
|
|
|
char plugin[MAX_PATH];
|
|
|
|
int i = viewers[info.selection];
|
|
|
|
snprintf(plugin, MAX_PATH, "%s/%s." ROCK_EXTENSION,
|
|
|
|
PLUGIN_DIR, filetypes[i].plugin);
|
2022-11-19 15:15:22 +00:00
|
|
|
ret = plugin_load(plugin, current_file);
|
2021-10-21 07:10:56 +00:00
|
|
|
}
|
|
|
|
return ret;
|
2007-03-29 06:16:00 +00:00
|
|
|
}
|
2004-05-21 20:08:24 +00:00
|
|
|
|
2011-12-05 19:23:46 +00:00
|
|
|
int filetype_load_plugin(const char* plugin, const char* file)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2007-08-07 07:55:18 +00:00
|
|
|
int i;
|
2007-03-29 06:16:00 +00:00
|
|
|
char plugin_name[MAX_PATH];
|
2007-08-07 07:55:18 +00:00
|
|
|
char *s;
|
2010-11-09 14:35:19 +00:00
|
|
|
|
2007-08-07 07:55:18 +00:00
|
|
|
for (i=0;i<filetype_count;i++)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2007-08-07 07:55:18 +00:00
|
|
|
if (filetypes[i].plugin)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
2007-08-07 07:55:18 +00:00
|
|
|
s = strrchr(filetypes[i].plugin, '/');
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
if (!strcmp(s+1, plugin))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!strcmp(filetypes[i].plugin, plugin))
|
|
|
|
break;
|
2004-05-21 20:08:24 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-07 07:55:18 +00:00
|
|
|
if (i >= filetype_count)
|
|
|
|
return PLUGIN_ERROR;
|
2021-10-21 04:03:52 +00:00
|
|
|
snprintf(plugin_name, MAX_PATH, "%s/%s." ROCK_EXTENSION,
|
|
|
|
PLUGIN_DIR, filetypes[i].plugin);
|
2008-05-12 17:52:50 +00:00
|
|
|
return plugin_load(plugin_name, file);
|
2004-05-21 20:08:24 +00:00
|
|
|
}
|