From: Eric Bollengier Date: Sun, 7 Nov 2010 09:46:25 +0000 (+0100) Subject: Allow some plugin variables to be available during loadPlugin() X-Git-Tag: Release-5.2.1~961 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f974a298000c3330fbe4d471d9575fdb77990dfc;p=bacula%2Fbacula Allow some plugin variables to be available during loadPlugin() --- diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index 8fb472f8f6..493368000e 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -951,24 +951,38 @@ static boffset_t my_plugin_blseek(BFILE *bfd, boffset_t offset, int whence) static bRC baculaGetValue(bpContext *ctx, bVariable var, void *value) { JCR *jcr; - if (!value || !ctx) { + if (!value) { return bRC_Error; } -// Dmsg1(dbglvl, "bacula: baculaGetValue var=%d\n", var); + + switch (var) { /* General variables, no need of ctx */ + case bVarFDName: + *((char **)value) = my_name; + break; + case bVarWorkingDir: + *(void **)value = me->working_directory; + break; + case bVarExePath: + *(char **)value = exepath; + break; + default: + break; + } + + if (!ctx) { /* Other variables need context */ + return bRC_Error; + } + jcr = ((bacula_ctx *)ctx->bContext)->jcr; if (!jcr) { return bRC_Error; } -// Dmsg1(dbglvl, "Bacula: jcr=%p\n", jcr); + switch (var) { case bVarJobId: *((int *)value) = jcr->JobId; Dmsg1(dbglvl, "Bacula: return bVarJobId=%d\n", jcr->JobId); break; - case bVarFDName: - *((char **)value) = my_name; - Dmsg1(dbglvl, "Bacula: return my_name=%s\n", my_name); - break; case bVarLevel: *((int *)value) = jcr->getJobLevel(); Dmsg1(dbglvl, "Bacula: return bVarJobLevel=%d\n", jcr->getJobLevel()); @@ -1015,17 +1029,16 @@ static bRC baculaGetValue(bpContext *ctx, bVariable var, void *value) } #endif return bRC_Error; - case bVarWorkingDir: - *(void **)value = me->working_directory; - break; case bVarWhere: *(char **)value = jcr->where; break; case bVarRegexWhere: *(char **)value = jcr->RegexWhere; break; + + case bVarFDName: /* get warning with g++ if we missed one */ + case bVarWorkingDir: case bVarExePath: - *(char **)value = exepath; break; } return bRC_OK;