]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/bvfs.h
Add %D option to edit_job_code, simplify callbacks on director side
[bacula/bacula] / bacula / src / cats / bvfs.h
index 8eb06c689cf41947074ff335eb455917ecdc102f..5e5f39fb5aedcc18b59b12bad3c70e1106a93752 100644 (file)
@@ -6,7 +6,7 @@
    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
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    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
+   You should have received a copy of the GNU Affero 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.
 
 /* Helper for result handler */
 typedef enum {
-   BVFS_FILE_RECORD  = 5,
-   BVFS_DIR_RECORD   = 4,
-   BVFS_FILE_VERSION = 6
+   BVFS_FILE_RECORD  = 'F',
+   BVFS_DIR_RECORD   = 'D',
+   BVFS_FILE_VERSION = 'V'
 } bvfs_handler_type;
 
 typedef enum {
-   BVFS_Id      = 0,
-   BVFS_Name    = 1,
-   BVFS_JobId   = 2,
-   BVFS_LStat   = 3,
+   BVFS_Type    = 0,            /* Could be D, F, V */
+   BVFS_PathId  = 1, 
+   BVFS_FilenameId = 2,
 
-   /* Only if File record */
-   BVFS_FileId  = 4,
+   BVFS_Name    = 3,
+   BVFS_JobId   = 4,
+
+   BVFS_LStat   = 5,            /* Can be empty for missing directories */
+   BVFS_FileId  = 6,            /* Can be empty for missing directories */
 
    /* Only if File Version record */
-   BVFS_Md5     = 1,
-   BVFS_VolName = 4,
-   BVFS_VolInchanger = 5
+   BVFS_Md5     = 3,
+   BVFS_VolName = 7,
+   BVFS_VolInchanger = 8
 } bvfs_row_index;
 
 class Bvfs {
@@ -70,13 +72,8 @@ public:
    Bvfs(JCR *j, B_DB *mdb);
    virtual ~Bvfs();
 
-   void set_jobid(JobId_t id) {
-      Mmsg(jobids.list, "%lld", (uint64_t)id);
-   }
-
-   void set_jobids(char *ids) {
-      pm_strcpy(jobids.list, ids);
-   }
+   void set_jobid(JobId_t id);
+   void set_jobids(char *ids);
 
    void set_limit(uint32_t max) {
       limit = max;
@@ -87,8 +84,8 @@ public:
    }
 
    void set_pattern(char *p) {
-      uint32_t len = strlen(p)*2+1;
-      pattern = check_pool_memory_size(pattern, len);
+      uint32_t len = strlen(p);
+      pattern = check_pool_memory_size(pattern, len*2+1);
       db_escape_string(jcr, db, pattern, p, len);
    }
 
@@ -115,14 +112,22 @@ public:
 
    void update_cache();
 
-   void set_see_all_version(bool val) {
-      see_all_version = val;
+   void set_see_all_versions(bool val) {
+      see_all_versions = val;
    }
 
    void set_see_copies(bool val) {
       see_copies = val;
    }
 
+   void filter_jobid();         /* Call after set_username */
+
+   void set_username(char *user) {
+      if (user) {
+         username = bstrdup(user);
+      }
+   }
+
    void set_handler(DB_RESULT_HANDLER *h, void *ctx) {
       list_entries = h;
       user_data = ctx;
@@ -148,6 +153,16 @@ public:
       offset+=limit;
    }
 
+   /* Clear all cache */
+   void clear_cache();
+
+   /* Compute restore list */
+   bool compute_restore_list(char *fileid, char *dirid, char *hardlink, 
+                             char *output_table);
+   
+   /* Drop previous restore list */
+   bool drop_restore_list(char *output_table);
+
    /* for internal use */
    int _handle_path(void *, int, char **);
    
@@ -157,7 +172,8 @@ private:
 
    JCR *jcr;
    B_DB *db;
-   db_list_ctx jobids;
+   POOLMEM *jobids;
+   char *username;              /* Used with Bweb */
    uint32_t limit;
    uint32_t offset;
    uint32_t nb_record;          /* number of records of the last query */
@@ -167,7 +183,7 @@ private:
    POOLMEM *prev_dir; /* ls_dirs query returns all versions, take the 1st one */
    ATTR *attr;        /* Can be use by handler to call decode_stat() */
 
-   bool see_all_version;
+   bool see_all_versions;
    bool see_copies;
 
    DBId_t get_dir_filenameid();
@@ -176,7 +192,12 @@ private:
    void *user_data;
 };
 
-void bvfs_update_path_hierarchy_cache(JCR *jcr, B_DB *mdb, db_list_ctx *jobids);
+#define bvfs_is_dir(row) ((row)[BVFS_Type][0] == BVFS_DIR_RECORD)
+#define bvfs_is_file(row) ((row)[BVFS_Type][0] == BVFS_FILE_RECORD)
+#define bvfs_is_version(row) ((row)[BVFS_Type][0] == BVFS_FILE_VERSION)
+
+
+void bvfs_update_path_hierarchy_cache(JCR *jcr, B_DB *mdb, char *jobids);
 void bvfs_update_cache(JCR *jcr, B_DB *mdb);
 char *bvfs_parent_dir(char *path);