From: Kern Sibbald Date: Sat, 27 Jan 2007 18:25:23 +0000 (+0000) Subject: Update names X-Git-Tag: Release-7.0.0~6995 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9c30cf4d0d6dc6b192060fee857ec78d2078c303;p=bacula%2Fbacula Update names git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4061 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/Makefile b/bacula/src/qt-console/Makefile index ac0fee30ae..856d690b3a 100644 --- a/bacula/src/qt-console/Makefile +++ b/bacula/src/qt-console/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: bat -# Generated by qmake (2.01a) (Qt 4.2.1) on: Sat Jan 27 18:35:42 2007 +# Generated by qmake (2.01a) (Qt 4.2.1) on: Sat Jan 27 19:24:48 2007 # Project: bat.pro # Template: app # Command: /usr/bin/qmake -unix -o Makefile bat.pro @@ -47,12 +47,12 @@ OBJECTS_DIR = ./ SOURCES = main.cpp \ authenticate.cpp \ - console_conf.cpp \ + bat_conf.cpp \ mainwindow.cpp moc_mainwindow.cpp \ qrc_main.cpp OBJECTS = main.o \ authenticate.o \ - console_conf.o \ + bat_conf.o \ mainwindow.o \ moc_mainwindow.o \ qrc_main.o @@ -146,7 +146,7 @@ qmake: FORCE dist: @$(CHK_DIR_EXISTS) .tmp/bat1.0.0 || $(MKDIR) .tmp/bat1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/bat1.0.0/ && $(COPY_FILE) --parents mainwindow.h console_conf.h .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.qrc .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.cpp authenticate.cpp console_conf.cpp mainwindow.cpp .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.ui .tmp/bat1.0.0/ && (cd `dirname .tmp/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname .tmp/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/bat1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/bat1.0.0/ && $(COPY_FILE) --parents mainwindow.h bat.h bat_conf.h .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.qrc .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.cpp authenticate.cpp bat_conf.cpp mainwindow.cpp .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.ui .tmp/bat1.0.0/ && (cd `dirname .tmp/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname .tmp/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/bat1.0.0 yaccclean: @@ -207,24 +207,25 @@ compiler_clean: compiler_moc_header_clean compiler_rcc_clean compiler_image_coll ####### Compile -main.o: main.cpp console.h \ +main.o: main.cpp bat.h \ mainwindow.h \ ui_main.h \ - console_conf.h + bat_conf.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp -authenticate.o: authenticate.cpp mainwindow.h \ +authenticate.o: authenticate.cpp bat.h \ + mainwindow.h \ ui_main.h \ - console_conf.h + bat_conf.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o authenticate.o authenticate.cpp -console_conf.o: console_conf.cpp console_conf.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o console_conf.o console_conf.cpp +bat_conf.o: bat_conf.cpp bat_conf.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o bat_conf.o bat_conf.cpp -mainwindow.o: mainwindow.cpp console.h \ +mainwindow.o: mainwindow.cpp bat.h \ mainwindow.h \ ui_main.h \ - console_conf.h + bat_conf.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp moc_mainwindow.o: moc_mainwindow.cpp diff --git a/bacula/src/qt-console/authenticate.cpp b/bacula/src/qt-console/authenticate.cpp index 1bd0efc944..7f0be6227e 100644 --- a/bacula/src/qt-console/authenticate.cpp +++ b/bacula/src/qt-console/authenticate.cpp @@ -40,7 +40,7 @@ Switzerland, email:ftf@fsfeurope.org. */ -#include "console.h" +#include "bat.h" /* Commands sent to Director */ diff --git a/bacula/src/qt-console/bat.h b/bacula/src/qt-console/bat.h new file mode 100644 index 0000000000..186b81ad62 --- /dev/null +++ b/bacula/src/qt-console/bat.h @@ -0,0 +1,14 @@ + +#include "mainwindow.h" +#include "config.h" +#include "bacula.h" +#include "bat_conf.h" +#include "jcr.h" + +extern MainWindow *mainWin; +extern QApplication *app; + +void set_textf(const char *fmt, ...); +void set_text(const char *buf); + +int bvsnprintf(char *str, int32_t size, const char *format, va_list ap); diff --git a/bacula/src/qt-console/bat.pro b/bacula/src/qt-console/bat.pro index e31e6ba462..4b582888cc 100644 --- a/bacula/src/qt-console/bat.pro +++ b/bacula/src/qt-console/bat.pro @@ -14,6 +14,6 @@ RESOURCES = main.qrc # Input FORMS += main.ui -HEADERS += mainwindow.h console_conf.h -SOURCES += main.cpp authenticate.cpp console_conf.cpp +HEADERS += mainwindow.h bat.h bat_conf.h +SOURCES += main.cpp authenticate.cpp bat_conf.cpp SOURCES += mainwindow.cpp diff --git a/bacula/src/qt-console/bat_conf.cpp b/bacula/src/qt-console/bat_conf.cpp new file mode 100644 index 0000000000..c7537b7863 --- /dev/null +++ b/bacula/src/qt-console/bat_conf.cpp @@ -0,0 +1,337 @@ +/* + * Main configuration file parser for Bacula User Agent + * some parts may be split into separate files such as + * the schedule configuration (sch_config.c). + * + * Note, the configuration file parser consists of three parts + * + * 1. The generic lexical scanner in lib/lex.c and lib/lex.h + * + * 2. The generic config scanner in lib/parse_config.c and + * lib/parse_config.h. + * These files contain the parser code, some utility + * routines, and the common store routines (name, int, + * string). + * + * 3. The daemon specific file, which contains the Resource + * definitions as well as any specific store routines + * for the resource records. + * + * Kern Sibbald, January MM, September MM + * + * Version $Id$ + */ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + + 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. +*/ + +#include "bacula.h" +#include "bat_conf.h" + +/* Define the first and last resource ID record + * types. Note, these should be unique for each + * daemon though not a requirement. + */ +int r_first = R_FIRST; +int r_last = R_LAST; +static RES *sres_head[R_LAST - R_FIRST + 1]; +RES **res_head = sres_head; + +/* Forward referenced subroutines */ + + +/* We build the current resource here as we are + * scanning the resource configuration definition, + * then move it to allocated memory when the resource + * scan is complete. + */ +URES res_all; +int res_all_size = sizeof(res_all); + +/* Definition of records permitted within each + * resource with the routine to process the record + * information. + */ +static RES_ITEM dir_items[] = { + {"name", store_name, ITEM(dir_res.hdr.name), 0, ITEM_REQUIRED, 0}, + {"description", store_str, ITEM(dir_res.hdr.desc), 0, 0, 0}, + {"dirport", store_int, ITEM(dir_res.DIRport), 0, ITEM_DEFAULT, 9101}, + {"address", store_str, ITEM(dir_res.address), 0, ITEM_REQUIRED, 0}, + {"password", store_password, ITEM(dir_res.password), 0, 0, 0}, + {"tlsenable", store_bit, ITEM(dir_res.tls_enable), 1, 0, 0}, + {"tlsrequire", store_bit, ITEM(dir_res.tls_require), 1, 0, 0}, + {"tlscacertificatefile", store_dir, ITEM(dir_res.tls_ca_certfile), 0, 0, 0}, + {"tlscacertificatedir", store_dir, ITEM(dir_res.tls_ca_certdir), 0, 0, 0}, + {"tlscertificate", store_dir, ITEM(dir_res.tls_certfile), 0, 0, 0}, + {"tlskey", store_dir, ITEM(dir_res.tls_keyfile), 0, 0, 0}, + {NULL, NULL, {0}, 0, 0, 0} +}; + +static RES_ITEM con_items[] = { + {"name", store_name, ITEM(con_res.hdr.name), 0, ITEM_REQUIRED, 0}, + {"description", store_str, ITEM(con_res.hdr.desc), 0, 0, 0}, + {"password", store_password, ITEM(con_res.password), 0, ITEM_REQUIRED, 0}, + {"tlsenable", store_bit, ITEM(con_res.tls_enable), 1, 0, 0}, + {"tlsrequire", store_bit, ITEM(con_res.tls_require), 1, 0, 0}, + {"tlscacertificatefile", store_dir, ITEM(con_res.tls_ca_certfile), 0, 0, 0}, + {"tlscacertificatedir", store_dir, ITEM(con_res.tls_ca_certdir), 0, 0, 0}, + {"tlscertificate", store_dir, ITEM(con_res.tls_certfile), 0, 0, 0}, + {"tlskey", store_dir, ITEM(con_res.tls_keyfile), 0, 0, 0}, + {NULL, NULL, {0}, 0, 0, 0} +}; + +static RES_ITEM con_font_items[] = { + {"name", store_name, ITEM(con_font.hdr.name), 0, ITEM_REQUIRED, 0}, + {"description", store_str, ITEM(con_font.hdr.desc), 0, 0, 0}, + {"font", store_str, ITEM(con_font.fontface), 0, 0, 0}, + {"requiressl", store_bit, ITEM(con_font.require_ssl), 1, ITEM_DEFAULT, 0}, + {NULL, NULL, {0}, 0, 0, 0} +}; + + +/* + * This is the master resource definition. + * It must have one item for each of the resources. + */ +RES_TABLE resources[] = { + {"director", dir_items, R_DIRECTOR}, + {"console", con_items, R_CONSOLE}, + {"consolefont", con_font_items, R_CONSOLE_FONT}, + {NULL, NULL, 0} +}; + + +/* Dump contents of resource */ +void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock) +{ + URES *res = (URES *)reshdr; + bool recurse = true; + + if (res == NULL) { + printf(_("No record for %d %s\n"), type, res_to_str(type)); + return; + } + if (type < 0) { /* no recursion */ + type = - type; + recurse = false; + } + switch (type) { + case R_DIRECTOR: + printf(_("Director: name=%s address=%s DIRport=%d\n"), reshdr->name, + res->dir_res.address, res->dir_res.DIRport); + break; + case R_CONSOLE: + printf(_("Console: name=%s\n"), reshdr->name); + break; + case R_CONSOLE_FONT: + printf(_("ConsoleFont: name=%s font face=%s\n"), + reshdr->name, NPRT(res->con_font.fontface)); + break; + default: + printf(_("Unknown resource type %d\n"), type); + } + if (recurse && res->dir_res.hdr.next) { + dump_resource(type, res->dir_res.hdr.next, sendit, sock); + } +} + +/* + * Free memory of resource. + * NB, we don't need to worry about freeing any references + * to other resources as they will be freed when that + * resource chain is traversed. Mainly we worry about freeing + * allocated strings (names). + */ +void free_resource(RES *sres, int type) +{ + RES *nres; + URES *res = (URES *)sres; + + if (res == NULL) + return; + + /* common stuff -- free the resource name */ + nres = (RES *)res->dir_res.hdr.next; + if (res->dir_res.hdr.name) { + free(res->dir_res.hdr.name); + } + if (res->dir_res.hdr.desc) { + free(res->dir_res.hdr.desc); + } + + switch (type) { + case R_DIRECTOR: + if (res->dir_res.address) { + free(res->dir_res.address); + } + if (res->dir_res.tls_ctx) { + free_tls_context(res->dir_res.tls_ctx); + } + if (res->dir_res.tls_ca_certfile) { + free(res->dir_res.tls_ca_certfile); + } + if (res->dir_res.tls_ca_certdir) { + free(res->dir_res.tls_ca_certdir); + } + if (res->dir_res.tls_certfile) { + free(res->dir_res.tls_certfile); + } + if (res->dir_res.tls_keyfile) { + free(res->dir_res.tls_keyfile); + } + break; + case R_CONSOLE: + if (res->con_res.password) { + free(res->con_res.password); + } + if (res->con_res.tls_ctx) { + free_tls_context(res->con_res.tls_ctx); + } + if (res->con_res.tls_ca_certfile) { + free(res->con_res.tls_ca_certfile); + } + if (res->con_res.tls_ca_certdir) { + free(res->con_res.tls_ca_certdir); + } + if (res->con_res.tls_certfile) { + free(res->con_res.tls_certfile); + } + if (res->con_res.tls_keyfile) { + free(res->con_res.tls_keyfile); + } + break; + case R_CONSOLE_FONT: + if (res->con_font.fontface) { + free(res->con_font.fontface); + } + break; + default: + printf(_("Unknown resource type %d\n"), type); + } + /* Common stuff again -- free the resource, recurse to next one */ + free(res); + if (nres) { + free_resource(nres, type); + } +} + +/* Save the new resource by chaining it into the head list for + * the resource. If this is pass 2, we update any resource + * pointers (currently only in the Job resource). + */ +void save_resource(int type, RES_ITEM *items, int pass) +{ + URES *res; + int rindex = type - r_first; + int i, size = 0; + int error = 0; + + /* + * Ensure that all required items are present + */ + for (i=0; items[i].name; i++) { + if (items[i].flags & ITEM_REQUIRED) { + if (!bit_is_set(i, res_all.dir_res.hdr.item_present)) { + Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found.\n"), + items[i].name, resources[rindex]); + } + } + } + + /* During pass 2, we looked up pointers to all the resources + * referrenced in the current resource, , now we + * must copy their address from the static record to the allocated + * record. + */ + if (pass == 2) { + switch (type) { + /* Resources not containing a resource */ + case R_DIRECTOR: + break; + + case R_CONSOLE: + case R_CONSOLE_FONT: + break; + + default: + Emsg1(M_ERROR, 0, _("Unknown resource type %d\n"), type); + error = 1; + break; + } + /* Note, the resoure name was already saved during pass 1, + * so here, we can just release it. + */ + if (res_all.dir_res.hdr.name) { + free(res_all.dir_res.hdr.name); + res_all.dir_res.hdr.name = NULL; + } + if (res_all.dir_res.hdr.desc) { + free(res_all.dir_res.hdr.desc); + res_all.dir_res.hdr.desc = NULL; + } + return; + } + + /* The following code is only executed during pass 1 */ + switch (type) { + case R_DIRECTOR: + size = sizeof(DIRRES); + break; + case R_CONSOLE_FONT: + size = sizeof(CONFONTRES); + break; + case R_CONSOLE: + size = sizeof(CONRES); + break; + default: + printf(_("Unknown resource type %d\n"), type); + error = 1; + break; + } + /* Common */ + if (!error) { + res = (URES *)malloc(size); + memcpy(res, &res_all, size); + if (!res_head[rindex]) { + res_head[rindex] = (RES *)res; /* store first entry */ + } else { + RES *next, *last; + /* Add new res to end of chain */ + for (last=next=res_head[rindex]; next; next=next->next) { + last = next; + if (strcmp(next->name, res->dir_res.hdr.name) == 0) { + Emsg2(M_ERROR_TERM, 0, + _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), + resources[rindex].name, res->dir_res.hdr.name); + } + } + last->next = (RES *)res; + Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), + res->dir_res.hdr.name); + } + } +} diff --git a/bacula/src/qt-console/bat_conf.h b/bacula/src/qt-console/bat_conf.h new file mode 100644 index 0000000000..209734aff8 --- /dev/null +++ b/bacula/src/qt-console/bat_conf.h @@ -0,0 +1,111 @@ +/* + * Bacula Adminstration Tool (bat) + * + * Kern Sibbald, March 2002 + * + * Version $Id$ + */ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2002-2006 Free Software Foundation Europe e.V. + + 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. +*/ + +#ifndef __CONSOLE_CONF_H_ +#define __CONSOLE_CONF_H_ + +/* + * Resource codes -- they must be sequential for indexing + */ + +enum { + R_DIRECTOR = 1001, + R_CONSOLE, + R_CONSOLE_FONT, + R_FIRST = R_DIRECTOR, + R_LAST = R_CONSOLE_FONT /* Keep this updated */ +}; + +/* + * Some resource attributes + */ +enum { + R_NAME = 1020, + R_ADDRESS, + R_PASSWORD, + R_TYPE, + R_BACKUP +}; + + +/* Definition of the contents of each Resource */ +struct DIRRES { + RES hdr; + int DIRport; /* UA server port */ + char *address; /* UA server address */ + char *password; /* UA server password */ + int tls_enable; /* Enable TLS */ + int tls_require; /* Require TLS */ + char *tls_ca_certfile; /* TLS CA Certificate File */ + char *tls_ca_certdir; /* TLS CA Certificate Directory */ + char *tls_certfile; /* TLS Client Certificate File */ + char *tls_keyfile; /* TLS Client Key File */ + + TLS_CONTEXT *tls_ctx; /* Shared TLS Context */ +}; + +struct CONFONTRES { + RES hdr; + char *fontface; /* Console Font specification */ + int require_ssl; /* Require SSL on all connections */ +}; + +struct CONRES { + RES hdr; + char *password; /* UA server password */ + int tls_enable; /* Enable TLS on all connections */ + int tls_require; /* Require TLS on all connections */ + char *tls_ca_certfile; /* TLS CA Certificate File */ + char *tls_ca_certdir; /* TLS CA Certificate Directory */ + char *tls_certfile; /* TLS Client Certificate File */ + char *tls_keyfile; /* TLS Client Key File */ + + TLS_CONTEXT *tls_ctx; /* Shared TLS Context */ +}; + + +/* Define the Union of all the above + * resource structure definitions. + */ +union u_res { + DIRRES dir_res; + CONRES con_res; + CONFONTRES con_font; + RES hdr; +}; + +typedef union u_res URES; + +#endif diff --git a/bacula/src/qt-console/console.h b/bacula/src/qt-console/console.h index 8715b5fe2d..6ff13fc600 100644 --- a/bacula/src/qt-console/console.h +++ b/bacula/src/qt-console/console.h @@ -5,3 +5,11 @@ #include "console_conf.h" #include "jcr.h" +extern MainWindow *mainWin; +extern QApplication *app; + +void set_textf(const char *fmt, ...); +void set_text(const char *buf); + +int bvsnprintf(char *str, int32_t size, const char *format, va_list ap); + diff --git a/bacula/src/qt-console/console_conf.cpp b/bacula/src/qt-console/console_conf.cpp deleted file mode 100644 index f1cd77ecf3..0000000000 --- a/bacula/src/qt-console/console_conf.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Main configuration file parser for Bacula User Agent - * some parts may be split into separate files such as - * the schedule configuration (sch_config.c). - * - * Note, the configuration file parser consists of three parts - * - * 1. The generic lexical scanner in lib/lex.c and lib/lex.h - * - * 2. The generic config scanner in lib/parse_config.c and - * lib/parse_config.h. - * These files contain the parser code, some utility - * routines, and the common store routines (name, int, - * string). - * - * 3. The daemon specific file, which contains the Resource - * definitions as well as any specific store routines - * for the resource records. - * - * Kern Sibbald, January MM, September MM - * - * Version $Id$ - */ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. - - 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. -*/ - -#include "bacula.h" -#include "console_conf.h" - -/* Define the first and last resource ID record - * types. Note, these should be unique for each - * daemon though not a requirement. - */ -int r_first = R_FIRST; -int r_last = R_LAST; -static RES *sres_head[R_LAST - R_FIRST + 1]; -RES **res_head = sres_head; - -/* Forward referenced subroutines */ - - -/* We build the current resource here as we are - * scanning the resource configuration definition, - * then move it to allocated memory when the resource - * scan is complete. - */ -URES res_all; -int res_all_size = sizeof(res_all); - -/* Definition of records permitted within each - * resource with the routine to process the record - * information. - */ -static RES_ITEM dir_items[] = { - {"name", store_name, ITEM(dir_res.hdr.name), 0, ITEM_REQUIRED, 0}, - {"description", store_str, ITEM(dir_res.hdr.desc), 0, 0, 0}, - {"dirport", store_int, ITEM(dir_res.DIRport), 0, ITEM_DEFAULT, 9101}, - {"address", store_str, ITEM(dir_res.address), 0, ITEM_REQUIRED, 0}, - {"password", store_password, ITEM(dir_res.password), 0, 0, 0}, - {"tlsenable", store_bit, ITEM(dir_res.tls_enable), 1, 0, 0}, - {"tlsrequire", store_bit, ITEM(dir_res.tls_require), 1, 0, 0}, - {"tlscacertificatefile", store_dir, ITEM(dir_res.tls_ca_certfile), 0, 0, 0}, - {"tlscacertificatedir", store_dir, ITEM(dir_res.tls_ca_certdir), 0, 0, 0}, - {"tlscertificate", store_dir, ITEM(dir_res.tls_certfile), 0, 0, 0}, - {"tlskey", store_dir, ITEM(dir_res.tls_keyfile), 0, 0, 0}, - {NULL, NULL, {0}, 0, 0, 0} -}; - -static RES_ITEM con_items[] = { - {"name", store_name, ITEM(con_res.hdr.name), 0, ITEM_REQUIRED, 0}, - {"description", store_str, ITEM(con_res.hdr.desc), 0, 0, 0}, - {"password", store_password, ITEM(con_res.password), 0, ITEM_REQUIRED, 0}, - {"tlsenable", store_bit, ITEM(con_res.tls_enable), 1, 0, 0}, - {"tlsrequire", store_bit, ITEM(con_res.tls_require), 1, 0, 0}, - {"tlscacertificatefile", store_dir, ITEM(con_res.tls_ca_certfile), 0, 0, 0}, - {"tlscacertificatedir", store_dir, ITEM(con_res.tls_ca_certdir), 0, 0, 0}, - {"tlscertificate", store_dir, ITEM(con_res.tls_certfile), 0, 0, 0}, - {"tlskey", store_dir, ITEM(con_res.tls_keyfile), 0, 0, 0}, - {NULL, NULL, {0}, 0, 0, 0} -}; - -static RES_ITEM con_font_items[] = { - {"name", store_name, ITEM(con_font.hdr.name), 0, ITEM_REQUIRED, 0}, - {"description", store_str, ITEM(con_font.hdr.desc), 0, 0, 0}, - {"font", store_str, ITEM(con_font.fontface), 0, 0, 0}, - {"requiressl", store_bit, ITEM(con_font.require_ssl), 1, ITEM_DEFAULT, 0}, - {NULL, NULL, {0}, 0, 0, 0} -}; - - -/* - * This is the master resource definition. - * It must have one item for each of the resources. - */ -RES_TABLE resources[] = { - {"director", dir_items, R_DIRECTOR}, - {"console", con_items, R_CONSOLE}, - {"consolefont", con_font_items, R_CONSOLE_FONT}, - {NULL, NULL, 0} -}; - - -/* Dump contents of resource */ -void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock) -{ - URES *res = (URES *)reshdr; - bool recurse = true; - - if (res == NULL) { - printf(_("No record for %d %s\n"), type, res_to_str(type)); - return; - } - if (type < 0) { /* no recursion */ - type = - type; - recurse = false; - } - switch (type) { - case R_DIRECTOR: - printf(_("Director: name=%s address=%s DIRport=%d\n"), reshdr->name, - res->dir_res.address, res->dir_res.DIRport); - break; - case R_CONSOLE: - printf(_("Console: name=%s\n"), reshdr->name); - break; - case R_CONSOLE_FONT: - printf(_("ConsoleFont: name=%s font face=%s\n"), - reshdr->name, NPRT(res->con_font.fontface)); - break; - default: - printf(_("Unknown resource type %d\n"), type); - } - if (recurse && res->dir_res.hdr.next) { - dump_resource(type, res->dir_res.hdr.next, sendit, sock); - } -} - -/* - * Free memory of resource. - * NB, we don't need to worry about freeing any references - * to other resources as they will be freed when that - * resource chain is traversed. Mainly we worry about freeing - * allocated strings (names). - */ -void free_resource(RES *sres, int type) -{ - RES *nres; - URES *res = (URES *)sres; - - if (res == NULL) - return; - - /* common stuff -- free the resource name */ - nres = (RES *)res->dir_res.hdr.next; - if (res->dir_res.hdr.name) { - free(res->dir_res.hdr.name); - } - if (res->dir_res.hdr.desc) { - free(res->dir_res.hdr.desc); - } - - switch (type) { - case R_DIRECTOR: - if (res->dir_res.address) { - free(res->dir_res.address); - } - if (res->dir_res.tls_ctx) { - free_tls_context(res->dir_res.tls_ctx); - } - if (res->dir_res.tls_ca_certfile) { - free(res->dir_res.tls_ca_certfile); - } - if (res->dir_res.tls_ca_certdir) { - free(res->dir_res.tls_ca_certdir); - } - if (res->dir_res.tls_certfile) { - free(res->dir_res.tls_certfile); - } - if (res->dir_res.tls_keyfile) { - free(res->dir_res.tls_keyfile); - } - break; - case R_CONSOLE: - if (res->con_res.password) { - free(res->con_res.password); - } - if (res->con_res.tls_ctx) { - free_tls_context(res->con_res.tls_ctx); - } - if (res->con_res.tls_ca_certfile) { - free(res->con_res.tls_ca_certfile); - } - if (res->con_res.tls_ca_certdir) { - free(res->con_res.tls_ca_certdir); - } - if (res->con_res.tls_certfile) { - free(res->con_res.tls_certfile); - } - if (res->con_res.tls_keyfile) { - free(res->con_res.tls_keyfile); - } - break; - case R_CONSOLE_FONT: - if (res->con_font.fontface) { - free(res->con_font.fontface); - } - break; - default: - printf(_("Unknown resource type %d\n"), type); - } - /* Common stuff again -- free the resource, recurse to next one */ - free(res); - if (nres) { - free_resource(nres, type); - } -} - -/* Save the new resource by chaining it into the head list for - * the resource. If this is pass 2, we update any resource - * pointers (currently only in the Job resource). - */ -void save_resource(int type, RES_ITEM *items, int pass) -{ - URES *res; - int rindex = type - r_first; - int i, size = 0; - int error = 0; - - /* - * Ensure that all required items are present - */ - for (i=0; items[i].name; i++) { - if (items[i].flags & ITEM_REQUIRED) { - if (!bit_is_set(i, res_all.dir_res.hdr.item_present)) { - Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found.\n"), - items[i].name, resources[rindex]); - } - } - } - - /* During pass 2, we looked up pointers to all the resources - * referrenced in the current resource, , now we - * must copy their address from the static record to the allocated - * record. - */ - if (pass == 2) { - switch (type) { - /* Resources not containing a resource */ - case R_DIRECTOR: - break; - - case R_CONSOLE: - case R_CONSOLE_FONT: - break; - - default: - Emsg1(M_ERROR, 0, _("Unknown resource type %d\n"), type); - error = 1; - break; - } - /* Note, the resoure name was already saved during pass 1, - * so here, we can just release it. - */ - if (res_all.dir_res.hdr.name) { - free(res_all.dir_res.hdr.name); - res_all.dir_res.hdr.name = NULL; - } - if (res_all.dir_res.hdr.desc) { - free(res_all.dir_res.hdr.desc); - res_all.dir_res.hdr.desc = NULL; - } - return; - } - - /* The following code is only executed during pass 1 */ - switch (type) { - case R_DIRECTOR: - size = sizeof(DIRRES); - break; - case R_CONSOLE_FONT: - size = sizeof(CONFONTRES); - break; - case R_CONSOLE: - size = sizeof(CONRES); - break; - default: - printf(_("Unknown resource type %d\n"), type); - error = 1; - break; - } - /* Common */ - if (!error) { - res = (URES *)malloc(size); - memcpy(res, &res_all, size); - if (!res_head[rindex]) { - res_head[rindex] = (RES *)res; /* store first entry */ - } else { - RES *next, *last; - /* Add new res to end of chain */ - for (last=next=res_head[rindex]; next; next=next->next) { - last = next; - if (strcmp(next->name, res->dir_res.hdr.name) == 0) { - Emsg2(M_ERROR_TERM, 0, - _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), - resources[rindex].name, res->dir_res.hdr.name); - } - } - last->next = (RES *)res; - Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), - res->dir_res.hdr.name); - } - } -} diff --git a/bacula/src/qt-console/console_conf.h b/bacula/src/qt-console/console_conf.h deleted file mode 100644 index 7a31004436..0000000000 --- a/bacula/src/qt-console/console_conf.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Bacula GNOME User Agent specific configuration and defines - * - * Kern Sibbald, March 2002 - * - * Version $Id$ - */ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2002-2006 Free Software Foundation Europe e.V. - - 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. -*/ - -#ifndef __CONSOLE_CONF_H_ -#define __CONSOLE_CONF_H_ - -/* - * Resource codes -- they must be sequential for indexing - */ - -enum { - R_DIRECTOR = 1001, - R_CONSOLE, - R_CONSOLE_FONT, - R_FIRST = R_DIRECTOR, - R_LAST = R_CONSOLE_FONT /* Keep this updated */ -}; - -/* - * Some resource attributes - */ -enum { - R_NAME = 1020, - R_ADDRESS, - R_PASSWORD, - R_TYPE, - R_BACKUP -}; - - -/* Definition of the contents of each Resource */ -struct DIRRES { - RES hdr; - int DIRport; /* UA server port */ - char *address; /* UA server address */ - char *password; /* UA server password */ - int tls_enable; /* Enable TLS */ - int tls_require; /* Require TLS */ - char *tls_ca_certfile; /* TLS CA Certificate File */ - char *tls_ca_certdir; /* TLS CA Certificate Directory */ - char *tls_certfile; /* TLS Client Certificate File */ - char *tls_keyfile; /* TLS Client Key File */ - - TLS_CONTEXT *tls_ctx; /* Shared TLS Context */ -}; - -struct CONFONTRES { - RES hdr; - char *fontface; /* Console Font specification */ - int require_ssl; /* Require SSL on all connections */ -}; - -struct CONRES { - RES hdr; - char *password; /* UA server password */ - int tls_enable; /* Enable TLS on all connections */ - int tls_require; /* Require TLS on all connections */ - char *tls_ca_certfile; /* TLS CA Certificate File */ - char *tls_ca_certdir; /* TLS CA Certificate Directory */ - char *tls_certfile; /* TLS Client Certificate File */ - char *tls_keyfile; /* TLS Client Key File */ - - TLS_CONTEXT *tls_ctx; /* Shared TLS Context */ -}; - - -/* Define the Union of all the above - * resource structure definitions. - */ -union u_res { - DIRRES dir_res; - CONRES con_res; - CONFONTRES con_font; - RES hdr; -}; - -typedef union u_res URES; - -#endif diff --git a/bacula/src/qt-console/main.cpp b/bacula/src/qt-console/main.cpp index bc54f0551d..91e0386a20 100644 --- a/bacula/src/qt-console/main.cpp +++ b/bacula/src/qt-console/main.cpp @@ -26,8 +26,16 @@ Switzerland, email:ftf@fsfeurope.org. */ +/* + * Main program for bat (qt-console) + * + * Kern Sibbald, January MMVI + * + */ + + #include -#include "console.h" +#include "bat.h" /* Imported functions */ @@ -44,6 +52,7 @@ static int check_resources(); static char *configfile = NULL; MainWindow *mainWin; +QApplication *app; int main(int argc, char *argv[]) { @@ -53,8 +62,8 @@ int main(int argc, char *argv[]) bool test_config = false; - QApplication app(argc, argv); - app.setQuitOnLastWindowClosed(true); + app = new QApplication(argc, argv); + app->setQuitOnLastWindowClosed(true); mainWin = new MainWindow; @@ -122,7 +131,6 @@ int main(int argc, char *argv[]) } parse_config(configfile); - set_text("Configuration read.\n"); if (init_crypto() != 0) { Emsg0(M_ERROR_TERM, 0, _("Cryptography library initialization failed.\n")); @@ -132,7 +140,7 @@ int main(int argc, char *argv[]) Emsg1(M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile); } - return app.exec(); + return app->exec(); } void terminate_console(int sig) diff --git a/bacula/src/qt-console/mainwindow.cpp b/bacula/src/qt-console/mainwindow.cpp index 7f87ec70f7..d5a45f4725 100644 --- a/bacula/src/qt-console/mainwindow.cpp +++ b/bacula/src/qt-console/mainwindow.cpp @@ -33,7 +33,7 @@ * */ -#include "console.h" +#include "bat.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { diff --git a/bacula/src/qt-console/mainwindow.h b/bacula/src/qt-console/mainwindow.h index a5d90a134c..884a28355b 100644 --- a/bacula/src/qt-console/mainwindow.h +++ b/bacula/src/qt-console/mainwindow.h @@ -52,9 +52,3 @@ private: QString m_UserInput; }; -extern MainWindow *mainWin; - -void set_textf(const char *fmt, ...); -void set_text(const char *buf); - -int bvsnprintf(char *str, int32_t size, const char *format, va_list ap);