From c5ca4b74b8092db1bec4804aec81ab13bc77d05a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 14 Sep 2008 20:39:04 +0000 Subject: [PATCH] kes Modify the license of the example plugin program to allow it to be used by anyone for making a Bacula plugin. kes Make apply_rp_codes() in bpipe-fd.c be static. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7596 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/plugins/fd/bpipe-fd.c | 176 +++++++++++----------- bacula/src/plugins/fd/example-plugin-fd.c | 42 ++---- bacula/src/version.h | 4 +- bacula/technotes-2.5 | 4 + 4 files changed, 105 insertions(+), 121 deletions(-) diff --git a/bacula/src/plugins/fd/bpipe-fd.c b/bacula/src/plugins/fd/bpipe-fd.c index c211bb48c1..c6787d9035 100644 --- a/bacula/src/plugins/fd/bpipe-fd.c +++ b/bacula/src/plugins/fd/bpipe-fd.c @@ -61,6 +61,7 @@ static bRC endRestoreFile(bpContext *ctx); static bRC createFile(bpContext *ctx, struct restore_pkt *rp); static bRC setFileAttributes(bpContext *ctx, struct restore_pkt *rp); +static char *apply_rp_codes(struct plugin_ctx * p_ctx); /* Pointers to Bacula functions */ static bFuncs *bfuncs = NULL; @@ -290,93 +291,6 @@ static bRC endBackupFile(bpContext *ctx) return bRC_OK; } -/* - * Apply codes in writer command: - * %w -> "where" - * %r -> "replace" - * - * Replace: - * 'always' => 'a', chr(97) - * 'ifnewer' => 'w', chr(119) - * 'ifolder' => 'o', chr(111) - * 'never' => 'n', chr(110) - * - * This function will allocate the required amount of memory with malloc. - * Need to be free()d manually. - * Inspired by edit_job_codes in lib/util.c - */ - -char *apply_rp_codes(struct plugin_ctx * p_ctx) -{ - char *p, *q; - const char *str; - char add[10]; - int w_count = 0, r_count = 0; - char *omsg; - - char *imsg = p_ctx->writer; - - if (!imsg) { - return NULL; - } - - if ((p = imsg)) { - while ((q = strstr(p, "%w"))) { - w_count++; - p=q+1; - } - - p = imsg; - while ((q = strstr(p, "%r"))) { - r_count++; - p=q+1; - } - } - - /* Required mem: - * len(imsg) - * + number of "where" codes * (len(where)-2) - * - number of "replace" codes - */ - omsg = (char*)malloc(strlen(imsg) + (w_count * (strlen(p_ctx->where)-2)) - r_count + 1); - if (!omsg) { - fprintf(stderr, "Out of memory."); - exit(1); - } - - *omsg = 0; - //printf("apply_rp_codes: %s\n", imsg); - for (p=imsg; *p; p++) { - if (*p == '%') { - switch (*++p) { - case '%': - str = "%"; - break; - case 'w': - str = p_ctx->where; - break; - case 'r': - snprintf(add, 2, "%c", p_ctx->replace); - str = add; - break; - default: - add[0] = '%'; - add[1] = *p; - add[2] = 0; - str = add; - break; - } - } else { - add[0] = *p; - add[1] = 0; - str = add; - } - //printf("add_str %s\n", str); - strcat(omsg, str); - //printf("omsg=%s\n", omsg); - } - return omsg; -} /* * Bacula is calling us to do the actual I/O @@ -495,6 +409,94 @@ static bRC setFileAttributes(bpContext *ctx, struct restore_pkt *rp) return bRC_OK; } +/************************************************************************* + * Apply codes in writer command: + * %w -> "where" + * %r -> "replace" + * + * Replace: + * 'always' => 'a', chr(97) + * 'ifnewer' => 'w', chr(119) + * 'ifolder' => 'o', chr(111) + * 'never' => 'n', chr(110) + * + * This function will allocate the required amount of memory with malloc. + * Need to be free()d manually. + * Inspired by edit_job_codes in lib/util.c + */ + +static char *apply_rp_codes(struct plugin_ctx * p_ctx) +{ + char *p, *q; + const char *str; + char add[10]; + int w_count = 0, r_count = 0; + char *omsg; + + char *imsg = p_ctx->writer; + + if (!imsg) { + return NULL; + } + + if ((p = imsg)) { + while ((q = strstr(p, "%w"))) { + w_count++; + p=q+1; + } + + p = imsg; + while ((q = strstr(p, "%r"))) { + r_count++; + p=q+1; + } + } + + /* Required mem: + * len(imsg) + * + number of "where" codes * (len(where)-2) + * - number of "replace" codes + */ + omsg = (char*)malloc(strlen(imsg) + (w_count * (strlen(p_ctx->where)-2)) - r_count + 1); + if (!omsg) { + fprintf(stderr, "Out of memory."); + exit(1); + } + + *omsg = 0; + //printf("apply_rp_codes: %s\n", imsg); + for (p=imsg; *p; p++) { + if (*p == '%') { + switch (*++p) { + case '%': + str = "%"; + break; + case 'w': + str = p_ctx->where; + break; + case 'r': + snprintf(add, 2, "%c", p_ctx->replace); + str = add; + break; + default: + add[0] = '%'; + add[1] = *p; + add[2] = 0; + str = add; + break; + } + } else { + add[0] = *p; + add[1] = 0; + str = add; + } + //printf("add_str %s\n", str); + strcat(omsg, str); + //printf("omsg=%s\n", omsg); + } + return omsg; +} + #ifdef __cplusplus } diff --git a/bacula/src/plugins/fd/example-plugin-fd.c b/bacula/src/plugins/fd/example-plugin-fd.c index 7553e15a5b..458537f364 100644 --- a/bacula/src/plugins/fd/example-plugin-fd.c +++ b/bacula/src/plugins/fd/example-plugin-fd.c @@ -1,36 +1,14 @@ /* - 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 Kern Sibbald. - 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 #include "fd_plugins.h" @@ -39,7 +17,7 @@ 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" diff --git a/bacula/src/version.h b/bacula/src/version.h index 679e899a3e..ec0aea08fd 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.3" -#define BDATE "13 September 2008" -#define LSMDATE "13Sep08" +#define BDATE "14 September 2008" +#define LSMDATE "14Sep08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index a9615fa64d..696db3f6f8 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -18,6 +18,10 @@ dbdriver remove reader/writer in FOPTS???? General: +14Sep08 +kes Modify the license of the example plugin program to allow + it to be used by anyone for making a Bacula plugin. +kes Make apply_rp_codes() in bpipe-fd.c be static. 13Sep08 kes Remove Encryption and Accurate lines in vbackup output -- not used. kes Fix subtle bug in vbackup by not changing DEV_RECORD packet. -- 2.39.5