1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 05:46:38 +02:00

Improved script plugin loader

This commit is contained in:
Sebastien Helleu
2006-03-26 09:46:30 +00:00
parent 9abddbb7e9
commit 56af0e3284
4 changed files with 82 additions and 4 deletions
+39 -1
View File
@@ -96,9 +96,47 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
int length;
struct stat st;
if ((strstr(filename, "/")) || (strstr(filename, "\\")))
if (filename[0] == '~')
{
dir_home = getenv ("HOME");
if (!dir_home)
return NULL;
length = strlen (dir_home) + strlen (filename + 1) + 1;
final_name = (char *) malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s%s", dir_home, filename + 1);
return final_name;
}
return NULL;
}
#ifdef _WIN32
if (strstr(filename, "\\"))
#else
if (strstr(filename, "/"))
#endif
return strdup(filename);
/* try WeeChat user's autoload dir */
dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
if (dir_home)
{
length = strlen (dir_home) + strlen (language) + 8 + strlen (filename) + 16;
final_name = (char *) malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s/%s/autoload/%s", dir_home, language, filename);
if ((stat (final_name, &st) == 0) && (st.st_size > 0))
{
free (dir_home);
return final_name;
}
free (final_name);
}
free (dir_home);
}
/* try WeeChat user's dir */
dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
if (dir_home)