Skip to content

Commit

Permalink
Added usage to the plugin information block
Browse files Browse the repository at this point in the history
Now the plugin information block also offers a
usage entry. That way, we can include a basic
info about the usage of the plugin in the plugin
itself.

Also, the status filed now shows extended information
about each plugin.

Signed-off-by: Marco van Wieringen <marco.van.wieringen@bareos.com>
  • Loading branch information
pstorz authored and Marco van Wieringen committed Sep 5, 2013
1 parent e064b68 commit 3b9a101
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/dird/dir_plugins.h
Expand Up @@ -163,7 +163,7 @@ typedef enum {
} pDirVariable;

#define DIR_PLUGIN_MAGIC "*DirPluginData*"
#define DIR_PLUGIN_INTERFACE_VERSION 1
#define DIR_PLUGIN_INTERFACE_VERSION 2

typedef struct s_dirpluginFuncs {
uint32_t size;
Expand Down
2 changes: 1 addition & 1 deletion src/filed/fd_plugins.h
Expand Up @@ -293,7 +293,7 @@ typedef enum {

#define FD_PLUGIN_MAGIC "*FDPluginData*"

#define FD_PLUGIN_INTERFACE_VERSION 7
#define FD_PLUGIN_INTERFACE_VERSION 8

/*
* This is a set of function pointers that Bareos can call
Expand Down
42 changes: 29 additions & 13 deletions src/lib/plugins.c
Expand Up @@ -340,25 +340,41 @@ int list_plugins(alist *plugin_list, POOL_MEM &msg)
Plugin *plugin;

if (plugin_list->size() > 0) {
pm_strcpy(msg, "Plugin: ");
pm_strcpy(msg, "Plugin Info:\n");
foreach_alist(plugin, plugin_list) {
pm_strcat(msg, " Plugin : ");
len = pm_strcat(msg, plugin->file);
/*
* Print plugin version when debug activated
*/
if (debug_level > 0 && plugin->pinfo) {
if (plugin->pinfo) {
genpInfo *info = (genpInfo *)plugin->pinfo;
pm_strcat(msg, "(");
pm_strcat(msg, "\n");
pm_strcat(msg, " Description: ");
pm_strcat(msg, NPRT(info->plugin_description));
pm_strcat(msg, "\n");

pm_strcat(msg, " Version : ");
pm_strcat(msg, NPRT(info->plugin_version));
len = pm_strcat(msg, ")");
}
if (len > 80) {
pm_strcat(msg, "\n ");
} else {
pm_strcat(msg, " ");
pm_strcat(msg, ", Date: ");
pm_strcat(msg, NPRT(info->plugin_date));
pm_strcat(msg, "\n");

pm_strcat(msg, " Author : ");
pm_strcat(msg, NPRT(info->plugin_author));
pm_strcat(msg, "\n");

pm_strcat(msg, " License : ");
pm_strcat(msg, NPRT(info->plugin_license));
pm_strcat(msg, "\n");

if (info->plugin_usage) {
pm_strcat(msg, " Usage : ");
pm_strcat(msg, info->plugin_usage);
pm_strcat(msg, "\n");
}

pm_strcat(msg, "\n");
}
}
len = pm_strcat(msg, "\n");
len = pm_strcat(msg, "\n");
}

return len;
Expand Down
1 change: 1 addition & 0 deletions src/lib/plugins.h
Expand Up @@ -82,6 +82,7 @@ typedef struct gen_pluginInfo {
const char *plugin_date;
const char *plugin_version;
const char *plugin_description;
const char *plugin_usage;
} genpInfo;

/* Functions */
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/dird/python-dir.c
Expand Up @@ -38,6 +38,7 @@
#define PLUGIN_DATE "August 2012"
#define PLUGIN_VERSION "1"
#define PLUGIN_DESCRIPTION "Python Director Daemon Plugin"
#define PLUGIN_USAGE "(No usage yet)"

/* Forward referenced functions */
static bRC newPlugin(bpContext *ctx);
Expand All @@ -58,7 +59,8 @@ static genpInfo pluginInfo = {
PLUGIN_AUTHOR,
PLUGIN_DATE,
PLUGIN_VERSION,
PLUGIN_DESCRIPTION
PLUGIN_DESCRIPTION,
PLUGIN_USAGE
};

static pDirFuncs pluginFuncs = {
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/filed/bpipe-fd.c
Expand Up @@ -34,6 +34,10 @@ static const int dbglvl = 150;
#define PLUGIN_DATE "January 2008"
#define PLUGIN_VERSION "1"
#define PLUGIN_DESCRIPTION "Bareos Pipe File Daemon Plugin"
#define PLUGIN_USAGE "bpipe:<filepath>:<readprogram>:<writeprogram>\n" \
" readprogram runs on backup and its stdout is saved\n" \
" writeprogram runs on restore and gets restored data into stdin\n" \
" the data is internally stored as filepath (e.g. mybackup/backup1)"

/* Forward referenced functions */
static bRC newPlugin(bpContext *ctx);
Expand Down Expand Up @@ -65,7 +69,8 @@ static genpInfo pluginInfo = {
PLUGIN_AUTHOR,
PLUGIN_DATE,
PLUGIN_VERSION,
PLUGIN_DESCRIPTION
PLUGIN_DESCRIPTION,
PLUGIN_USAGE
};

/* Plugin entry points for Bareos */
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/filed/example-plugin-fd.c
Expand Up @@ -50,7 +50,7 @@ static genpInfo pluginInfo = {
PLUGIN_AUTHOR,
PLUGIN_DATE,
PLUGIN_VERSION,
PLUGIN_DESCRIPTION,
PLUGIN_DESCRIPTION
};

static pFuncs pluginFuncs = {
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/filed/python-fd.c
Expand Up @@ -40,6 +40,7 @@
#define PLUGIN_DATE "August 2012"
#define PLUGIN_VERSION "1"
#define PLUGIN_DESCRIPTION "Python File Daemon Plugin"
#define PLUGIN_USAGE "(No usage yet)"

/* Forward referenced functions */
static bRC newPlugin(bpContext *ctx);
Expand Down Expand Up @@ -69,6 +70,7 @@ static genpInfo pluginInfo = {
PLUGIN_DATE,
PLUGIN_VERSION,
PLUGIN_DESCRIPTION,
PLUGIN_USAGE
};

static pFuncs pluginFuncs = {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/filed/test-deltaseq-fd.c
Expand Up @@ -62,7 +62,7 @@ static genpInfo pluginInfo = {
PLUGIN_AUTHOR,
PLUGIN_DATE,
PLUGIN_VERSION,
PLUGIN_DESCRIPTION,
PLUGIN_DESCRIPTION
};

/* Plugin entry points for Bareos */
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/stored/autoxflate-sd.c
Expand Up @@ -39,6 +39,7 @@
#define PLUGIN_DATE "June 2013"
#define PLUGIN_VERSION "1"
#define PLUGIN_DESCRIPTION "Auto Xflation Storage Daemon Plugin"
#define PLUGIN_USAGE "(No usage yet)"

/*
* Forward referenced functions
Expand Down Expand Up @@ -71,7 +72,8 @@ static genpInfo pluginInfo = {
PLUGIN_AUTHOR,
PLUGIN_DATE,
PLUGIN_VERSION,
PLUGIN_DESCRIPTION
PLUGIN_DESCRIPTION,
PLUGIN_USAGE
};

static psdFuncs pluginFuncs = {
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/stored/python-sd.c
Expand Up @@ -38,6 +38,7 @@
#define PLUGIN_DATE "August 2012"
#define PLUGIN_VERSION "1"
#define PLUGIN_DESCRIPTION "Python Storage Daemon Plugin"
#define PLUGIN_USAGE "(No usage yet)"

/* Forward referenced functions */
static bRC newPlugin(bpContext *ctx);
Expand All @@ -59,7 +60,8 @@ static genpInfo pluginInfo = {
PLUGIN_AUTHOR,
PLUGIN_DATE,
PLUGIN_VERSION,
PLUGIN_DESCRIPTION
PLUGIN_DESCRIPTION,
PLUGIN_USAGE
};

static psdFuncs pluginFuncs = {
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/stored/scsicrypto-sd.c
Expand Up @@ -66,6 +66,7 @@
#define PLUGIN_DATE "March 2012"
#define PLUGIN_VERSION "1"
#define PLUGIN_DESCRIPTION "SCSI Encryption Storage Daemon Plugin"
#define PLUGIN_USAGE "(No usage yet)"

/*
* Forward referenced functions
Expand Down Expand Up @@ -95,7 +96,8 @@ static genpInfo pluginInfo = {
PLUGIN_AUTHOR,
PLUGIN_DATE,
PLUGIN_VERSION,
PLUGIN_DESCRIPTION
PLUGIN_DESCRIPTION,
PLUGIN_USAGE
};

static psdFuncs pluginFuncs = {
Expand Down
2 changes: 1 addition & 1 deletion src/stored/sd_plugins.h
Expand Up @@ -176,7 +176,7 @@ typedef enum {
} psdVariable;

#define SD_PLUGIN_MAGIC "*SDPluginData*"
#define SD_PLUGIN_INTERFACE_VERSION 1
#define SD_PLUGIN_INTERFACE_VERSION 2

/*
* Functions that must be defined in every plugin
Expand Down
41 changes: 14 additions & 27 deletions src/tools/bpluginfo.c
Expand Up @@ -355,42 +355,29 @@ void dump_pluginfo(progdata *pdata)
switch (pdata->bplugtype) {
case DIRPLUGIN:
printf("\nPlugin type:\t\tBareos Director plugin\n");
if (pdata->verbose) {
printf("Plugin magic:\t\t%s\n", NPRT(pinfo->plugin_magic));
}
printf("Plugin version:\t\t%s\n", pinfo->plugin_version);
printf("Plugin release date:\t%s\n", NPRT(pinfo->plugin_date));
printf("Plugin author:\t\t%s\n", NPRT(pinfo->plugin_author));
printf("Plugin licence:\t\t%s\n", NPRT(pinfo->plugin_license));
printf("Plugin description:\t%s\n", NPRT(pinfo->plugin_description));
printf("Plugin API version:\t%d\n", pinfo->version);
break;
case FDPLUGIN:
printf("\nPlugin type:\t\tBareos File Daemon plugin\n");
if (pdata->verbose) {
printf("Plugin magic:\t\t%s\n", NPRT(pinfo->plugin_magic));
}
printf("Plugin version:\t\t%s\n", pinfo->plugin_version);
printf("Plugin release date:\t%s\n", NPRT(pinfo->plugin_date));
printf("Plugin author:\t\t%s\n", NPRT(pinfo->plugin_author));
printf("Plugin licence:\t\t%s\n", NPRT(pinfo->plugin_license));
printf("Plugin description:\t%s\n", NPRT(pinfo->plugin_description));
printf("Plugin API version:\t%d\n", pinfo->version);
break;
case SDPLUGIN:
printf("\nPlugin type:\t\tBareos Storage plugin\n");
if (pdata->verbose) {
printf("Plugin magic:\t\t%s\n", NPRT(pinfo->plugin_magic));
}
printf("Plugin version:\t\t%s\n", pinfo->plugin_version);
printf("Plugin release date:\t%s\n", NPRT(pinfo->plugin_date));
printf("Plugin author:\t\t%s\n", NPRT(pinfo->plugin_author));
printf("Plugin licence:\t\t%s\n", NPRT(pinfo->plugin_license));
printf("Plugin description:\t%s\n", NPRT(pinfo->plugin_description));
printf("Plugin API version:\t%d\n", pinfo->version);
break;
default:
printf("\nUnknown plugin type or other Error\n\n");
return;
}

if (pdata->verbose) {
printf("Plugin magic:\t\t%s\n", NPRT(pinfo->plugin_magic));
}
printf("Plugin version:\t\t%s\n", pinfo->plugin_version);
printf("Plugin release date:\t%s\n", NPRT(pinfo->plugin_date));
printf("Plugin author:\t\t%s\n", NPRT(pinfo->plugin_author));
printf("Plugin licence:\t\t%s\n", NPRT(pinfo->plugin_license));
printf("Plugin description:\t%s\n", NPRT(pinfo->plugin_description));
printf("Plugin API version:\t%d\n", pinfo->version);
if (pinfo->plugin_usage) {
printf("Plugin usage:\n%s\n", pinfo->plugin_usage);
}
}

Expand Down

0 comments on commit 3b9a101

Please sign in to comment.