import bacula
def EndJob(jcr):
- jobid = jcr.get("JobId")
- client = jcr.get("Client")
- jcr.set(JobReport="Python EndJob output: JobId=%d Client=%s.\n" % (jobid, client))
- if (jobid < 2) :
- startid = bacula.run("run kernsave")
- print "Python started new Job: jobid=", startid
+ jobid = jcr.get("JobId")
+ client = jcr.get("Client")
+ jcr.set(JobReport="Python EndJob output: JobId=%d Client=%s.\n" % (jobid, client))
+ if (jobid < 2) :
+ startid = bacula.run("run kernsave")
+ print "Python started new Job: jobid=", startid
- return 1
+ return 1
all Volumes from other drives. "update slots all-drives"?
For 1.37:
+- Look at dird_conf.c:1000: warning: `int size'
+ might be used uninitialized in this function
- Make a callback when Rerun failed levels is called.
- Give Python program access to Scheduled jobs.
- Implement some way to turn off automatic pruning in Jobs.
/* Imported functions */
int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
-
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
/* Forward referenced functions */
static void terminate_console(int sig);
static BSOCK *UA_sock = NULL;
static DIRRES *dir;
static FILE *output = stdout;
-static bool tee = false; /* output to output and stdout */
+static bool tee = false; /* output to output and stdout */
static bool stop = false;
static int argc;
static POOLMEM *args;
{ N_("version"), versioncmd, _("print Console's version")},
{ N_("exit"), quitcmd, _("exit = quit")},
{ N_("zed_keyst"), zed_keyscmd, _("zed_keys = use zed keys instead of bash keys")},
- };
+ };
#define comsize (sizeof(commands)/sizeof(struct cmdstruct))
static int do_a_command(FILE *input, BSOCK *UA_sock)
return 1;
}
len = strlen(cmd);
- for (i=0; i<comsize; i++) { /* search for command */
+ for (i=0; i<comsize; i++) { /* search for command */
if (strncasecmp(cmd, _(commands[i].key), len) == 0) {
- stat = (*commands[i].func)(input, UA_sock); /* go execute command */
- found = 1;
- break;
+ stat = (*commands[i].func)(input, UA_sock); /* go execute command */
+ found = 1;
+ break;
}
}
if (!found) {
prompt = "";
} else {
prompt = "*";
- at_prompt = true;
+ at_prompt = true;
}
if (tty_input) {
- stat = get_cmd(input, prompt, UA_sock, 30);
- if (usrbrk() == 1) {
- clrbrk();
- }
- if (usrbrk()) {
- break;
- }
+ stat = get_cmd(input, prompt, UA_sock, 30);
+ if (usrbrk() == 1) {
+ clrbrk();
+ }
+ if (usrbrk()) {
+ break;
+ }
} else {
- /* Reading input from a file */
- int len = sizeof_pool_memory(UA_sock->msg) - 1;
- if (usrbrk()) {
- break;
- }
- if (fgets(UA_sock->msg, len, input) == NULL) {
- stat = -1;
- } else {
- sendit(UA_sock->msg); /* echo to terminal */
- strip_trailing_junk(UA_sock->msg);
- UA_sock->msglen = strlen(UA_sock->msg);
- stat = 1;
- }
+ /* Reading input from a file */
+ int len = sizeof_pool_memory(UA_sock->msg) - 1;
+ if (usrbrk()) {
+ break;
+ }
+ if (fgets(UA_sock->msg, len, input) == NULL) {
+ stat = -1;
+ } else {
+ sendit(UA_sock->msg); /* echo to terminal */
+ strip_trailing_junk(UA_sock->msg);
+ UA_sock->msglen = strlen(UA_sock->msg);
+ stat = 1;
+ }
}
if (stat < 0) {
- break; /* error or interrupt */
- } else if (stat == 0) { /* timeout */
+ break; /* error or interrupt */
+ } else if (stat == 0) { /* timeout */
if (strcmp(prompt, "*") == 0) {
bnet_fsend(UA_sock, ".messages");
- } else {
- continue;
- }
+ } else {
+ continue;
+ }
} else {
- at_prompt = FALSE;
- /* @ => internal command for us */
+ at_prompt = FALSE;
+ /* @ => internal command for us */
if (UA_sock->msg[0] == '@') {
- parse_args(UA_sock->msg, &args, &argc, argk, argv, MAX_CMD_ARGS);
- if (!do_a_command(input, UA_sock)) {
- break;
- }
- continue;
- }
- if (!bnet_send(UA_sock)) { /* send command */
- break; /* error */
- }
+ parse_args(UA_sock->msg, &args, &argc, argk, argv, MAX_CMD_ARGS);
+ if (!do_a_command(input, UA_sock)) {
+ break;
+ }
+ continue;
+ }
+ if (!bnet_send(UA_sock)) { /* send command */
+ break; /* error */
+ }
}
if (strcmp(UA_sock->msg, ".quit") == 0 || strcmp(UA_sock->msg, ".exit") == 0) {
- break;
+ break;
}
while ((stat = bnet_recv(UA_sock)) >= 0) {
- if (at_prompt) {
- if (!stop) {
+ if (at_prompt) {
+ if (!stop) {
sendit("\n");
- }
- at_prompt = false;
- }
- /* Suppress output if running in background or user hit ctl-c */
- if (!stop && !usrbrk()) {
- sendit(UA_sock->msg);
- }
+ }
+ at_prompt = false;
+ }
+ /* Suppress output if running in background or user hit ctl-c */
+ if (!stop && !usrbrk()) {
+ sendit(UA_sock->msg);
+ }
}
if (usrbrk() > 1) {
- break;
+ break;
} else {
- clrbrk();
+ clrbrk();
}
if (!stop) {
- fflush(stdout);
+ fflush(stdout);
}
if (is_bnet_stop(UA_sock)) {
- break; /* error or term */
+ break; /* error or term */
} else if (stat == BNET_SIGNAL) {
- if (UA_sock->msglen == BNET_PROMPT) {
- at_prompt = true;
- }
+ if (UA_sock->msglen == BNET_PROMPT) {
+ at_prompt = true;
+ }
Dmsg1(100, "Got poll %s\n", bnet_sig_to_ascii(UA_sock));
}
}
/*********************************************************************
*
- * Main Bacula Console -- User Interface Program
+ * Main Bacula Console -- User Interface Program
*
*/
int main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "bc:d:r:st?")) != -1) {
switch (ch) {
case 'c': /* configuration file */
- if (configfile != NULL) {
- free(configfile);
- }
- configfile = bstrdup(optarg);
- break;
+ if (configfile != NULL) {
+ free(configfile);
+ }
+ configfile = bstrdup(optarg);
+ break;
case 'd':
- debug_level = atoi(optarg);
- if (debug_level <= 0) {
- debug_level = 1;
- }
- break;
+ debug_level = atoi(optarg);
+ if (debug_level <= 0) {
+ debug_level = 1;
+ }
+ break;
case 's': /* turn off signals */
- no_signals = true;
- break;
+ no_signals = true;
+ break;
case 't':
- test_config = true;
- break;
+ test_config = true;
+ break;
case '?':
default:
- usage();
- con_term();
- exit(1);
+ usage();
+ con_term();
+ exit(1);
}
}
argc -= optind;
memset(&jcr, 0, sizeof(jcr));
- (void)WSA_Init(); /* Initialize Windows sockets */
+ (void)WSA_Init(); /* Initialize Windows sockets */
if (ndir > 1) {
struct sockaddr client_addr;
ndir = 0;
foreach_res(dir, R_DIRECTOR) {
senditf( _("%d %s at %s:%d\n"), 1+ndir++, dir->hdr.name, dir->address,
- dir->DIRport);
+ dir->DIRport);
}
UnlockRes();
if (get_cmd(stdin, _("Select Director: "), UA_sock, 600) < 0) {
- (void)WSACleanup(); /* Cleanup Windows sockets */
- return 1;
+ (void)WSACleanup(); /* Cleanup Windows sockets */
+ return 1;
}
item = atoi(UA_sock->msg);
if (item < 0 || item > ndir) {
senditf(_("You must enter a number between 1 and %d\n"), ndir);
- goto try_again;
+ goto try_again;
}
LockRes();
dir = NULL;
for (i=0; i<item; i++) {
- dir = (DIRRES *)GetNextRes(R_DIRECTOR, (RES *)dir);
+ dir = (DIRRES *)GetNextRes(R_DIRECTOR, (RES *)dir);
}
UnlockRes();
term_bsock(UA_sock);
senditf(_("Connecting to Director %s:%d\n"), dir->address,dir->DIRport);
UA_sock = bnet_connect(NULL, 5, 15, "Director daemon", dir->address,
- NULL, dir->DIRport, 0);
+ NULL, dir->DIRport, 0);
if (UA_sock == NULL) {
terminate_console(0);
return 1;
pm_strcat(&UA_sock->msg, "/.bconsolerc");
fd = fopen(UA_sock->msg, "r");
if (fd) {
- read_and_process_input(fd, UA_sock);
- fclose(fd);
+ read_and_process_input(fd, UA_sock);
+ fclose(fd);
}
}
static bool already_here = false;
- if (already_here) { /* avoid recursive temination problems */
+ if (already_here) { /* avoid recursive temination problems */
exit(1);
}
already_here = true;
free_pool_memory(args);
con_term();
- (void)WSACleanup(); /* Cleanup Windows sockets */
+ (void)WSACleanup(); /* Cleanup Windows sockets */
if (sig != 0) {
exit(1);
}
{
char *line;
- rl_catch_signals = 0; /* do it ourselves */
+ rl_catch_signals = 0; /* do it ourselves */
line = readline((char *)prompt); /* cast needed for old readlines */
if (!line) {
/*
* Returns: 1 if data available
- * 0 if timeout
- * -1 if error
+ * 0 if timeout
+ * -1 if error
*/
static int
wait_for_data(int fd, int sec)
FD_ZERO(&fdset);
FD_SET((unsigned)fd, &fdset);
switch(select(fd + 1, &fdset, NULL, NULL, &tv)) {
- case 0: /* timeout */
- return 0;
+ case 0: /* timeout */
+ return 0;
case -1:
- if (errno == EINTR || errno == EAGAIN) {
- continue;
- }
- return -1; /* error return */
+ if (errno == EINTR || errno == EAGAIN) {
+ continue;
+ }
+ return -1; /* error return */
default:
- return 1;
+ return 1;
}
}
}
* Get next input command from terminal.
*
* Returns: 1 if got input
- * 0 if timeout
- * -1 if EOF or error
+ * 0 if timeout
+ * -1 if EOF or error
*/
int
get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
int len;
if (!stop) {
if (output == stdout || tee) {
- sendit(prompt);
+ sendit(prompt);
}
}
again:
switch (wait_for_data(fileno(input), sec)) {
case 0:
- return 0; /* timeout */
+ return 0; /* timeout */
case -1:
- return -1; /* error */
+ return -1; /* error */
default:
len = sizeof_pool_memory(sock->msg) - 1;
if (stop) {
- sleep(1);
- goto again;
+ sleep(1);
+ goto again;
}
#ifdef HAVE_CONIO
if (isatty(fileno(input))) {
- input_line(sock->msg, len);
- break;
+ input_line(sock->msg, len);
+ break;
}
#endif
if (fgets(sock->msg, len, input) == NULL) {
- return -1;
+ return -1;
}
break;
}
fd = fopen(argk[1], "r");
if (!fd) {
senditf(_("Cannot open file %s for input. ERR=%s\n"),
- argk[1], strerror(errno));
+ argk[1], strerror(errno));
return 1;
}
read_and_process_input(fd, UA_sock);
}
if (argc == 1) {
if (output != stdout) {
- fclose(output);
- output = stdout;
- tee = false;
+ fclose(output);
+ output = stdout;
+ tee = false;
}
return 1;
}
fd = fopen(argk[1], mode);
if (!fd) {
senditf(_("Cannot open file %s for output. ERR=%s\n"),
- argk[1], strerror(errno));
+ argk[1], strerror(errno));
return 1;
}
output = fd;
char *p, *q;
/*
* Here, we convert every \n into \r\n because the
- * terminal is in raw mode when we are using
- * conio.
- */
+ * terminal is in raw mode when we are using
+ * conio.
+ */
for (p=q=buf; (p=strchr(q, '\n')); ) {
- if (p-q > 0) {
- t_sendl(q, p-q);
- }
+ if (p-q > 0) {
+ t_sendl(q, p-q);
+ }
t_sendl("\r\n", 2);
q = ++p; /* point after \n */
}
if (*q) {
- t_send(q);
+ t_send(q);
}
}
if (output != stdout) {
goto bail_out;
}
}
+ } else {
+ goto bail_out;
}
pr.NumVols++;
if (db_create_media_record(jcr, jcr->db, mr) &&
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2004-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
static PyObject *jcr_write(PyObject *self, PyObject *args);
static PyObject *jcr_set(PyObject *self, PyObject *args, PyObject *keyw);
static PyObject *set_jcr_events(PyObject *self, PyObject *args);
-
-PyObject *bacula_run(PyObject *self, PyObject *args);
+static PyObject *jcr_run(PyObject *self, PyObject *args);
/* Define Job entry points */
PyMethodDef JobMethods[] = {
"Set Job variables."},
{"set_events", set_jcr_events, METH_VARARGS, "Define Job events."},
{"write", jcr_write, METH_VARARGS, "Write output."},
-// {"run", (PyCFunction)bacula_run, METH_VARARGS, "Run a Bacula command."},
+ {"run", (PyCFunction)jcr_run, METH_VARARGS, "Run a Bacula command."},
{NULL, NULL, 0, NULL} /* last item */
};
static PyObject *open_method = NULL;
static PyObject *read_method = NULL;
static PyObject *close_method = NULL;
-static PyObject *volname_method = NULL;
struct s_vars {
const char *name;
open_method = find_method(eObject, open_method, "open");
read_method = find_method(eObject, read_method, "read");
close_method = find_method(eObject, close_method, "close");
- volname_method = find_method(eObject, volname_method, "VolumeName");
Py_INCREF(Py_None);
return Py_None;
}
return Py_None;
}
+/* Run a Bacula command */
+static PyObject *jcr_run(PyObject *self, PyObject *args)
+{
+ JCR *jcr;
+ char *item;
+ int stat;
+
+ if (!PyArg_ParseTuple(args, "s:get", &item)) {
+ return NULL;
+ }
+ jcr = get_jcr_from_PyObject(self);
+ UAContext *ua = new_ua_context(jcr);
+ ua->batch = true;
+ pm_strcpy(ua->cmd, item); /* copy command */
+ parse_ua_args(ua); /* parse command */
+ stat = run_cmd(ua, ua->cmd);
+ free_ua_context(ua);
+ return Py_BuildValue("i", stat);
+}
+
+
int generate_job_event(JCR *jcr, const char *event)
{
+#ifdef xxx
+ PyObject *eObject, *method;
PyEval_AcquireLock();
- PyObject *result = PyObject_CallFunction(open_method, "s", "m.py");
+ method = find_method(eObject, method, event);
+
+ PyObject *result = PyObject_CallFunction(method, "s", "m.py");
if (result == NULL) {
PyErr_Print();
PyErr_Clear();
Py_XDECREF(result);
PyEval_ReleaseLock();
+#endif
return 1;
}
#else
/* Dummy if Python not configured */
-int generate_job_event(JCR *jcr, const char *event)
-{ return 1; }
+int generate_job_event(JCR *jcr, const char *event) { return 1; }
#endif /* HAVE_PYTHON */
-
-#ifdef xxx
-/* Run a Bacula command */
-PyObject *bacula_run(PyObject *self, PyObject *args)
-{
- JCR *jcr;
- char *item;
- int stat;
-
- if (!PyArg_ParseTuple(args, "s:get", &item)) {
- return NULL;
- }
- jcr = get_jcr_from_PyObject(self);
- UAContext *ua = new_ua_context(jcr);
- ua->batch = true;
- pm_strcpy(ua->cmd, item); /* copy command */
- parse_ua_args(ua); /* parse command */
- stat = run_cmd(ua, ua->cmd);
- free_ua_context(ua);
- return Py_BuildValue("i", stat);
-}
-#endif
int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
void select_restore_setup();
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
+
/* Exported variables */
GtkWidget *console; /* application window */
-GtkWidget *text1; /* text window */
-GtkWidget *entry1; /* entry box */
-GtkWidget *status1; /* status bar */
-GtkWidget *combo1; /* director combo */
-GtkWidget *scroll1; /* main scroll bar */
-GtkWidget *run_dialog; /* run dialog */
-GtkWidget *dir_dialog; /* director selection dialog */
+GtkWidget *text1; /* text window */
+GtkWidget *entry1; /* entry box */
+GtkWidget *status1; /* status bar */
+GtkWidget *combo1; /* director combo */
+GtkWidget *scroll1; /* main scroll bar */
+GtkWidget *run_dialog; /* run dialog */
+GtkWidget *dir_dialog; /* director selection dialog */
GtkWidget *restore_dialog; /* restore dialog */
GtkWidget *restore_file_selection;
GtkWidget *dir_select;
-GtkWidget *about1; /* about box */
+GtkWidget *about1; /* about box */
GtkWidget *label_dialog;
GdkFont *text_font = NULL;
PangoFontDescription *font_desc;
pthread_mutex_t cmd_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t cmd_wait;
+pthread_cond_t cmd_wait;
char cmd[1000];
int reply;
BSOCK *UA_sock = NULL;
/*********************************************************************
*
- * Main Bacula GNOME Console -- User Interface Program
+ * Main Bacula GNOME Console -- User Interface Program
*
*/
int main(int argc, char *argv[])
if ((stat=pthread_cond_init(&cmd_wait, NULL)) != 0) {
Emsg1(M_ABORT, 0, _("Pthread cond init error = %s\n"),
- strerror(stat));
+ strerror(stat));
}
gnome_init("bacula", VERSION, gargc, (char **)&gargv);
while ((ch = getopt(argc, argv, "bc:d:r:st?")) != -1) {
switch (ch) {
case 'c': /* configuration file */
- if (configfile != NULL)
- free(configfile);
- configfile = bstrdup(optarg);
- break;
+ if (configfile != NULL)
+ free(configfile);
+ configfile = bstrdup(optarg);
+ break;
case 'd':
- debug_level = atoi(optarg);
- if (debug_level <= 0)
- debug_level = 1;
- break;
+ debug_level = atoi(optarg);
+ if (debug_level <= 0)
+ debug_level = 1;
+ break;
case 's': /* turn off signals */
- no_signals = TRUE;
- break;
+ no_signals = TRUE;
+ break;
case 't':
- test_config = TRUE;
- break;
+ test_config = TRUE;
+ break;
case '?':
default:
- usage();
+ usage();
}
}
argc -= optind;
LockRes();
foreach_res(con_font, R_CONSOLE_FONT) {
if (!con_font->fontface) {
- Dmsg1(400, "No fontface for %s\n", con_font->hdr.name);
- continue;
+ Dmsg1(400, "No fontface for %s\n", con_font->hdr.name);
+ continue;
}
text_font = gdk_font_load(con_font->fontface);
if (text_font == NULL) {
- Dmsg2(400, "Load of requested ConsoleFont \"%s\" (%s) failed!\n",
- con_font->hdr.name, con_font->fontface);
+ Dmsg2(400, "Load of requested ConsoleFont \"%s\" (%s) failed!\n",
+ con_font->hdr.name, con_font->fontface);
} else {
- Dmsg2(400, "ConsoleFont \"%s\" (%s) loaded.\n",
- con_font->hdr.name, con_font->fontface);
- break;
+ Dmsg2(400, "ConsoleFont \"%s\" (%s) loaded.\n",
+ con_font->hdr.name, con_font->fontface);
+ break;
}
}
UnlockRes();
if (text_font == NULL) {
Dmsg1(400, "Attempting to load fallback font %s\n",
- "-misc-fixed-medium-r-normal-*-*-130-*-*-c-*-iso8859-1");
+ "-misc-fixed-medium-r-normal-*-*-130-*-*-c-*-iso8859-1");
text_font = gdk_font_load("-misc-fixed-medium-r-normal-*-*-130-*-*-c-*-iso8859-1");
}
font_desc = pango_font_description_from_string("LucidaTypewriter 9");
if (ndir > 1) {
LockRes();
foreach_res(dir, R_DIRECTOR) {
- dirs = g_list_append(dirs, dir->hdr.name);
+ dirs = g_list_append(dirs, dir->hdr.name);
}
UnlockRes();
dir_dialog = create_SelectDirectorDialog();
combo = lookup_widget(dir_dialog, "combo1");
dir_select = lookup_widget(dir_dialog, "dirselect");
if (dirs) {
- gtk_combo_set_popdown_strings(GTK_COMBO(combo), dirs);
+ gtk_combo_set_popdown_strings(GTK_COMBO(combo), dirs);
}
gtk_widget_show(dir_dialog);
gtk_main();
if (reply == OK) {
- gchar *ecmd = gtk_editable_get_chars((GtkEditable *)dir_select, 0, -1);
- dir = (DIRRES *)GetResWithName(R_DIRECTOR, ecmd);
- if (ecmd) {
- g_free(ecmd); /* release director name string */
- }
+ gchar *ecmd = gtk_editable_get_chars((GtkEditable *)dir_select, 0, -1);
+ dir = (DIRRES *)GetResWithName(R_DIRECTOR, ecmd);
+ if (ecmd) {
+ g_free(ecmd); /* release director name string */
+ }
}
if (dirs) {
- g_free(dirs);
+ g_free(dirs);
}
gtk_widget_destroy(dir_dialog);
dir_dialog = NULL;
gtk_main_iteration();
}
UA_sock = bnet_connect(NULL, 5, 15, "Director daemon", dir->address,
- NULL, dir->DIRport, 0);
+ NULL, dir->DIRport, 0);
if (UA_sock == NULL) {
return 0;
}
stat = bnet_recv(UA_sock);
if (stat >= 0) {
if (at_prompt) {
- set_text("\n", 1);
- at_prompt = false;
+ set_text("\n", 1);
+ at_prompt = false;
}
set_text(UA_sock->msg, UA_sock->msglen);
return;
}
- if (is_bnet_stop(UA_sock)) { /* error or term request */
+ if (is_bnet_stop(UA_sock)) { /* error or term request */
gtk_main_quit();
return;
}
{
static int already_here = FALSE;
- if (already_here) /* avoid recursive temination problems */
+ if (already_here) /* avoid recursive temination problems */
exit(1);
already_here = TRUE;
disconnect_from_director((gpointer)NULL);
/* Buffer approx 2000 lines -- assume 60 chars/line */
-#define MAX_TEXT_CHARS (2000 * 60)
+#define MAX_TEXT_CHARS (2000 * 60)
static int text_chars = 0;
static void truncate_text_chars()
gtk_text_iter_set_offset(&iter, buf_len);
gtk_text_buffer_place_cursor(textbuf, &iter);
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(text1),
- gtk_text_buffer_get_mark(textbuf, "insert"),
- 0, TRUE, 0.0, 1.0);
+ gtk_text_buffer_get_mark(textbuf, "insert"),
+ 0, TRUE, 0.0, 1.0);
}
void init_python_interpreter(const char *progname, const char *scripts,
const char *module);
void term_python_interpreter();
-extern EVENT_HANDLER *generate_daemon_event;
+//extern EVENT_HANDLER *generate_daemon_event;
+int generate_daemon_event(JCR *jcr, const char *event);
/* signal.c */
void init_signals (void terminate(int sig));
#include "bacula.h"
#include "jcr.h"
-EVENT_HANDLER *generate_daemon_event;
-
#ifdef HAVE_PYTHON
#undef _POSIX_C_SOURCE
static PyObject *set_bacula_events(PyObject *self, PyObject *args);
static PyObject *bacula_write(PyObject *self, PyObject *args);
-int _generate_daemon_event(JCR *jcr, const char *event);
PyObject *find_method(PyObject *eventsObject, PyObject *method, char *name);
};
-/* Pull in Bacula entry points */
-extern PyMethodDef JobMethods[];
-
-
/*
* This is a Bacula Job type as defined in Python. We store a pointer
* to the jcr. That is all we need, but the user's script may keep
PyErr_Clear();
}
PyEval_ReleaseLock();
- generate_daemon_event = _generate_daemon_event;
}
-
void term_python_interpreter()
{
Py_XDECREF(StartUp_module);
* -1 on Python error
* 1 OK
*/
-int _generate_daemon_event(JCR *jcr, const char *event)
+int generate_daemon_event(JCR *jcr, const char *event)
{
PyObject *pJCR;
int stat = -1;
* No Python configured -- create external entry points and
* dummy routines so that library code can call this without
* problems even if it is not configured.
-
*/
-
-int _generate_daemon_event(JCR *jcr, const char *event) { return 0; }
+int generate_daemon_event(JCR *jcr, const char *event) { return 0; }
void init_python_interpreter(const char *progname, const char *scripts,
- const char *module)
-{
- generate_daemon_event = _generate_daemon_event;
-}
+ const char *module) { }
void term_python_interpreter() { }
-
#endif /* HAVE_PYTHON */
btape: $(TAPEOBJS) ../lib/libbac.a ../cats/libsql.a
$(CXX) $(TTOOL_LDFLAGS) $(LDFLAGS) -L../lib -L../cats -o $@ $(TAPEOBJS) \
- -lsql $(DLIB) -lbac -lm $(PYTHON_LIBS) $(LIBS)
+ -lsql $(DLIB) -lbac -lm $(LIBS)
bls.o: bls.c
$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) \
bls: ../findlib/libfind.a $(BLSOBJS) ../lib/libbac.a
$(CXX) $(TTOOL_LDFLAGS) $(LDFLAGS) -L../lib -L../findlib -o $@ $(BLSOBJS) $(DLIB) -lfind \
- -lbac -lm $(PYTHON_LIBS) $(LIBS)
+ -lbac -lm $(LIBS)
bextract.o: bextract.c
$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) \
bscan: ../findlib/libfind.a $(SCNOBJS) ../cats/libsql.a
$(CXX) $(TTOOL_LDFLAGS) $(LDFLAGS) -L../lib -L../cats -L../findlib -o $@ $(SCNOBJS) \
- -lsql $(DB_LIBS) $(FDLIBS) -lfind -lbac -lm $(PYTHON_LIBS) $(LIBS)
+ -lsql $(DB_LIBS) $(FDLIBS) -lfind -lbac -lm $(LIBS)
bcopy.o: bcopy.c
- $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) \
+ $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) \
-I$(basedir) $(DINCLUDE) $(CFLAGS) $<
bcopy: $(COPYOBJS) ../findlib/libfind.a ../lib/libbac.a
$(CXX) $(TTOOL_LDFLAGS) $(LDFLAGS) -L../lib -L../findlib -o $@ $(COPYOBJS) \
- $(DB_LIBS) $(FDLIBS) -lfind -lbac -lm $(PYTHON_LIBS) $(LIBS)
+ $(DB_LIBS) $(FDLIBS) -lfind -lbac -lm $(LIBS)
Makefile: $(srcdir)/Makefile.in $(topdir)/config.status
#include "bacula.h"
#include "stored.h"
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
+
/* Forward referenced functions */
static bool record_cb(DCR *dcr, DEV_RECORD *rec);
/* Global variables */
static DEVICE *in_dev = NULL;
static DEVICE *out_dev = NULL;
-static JCR *in_jcr; /* input jcr */
-static JCR *out_jcr; /* output jcr */
+static JCR *in_jcr; /* input jcr */
+static JCR *out_jcr; /* output jcr */
static BSR *bsr = NULL;
static const char *wd = "/tmp";
static int list_records = 0;
#define CONFIG_FILE "bacula-sd.conf"
char *configfile;
-STORES *me = NULL; /* our Global resource */
-bool forge_on = false; /* proceed inspite of I/O errors */
+STORES *me = NULL; /* our Global resource */
+bool forge_on = false; /* proceed inspite of I/O errors */
pthread_mutex_t device_release_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t wait_device_release = PTHREAD_COND_INITIALIZER;
while ((ch = getopt(argc, argv, "b:c:d:i:o:pvw:?")) != -1) {
switch (ch) {
case 'b':
- bsr = parse_bsr(NULL, optarg);
- break;
+ bsr = parse_bsr(NULL, optarg);
+ break;
case 'c': /* specify config file */
- if (configfile != NULL) {
- free(configfile);
- }
- configfile = bstrdup(optarg);
- break;
+ if (configfile != NULL) {
+ free(configfile);
+ }
+ configfile = bstrdup(optarg);
+ break;
case 'd': /* debug level */
- debug_level = atoi(optarg);
- if (debug_level <= 0)
- debug_level = 1;
- break;
+ debug_level = atoi(optarg);
+ if (debug_level <= 0)
+ debug_level = 1;
+ break;
case 'i': /* input Volume name */
- iVolumeName = optarg;
- break;
+ iVolumeName = optarg;
+ break;
case 'o': /* output Volume name */
- oVolumeName = optarg;
- break;
+ oVolumeName = optarg;
+ break;
case 'p':
- ignore_label_errors = true;
- forge_on = true;
- break;
+ ignore_label_errors = true;
+ forge_on = true;
+ break;
case 'v':
- verbose++;
- break;
+ verbose++;
+ break;
case 'w':
- wd = optarg;
- break;
+ wd = optarg;
+ break;
case '?':
default:
- usage();
+ usage();
}
}
{
if (list_records) {
Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
- rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
- rec->Stream, rec->data_len);
+ rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
+ rec->Stream, rec->data_len);
}
/*
* Check for Start or End of Session Record
if (rec->FileIndex < 0) {
if (verbose > 1) {
- dump_label_record(in_dcr->dev, rec, 1);
+ dump_label_record(in_dcr->dev, rec, 1);
}
switch (rec->FileIndex) {
case PRE_LABEL:
Pmsg0(000, "Volume is prelabeled. This volume cannot be copied.\n");
- return false;
+ return false;
case VOL_LABEL:
Pmsg0(000, "Volume label not copied.\n");
- return true;
+ return true;
case SOS_LABEL:
- jobs++;
- break;
+ jobs++;
+ break;
case EOS_LABEL:
- while (!write_record_to_block(out_block, rec)) {
+ while (!write_record_to_block(out_block, rec)) {
Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
- rec->remainder);
- if (!write_block_to_device(out_jcr->dcr)) {
+ rec->remainder);
+ if (!write_block_to_device(out_jcr->dcr)) {
Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
- out_dev->print_name(), strerror_dev(out_dev));
+ out_dev->print_name(), strerror_dev(out_dev));
Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
- strerror_dev(out_dev));
- }
- }
- if (!write_block_to_device(out_jcr->dcr)) {
+ strerror_dev(out_dev));
+ }
+ }
+ if (!write_block_to_device(out_jcr->dcr)) {
Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
- out_dev->print_name(), strerror_dev(out_dev));
+ out_dev->print_name(), strerror_dev(out_dev));
Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
- strerror_dev(out_dev));
- }
- break;
+ strerror_dev(out_dev));
+ }
+ break;
case EOM_LABEL:
Pmsg0(000, "EOM label not copied.\n");
- return true;
- case EOT_LABEL: /* end of all tapes */
+ return true;
+ case EOT_LABEL: /* end of all tapes */
Pmsg0(000, "EOT label not copied.\n");
- return true;
+ return true;
default:
- break;
+ break;
}
}
records++;
while (!write_record_to_block(out_block, rec)) {
Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
- rec->remainder);
+ rec->remainder);
if (!write_block_to_device(out_jcr->dcr)) {
Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
- out_dev->print_name(), strerror_dev(out_dev));
+ out_dev->print_name(), strerror_dev(out_dev));
Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
- strerror_dev(out_dev));
- break;
+ strerror_dev(out_dev));
+ break;
}
}
return true;
/* Dummies to replace askdir.c */
-bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing) { return 1;}
-bool dir_find_next_appendable_volume(DCR *dcr) { return 1;}
-bool dir_update_volume_info(DCR *dcr, bool relabel) { return 1; }
-bool dir_create_jobmedia_record(DCR *dcr) { return 1; }
-bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) { return 1; }
-bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
-bool dir_send_job_status(JCR *jcr) {return 1;}
+bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing) { return 1;}
+bool dir_find_next_appendable_volume(DCR *dcr) { return 1;}
+bool dir_update_volume_info(DCR *dcr, bool relabel) { return 1; }
+bool dir_create_jobmedia_record(DCR *dcr) { return 1; }
+bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) { return 1; }
+bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
+bool dir_send_job_status(JCR *jcr) {return 1;}
bool dir_ask_sysop_to_mount_volume(DCR *dcr)
int win32_client = 0;
#endif
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
+
static void do_blocks(char *infname);
static void do_jobs(char *infname);
static void do_ls(char *fname);
#include "stored.h"
#include "findlib/find.h"
#include "cats/cats.h"
+
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
/* Forward referenced functions */
static void do_scan(void);
#include "bacula.h"
#include "stored.h"
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
/* External subroutines */
extern void free_config_resources();
#endif
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event)
+ { return 1; }
#ifndef MAXSTRING
#define MAXSTRING 254
Dmsg0(50, "Calling fgets on read socket rfp.\n");
buf[3] = 0;
while (fgets(buf, sizeof(buf), rfp)) {
- int len = strlen(buf);
- if (len > 0) {
- buf[len-1] = 0;
- }
- Dmsg2(10, "%s --> %s\n", mailhost, buf);
- if (!isdigit((int)buf[0]) || buf[0] > '3') {
- Pmsg2(0, "Fatal malformed reply from %s: %s\n", mailhost, buf);
- exit(1);
- }
- if (buf[3] != '-') {
- break;
- }
+ int len = strlen(buf);
+ if (len > 0) {
+ buf[len-1] = 0;
+ }
+ Dmsg2(10, "%s --> %s\n", mailhost, buf);
+ if (!isdigit((int)buf[0]) || buf[0] > '3') {
+ Pmsg2(0, "Fatal malformed reply from %s: %s\n", mailhost, buf);
+ exit(1);
+ }
+ if (buf[3] != '-') {
+ break;
+ }
}
return;
}
while ((ch = getopt(argc, argv, "c:d:f:h:r:s:?")) != -1) {
switch (ch) {
case 'c':
- Dmsg1(20, "cc=%s\n", optarg);
- cc_addr = optarg;
- break;
+ Dmsg1(20, "cc=%s\n", optarg);
+ cc_addr = optarg;
+ break;
case 'd': /* set debug level */
- debug_level = atoi(optarg);
- if (debug_level <= 0) {
- debug_level = 1;
- }
- Dmsg1(20, "Debug level = %d\n", debug_level);
- break;
+ debug_level = atoi(optarg);
+ if (debug_level <= 0) {
+ debug_level = 1;
+ }
+ Dmsg1(20, "Debug level = %d\n", debug_level);
+ break;
case 'f': /* from */
- from_addr = optarg;
- break;
+ from_addr = optarg;
+ break;
case 'h': /* smtp host */
- Dmsg1(20, "host=%s\n", optarg);
- p = strchr(optarg, ':');
- if (p) {
- *p++ = 0;
- mailport = atoi(p);
- }
- mailhost = optarg;
- break;
+ Dmsg1(20, "host=%s\n", optarg);
+ p = strchr(optarg, ':');
+ if (p) {
+ *p++ = 0;
+ mailport = atoi(p);
+ }
+ mailhost = optarg;
+ break;
case 's': /* subject */
- Dmsg1(20, "subject=%s\n", optarg);
- subject = optarg;
- break;
+ Dmsg1(20, "subject=%s\n", optarg);
+ subject = optarg;
+ break;
case 'r': /* reply address */
- reply_addr = optarg;
- break;
+ reply_addr = optarg;
+ break;
case '?':
default:
- usage();
+ usage();
}
}
*/
if (mailhost == NULL) {
if ((cp = getenv("SMTPSERVER")) != NULL) {
- mailhost = cp;
+ mailhost = cp;
} else {
- mailhost = "localhost";
+ mailhost = "localhost";
}
}
}
if ((hp = gethostbyname(my_hostname)) == NULL) {
Pmsg2(0, "Fatal gethostbyname for myself failed \"%s\": ERR=%s\n", my_hostname,
- strerror(errno));
+ strerror(errno));
exit(1);
}
strcpy(my_hostname, hp->h_name);
*/
if (from_addr == NULL) {
if ((pwd = getpwuid(getuid())) == 0) {
- sprintf(buf, "userid-%d@%s", (int)getuid(), my_hostname);
+ sprintf(buf, "userid-%d@%s", (int)getuid(), my_hostname);
} else {
- sprintf(buf, "%s@%s", pwd->pw_name, my_hostname);
+ sprintf(buf, "%s@%s", pwd->pw_name, my_hostname);
}
from_addr = bstrdup(buf);
}
hp:
if ((hp = gethostbyname(mailhost)) == NULL) {
Pmsg2(0, "Error unknown mail host \"%s\": ERR=%s\n", mailhost,
- strerror(errno));
+ strerror(errno));
if (strcasecmp(mailhost, "localhost") != 0) {
- Pmsg0(0, "Retrying connection using \"localhost\".\n");
- mailhost = "localhost";
- goto hp;
+ Pmsg0(0, "Retrying connection using \"localhost\".\n");
+ mailhost = "localhost";
+ goto hp;
}
exit(1);
}
while (fgets(buf, sizeof(buf), stdin)) {
buf[strlen(buf)-1] = 0;
if (strcmp(buf, ".") == 0) { /* quote lone dots */
- fprintf(sfp, "..\r\n");
- } else { /* pass body through unchanged */
- fprintf(sfp, "%s\r\n", buf);
+ fprintf(sfp, "..\r\n");
+ } else { /* pass body through unchanged */
+ fprintf(sfp, "%s\r\n", buf);
}
}
#include "cats/cats.h"
#include "dird/dird_conf.h"
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event)
+ { return 1; }
+
typedef struct s_id_ctx {
- uint32_t *Id; /* ids to be modified */
- int num_ids; /* ids stored */
- int max_ids; /* size of array */
- int num_del; /* number deleted */
- int tot_ids; /* total to process */
+ uint32_t *Id; /* ids to be modified */
+ int num_ids; /* ids stored */
+ int max_ids; /* size of array */
+ int num_del; /* number deleted */
+ int tot_ids; /* total to process */
} ID_LIST;
typedef struct s_name_ctx {
- char **name; /* list of names */
- int num_ids; /* ids stored */
- int max_ids; /* size of array */
- int num_del; /* number deleted */
- int tot_ids; /* total to process */
+ char **name; /* list of names */
+ int num_ids; /* ids stored */
+ int max_ids; /* size of array */
+ int num_del; /* number deleted */
+ int tot_ids; /* total to process */
} NAME_LIST;
char *catalogname = NULL;
my_name_is(argc, argv, "dbcheck");
- init_msg(NULL, NULL); /* setup message handler */
+ init_msg(NULL, NULL); /* setup message handler */
memset(&id_list, 0, sizeof(id_list));
memset(&name_list, 0, sizeof(name_list));
while ((ch = getopt(argc, argv, "bc:C:d:fv?")) != -1) {
switch (ch) {
case 'b': /* batch */
- batch = true;
- break;
+ batch = true;
+ break;
case 'C': /* CatalogName */
- catalogname = optarg;
- break;
+ catalogname = optarg;
+ break;
case 'c': /* configfile */
- configfile = optarg;
- break;
+ configfile = optarg;
+ break;
case 'd': /* debug level */
- debug_level = atoi(optarg);
- if (debug_level <= 0)
- debug_level = 1;
- break;
+ debug_level = atoi(optarg);
+ if (debug_level <= 0)
+ debug_level = 1;
+ break;
case 'f': /* fix inconsistencies */
- fix = true;
- break;
+ fix = true;
+ break;
case 'v':
- verbose++;
- break;
+ verbose++;
+ break;
case '?':
default:
- usage();
+ usage();
}
}
argc -= optind;
CAT *catalog = NULL;
int found = 0;
if (argc > 0) {
- Pmsg0(0, _("Warning skipping the additional parameters for working directory/dbname/user/password/host.\n"));
+ Pmsg0(0, _("Warning skipping the additional parameters for working directory/dbname/user/password/host.\n"));
}
parse_config(configfile);
LockRes();
foreach_res(catalog, R_CATALOG) {
- if (catalogname && !strcmp(catalog->hdr.name, catalogname)) {
- ++found;
- break;
- } else if (!catalogname) { // stop on first if no catalogname is given
- ++found;
- break;
- }
+ if (catalogname && !strcmp(catalog->hdr.name, catalogname)) {
+ ++found;
+ break;
+ } else if (!catalogname) { // stop on first if no catalogname is given
+ ++found;
+ break;
+ }
}
UnlockRes();
if (!found) {
- if (catalogname) {
- Pmsg2(0, "Error can not find the Catalog name[%s] in the given config file [%s]\n", catalogname, configfile);
- } else {
- Pmsg1(0, "Error there is no Catalog section in the given config file [%s]\n", configfile);
- }
- exit(1);
+ if (catalogname) {
+ Pmsg2(0, "Error can not find the Catalog name[%s] in the given config file [%s]\n", catalogname, configfile);
+ } else {
+ Pmsg1(0, "Error there is no Catalog section in the given config file [%s]\n", configfile);
+ }
+ exit(1);
} else {
- DIRRES *director;
- LockRes();
- director = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
- UnlockRes();
- if (!director) {
- Pmsg0(0, "Error no Director resource defined.\n");
- exit(1);
- }
- set_working_directory(director->working_directory);
- db_name = catalog->db_name;
- user = catalog->db_user;
- password = catalog->db_password;
- dbhost = catalog->db_address;
- if (dbhost && dbhost[0] == 0) {
- dbhost = NULL;
- }
+ DIRRES *director;
+ LockRes();
+ director = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
+ UnlockRes();
+ if (!director) {
+ Pmsg0(0, "Error no Director resource defined.\n");
+ exit(1);
+ }
+ set_working_directory(director->working_directory);
+ db_name = catalog->db_name;
+ user = catalog->db_user;
+ password = catalog->db_password;
+ dbhost = catalog->db_address;
+ if (dbhost && dbhost[0] == 0) {
+ dbhost = NULL;
+ }
}
} else {
if (argc > 5) {
- Pmsg0(0, _("Wrong number of arguments.\n"));
- usage();
+ Pmsg0(0, _("Wrong number of arguments.\n"));
+ usage();
}
if (argc < 1) {
- Pmsg0(0, _("Working directory not supplied.\n"));
- usage();
+ Pmsg0(0, _("Working directory not supplied.\n"));
+ usage();
}
/* This is needed by SQLite to find the db */
dbhost = NULL;
if (argc == 2) {
- db_name = argv[1];
- user = db_name;
+ db_name = argv[1];
+ user = db_name;
} else if (argc == 3) {
- db_name = argv[1];
- user = argv[2];
+ db_name = argv[1];
+ user = argv[2];
} else if (argc == 4) {
- db_name = argv[1];
- user = argv[2];
- password = argv[3];
+ db_name = argv[1];
+ user = argv[2];
+ password = argv[3];
} else if (argc == 5) {
- db_name = argv[1];
- user = argv[2];
- password = argv[3];
- dbhost = argv[4];
+ db_name = argv[1];
+ user = argv[2];
+ password = argv[3];
+ dbhost = argv[4];
}
}
db = db_init_database(NULL, db_name, user, password, dbhost, 0, NULL, 0);
if (!db_open_database(NULL, db)) {
Emsg1(M_FATAL, 0, "%s", db_strerror(db));
- return 1;
+ return 1;
}
if (batch) {
printf("Hello, this is the database check/correct program.\n"
"Modify database is %s. Verbose is %s.\n"
"Please select the fuction you want to perform.\n",
- fix?"On":"Off", verbose?"On":"Off");
+ fix?"On":"Off", verbose?"On":"Off");
while (!quit) {
if (fix) {
- printf(_("\n"
+ printf(_("\n"
" 1) Toggle modify database flag\n"
" 2) Toggle verbose flag\n"
" 3) Repair bad Filename records\n"
" 16) All (3-15)\n"
" 17) Quit\n"));
} else {
- printf(_("\n"
+ printf(_("\n"
" 1) Toggle modify database flag\n"
" 2) Toggle verbose flag\n"
" 3) Check for bad Filename records\n"
cmd = get_cmd(_("Select function number: "));
if (cmd) {
- int item = atoi(cmd);
- switch (item) {
- case 1:
- fix = !fix;
- printf(_("Database will %sbe modified.\n"), fix?"":_("NOT "));
- break;
- case 2:
- verbose = verbose?0:1;
- printf(_("Verbose is %s\n"), verbose?_("On"):_("Off"));
- break;
- case 3:
- repair_bad_filenames();
- break;
- case 4:
- repair_bad_paths();
- break;
- case 5:
- eliminate_duplicate_filenames();
- break;
- case 6:
- eliminate_duplicate_paths();
- break;
- case 7:
- eliminate_orphaned_jobmedia_records();
- break;
- case 8:
- eliminate_orphaned_file_records();
- break;
- case 9:
- eliminate_orphaned_path_records();
- break;
- case 10:
- eliminate_orphaned_filename_records();
- break;
- case 11:
- eliminate_orphaned_fileset_records();
- break;
- case 12:
- eliminate_orphaned_client_records();
- break;
- case 13:
- eliminate_orphaned_job_records();
- break;
- case 14:
- eliminate_admin_records();
- break;
- case 15:
- eliminate_restore_records();
- break;
- case 16:
- repair_bad_filenames();
- repair_bad_paths();
- eliminate_duplicate_filenames();
- eliminate_duplicate_paths();
- eliminate_orphaned_jobmedia_records();
- eliminate_orphaned_file_records();
- eliminate_orphaned_path_records();
- eliminate_orphaned_filename_records();
- eliminate_orphaned_fileset_records();
- eliminate_orphaned_client_records();
- eliminate_orphaned_job_records();
- eliminate_admin_records();
- eliminate_restore_records();
- break;
- case 17:
- quit = true;
- break;
- }
+ int item = atoi(cmd);
+ switch (item) {
+ case 1:
+ fix = !fix;
+ printf(_("Database will %sbe modified.\n"), fix?"":_("NOT "));
+ break;
+ case 2:
+ verbose = verbose?0:1;
+ printf(_("Verbose is %s\n"), verbose?_("On"):_("Off"));
+ break;
+ case 3:
+ repair_bad_filenames();
+ break;
+ case 4:
+ repair_bad_paths();
+ break;
+ case 5:
+ eliminate_duplicate_filenames();
+ break;
+ case 6:
+ eliminate_duplicate_paths();
+ break;
+ case 7:
+ eliminate_orphaned_jobmedia_records();
+ break;
+ case 8:
+ eliminate_orphaned_file_records();
+ break;
+ case 9:
+ eliminate_orphaned_path_records();
+ break;
+ case 10:
+ eliminate_orphaned_filename_records();
+ break;
+ case 11:
+ eliminate_orphaned_fileset_records();
+ break;
+ case 12:
+ eliminate_orphaned_client_records();
+ break;
+ case 13:
+ eliminate_orphaned_job_records();
+ break;
+ case 14:
+ eliminate_admin_records();
+ break;
+ case 15:
+ eliminate_restore_records();
+ break;
+ case 16:
+ repair_bad_filenames();
+ repair_bad_paths();
+ eliminate_duplicate_filenames();
+ eliminate_duplicate_paths();
+ eliminate_orphaned_jobmedia_records();
+ eliminate_orphaned_file_records();
+ eliminate_orphaned_path_records();
+ eliminate_orphaned_filename_records();
+ eliminate_orphaned_fileset_records();
+ eliminate_orphaned_client_records();
+ eliminate_orphaned_job_records();
+ eliminate_admin_records();
+ eliminate_restore_records();
+ break;
+ case 17:
+ quit = true;
+ break;
+ }
}
}
}
static int print_job_handler(void *ctx, int num_fields, char **row)
{
printf(_("JobId=%s Name=\"%s\" StartTime=%s\n"),
- NPRT(row[0]), NPRT(row[1]), NPRT(row[2]));
+ NPRT(row[0]), NPRT(row[1]), NPRT(row[2]));
return 0;
}
static int print_jobmedia_handler(void *ctx, int num_fields, char **row)
{
printf(_("Orphaned JobMediaId=%s JobId=%s Volume=\"%s\"\n"),
- NPRT(row[0]), NPRT(row[1]), NPRT(row[2]));
+ NPRT(row[0]), NPRT(row[1]), NPRT(row[2]));
return 0;
}
static int print_file_handler(void *ctx, int num_fields, char **row)
{
printf(_("Orphaned FileId=%s JobId=%s Volume=\"%s\"\n"),
- NPRT(row[0]), NPRT(row[1]), NPRT(row[2]));
+ NPRT(row[0]), NPRT(row[1]), NPRT(row[2]));
return 0;
}
static int print_fileset_handler(void *ctx, int num_fields, char **row)
{
printf(_("Orphaned FileSetId=%s FileSet=\"%s\" MD5=%s\n"),
- NPRT(row[0]), NPRT(row[1]), NPRT(row[2]));
+ NPRT(row[0]), NPRT(row[1]), NPRT(row[2]));
return 0;
}
static int print_client_handler(void *ctx, int num_fields, char **row)
{
printf(_("Orphaned ClientId=%s Name=\"%s\"\n"),
- NPRT(row[0]), NPRT(row[1]));
+ NPRT(row[0]), NPRT(row[1]));
return 0;
}
}
if (lst->num_ids == lst->max_ids) {
if (lst->max_ids == 0) {
- lst->max_ids = 1000;
- lst->Id = (uint32_t *)bmalloc(sizeof(uint32_t) * lst->max_ids);
+ lst->max_ids = 1000;
+ lst->Id = (uint32_t *)bmalloc(sizeof(uint32_t) * lst->max_ids);
} else {
- lst->max_ids = (lst->max_ids * 3) / 2;
- lst->Id = (uint32_t *)brealloc(lst->Id, sizeof(uint32_t) * lst->max_ids);
+ lst->max_ids = (lst->max_ids * 3) / 2;
+ lst->Id = (uint32_t *)brealloc(lst->Id, sizeof(uint32_t) * lst->max_ids);
}
}
lst->Id[lst->num_ids++] = (uint32_t)strtod(row[0], NULL);
for (int i=0; i < id_list->num_ids; i++) {
bsnprintf(buf, sizeof(buf), query, id_list->Id[i]);
if (verbose) {
- printf("Deleting: %s\n", buf);
+ printf("Deleting: %s\n", buf);
}
db_sql_query(db, buf, NULL, NULL);
}
}
if (name->num_ids == name->max_ids) {
if (name->max_ids == 0) {
- name->max_ids = 1000;
- name->name = (char **)bmalloc(sizeof(char *) * name->max_ids);
+ name->max_ids = 1000;
+ name->name = (char **)bmalloc(sizeof(char *) * name->max_ids);
} else {
- name->max_ids = (name->max_ids * 3) / 2;
- name->name = (char **)brealloc(name->name, sizeof(char *) * name->max_ids);
+ name->max_ids = (name->max_ids * 3) / 2;
+ name->name = (char **)brealloc(name->name, sizeof(char *) * name->max_ids);
}
}
name->name[name->num_ids++] = bstrdup(row[0]);
/* Make list of duplicated names */
query = "SELECT Name, count(Name) as Count FROM Filename GROUP BY Name "
- "HAVING count(Name) > 1";
+ "HAVING count(Name) > 1";
if (!make_name_list(query, &name_list)) {
exit(1);
if (fix) {
/* Loop through list of duplicate names */
for (int i=0; i<name_list.num_ids; i++) {
- /* Get all the Ids of each name */
- db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
- bsnprintf(buf, sizeof(buf), "SELECT FilenameId FROM Filename WHERE Name='%s'", esc_name);
- if (verbose > 1) {
- printf("%s\n", buf);
- }
- if (!make_id_list(buf, &id_list)) {
- exit(1);
- }
- if (verbose) {
- printf("Found %d for: %s\n", id_list.num_ids, name_list.name[i]);
- }
- /* Force all records to use the first id then delete the other ids */
- for (int j=1; j<id_list.num_ids; j++) {
- bsnprintf(buf, sizeof(buf), "UPDATE File SET FilenameId=%u WHERE FilenameId=%u",
- id_list.Id[0], id_list.Id[j]);
- if (verbose > 1) {
- printf("%s\n", buf);
- }
- db_sql_query(db, buf, NULL, NULL);
- bsnprintf(buf, sizeof(buf), "DELETE FROM Filename WHERE FilenameId=%u",
- id_list.Id[j]);
- if (verbose > 2) {
- printf("%s\n", buf);
- }
- db_sql_query(db, buf, NULL, NULL);
- }
+ /* Get all the Ids of each name */
+ db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
+ bsnprintf(buf, sizeof(buf), "SELECT FilenameId FROM Filename WHERE Name='%s'", esc_name);
+ if (verbose > 1) {
+ printf("%s\n", buf);
+ }
+ if (!make_id_list(buf, &id_list)) {
+ exit(1);
+ }
+ if (verbose) {
+ printf("Found %d for: %s\n", id_list.num_ids, name_list.name[i]);
+ }
+ /* Force all records to use the first id then delete the other ids */
+ for (int j=1; j<id_list.num_ids; j++) {
+ bsnprintf(buf, sizeof(buf), "UPDATE File SET FilenameId=%u WHERE FilenameId=%u",
+ id_list.Id[0], id_list.Id[j]);
+ if (verbose > 1) {
+ printf("%s\n", buf);
+ }
+ db_sql_query(db, buf, NULL, NULL);
+ bsnprintf(buf, sizeof(buf), "DELETE FROM Filename WHERE FilenameId=%u",
+ id_list.Id[j]);
+ if (verbose > 2) {
+ printf("%s\n", buf);
+ }
+ db_sql_query(db, buf, NULL, NULL);
+ }
}
}
free_name_list(&name_list);
/* Make list of duplicated names */
query = "SELECT Path, count(Path) as Count FROM Path "
- "GROUP BY Path HAVING count(Path) > 1";
+ "GROUP BY Path HAVING count(Path) > 1";
if (!make_name_list(query, &name_list)) {
exit(1);
if (fix) {
/* Loop through list of duplicate names */
for (int i=0; i<name_list.num_ids; i++) {
- /* Get all the Ids of each name */
- db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
- bsnprintf(buf, sizeof(buf), "SELECT PathId FROM Path WHERE Path='%s'", esc_name);
- if (verbose > 1) {
- printf("%s\n", buf);
- }
- if (!make_id_list(buf, &id_list)) {
- exit(1);
- }
- if (verbose) {
- printf("Found %d for: %s\n", id_list.num_ids, name_list.name[i]);
- }
- /* Force all records to use the first id then delete the other ids */
- for (int j=1; j<id_list.num_ids; j++) {
- bsnprintf(buf, sizeof(buf), "UPDATE File SET PathId=%u WHERE PathId=%u",
- id_list.Id[0], id_list.Id[j]);
- if (verbose > 1) {
- printf("%s\n", buf);
- }
- db_sql_query(db, buf, NULL, NULL);
- bsnprintf(buf, sizeof(buf), "DELETE FROM Path WHERE PathId=%u",
- id_list.Id[j]);
- if (verbose > 2) {
- printf("%s\n", buf);
- }
- db_sql_query(db, buf, NULL, NULL);
- }
+ /* Get all the Ids of each name */
+ db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
+ bsnprintf(buf, sizeof(buf), "SELECT PathId FROM Path WHERE Path='%s'", esc_name);
+ if (verbose > 1) {
+ printf("%s\n", buf);
+ }
+ if (!make_id_list(buf, &id_list)) {
+ exit(1);
+ }
+ if (verbose) {
+ printf("Found %d for: %s\n", id_list.num_ids, name_list.name[i]);
+ }
+ /* Force all records to use the first id then delete the other ids */
+ for (int j=1; j<id_list.num_ids; j++) {
+ bsnprintf(buf, sizeof(buf), "UPDATE File SET PathId=%u WHERE PathId=%u",
+ id_list.Id[0], id_list.Id[j]);
+ if (verbose > 1) {
+ printf("%s\n", buf);
+ }
+ db_sql_query(db, buf, NULL, NULL);
+ bsnprintf(buf, sizeof(buf), "DELETE FROM Path WHERE PathId=%u",
+ id_list.Id[j]);
+ if (verbose > 2) {
+ printf("%s\n", buf);
+ }
+ db_sql_query(db, buf, NULL, NULL);
+ }
}
}
free_name_list(&name_list);
printf("Checking for orphaned JobMedia entries.\n");
query = "SELECT JobMedia.JobMediaId,Job.JobId FROM JobMedia "
- "LEFT OUTER JOIN Job ON (JobMedia.JobId=Job.JobId) "
- "WHERE Job.JobId IS NULL";
+ "LEFT OUTER JOIN Job ON (JobMedia.JobId=Job.JobId) "
+ "WHERE Job.JobId IS NULL";
if (!make_id_list(query, &id_list)) {
exit(1);
}
printf("Found %d orphaned JobMedia records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (int i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf),
+ bsnprintf(buf, sizeof(buf),
"SELECT JobMedia.JobMediaId,JobMedia.JobId,Media.VolumeName FROM JobMedia,Media "
"WHERE JobMedia.JobMediaId=%u AND Media.MediaId=JobMedia.MediaId", id_list.Id[i]);
- if (!db_sql_query(db, buf, print_jobmedia_handler, NULL)) {
- printf("%s\n", db_strerror(db));
- }
+ if (!db_sql_query(db, buf, print_jobmedia_handler, NULL)) {
+ printf("%s\n", db_strerror(db));
+ }
}
}
printf("Checking for orphaned File entries. This may take some time!\n");
query = "SELECT File.FileId,Job.JobId FROM File "
- "LEFT OUTER JOIN Job ON (File.JobId=Job.JobId) "
- "WHERE Job.JobId IS NULL";
+ "LEFT OUTER JOIN Job ON (File.JobId=Job.JobId) "
+ "WHERE Job.JobId IS NULL";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d orphaned File records.\n", id_list.num_ids);
if (name_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (int i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf),
+ bsnprintf(buf, sizeof(buf),
"SELECT File.FileId,File.JobId,Filename.Name FROM File,Filename "
"WHERE File.FileId=%u AND File.FilenameId=Filename.FilenameId", id_list.Id[i]);
- if (!db_sql_query(db, buf, print_file_handler, NULL)) {
- printf("%s\n", db_strerror(db));
- }
+ if (!db_sql_query(db, buf, print_file_handler, NULL)) {
+ printf("%s\n", db_strerror(db));
+ }
}
}
printf("Checking for orphaned Path entries. This may take some time!\n");
query = "SELECT DISTINCT Path.PathId,File.PathId FROM Path "
- "LEFT OUTER JOIN File ON (Path.PathId=File.PathId) "
- "WHERE File.PathId IS NULL";
+ "LEFT OUTER JOIN File ON (Path.PathId=File.PathId) "
+ "WHERE File.PathId IS NULL";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d orphaned Path records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (int i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf), "SELECT Path FROM Path WHERE PathId=%u", id_list.Id[i]);
- db_sql_query(db, buf, print_name_handler, NULL);
+ bsnprintf(buf, sizeof(buf), "SELECT Path FROM Path WHERE PathId=%u", id_list.Id[i]);
+ db_sql_query(db, buf, print_name_handler, NULL);
}
}
printf("Checking for orphaned Filename entries. This may take some time!\n");
query = "SELECT Filename.FilenameId,File.FilenameId FROM Filename "
- "LEFT OUTER JOIN File ON (Filename.FilenameId=File.FilenameId) "
- "WHERE File.FilenameId IS NULL";
+ "LEFT OUTER JOIN File ON (Filename.FilenameId=File.FilenameId) "
+ "WHERE File.FilenameId IS NULL";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d orphaned Filename records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (int i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf), "SELECT Name FROM Filename WHERE FilenameId=%u", id_list.Id[i]);
- db_sql_query(db, buf, print_name_handler, NULL);
+ bsnprintf(buf, sizeof(buf), "SELECT Name FROM Filename WHERE FilenameId=%u", id_list.Id[i]);
+ db_sql_query(db, buf, print_name_handler, NULL);
}
}
printf("Checking for orphaned FileSet entries. This takes some time!\n");
query = "SELECT FileSet.FileSetId,Job.FileSetId FROM FileSet "
- "LEFT OUTER JOIN Job ON (FileSet.FileSetId=Job.FileSetId) "
- "WHERE Job.FileSetId IS NULL";
+ "LEFT OUTER JOIN Job ON (FileSet.FileSetId=Job.FileSetId) "
+ "WHERE Job.FileSetId IS NULL";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d orphaned FileSet records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (int i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf), "SELECT FileSetId,FileSet,MD5 FROM FileSet "
- "WHERE FileSetId=%u", id_list.Id[i]);
- if (!db_sql_query(db, buf, print_fileset_handler, NULL)) {
- printf("%s\n", db_strerror(db));
- }
+ bsnprintf(buf, sizeof(buf), "SELECT FileSetId,FileSet,MD5 FROM FileSet "
+ "WHERE FileSetId=%u", id_list.Id[i]);
+ if (!db_sql_query(db, buf, print_fileset_handler, NULL)) {
+ printf("%s\n", db_strerror(db));
+ }
}
}
printf("Checking for orphaned Client entries.\n");
/* In English:
- * Wiffle through Client for every Client
- * joining with the Job table including every Client even if
- * there is not a match in Job (left outer join), then
- * filter out only those where no Job points to a Client
- * i.e. Job.Client is NULL
+ * Wiffle through Client for every Client
+ * joining with the Job table including every Client even if
+ * there is not a match in Job (left outer join), then
+ * filter out only those where no Job points to a Client
+ * i.e. Job.Client is NULL
*/
query = "SELECT Client.ClientId,Client.Name FROM Client "
- "LEFT OUTER JOIN Job ON (Client.ClientId=Job.ClientId) "
- "WHERE Job.ClientId IS NULL";
+ "LEFT OUTER JOIN Job ON (Client.ClientId=Job.ClientId) "
+ "WHERE Job.ClientId IS NULL";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d orphaned Client records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (int i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf), "SELECT ClientId,Name FROM Client "
- "WHERE ClientId=%u", id_list.Id[i]);
- if (!db_sql_query(db, buf, print_client_handler, NULL)) {
- printf("%s\n", db_strerror(db));
- }
+ bsnprintf(buf, sizeof(buf), "SELECT ClientId,Name FROM Client "
+ "WHERE ClientId=%u", id_list.Id[i]);
+ if (!db_sql_query(db, buf, print_client_handler, NULL)) {
+ printf("%s\n", db_strerror(db));
+ }
}
}
printf("Checking for orphaned Job entries.\n");
/* In English:
- * Wiffle through Job for every Job
- * joining with the Client table including every Job even if
- * there is not a match in Client (left outer join), then
- * filter out only those where no Client exists
- * i.e. Client.Name is NULL
+ * Wiffle through Job for every Job
+ * joining with the Client table including every Job even if
+ * there is not a match in Client (left outer join), then
+ * filter out only those where no Client exists
+ * i.e. Client.Name is NULL
*/
query = "SELECT Job.JobId,Job.Name FROM Job "
- "LEFT OUTER JOIN Client ON (Job.ClientId=Client.ClientId) "
- "WHERE Client.Name IS NULL";
+ "LEFT OUTER JOIN Client ON (Job.ClientId=Client.ClientId) "
+ "WHERE Client.Name IS NULL";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d orphaned Job records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (int i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf), "SELECT JobId,Name,StartTime FROM Job "
- "WHERE JobId=%u", id_list.Id[i]);
- if (!db_sql_query(db, buf, print_job_handler, NULL)) {
- printf("%s\n", db_strerror(db));
- }
+ bsnprintf(buf, sizeof(buf), "SELECT JobId,Name,StartTime FROM Job "
+ "WHERE JobId=%u", id_list.Id[i]);
+ if (!db_sql_query(db, buf, print_job_handler, NULL)) {
+ printf("%s\n", db_strerror(db));
+ }
}
}
printf("Checking for Admin Job entries.\n");
query = "SELECT Job.JobId FROM Job "
- "WHERE Job.Type='D'";
+ "WHERE Job.Type='D'";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d Admin Job records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (int i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf), "SELECT JobId,Name,StartTime FROM Job "
- "WHERE JobId=%u", id_list.Id[i]);
- if (!db_sql_query(db, buf, print_job_handler, NULL)) {
- printf("%s\n", db_strerror(db));
- }
+ bsnprintf(buf, sizeof(buf), "SELECT JobId,Name,StartTime FROM Job "
+ "WHERE JobId=%u", id_list.Id[i]);
+ if (!db_sql_query(db, buf, print_job_handler, NULL)) {
+ printf("%s\n", db_strerror(db));
+ }
}
}
printf("Checking for Restore Job entries.\n");
query = "SELECT Job.JobId FROM Job "
- "WHERE Job.Type='R'";
+ "WHERE Job.Type='R'";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d Restore Job records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (int i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf), "SELECT JobId,Name,StartTime FROM Job "
- "WHERE JobId=%u", id_list.Id[i]);
- if (!db_sql_query(db, buf, print_job_handler, NULL)) {
- printf("%s\n", db_strerror(db));
- }
+ bsnprintf(buf, sizeof(buf), "SELECT JobId,Name,StartTime FROM Job "
+ "WHERE JobId=%u", id_list.Id[i]);
+ if (!db_sql_query(db, buf, print_job_handler, NULL)) {
+ printf("%s\n", db_strerror(db));
+ }
}
}
printf("Checking for Filenames with a trailing slash\n");
query = "SELECT FilenameId,Name from Filename "
- "WHERE Name LIKE '%/'";
+ "WHERE Name LIKE '%/'";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d bad Filename records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf),
- "SELECT Name FROM Filename WHERE FilenameId=%u", id_list.Id[i]);
- if (!db_sql_query(db, buf, print_name_handler, NULL)) {
- printf("%s\n", db_strerror(db));
- }
+ bsnprintf(buf, sizeof(buf),
+ "SELECT Name FROM Filename WHERE FilenameId=%u", id_list.Id[i]);
+ if (!db_sql_query(db, buf, print_name_handler, NULL)) {
+ printf("%s\n", db_strerror(db));
+ }
}
}
char esc_name[5000];
printf("Reparing %d bad Filename records.\n", id_list.num_ids);
for (i=0; i < id_list.num_ids; i++) {
- int len;
- bsnprintf(buf, sizeof(buf),
- "SELECT Name FROM Filename WHERE FilenameId=%u", id_list.Id[i]);
- if (!db_sql_query(db, buf, get_name_handler, name)) {
- printf("%s\n", db_strerror(db));
- }
- /* Strip trailing slash(es) */
- for (len=strlen(name); len > 0 && name[len-1]=='/'; len--)
- { }
- if (len == 0) {
- len = 1;
- esc_name[0] = ' ';
- esc_name[1] = 0;
- } else {
- name[len-1] = 0;
- db_escape_string(esc_name, name, len);
- }
- bsnprintf(buf, sizeof(buf),
- "UPDATE Filename SET Name='%s' WHERE FilenameId=%u",
- esc_name, id_list.Id[i]);
- if (verbose > 1) {
- printf("%s\n", buf);
- }
- db_sql_query(db, buf, NULL, NULL);
+ int len;
+ bsnprintf(buf, sizeof(buf),
+ "SELECT Name FROM Filename WHERE FilenameId=%u", id_list.Id[i]);
+ if (!db_sql_query(db, buf, get_name_handler, name)) {
+ printf("%s\n", db_strerror(db));
+ }
+ /* Strip trailing slash(es) */
+ for (len=strlen(name); len > 0 && name[len-1]=='/'; len--)
+ { }
+ if (len == 0) {
+ len = 1;
+ esc_name[0] = ' ';
+ esc_name[1] = 0;
+ } else {
+ name[len-1] = 0;
+ db_escape_string(esc_name, name, len);
+ }
+ bsnprintf(buf, sizeof(buf),
+ "UPDATE Filename SET Name='%s' WHERE FilenameId=%u",
+ esc_name, id_list.Id[i]);
+ if (verbose > 1) {
+ printf("%s\n", buf);
+ }
+ db_sql_query(db, buf, NULL, NULL);
}
}
}
printf("Checking for Paths without a trailing slash\n");
query = "SELECT PathId,Path from Path "
- "WHERE Path NOT LIKE '%/'";
+ "WHERE Path NOT LIKE '%/'";
if (verbose > 1) {
printf("%s\n", query);
}
printf("Found %d bad Path records.\n", id_list.num_ids);
if (id_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) {
for (i=0; i < id_list.num_ids; i++) {
- bsnprintf(buf, sizeof(buf),
- "SELECT Path FROM Path WHERE PathId=%u", id_list.Id[i]);
- if (!db_sql_query(db, buf, print_name_handler, NULL)) {
- printf("%s\n", db_strerror(db));
- }
+ bsnprintf(buf, sizeof(buf),
+ "SELECT Path FROM Path WHERE PathId=%u", id_list.Id[i]);
+ if (!db_sql_query(db, buf, print_name_handler, NULL)) {
+ printf("%s\n", db_strerror(db));
+ }
}
}
char esc_name[5000];
printf("Reparing %d bad Filename records.\n", id_list.num_ids);
for (i=0; i < id_list.num_ids; i++) {
- int len;
- bsnprintf(buf, sizeof(buf),
- "SELECT Path FROM Path WHERE PathId=%u", id_list.Id[i]);
- if (!db_sql_query(db, buf, get_name_handler, name)) {
- printf("%s\n", db_strerror(db));
- }
- /* Strip trailing blanks */
- for (len=strlen(name); len > 0 && name[len-1]==' '; len--) {
- name[len-1] = 0;
- }
- /* Add trailing slash */
- len = pm_strcat(&name, "/");
- db_escape_string(esc_name, name, len);
- bsnprintf(buf, sizeof(buf), "UPDATE Path SET Path='%s' WHERE PathId=%u",
- esc_name, id_list.Id[i]);
- if (verbose > 1) {
- printf("%s\n", buf);
- }
- db_sql_query(db, buf, NULL, NULL);
+ int len;
+ bsnprintf(buf, sizeof(buf),
+ "SELECT Path FROM Path WHERE PathId=%u", id_list.Id[i]);
+ if (!db_sql_query(db, buf, get_name_handler, name)) {
+ printf("%s\n", db_strerror(db));
+ }
+ /* Strip trailing blanks */
+ for (len=strlen(name); len > 0 && name[len-1]==' '; len--) {
+ name[len-1] = 0;
+ }
+ /* Add trailing slash */
+ len = pm_strcat(&name, "/");
+ db_escape_string(esc_name, name, len);
+ bsnprintf(buf, sizeof(buf), "UPDATE Path SET Path='%s' WHERE PathId=%u",
+ esc_name, id_list.Id[i]);
+ if (verbose > 1) {
+ printf("%s\n", buf);
+ }
+ db_sql_query(db, buf, NULL, NULL);
}
}
}
#include "bacula.h"
#include "findlib/find.h"
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event)
+ { return 1; }
+
static void usage()
{
fprintf(stderr, _(
while ((ch = getopt(argc, argv, "v?")) != -1) {
switch (ch) {
case 'v':
- verbose = 1;
- break;
+ verbose = 1;
+ break;
case '?':
- default:
- usage();
+ default:
+ usage();
}
}
for (i = 0; i < argc; --argc, ++argv) {
if (fstype(*argv, fs, sizeof(fs))) {
- if (verbose) {
+ if (verbose) {
printf("%s: %s\n", *argv, fs);
- } else {
- puts(fs);
- }
+ } else {
+ puts(fs);
+ }
} else {
fprintf(stderr, "%s: unknown\n", *argv);
- status = 1;
+ status = 1;
}
}
int win32_client = 0;
#endif
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
+int generate_job_event(JCR *jcr, const char *event) { return 1; }
/* Global variables */
static int num_files = 0;
int win32_client = 0;
#endif
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
+int generate_job_event(JCR *jcr, const char *event) { return 1; }
+
/* Global variables */
int attrs = 0;
*/
/*
- Copyright (C) 2004 Kern Sibbald and John Walker
+ Copyright (C) 2004-2005 Kern Sibbald
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
int authenticate_file_daemon(JCR *jcr, MONITOR *monitor, CLIENT* client);
int authenticate_storage_daemon(JCR *jcr, MONITOR *monitor, STORE* store);
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
+
/* Forward referenced functions */
void writecmd(monitoritem* item, const char* command);
int docmd(monitoritem* item, const char* command, GSList** list);
}
static GtkWidget *new_image_button(const gchar *stock_id,
- const gchar *label_text) {
+ const gchar *label_text) {
GtkWidget *button;
GtkWidget *box;
GtkWidget *label;
/*********************************************************************
*
- * Main Bacula Tray Monitor -- User Interface Program
+ * Main Bacula Tray Monitor -- User Interface Program
*
*/
int main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "bc:d:th?f:s:")) != -1) {
switch (ch) {
case 'c': /* configuration file */
- if (configfile != NULL) {
- free(configfile);
- }
- configfile = bstrdup(optarg);
- break;
+ if (configfile != NULL) {
+ free(configfile);
+ }
+ configfile = bstrdup(optarg);
+ break;
case 'd':
- debug_level = atoi(optarg);
- if (debug_level <= 0) {
- debug_level = 1;
- }
- break;
+ debug_level = atoi(optarg);
+ if (debug_level <= 0) {
+ debug_level = 1;
+ }
+ break;
case 't':
- test_config = true;
- break;
+ test_config = true;
+ break;
case 'h':
case '?':
default:
- usage();
- exit(1);
+ usage();
+ exit(1);
}
}
argc -= optind;
if (nitems != 1) {
Emsg2(M_ERROR_TERM, 0,
- _("Error: %d Monitor resource defined in %s. You must define one and only one Monitor resource.\n"), nitems, configfile);
+ _("Error: %d Monitor resource defined in %s. You must define one and only one Monitor resource.\n"), nitems, configfile);
}
nitems = 0;
for (int i = 0; i < nitems; i++) {
switch (items[i].type) {
case R_DIRECTOR:
- str = g_string_new(((DIRRES*)(items[i].resource))->hdr.name);
- g_string_append(str, _(" (DIR)"));
- break;
+ str = g_string_new(((DIRRES*)(items[i].resource))->hdr.name);
+ g_string_append(str, _(" (DIR)"));
+ break;
case R_CLIENT:
- str = g_string_new(((CLIENT*)(items[i].resource))->hdr.name);
- g_string_append(str, _(" (FD)"));
- break;
+ str = g_string_new(((CLIENT*)(items[i].resource))->hdr.name);
+ g_string_append(str, _(" (FD)"));
+ break;
case R_STORAGE:
- str = g_string_new(((STORE*)(items[i].resource))->hdr.name);
- g_string_append(str, _(" (SD)"));
- break;
+ str = g_string_new(((STORE*)(items[i].resource))->hdr.name);
+ g_string_append(str, _(" (SD)"));
+ break;
default:
- continue;
+ continue;
}
radio = gtk_radio_button_new_with_label(group, str->str);
gtk_container_add(GTK_CONTAINER(align), items[i].label);
gtk_table_attach(GTK_TABLE(daemon_table), radio, 0, 1, (i*2)+1, (i*2)+2,
- GTK_FILL, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
+ GTK_FILL, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
gtk_table_attach(GTK_TABLE(daemon_table), items[i].image, 1, 2, (i*2)+1, (i*2)+2,
- GTK_FILL, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
+ GTK_FILL, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
gtk_table_attach(GTK_TABLE(daemon_table), align, 2, 3, (i*2)+1, (i*2)+2,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
+ (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
separator = gtk_hseparator_new();
gtk_table_attach_defaults(GTK_TABLE(daemon_table), separator, 0, 3, (i*2)+2, (i*2)+3);
for (i = 0; i < nitems; i++) {
if (items[i].D_sock) {
- writecmd(&items[i], "quit");
- bnet_sig(items[i].D_sock, BNET_TERMINATE); /* send EOF */
- bnet_close(items[i].D_sock);
+ writecmd(&items[i], "quit");
+ bnet_sig(items[i].D_sock, BNET_TERMINATE); /* send EOF */
+ bnet_close(items[i].D_sock);
}
}
- (void)WSACleanup(); /* Cleanup Windows sockets */
+ (void)WSACleanup(); /* Cleanup Windows sockets */
//Free xpm_generic_var
for (i = 0; i < (int)(sizeof(xpm_generic)/sizeof(const char*)); i++) {
}
static gboolean delete_event( GtkWidget *widget,
- GdkEvent *event,
- gpointer data ) {
+ GdkEvent *event,
+ gpointer data ) {
gtk_widget_hide(window);
return TRUE; /* do not destroy the window */
}
g_source_remove(timerTag);
timerTag = g_timeout_add(
(guint)(
- gtk_spin_button_get_value(GTK_SPIN_BUTTON(timeoutspinner))*1000/nitems
+ gtk_spin_button_get_value(GTK_SPIN_BUTTON(timeoutspinner))*1000/nitems
), fd_read, NULL );
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
fullitem = -1;
for (int i = 0; i < nitems; i++) {
- if (data == &(items[i])) {
- fullitem = i;
- break;
- }
+ if (data == &(items[i])) {
+ fullitem = i;
+ break;
+ }
}
g_return_if_fail(fullitem != -1);
newbuffer = gtk_text_buffer_new(NULL);
if (items[lastupdated].type == R_DIRECTOR)
- docmd(&items[lastupdated], "status Director\n", &list);
+ docmd(&items[lastupdated], "status Director\n", &list);
else
- docmd(&items[lastupdated], "status\n", &list);
+ docmd(&items[lastupdated], "status\n", &list);
it = list->next;
do {
- gtk_text_buffer_get_end_iter(newbuffer, &stop);
- gtk_text_buffer_insert (newbuffer, &stop, ((GString*)it->data)->str, -1);
- if (it->data) g_string_free((GString*)it->data, TRUE);
+ gtk_text_buffer_get_end_iter(newbuffer, &stop);
+ gtk_text_buffer_insert (newbuffer, &stop, ((GString*)it->data)->str, -1);
+ if (it->data) g_string_free((GString*)it->data, TRUE);
} while ((it = it->next) != NULL);
g_slist_free(list);
/* Keep the selection if necessary */
if (gtk_text_buffer_get_selection_bounds(buffer, &start, &stop)) {
- gtk_text_buffer_get_iter_at_offset(newbuffer, &nstart, gtk_text_iter_get_offset(&start));
- gtk_text_buffer_get_iter_at_offset(newbuffer, &nstop, gtk_text_iter_get_offset(&stop ));
+ gtk_text_buffer_get_iter_at_offset(newbuffer, &nstart, gtk_text_iter_get_offset(&start));
+ gtk_text_buffer_get_iter_at_offset(newbuffer, &nstop, gtk_text_iter_get_offset(&stop ));
#if HAVE_GTK_2_4
- gtk_text_buffer_select_range(newbuffer, &nstart, &nstop);
+ gtk_text_buffer_select_range(newbuffer, &nstart, &nstop);
#else
- gtk_text_buffer_move_mark(newbuffer, gtk_text_buffer_get_mark(newbuffer, "insert"), &nstart);
- gtk_text_buffer_move_mark(newbuffer, gtk_text_buffer_get_mark(newbuffer, "selection_bound"), &nstop);
+ gtk_text_buffer_move_mark(newbuffer, gtk_text_buffer_get_mark(newbuffer, "insert"), &nstart);
+ gtk_text_buffer_move_mark(newbuffer, gtk_text_buffer_get_mark(newbuffer, "selection_bound"), &nstop);
#endif
}
if (current) {
if (item->type == R_DIRECTOR)
- docmd(&items[lastupdated], ".status dir current\n", &list);
+ docmd(&items[lastupdated], ".status dir current\n", &list);
else
- docmd(&items[lastupdated], ".status current\n", &list);
+ docmd(&items[lastupdated], ".status current\n", &list);
}
else {
if (item->type == R_DIRECTOR)
- docmd(&items[lastupdated], ".status dir last\n", &list);
+ docmd(&items[lastupdated], ".status dir last\n", &list);
else
- docmd(&items[lastupdated], ".status last\n", &list);
+ docmd(&items[lastupdated], ".status last\n", &list);
}
it = list->next;
if ((it == NULL) || (sscanf(((GString*)it->data)->str, OKqstatus, &num) != 1)) {
g_string_append_printf(*str, ".status error : %s", (it == NULL) ? "" : ((GString*)it->data)->str);
while (((*str)->str[(*str)->len-1] == '\n') || ((*str)->str[(*str)->len-1] == '\r')) {
- g_string_set_size(*str, (*str)->len-1);
+ g_string_set_size(*str, (*str)->len-1);
}
ret = error;
}
else if ((it = it->next) == NULL) {
if (current) {
- g_string_append(*str, _("No current job."));
+ g_string_append(*str, _("No current job."));
}
else {
- g_string_append(*str, _("No last job."));
+ g_string_append(*str, _("No last job."));
}
ret = idle;
}
else if ((k = sscanf(((GString*)it->data)->str, DotStatusJob, &jobid, &jobstatus, &joberrors)) == 3) {
switch (jobstatus) {
case JS_Created:
- ret = (joberrors > 0) ? warn : running;
- g_string_append_printf(*str, _("Job status: Created (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- break;
+ ret = (joberrors > 0) ? warn : running;
+ g_string_append_printf(*str, _("Job status: Created (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ break;
case JS_Running:
- ret = (joberrors > 0) ? warn : running;
- g_string_append_printf(*str, _("Job status: Running (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- break;
+ ret = (joberrors > 0) ? warn : running;
+ g_string_append_printf(*str, _("Job status: Running (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ break;
case JS_Blocked:
- g_string_append_printf(*str, _("Job status: Blocked (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Blocked (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_Terminated:
- g_string_append_printf(*str, _("Job status: Terminated (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = (joberrors > 0) ? warn : idle;
- break;
+ g_string_append_printf(*str, _("Job status: Terminated (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = (joberrors > 0) ? warn : idle;
+ break;
case JS_ErrorTerminated:
- g_string_append_printf(*str, _("Job status: Terminated in error (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = error;
- break;
+ g_string_append_printf(*str, _("Job status: Terminated in error (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = error;
+ break;
case JS_Error:
- ret = (joberrors > 0) ? warn : running;
- g_string_append_printf(*str, _("Job status: Error (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- break;
+ ret = (joberrors > 0) ? warn : running;
+ g_string_append_printf(*str, _("Job status: Error (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ break;
case JS_FatalError:
- g_string_append_printf(*str, _("Job status: Fatal error (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = error;
- break;
+ g_string_append_printf(*str, _("Job status: Fatal error (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = error;
+ break;
case JS_Differences:
- g_string_append_printf(*str, _("Job status: Verify differences (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Verify differences (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_Canceled:
- g_string_append_printf(*str, _("Job status: Canceled (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Canceled (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitFD:
- g_string_append_printf(*str, _("Job status: Waiting on File daemon (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting on File daemon (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitSD:
- g_string_append_printf(*str, _("Job status: Waiting on the Storage daemon (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting on the Storage daemon (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitMedia:
- g_string_append_printf(*str, _("Job status: Waiting for new media (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting for new media (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitMount:
- g_string_append_printf(*str, _("Job status: Waiting for Mount (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting for Mount (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitStoreRes:
- g_string_append_printf(*str, _("Job status: Waiting for storage resource (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting for storage resource (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitJobRes:
- g_string_append_printf(*str, _("Job status: Waiting for job resource (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting for job resource (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitClientRes:
- g_string_append_printf(*str, _("Job status: Waiting for Client resource (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting for Client resource (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitMaxJobs:
- g_string_append_printf(*str, _("Job status: Waiting for maximum jobs (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting for maximum jobs (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitStartTime:
- g_string_append_printf(*str, _("Job status: Waiting for start time (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting for start time (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
case JS_WaitPriority:
- g_string_append_printf(*str, _("Job status: Waiting for higher priority jobs to finish (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_string_append_printf(*str, _("Job status: Waiting for higher priority jobs to finish (%d error%s)"), joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
default:
- g_warning("Unknown job status %c.", jobstatus);
- g_string_append_printf(*str, _("Job status: Unknown(%c) (%d error%s)"), jobstatus, joberrors, (joberrors > 1) ? "s" : "");
- ret = warn;
- break;
+ g_warning("Unknown job status %c.", jobstatus);
+ g_string_append_printf(*str, _("Job status: Unknown(%c) (%d error%s)"), jobstatus, joberrors, (joberrors > 1) ? "s" : "");
+ ret = warn;
+ break;
}
}
else {
switch (item->type) {
case R_DIRECTOR:
- dird = (DIRRES*)item->resource;
- trayMessage("Connecting to Director %s:%d\n", dird->address, dird->DIRport);
- changeStatusMessage(item, "Connecting to Director %s:%d", dird->address, dird->DIRport);
- item->D_sock = bnet_connect(NULL, 0, 0, "Director daemon", dird->address, NULL, dird->DIRport, 0);
- jcr.dir_bsock = item->D_sock;
- break;
+ dird = (DIRRES*)item->resource;
+ trayMessage("Connecting to Director %s:%d\n", dird->address, dird->DIRport);
+ changeStatusMessage(item, "Connecting to Director %s:%d", dird->address, dird->DIRport);
+ item->D_sock = bnet_connect(NULL, 0, 0, "Director daemon", dird->address, NULL, dird->DIRport, 0);
+ jcr.dir_bsock = item->D_sock;
+ break;
case R_CLIENT:
- filed = (CLIENT*)item->resource;
- trayMessage("Connecting to Client %s:%d\n", filed->address, filed->FDport);
- changeStatusMessage(item, "Connecting to Client %s:%d", filed->address, filed->FDport);
- item->D_sock = bnet_connect(NULL, 0, 0, "File daemon", filed->address, NULL, filed->FDport, 0);
- jcr.file_bsock = item->D_sock;
- break;
+ filed = (CLIENT*)item->resource;
+ trayMessage("Connecting to Client %s:%d\n", filed->address, filed->FDport);
+ changeStatusMessage(item, "Connecting to Client %s:%d", filed->address, filed->FDport);
+ item->D_sock = bnet_connect(NULL, 0, 0, "File daemon", filed->address, NULL, filed->FDport, 0);
+ jcr.file_bsock = item->D_sock;
+ break;
case R_STORAGE:
- stored = (STORE*)item->resource;
- trayMessage("Connecting to Storage %s:%d\n", stored->address, stored->SDport);
- changeStatusMessage(item, "Connecting to Storage %s:%d", stored->address, stored->SDport);
- item->D_sock = bnet_connect(NULL, 0, 0, "Storage daemon", stored->address, NULL, stored->SDport, 0);
- jcr.store_bsock = item->D_sock;
- break;
+ stored = (STORE*)item->resource;
+ trayMessage("Connecting to Storage %s:%d\n", stored->address, stored->SDport);
+ changeStatusMessage(item, "Connecting to Storage %s:%d", stored->address, stored->SDport);
+ item->D_sock = bnet_connect(NULL, 0, 0, "Storage daemon", stored->address, NULL, stored->SDport, 0);
+ jcr.store_bsock = item->D_sock;
+ break;
default:
- printf("Error, currentitem is not a Client, a Storage or a Director..\n");
- gtk_main_quit();
- return 0;
+ printf("Error, currentitem is not a Client, a Storage or a Director..\n");
+ gtk_main_quit();
+ return 0;
}
if (item->D_sock == NULL) {
- g_slist_append(*list, g_string_new("Cannot connect to daemon.\n"));
- changeStatusMessage(item, "Cannot connect to daemon.");
- item->state = error;
- item->oldstate = error;
- return 0;
+ g_slist_append(*list, g_string_new("Cannot connect to daemon.\n"));
+ changeStatusMessage(item, "Cannot connect to daemon.");
+ item->state = error;
+ item->oldstate = error;
+ return 0;
}
if (!authenticate_daemon(item, &jcr)) {
- str = g_string_sized_new(64);
- g_string_printf(str, "ERR=%s\n", item->D_sock->msg);
- g_slist_append(*list, str);
- item->state = error;
- item->oldstate = error;
- changeStatusMessage(item, "Authentication error : %s", item->D_sock->msg);
- item->D_sock = NULL;
- return 0;
+ str = g_string_sized_new(64);
+ g_string_printf(str, "ERR=%s\n", item->D_sock->msg);
+ g_slist_append(*list, str);
+ item->state = error;
+ item->oldstate = error;
+ changeStatusMessage(item, "Authentication error : %s", item->D_sock->msg);
+ item->D_sock = NULL;
+ return 0;
}
switch (item->type) {
case R_DIRECTOR:
- trayMessage("Opened connection with Director daemon.\n");
- changeStatusMessage(item, "Opened connection with Director daemon.");
- break;
+ trayMessage("Opened connection with Director daemon.\n");
+ changeStatusMessage(item, "Opened connection with Director daemon.");
+ break;
case R_CLIENT:
- trayMessage("Opened connection with File daemon.\n");
- changeStatusMessage(item, "Opened connection with File daemon.");
- break;
+ trayMessage("Opened connection with File daemon.\n");
+ changeStatusMessage(item, "Opened connection with File daemon.");
+ break;
case R_STORAGE:
- trayMessage("Opened connection with Storage daemon.\n");
- changeStatusMessage(item, "Opened connection with Storage daemon.");
- break;
+ trayMessage("Opened connection with Storage daemon.\n");
+ changeStatusMessage(item, "Opened connection with Storage daemon.");
+ break;
default:
- printf("Error, currentitem is not a Client, a Storage or a Director..\n");
- gtk_main_quit();
- return 0;
- break;
+ printf("Error, currentitem is not a Client, a Storage or a Director..\n");
+ gtk_main_quit();
+ return 0;
+ break;
}
if (item->type == R_DIRECTOR) { /* Read connection messages... */
- GSList *list, *it;
- docmd(item, "", &list); /* Usually invalid, but no matter */
- it = list;
- do {
- if (it->data) g_string_free((GString*)it->data, TRUE);
- } while ((it = it->next) != NULL);
-
- g_slist_free(list);
+ GSList *list, *it;
+ docmd(item, "", &list); /* Usually invalid, but no matter */
+ it = list;
+ do {
+ if (it->data) g_string_free((GString*)it->data, TRUE);
+ } while ((it = it->next) != NULL);
+
+ g_slist_free(list);
}
}
while(1) {
if ((stat = bnet_recv(item->D_sock)) >= 0) {
- g_slist_append(*list, g_string_new(item->D_sock->msg));
+ g_slist_append(*list, g_string_new(item->D_sock->msg));
}
else if (stat == BNET_SIGNAL) {
- if (item->D_sock->msglen == BNET_EOD) {
- //fprintf(stderr, "<< EOD >>\n");
- return 1;
- }
- else if (item->D_sock->msglen == BNET_PROMPT) {
- //fprintf(stderr, "<< PROMPT >>\n");
- g_slist_append(*list, g_string_new("<< Error: BNET_PROMPT signal received. >>\n"));
- return 0;
- }
- else if (item->D_sock->msglen == BNET_HEARTBEAT) {
- bnet_sig(item->D_sock, BNET_HB_RESPONSE);
- g_slist_append(*list, g_string_new("<< Heartbeat signal received, answered. >>\n"));
- }
- else {
- str = g_string_sized_new(64);
- g_string_printf(str, "<< Unexpected signal received : %s >>\n", bnet_sig_to_ascii(item->D_sock));
- g_slist_append(*list, str);
- }
+ if (item->D_sock->msglen == BNET_EOD) {
+ //fprintf(stderr, "<< EOD >>\n");
+ return 1;
+ }
+ else if (item->D_sock->msglen == BNET_PROMPT) {
+ //fprintf(stderr, "<< PROMPT >>\n");
+ g_slist_append(*list, g_string_new("<< Error: BNET_PROMPT signal received. >>\n"));
+ return 0;
+ }
+ else if (item->D_sock->msglen == BNET_HEARTBEAT) {
+ bnet_sig(item->D_sock, BNET_HB_RESPONSE);
+ g_slist_append(*list, g_string_new("<< Heartbeat signal received, answered. >>\n"));
+ }
+ else {
+ str = g_string_sized_new(64);
+ g_string_printf(str, "<< Unexpected signal received : %s >>\n", bnet_sig_to_ascii(item->D_sock));
+ g_slist_append(*list, str);
+ }
}
else { /* BNET_HARDEOF || BNET_ERROR */
- g_slist_append(*list, g_string_new("<ERROR>\n"));
- item->D_sock = NULL;
- item->state = error;
- item->oldstate = error;
- changeStatusMessage(item, "Error : BNET_HARDEOF or BNET_ERROR");
- //fprintf(stderr, "<< ERROR >>\n");
- return 0;
+ g_slist_append(*list, g_string_new("<ERROR>\n"));
+ item->D_sock = NULL;
+ item->state = error;
+ item->oldstate = error;
+ changeStatusMessage(item, "Error : BNET_HARDEOF or BNET_ERROR");
+ //fprintf(stderr, "<< ERROR >>\n");
+ return 0;
}
if (is_bnet_stop(item->D_sock)) {
- g_string_append_printf(str, "<STOP>\n");
- item->D_sock = NULL;
- item->state = error;
- item->oldstate = error;
- changeStatusMessage(item, "Error : Connection closed.");
- //fprintf(stderr, "<< STOP >>\n");
- return 0; /* error or term */
+ g_string_append_printf(str, "<STOP>\n");
+ item->D_sock = NULL;
+ item->state = error;
+ item->oldstate = error;
+ changeStatusMessage(item, "Error : Connection closed.");
+ //fprintf(stderr, "<< STOP >>\n");
+ return 0; /* error or term */
}
}
}
if (item == NULL) {
/* For the current status, select the two worse for blinking,
- but never blink a D_Sock == NULL error with idle. */
+ but never blink a D_Sock == NULL error with idle. */
stateenum state1, state2, oldstate;
gboolean onenull = FALSE;
state1 = idle;
state2 = idle;
oldstate = idle;
for (int i = 0; i < nitems; i++) {
- if (items[i].D_sock == NULL) onenull = TRUE;
- if (items[i].state >= state1) {
- state2 = state1;
- state1 = items[i].state;
- }
- else if (items[i].state > state2) {
- state2 = items[i].state;
- }
- if (items[i].oldstate > oldstate) oldstate = items[i].oldstate;
+ if (items[i].D_sock == NULL) onenull = TRUE;
+ if (items[i].state >= state1) {
+ state2 = state1;
+ state1 = items[i].state;
+ }
+ else if (items[i].state > state2) {
+ state2 = items[i].state;
+ }
+ if (items[i].oldstate > oldstate) oldstate = items[i].oldstate;
}
if ((onenull == TRUE) && (state2 == idle)) {
- state2 = error;
+ state2 = error;
}
xpm = generateXPM(blinkstate ? state1 : state2, oldstate);
}
else {
if ((blinkstate) && (item->D_sock != NULL)) {
- if (item->state > 1) { //Warning or error while running
- xpm = generateXPM(running, item->oldstate);
- }
- else {
- xpm = generateXPM(idle, item->oldstate);
- }
+ if (item->state > 1) { //Warning or error while running
+ xpm = generateXPM(running, item->oldstate);
+ }
+ else {
+ xpm = generateXPM(idle, item->oldstate);
+ }
}
else {
- xpm = generateXPM(item->state, item->oldstate);
+ xpm = generateXPM(item->state, item->oldstate);
}
}
/* */
#undef VERSION
-#define VERSION "1.37.12"
-#define BDATE "18 April 2005"
-#define LSMDATE "18Apr05"
+#define VERSION "1.37.13"
+#define BDATE "19 April 2005"
+#define LSMDATE "19Apr05"
/* Debug flags */
#undef DEBUG
#include "csprint.h"
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
+int generate_job_event(JCR *jcr, const char *event) { return 1; }
+
+
// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------