-/*
- *
- * Interaction thread between director and the GUI
- *
- * Nicolas Boichat, April 2004
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2004-2008 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.
+ 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.
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
+ 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.
- Bacula® is a registered trademark of John Walker.
+ Bacula® is a registered trademark of Kern Sibbald.
The licensor of Bacula is the Free Software Foundation Europe
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Interaction thread between director and the GUI
+ *
+ * Nicolas Boichat, April 2004
+ *
+ * Version $Id$
+ */
// http://66.102.9.104/search?q=cache:Djc1mPF3hRoJ:cvs.sourceforge.net/viewcvs.py/audacity/audacity-src/src/AudioIO.cpp%3Frev%3D1.102+macos+x+wxthread&hl=fr
/* Imported functions */
int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
+bool parse_wxcons_config(CONFIG *config, const char *cfgfile, LEX_ERROR_HANDLER *scan_error);
bool console_thread::inited = false;
bool console_thread::configloaded = false;
wxString console_thread::working_dir = wxT(".");
int numdir = 0;
+static CONFIG *config = NULL;
+static void scan_err(const char *file, int line, LEX *lc, const char *msg, ...);
+
/*
* Call-back for reading a passphrase for an encrypted PEM file
return _("Error while initializing library.");
}
- free_config_resources();
+ if (config) {
+ config->free_resources();
+ free(config);
+ }
MSGS* msgs = (MSGS *)bmalloc(sizeof(MSGS));
memset(msgs, 0, sizeof(MSGS));
//init_console_msg(console_thread::working_dir.mb_str(*wxConvCurrent));
errmsg = wxT("");
- if (!parse_config(configfile.mb_str(*wxConvCurrent), &scan_err)) {
+ config = new_config_parser();
+ if (!parse_wxcons_config(config, configfile.mb_str(*wxConvCurrent), &scan_err)) {
configloaded = false;
term_msg();
return errmsg;
// class destructor
console_thread::~console_thread() {
if (UA_sock) {
- bnet_sig(UA_sock, BNET_TERMINATE); /* send EOF */
- bnet_close(UA_sock);
+ UA_sock->signal(BNET_TERMINATE); /* send EOF */
+ UA_sock->close();
UA_sock = NULL;
}
}
memset(&jcr, 0, sizeof(jcr));
- jcr.dequeuing = 1; /* TODO: catch messages */
+ jcr.dequeuing_msgs = 1; /* TODO: catch messages */
LockRes();
/* If cons==NULL, default console will be used */
}
- UA_sock = bnet_connect(&jcr, 3, 3, wxString(_("Director daemon")).mb_str(*wxConvCurrent),
+ UA_sock = bnet_connect(&jcr, 3, 3, 0, wxString(_("Director daemon")).mb_str(*wxConvCurrent),
dir->address, NULL, dir->DIRport, 0);
if (UA_sock == NULL) {
/* main loop */
while(!TestDestroy()) { /* Tests if thread has been ended */
- stat = bnet_wait_data(UA_sock, 10);
+ stat = UA_sock->wait_data(10);
if (stat == 0) {
if (last_is_eod) {
Write(".messages\n");
}
last_is_eod = 0;
- if ((stat = bnet_recv(UA_sock)) >= 0) {
+ if ((stat = UA_sock->recv()) >= 0) {
if (do_not_forward_eod) { /* .messages got data: remove the prompt */
csprint(NULL, CS_REMOVEPROMPT);
}
csprint(UA_sock->msg);
}
else if (stat == BNET_SIGNAL) {
- if (UA_sock->msglen == BNET_PROMPT) {
+ if (UA_sock->msglen == BNET_SUB_PROMPT) {
csprint(NULL, CS_PROMPT);
} else if (UA_sock->msglen == BNET_EOD) {
last_is_eod = 1;
if (!do_not_forward_eod)
csprint(NULL, CS_END);
} else if (UA_sock->msglen == BNET_HEARTBEAT) {
- bnet_sig(UA_sock, BNET_HB_RESPONSE);
+ UA_sock->signal(BNET_HB_RESPONSE);
csprint(_("<< Heartbeat signal received, answered. >>\n"), CS_DEBUG);
} else if (UA_sock->msglen == BNET_START_SELECT ||
UA_sock->msglen == BNET_END_SELECT) {
break;
}
- if (is_bnet_stop(UA_sock)) {
+ if (UA_sock->is_stop()) {
csprint(NULL, CS_END);
break; /* error or term */
}
if (UA_sock) {
UA_sock->msglen = (int32_t)strlen(str);
pm_strcpy(&UA_sock->msg, str);
- bnet_send(UA_sock);
+ UA_sock->send();
} else if (choosingdirector) {
// wxString number = str;
// number.RemoveLast(); /* Removes \n */
void console_thread::Delete() {
Write("quit\n");
if (UA_sock) {
- bnet_sig(UA_sock, BNET_TERMINATE); /* send EOF */
- bnet_close(UA_sock);
+ UA_sock->signal(BNET_TERMINATE); /* send EOF */
+ UA_sock->close();
UA_sock = NULL;
/*csprint(NULL, CS_END);
csprint(NULL, CS_DISCONNECTED);