]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
pluginlib: Update execprog class.
authorRadosław Korzeniewski <radoslaw@korzeniewski.net>
Tue, 19 Oct 2021 15:43:05 +0000 (17:43 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:56 +0000 (13:56 +0200)
bacula/src/plugins/fd/pluginlib/execprog.cpp
bacula/src/plugins/fd/pluginlib/execprog.h

index af68ce78fb2fa35b351adcf6b2dbe3fdc730f6e5..8d4c8fb527a3d4955c09f7a81d1f7a50071890d5 100644 (file)
  */
 void EXECPROG::terminate(bpContext *ctx, bool raise_error)
 {
-   if (is_closed()){
+   if (is_closed())
+   {
       return;
    }
 
    // after close_bpipe it is no longer available
    tstatus = close_bpipe(bpipe);
-   if (tstatus && raise_error){
+   if (tstatus && raise_error)
+   {
       /* error during close */
       berrno be;
       DMSG(ctx, DERROR, "Error closing command. Err=%s\n", be.bstrerror(tstatus));
@@ -66,22 +68,6 @@ void EXECPROG::terminate(bpContext *ctx, bool raise_error)
    bpipe = NULL;
 };
 
-/*
- * Run command and prepared parameters.
- */
-bool EXECPROG::execute_command(bpContext *ctx, const POOL_MEM &cmd, const POOL_MEM &args)
-{
-   return execute_command(ctx, cmd.c_str(), args.c_str());
-}
-
-/*
- * Run command and prepared parameters.
- */
-bool EXECPROG::execute_command(bpContext *ctx, const POOL_MEM &cmd)
-{
-   return execute_command(ctx, cmd.c_str());
-}
-
 /*
  * Run command and prepared parameters.
  *
@@ -92,11 +78,12 @@ bool EXECPROG::execute_command(bpContext *ctx, const POOL_MEM &cmd)
  *    True - when command execute successfully
  *    False - when execution return error
  */
-bool EXECPROG::execute_command(bpContext *ctx, const POOLMEM *cmd, const POOLMEM *args)
+bool EXECPROG::execute_command(bpContext *ctx, const char *cmd, const char *args)
 {
    POOL_MEM exe_cmd(PM_FNAME);
 
-   if (cmd == NULL){
+   if (cmd == NULL)
+   {
       /* cannot execute command NULL */
       DMSG0(ctx, DERROR, "Logic error: Cannot execute NULL command!\n");
       JMSG0(ctx, M_FATAL, "Logic error: Cannot execute NULL command!\n");
@@ -107,7 +94,8 @@ bool EXECPROG::execute_command(bpContext *ctx, const POOLMEM *cmd, const POOLMEM
    Mmsg(exe_cmd, "%s %s", cmd, args);
    DMSG(ctx, DINFO, "Executing: %s\n", exe_cmd.c_str());
    bpipe = open_bpipe(exe_cmd.c_str(), 0, "rw");
-   if (bpipe == NULL){
+   if (bpipe == NULL)
+   {
       berrno be;
       DMSG(ctx, DERROR, "Unable to run command. Err=%s\n", be.bstrerror());
       JMSG(ctx, M_FATAL, "Unable to run command. Err=%s\n", be.bstrerror());
index 1ecc8319564ef1dba3d31d712768a4fc2c3c68bf..e7700bb3cf76d5c6e89e69717de0eda216ce0afd 100644 (file)
@@ -170,9 +170,14 @@ public:
    inline int get_terminate_status() { return tstatus; };
 
    /* all you need is to simply execute the command first */
-   bool execute_command(bpContext *ctx, const POOLMEM *cmd, const POOLMEM *args = "");
-   bool execute_command(bpContext *ctx, const POOL_MEM &cmd, const POOL_MEM &args);
-   bool execute_command(bpContext *ctx, const POOL_MEM &cmd);
+   bool execute_command(bpContext *ctx, const char *cmd, const char *args = "");
+
+   /*
+    * Run command and prepared parameters.
+    */
+   inline bool execute_command(bpContext *ctx, const char *cmd, const POOL_MEM &args) { return execute_command(ctx, cmd, args.c_str()); }
+   inline bool execute_command(bpContext *ctx, const POOL_MEM &cmd, const POOL_MEM &args)  { return execute_command(ctx, cmd.c_str(), args.c_str()); }
+   inline bool execute_command(bpContext *ctx, const POOL_MEM &cmd) { return execute_command(ctx, cmd.c_str()); }
 
    /* then just simply read or write data to it */
    int32_t read_data(bpContext *ctx, POOLMEM *buf, int32_t len);