summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-07-28 09:57:35 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-07-28 09:57:35 (GMT)
commit81a4be1d7f2621a899c23db6243ce5aefddbbe93 (patch)
treeaba9f0db3ae6379fc58c44106a815647fd49e976 /plugins
parent77f88a59bfb9296df7e995e99218d27862136588 (diff)
Replaced the deprecated readdir_r() function by readdir() calls.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pychrysa/pychrysa.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c
index f09c234..f959671 100644
--- a/plugins/pychrysa/pychrysa.c
+++ b/plugins/pychrysa/pychrysa.c
@@ -24,6 +24,7 @@
#include "pychrysa.h"
+#include <errno.h>
#include <pygobject.h>
#include <stdio.h>
#include <stdbool.h>
@@ -485,9 +486,7 @@ static bool load_python_plugins(GPluginModule *plugin, GObject *ref)
char *save; /* Sauvegarde pour ré-entrance */
char *path; /* Chemin à fouiller */
DIR *dir; /* Répertoire à parcourir */
- struct dirent entry; /* Elément trouvé */
- struct dirent *next; /* Prochain élément fourni */
- int ret; /* Bilan d'un appel système */
+ struct dirent *entry; /* Elément trouvé */
char *modname; /* Nom du module pour Python */
char *filename; /* Chemin d'accès reconstruit */
GPluginModule *pyplugin; /* Lien vers un grffon Python */
@@ -511,20 +510,31 @@ static bool load_python_plugins(GPluginModule *plugin, GObject *ref)
_("Looking for Python plugins in '%s'..."),
path);
- for (ret = readdir_r(dir, &entry, &next);
- ret == 0 && next != NULL;
- ret = readdir_r(dir, &entry, &next))
+ while (1)
{
- if (entry.d_type != DT_DIR) continue;
- if (entry.d_name[0] == '.') continue;
+ errno = 0;
- modname = strdup(entry.d_name);
+ entry = readdir(dir);
+
+ if (entry == NULL)
+ {
+ if (errno != 0)
+ perror("readdir");
+
+ break;
+
+ }
+
+ if (entry->d_type != DT_DIR) continue;
+ if (entry->d_name[0] == '.') continue;
+
+ modname = strdup(entry->d_name);
modname = stradd(modname, ".");
modname = stradd(modname, "__init__");
filename = strdup(path);
filename = stradd(filename, G_DIR_SEPARATOR_S);
- filename = stradd(filename, entry.d_name);
+ filename = stradd(filename, entry->d_name);
pyplugin = g_python_plugin_new(modname, filename, ref);