]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/plugins/fd/example-plugin-fd.c
Merge branch 'master' into mvw/plugin-changes
[bacula/bacula] / bacula / src / plugins / fd / example-plugin-fd.c
index 01e30d3d3072faa80587e6539d35b2645c888849..4fc93ae1a6132adb0f3fd1de7180060ed1e2cafb 100644 (file)
@@ -1,45 +1,23 @@
 /*
-   Bacula® - The Network Backup Solution
-
-   Copyright (C) 2007-2008 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.
-   This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
-   License as published by the Free Software Foundation, which is 
-   listed in the file LICENSE.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Bacula® is a registered trademark of John Walker.
-   The licensor of Bacula is the Free Software Foundation Europe
-   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
-   Switzerland, email:ftf@fsfeurope.org.
+
+   Copyright (C) 2007-2008 Kern Sibbald
+
+   You may freely use this code to create your own plugin provided
+   it is to write a plugin for Bacula licensed under GPLv2
+   (as Bacula is), and in that case, you may also remove
+   the above Copyright and this notice as well as modify 
+   the code in any way. 
+
 */
-/*
- * Sample Plugin program
- *
- *  Kern Sibbald, October 2007
- *
- */
-#include <stdio.h>
-#include "fd-plugins.h"
+#include "bacula.h"
+#include "fd_plugins.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 #define PLUGIN_LICENSE      "GPL"
-#define PLUGIN_AUTHOR       "Kern Sibbald"
+#define PLUGIN_AUTHOR       "Your name"
 #define PLUGIN_DATE         "January 2008"
 #define PLUGIN_VERSION      "1"
 #define PLUGIN_DESCRIPTION  "Test File Daemon Plugin"
@@ -50,8 +28,13 @@ static bRC freePlugin(bpContext *ctx);
 static bRC getPluginValue(bpContext *ctx, pVariable var, void *value);
 static bRC setPluginValue(bpContext *ctx, pVariable var, void *value);
 static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value);
-static bRC startPluginBackup(bpContext *ctx, struct save_pkt *sp);
+static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp);
+static bRC endBackupFile(bpContext *ctx);
 static bRC pluginIO(bpContext *ctx, struct io_pkt *io);
+static bRC startRestoreFile(bpContext *ctx, const char *cmd);
+static bRC endRestoreFile(bpContext *ctx);
+static bRC createFile(bpContext *ctx, struct restore_pkt *rp);
+static bRC setFileAttributes(bpContext *ctx, struct restore_pkt *rp);
 
 
 /* Pointers to Bacula functions */
@@ -60,8 +43,8 @@ static bInfo  *binfo = NULL;
 
 static pInfo pluginInfo = {
    sizeof(pluginInfo),
-   PLUGIN_INTERFACE_VERSION,
-   PLUGIN_MAGIC,
+   FD_PLUGIN_INTERFACE_VERSION,
+   FD_PLUGIN_MAGIC,
    PLUGIN_LICENSE,
    PLUGIN_AUTHOR,
    PLUGIN_DATE,
@@ -71,7 +54,7 @@ static pInfo pluginInfo = {
 
 static pFuncs pluginFuncs = {
    sizeof(pluginFuncs),
-   PLUGIN_INTERFACE_VERSION,
+   FD_PLUGIN_INTERFACE_VERSION,
 
    /* Entry points into plugin */
    newPlugin,                         /* new plugin instance */
@@ -79,8 +62,13 @@ static pFuncs pluginFuncs = {
    getPluginValue,
    setPluginValue,
    handlePluginEvent,
-   startPluginBackup,
-   pluginIO
+   startBackupFile,
+   endBackupFile,
+   startRestoreFile,
+   endRestoreFile,
+   pluginIO,
+   createFile,
+   setFileAttributes
 };
 
 bRC loadPlugin(bInfo *lbinfo, bFuncs *lbfuncs, pInfo **pinfo, pFuncs **pfuncs)
@@ -136,27 +124,37 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
 
    switch (event->eventType) {
    case bEventJobStart:
-      printf("plugin: JobStart=%s\n", (char *)value);
+      printf("plugin: JobStart=%s\n", NPRT((char *)value));
       break;
    case bEventJobEnd:
       printf("plugin: JobEnd\n");
       break;
-   case bEventBackupStart:
+   case bEventStartBackupJob:
       printf("plugin: BackupStart\n");
       break;
-   case bEventBackupEnd:
+   case bEventEndBackupJob:
       printf("plugin: BackupEnd\n");
       break;
    case bEventLevel:
-      printf("plugin: JobLevel=%c %d\n", (int)value, (int)value);
+      printf("plugin: JobLevel=%c %d\n", (int64_t)value, (int64_t)value);
       break;
    case bEventSince:
-      printf("plugin: since=%d\n", (int)value);
+      printf("plugin: since=%d\n", (int64_t)value);
+      break;
+   case bEventStartRestoreJob:
+      printf("plugin: StartRestoreJob\n");
+      break;
+   case bEventEndRestoreJob:
+      printf("plugin: EndRestoreJob\n");
       break;
 
    /* Plugin command e.g. plugin = <plugin-name>:<name-space>:command */
-   case bEventPluginCommand:
-      printf("plugin: command=%s\n", (char *)value);
+   case bEventRestoreCommand:
+      printf("plugin: backup command=%s\n", NPRT((char *)value));
+      break;
+
+   case bEventBackupCommand:
+      printf("plugin: backup command=%s\n", NPRT((char *)value));
       break;
 
    default:
@@ -169,11 +167,16 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
    return bRC_OK;
 }
 
-static bRC startPluginBackup(bpContext *ctx, struct save_pkt *sp)
+static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp)
 {
    return bRC_OK;
 }
 
+static bRC endBackupFile(bpContext *ctx)
+{ 
+   return bRC_OK;
+}
+
 /*
  * Do actual I/O
  */
@@ -198,6 +201,27 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
    return bRC_OK;
 }
 
+static bRC startRestoreFile(bpContext *ctx, const char *cmd)
+{
+   return bRC_OK;
+}
+
+static bRC endRestoreFile(bpContext *ctx)
+{
+   return bRC_OK;
+}
+
+static bRC createFile(bpContext *ctx, struct restore_pkt *rp)
+{
+   return bRC_OK;
+}
+
+static bRC setFileAttributes(bpContext *ctx, struct restore_pkt *rp)
+{
+   return bRC_OK;
+}
+
+
 #ifdef __cplusplus
 }
 #endif