]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/dir_plugins.c
Backport from Bacula Enterprise
[bacula/bacula] / bacula / src / dird / dir_plugins.c
index 6f693feb2044863d3f740d802a0c82ce0f5d3604..c6723414cacd75a46fa4fc7f42c4711021587b84 100644 (file)
@@ -1,17 +1,21 @@
 /*
-   Bacula® - The Network Backup Solution
+   Bacula(R) - The Network Backup Solution
 
+   Copyright (C) 2000-2015 Kern Sibbald
    Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
-   The main author of Bacula is Kern Sibbald, with contributions from many
-   others, a complete list can be found in the file AUTHORS.
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
 
    You may use this file and others of this release according to the
    license defined in the LICENSE file, which includes the Affero General
    Public License, v3.0 ("AGPLv3") and some additional permissions and
    terms pursuant to its AGPLv3 Section 7.
 
-   Bacula® is a registered trademark of Kern Sibbald.
+   This notice must be preserved when any source code is 
+   conveyed and/or propagated.
+
+   Bacula(R) is a registered trademark of Kern Sibbald.
 */
 /*
  * Main program to test loading and running Bacula plugins.
@@ -89,10 +93,10 @@ int generate_plugin_event(JCR *jcr, bDirEventType eventType, void *value)
    bpContext *plugin_ctx;
    bDirEvent event;
    Plugin *plugin;
-   int i;
+   int i = 0;
    bRC rc = bRC_OK;
 
-   if (!bplugin_list || !jcr || !jcr->plugin_ctx_list) {
+   if (!b_plugin_list || !jcr || !jcr->plugin_ctx_list) {
       return bRC_OK;                  /* Return if no plugins loaded */
    }
    if (jcr->is_job_canceled()) {
@@ -104,7 +108,7 @@ int generate_plugin_event(JCR *jcr, bDirEventType eventType, void *value)
 
    Dmsg2(dbglvl, "dir-plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId);
 
-   foreach_alist_index(i, plugin, bplugin_list) {
+   foreach_alist_index(i, plugin, b_plugin_list) {
       plugin_ctx = &plugin_ctx_list[i];
       if (is_plugin_disabled(plugin_ctx)) {
          continue;
@@ -145,18 +149,18 @@ void load_dir_plugins(const char *plugin_dir)
    Plugin *plugin;
    int i;
 
-   Dmsg0(dbglvl, "Load dir plugins\n");
+   Dmsg0(dbglvl, "Load Director plugins\n");
    if (!plugin_dir) {
-      Dmsg0(dbglvl, "No dir plugin dir!\n");
+      Dmsg0(dbglvl, "No Director plugin directory!\n");
       return;
    }
-   bplugin_list = New(alist(10, not_owned_by_alist));
+   b_plugin_list = New(alist(10, not_owned_by_alist));
    if (!load_plugins((void *)&binfo, (void *)&bfuncs, plugin_dir, plugin_type,
                 is_plugin_compatible)) {
       /* Either none found, or some error */
-      if (bplugin_list->size() == 0) {
-         delete bplugin_list;
-         bplugin_list = NULL;
+      if (b_plugin_list->size() == 0) {
+         delete b_plugin_list;
+         b_plugin_list = NULL;
          Dmsg0(dbglvl, "No plugins loaded\n");
          return;
       }
@@ -165,12 +169,12 @@ void load_dir_plugins(const char *plugin_dir)
     * Verify that the plugin is acceptable, and print information
     *  about it.
     */
-   foreach_alist_index(i, plugin, bplugin_list) {
+   foreach_alist_index(i, plugin, b_plugin_list) {
       Jmsg(NULL, M_INFO, 0, _("Loaded plugin: %s\n"), plugin->file);
       Dmsg1(dbglvl, "Loaded plugin: %s\n", plugin->file);
    }
 
-   Dmsg1(dbglvl, "num plugins=%d\n", bplugin_list->size());
+   Dmsg1(dbglvl, "num plugins=%d\n", b_plugin_list->size());
    dbg_plugin_add_hook(dump_dir_plugin);
 }
 
@@ -226,18 +230,18 @@ static bool is_plugin_compatible(Plugin *plugin)
 void new_plugins(JCR *jcr)
 {
    Plugin *plugin;
-   int i;
+   int i = 0;
 
    Dmsg0(dbglvl, "=== enter new_plugins ===\n");
-   if (!bplugin_list) {
-      Dmsg0(dbglvl, "No dir plugin list!\n");
+   if (!b_plugin_list) {
+      Dmsg0(dbglvl, "No Director plugin list!\n");
       return;
    }
    if (jcr->is_job_canceled()) {
       return;
    }
 
-   int num = bplugin_list->size();
+   int num = b_plugin_list->size();
 
    Dmsg1(dbglvl, "dir-plugin-list size=%d\n", num);
    if (num == 0) {
@@ -248,7 +252,7 @@ void new_plugins(JCR *jcr)
 
    bpContext *plugin_ctx_list = jcr->plugin_ctx_list;
    Dmsg2(dbglvl, "Instantiate dir-plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId);
-   foreach_alist_index(i, plugin, bplugin_list) {
+   foreach_alist_index(i, plugin, b_plugin_list) {
       /* Start a new instance of each plugin */
       bacula_ctx *b_ctx = (bacula_ctx *)malloc(sizeof(bacula_ctx));
       memset(b_ctx, 0, sizeof(bacula_ctx));
@@ -267,15 +271,15 @@ void new_plugins(JCR *jcr)
 void free_plugins(JCR *jcr)
 {
    Plugin *plugin;
-   int i;
+   int i = 0;
 
-   if (!bplugin_list || !jcr->plugin_ctx_list) {
+   if (!b_plugin_list || !jcr->plugin_ctx_list) {
       return;
    }
 
    bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
    Dmsg2(dbglvl, "Free instance dir-plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId);
-   foreach_alist_index(i, plugin, bplugin_list) {
+   foreach_alist_index(i, plugin, b_plugin_list) {
       /* Free the plugin instance */
       dirplug_func(plugin)->freePlugin(&plugin_ctx_list[i]);
       free(plugin_ctx_list[i].bContext);     /* free Bacula private context */