]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/cats.h
kes Fix memory leak with storage ids in cats/sql_get.c
[bacula/bacula] / bacula / src / cats / cats.h
index c4766fc55cedceab5d0d02af7f8852ca8ac44d67..609dd43931d4577a4380203bfa18139cf98ef49b 100644 (file)
  *    Version $Id$
  */
 /*
-   Copyright (C) 2000-2006 Kern Sibbald
+   Bacula® - The Network Backup Solution
 
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
+   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
 
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
+   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
+   License as published by the Free Software Foundation plus additions
+   that are listed in the file LICENSE.
 
- */
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   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
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 
 /*
    Here is how database versions work. 
@@ -65,6 +78,7 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **);
 
 #ifdef __SQL_C
 
+#if defined(BUILDING_CATS)
 #ifdef HAVE_SQLITE
 
 #define BDB_VERSION 10
@@ -162,7 +176,7 @@ struct B_DB {
 /* In cats/sqlite.c */
 void       my_sqlite_free_table(B_DB *mdb);
 SQL_ROW    my_sqlite_fetch_row(B_DB *mdb);
-int        my_sqlite_query(B_DB *mdb, char *cmd);
+int        my_sqlite_query(B_DB *mdb, const char *cmd);
 void       my_sqlite_field_seek(B_DB *mdb, int field);
 SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb);
 
@@ -281,7 +295,7 @@ struct B_DB {
 /* In cats/sqlite.c */
 void       my_sqlite_free_table(B_DB *mdb);
 SQL_ROW    my_sqlite_fetch_row(B_DB *mdb);
-int        my_sqlite_query(B_DB *mdb, char *cmd);
+int        my_sqlite_query(B_DB *mdb, const char *cmd);
 void       my_sqlite_field_seek(B_DB *mdb, int field);
 SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb);
 
@@ -490,6 +504,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)
@@ -786,20 +801,34 @@ struct FILESET_DBR {
    bool created;                      /* set when record newly created */
 };
 
+/* Call back context for getting a 32/64 bit value from the database */
+struct db_int64_ctx {
+   int64_t value;                     /* value returned */
+   int count;                         /* number of values seen */
+};
 
 
 #include "protos.h"
 #include "jcr.h"
+#include "sql_cmds.h"
 
 /*
- * Some functions exported by sql.c for use withing the
+ * Some functions exported by sql.c for use within the
  *   cats directory.
  */
-void list_result(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type type);
+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);
-int check_tables_version(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);
+int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+int InsertDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+int DeleteDB(const char *file, int line, JCR *jcr, B_DB *db, char *delete_cmd);
+int UpdateDB(const char *file, int line, JCR *jcr, B_DB *db, char *update_cmd);
+void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname);
 #endif /* __SQL_H_ */