]> git.sur5r.net Git - bacula/bacula/commitdiff
Move the definition of catalog_db[] into cats. Change it to db_get_type() which...
authorRobert Nelson <robertn@the-nelsons.org>
Sat, 5 Aug 2006 22:27:03 +0000 (22:27 +0000)
committerRobert Nelson <robertn@the-nelsons.org>
Sat, 5 Aug 2006 22:27:03 +0000 (22:27 +0000)
in the database specific files: bdb.c, mysql.c, postgresql.c and sqlite.c.

Change cats.h so that database specific sections are only visible which building the cats directory.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3251 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/bdb.c
bacula/src/cats/cats.h
bacula/src/cats/mysql.c
bacula/src/cats/postgresql.c
bacula/src/cats/sqlite.c
bacula/src/dird/pythondir.c
bacula/src/lib/message.c
bacula/src/lib/message.h
bacula/src/win32/cats/bacula_cats.def

index ddf659fd37f959480e352a12859ed41bf6d5e8f5..b5979f18c9e9bf26240549cbec80b8951db99586 100644 (file)
@@ -86,6 +86,15 @@ int bdb_write_control_file(B_DB *mdb)
    return 1;
 }
 
+/*
+ * Retrieve database type
+ */
+const char *
+db_get_type(void)
+{
+   return "Internal";
+}
+
 /*
  * Initialize database data structure. In principal this should
  * never have errors, or it is really fatal.
@@ -106,6 +115,7 @@ db_init_database(JCR *jcr, char const *db_name, char const *db_user, char const
          return mdb;                  /* already open */
       }
    }
+
    Dmsg0(200, "db_open first time\n");
    mdb = (B_DB *)malloc(sizeof(B_DB));
    memset(mdb, 0, sizeof(B_DB));
index 2eda36734b8f9c7a73f7281b5ef1a8b9e0c66598..3e790f5dcbeee606ac4afc9198e052c628108aab 100644 (file)
@@ -65,6 +65,7 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **);
 
 #ifdef __SQL_C
 
+#if defined(BUILDING_CATS)
 #ifdef HAVE_SQLITE
 
 #define BDB_VERSION 10
@@ -490,6 +491,7 @@ struct B_DB {
 #endif /* HAVE_MYSQL */
 #endif /* HAVE_SQLITE */
 #endif /* HAVE_POSTGRESQL */
+#endif
 
 /* Use for better error location printing */
 #define UPDATE_DB(jcr, db, cmd) UpdateDB(__FILE__, __LINE__, jcr, db, cmd)
@@ -807,6 +809,7 @@ int get_sql_record_max(JCR *jcr, B_DB *mdb);
 bool check_tables_version(JCR *jcr, B_DB *mdb);
 void _db_unlock(const char *file, int line, B_DB *mdb);
 void _db_lock(const char *file, int line, B_DB *mdb);
+const char *db_get_type(void);
 
 void print_dashes(B_DB *mdb);
 void print_result(B_DB *mdb);
index 3c1a6e2fd626abfbfc6ffae8cb3b54ac2764cd80..c8a5b545472cd3808051586861c745d55cb639b5 100644 (file)
@@ -45,6 +45,15 @@ static BQUEUE db_list = {&db_list, &db_list};
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
+/*
+ * Retrieve database type
+ */
+const char *
+db_get_type(void)
+{
+   return "MySQL";
+}
+
 /*
  * Initialize database data structure. In principal this should
  * never have errors, or it is really fatal.
index 4b0e151dc72a33c7bbbcf0c345f7a4abb43ed95f..cc48f1d43e5da307feaafe4d93cc2d05ea2ad298 100644 (file)
@@ -47,6 +47,16 @@ static BQUEUE db_list = {&db_list, &db_list};
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
+/*
+ * Retrieve database type
+ */
+const char *
+db_get_type(void)
+{
+   return "PostgreSQL";
+
+}
+
 /*
  * Initialize database data structure. In principal this should
  * never have errors, or it is really fatal.
index 34f2c136e87f5974f945291ad7c94f014357a0bd..e37b0e915f83f1b147844ce8d800c410b56e3dcc 100644 (file)
@@ -47,6 +47,15 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
 
 
+/*
+ * Retrieve database type
+ */
+const char *
+db_get_type(void)
+{
+   return "SQLite";
+}
+
 /*
  * Initialize database data structure. In principal this should
  * never have errors, or it is really fatal.
index d64bb23e3da7dd5780eba9c754eb6af3cca88c1c..09c49659f885b94449d7801b7fc8a5c6a22455ca 100644 (file)
@@ -174,7 +174,7 @@ PyObject *job_getattr(PyObject *self, char *attrname)
          jcr->catalog->db_name, jcr->catalog->db_address, 
          jcr->catalog->db_user, jcr->catalog->db_password,
          jcr->catalog->db_socket, jcr->catalog->db_port,
-         catalog_db);
+         db_get_type());
 
    }
    bsnprintf(errmsg, sizeof(errmsg), _("Attribute %s not found."), attrname);
index 544757f30cd6a66f38d72bfb1abb2db2b81532d3..6e131e55edb1d1777096c114c5d1ffa8928c80bd 100755 (executable)
@@ -47,16 +47,7 @@ char con_fname[500];                  /* Console filename */
 FILE *con_fd = NULL;                  /* Console file descriptor */
 brwlock_t con_lock;                   /* Console lock structure */
 
-
-#if defined(HAVE_POSTGRESQL)
-char catalog_db[] = "PostgreSQL";
-#elif defined(HAVE_MYSQL)
-char catalog_db[] = "MySQL";
-#elif defined(HAVE_SQLITE)
-char catalog_db[] = "SQLite";
-#else
-char catalog_db[] = "Internal";
-#endif
+static char *catalog_db = NULL;              /* database type */
 
 const char *host_os = HOST_OS;
 const char *distname = DISTNAME;
@@ -142,6 +133,23 @@ void my_name_is(int argc, char *argv[], const char *name)
    }
 }
 
+const char *
+get_db_type(void)
+{
+   return catalog_db != NULL ? catalog_db : "unknown";
+}
+
+void
+set_db_type(const char *name)
+{
+   if (catalog_db != NULL)
+   {
+      free(catalog_db);
+   }
+
+   catalog_db = bstrdup(name);
+}
+
 /*
  * Initialize message handler for a daemon or a Job
  *   We make a copy of the MSGS resource passed, so it belows
index ab55307b9a86d4c719e48697b6db04ee9412404a..34721c3dd8097551dae7d7ed5ca38b0eba1a2702 100644 (file)
@@ -132,6 +132,9 @@ void Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
 void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
 bool get_trace(void);
 
+const char *get_db_type(void);
+void set_db_type(const char *file);
+
 typedef void (*sql_query)(JCR *jcr, const char *cmd);
 extern sql_query     DLL_IMP_EXP p_sql_query;
 
@@ -140,7 +143,6 @@ extern int           DLL_IMP_EXP verbose;
 extern char          DLL_IMP_EXP my_name[];
 extern const char *  DLL_IMP_EXP working_directory;
 extern time_t        DLL_IMP_EXP daemon_start_time;
-extern char                      catalog_db[];
 
 extern int           DLL_IMP_EXP console_msg_pending;
 extern FILE *        DLL_IMP_EXP con_fd;                 /* Console file descriptor */
index 1cc08cfb6c51461e85fc71f4fef86dd0241fd9c5..095f9092811e5220353df3a9072dcb8f48e096a7 100644 (file)
@@ -5,6 +5,7 @@ EXPORTS
 ; mysql.c:
 ; postgresql.c:
 ; sqlite.c:
+_Z11db_get_typev
 _Z12db_sql_queryP4B_DBPKcPFiPviPPcES3_
 ;_Z13db_next_indexP3JCRP4B_DBPcS3_
 _Z16db_escape_stringPcS_i