mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 14:26:39 +02:00
Do not auto-load hidden files in script plugins (bug #21390)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
WeeChat ChangeLog
|
||||
=================
|
||||
FlashCode <flashcode@flashtux.org>
|
||||
v0.3.0-dev, 2009-06-13
|
||||
v0.3.0-dev, 2009-06-14
|
||||
|
||||
|
||||
Version 0.3.0 (under dev!)
|
||||
@@ -38,6 +38,7 @@ Version 0.3.0 (under dev!)
|
||||
protocol), go.py (quick jump to buffers), buffers.pl (sidebar with list of
|
||||
buffers), iset.pl (set options interactively), weetris.pl (tetris-like game),
|
||||
mastermind.pl, ...
|
||||
* scripts: do not auto-load hidden files (bug #21390)
|
||||
* api: add hooks: command, timer, file descriptor, process, connection, print,
|
||||
signal, config, completion, modifier, info, infolist
|
||||
* api: new plugin API with many new functions: hooks, buffer management and
|
||||
|
||||
@@ -1549,7 +1549,9 @@ Prototype:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
void weechat_exec_on_files (const char *directory, void *data,
|
||||
void weechat_exec_on_files (const char *directory,
|
||||
int hidden_files,
|
||||
void *data,
|
||||
int (*callback)(void *data,
|
||||
const char *filename));
|
||||
----------------------------------------
|
||||
@@ -1557,6 +1559,7 @@ void weechat_exec_on_files (const char *directory, void *data,
|
||||
Arguments:
|
||||
|
||||
* 'directory': directory for searching files
|
||||
* 'hidden_files': include hidden files
|
||||
* 'data': pointer given to callback when it is called by WeeChat
|
||||
* 'callback': function called for each file found, arguments:
|
||||
** 'void *data': pointer
|
||||
@@ -1572,7 +1575,7 @@ int callback (void *data, const char *filename)
|
||||
return 1;
|
||||
}
|
||||
...
|
||||
weechat_exec_on_files (plugin, "/tmp", &callback);
|
||||
weechat_exec_on_files ("/tmp", 0, NULL, &callback);
|
||||
----------------------------------------
|
||||
|
||||
[[util]]
|
||||
|
||||
@@ -615,6 +615,7 @@ void
|
||||
upgrade_weechat_remove_files ()
|
||||
{
|
||||
util_exec_on_files (weechat_home,
|
||||
0,
|
||||
NULL,
|
||||
&upgrade_weechat_remove_file_cb);
|
||||
}
|
||||
|
||||
+9
-6
@@ -255,7 +255,7 @@ util_mkdir_parents (const char *directory, int mode)
|
||||
*/
|
||||
|
||||
void
|
||||
util_exec_on_files (const char *directory, void *data,
|
||||
util_exec_on_files (const char *directory, int hidden_files, void *data,
|
||||
void (*callback)(void *data, const char *filename))
|
||||
{
|
||||
char complete_filename[1024];
|
||||
@@ -271,12 +271,15 @@ util_exec_on_files (const char *directory, void *data,
|
||||
{
|
||||
while ((entry = readdir (dir)))
|
||||
{
|
||||
snprintf (complete_filename, sizeof (complete_filename) - 1,
|
||||
"%s/%s", directory, entry->d_name);
|
||||
lstat (complete_filename, &statbuf);
|
||||
if (!S_ISDIR(statbuf.st_mode))
|
||||
if (hidden_files || (entry->d_name[0] != '.'))
|
||||
{
|
||||
(*callback) (data, complete_filename);
|
||||
snprintf (complete_filename, sizeof (complete_filename) - 1,
|
||||
"%s/%s", directory, entry->d_name);
|
||||
lstat (complete_filename, &statbuf);
|
||||
if (!S_ISDIR(statbuf.st_mode))
|
||||
{
|
||||
(*callback) (data, complete_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
+2
-1
@@ -28,7 +28,8 @@ extern void util_catch_signal (int signum, void (*handler)(int));
|
||||
extern int util_mkdir_home (const char *directory, int mode);
|
||||
extern int util_mkdir (const char *directory, int mode);
|
||||
extern int util_mkdir_parents (const char *directory, int mode);
|
||||
extern void util_exec_on_files (const char *directory, void *data,
|
||||
extern void util_exec_on_files (const char *directory, int hidden_files,
|
||||
void *data,
|
||||
void (*callback)(void *data,
|
||||
const char *filename));
|
||||
extern char *util_search_full_lib_name (const char *filename,
|
||||
|
||||
@@ -697,6 +697,7 @@ plugin_auto_load ()
|
||||
util_exec_on_files ((plugin_path2) ?
|
||||
plugin_path2 : ((plugin_path) ?
|
||||
plugin_path : CONFIG_STRING(config_plugin_path)),
|
||||
0,
|
||||
NULL,
|
||||
&plugin_auto_load_file);
|
||||
if (plugin_path)
|
||||
@@ -711,7 +712,7 @@ plugin_auto_load ()
|
||||
{
|
||||
snprintf (dir_name, strlen (WEECHAT_LIBDIR) + 16,
|
||||
"%s/plugins", WEECHAT_LIBDIR);
|
||||
util_exec_on_files (dir_name, NULL, &plugin_auto_load_file);
|
||||
util_exec_on_files (dir_name, 0, NULL, &plugin_auto_load_file);
|
||||
free (dir_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
||||
|
||||
snprintf (dir_name, dir_length,
|
||||
"%s/%s/autoload", dir_home, weechat_plugin->name);
|
||||
weechat_exec_on_files (dir_name, NULL, callback);
|
||||
weechat_exec_on_files (dir_name, 0, NULL, callback);
|
||||
|
||||
free (dir_name);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ struct t_infolist;
|
||||
struct t_weelist;
|
||||
|
||||
/* API version (used to check that plugin has same API and can be loaded) */
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20090614-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20090614-02"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -193,7 +193,7 @@ struct t_weechat_plugin
|
||||
int (*mkdir_home) (const char *directory, int mode);
|
||||
int (*mkdir) (const char *directory, int mode);
|
||||
int (*mkdir_parents) (const char *directory, int mode);
|
||||
void (*exec_on_files) (const char *directory, void *data,
|
||||
void (*exec_on_files) (const char *directory, int hidden_files, void *data,
|
||||
void (*callback)(void *data, const char *filename));
|
||||
|
||||
/* util */
|
||||
@@ -751,8 +751,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
weechat_plugin->mkdir(__directory, __mode)
|
||||
#define weechat_mkdir_parents(__directory, __mode) \
|
||||
weechat_plugin->mkdir_parents(__directory, __mode)
|
||||
#define weechat_exec_on_files(__directory, __data, __callback) \
|
||||
weechat_plugin->exec_on_files(__directory, __data, __callback)
|
||||
#define weechat_exec_on_files(__directory, __hidden_files, __data, \
|
||||
__callback) \
|
||||
weechat_plugin->exec_on_files(__directory, __hidden_files, __data, \
|
||||
__callback)
|
||||
|
||||
/* util */
|
||||
#define weechat_timeval_cmp(__time1, __time2) \
|
||||
|
||||
Reference in New Issue
Block a user