+}
+
+void initPlugins(AFB_session *session) {
+ static AFB_plugin **plugins;
+
+ afbJsonType = json_object_new_string (AFB_MSG_JTYPE);
+ int count = 0;
+ char *dirpath;
+ int dirfd;
+
+ /* pre-allocate for AFB_MAX_PLUGINS plugins, we will downsize later */
+ plugins = (AFB_plugin **) malloc (AFB_MAX_PLUGINS *sizeof(AFB_plugin));
+
+ // Loop on every directory passed in --plugins=xxx
+ while (dirpath = strsep(&session->config->ldpaths, ":")) {
+ // Ignore any directory we fail to open
+ if ((dirfd = open(dirpath, O_DIRECTORY)) <= 0) {
+ fprintf(stderr, "Invalid directory path=[%s]\n", dirpath);
+ continue;
+ }
+ scanDirectory (dirpath, dirfd, plugins, &count);
+ close (dirfd);
+ }