| 1882 | } |
| 1883 | |
| 1884 | char *add_plugin_dir(struct plugins *plugins, const char *dir, bool error_ok) |
| 1885 | { |
| 1886 | struct dirent *di; |
| 1887 | DIR *d = opendir(dir); |
| 1888 | struct plugin *p; |
| 1889 | |
| 1890 | if (!d) { |
| 1891 | if (!error_ok && errno == ENOENT) |
| 1892 | return NULL; |
| 1893 | return tal_fmt(tmpctx, "Failed to open plugin-dir %s: %s", |
| 1894 | dir, strerror(errno)); |
| 1895 | } |
| 1896 | |
| 1897 | while ((di = readdir(d)) != NULL) { |
| 1898 | const char *fullpath; |
| 1899 | |
| 1900 | if (streq(di->d_name, ".") || streq(di->d_name, "..")) |
| 1901 | continue; |
| 1902 | fullpath = plugin_fullpath(tmpctx, dir, di->d_name); |
| 1903 | if (!fullpath) |
| 1904 | continue; |
| 1905 | if (plugin_blacklisted(plugins, fullpath)) { |
| 1906 | log_info(plugins->log, "%s: disabled via disable-plugin", |
| 1907 | fullpath); |
| 1908 | } else { |
| 1909 | p = plugin_register(plugins, fullpath, NULL, false, |
| 1910 | NULL, NULL); |
| 1911 | if (!p && !error_ok) { |
| 1912 | closedir(d); |
| 1913 | return tal_fmt(tmpctx, "Failed to register %s: %s", |
| 1914 | fullpath, strerror(errno)); |
| 1915 | } |
| 1916 | } |
| 1917 | } |
| 1918 | closedir(d); |
| 1919 | return NULL; |
| 1920 | } |
| 1921 | |
| 1922 | void clear_plugins(struct plugins *plugins) |
| 1923 | { |
no test coverage detected