]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/cats.h
Add %D option to edit_job_code, simplify callbacks on director side
[bacula/bacula] / bacula / src / cats / cats.h
index a41ea7ac55520762e4be33b8b4126fe941f374c2..e83287a560f33688afafb06caa2e90ec0dc0f68e 100644 (file)
@@ -213,6 +213,7 @@ struct FILE_DBR {
    DBId_t FilenameId;
    DBId_t PathId;
    JobId_t  MarkId;
+   uint32_t DeltaSeq;
    char LStat[256];
    char Digest[BASE64_SIZE(CRYPTO_DIGEST_MAX_SIZE)];
    int DigestType;                    /* NO_SIG/MD5_SIG/SHA1_SIG */
@@ -370,9 +371,16 @@ struct FILESET_DBR {
 };
 
 /* Call back context for getting a 32/64 bit value from the database */
-struct db_int64_ctx {
+class db_int64_ctx {
+public:
    int64_t value;                     /* value returned */
    int count;                         /* number of values seen */
+
+   db_int64_ctx() : value(0), count(0) {};
+   ~db_int64_ctx() {};
+private:
+   db_int64_ctx(const db_int64_ctx&);            /* prohibit pass by value */
+   db_int64_ctx &operator=(const db_int64_ctx&); /* prohibit class assignment */
 };
 
 /* Call back context for getting a list of comma separated strings from the
@@ -386,7 +394,7 @@ public:
    db_list_ctx() { list = get_pool_memory(PM_FNAME); reset(); }
    ~db_list_ctx() { free_pool_memory(list); list = NULL; }
    void reset() { *list = 0; count = 0;}
-   void cat(const db_list_ctx &str) {
+   void add(const db_list_ctx &str) {
       if (str.count > 0) {
          if (*list) {
             pm_strcat(list, ",");
@@ -395,6 +403,13 @@ public:
          count += str.count;
       }
    }
+   void add(const char *str) {
+      if (count > 0) {
+         pm_strcat(list, ",");
+      }
+      pm_strcat(list, str);
+      count++;
+   }
 private:
    db_list_ctx(const db_list_ctx&);            /* prohibit pass by value */
    db_list_ctx &operator=(const db_list_ctx&); /* prohibit class assignment */
@@ -423,7 +438,7 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **);
 #define db_unlock(mdb) mdb->_db_unlock(__FILE__, __LINE__)
 
 /* Current database version number for all drivers */
-#define BDB_VERSION 13
+#define BDB_VERSION 14
 
 class B_DB: public SMARTALLOC {
 protected:
@@ -490,10 +505,16 @@ public:
    virtual void db_start_transaction(JCR *jcr) = 0;
    virtual void db_end_transaction(JCR *jcr) = 0;
    virtual bool db_sql_query(const char *query, DB_RESULT_HANDLER *result_handler, void *ctx) = 0;
+
+   /* By default, we use db_sql_query */
+   virtual bool db_big_sql_query(const char *query, 
+                                 DB_RESULT_HANDLER *result_handler, void *ctx) {
+      return db_sql_query(query, result_handler, ctx);
+   };
 };
 
 /* sql_query Query Flags */
-#define QF_STORE_RESULT        0x01
+#define QF_STORE_RESULT 0x01
 
 /* Use for better error location printing */
 #define UPDATE_DB(jcr, db, cmd) UpdateDB(__FILE__, __LINE__, jcr, db, cmd)
@@ -505,9 +526,46 @@ public:
 #include "jcr.h"
 #include "sql_cmds.h"
 
+/* Object used in db_list_xxx function */
+class LIST_CTX {
+public:
+   char line[256];              /* Used to print last dash line */
+   int32_t num_rows;
+
+   e_list_type type;            /* Vertical/Horizontal */
+   DB_LIST_HANDLER *send;       /* send data back */
+   bool once;                   /* Used to print header one time */
+   void *ctx;                   /* send() user argument */
+   B_DB *mdb;
+   JCR *jcr;
+
+   void empty() {
+      once = false;
+      line[0] = '\0';
+   }
+
+   void send_dashes() {
+      if (*line) {
+         send(ctx, line);
+      }
+   }
+
+   LIST_CTX(JCR *j, B_DB *m, DB_LIST_HANDLER *h, void *c, e_list_type t) {
+      line[0] = '\0';
+      once = false;
+      num_rows = 0;
+      type = t;
+      send = h;
+      ctx = c;
+      jcr = j;
+      mdb = m;
+   }
+};
+
 /*
  * Some functions exported by sql.c for use within the cats directory.
  */
+int list_result(void *vctx, int cols, char **row);
 void list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type type);
 void list_dashes(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx);
 int get_sql_record_max(JCR *jcr, B_DB *mdb);