]> git.sur5r.net Git - bacula/bacula/commitdiff
Apply Preben 'Peppe' Guldberg <peppe@wielders.org>
authorKern Sibbald <kern@sibbald.com>
Tue, 21 Dec 2004 16:19:00 +0000 (16:19 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 21 Dec 2004 16:19:00 +0000 (16:19 +0000)
  three patches that clean up white space:
  ws.patch.02.strings:
    Breaks strings that span lines into concatenated strings. I am not sure
    if you like this one. Other code works with concatenated strings, though.
  ws.patch.03.trailing:
    This removes trailing whitespace. No changes resulted from this for
    my setup.
  ws.patch.04.leading:
    This replaces space runs at the start of line with tabs. No changes
    again.

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

224 files changed:
bacula/patches/1.36.1-store.patch [new file with mode: 0644]
bacula/patches/patches-1.36.1
bacula/src/baconfig.h
bacula/src/bacula.h
bacula/src/bc_types.h
bacula/src/cats/bdb.c
bacula/src/cats/bdb_create.c
bacula/src/cats/bdb_delete.c
bacula/src/cats/bdb_find.c
bacula/src/cats/bdb_get.c
bacula/src/cats/bdb_list.c
bacula/src/cats/bdb_update.c
bacula/src/cats/cats.h
bacula/src/cats/mysql.c
bacula/src/cats/postgresql.c
bacula/src/cats/protos.h
bacula/src/cats/sql.c
bacula/src/cats/sql_create.c
bacula/src/cats/sql_delete.c
bacula/src/cats/sql_find.c
bacula/src/cats/sql_get.c
bacula/src/cats/sql_list.c
bacula/src/cats/sql_update.c
bacula/src/cats/sqlite.c
bacula/src/console/authenticate.c
bacula/src/console/conio.c
bacula/src/console/console.c
bacula/src/console/console_conf.c
bacula/src/console/console_conf.h
bacula/src/dird/admin.c
bacula/src/dird/authenticate.c
bacula/src/dird/autoprune.c
bacula/src/dird/backup.c
bacula/src/dird/bsr.c
bacula/src/dird/bsr.h
bacula/src/dird/catreq.c
bacula/src/dird/dird.c
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/expand.c
bacula/src/dird/fd_cmds.c
bacula/src/dird/getmsg.c
bacula/src/dird/inc_conf.c
bacula/src/dird/job.c
bacula/src/dird/jobq.c
bacula/src/dird/jobq.h
bacula/src/dird/mac.c
bacula/src/dird/msgchan.c
bacula/src/dird/newvol.c
bacula/src/dird/next_vol.c
bacula/src/dird/protos.h
bacula/src/dird/python.c
bacula/src/dird/recycle.c
bacula/src/dird/restore.c
bacula/src/dird/run_conf.c
bacula/src/dird/scheduler.c
bacula/src/dird/sql_cmds.c
bacula/src/dird/ua.h
bacula/src/dird/ua_acl.c
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_dotcmds.c
bacula/src/dird/ua_input.c
bacula/src/dird/ua_label.c
bacula/src/dird/ua_output.c
bacula/src/dird/ua_prune.c
bacula/src/dird/ua_purge.c
bacula/src/dird/ua_query.c
bacula/src/dird/ua_restore.c
bacula/src/dird/ua_run.c
bacula/src/dird/ua_select.c
bacula/src/dird/ua_server.c
bacula/src/dird/ua_status.c
bacula/src/dird/ua_tree.c
bacula/src/dird/verify.c
bacula/src/filed/authenticate.c
bacula/src/filed/backup.c
bacula/src/filed/chksum.c
bacula/src/filed/estimate.c
bacula/src/filed/filed.c
bacula/src/filed/filed.h
bacula/src/filed/filed_conf.c
bacula/src/filed/filed_conf.h
bacula/src/filed/heartbeat.c
bacula/src/filed/job.c
bacula/src/filed/restore.c
bacula/src/filed/status.c
bacula/src/filed/verify.c
bacula/src/filed/verify_vol.c
bacula/src/filed/win32/popup.c
bacula/src/filed/win32/winabout.h
bacula/src/filed/win32/winservice.h
bacula/src/filed/win32/winstat.h
bacula/src/filed/win32/wintray.h
bacula/src/findlib/attribs.c
bacula/src/findlib/bfile.c
bacula/src/findlib/bfile.h
bacula/src/findlib/create_file.c
bacula/src/findlib/enable_priv.c
bacula/src/findlib/find.c
bacula/src/findlib/find.h
bacula/src/findlib/find_one.c
bacula/src/findlib/fstype.c
bacula/src/findlib/makepath.c
bacula/src/findlib/match.c
bacula/src/findlib/protos.h
bacula/src/findlib/save-cwd.c
bacula/src/findlib/save-cwd.h
bacula/src/findlib/winapi.c
bacula/src/findlib/winapi.h
bacula/src/jcr.h
bacula/src/lib/address_conf.c
bacula/src/lib/address_conf.h
bacula/src/lib/alist.c
bacula/src/lib/alist.h
bacula/src/lib/alloc.c
bacula/src/lib/attr.c
bacula/src/lib/attr.h
bacula/src/lib/base64.c
bacula/src/lib/berrno.c
bacula/src/lib/berrno.h
bacula/src/lib/bget_msg.c
bacula/src/lib/bits.h
bacula/src/lib/bnet.c
bacula/src/lib/bnet_pkt.c
bacula/src/lib/bnet_server.c
bacula/src/lib/bpipe.c
bacula/src/lib/bpipe.h
bacula/src/lib/bsd_queue.h
bacula/src/lib/bshm.c
bacula/src/lib/bsock.h
bacula/src/lib/bsys.c
bacula/src/lib/btime.c
bacula/src/lib/btime.h
bacula/src/lib/btimers.c
bacula/src/lib/btimers.h
bacula/src/lib/cram-md5.c
bacula/src/lib/crc32.c
bacula/src/lib/daemon.c
bacula/src/lib/dlist.c
bacula/src/lib/dlist.h
bacula/src/lib/edit.c
bacula/src/lib/events.c
bacula/src/lib/fnmatch.c
bacula/src/lib/getopt.h
bacula/src/lib/hmac.c
bacula/src/lib/htable.c
bacula/src/lib/htable.h
bacula/src/lib/jcr.c
bacula/src/lib/lex.c
bacula/src/lib/lex.h
bacula/src/lib/lib.h
bacula/src/lib/md5.c
bacula/src/lib/mem_pool.c
bacula/src/lib/mem_pool.h
bacula/src/lib/message.c
bacula/src/lib/message.h
bacula/src/lib/parse_conf.c
bacula/src/lib/parse_conf.h
bacula/src/lib/protos.h
bacula/src/lib/python.c
bacula/src/lib/queue.c
bacula/src/lib/rwlock.c
bacula/src/lib/rwlock.h
bacula/src/lib/scan.c
bacula/src/lib/semlock.c
bacula/src/lib/semlock.h
bacula/src/lib/serial.c
bacula/src/lib/serial.h
bacula/src/lib/sha1.c
bacula/src/lib/sha1.h
bacula/src/lib/signal.c
bacula/src/lib/smartall.c
bacula/src/lib/smartall.h
bacula/src/lib/tcpd.h
bacula/src/lib/tree.c
bacula/src/lib/tree.h
bacula/src/lib/util.c
bacula/src/lib/var.c
bacula/src/lib/var.h
bacula/src/lib/waitq.h
bacula/src/lib/watchdog.c
bacula/src/lib/watchdog.h
bacula/src/lib/workq.c
bacula/src/lib/workq.h
bacula/src/stored/acquire.c
bacula/src/stored/append.c
bacula/src/stored/askdir.c
bacula/src/stored/authenticate.c
bacula/src/stored/autochanger.c
bacula/src/stored/bcopy.c
bacula/src/stored/bextract.c
bacula/src/stored/block.c
bacula/src/stored/block.h
bacula/src/stored/bls.c
bacula/src/stored/bscan.c
bacula/src/stored/bsr.h
bacula/src/stored/btape.c
bacula/src/stored/butil.c
bacula/src/stored/dev.c
bacula/src/stored/dev.h
bacula/src/stored/device.c
bacula/src/stored/dircmd.c
bacula/src/stored/fd_cmds.c
bacula/src/stored/job.c
bacula/src/stored/label.c
bacula/src/stored/match_bsr.c
bacula/src/stored/mount.c
bacula/src/stored/parse_bsr.c
bacula/src/stored/protos.h
bacula/src/stored/read.c
bacula/src/stored/read_record.c
bacula/src/stored/record.c
bacula/src/stored/record.h
bacula/src/stored/spool.c
bacula/src/stored/status.c
bacula/src/stored/stored.c
bacula/src/stored/stored_conf.c
bacula/src/stored/stored_conf.h
bacula/src/tools/bsmtp.c
bacula/src/tools/dbcheck.c
bacula/src/tools/fstype.c
bacula/src/tools/testfind.c
bacula/src/tools/testls.c
bacula/src/version.h

diff --git a/bacula/patches/1.36.1-store.patch b/bacula/patches/1.36.1-store.patch
new file mode 100644 (file)
index 0000000..8b0a926
--- /dev/null
@@ -0,0 +1,802 @@
+ This patch fixes a problem with overriding storage daemon
+ specifications. Previously they were not always honored.
+ This implements more uniform handling. It also eliminates
+ an orphaned buffer situation using JobDefs.
+ Apply to version 1.36.1 with:
+
+ cd <bacula-source>
+ patch -p0 <1.36.1-store.patch
+ make
+ make install
+ ...
+
+Index: src/dird/job.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/job.c,v
+retrieving revision 1.92
+diff -u -r1.92 job.c
+--- src/dird/job.c     21 Nov 2004 13:10:15 -0000      1.92
++++ src/dird/job.c     21 Dec 2004 13:04:08 -0000
+@@ -4,10 +4,10 @@
+  *
+  *     Kern Sibbald, October MM
+  *
+- *    Version $Id$
++ *    Version $Id$
+  */
+ /*
+-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
++   Copyright (C) 2000-2004 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
+@@ -344,7 +344,7 @@
+        if (!ua->jcr->storage[0]) {
+           copy_storage(ua->jcr, jcr);
+        } else {
+-          ua->jcr->store = jcr->store;
++          set_storage(ua->jcr, jcr->store);
+        }
+        if (!connect_to_storage_daemon(ua->jcr, 10, SDConnectTimeout, 1)) {
+             bsendmsg(ua, _("Failed to connect to Storage daemon.\n"));
+@@ -724,6 +724,12 @@
+    if (jcr->term_wait_inited) {
+       pthread_cond_destroy(&jcr->term_wait);
+    }
++   /* Delete lists setup to hold storage pointers */
++   for (int i=0; i<MAX_STORE; i++) {
++      if (jcr->storage[i]) {
++       delete jcr->storage[i];
++      }
++   }
+    jcr->job_end_push.destroy();
+    Dmsg0(200, "End dird free_jcr\n");
+ }
+@@ -749,10 +755,17 @@
+       break;
+    }
+    jcr->JobPriority = job->Priority;
++   /* Copy storage definitions -- deleted in dir_free_jcr above */
+    for (int i=0; i<MAX_STORE; i++) {
+-      jcr->storage[i] = job->storage[i];
++      STORE *st;
++      if (job->storage[i]) {
++       jcr->storage[i] = New(alist(10, not_owned_by_alist));
++       foreach_alist(st, job->storage[i]) {
++          jcr->storage[i]->append(st);
++       }
++      }
+    }
+-   if (!jcr->store && jcr->storage[0]) {
++   if (jcr->storage[0]) {
+       jcr->store = (STORE *)jcr->storage[0]->first();
+    }
+    jcr->client = job->client;
+@@ -805,6 +818,9 @@
+    for (int i=0; i < MAX_STORE; i++) {
+       if (old_jcr->storage[i]) {
+        STORE *st;
++       if (old_jcr->storage[i]) {
++          delete old_jcr->storage[i];
++       }
+        new_jcr->storage[i] = New(alist(10, not_owned_by_alist));
+        foreach_alist(st, old_jcr->storage[i]) {
+           new_jcr->storage[i]->append(st);
+@@ -817,3 +833,10 @@
+       }
+    }
+ }
++
++/* Set storage override */
++void set_storage(JCR *jcr, STORE *store)
++{
++   jcr->store = store;
++   jcr->storage[0]->prepend(store);
++}
+Index: src/dird/msgchan.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/msgchan.c,v
+retrieving revision 1.32
+diff -u -r1.32 msgchan.c
+--- src/dird/msgchan.c 29 Sep 2004 19:58:17 -0000      1.32
++++ src/dird/msgchan.c 21 Dec 2004 13:04:08 -0000
+@@ -13,10 +13,10 @@
+  *    Create a thread to interact with the Storage daemon
+  *    who returns a job status and requests Catalog services, etc.
+  *
+- *   Version $Id$
++ *   Version $Id$
+  */
+ /*
+-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
++   Copyright (C) 2000-2004 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
+@@ -64,10 +64,9 @@
+                             int max_retry_time, int verbose)
+ {
+    BSOCK *sd;
+-   STORE *store = jcr->store;
+-   if (!store) {
+-      jcr->store = store = (STORE *)jcr->storage[0]->first();
+-   }
++   STORE *store;
++
++   store = (STORE *)jcr->storage[0]->first();
+    /*
+     *  Open message channel with the Storage daemon   
+@@ -94,13 +93,13 @@
+  */
+ int start_storage_daemon_job(JCR *jcr)
+ {
+-   int status;
++   int status = 0;
+    STORE *storage;
+    BSOCK *sd;
+    char auth_key[100];
+    POOL_MEM device_name, pool_name, pool_type, media_type;
++   int i;
+-   storage = jcr->store;
+    sd = jcr->store_bsock;
+    /*
+     * Now send JobId and permissions, and get back the authorization key.
+@@ -139,23 +138,29 @@
+    /*
+     * Send use device = xxx media = yyy pool = zzz
+     */
+-   pm_strcpy(device_name, storage->dev_name);
+-   pm_strcpy(media_type, storage->media_type);
+-   pm_strcpy(pool_type, jcr->pool->pool_type);
+-   pm_strcpy(pool_name, jcr->pool->hdr.name);
+-   bash_spaces(device_name);
+-   bash_spaces(media_type);
+-   bash_spaces(pool_type);
+-   bash_spaces(pool_name);
+-   bnet_fsend(sd, use_device, device_name.c_str(), 
+-            media_type.c_str(), pool_name.c_str(), pool_type.c_str());
+-   Dmsg1(110, ">stored: %s", sd->msg);
+-   status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY);
+-   if (!status) {
+-      pm_strcpy(pool_type, sd->msg); /* save message */
+-      Jmsg(jcr, M_FATAL, 0, _("\n"
+-         "     Storage daemon didn't accept Device \"%s\" because:\n     %s"),
+-       device_name.c_str(), pool_type.c_str()/* sd->msg */);
++
++   for (i=0; i < MAX_STORE; i++) {
++      if (jcr->storage[i]) {
++       storage = (STORE *)jcr->storage[i]->first();
++       pm_strcpy(device_name, storage->dev_name);
++       pm_strcpy(media_type, storage->media_type);
++       pm_strcpy(pool_type, jcr->pool->pool_type);
++       pm_strcpy(pool_name, jcr->pool->hdr.name);
++       bash_spaces(device_name);
++       bash_spaces(media_type);
++       bash_spaces(pool_type);
++       bash_spaces(pool_name);
++       bnet_fsend(sd, use_device, device_name.c_str(), 
++                  media_type.c_str(), pool_name.c_str(), pool_type.c_str());
++         Dmsg1(110, ">stored: %s", sd->msg);
++         status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY);
++       if (!status) {
++          pm_strcpy(pool_type, sd->msg); /* save message */
++            Jmsg(jcr, M_FATAL, 0, _("\n"
++               "     Storage daemon didn't accept Device \"%s\" because:\n     %s"),
++             device_name.c_str(), pool_type.c_str()/* sd->msg */);
++       }
++      }
+    }
+    return status;
+ }
+Index: src/dird/protos.h
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/protos.h,v
+retrieving revision 1.56
+diff -u -r1.56 protos.h
+--- src/dird/protos.h  17 Nov 2004 22:48:22 -0000      1.56
++++ src/dird/protos.h  21 Dec 2004 13:04:08 -0000
+@@ -1,7 +1,7 @@
+ /*
+  * Director external function prototypes
+  *
+- *   Version $Id$
++ *   Version $Id$
+  */
+ /*
+    Copyright (C) 2000-2004 Kern Sibbald and John Walker
+@@ -62,7 +62,7 @@
+ /* fd_cmds.c */
+ extern int connect_to_file_daemon(JCR *jcr, int retry_interval,
+-                                  int max_retry_time, int verbose);
++                                int max_retry_time, int verbose);
+ extern int send_include_list(JCR *jcr);
+ extern int send_exclude_list(JCR *jcr);
+ extern int send_bootstrap_file(JCR *jcr);
+@@ -70,7 +70,7 @@
+ extern int get_attributes_and_put_in_catalog(JCR *jcr);
+ extern int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId);
+ extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname, 
+-                          char *link, char *attr, int stream);
++                        char *link, char *attr, int stream);
+ extern void get_level_since_time(JCR *jcr, char *since, int since_len);
+ extern int send_run_before_and_after_commands(JCR *jcr);
+@@ -91,13 +91,14 @@
+ extern int cancel_job(UAContext *ua, JCR *jcr);
+ extern void init_jcr_job_record(JCR *jcr);
+ extern void copy_storage(JCR *new_jcr, JCR *old_jcr);
++extern void set_storage(JCR *jcr, STORE *store);
+ /* mountreq.c */
+ extern void mount_request(JCR *jcr, BSOCK *bs, char *buf);
+ /* msgchan.c */
+ extern bool connect_to_storage_daemon(JCR *jcr, int retry_interval,    
+-                              int max_retry_time, int verbose);
++                            int max_retry_time, int verbose);
+ extern int start_storage_daemon_job(JCR *jcr);
+ extern int start_storage_daemon_message_thread(JCR *jcr);
+ extern int bget_dirmsg(BSOCK *bs);
+@@ -149,28 +150,28 @@
+ void free_ua_context(UAContext *ua);
+ /* ua_select.c */
+-STORE   *select_storage_resource(UAContext *ua);
+-JOB     *select_job_resource(UAContext *ua);
+-JOB     *select_restore_job_resource(UAContext *ua);
+-CLIENT  *select_client_resource(UAContext *ua);
++STORE *select_storage_resource(UAContext *ua);
++JOB   *select_job_resource(UAContext *ua);
++JOB   *select_restore_job_resource(UAContext *ua);
++CLIENT        *select_client_resource(UAContext *ua);
+ FILESET *select_fileset_resource(UAContext *ua);
+-int     select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr);
+-int     select_media_dbr(UAContext *ua, MEDIA_DBR *mr);
+-bool    select_pool_dbr(UAContext *ua, POOL_DBR *pr);
+-int     select_client_dbr(UAContext *ua, CLIENT_DBR *cr);
+-
+-void    start_prompt(UAContext *ua, const char *msg);
+-void    add_prompt(UAContext *ua, const char *prompt);
+-int     do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt);
+-CAT    *get_catalog_resource(UAContext *ua);           
++int   select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr);
++int   select_media_dbr(UAContext *ua, MEDIA_DBR *mr);
++bool  select_pool_dbr(UAContext *ua, POOL_DBR *pr);
++int   select_client_dbr(UAContext *ua, CLIENT_DBR *cr);
++
++void  start_prompt(UAContext *ua, const char *msg);
++void  add_prompt(UAContext *ua, const char *prompt);
++int   do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt);
++CAT    *get_catalog_resource(UAContext *ua);         
+ STORE  *get_storage_resource(UAContext *ua, int use_default);
+-int     get_media_type(UAContext *ua, char *MediaType, int max_media);
+-bool    get_pool_dbr(UAContext *ua, POOL_DBR *pr);
+-int     get_client_dbr(UAContext *ua, CLIENT_DBR *cr);
++int   get_media_type(UAContext *ua, char *MediaType, int max_media);
++bool  get_pool_dbr(UAContext *ua, POOL_DBR *pr);
++int   get_client_dbr(UAContext *ua, CLIENT_DBR *cr);
+ POOL   *get_pool_resource(UAContext *ua);
+ POOL   *select_pool_resource(UAContext *ua);
+ CLIENT *get_client_resource(UAContext *ua);
+-int     get_job_dbr(UAContext *ua, JOB_DBR *jr);
++int   get_job_dbr(UAContext *ua, JOB_DBR *jr);
+ int find_arg_keyword(UAContext *ua, const char **list);
+ int find_arg(UAContext *ua, const char *keyword);
+@@ -190,3 +191,6 @@
+ /* ua_purge.c */
+ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr);
++
++/* ua_run.c */
++extern int run_cmd(UAContext *ua, const char *cmd);
+Index: src/dird/scheduler.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/scheduler.c,v
+retrieving revision 1.27
+diff -u -r1.27 scheduler.c
+--- src/dird/scheduler.c       3 Oct 2004 19:47:34 -0000       1.27
++++ src/dird/scheduler.c       21 Dec 2004 13:04:08 -0000
+@@ -10,7 +10,7 @@
+  *   Version $Id$
+  */
+ /*
+-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
++   Copyright (C) 2000-2004 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
+@@ -157,7 +157,7 @@
+       jcr->dif_pool = run->dif_pool;  /* override dif pool */
+    }
+    if (run->storage) {
+-      jcr->store = run->storage;      /* override storage */
++      set_storage(jcr, run->storage); /* override storage */
+    }
+    if (run->msgs) {
+       jcr->messages = run->msgs;      /* override messages */
+Index: src/dird/ua.h
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/ua.h,v
+retrieving revision 1.23
+diff -u -r1.23 ua.h
+--- src/dird/ua.h      18 Jun 2004 10:07:41 -0000      1.23
++++ src/dird/ua.h      21 Dec 2004 13:04:08 -0000
+@@ -3,7 +3,7 @@
+  *
+  *     Kern Sibbald, August MMI
+  *
+- *     Version $Id$
++ *     Version $Id$
+  */
+ /*
+    Copyright (C) 2000-2004 Kern Sibbald and John Walker
+@@ -48,6 +48,7 @@
+    bool automount;                    /* if set, mount after label */
+    bool quit;                         /* if set, quit */
+    bool verbose;                      /* set for normal UA verbosity */
++   bool batch;                        /* set for non-interactive mode */
+    uint32_t pint32_val;               /* positive integer */
+    int32_t  int32_val;                /* positive/negative */
+ };          
+Index: src/dird/ua_cmds.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/ua_cmds.c,v
+retrieving revision 1.127
+diff -u -r1.127 ua_cmds.c
+--- src/dird/ua_cmds.c 4 Oct 2004 20:34:01 -0000       1.127
++++ src/dird/ua_cmds.c 21 Dec 2004 13:04:10 -0000
+@@ -4,7 +4,7 @@
+  *
+  *     Kern Sibbald, September MM
+  *
+- *   Version $Id$
++ *   Version $Id$
+  */
+ /*
+@@ -52,7 +52,6 @@
+ extern int gui_cmd(UAContext *ua, const char *cmd);
+ extern int sqlquerycmd(UAContext *ua, const char *cmd);
+ extern int querycmd(UAContext *ua, const char *cmd);
+-extern int run_cmd(UAContext *ua, const char *cmd);
+ extern int retentioncmd(UAContext *ua, const char *cmd);
+ extern int prunecmd(UAContext *ua, const char *cmd);
+ extern int purgecmd(UAContext *ua, const char *cmd);
+@@ -1195,7 +1194,7 @@
+    BSOCK *sd;
+    JCR *jcr = ua->jcr;
+-   jcr->store = store;
++   set_storage(jcr, store);
+    /* Try connecting for up to 15 seconds */
+    bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), 
+       store->hdr.name, store->address, store->SDport);
+@@ -1254,8 +1253,10 @@
+    /* Count Storage items */
+    LockRes();
+    store = NULL;
+-   for (i=0; (store = (STORE *)GetNextRes(R_STORAGE, (RES *)store)); i++)
+-      { }
++   i = 0;
++   foreach_res(store, R_STORAGE) {
++      i++;
++   }
+    unique_store = (STORE **) malloc(i * sizeof(STORE));
+    /* Find Unique Storage address/port */       
+    store = (STORE *)GetNextRes(R_STORAGE, NULL);
+@@ -1286,8 +1287,10 @@
+    /* Count Client items */
+    LockRes();
+    client = NULL;
+-   for (i=0; (client = (CLIENT *)GetNextRes(R_CLIENT, (RES *)client)); i++)
+-      { }
++   i = 0;
++   foreach_res(client, R_CLIENT) {
++      i++;
++   }
+    unique_client = (CLIENT **) malloc(i * sizeof(CLIENT));
+    /* Find Unique Client address/port */       
+    client = (CLIENT *)GetNextRes(R_CLIENT, NULL);
+@@ -1841,7 +1844,7 @@
+    Dmsg2(120, "Found storage, MediaType=%s DevName=%s\n",
+       store->media_type, store->dev_name);
+-   jcr->store = store;
++   set_storage(jcr, store);
+    if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) {
+       bsendmsg(ua, _("Failed to connect to Storage daemon.\n"));
+       return;
+Index: src/dird/ua_label.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/ua_label.c,v
+retrieving revision 1.38
+diff -u -r1.38 ua_label.c
+--- src/dird/ua_label.c        17 Aug 2004 14:40:09 -0000      1.38
++++ src/dird/ua_label.c        21 Dec 2004 13:04:10 -0000
+@@ -8,7 +8,7 @@
+  */
+ /*
+-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
++   Copyright (C) 2000-2004 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
+@@ -170,7 +170,7 @@
+    if (!store) {
+       return 1;
+    }
+-   ua->jcr->store = store;
++   set_storage(ua->jcr, store);
+    scan = find_arg(ua, _("scan")) >= 0;
+@@ -296,7 +296,7 @@
+    if (!store) {
+       return 1;
+    }
+-   ua->jcr->store = store;
++   set_storage(ua->jcr, store);
+    if (!relabel && find_arg_keyword(ua, barcode_keyword) >= 0) {
+       label_from_barcodes(ua);
+Index: src/dird/ua_run.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/ua_run.c,v
+retrieving revision 1.58
+diff -u -r1.58 ua_run.c
+--- src/dird/ua_run.c  8 Nov 2004 21:12:12 -0000       1.58
++++ src/dird/ua_run.c  21 Dec 2004 13:04:11 -0000
+@@ -4,11 +4,11 @@
+  *
+  *     Kern Sibbald, December MMI
+  *
+- *   Version $Id$
++ *   Version $Id$
+  */
+ /*
+-   Copyright (C) 2001-2004 Kern Sibbald and John Walker
++   Copyright (C) 2001-2004 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
+@@ -42,6 +42,9 @@
+  * For Restore Jobs
+  *     run <job-name> jobid=nn
+  *
++ *  Returns: 0 on error
++ *         JobId if OK
++ *
+  */
+ int run_cmd(UAContext *ua, const char *cmd)
+ {
+@@ -101,7 +104,7 @@
+    catalog_name = NULL;
+    for (i=1; i<ua->argc; i++) {
+-      Dmsg2(200, "Doing arg %d = %s\n", i, ua->argk[i]);
++      Dmsg2(800, "Doing arg %d = %s\n", i, ua->argk[i]);
+       kw_ok = false;
+       /* Keep looking until we find a good keyword */
+       for (j=0; !kw_ok && kw[j]; j++) {
+@@ -111,12 +114,12 @@
+                bsendmsg(ua, _("Value missing for keyword %s\n"), ua->argk[i]);
+              return 1;
+           }
+-            Dmsg1(200, "Got keyword=%s\n", kw[j]);
++            Dmsg1(800, "Got keyword=%s\n", kw[j]);
+           switch (j) {
+           case 0: /* job */
+              if (job_name) {
+                   bsendmsg(ua, _("Job name specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              job_name = ua->argv[i];
+              kw_ok = true;
+@@ -124,7 +127,7 @@
+           case 1: /* JobId */
+              if (jid) {
+                   bsendmsg(ua, _("JobId specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              jid = ua->argv[i];
+              kw_ok = true;
+@@ -133,7 +136,7 @@
+           case 3: /* fd */
+              if (client_name) {
+                   bsendmsg(ua, _("Client specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              client_name = ua->argv[i];
+              kw_ok = true;
+@@ -141,7 +144,7 @@
+           case 4: /* fileset */
+              if (fileset_name) {
+                   bsendmsg(ua, _("FileSet specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              fileset_name = ua->argv[i];
+              kw_ok = true;
+@@ -149,7 +152,7 @@
+           case 5: /* level */
+              if (level_name) {
+                   bsendmsg(ua, _("Level specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              level_name = ua->argv[i];
+              kw_ok = true;
+@@ -158,7 +161,7 @@
+           case 7: /* sd */
+              if (store_name) {
+                   bsendmsg(ua, _("Storage specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              store_name = ua->argv[i];
+              kw_ok = true;
+@@ -166,7 +169,7 @@
+           case 8: /* pool */
+              if (pool_name) {
+                   bsendmsg(ua, _("Pool specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              pool_name = ua->argv[i];
+              kw_ok = true;
+@@ -174,7 +177,7 @@
+           case 9: /* where */
+              if (where) {
+                   bsendmsg(ua, _("Where specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              where = ua->argv[i];
+              kw_ok = true;
+@@ -182,7 +185,7 @@
+           case 10: /* bootstrap */
+              if (bootstrap) {
+                   bsendmsg(ua, _("Bootstrap specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              bootstrap = ua->argv[i];
+              kw_ok = true;
+@@ -190,7 +193,7 @@
+           case 11: /* replace */
+              if (replace) {
+                   bsendmsg(ua, _("Replace specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              replace = ua->argv[i];
+              kw_ok = true;
+@@ -198,7 +201,7 @@
+           case 12: /* When */
+              if (when) {
+                   bsendmsg(ua, _("When specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              when = ua->argv[i];
+              kw_ok = true;
+@@ -206,7 +209,7 @@
+           case 13:  /* Priority */
+              if (Priority) {
+                   bsendmsg(ua, _("Priority specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              Priority = atoi(ua->argv[i]);
+              if (Priority <= 0) {
+@@ -221,7 +224,7 @@
+           case 15: /* Verify Job */
+              if (verify_job_name) {
+                   bsendmsg(ua, _("Verify Job specified twice.\n"));
+-                return 1;
++                return 0;
+              }
+              verify_job_name = ua->argv[i];
+              kw_ok = true;
+@@ -255,21 +258,22 @@
+             Dmsg1(200, "Set jobname=%s\n", job_name);
+        } else {
+             bsendmsg(ua, _("Invalid keyword: %s\n"), ua->argk[i]);
+-          return 1;
++          return 0;
+        }
+       }
+    } /* end argc loop */
+            
+-   Dmsg0(200, "Done scan.\n");
++   Dmsg0(800, "Done scan.\n");
+    CAT *catalog = NULL;
+    if (catalog_name != NULL) {
+        catalog = (CAT *)GetResWithName(R_CATALOG, catalog_name);
+        if (catalog == NULL) {
+             bsendmsg(ua, _("Catalog \"%s\" not found\n"), catalog_name);
+-         return 1;
++         return 0;
+        }
+    }
++   Dmsg1(200, "Using catalog=%s\n", catalog_name);
+    if (job_name) {
+       /* Find Job */
+@@ -287,11 +291,11 @@
+       job = select_job_resource(ua);
+    }
+    if (!job) {
+-      return 1;
++      return 0;
+    } else if (!acl_access_ok(ua, Job_ACL, job->hdr.name)) {
+       bsendmsg(ua, _("No authorization. Job \"%s\".\n"),
+        job->hdr.name);
+-      return 1;
++      return 0;
+    }
+    if (store_name) {
+@@ -310,8 +314,9 @@
+    } else if (!acl_access_ok(ua, Storage_ACL, store->hdr.name)) {
+       bsendmsg(ua, _("No authorization. Storage \"%s\".\n"),
+              store->hdr.name);
+-      return 1;
++      return 0;
+    }
++   Dmsg1(200, "Using storage=%s\n", store->hdr.name);
+    if (pool_name) {
+       pool = (POOL *)GetResWithName(R_POOL, pool_name);
+@@ -325,12 +330,13 @@
+       pool = job->pool;           /* use default */
+    }
+    if (!pool) {
+-      return 1;
++      return 0;
+    } else if (!acl_access_ok(ua, Pool_ACL, store->hdr.name)) {
+       bsendmsg(ua, _("No authorization. Pool \"%s\".\n"),
+              pool->hdr.name);
+-      return 1;
++      return 0;
+    }
++   Dmsg1(200, "Using pool\n", pool->hdr.name);
+    if (client_name) {
+       client = (CLIENT *)GetResWithName(R_CLIENT, client_name);
+@@ -344,12 +350,13 @@
+       client = job->client;         /* use default */
+    }
+    if (!client) {
+-      return 1;
++      return 0;
+    } else if (!acl_access_ok(ua, Client_ACL, store->hdr.name)) {
+       bsendmsg(ua, _("No authorization. Client \"%s\".\n"),
+              client->hdr.name);
+-      return 1;
++      return 0;
+    }
++   Dmsg1(200, "Using client=%s\n", client->hdr.name);
+    if (fileset_name) {
+       fileset = (FILESET *)GetResWithName(R_FILESET, fileset_name);
+@@ -361,11 +368,11 @@
+       fileset = job->fileset;         /* use default */
+    }
+    if (!fileset) {
+-      return 1;
++      return 0;
+    } else if (!acl_access_ok(ua, FileSet_ACL, store->hdr.name)) {
+       bsendmsg(ua, _("No authorization. FileSet \"%s\".\n"),
+              fileset->hdr.name);
+-      return 1;
++      return 0;
+    }
+    if (verify_job_name) {
+@@ -386,7 +393,7 @@
+    set_jcr_defaults(jcr, job);
+    jcr->verify_job = verify_job;
+-   jcr->store = store;
++   set_storage(jcr, store);
+    jcr->client = client;
+    jcr->fileset = fileset;
+    jcr->pool = pool;
+@@ -460,7 +467,7 @@
+    }
+    /* Run without prompting? */
+-   if (find_arg(ua, _("yes")) > 0) {
++   if (ua->batch || find_arg(ua, _("yes")) > 0) {
+       goto start_job;
+    }
+@@ -701,7 +708,7 @@
+        /* Storage */
+        store = select_storage_resource(ua);
+        if (store) {
+-          jcr->store = store;
++          set_storage(jcr, store);
+           goto try_again;
+        }
+        break;
+@@ -847,7 +854,7 @@
+       } else {
+          bsendmsg(ua, _("Job started. JobId=%u\n"), JobId);
+       }
+-      return 1;
++      return JobId;
+    }
+ bail_out:
+Index: src/dird/ua_server.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/ua_server.c,v
+retrieving revision 1.35
+diff -u -r1.35 ua_server.c
+--- src/dird/ua_server.c       19 Sep 2004 18:56:24 -0000      1.35
++++ src/dird/ua_server.c       21 Dec 2004 13:04:11 -0000
+@@ -99,6 +99,15 @@
+ {
+    JCR *jcr;
+    jcr = new_jcr(sizeof(JCR), dird_free_jcr);
++   /*
++    * The job and defaults are not really used, but
++    *  we set them up to ensure that everything is correctly
++    *  initialized.
++    */
++   LockRes();
++   jcr->job = (JOB *)GetNextRes(R_JOB, NULL);
++   set_jcr_defaults(jcr, jcr->job);
++   UnlockRes();
+    jcr->sd_auth_key = bstrdup("dummy"); /* dummy Storage daemon key */
+    create_unique_job_name(jcr, base_name);
+    jcr->sched_time = jcr->start_time;
+@@ -106,20 +115,6 @@
+    jcr->JobLevel = L_NONE;
+    jcr->JobStatus = JS_Running;
+    jcr->JobId = 0;
+-   /*
+-    * None of these are really defined for control JCRs, so we
+-    * simply take the first of each one. This ensures that there
+-    * will be no null pointer references.
+-    */
+-   LockRes();
+-   jcr->job = (JOB *)GetNextRes(R_JOB, NULL);
+-   jcr->messages = (MSGS *)GetNextRes(R_MSGS, NULL);
+-   jcr->client = (CLIENT *)GetNextRes(R_CLIENT, NULL);
+-   jcr->pool = (POOL *)GetNextRes(R_POOL, NULL);
+-   jcr->catalog = (CAT *)GetNextRes(R_CATALOG, NULL);
+-   jcr->store = (STORE *)GetNextRes(R_STORAGE, NULL);
+-   jcr->fileset = (FILESET *)GetNextRes(R_FILESET, NULL);
+-   UnlockRes();
+    return jcr;
+ }
+Index: src/dird/ua_status.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/ua_status.c,v
+retrieving revision 1.61
+diff -u -r1.61 ua_status.c
+--- src/dird/ua_status.c       19 Sep 2004 18:56:25 -0000      1.61
++++ src/dird/ua_status.c       21 Dec 2004 13:04:12 -0000
+@@ -282,7 +282,7 @@
+ {
+    BSOCK *sd;
+-   ua->jcr->store = store;
++   set_storage(ua->jcr, store);
+    /* Try connecting for up to 15 seconds */
+    bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), 
+       store->hdr.name, store->address, store->SDport);
index cf12c35f1c3199a332249988ffff84e64e3c908f..0480335f72c631e17637dd0e385ab0b9eb2dd082 100644 (file)
@@ -12,3 +12,9 @@
  This patch fixes the despooling size printed in the Job 
  report. Previously, it reported the total size for the
  device. This patch makes it report the size for the job.
+
+21Dec04
+ This patch fixes a problem with overriding storage daemon
+ specifications. Previously they were not always honored.
+ This implements more uniform handling. It also eliminates
+ an orphaned buffer situation using JobDefs.
index a5fc2a1333e5c39c993b8e5374c3bae6c923c7ca..47712645114371fb29e653b589f0a4b5177b2e53 100644 (file)
@@ -55,7 +55,7 @@
 #endif
 
 /* Allow printing of NULL pointers */
-#define NPRT(x) (x)?(x):"*None*" 
+#define NPRT(x) (x)?(x):"*None*"
 
 #ifdef ENABLE_NLS
 #include <libintl.h>
@@ -76,7 +76,7 @@
 #define MAXSTRING 500
 
 /* Maximum length to edit time/date */
-#define MAX_TIME_LENGTH 50  
+#define MAX_TIME_LENGTH 50
 
 /* Maximum Name length including EOS */
 #define MAX_NAME_LENGTH 128
 /*** FIXME ***/
 
 
-/* 
- *  File type (Bacula defined).           
+/*
+ *  File type (Bacula defined).
  *  NOTE!!! These are saved in the Attributes record on the tape, so
  *          do not change them. If need be, add to them.
  *
  *    additional optional fields in the attribute record.
  */
 #define FT_MASK       0xFFFF          /* Bits used by FT (type) */
-#define FT_LNKSAVED   1               /* hard link to file already saved */  
+#define FT_LNKSAVED   1               /* hard link to file already saved */
 #define FT_REGE       2               /* Regular file but empty */
 #define FT_REG        3               /* Regular file */
 #define FT_LNK        4               /* Soft Link */
@@ -260,13 +260,13 @@ extern void _v(char *file, int line, pthread_mutex_t *m);
 #define P(x) \
    do { int errstat; if ((errstat=pthread_mutex_lock(&(x)))) \
       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex lock failure. ERR=%s\n",\
-           strerror(errstat)); \
+          strerror(errstat)); \
    } while(0)
 
 #define V(x) \
    do { int errstat; if ((errstat=pthread_mutex_unlock(&(x)))) \
-         e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\
-           strerror(errstat)); \
+        e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\
+          strerror(errstat)); \
    } while(0)
 
 #endif /* DEBUG_MUTEX */
@@ -275,13 +275,13 @@ extern void _v(char *file, int line, pthread_mutex_t *m);
 #define Pw(x) \
    do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
-           strerror(errstat)); \
+          strerror(errstat)); \
    } while(0)
 
 #define Vw(x) \
    do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
-         e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
-           strerror(errstat)); \
+        e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
+          strerror(errstat)); \
    } while(0)
 
 #define LockRes()   b_LockRes(__FILE__, __LINE__)
@@ -378,7 +378,7 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num);
 #define Pmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
 #define Pmsg14(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
 
-       
+
 /* Daemon Error Messages that are delivered according to the message resource */
 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
@@ -463,7 +463,7 @@ int  m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...)
 #endif
 
 #ifdef HAVE_SUN_OS
-   /* 
+   /*
     * On Solaris 2.5, threads are not timesliced by default, so we need to
     * explictly increase the conncurrency level.
     */
@@ -504,7 +504,7 @@ extern "C" int getdomainname(char *name, int len);
 extern "C" int fchdir(int filedes);
 extern "C" long gethostid(void);
 #endif
+
 /* This probably should be done on a machine by machine basic, but it works */
 #define ALIGN_SIZE (sizeof(double))
 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
@@ -517,7 +517,7 @@ extern "C" long gethostid(void);
 
 /*
  * Replace codes needed in both file routines and non-file routines
- * Job replace codes -- in "replace"   
+ * Job replace codes -- in "replace"
  */
 #define REPLACE_ALWAYS   'a'
 #define REPLACE_IFNEWER  'w'
@@ -532,7 +532,7 @@ extern "C" long gethostid(void);
 #endif
 #ifdef HAVE_NL_LANGINFO
 #include <langinfo.h>
-#else 
+#else
 #define nl_langinfo(x) ("ANSI_X3.4-1968")
 #endif
 
index 6e2bf2769bb6b6481a2d669c63c00b2c2f014f84..d40cdfb32805d4a2f90658c75e7aee7b21a4035c 100644 (file)
@@ -72,7 +72,7 @@
 #else
 #include "lib/getopt.h"
 #endif
-#endif 
+#endif
 
 #include <string.h>
 #include <strings.h>
 #include <pthread.h>
 
 /* Local Bacula includes. Be sure to put all the system
- *  includes before these.  
+ *  includes before these.
  */
 #include "version.h"
 #include "bc_types.h"
index 1f5738c37ccc09f3b3a61d67c5509aad05b3acbe..3229b35d0e6aaa8b8e795796e534e127a2f665e3 100644 (file)
@@ -38,7 +38,7 @@
 #ifndef __bc_types_INCLUDED
 #define __bc_types_INCLUDED
 
-typedef char POOLMEM;   
+typedef char POOLMEM;
 
 
 /* Types */
@@ -139,14 +139,14 @@ typedef u_int64_t u_intmax_t;
 
 
 /* Limits for the above types. */
-#undef INT8_MIN  
-#undef INT8_MAX  
-#undef UINT8_MAX 
-#undef INT16_MIN 
-#undef INT16_MAX 
+#undef INT8_MIN
+#undef INT8_MAX
+#undef UINT8_MAX
+#undef INT16_MIN
+#undef INT16_MAX
 #undef UINT16_MAX
-#undef INT32_MIN 
-#undef INT32_MAX 
+#undef INT32_MIN
+#undef INT32_MAX
 #undef UINT32_MAX
 
 #define INT8_MIN        (-127-1)
index 1cf8c3a05b37d5f0f056f22e674e0b3343287548..ae12c1c22dc3a10bc66a7ed5f10e5c5319b447d8 100644 (file)
@@ -5,8 +5,8 @@
  *  The purpose of these routines is to ensure that Bacula
  *  can limp along if no real database is loaded on the
  *  system.
- *   
- *    Kern Sibbald, January MMI 
+ *
+ *    Kern Sibbald, January MMI
  *
  *    Version $Id$
  *
@@ -79,7 +79,7 @@ static POOLMEM *make_filename(B_DB *mdb, char *name)
    if (working_directory[strlen(working_directory)-1] == '/') {
       sep = 0;
    } else {
-      sep = '/'; 
+      sep = '/';
    }
    Mmsg(dbf, "%s%c%s-%s", working_directory, sep, mdb->db_name, name);
    return dbf;
@@ -103,7 +103,7 @@ int bdb_write_control_file(B_DB *mdb)
  */
 B_DB *
 db_init_database(JCR *jcr, char const *db_name, char const *db_user, char const *db_password,
-                char const *db_address, int db_port, char const *db_socket, 
+                char const *db_address, int db_port, char const *db_socket,
                 int mult_db_connections)
 {
    B_DB *mdb;
@@ -111,7 +111,7 @@ db_init_database(JCR *jcr, char const *db_name, char const *db_user, char const
    /* Look to see if DB already open */
    for (mdb=NULL; (mdb=(B_DB *)qnext(&db_list, &mdb->bq)); ) {
       if (strcmp(mdb->db_name, db_name) == 0) {
-         Dmsg2(200, "DB REopen %d %s\n", mdb->ref_count, db_name);
+        Dmsg2(200, "DB REopen %d %s\n", mdb->ref_count, db_name);
         mdb->ref_count++;
         V(mutex);
         return mdb;                  /* already open */
@@ -163,10 +163,10 @@ db_open_database(JCR *jcr, B_DB *mdb)
 
    Dmsg0(200, "make_filename\n");
    dbf = make_filename(mdb, DB_CONTROL_FILENAME);
-   mdb->cfd = open(dbf, O_CREAT|O_RDWR, 0600); 
+   mdb->cfd = open(dbf, O_CREAT|O_RDWR, 0600);
    free_memory(dbf);
    if (mdb->cfd < 0) {
-      Mmsg2(&mdb->errmsg, _("Unable to open Catalog DB control file %s: ERR=%s\n"), 
+      Mmsg2(&mdb->errmsg, _("Unable to open Catalog DB control file %s: ERR=%s\n"),
         dbf, strerror(errno));
       V(mutex);
       return 0;
@@ -224,9 +224,9 @@ db_open_database(JCR *jcr, B_DB *mdb)
       Mmsg1(&mdb->errmsg, _("Error reading catalog DB control file. ERR=%s\n"), strerror(errno));
       badctl = 1;
    } else if (mdb->control.bdb_version != BDB_VERSION) {
-      Mmsg2(&mdb->errmsg, _("Error, catalog DB control file wrong version. \
-Wanted %d, got %d\n\
-Please reinitialize the working directory.\n"), 
+      Mmsg2(&mdb->errmsg, _("Error, catalog DB control file wrong version. "
+"Wanted %d, got %d\n"
+"Please reinitialize the working directory.\n"),
         BDB_VERSION, mdb->control.bdb_version);
       badctl = 1;
    }
@@ -239,7 +239,7 @@ Please reinitialize the working directory.\n"),
    return 1;
 }
 
-void db_close_database(JCR *jcr, B_DB *mdb)           
+void db_close_database(JCR *jcr, B_DB *mdb)
 {
    P(mutex);
    mdb->ref_count--;
@@ -268,7 +268,7 @@ void db_close_database(JCR *jcr, B_DB *mdb)
       if (mdb->filesetfd) {
         fclose(mdb->filesetfd);
       }
-      rwl_destroy(&mdb->lock);      
+      rwl_destroy(&mdb->lock);
       free_pool_memory(mdb->errmsg);
       free_pool_memory(mdb->cmd);
       free_pool_memory(mdb->cached_path);
@@ -301,11 +301,11 @@ int bdb_open_jobs_file(B_DB *mdb)
 {
    char *dbf;
 
-   if (!mdb->jobfd) {  
+   if (!mdb->jobfd) {
       dbf = make_filename(mdb, DB_JOBS_FILENAME);
       mdb->jobfd = fopen(dbf, "r+");
       if (!mdb->jobfd) {
-         Mmsg2(&mdb->errmsg, "Error opening DB Jobs file %s: ERR=%s\n", 
+        Mmsg2(&mdb->errmsg, "Error opening DB Jobs file %s: ERR=%s\n",
            dbf, strerror(errno));
         Emsg0(M_FATAL, 0, mdb->errmsg);
         free_memory(dbf);
@@ -323,11 +323,11 @@ int bdb_open_jobmedia_file(B_DB *mdb)
 {
    char *dbf;
 
-   if (!mdb->jobmediafd) {  
+   if (!mdb->jobmediafd) {
       dbf = make_filename(mdb, DB_JOBMEDIA_FILENAME);
       mdb->jobmediafd = fopen(dbf, "r+");
       if (!mdb->jobmediafd) {
-         Mmsg2(&mdb->errmsg, "Error opening DB JobMedia file %s: ERR=%s\n", 
+        Mmsg2(&mdb->errmsg, "Error opening DB JobMedia file %s: ERR=%s\n",
            dbf, strerror(errno));
         Emsg0(M_FATAL, 0, mdb->errmsg);
         free_memory(dbf);
@@ -346,11 +346,11 @@ int bdb_open_pools_file(B_DB *mdb)
 {
    char *dbf;
 
-   if (!mdb->poolfd) { 
+   if (!mdb->poolfd) {
       dbf = make_filename(mdb, DB_POOLS_FILENAME);
       mdb->poolfd = fopen(dbf, "r+");
       if (!mdb->poolfd) {
-         Mmsg2(&mdb->errmsg, "Error opening DB Pools file %s: ERR=%s\n", 
+        Mmsg2(&mdb->errmsg, "Error opening DB Pools file %s: ERR=%s\n",
            dbf, strerror(errno));
         Emsg0(M_FATAL, 0, mdb->errmsg);
         free_memory(dbf);
@@ -369,11 +369,11 @@ int bdb_open_client_file(B_DB *mdb)
 {
    char *dbf;
 
-   if (!mdb->clientfd) {  
+   if (!mdb->clientfd) {
       dbf = make_filename(mdb, DB_CLIENT_FILENAME);
       mdb->clientfd = fopen(dbf, "r+");
       if (!mdb->clientfd) {
-         Mmsg2(&mdb->errmsg, "Error opening DB Clients file %s: ERR=%s\n", 
+        Mmsg2(&mdb->errmsg, "Error opening DB Clients file %s: ERR=%s\n",
            dbf, strerror(errno));
         Emsg0(M_FATAL, 0, mdb->errmsg);
         free_memory(dbf);
@@ -391,11 +391,11 @@ int bdb_open_fileset_file(B_DB *mdb)
 {
    char *dbf;
 
-   if (!mdb->filesetfd) {  
+   if (!mdb->filesetfd) {
       dbf = make_filename(mdb, DB_CLIENT_FILENAME);
       mdb->filesetfd = fopen(dbf, "r+");
       if (!mdb->filesetfd) {
-         Mmsg2(&mdb->errmsg, "Error opening DB FileSet file %s: ERR=%s\n", 
+        Mmsg2(&mdb->errmsg, "Error opening DB FileSet file %s: ERR=%s\n",
            dbf, strerror(errno));
         Emsg0(M_FATAL, 0, mdb->errmsg);
         free_memory(dbf);
@@ -415,11 +415,11 @@ int bdb_open_media_file(B_DB *mdb)
 {
    char *dbf;
 
-   if (!mdb->mediafd) {  
+   if (!mdb->mediafd) {
       dbf = make_filename(mdb, DB_MEDIA_FILENAME);
       mdb->mediafd = fopen(dbf, "r+");
       if (!mdb->mediafd) {
-         Mmsg2(&mdb->errmsg, "Error opening DB Media file %s: ERR=%s\n", 
+        Mmsg2(&mdb->errmsg, "Error opening DB Media file %s: ERR=%s\n",
            dbf, strerror(errno));
         free_memory(dbf);
         return 0;
@@ -437,7 +437,7 @@ void _db_lock(const char *file, int line, B_DB *mdb)
       e_msg(file, line, M_ABORT, 0, "rwl_writelock failure. ERR=%s\n",
           strerror(errstat));
    }
-}    
+}
 
 void _db_unlock(const char *file, int line, B_DB *mdb)
 {
@@ -446,11 +446,11 @@ void _db_unlock(const char *file, int line, B_DB *mdb)
       e_msg(file, line, M_ABORT, 0, "rwl_writeunlock failure. ERR=%s\n",
           strerror(errstat));
    }
-}    
+}
 
 /*
  * Start a transaction. This groups inserts and makes things
- *  much more efficient. Usually started when inserting 
+ *  much more efficient. Usually started when inserting
  *  file attributes.
  */
 void db_start_transaction(JCR *jcr, B_DB *mdb)
index a42c4a422a6c76ee5f3dc524a42f87ad38195b4c..165404124020107b62811fc061211e879ce04115 100644 (file)
@@ -7,8 +7,8 @@
  *  The purpose of these routines is to ensure that Bacula
  *  can limp along if no real database is loaded on the
  *  system.
- *   
- *    Kern Sibbald, January MMI 
+ *
+ *    Kern Sibbald, January MMI
  *
  *    Version $Id$
  */
@@ -62,14 +62,14 @@ int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
 }
 
 int db_create_file_item(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
-{           
+{
    /****FIXME***** not implemented */
    return 1;
 }
 
 
-/*  
- * Create a new record for the Job    
+/*
+ * Create a new record for the Job
  *   This record is created at the start of the Job,
  *   it is updated in bdb_update.c when the Job terminates.
  *
@@ -101,7 +101,7 @@ int db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    return 1;
 }
 
-/* Create a JobMedia record for Volume used this job   
+/* Create a JobMedia record for Volume used this job
  * Returns: 0 on failure
  *         record-id on success
  */
@@ -172,14 +172,14 @@ int db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
 }
 
 
-/* 
+/*
  * Create Unique Media record. This record
  *   contains all the data pertaining to a specific
  *   Volume.
  *
  * Returns: 0 on failure
  *         1 on success
- */ 
+ */
 int db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
    int len;
@@ -254,7 +254,7 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
 /*
  *  Create a unique FileSet record or return existing record
  *
- *   Note, here we write the FILESET_DBR structure 
+ *   Note, here we write the FILESET_DBR structure
  *
  * Returns: 0 on failure
  *         1 on success
index b2c5ad10c5551eda886d91632cd2f0d8e05c553b..3e3915a8d3dcd6766c535c007254ecfc5ff133bf 100644 (file)
@@ -7,8 +7,8 @@
  *  The purpose of these routines is to ensure that Bacula
  *  can limp along if no real database is loaded on the
  *  system.
- *   
- *    Kern Sibbald, January MMI 
+ *
+ *    Kern Sibbald, January MMI
  *
  *    Version $Id$
  */
@@ -59,7 +59,7 @@
  * Delete a Pool record given the Name
  *
  * Returns: 0 on error
- *         the number of records deleted on success 
+ *         the number of records deleted on success
  */
 int db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
 {
@@ -77,11 +77,11 @@ int db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
    memset(&opr, 0, sizeof(opr));
    stat = fwrite(&opr, sizeof(opr), 1, mdb->poolfd);
    db_unlock(mdb);
-   return stat; 
+   return stat;
 }
 
-int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) 
-{ 
+int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
+{
    int stat;
    MEDIA_DBR omr;
 
@@ -95,7 +95,7 @@ int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    memset(&omr, 0, sizeof(omr));
    stat = fwrite(&omr, sizeof(omr), 1, mdb->mediafd);
    db_unlock(mdb);
-   return stat; 
+   return stat;
 }
 
 #endif /* HAVE_BACULA_DB */
index 38e8a57c46ce143c115c607bb9aab3a9c69890b4..b234f69b6904bac8af4f4bf253c6fbcbc28fe9c0 100644 (file)
@@ -11,8 +11,8 @@
  *  The purpose of these routines is to ensure that Bacula
  *  can limp along if no real database is loaded on the
  *  system.
- *   
- *    Kern Sibbald, January MMI 
+ *
+ *    Kern Sibbald, January MMI
  *
  *    Version $Id$
  */
@@ -58,7 +58,7 @@
  */
 
 
-/* 
+/*
  * Find job start time. Used to find last full save that terminated normally
  * so we can do Incremental and Differential saves.
  *
@@ -86,8 +86,8 @@ int db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
     */
 
    while (fgets(cmd, sizeof(cmd), mdb->jobfd)) {
-      if (sscanf(cmd, "JobStart JobId=%d Name=%127s Type=%1s Level=%1s \
-StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
+      if (sscanf(cmd, "JobStart JobId=%d Name=%127s Type=%1s Level=%1s "
+"StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
         if (JobId < jr->JobId) {
            continue;                 /* older not a candidate */
         }
@@ -95,15 +95,15 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
         Level = cLevel[0];
         unbash_spaces(Name);
         unbash_spaces(StartTime);
-         Dmsg4(200, "Got Type=%c Level=%c Name=%s StartTime=%s\n",
+        Dmsg4(200, "Got Type=%c Level=%c Name=%s StartTime=%s\n",
            Type, Level, Name, StartTime);
-         Dmsg3(200, "Want Type=%c Level=%c Name=%s\n", jr->JobType, jr->JobLevel,     
+        Dmsg3(200, "Want Type=%c Level=%c Name=%s\n", jr->JobType, jr->JobLevel,
            jr->Name);
         /* Differential is since last Full backup */
         /* Incremental is since last FULL or Incremental or Differential */
-        if (((jr->JobLevel == L_DIFFERENTIAL) && (Type == jr->JobType && 
+        if (((jr->JobLevel == L_DIFFERENTIAL) && (Type == jr->JobType &&
               Level == L_FULL && strcmp(Name, jr->Name) == 0)) ||
-            ((jr->JobLevel == L_INCREMENTAL) && (Type == jr->JobType && 
+            ((jr->JobLevel == L_INCREMENTAL) && (Type == jr->JobType &&
               (Level == L_FULL || Level == L_INCREMENTAL ||
                Level == L_DIFFERENTIAL) && strcmp(Name, jr->Name) == 0))) {
            addr = ftell(mdb->jobfd);    /* save current location */
@@ -111,10 +111,10 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
            found = 0;
            /* Search for matching JobEnd record */
            while (!found && fgets(cmd, sizeof(cmd), mdb->jobfd)) {
-               if (sscanf(cmd, "JobEnd JobId=%d JobStatus=%1s ClientId=%d",
+              if (sscanf(cmd, "JobEnd JobId=%d JobStatus=%1s ClientId=%d",
                  &EndId, JobStatus, &ClientId) == 3) {
-                  if (EndId == JobId && *JobStatus == 'T' && ClientId == jr->ClientId) {
-                     Dmsg0(200, "====found EndJob matching Job\n");
+                 if (EndId == JobId && *JobStatus == 'T' && ClientId == jr->ClientId) {
+                    Dmsg0(200, "====found EndJob matching Job\n");
                     found = 1;
                     break;
                  }
@@ -125,7 +125,7 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
            if (found) {
               pm_strcpy(stime, StartTime);
               stat = 1;              /* Got a candidate */
-               Dmsg5(200, "Got candidate JobId=%d Type=%c Level=%c Name=%s StartTime=%s\n",
+              Dmsg5(200, "Got candidate JobId=%d Type=%c Level=%c Name=%s StartTime=%s\n",
                  JobId, Type, Level, Name, StartTime);
            }
         }
@@ -136,18 +136,18 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
 }
 
 
-/* 
+/*
  * Find Available Media (Volume) for Pool
  *
  * Find a Volume for a given PoolId, MediaType, and VolStatus
  *
- *   Note! this does not correctly implement InChanger.          
+ *   Note! this does not correctly implement InChanger.
  *
  * Returns: 0 on failure
  *         numrows on success
- */    
+ */
 int
-db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr) 
+db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr)
 {
    MEDIA_DBR omr;
    int stat = 0;
@@ -164,19 +164,19 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr
    while (fread(&omr, len, 1, mdb->mediafd) > 0) {
       if (mr->PoolId == omr.PoolId && strcmp(mr->VolStatus, omr.VolStatus) == 0 &&
          strcmp(mr->MediaType, omr.MediaType) == 0) {
-         if (!(++index == item)) {    /* looking for item'th entry */
-            Dmsg0(200, "Media record matches, but not index\n");
+        if (!(++index == item)) {    /* looking for item'th entry */
+           Dmsg0(200, "Media record matches, but not index\n");
            continue;
         }
-         Dmsg0(200, "Media record matches\n");
+        Dmsg0(200, "Media record matches\n");
         memcpy(mr, &omr, len);
-         Dmsg1(200, "Findnextvol MediaId=%d\n", mr->MediaId);
+        Dmsg1(200, "Findnextvol MediaId=%d\n", mr->MediaId);
         stat = 1;
         break;                       /* found it */
       }
    }
    db_unlock(mdb);
-   return stat;                
+   return stat;
 }
 
 int
index cbabc7a3aa66f2b7f1fc5cfe104e55c831c1a929..4bc4447d52fe239f6bd043fd7515c0705c2f1518 100644 (file)
@@ -2,7 +2,7 @@
  * Bacula Catalog Database Get record interface routines
  *  Note, these routines generally get a record by id or
  *       by name.  If more logic is involved, the routine
- *       should be in find.c 
+ *       should be in find.c
  *
  * Bacula Catalog Database routines written specifically
  *  for Bacula.  Note, these routines are VERY dumb and
@@ -10,8 +10,8 @@
  *  The purpose of these routines is to ensure that Bacula
  *  can limp along if no real database is loaded on the
  *  system.
- *   
- *    Kern Sibbald, January MMI 
+ *
+ *    Kern Sibbald, January MMI
  *
  *    Version $Id$
  */
  */
 
 
-/* 
+/*
  * Get Job record for given JobId
  * Returns: 0 on failure
  *         1 on success
  */
 
 int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
-{ 
+{
    JOB_DBR ojr;
    faddr_t rec_addr;
    int found = 0;
@@ -98,7 +98,7 @@ int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
       /* Search by Job */
       } else if (strcmp(jr->Job, ojr.Job) == 0) {
         found = 1;
-         Dmsg1(200, "Found Job: %s\n", ojr.Job);
+        Dmsg1(200, "Found Job: %s\n", ojr.Job);
       }
       if (!found) {
         rec_addr = ftell(mdb->jobfd); /* save start next record */
@@ -121,7 +121,7 @@ int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 }
 
 
-/* 
+/*
  * Get the number of pool records
  *
  * Returns: -1 on failure
@@ -172,13 +172,13 @@ int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
 }
 
 
-/* 
- * Get Pool Record   
+/*
+ * Get Pool Record
  * If the PoolId is non-zero, we get its record,
  *  otherwise, we search on the PoolName
  *
  * Returns: 0 on failure
- *         id on success 
+ *         id on success
  */
 int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
 {
@@ -208,7 +208,7 @@ int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
       /* Search by Name */
       } else if (strcmp(pr->Name, opr.Name) == 0) {
         found = 1;
-         Dmsg1(200, "Found pool: %s\n", opr.Name);
+        Dmsg1(200, "Found pool: %s\n", opr.Name);
       }
       if (!found) {
         rec_addr = ftell(mdb->poolfd); /* save start next record */
@@ -230,7 +230,7 @@ int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
    return stat;
 }
 
-/* 
+/*
  * Get the number of Media records
  *
  * Returns: -1 on failure
@@ -247,7 +247,7 @@ int db_get_num_media_records(JCR *jcr, B_DB *mdb)
 }
 
 /*
- * This function returns a list of all the Media record ids 
+ * This function returns a list of all the Media record ids
  *  for a specified PoolId
  *  The caller must free ids if non-NULL.
  *
@@ -287,13 +287,13 @@ int db_get_media_ids(JCR *jcr, B_DB *mdb, uint32_t PoolId, int *num_ids, uint32_
    return 1;
 }
 
-/* 
- * Get Media Record   
+/*
+ * Get Media Record
  * If the MediaId is non-zero, we get its record,
  *  otherwise, we search on the MediaName
  *
  * Returns: 0 on failure
- *         id on success 
+ *         id on success
  */
 int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
@@ -320,7 +320,7 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
       Dmsg1(200, "VolName=%s\n", omr.VolumeName);
       /* If id not zero, search by Id */
       if (mr->MediaId != 0) {
-         Dmsg1(200, "MediaId=%d\n", mr->MediaId);
+        Dmsg1(200, "MediaId=%d\n", mr->MediaId);
         if (mr->MediaId == omr.MediaId) {
           found = 1;
         }
@@ -381,7 +381,7 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum
         while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) {
            if (jm.MediaId == mr.MediaId) {
               if (*VolumeNames[0] != 0) {      /* if not first name, */
-                  pm_strcat(VolumeNames, "|");  /* add separator */
+                 pm_strcat(VolumeNames, "|");  /* add separator */
               }
               pm_strcat(VolumeNames, mr.VolumeName); /* add Volume Name */
               found++;
@@ -393,16 +393,16 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum
       strcpy(mdb->errmsg, "No Volumes found.\n");
    }
    db_unlock(mdb);
-   return found; 
+   return found;
 }
 
-/* 
- * Get Client Record   
+/*
+ * Get Client Record
  * If the ClientId is non-zero, we get its record,
  *  otherwise, we search on the Name
  *
  * Returns: 0 on failure
- *         id on success 
+ *         id on success
  */
 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
 {
@@ -432,7 +432,7 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
       }
       memcpy(cr, &lcr, len);
       stat = lcr.ClientId;
-      Dmsg2(200, "Found Client record: ClientId=%d Name=%s\n", 
+      Dmsg2(200, "Found Client record: ClientId=%d Name=%s\n",
            lcr.ClientId, lcr.Name);
       break;
    }
@@ -443,13 +443,13 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
    return stat;
 }
 
-/* 
+/*
  * Get FileSet Record  (We read the FILESET_DBR structure)
  * If the FileSetId is non-zero, we get its record,
  *  otherwise, we search on the FileSet (its name).
  *
  * Returns: 0 on failure
- *         id on success 
+ *         id on success
  */
 int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
 {
@@ -479,7 +479,7 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
       /* Found desired record, now return it */
       memcpy(fsr, &lfsr, sizeof(lfsr));
       stat = fsr->FileSetId;
-      Dmsg2(200, "Found FileSet record: FileSetId=%d FileSet=%s\n", 
+      Dmsg2(200, "Found FileSet record: FileSetId=%d FileSet=%s\n",
            lfsr.FileSetId, lfsr.FileSet);
       break;
    }
index 49fa0f39b7108a524c63094fa9d200b23da3f9bb..82238c77da482d45c3d9511e9efb90b466d49f53 100644 (file)
@@ -7,8 +7,8 @@
  *  The purpose of these routines is to ensure that Bacula
  *  can limp along if no real database is loaded on the
  *  system.
- *   
- *    Kern Sibbald, January MMI 
+ *
+ *    Kern Sibbald, January MMI
  *
  *    Version $Id$
  */
  * -----------------------------------------------------------------------
  */
 
-/* 
+/*
  * Submit general SQL query
  */
-int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, 
+int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
                      void *ctx, int verbose)
 {
    sendit(ctx, "SQL Queries not implemented with internal database.\n");
@@ -84,7 +84,7 @@ void db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ct
    fseek(mdb->poolfd, 0L, SEEK_SET);   /* rewind file */
    len = sizeof(pr);
    while (fread(&pr, len, 1, mdb->poolfd) > 0) {
-         Mmsg(mdb->cmd, " %7d  %6d  %6d  %-10s %s\n",
+        Mmsg(mdb->cmd, " %7d  %6d  %6d  %-10s %s\n",
            pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name);
         sendit(ctx, mdb->cmd);
    }
@@ -98,7 +98,7 @@ void db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ct
 /*
  * List Media records
  */
-void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, 
+void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
                           DB_LIST_HANDLER *sendit, void *ctx)
 {
    char ewc[30];
@@ -115,7 +115,7 @@ void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
    fseek(mdb->mediafd, 0L, SEEK_SET);  /* rewind file */
    len = sizeof(mr);
    while (fread(&mr, len, 1, mdb->mediafd) > 0) {
-         Mmsg(mdb->cmd, " %-10s %17s %-15s  %s\n",
+        Mmsg(mdb->cmd, " %-10s %17s %-15s  %s\n",
            mr.VolStatus, edit_uint64_with_commas(mr.VolBytes, ewc),
            mr.MediaType, mr.VolumeName);
         sendit(ctx, mdb->cmd);
@@ -125,7 +125,7 @@ void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
    return;
 }
 
-void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, 
+void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
                              DB_LIST_HANDLER *sendit, void *ctx)
 {
    JOBMEDIA_DBR jm;
@@ -154,7 +154,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
            fseek(mdb->mediafd, 0L, SEEK_SET);
            while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) {
               if (mr.MediaId == jm.MediaId) {
-                  Mmsg(mdb->cmd, " %7d  %-10s %10d %10d\n",
+                 Mmsg(mdb->cmd, " %7d  %-10s %10d %10d\n",
                       jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
                  sendit(ctx, mdb->cmd);
                  break;
@@ -166,7 +166,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
         fseek(mdb->mediafd, 0L, SEEK_SET);
         while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) {
            if (mr.MediaId == jm.MediaId) {
-               Mmsg(mdb->cmd, " %7d  %-10s %10d %10d\n",
+              Mmsg(mdb->cmd, " %7d  %-10s %10d %10d\n",
                    jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
               sendit(ctx, mdb->cmd);
               break;
@@ -184,7 +184,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
 /*
  * List Job records
  */
-void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, 
+void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
                         DB_LIST_HANDLER *sendit, void *ctx)
 {
    int jrlen;
@@ -200,7 +200,7 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
       return;
    }
    fseek(mdb->jobfd, 0L, SEEK_SET);   /* rewind file */
-   /* 
+   /*
     * Linear search through Job records
     */
    sendit(ctx, "   JobId   StartTime   Type Level         Bytes      Files Stat JobName\n");
@@ -216,9 +216,9 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
       }
       localtime_r(&ojr.StartTime, &tm);
       strftime(dt, sizeof(dt), "%m-%d %H:%M", &tm);
-      Mmsg(mdb->cmd, " %7d  %-10s   %c    %c   %14s %10s  %c  %s\n", 
-               ojr.JobId, dt, (char)ojr.JobType, (char)ojr.JobLevel, 
-               edit_uint64_with_commas(ojr.JobBytes, ewc1), 
+      Mmsg(mdb->cmd, " %7d  %-10s   %c    %c   %14s %10s  %c  %s\n",
+               ojr.JobId, dt, (char)ojr.JobType, (char)ojr.JobLevel,
+               edit_uint64_with_commas(ojr.JobBytes, ewc1),
                edit_uint64_with_commas(ojr.JobFiles, ewc2),
                (char)ojr.JobStatus, ojr.Name);
       sendit(ctx, mdb->cmd);
@@ -232,7 +232,7 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
 /*
  * List Job Totals
  */
-void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, 
+void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
                        DB_LIST_HANDLER *sendit, void *ctx)
 {
    char ewc1[30], ewc2[30], ewc3[30];
@@ -248,7 +248,7 @@ void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
       return;
    }
    fseek(mdb->jobfd, 0L, SEEK_SET);   /* rewind file */
-   /* 
+   /*
     * Linear search through JobStart records
     */
    sendit(ctx, "   NumJobs   NumFiles          NumBytes\n");
@@ -259,9 +259,9 @@ void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
       total_bytes += ojr.JobBytes;
       total_jobs++;
    }
-   Mmsg(mdb->cmd, " %7s  %10s   %15s\n", 
+   Mmsg(mdb->cmd, " %7s  %10s   %15s\n",
             edit_uint64_with_commas(total_jobs, ewc1),
-            edit_uint64_with_commas(total_files, ewc2), 
+            edit_uint64_with_commas(total_files, ewc2),
             edit_uint64_with_commas(total_bytes, ewc3));
    sendit(ctx, mdb->cmd);
    sendit(ctx, "=======================================\n");
@@ -277,27 +277,27 @@ void db_list_files_for_job(JCR *jcr, B_DB *mdb, uint32_t jobid, DB_LIST_HANDLER
 void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx)
 { }
 
-int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, 
+int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
                      void *ctx, int verbose, e_list_type type)
 {
    return 0;
 }
 
 void
-db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) 
+db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
 { }
 
 void
-db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, 
+db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
                      DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
 { }
 
-void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, 
+void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
                              DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
 { }
 
 void
-db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, 
+db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit,
                    void *ctx, e_list_type type)
 { }
 
index 37286135433efdd97fa0cf88ae75df2f1a36844c..bea9cc8bec097a7c8fdfcee7e4c5a4f65651ece4 100755 (executable)
@@ -7,8 +7,8 @@
  *  The purpose of these routines is to ensure that Bacula
  *  can limp along if no real database is loaded on the
  *  system.
- *   
- *    Kern Sibbald, January MMI 
+ *
+ *    Kern Sibbald, January MMI
  *
  *
  *    Version $Id$
@@ -61,7 +61,7 @@
  * most current start fields to the job record.
  * It is assumed that you did a db_create_job_record() already.
  */
-bool db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)    
+bool db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 {
    int len, stat = 1;
    JOB_DBR ojr;
@@ -93,7 +93,7 @@ bool db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
  * This is called at Job termination time to add all the
  * other fields to the job record.
  */
-int db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)   
+int db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 {
    int len, stat = 1;
    JOB_DBR ojr;
@@ -121,12 +121,12 @@ int db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 }
 
 
-int db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) 
-{ 
+int db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
+{
    int stat = 1;
    MEDIA_DBR omr;
    int len;
-       
+
    db_lock(mdb);
    Dmsg0(200, "In db_update_media_record\n");
    mr->MediaId = 0;
@@ -159,12 +159,12 @@ int db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    return stat;
 }
 
-int db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) 
-{ 
+int db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
+{
    int stat = 1;
    POOL_DBR opr;
    int len;
-       
+
    db_lock(mdb);
    Dmsg0(200, "In db_update_pool_record\n");
    len = sizeof(opr);
@@ -178,7 +178,7 @@ int db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
 
    /* Update specific fields */
    opr.NumVols = pr->NumVols;
-   opr.MaxVols = pr->MaxVols; 
+   opr.MaxVols = pr->MaxVols;
    opr.UseOnce = pr->UseOnce;
    opr.UseCatalog = pr->UseCatalog;
    opr.AcceptAnyVolume = pr->AcceptAnyVolume;
@@ -203,7 +203,7 @@ int db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, i
 }
 
 int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId)
-{ 
+{
    return 1;
 }
 
@@ -217,7 +217,7 @@ int db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
    return 0;
 }
 
-int db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) 
+int db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
    return 1;
 }
index 62125549c7b6260002b929ffea8a8fdcffe25acc..4b98d9094b08e5b6cfed74505d63577335a53de6 100644 (file)
@@ -113,8 +113,8 @@ typedef struct s_db {
 } B_DB;
 
 
-/* 
- * "Generic" names for easier conversion   
+/*
+ * "Generic" names for easier conversion
  *
  *                    S Q L I T E
  */
@@ -122,7 +122,7 @@ typedef struct s_db {
 #define sql_free_result(x)    my_sqlite_free_table(x)
 #define sql_fetch_row(x)      my_sqlite_fetch_row(x)
 #define sql_query(x, y)       my_sqlite_query((x), (y))
-#define sql_close(x)          sqlite_close((x)->db)  
+#define sql_close(x)          sqlite_close((x)->db)
 #define sql_strerror(x)       (x)->sqlite_errmsg?(x)->sqlite_errmsg:"unknown"
 #define sql_num_rows(x)       (x)->nrow
 #define sql_data_seek(x, i)   (x)->row = (i)
@@ -131,7 +131,7 @@ typedef struct s_db {
 #define sql_field_seek(x, y)  my_sqlite_field_seek((x), (y))
 #define sql_fetch_field(x)    my_sqlite_fetch_field(x)
 #define sql_num_fields(x)     ((x)->ncolumn)
-#define SQL_ROW               char**   
+#define SQL_ROW               char**
 
 
 
@@ -195,7 +195,7 @@ typedef struct s_db {
 #define sql_free_result(x)    mysql_free_result((x)->result)
 #define sql_fetch_row(x)      mysql_fetch_row((x)->result)
 #define sql_query(x, y)       mysql_query((x)->db, (y))
-#define sql_close(x)          mysql_close((x)->db)  
+#define sql_close(x)          mysql_close((x)->db)
 #define sql_strerror(x)       mysql_error((x)->db)
 #define sql_num_rows(x)       mysql_num_rows((x)->result)
 #define sql_data_seek(x, i)   mysql_data_seek((x)->result, (i))
@@ -221,10 +221,10 @@ typedef struct s_db {
 
 typedef char **POSTGRESQL_ROW;
 typedef struct pg_field {
-        char         *name;
-        int           max_length;
-        unsigned int  type;
-        unsigned int  flags;       // 1 == not null
+       char         *name;
+       int           max_length;
+       unsigned int  type;
+       unsigned int  flags;       // 1 == not null
 } POSTGRESQL_FIELD;
 
 
@@ -285,7 +285,7 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb);
 #define sql_free_result(x)    my_postgresql_free_result(x)
 #define sql_fetch_row(x)      my_postgresql_fetch_row(x)
 #define sql_query(x, y)       my_postgresql_query((x), (y))
-#define sql_close(x)          PQfinish((x)->db)  
+#define sql_close(x)          PQfinish((x)->db)
 #define sql_strerror(x)       PQresultErrorMessage((x)->result)
 #define sql_num_rows(x)       ((unsigned) PQntuples((x)->result))
 #define sql_data_seek(x, i)   my_postgresql_data_seek((x), (i))
@@ -357,9 +357,9 @@ typedef struct s_db {
 
 /* This is a "dummy" definition for use outside of sql.c
  */
-typedef struct s_db {     
+typedef struct s_db {
    int dummy;                         /* for SunOS compiler */
-} B_DB;  
+} B_DB;
 
 #endif /*  __SQL_C */
 
@@ -371,7 +371,7 @@ extern uint32_t bacula_db_version;
 typedef uint32_t FileId_t;
 typedef uint32_t DBId_t;              /* general DB id type */
 typedef uint32_t JobId_t;
-      
+
 #define faddr_t long
 
 
@@ -439,7 +439,7 @@ struct JOBMEDIA_DBR {
 /* Volume Parameter structure */
 struct VOL_PARAMS {
    char VolumeName[MAX_NAME_LENGTH];  /* Volume name */
-   uint32_t VolIndex;                 /* Volume seqence no. */ 
+   uint32_t VolIndex;                 /* Volume seqence no. */
    uint32_t FirstIndex;               /* First index this Volume */
    uint32_t LastIndex;                /* Last index this Volume */
    uint32_t StartFile;                /* File for start of data */
@@ -497,7 +497,7 @@ struct POOL_DBR {
    uint32_t MaxVolJobs;               /* Max Jobs on Volume */
    uint32_t MaxVolFiles;              /* Max files on Volume */
    uint64_t MaxVolBytes;              /* Max bytes on Volume */
-   char PoolType[MAX_NAME_LENGTH];             
+   char PoolType[MAX_NAME_LENGTH];
    char LabelFormat[MAX_NAME_LENGTH];
    /* Extra stuff not in DB */
    faddr_t rec_addr;
@@ -584,7 +584,7 @@ struct FILESET_DBR {
 #include "jcr.h"
 
 /*
- * Some functions exported by sql.c for use withing the 
+ * Some functions exported by sql.c for use withing the
  *   cats directory.
  */
 void list_result(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type type);
@@ -593,5 +593,5 @@ int get_sql_record_max(JCR *jcr, B_DB *mdb);
 int check_tables_version(JCR *jcr, B_DB *mdb);
 void _db_unlock(const char *file, int line, B_DB *mdb);
 void _db_lock(const char *file, int line, B_DB *mdb);
+
 #endif /* __SQL_H_ */
index 1fc4d8aba22f66b9a7671aab41c191d07b79e7a9..a8cd052bbd89dcded1e2ee4d802da5a407e16770 100644 (file)
@@ -56,13 +56,13 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  * never have errors, or it is really fatal.
  */
 B_DB *
-db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, 
+db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
                 const char *db_address, int db_port, const char *db_socket,
                 int mult_db_connections)
 {
    B_DB *mdb;
 
-   if (!db_user) {             
+   if (!db_user) {
       Jmsg(jcr, M_FATAL, 0, _("A user name for MySQL must be supplied.\n"));
       return NULL;
    }
@@ -71,7 +71,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char
    if (!mult_db_connections) {
       for (mdb=NULL; (mdb=(B_DB *)qnext(&db_list, &mdb->bq)); ) {
         if (strcmp(mdb->db_name, db_name) == 0) {
-            Dmsg2(100, "DB REopen %d %s\n", mdb->ref_count, db_name);
+           Dmsg2(100, "DB REopen %d %s\n", mdb->ref_count, db_name);
            mdb->ref_count++;
            V(mutex);
            return mdb;                  /* already open */
@@ -127,7 +127,7 @@ db_open_database(JCR *jcr, B_DB *mdb)
    mdb->connected = FALSE;
 
    if ((errstat=rwl_init(&mdb->lock)) != 0) {
-      Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), 
+      Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"),
            strerror(errstat));
       V(mutex);
       return 0;
@@ -157,15 +157,15 @@ db_open_database(JCR *jcr, B_DB *mdb)
       }
       bmicrosleep(5,0);
    }
-    
+
    Dmsg0(50, "mysql_real_connect done\n");
-   Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name, 
-            mdb->db_password==NULL?"(NULL)":mdb->db_password);
-  
+   Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name,
+           mdb->db_password==NULL?"(NULL)":mdb->db_password);
+
    if (mdb->db == NULL) {
-      Mmsg2(&mdb->errmsg, _("Unable to connect to MySQL server. \n\
-Database=%s User=%s\n\
-It is probably not running or your password is incorrect.\n"), 
+      Mmsg2(&mdb->errmsg, _("Unable to connect to MySQL server. \n"
+"Database=%s User=%s\n"
+"It is probably not running or your password is incorrect.\n"),
         mdb->db_name, mdb->db_user);
       V(mutex);
       return 0;
@@ -204,7 +204,7 @@ db_close_database(JCR *jcr, B_DB *mdb)
         mysql_server_end();
 #endif
       }
-      rwl_destroy(&mdb->lock);      
+      rwl_destroy(&mdb->lock);
       free_pool_memory(mdb->errmsg);
       free_pool_memory(mdb->cmd);
       free_pool_memory(mdb->cached_path);
@@ -234,7 +234,7 @@ db_close_database(JCR *jcr, B_DB *mdb)
 /*
  * Return the next unique index (auto-increment) for
  * the given table.  Return NULL on error.
- *  
+ *
  * For MySQL, NULL causes the auto-increment value
  *  to be updated.
  */
@@ -242,7 +242,7 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index)
 {
    strcpy(index, "NULL");
    return 1;
-}   
+}
 
 
 /*
@@ -269,38 +269,38 @@ unsigned long mysql_real_escape_string(MYSQL *mysql, char *to, const char *from,
    while (len--) {
       switch (*o) {
       case 0:
-         *n++= '\\';
-         *n++= '0';
+        *n++= '\\';
+        *n++= '0';
         o++;
         break;
       case '\n':
-         *n++= '\\';
-         *n++= 'n';
+        *n++= '\\';
+        *n++= 'n';
         o++;
         break;
       case '\r':
-         *n++= '\\';
-         *n++= 'r';
+        *n++= '\\';
+        *n++= 'r';
         o++;
         break;
       case '\\':
-         *n++= '\\';
-         *n++= '\\';
+        *n++= '\\';
+        *n++= '\\';
         o++;
         break;
       case '\'':
-         *n++= '\\';
-         *n++= '\'';
+        *n++= '\\';
+        *n++= '\'';
         o++;
         break;
       case '"':
-         *n++= '\\';
-         *n++= '"';
+        *n++= '\\';
+        *n++= '"';
         o++;
         break;
       case '\032':
-         *n++= '\\';
-         *n++= 'Z';
+        *n++= '\\';
+        *n++= 'Z';
         o++;
         break;
       default:
@@ -318,7 +318,7 @@ unsigned long mysql_real_escape_string(MYSQL *mysql, char *to, const char *from,
 int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
 {
    SQL_ROW row;
-  
+
    db_lock(mdb);
    if (sql_query(mdb, query) != 0) {
       Mmsg(mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb));
index 270d1b14eb9e3c43d3c95ec9fea94aad8ae3b0d5..19d730a33a85b2034d10aa6006f684658b4ec45c 100644 (file)
@@ -58,13 +58,13 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  * never have errors, or it is really fatal.
  */
 B_DB *
-db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, 
-                const char *db_address, int db_port, const char *db_socket, 
+db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
+                const char *db_address, int db_port, const char *db_socket,
                 int mult_db_connections)
 {
    B_DB *mdb;
 
-   if (!db_user) {             
+   if (!db_user) {
       Jmsg(jcr, M_FATAL, 0, _("A user name for PostgreSQL must be supplied.\n"));
       return NULL;
    }
@@ -73,7 +73,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char
       /* Look to see if DB already open */
       for (mdb=NULL; (mdb=(B_DB *)qnext(&db_list, &mdb->bq)); ) {
         if (strcmp(mdb->db_name, db_name) == 0) {
-            Dmsg2(100, "DB REopen %d %s\n", mdb->ref_count, db_name);
+           Dmsg2(100, "DB REopen %d %s\n", mdb->ref_count, db_name);
            mdb->ref_count++;
            V(mutex);
            return mdb;                  /* already open */
@@ -131,7 +131,7 @@ db_open_database(JCR *jcr, B_DB *mdb)
    mdb->connected = false;
 
    if ((errstat=rwl_init(&mdb->lock)) != 0) {
-      Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), 
+      Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"),
            strerror(errstat));
       V(mutex);
       return 0;
@@ -158,19 +158,19 @@ db_open_database(JCR *jcr, B_DB *mdb)
 
       /* If no connect, try once more in case it is a timing problem */
       if (PQstatus(mdb->db) == CONNECTION_OK) {
-        break;   
+        break;
       }
       bmicrosleep(5, 0);
    }
 
    Dmsg0(50, "pg_real_connect done\n");
-   Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name, 
-            mdb->db_password==NULL?"(NULL)":mdb->db_password);
-  
+   Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name,
+           mdb->db_password==NULL?"(NULL)":mdb->db_password);
+
    if (PQstatus(mdb->db) != CONNECTION_OK) {
       Mmsg2(&mdb->errmsg, _("Unable to connect to PostgreSQL server.\n"
-            "Database=%s User=%s\n"
-            "It is probably not running or your password is incorrect.\n"),
+           "Database=%s User=%s\n"
+           "It is probably not running or your password is incorrect.\n"),
             mdb->db_name, mdb->db_user);
       V(mutex);
       return 0;
@@ -199,7 +199,7 @@ db_close_database(JCR *jcr, B_DB *mdb)
       if (mdb->connected && mdb->db) {
         sql_close(mdb);
       }
-      rwl_destroy(&mdb->lock);      
+      rwl_destroy(&mdb->lock);
       free_pool_memory(mdb->errmsg);
       free_pool_memory(mdb->cmd);
       free_pool_memory(mdb->cached_path);
@@ -221,7 +221,7 @@ db_close_database(JCR *jcr, B_DB *mdb)
       if (mdb->db_socket) {
         free(mdb->db_socket);
       }
-      my_postgresql_free_result(mdb);      
+      my_postgresql_free_result(mdb);
       free(mdb);
    }
    V(mutex);
@@ -230,7 +230,7 @@ db_close_database(JCR *jcr, B_DB *mdb)
 /*
  * Return the next unique index (auto-increment) for
  * the given table.  Return NULL on error.
- *  
+ *
  * For PostgreSQL, NULL causes the auto-increment value
  *  to be updated.
  */
@@ -238,7 +238,7 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index)
 {
    strcpy(index, "NULL");
    return 1;
-}   
+}
 
 
 /*
@@ -263,7 +263,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler
    SQL_ROW row;
 
    Dmsg0(500, "db_sql_query started\n");
-  
+
    db_lock(mdb);
    if (sql_query(mdb, query) != 0) {
       Mmsg(mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb));
@@ -278,10 +278,10 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler
       if ((mdb->result = sql_store_result(mdb)) != NULL) {
         int num_fields = sql_num_fields(mdb);
 
-         Dmsg0(500, "db_sql_query sql_store_result suceeded\n");
+        Dmsg0(500, "db_sql_query sql_store_result suceeded\n");
         while ((row = sql_fetch_row(mdb)) != NULL) {
 
-            Dmsg0(500, "db_sql_query sql_fetch_row worked\n");
+           Dmsg0(500, "db_sql_query sql_fetch_row worked\n");
            if (result_handler(ctx, num_fields, row))
               break;
         }
@@ -298,7 +298,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler
 
 
 
-POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb) 
+POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb)
 {
    int j;
    POSTGRESQL_ROW row = NULL; // by default, return NULL
@@ -309,7 +309,7 @@ POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb)
       Dmsg1(500, "we have need space of %d bytes\n", sizeof(char *) * mdb->num_fields);
 
       if (mdb->row != NULL) {
-         Dmsg0(500, "my_postgresql_fetch_row freeing space\n");
+        Dmsg0(500, "my_postgresql_fetch_row freeing space\n");
         free(mdb->row);
         mdb->row = NULL;
       }
@@ -326,7 +326,7 @@ POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb)
       // get each value from this row
       for (j = 0; j < mdb->num_fields; j++) {
         mdb->row[j] = PQgetvalue(mdb->result, mdb->row_number, j);
-         Dmsg2(500, "my_postgresql_fetch_row field '%d' has value '%s'\n", j, mdb->row[j]);
+        Dmsg2(500, "my_postgresql_fetch_row field '%d' has value '%s'\n", j, mdb->row[j]);
       }
       // increment the row number for the next call
       mdb->row_number++;
@@ -352,11 +352,11 @@ int my_postgresql_max_length(B_DB *mdb, int field_num) {
    max_length = 0;
    for (i = 0; i < mdb->num_rows; i++) {
       if (PQgetisnull(mdb->result, i, field_num)) {
-          this_length = 4;        // "NULL"
+         this_length = 4;        // "NULL"
       } else {
          this_length = strlen(PQgetvalue(mdb->result, i, field_num));
       }
-                     
+
       if (max_length < this_length) {
          max_length = this_length;
       }
@@ -365,7 +365,7 @@ int my_postgresql_max_length(B_DB *mdb, int field_num) {
    return max_length;
 }
 
-POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb) 
+POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb)
 {
    int    i;
 
@@ -375,13 +375,13 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb)
       mdb->fields = (POSTGRESQL_FIELD *)malloc(sizeof(POSTGRESQL_FIELD) * mdb->num_fields);
 
       for (i = 0; i < mdb->num_fields; i++) {
-         Dmsg1(500, "filling field %d\n", i);
+        Dmsg1(500, "filling field %d\n", i);
         mdb->fields[i].name           = PQfname(mdb->result, i);
         mdb->fields[i].max_length = my_postgresql_max_length(mdb, i);
         mdb->fields[i].type       = PQftype(mdb->result, i);
         mdb->fields[i].flags      = 0;
 
-         Dmsg4(500, "my_postgresql_fetch_field finds field '%s' has length='%d' type='%d' and IsNull=%d\n", 
+        Dmsg4(500, "my_postgresql_fetch_field finds field '%s' has length='%d' type='%d' and IsNull=%d\n",
            mdb->fields[i].name, mdb->fields[i].max_length, mdb->fields[i].type,
            mdb->fields[i].flags);
       } // end for
@@ -393,7 +393,7 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb)
    return &mdb->fields[mdb->field_number++];
 }
 
-void my_postgresql_data_seek(B_DB *mdb, int row) 
+void my_postgresql_data_seek(B_DB *mdb, int row)
 {
    // set the row number to be returned on the next call
    // to my_postgresql_fetch_row
@@ -444,7 +444,7 @@ int my_postgresql_query(B_DB *mdb, const char *query) {
    return mdb->status;
 }
 
-void my_postgresql_free_result (B_DB *mdb) 
+void my_postgresql_free_result (B_DB *mdb)
 {
    if (mdb->result) {
       PQclear(mdb->result);
@@ -462,7 +462,7 @@ void my_postgresql_free_result (B_DB *mdb)
    }
 }
 
-int my_postgresql_currval(B_DB *mdb, char *table_name) 
+int my_postgresql_currval(B_DB *mdb, char *table_name)
 {
    // Obtain the current value of the sequence that
    // provides the serial value for primary key of the table.
index 6fe707657a629d4b1531da63ab0057e45d166341..4c049ce99f01cca7d2d47c279e487ba7588df911 100644 (file)
@@ -33,8 +33,8 @@
 /* Database prototypes */
 
 /* sql.c */
-B_DB *db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, 
-                      const char *db_address, int db_port, const char *db_socket, 
+B_DB *db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
+                      const char *db_address, int db_port, const char *db_socket,
                       int mult_db_connections);
 int  db_open_database(JCR *jcr, B_DB *db);
 void db_close_database(JCR *jcr, B_DB *db);
@@ -52,7 +52,7 @@ int db_create_job_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
 int db_create_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *media_dbr);
 int db_create_client_record(JCR *jcr, B_DB *db, CLIENT_DBR *cr);
 int db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr);
-int db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);         
+int db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
 bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jr);
 int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
 
@@ -106,7 +106,7 @@ int  db_update_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pr);
 int  db_update_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *mr);
 int  db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
 int  db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
-int  db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, int type);  
+int  db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, int type);
 int  db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId);
 void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
 
index 75b8e94333032cdb01ae3e8812e695d90f7db05f..a4c1872a70bafd668117f099ce1102e5b351d817 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Bacula Catalog Database interface routines
- * 
+ *
  *     Almost generic set of SQL database interface routines
  *     (with a little more work)
  *
@@ -64,7 +64,7 @@ static int int_handler(void *ctx, int num_fields, char **row)
    Dmsg0(800, "int_handler finishes\n");
    return 0;
 }
-       
+
 
 
 /* NOTE!!! The following routines expect that the
@@ -75,7 +75,7 @@ static int int_handler(void *ctx, int num_fields, char **row)
 int check_tables_version(JCR *jcr, B_DB *mdb)
 {
    const char *query = "SELECT VersionId FROM Version";
-  
+
    bacula_db_version = 0;
    db_sql_query(mdb, query, int_handler, (void *)&bacula_db_version);
    if (bacula_db_version != BDB_VERSION) {
@@ -96,7 +96,7 @@ QueryDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
       m_msg(file, line, &mdb->errmsg, _("query %s failed:\n%s\n"), cmd, sql_strerror(mdb));
       j_msg(file, line, jcr, M_FATAL, 0, "%s", mdb->errmsg);
       if (verbose) {
-         j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
+        j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
       }
       return 0;
    }
@@ -106,9 +106,9 @@ QueryDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
    return mdb->result != NULL;
 }
 
-/* 
- * Utility routine to do inserts   
- * Returns: 0 on failure      
+/*
+ * Utility routine to do inserts
+ * Returns: 0 on failure
  *         1 on success
  */
 int
@@ -118,7 +118,7 @@ InsertDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
       m_msg(file, line, &mdb->errmsg,  _("insert %s failed:\n%s\n"), cmd, sql_strerror(mdb));
       j_msg(file, line, jcr, M_FATAL, 0, "%s", mdb->errmsg);
       if (verbose) {
-         j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
+        j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
       }
       return 0;
    }
@@ -129,10 +129,10 @@ InsertDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
    }
    if (mdb->num_rows != 1) {
       char ed1[30];
-      m_msg(file, line, &mdb->errmsg, _("Insertion problem: affected_rows=%s\n"), 
+      m_msg(file, line, &mdb->errmsg, _("Insertion problem: affected_rows=%s\n"),
         edit_uint64(mdb->num_rows, ed1));
       if (verbose) {
-         j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
+        j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
       }
       return 0;
    }
@@ -142,7 +142,7 @@ InsertDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
 
 /* Utility routine for updates.
  *  Returns: 0 on failure
- *          1 on success  
+ *          1 on success
  */
 int
 UpdateDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
@@ -152,14 +152,14 @@ UpdateDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
       m_msg(file, line, &mdb->errmsg, _("update %s failed:\n%s\n"), cmd, sql_strerror(mdb));
       j_msg(file, line, jcr, M_ERROR, 0, "%s", mdb->errmsg);
       if (verbose) {
-         j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
+        j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
       }
       return 0;
    }
    mdb->num_rows = sql_affected_rows(mdb);
    if (mdb->num_rows < 1) {
       char ed1[30];
-      m_msg(file, line, &mdb->errmsg, _("Update problem: affected_rows=%s\n"), 
+      m_msg(file, line, &mdb->errmsg, _("Update problem: affected_rows=%s\n"),
         edit_uint64(mdb->num_rows, ed1));
       if (verbose) {
 //       j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
@@ -170,7 +170,7 @@ UpdateDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
    return 1;
 }
 
-/* Utility routine for deletes  
+/* Utility routine for deletes
  *
  * Returns: -1 on error
  *          n number of rows affected
@@ -183,7 +183,7 @@ DeleteDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
       m_msg(file, line, &mdb->errmsg, _("delete %s failed:\n%s\n"), cmd, sql_strerror(mdb));
       j_msg(file, line, jcr, M_ERROR, 0, "%s", mdb->errmsg);
       if (verbose) {
-         j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
+        j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd);
       }
       return -1;
    }
@@ -206,7 +206,7 @@ int get_sql_record_max(JCR *jcr, B_DB *mdb)
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       if ((row = sql_fetch_row(mdb)) == NULL) {
-         Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
+        Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
         stat = -1;
       } else {
         stat = atoi(row[0]);
@@ -240,7 +240,7 @@ void _db_lock(const char *file, int line, B_DB *mdb)
       e_msg(file, line, M_ABORT, 0, "rwl_writelock failure. ERR=%s\n",
           be.strerror(errstat));
    }
-}    
+}
 
 /*
  * Unlock the database. This can be called multiple times by the
@@ -255,11 +255,11 @@ void _db_unlock(const char *file, int line, B_DB *mdb)
       e_msg(file, line, M_ABORT, 0, "rwl_writeunlock failure. ERR=%s\n",
           be.strerror(errstat));
    }
-}    
+}
 
 /*
  * Start a transaction. This groups inserts and makes things
- *  much more efficient. Usually started when inserting 
+ *  much more efficient. Usually started when inserting
  *  file attributes.
  */
 void db_start_transaction(JCR *jcr, B_DB *mdb)
@@ -273,7 +273,7 @@ void db_start_transaction(JCR *jcr, B_DB *mdb)
    if (mdb->transaction && mdb->changes > 10000) {
       db_end_transaction(jcr, mdb);
    }
-   if (!mdb->transaction) {   
+   if (!mdb->transaction) {
       my_sqlite_query(mdb, "BEGIN");  /* begin transaction */
       Dmsg0(400, "Start SQLite transaction\n");
       mdb->transaction = 1;
@@ -283,7 +283,7 @@ void db_start_transaction(JCR *jcr, B_DB *mdb)
 
 /*
  * This is turned off because transactions break
- * if multiple simultaneous jobs are run.    
+ * if multiple simultaneous jobs are run.
  */
 #ifdef HAVE_POSTGRESQL
    if (!mdb->allow_transactions) {
@@ -294,7 +294,7 @@ void db_start_transaction(JCR *jcr, B_DB *mdb)
    if (mdb->transaction && mdb->changes > 25000) {
       db_end_transaction(jcr, mdb);
    }
-   if (!mdb->transaction) {   
+   if (!mdb->transaction) {
       db_sql_query(mdb, "BEGIN", NULL, NULL);  /* begin transaction */
       Dmsg0(400, "Start PosgreSQL transaction\n");
       mdb->transaction = 1;
@@ -306,7 +306,7 @@ void db_start_transaction(JCR *jcr, B_DB *mdb)
 void db_end_transaction(JCR *jcr, B_DB *mdb)
 {
    /*
-    * This can be called during thread cleanup and 
+    * This can be called during thread cleanup and
     *  the db may already be closed.  So simply return.
     */
    if (!mdb) {
@@ -350,7 +350,7 @@ void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname)
 {
    const char *p, *f;
 
-   /* Find path without the filename.  
+   /* Find path without the filename.
     * I.e. everything after the last / is a "filename".
     * OK, maybe it is a directory name, but we treat it like
     * a filename. If we don't find a / then the whole name
@@ -368,7 +368,7 @@ void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname)
    }
 
    /* If filename doesn't exist (i.e. root directory), we
-    * simply create a blank name consisting of a single 
+    * simply create a blank name consisting of a single
     * space. This makes handling zero length filenames
     * easier.
     */
@@ -382,7 +382,7 @@ void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname)
       mdb->fnl = 0;
    }
 
-   mdb->pnl = f - fname;    
+   mdb->pnl = f - fname;
    if (mdb->pnl > 0) {
       mdb->path = check_pool_memory_size(mdb->path, mdb->pnl+1);
       memcpy(mdb->path, fname, mdb->pnl);
@@ -411,7 +411,7 @@ list_dashes(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx)
    for (i = 0; i < sql_num_fields(mdb); i++) {
       field = sql_fetch_field(mdb);
       for (j = 0; j < (int)field->max_length + 2; j++) {
-         send(ctx, "-");
+        send(ctx, "-");
       }
       send(ctx, "+");
    }
@@ -419,8 +419,8 @@ list_dashes(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx)
 }
 
 /*
- * If full_list is set, we list vertically, otherwise, we 
- * list on one line horizontally.      
+ * If full_list is set, we list vertically, otherwise, we
+ * list on one line horizontally.
  */
 void
 list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type type)
@@ -455,7 +455,7 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t
            col_len = field->max_length;
         }
         if (col_len < 4 && !IS_NOT_NULL(field->flags)) {
-            col_len = 4;                 /* 4 = length of the word "NULL" */
+           col_len = 4;                 /* 4 = length of the word "NULL" */
         }
         field->max_length = col_len;    /* reset column info */
       }
@@ -486,12 +486,12 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t
       for (i = 0; i < sql_num_fields(mdb); i++) {
         field = sql_fetch_field(mdb);
         if (row[i] == NULL) {
-            bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, "NULL");
+           bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, "NULL");
         } else if (IS_NUM(field->type) && !jcr->gui && is_an_integer(row[i])) {
-            bsnprintf(buf, sizeof(buf), " %*s |", (int)field->max_length,       
+           bsnprintf(buf, sizeof(buf), " %*s |", (int)field->max_length,
                      add_commas(row[i], ewc));
         } else {
-            bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, row[i]);
+           bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, row[i]);
         }
         send(ctx, buf);
       }
@@ -501,19 +501,19 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t
    return;
 
 vertical_list:
-   
+
    Dmsg1(800, "list_result starts vertical list at %d fields\n", sql_num_fields(mdb));
    while ((row = sql_fetch_row(mdb)) != NULL) {
       sql_field_seek(mdb, 0);
       for (i = 0; i < sql_num_fields(mdb); i++) {
         field = sql_fetch_field(mdb);
         if (row[i] == NULL) {
-            bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, "NULL");
+           bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, "NULL");
         } else if (IS_NUM(field->type) && !jcr->gui && is_an_integer(row[i])) {
-            bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, 
+           bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name,
                add_commas(row[i], ewc));
         } else {
-            bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, row[i]);
+           bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, row[i]);
         }
         send(ctx, buf);
       }
index 03c7d9f81a20600c046b985ec4462a2cb1a0f82d..147538484a9d333fb92daa699b8818ad27473a4a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Bacula Catalog Database Create record interface routines
- * 
+ *
  *    Kern Sibbald, March 2000
  *
  *    Version $Id$
@@ -77,19 +77,19 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    stime = jr->SchedTime;
    ASSERT(stime != 0);
 
-   localtime_r(&stime, &tm); 
+   localtime_r(&stime, &tm);
    strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
    JobTDate = (utime_t)stime;
 
    /* Must create it */
    Mmsg(mdb->cmd,
-"INSERT INTO Job (Job,Name,Type,Level,JobStatus,SchedTime,JobTDate) VALUES \
-('%s','%s','%c','%c','%c','%s',%s)", 
-          jr->Job, jr->Name, (char)(jr->JobType), (char)(jr->JobLevel), 
+"INSERT INTO Job (Job,Name,Type,Level,JobStatus,SchedTime,JobTDate) VALUES "
+"('%s','%s','%c','%c','%c','%s',%s)",
+          jr->Job, jr->Name, (char)(jr->JobType), (char)(jr->JobLevel),
           (char)(jr->JobStatus), dt, edit_uint64(JobTDate, ed1));
 
    if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
-      Mmsg2(&mdb->errmsg, _("Create DB Job record %s failed. ERR=%s\n"), 
+      Mmsg2(&mdb->errmsg, _("Create DB Job record %s failed. ERR=%s\n"),
            mdb->cmd, sql_strerror(mdb));
       jr->JobId = 0;
       stat = 0;
@@ -101,7 +101,7 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    return stat;
 }
 
-/* Create a JobMedia record for medium used this job   
+/* Create a JobMedia record for medium used this job
  * Returns: false on failure
  *         true  on success
  */
@@ -121,25 +121,25 @@ db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm)
    }
    count++;
 
-   Mmsg(mdb->cmd, 
-        "INSERT INTO JobMedia (JobId,MediaId,FirstIndex,LastIndex,"
-        "StartFile,EndFile,StartBlock,EndBlock,VolIndex) "
-        "VALUES (%u,%u,%u,%u,%u,%u,%u,%u,%u)",
+   Mmsg(mdb->cmd,
+       "INSERT INTO JobMedia (JobId,MediaId,FirstIndex,LastIndex,"
+       "StartFile,EndFile,StartBlock,EndBlock,VolIndex) "
+       "VALUES (%u,%u,%u,%u,%u,%u,%u,%u,%u)",
        jm->JobId, jm->MediaId, jm->FirstIndex, jm->LastIndex,
        jm->StartFile, jm->EndFile, jm->StartBlock, jm->EndBlock,count);
 
    Dmsg0(300, mdb->cmd);
    if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
-      Mmsg2(&mdb->errmsg, _("Create JobMedia record %s failed: ERR=%s\n"), mdb->cmd, 
+      Mmsg2(&mdb->errmsg, _("Create JobMedia record %s failed: ERR=%s\n"), mdb->cmd,
         sql_strerror(mdb));
       ok = false;
    } else {
       /* Worked, now update the Media record with the EndFile and EndBlock */
-      Mmsg(mdb->cmd, 
-           "UPDATE Media SET EndFile=%u, EndBlock=%u WHERE MediaId=%u",
+      Mmsg(mdb->cmd,
+          "UPDATE Media SET EndFile=%u, EndBlock=%u WHERE MediaId=%u",
           jm->EndFile, jm->EndBlock, jm->MediaId);
       if (!UPDATE_DB(jcr, mdb, mdb->cmd)) {
-         Mmsg2(&mdb->errmsg, _("Update Media record %s failed: ERR=%s\n"), mdb->cmd, 
+        Mmsg2(&mdb->errmsg, _("Update Media record %s failed: ERR=%s\n"), mdb->cmd,
              sql_strerror(mdb));
         ok = false;
       }
@@ -169,7 +169,7 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 0) {
-         Mmsg1(&mdb->errmsg, _("pool record %s already exists\n"), pr->Name);
+        Mmsg1(&mdb->errmsg, _("pool record %s already exists\n"), pr->Name);
         sql_free_result(mdb);
         db_unlock(mdb);
         return 0;
@@ -178,11 +178,11 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
    }
 
    /* Must create it */
-   Mmsg(mdb->cmd, 
-"INSERT INTO Pool (Name,NumVols,MaxVols,UseOnce,UseCatalog,\
-AcceptAnyVolume,AutoPrune,Recycle,VolRetention,VolUseDuration,\
-MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelFormat) \
-VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s','%s')", 
+   Mmsg(mdb->cmd,
+"INSERT INTO Pool (Name,NumVols,MaxVols,UseOnce,UseCatalog,"
+"AcceptAnyVolume,AutoPrune,Recycle,VolRetention,VolUseDuration,"
+"MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelFormat) "
+"VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s','%s')",
                  pr->Name,
                  pr->NumVols, pr->MaxVols,
                  pr->UseOnce, pr->UseCatalog,
@@ -195,7 +195,7 @@ VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s','%s')",
                  pr->PoolType, pr->LabelFormat);
    Dmsg1(200, "Create Pool: %s\n", mdb->cmd);
    if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
-      Mmsg2(&mdb->errmsg, _("Create db Pool record %s failed: ERR=%s\n"), 
+      Mmsg2(&mdb->errmsg, _("Create db Pool record %s failed: ERR=%s\n"),
            mdb->cmd, sql_strerror(mdb));
       pr->PoolId = 0;
       stat = 0;
@@ -204,17 +204,17 @@ VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s','%s')",
       stat = 1;
    }
    db_unlock(mdb);
-   
+
    return stat;
 }
 
 
-/* 
+/*
  * Create Media record. VolumeName and non-zero Slot must be unique
  *
  * Returns: 0 on failure
  *         1 on success
- */ 
+ */
 int
 db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
@@ -223,14 +223,14 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    struct tm tm;
 
    db_lock(mdb);
-   Mmsg(mdb->cmd, "SELECT MediaId FROM Media WHERE VolumeName='%s'", 
+   Mmsg(mdb->cmd, "SELECT MediaId FROM Media WHERE VolumeName='%s'",
           mr->VolumeName);
    Dmsg1(300, "selectpool: %s\n", mdb->cmd);
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 0) {
-         Mmsg1(&mdb->errmsg, _("Volume \"%s\" already exists.\n"), mr->VolumeName);
+        Mmsg1(&mdb->errmsg, _("Volume \"%s\" already exists.\n"), mr->VolumeName);
         sql_free_result(mdb);
         db_unlock(mdb);
         return 0;
@@ -239,14 +239,14 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    }
 
    /* Must create it */
-   Mmsg(mdb->cmd, 
-"INSERT INTO Media (VolumeName,MediaType,PoolId,MaxVolBytes,VolCapacityBytes," 
+   Mmsg(mdb->cmd,
+"INSERT INTO Media (VolumeName,MediaType,PoolId,MaxVolBytes,VolCapacityBytes,"
 "Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
-"VolStatus,Slot,VolBytes,InChanger,VolReadTime,VolWriteTime," 
+"VolStatus,Slot,VolBytes,InChanger,VolReadTime,VolWriteTime,"
 "EndFile,EndBlock) "
-"VALUES ('%s','%s',%u,%s,%s,%d,%s,%s,%u,%u,'%s',%d,%s,%d,%s,%s,0,0)", 
+"VALUES ('%s','%s',%u,%s,%s,%d,%s,%s,%u,%u,'%s',%d,%s,%d,%s,%s,0,0)",
                  mr->VolumeName,
-                 mr->MediaType, mr->PoolId, 
+                 mr->MediaType, mr->PoolId,
                  edit_uint64(mr->MaxVolBytes,ed1),
                  edit_uint64(mr->VolCapacityBytes, ed2),
                  mr->Recycle,
@@ -273,9 +273,9 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
       if (mr->LabelDate) {
         char dt[MAX_TIME_LENGTH];
         localtime_r(&mr->LabelDate, &tm);
-         strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
-         Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' "
-              "WHERE MediaId=%d", dt, mr->MediaId);
+        strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
+        Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' "
+             "WHERE MediaId=%d", dt, mr->MediaId);
         stat = UPDATE_DB(jcr, mdb, mdb->cmd);
       }
    }
@@ -292,8 +292,8 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 
 
 
-/* 
- * Create a Unique record for the client -- no duplicates 
+/*
+ * Create a Unique record for the client -- no duplicates
  * Returns: 0 on failure
  *         1 on success with id in cr->ClientId
  */
@@ -311,13 +311,13 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
       mdb->num_rows = sql_num_rows(mdb);
       /* If more than one, report error, but return first row */
       if (mdb->num_rows > 1) {
-         Mmsg1(&mdb->errmsg, _("More than one Client!: %d\n"), (int)(mdb->num_rows));
-         Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+        Mmsg1(&mdb->errmsg, _("More than one Client!: %d\n"), (int)(mdb->num_rows));
+        Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
       }
       if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("error fetching Client row: %s\n"), sql_strerror(mdb));
-            Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+           Mmsg1(&mdb->errmsg, _("error fetching Client row: %s\n"), sql_strerror(mdb));
+           Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
            sql_free_result(mdb);
            db_unlock(mdb);
            return 0;
@@ -336,9 +336,9 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
    }
 
    /* Must create it */
-   Mmsg(mdb->cmd, "INSERT INTO Client (Name, Uname, AutoPrune, \
-FileRetention, JobRetention) VALUES \
-('%s', '%s', %d, %s, %s)", cr->Name, cr->Uname, cr->AutoPrune,
+   Mmsg(mdb->cmd, "INSERT INTO Client (Name, Uname, AutoPrune, "
+"FileRetention, JobRetention) VALUES "
+"('%s', '%s', %d, %s, %s)", cr->Name, cr->Uname, cr->AutoPrune,
       edit_uint64(cr->FileRetention, ed1),
       edit_uint64(cr->JobRetention, ed2));
 
@@ -357,8 +357,8 @@ FileRetention, JobRetention) VALUES \
 }
 
 
-/* 
- * Create a Unique record for the counter -- no duplicates 
+/*
+ * Create a Unique record for the counter -- no duplicates
  * Returns: 0 on failure
  *         1 on success with counter filled in
  */
@@ -395,7 +395,7 @@ int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
 }
 
 
-/* 
+/*
  * Create a FileSet record. This record is unique in the
  *  name and the MD5 signature of the include/exclude sets.
  *  Returns: 0 on failure
@@ -416,13 +416,13 @@ int db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 1) {
-         Mmsg1(&mdb->errmsg, _("More than one FileSet!: %d\n"), (int)(mdb->num_rows));
-         Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+        Mmsg1(&mdb->errmsg, _("More than one FileSet!: %d\n"), (int)(mdb->num_rows));
+        Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
       }
       if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("error fetching FileSet row: ERR=%s\n"), sql_strerror(mdb));
-            Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+           Mmsg1(&mdb->errmsg, _("error fetching FileSet row: ERR=%s\n"), sql_strerror(mdb));
+           Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
            sql_free_result(mdb);
            db_unlock(mdb);
            return 0;
@@ -482,17 +482,17 @@ int db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
  *     unsigned long st_blocks;    * number of blocks allocated *
  *     time_t        st_atime;     * time of last access *
  *     time_t        st_mtime;     * time of last modification *
- *     time_t        st_ctime;     * time of last inode change *            
+ *     time_t        st_ctime;     * time of last inode change *
  *  };
  */
 
 
 
-/* 
- * Create File record in B_DB  
+/*
+ * Create File record in B_DB
  *
  *  In order to reduce database size, we store the File attributes,
- *  the FileName, and the Path separately.  In principle, there   
+ *  the FileName, and the Path separately.  In principle, there
  *  is a single FileName record and a single Path record, no matter
  *  how many times it occurs.  This is this subroutine, we separate
  *  the file and the path and create three database records.
@@ -506,7 +506,7 @@ int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
    /*
     * Make sure we have an acceptable attributes record.
     */
-   if (!(ar->Stream == STREAM_UNIX_ATTRIBUTES || 
+   if (!(ar->Stream == STREAM_UNIX_ATTRIBUTES ||
         ar->Stream == STREAM_UNIX_ATTRIBUTES_EX)) {
       Mmsg0(&mdb->errmsg, _("Attempt to put non-attributes into catalog\n"));
       Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
@@ -556,13 +556,13 @@ static int db_create_file_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
 
    /* Must create it */
    Mmsg(mdb->cmd,
-        "INSERT INTO File (FileIndex,JobId,PathId,FilenameId,"
-        "LStat,MD5) VALUES (%u,%u,%u,%u,'%s','0')", 
-       ar->FileIndex, ar->JobId, ar->PathId, ar->FilenameId, 
+       "INSERT INTO File (FileIndex,JobId,PathId,FilenameId,"
+       "LStat,MD5) VALUES (%u,%u,%u,%u,'%s','0')",
+       ar->FileIndex, ar->JobId, ar->PathId, ar->FilenameId,
        ar->attr);
 
    if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
-      Mmsg2(&mdb->errmsg, _("Create db File record %s failed. ERR=%s"),       
+      Mmsg2(&mdb->errmsg, _("Create db File record %s failed. ERR=%s"),
         mdb->cmd, sql_strerror(mdb));
       Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg);
       ar->FileId = 0;
@@ -587,7 +587,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
        strcmp(mdb->cached_path, mdb->path) == 0) {
       ar->PathId = mdb->cached_path_id;
       return 1;
-   }         
+   }
 
    Mmsg(mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", mdb->esc_name);
 
@@ -595,15 +595,15 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 1) {
         char ed1[30];
-         Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"), 
+        Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"),
            edit_uint64(mdb->num_rows, ed1), mdb->path);
-         Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
+        Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
       }
       /* Even if there are multiple paths, take the first one */
       if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
-            Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+           Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
+           Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
            sql_free_result(mdb);
            ar->PathId = 0;
            ASSERT(ar->PathId);
@@ -626,7 +626,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
    Mmsg(mdb->cmd, "INSERT INTO Path (Path) VALUES ('%s')", mdb->esc_name);
 
    if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
-      Mmsg2(&mdb->errmsg, _("Create db Path record %s failed. ERR=%s\n"), 
+      Mmsg2(&mdb->errmsg, _("Create db Path record %s failed. ERR=%s\n"),
         mdb->cmd, sql_strerror(mdb));
       Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg);
       ar->PathId = 0;
@@ -646,7 +646,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
 }
 
 /* Create a Unique record for the filename -- no duplicates */
-static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) 
+static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
 {
    SQL_ROW row;
 
@@ -659,15 +659,15 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 1) {
         char ed1[30];
-         Mmsg2(&mdb->errmsg, _("More than one Filename! %s for file: %s\n"), 
+        Mmsg2(&mdb->errmsg, _("More than one Filename! %s for file: %s\n"),
            edit_uint64(mdb->num_rows, ed1), mdb->fname);
-         Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
+        Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
       }
       if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg2(&mdb->errmsg, _("Error fetching row for file=%s: ERR=%s\n"), 
+           Mmsg2(&mdb->errmsg, _("Error fetching row for file=%s: ERR=%s\n"),
                mdb->fname, sql_strerror(mdb));
-            Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+           Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
            ar->FilenameId = 0;
         } else {
            ar->FilenameId = atoi(row[0]);
@@ -681,7 +681,7 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
    Mmsg(mdb->cmd, "INSERT INTO Filename (Name) VALUES ('%s')", mdb->esc_name);
 
    if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
-      Mmsg2(&mdb->errmsg, _("Create db Filename record %s failed. ERR=%s\n"), 
+      Mmsg2(&mdb->errmsg, _("Create db Filename record %s failed. ERR=%s\n"),
            mdb->cmd, sql_strerror(mdb));
       Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg);
       ar->FilenameId = 0;
index fd07956607824c2b6afb4f4a50a25587ea22ef8d..a35b64e90055395afc954c504c057f7cccfd6795 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Bacula Catalog Database Delete record interface routines
- * 
+ *
  *    Kern Sibbald, December 2000
  *
  *    Version $Id$
@@ -50,7 +50,7 @@ extern void print_dashes(B_DB *mdb);
 extern void print_result(B_DB *mdb);
 extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
 extern int DeleteDB(const char *file, int line, JCR *jcr, B_DB *db, char *delete_cmd);
-       
+
 /*
  * Delete Pool record, must also delete all associated
  *  Media records.
@@ -74,20 +74,20 @@ db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
 
       mdb->num_rows = sql_num_rows(mdb);
-   
+
       if (mdb->num_rows == 0) {
-         Mmsg(mdb->errmsg, _("No pool record %s exists\n"), pr->Name);
+        Mmsg(mdb->errmsg, _("No pool record %s exists\n"), pr->Name);
         sql_free_result(mdb);
         db_unlock(mdb);
         return 0;
       } else if (mdb->num_rows != 1) {
-         Mmsg(mdb->errmsg, _("Expecting one pool record, got %d\n"), mdb->num_rows);
+        Mmsg(mdb->errmsg, _("Expecting one pool record, got %d\n"), mdb->num_rows);
         sql_free_result(mdb);
         db_unlock(mdb);
         return 0;
       }
       if ((row = sql_fetch_row(mdb)) == NULL) {
-         Mmsg1(&mdb->errmsg, _("Error fetching row %s\n"), sql_strerror(mdb));
+        Mmsg1(&mdb->errmsg, _("Error fetching row %s\n"), sql_strerror(mdb));
         db_unlock(mdb);
         return 0;
       }
@@ -115,7 +115,7 @@ db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
 #define MAX_DEL_LIST_LEN 1000000
 
 struct s_del_ctx {
-   JobId_t *JobId; 
+   JobId_t *JobId;
    int num_ids;                      /* ids stored */
    int max_ids;                      /* size of array */
    int num_del;                      /* number deleted */
@@ -133,7 +133,7 @@ static int delete_handler(void *ctx, int num_fields, char **row)
 {
    struct s_del_ctx *del = (struct s_del_ctx *)ctx;
 
-   if (del->num_ids == MAX_DEL_LIST_LEN) {  
+   if (del->num_ids == MAX_DEL_LIST_LEN) {
       return 1;
    }
    if (del->num_ids == del->max_ids) {
@@ -146,8 +146,8 @@ static int delete_handler(void *ctx, int num_fields, char **row)
 }
 
 
-/* 
- * This routine will purge (delete) all records 
+/*
+ * This routine will purge (delete) all records
  * associated with a particular Volume. It will
  * not delete the media record itself.
  */
@@ -194,7 +194,7 @@ int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    if (mr->MediaId == 0 && !db_get_media_record(jcr, mdb, mr)) {
       db_unlock(mdb);
       return 0;
-   } 
+   }
    /* Do purge if not already purged */
    if (strcmp(mr->VolStatus, "Purged") != 0) {
       /* Delete associated records */
@@ -208,7 +208,7 @@ int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 }
 
 /*
- * Purge all records associated with a 
+ * Purge all records associated with a
  * media record. This does not delete the
  * media record itself. But the media status
  * is changed to "Purged".
@@ -219,7 +219,7 @@ int db_purge_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    if (mr->MediaId == 0 && !db_get_media_record(jcr, mdb, mr)) {
       db_unlock(mdb);
       return 0;
-   } 
+   }
    /* Delete associated records */
    do_media_purge(mdb, mr);          /* Note, always purge */
 
index b09d69189d54bbd81738ff9321c06d55b0e41fa1..dd10220aa18481745d90db621a9b89391ace8de6 100644 (file)
@@ -4,7 +4,7 @@
  *  Note, generally, these routines are more complicated
  *       that a simple search by name or id. Such simple
  *       request are in get.c
- * 
+ *
  *    Kern Sibbald, December 2000
  *
  *    Version $Id$
@@ -57,7 +57,7 @@ extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_
  * find last full save for Incremental and Differential saves.
  *
  *  StartTime is returned in stime
- *     
+ *
  * Returns: 0 on failure
  *         1 on success, jr is unchanged, but stime is set
  */
@@ -72,7 +72,7 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
    /* If no Id given, we must find corresponding job */
    if (jr->JobId == 0) {
       /* Differential is since last Full backup */
-        Mmsg(mdb->cmd, 
+        Mmsg(mdb->cmd,
 "SELECT StartTime FROM Job WHERE JobStatus='T' AND Type='%c' AND "
 "Level='%c' AND Name='%s' AND ClientId=%u AND FileSetId=%u "
 "ORDER BY StartTime DESC LIMIT 1",
@@ -83,34 +83,34 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
 
       /* Incremental is since last Full, Incremental, or Differential */
       } else if (jr->JobLevel == L_INCREMENTAL) {
-        /* 
+        /*
          * For an Incremental job, we must first ensure
          *  that a Full backup was done (cmd edited above)
          *  then we do a second look to find the most recent
          *  backup
          */
         if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
-            Mmsg2(&mdb->errmsg, _("Query error for start time request: ERR=%s\nCMD=%s\n"), 
+           Mmsg2(&mdb->errmsg, _("Query error for start time request: ERR=%s\nCMD=%s\n"),
               sql_strerror(mdb), mdb->cmd);
            db_unlock(mdb);
            return 0;
         }
         if ((row = sql_fetch_row(mdb)) == NULL) {
            sql_free_result(mdb);
-            Mmsg(mdb->errmsg, _("No prior Full backup Job record found.\n"));
+           Mmsg(mdb->errmsg, _("No prior Full backup Job record found.\n"));
            db_unlock(mdb);
            return 0;
         }
         sql_free_result(mdb);
         /* Now edit SQL command for Incremental Job */
-        Mmsg(mdb->cmd, 
+        Mmsg(mdb->cmd,
 "SELECT StartTime FROM Job WHERE JobStatus='T' AND Type='%c' AND "
 "Level IN ('%c','%c','%c') AND Name='%s' AND ClientId=%u "
 "AND FileSetId=%u ORDER BY StartTime DESC LIMIT 1",
            jr->JobType, L_INCREMENTAL, L_DIFFERENTIAL, L_FULL, jr->Name,
            jr->ClientId, jr->FileSetId);
       } else {
-         Mmsg1(&mdb->errmsg, _("Unknown level=%d\n"), jr->JobLevel);
+        Mmsg1(&mdb->errmsg, _("Unknown level=%d\n"), jr->JobLevel);
         db_unlock(mdb);
         return 0;
       }
@@ -144,7 +144,7 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
 }
 
 /*
- * Find last failed job since given start-time 
+ * Find last failed job since given start-time
  *   it must be either Full or Diff.
  *
  * Returns: false on failure
@@ -158,7 +158,7 @@ db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int &
 
    db_lock(mdb);
    /* Differential is since last Full backup */
-   Mmsg(mdb->cmd, 
+   Mmsg(mdb->cmd,
 "SELECT Level FROM Job WHERE JobStatus!='T' AND Type='%c' AND "
 "Level IN ('%c','%c') AND Name='%s' AND ClientId=%u "
 "AND FileSetId=%u AND StartTime>'%s' "
@@ -184,7 +184,7 @@ db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int &
 }
 
 
-/* 
+/*
  * Find JobId of last job that ran.  E.g. for
  *   VERIFY_CATALOG we want the JobId of the last INIT.
  *   For VERIFY_VOLUME_TO_CATALOG, we want the JobId of the last Job.
@@ -200,7 +200,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr)
    /* Find last full */
    db_lock(mdb);
    if (jr->JobLevel == L_VERIFY_CATALOG) {
-      Mmsg(mdb->cmd, 
+      Mmsg(mdb->cmd,
 "SELECT JobId FROM Job WHERE Type='V' AND Level='%c' AND "
 " JobStatus='T' AND Name='%s' AND "
 "ClientId=%u ORDER BY StartTime DESC LIMIT 1",
@@ -212,7 +212,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr)
 "SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND "
 "Name='%s' ORDER BY StartTime DESC LIMIT 1", Name);
       } else {
-        Mmsg(mdb->cmd, 
+        Mmsg(mdb->cmd,
 "SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND "
 "ClientId=%u ORDER BY StartTime DESC LIMIT 1", jr->ClientId);
       }
@@ -247,7 +247,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr)
    return 1;
 }
 
-/* 
+/*
  * Find Available Media (Volume) for Pool
  *
  * Find a Volume for a given PoolId, MediaType, and Status.
@@ -256,7 +256,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr)
  *         numrows on success
  */
 int
-db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr) 
+db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr)
 {
    SQL_ROW row;
    int numrows;
@@ -266,33 +266,33 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr
    if (item == -1) {      /* find oldest volume */
       /* Find oldest volume */
       Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
-          "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
-          "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
-          "FirstWritten,LastWritten,VolStatus,InChanger "
-          "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus IN ('Full',"
-          "'Recycle','Purged','Used','Append') "
-          "ORDER BY LastWritten LIMIT 1", mr->PoolId, mr->MediaType); 
+         "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
+         "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
+         "FirstWritten,LastWritten,VolStatus,InChanger "
+         "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus IN ('Full',"
+         "'Recycle','Purged','Used','Append') "
+         "ORDER BY LastWritten LIMIT 1", mr->PoolId, mr->MediaType);
      item = 1;
    } else {
       /* Find next available volume */
       if (InChanger) {
-         changer = "AND InChanger=1";
+        changer = "AND InChanger=1";
       } else {
-         changer = "";
+        changer = "";
       }
       if (strcmp(mr->VolStatus, "Recycled") == 0 ||
-          strcmp(mr->VolStatus, "Purged") == 0) {
-         order = "ORDER BY LastWritten ASC,MediaId";  /* take oldest */
+         strcmp(mr->VolStatus, "Purged") == 0) {
+        order = "ORDER BY LastWritten ASC,MediaId";  /* take oldest */
       } else {
-         order = "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId";   /* take most recently written */
-      }  
+        order = "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId";   /* take most recently written */
+      }
       Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
-          "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
-          "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
-          "FirstWritten,LastWritten,VolStatus,InChanger "
-          "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' "
-          "%s " 
-          "%s LIMIT %d",
+         "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
+         "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
+         "FirstWritten,LastWritten,VolStatus,InChanger "
+         "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' "
+         "%s "
+         "%s LIMIT %d",
          mr->PoolId, mr->MediaType, mr->VolStatus, changer, order, item);
    }
    if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
@@ -307,8 +307,8 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr
       db_unlock(mdb);
       return 0;
    }
-   
-   /* Seek to desired item 
+
+   /* Seek to desired item
     * Note, we use base 1; SQL uses base 0
     */
    sql_data_seek(mdb, item-1);
index 6b27b17ad55abf322af8203f85dd19fb605e7da6..e53ecfa4db9f4c375e7b4365d84b539e4e50097b 100644 (file)
@@ -2,7 +2,7 @@
  * Bacula Catalog Database Get record interface routines
  *  Note, these routines generally get a record by id or
  *       by name.  If more logic is involved, the routine
- *       should be in find.c 
+ *       should be in find.c
  *
  *    Kern Sibbald, March 2000
  *
@@ -86,9 +86,9 @@ int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, JOB_DBR *jr,
    return stat;
 }
 
+
 /*
- * Get a File record   
+ * Get a File record
  * Returns: 0 on failure
  *         1 on success
  *
@@ -105,32 +105,32 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr)
    int stat = 0;
 
    if (jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) {
-   Mmsg(mdb->cmd, 
+   Mmsg(mdb->cmd,
 "SELECT FileId, LStat, MD5 FROM File,Job WHERE "
 "File.JobId=Job.JobId AND File.PathId=%u AND "
 "File.FilenameId=%u AND Job.Type='B' AND Job.JobSTATUS='T' AND "
 "ClientId=%u ORDER BY StartTime DESC LIMIT 1",
       fdbr->PathId, fdbr->FilenameId, jr->ClientId);
    } else {
-      Mmsg(mdb->cmd, 
+      Mmsg(mdb->cmd,
 "SELECT FileId, LStat, MD5 FROM File WHERE File.JobId=%u AND File.PathId=%u AND "
 "File.FilenameId=%u", fdbr->JobId, fdbr->PathId, fdbr->FilenameId);
    }
    Dmsg3(050, "Get_file_record JobId=%u FilenameId=%u PathId=%u\n",
       fdbr->JobId, fdbr->FilenameId, fdbr->PathId);
-      
+
    Dmsg1(100, "Query=%s\n", mdb->cmd);
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
       Dmsg1(050, "get_file_record num_rows=%d\n", (int)mdb->num_rows);
       if (mdb->num_rows > 1) {
-         Mmsg1(&mdb->errmsg, _("get_file_record want 1 got rows=%d\n"),
+        Mmsg1(&mdb->errmsg, _("get_file_record want 1 got rows=%d\n"),
            mdb->num_rows);
       }
       if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("Error fetching row: %s\n"), sql_strerror(mdb));
+           Mmsg1(&mdb->errmsg, _("Error fetching row: %s\n"), sql_strerror(mdb));
         } else {
            fdbr->FileId = (FileId_t)str_to_int64(row[0]);
            bstrncpy(fdbr->LStat, row[1], sizeof(fdbr->LStat));
@@ -138,7 +138,7 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr)
            stat = 1;
         }
       } else {
-         Mmsg2(&mdb->errmsg, _("File record for PathId=%u FilenameId=%u not found.\n"),
+        Mmsg2(&mdb->errmsg, _("File record for PathId=%u FilenameId=%u not found.\n"),
            fdbr->PathId, fdbr->FilenameId);
       }
       sql_free_result(mdb);
@@ -149,7 +149,7 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr)
 
 }
 
-/* Get Filename record  
+/* Get Filename record
  * Returns: 0 on failure
  *         FilenameId on success
  *
@@ -162,29 +162,29 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb)
 
    mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2);
    db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl);
-   
+
    Mmsg(mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name);
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       char ed1[30];
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 1) {
-         Mmsg2(&mdb->errmsg, _("More than one Filename!: %s for file: %s\n"),
+        Mmsg2(&mdb->errmsg, _("More than one Filename!: %s for file: %s\n"),
            edit_uint64(mdb->num_rows, ed1), mdb->fname);
-         Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
-      } 
+        Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
+      }
       if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
+           Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
         } else {
            FilenameId = atoi(row[0]);
            if (FilenameId <= 0) {
-               Mmsg2(&mdb->errmsg, _("Get DB Filename record %s found bad record: %d\n"),
-                 mdb->cmd, FilenameId); 
+              Mmsg2(&mdb->errmsg, _("Get DB Filename record %s found bad record: %d\n"),
+                 mdb->cmd, FilenameId);
               FilenameId = 0;
            }
         }
       } else {
-         Mmsg1(&mdb->errmsg, _("Filename record: %s not found.\n"), mdb->fname);
+        Mmsg1(&mdb->errmsg, _("Filename record: %s not found.\n"), mdb->fname);
       }
       sql_free_result(mdb);
    } else {
@@ -193,7 +193,7 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb)
    return FilenameId;
 }
 
-/* Get path record   
+/* Get path record
  * Returns: 0 on failure
  *         PathId on success
  *
@@ -210,7 +210,7 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb)
    if (mdb->cached_path_id != 0 && mdb->cached_path_len == mdb->pnl &&
        strcmp(mdb->cached_path, mdb->path) == 0) {
       return mdb->cached_path_id;
-   }         
+   }
 
    Mmsg(mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", mdb->esc_name);
 
@@ -218,19 +218,19 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb)
       char ed1[30];
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 1) {
-         Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"),
+        Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"),
            edit_uint64(mdb->num_rows, ed1), mdb->path);
-         Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
-      } 
+        Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg);
+      }
       /* Even if there are multiple paths, take the first one */
       if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
+           Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
         } else {
            PathId = atoi(row[0]);
            if (PathId <= 0) {
-               Mmsg2(&mdb->errmsg, _("Get DB path record %s found bad record: %u\n"),
-                 mdb->cmd, PathId); 
+              Mmsg2(&mdb->errmsg, _("Get DB path record %s found bad record: %u\n"),
+                 mdb->cmd, PathId);
               PathId = 0;
            } else {
               /* Cache path */
@@ -241,8 +241,8 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb)
               }
            }
         }
-      } else { 
-         Mmsg1(&mdb->errmsg, _("Path record: %s not found.\n"), mdb->path);
+      } else {
+        Mmsg1(&mdb->errmsg, _("Path record: %s not found.\n"), mdb->path);
       }
       sql_free_result(mdb);
    } else {
@@ -252,7 +252,7 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb)
 }
 
 
-/* 
+/*
  * Get Job record for given JobId or Job name
  * Returns: 0 on failure
  *         1 on success
@@ -322,11 +322,11 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum
 
    db_lock(mdb);
    /* Get one entry per VolumeName, but "sort" by VolIndex */
-   Mmsg(mdb->cmd, 
-        "SELECT VolumeName,MAX(VolIndex) FROM JobMedia,Media WHERE "
-        "JobMedia.JobId=%u AND JobMedia.MediaId=Media.MediaId "
-        "GROUP BY VolumeName "
-        "ORDER BY 2 ASC", JobId);
+   Mmsg(mdb->cmd,
+       "SELECT VolumeName,MAX(VolIndex) FROM JobMedia,Media WHERE "
+       "JobMedia.JobId=%u AND JobMedia.MediaId=Media.MediaId "
+       "GROUP BY VolumeName "
+       "ORDER BY 2 ASC", JobId);
 
    Dmsg1(130, "VolNam=%s\n", mdb->cmd);
    *VolumeNames[0] = 0;
@@ -334,19 +334,19 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum
       mdb->num_rows = sql_num_rows(mdb);
       Dmsg1(130, "Num rows=%d\n", mdb->num_rows);
       if (mdb->num_rows <= 0) {
-         Mmsg1(&mdb->errmsg, _("No volumes found for JobId=%d\n"), JobId);
+        Mmsg1(&mdb->errmsg, _("No volumes found for JobId=%d\n"), JobId);
         stat = 0;
       } else {
         stat = mdb->num_rows;
         for (i=0; i < stat; i++) {
            if ((row = sql_fetch_row(mdb)) == NULL) {
-               Mmsg2(&mdb->errmsg, _("Error fetching row %d: ERR=%s\n"), i, sql_strerror(mdb));
-               Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+              Mmsg2(&mdb->errmsg, _("Error fetching row %d: ERR=%s\n"), i, sql_strerror(mdb));
+              Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
               stat = 0;
               break;
            } else {
               if (*VolumeNames[0] != 0) {
-                  pm_strcat(VolumeNames, "|");
+                 pm_strcat(VolumeNames, "|");
               }
               pm_strcat(VolumeNames, row[0]);
            }
@@ -376,7 +376,7 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS
    VOL_PARAMS *Vols = NULL;
 
    db_lock(mdb);
-   Mmsg(mdb->cmd, 
+   Mmsg(mdb->cmd,
 "SELECT VolumeName,FirstIndex,LastIndex,StartFile,JobMedia.EndFile,"
 "StartBlock,JobMedia.EndBlock"
 " FROM JobMedia,Media WHERE JobMedia.JobId=%u"
@@ -387,7 +387,7 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS
       mdb->num_rows = sql_num_rows(mdb);
       Dmsg1(130, "Num rows=%d\n", mdb->num_rows);
       if (mdb->num_rows <= 0) {
-         Mmsg1(&mdb->errmsg, _("No volumes found for JobId=%d\n"), JobId);
+        Mmsg1(&mdb->errmsg, _("No volumes found for JobId=%d\n"), JobId);
         stat = 0;
       } else {
         stat = mdb->num_rows;
@@ -396,8 +396,8 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS
         }
         for (i=0; i < stat; i++) {
            if ((row = sql_fetch_row(mdb)) == NULL) {
-               Mmsg2(&mdb->errmsg, _("Error fetching row %d: ERR=%s\n"), i, sql_strerror(mdb));
-               Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+              Mmsg2(&mdb->errmsg, _("Error fetching row %d: ERR=%s\n"), i, sql_strerror(mdb));
+              Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
               stat = 0;
               break;
            } else {
@@ -419,7 +419,7 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS
 
 
 
-/* 
+/*
  * Get the number of pool records
  *
  * Returns: -1 on failure
@@ -512,12 +512,12 @@ int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
 
 
 
-/* Get Pool Record   
+/* Get Pool Record
  * If the PoolId is non-zero, we get its record,
  *  otherwise, we search on the PoolName
  *
  * Returns: 0 on failure
- *         id on success 
+ *         id on success
  */
 int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr)
 {
@@ -526,31 +526,31 @@ int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr)
 
    db_lock(mdb);
    if (pdbr->PoolId != 0) {              /* find by id */
-      Mmsg(mdb->cmd, 
-"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,\
-AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,\
-MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.PoolId=%u", pdbr->PoolId);
+      Mmsg(mdb->cmd,
+"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,"
+"AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
+"MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.PoolId=%u", pdbr->PoolId);
    } else {                          /* find by name */
-      Mmsg(mdb->cmd, 
-"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,\
-AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,\
-MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name);
-   }  
+      Mmsg(mdb->cmd,
+"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,"
+"AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
+"MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name);
+   }
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 1) {
         char ed1[30];
-         Mmsg1(&mdb->errmsg, _("More than one Pool!: %s\n"), 
+        Mmsg1(&mdb->errmsg, _("More than one Pool!: %s\n"),
            edit_uint64(mdb->num_rows, ed1));
-         Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+        Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
       } else if (mdb->num_rows == 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
-            Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+           Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
+           Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
         } else {
            pdbr->PoolId = str_to_int64(row[0]);
-            bstrncpy(pdbr->Name, row[1]!=NULL?row[1]:"", sizeof(pdbr->Name));
+           bstrncpy(pdbr->Name, row[1]!=NULL?row[1]:"", sizeof(pdbr->Name));
            pdbr->NumVols = str_to_int64(row[2]);
            pdbr->MaxVols = str_to_int64(row[3]);
            pdbr->UseOnce = str_to_int64(row[4]);
@@ -563,12 +563,12 @@ MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name);
            pdbr->MaxVolJobs = str_to_int64(row[11]);
            pdbr->MaxVolFiles = str_to_int64(row[12]);
            pdbr->MaxVolBytes = str_to_uint64(row[13]);
-            bstrncpy(pdbr->PoolType, row[13]!=NULL?row[14]:"", sizeof(pdbr->PoolType));
-            bstrncpy(pdbr->LabelFormat, row[14]!=NULL?row[15]:"", sizeof(pdbr->LabelFormat));
+           bstrncpy(pdbr->PoolType, row[13]!=NULL?row[14]:"", sizeof(pdbr->PoolType));
+           bstrncpy(pdbr->LabelFormat, row[14]!=NULL?row[15]:"", sizeof(pdbr->LabelFormat));
            stat = pdbr->PoolId;
         }
       } else {
-         Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n"));
+        Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n"));
       }
       sql_free_result(mdb);
    } else {
@@ -578,12 +578,12 @@ MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name);
    return stat;
 }
 
-/* Get Client Record   
+/* Get Client Record
  * If the ClientId is non-zero, we get its record,
  *  otherwise, we search on the Client Name
  *
  * Returns: 0 on failure
- *         1 on success 
+ *         1 on success
  */
 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr)
 {
@@ -592,37 +592,37 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr)
 
    db_lock(mdb);
    if (cdbr->ClientId != 0) {              /* find by id */
-      Mmsg(mdb->cmd, 
+      Mmsg(mdb->cmd,
 "SELECT ClientId,Name,Uname,AutoPrune,FileRetention,JobRetention "
 "FROM Client WHERE Client.ClientId=%u", cdbr->ClientId);
    } else {                          /* find by name */
-      Mmsg(mdb->cmd, 
+      Mmsg(mdb->cmd,
 "SELECT ClientId,Name,Uname,AutoPrune,FileRetention,JobRetention "
 "FROM Client WHERE Client.Name='%s'", cdbr->Name);
-   }  
+   }
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 1) {
         char ed1[30];
-         Mmsg1(&mdb->errmsg, _("More than one Client!: %s\n"), 
+        Mmsg1(&mdb->errmsg, _("More than one Client!: %s\n"),
            edit_uint64(mdb->num_rows, ed1));
-         Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+        Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
       } else if (mdb->num_rows == 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
-            Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+           Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
+           Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
         } else {
            cdbr->ClientId = str_to_int64(row[0]);
-            bstrncpy(cdbr->Name, row[1]!=NULL?row[1]:"", sizeof(cdbr->Name));
-            bstrncpy(cdbr->Uname, row[2]!=NULL?row[1]:"", sizeof(cdbr->Uname));
+           bstrncpy(cdbr->Name, row[1]!=NULL?row[1]:"", sizeof(cdbr->Name));
+           bstrncpy(cdbr->Uname, row[2]!=NULL?row[1]:"", sizeof(cdbr->Uname));
            cdbr->AutoPrune = str_to_int64(row[3]);
            cdbr->FileRetention = str_to_int64(row[4]);
            cdbr->JobRetention = str_to_int64(row[5]);
            stat = 1;
         }
       } else {
-         Mmsg(mdb->errmsg, _("Client record not found in Catalog.\n"));
+        Mmsg(mdb->errmsg, _("Client record not found in Catalog.\n"));
       }
       sql_free_result(mdb);
    } else {
@@ -648,16 +648,16 @@ int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
-      
+
       /* If more than one, report error, but return first row */
       if (mdb->num_rows > 1) {
-         Mmsg1(&mdb->errmsg, _("More than one Counter!: %d\n"), (int)(mdb->num_rows));
-         Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+        Mmsg1(&mdb->errmsg, _("More than one Counter!: %d\n"), (int)(mdb->num_rows));
+        Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
       }
       if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("error fetching Counter row: %s\n"), sql_strerror(mdb));
-            Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+           Mmsg1(&mdb->errmsg, _("error fetching Counter row: %s\n"), sql_strerror(mdb));
+           Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
            sql_free_result(mdb);
            db_unlock(mdb);
            return 0;
@@ -677,18 +677,18 @@ int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
       sql_free_result(mdb);
    } else {
       Mmsg(mdb->errmsg, _("Counter record: %s not found in Catalog.\n"), cr->Counter);
-   }  
+   }
    db_unlock(mdb);
    return 0;
 }
 
 
-/* Get FileSet Record  
+/* Get FileSet Record
  * If the FileSetId is non-zero, we get its record,
  *  otherwise, we search on the name
  *
  * Returns: 0 on failure
- *         id on success 
+ *         id on success
  */
 int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
 {
@@ -697,30 +697,30 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
 
    db_lock(mdb);
    if (fsr->FileSetId != 0) {              /* find by id */
-      Mmsg(mdb->cmd, 
-           "SELECT FileSetId,FileSet,MD5,CreateTime FROM FileSet "
-           "WHERE FileSetId=%u", fsr->FileSetId);
+      Mmsg(mdb->cmd,
+          "SELECT FileSetId,FileSet,MD5,CreateTime FROM FileSet "
+          "WHERE FileSetId=%u", fsr->FileSetId);
    } else {                          /* find by name */
-      Mmsg(mdb->cmd, 
-           "SELECT FileSetId,FileSet,CreateTime,MD5 FROM FileSet "
-           "WHERE FileSet='%s' ORDER BY CreateTime DESC LIMIT 1", fsr->FileSet);
-   }  
+      Mmsg(mdb->cmd,
+          "SELECT FileSetId,FileSet,CreateTime,MD5 FROM FileSet "
+          "WHERE FileSet='%s' ORDER BY CreateTime DESC LIMIT 1", fsr->FileSet);
+   }
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 1) {
         char ed1[30];
-         Mmsg1(&mdb->errmsg, _("Error got %s FileSets but expected only one!\n"), 
+        Mmsg1(&mdb->errmsg, _("Error got %s FileSets but expected only one!\n"),
            edit_uint64(mdb->num_rows, ed1));
         sql_data_seek(mdb, mdb->num_rows-1);
       }
       if ((row = sql_fetch_row(mdb)) == NULL) {
-         Mmsg1(&mdb->errmsg, _("FileSet record \"%s\" not found.\n"), fsr->FileSet);
+        Mmsg1(&mdb->errmsg, _("FileSet record \"%s\" not found.\n"), fsr->FileSet);
       } else {
         fsr->FileSetId = atoi(row[0]);
-         bstrncpy(fsr->FileSet, row[1]!=NULL?row[1]:"", sizeof(fsr->FileSet));
-         bstrncpy(fsr->MD5, row[2]!=NULL?row[2]:"", sizeof(fsr->MD5));
-         bstrncpy(fsr->cCreateTime, row[3]!=NULL?row[3]:"", sizeof(fsr->cCreateTime));
+        bstrncpy(fsr->FileSet, row[1]!=NULL?row[1]:"", sizeof(fsr->FileSet));
+        bstrncpy(fsr->MD5, row[2]!=NULL?row[2]:"", sizeof(fsr->MD5));
+        bstrncpy(fsr->cCreateTime, row[3]!=NULL?row[3]:"", sizeof(fsr->cCreateTime));
         stat = fsr->FileSetId;
       }
       sql_free_result(mdb);
@@ -732,7 +732,7 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
 }
 
 
-/* 
+/*
  * Get the number of Media records
  *
  * Returns: -1 on failure
@@ -789,10 +789,10 @@ int db_get_media_ids(JCR *jcr, B_DB *mdb, uint32_t PoolId, int *num_ids, uint32_
 }
 
 
-/* Get Media Record   
+/* Get Media Record
  *
  * Returns: 0 on failure
- *         id on success 
+ *         id on success
  */
 int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
@@ -808,33 +808,33 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    }
    if (mr->MediaId != 0) {              /* find by id */
       Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
-         "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
-         "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
-         "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock "
-         "FROM Media WHERE MediaId=%d", mr->MediaId);
+        "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
+        "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
+        "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock "
+        "FROM Media WHERE MediaId=%d", mr->MediaId);
    } else {                          /* find by name */
       Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
-         "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
-         "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
-         "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock "
-         "FROM Media WHERE VolumeName='%s'", mr->VolumeName);
-   }  
+        "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
+        "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
+        "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock "
+        "FROM Media WHERE VolumeName='%s'", mr->VolumeName);
+   }
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
       if (mdb->num_rows > 1) {
         char ed1[30];
-         Mmsg1(&mdb->errmsg, _("More than one Volume!: %s\n"), 
+        Mmsg1(&mdb->errmsg, _("More than one Volume!: %s\n"),
            edit_uint64(mdb->num_rows, ed1));
-         Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+        Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
       } else if (mdb->num_rows == 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
-            Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
-            Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
+           Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
+           Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
         } else {
            /* return values */
            mr->MediaId = str_to_int64(row[0]);
-            bstrncpy(mr->VolumeName, row[1]!=NULL?row[1]:"", sizeof(mr->VolumeName));
+           bstrncpy(mr->VolumeName, row[1]!=NULL?row[1]:"", sizeof(mr->VolumeName));
            mr->VolJobs = str_to_int64(row[2]);
            mr->VolFiles = str_to_int64(row[3]);
            mr->VolBlocks = str_to_int64(row[4]);
@@ -844,8 +844,8 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
            mr->VolWrites = str_to_int64(row[8]);
            mr->MaxVolBytes = str_to_uint64(row[9]);
            mr->VolCapacityBytes = str_to_uint64(row[10]);
-            bstrncpy(mr->MediaType, row[11]!=NULL?row[11]:"", sizeof(mr->MediaType));
-            bstrncpy(mr->VolStatus, row[12]!=NULL?row[12]:"", sizeof(mr->VolStatus));
+           bstrncpy(mr->MediaType, row[11]!=NULL?row[11]:"", sizeof(mr->MediaType));
+           bstrncpy(mr->VolStatus, row[12]!=NULL?row[12]:"", sizeof(mr->VolStatus));
            mr->PoolId = str_to_int64(row[13]);
            mr->VolRetention = str_to_uint64(row[14]);
            mr->VolUseDuration = str_to_uint64(row[15]);
@@ -853,9 +853,9 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
            mr->MaxVolFiles = str_to_int64(row[17]);
            mr->Recycle = str_to_int64(row[18]);
            mr->Slot = str_to_int64(row[19]);
-            bstrncpy(mr->cFirstWritten, row[20]!=NULL?row[20]:"", sizeof(mr->cFirstWritten));
+           bstrncpy(mr->cFirstWritten, row[20]!=NULL?row[20]:"", sizeof(mr->cFirstWritten));
            mr->FirstWritten = (time_t)str_to_utime(mr->cFirstWritten);
-            bstrncpy(mr->cLastWritten, row[21]!=NULL?row[21]:"", sizeof(mr->cLastWritten));
+           bstrncpy(mr->cLastWritten, row[21]!=NULL?row[21]:"", sizeof(mr->cLastWritten));
            mr->LastWritten = (time_t)str_to_utime(mr->cLastWritten);
            mr->InChanger = str_to_uint64(row[22]);
            mr->EndFile = str_to_uint64(row[23]);
@@ -864,9 +864,9 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
         }
       } else {
         if (mr->MediaId != 0) {
-            Mmsg1(&mdb->errmsg, _("Media record MediaId=%u not found.\n"), mr->MediaId);
+           Mmsg1(&mdb->errmsg, _("Media record MediaId=%u not found.\n"), mr->MediaId);
         } else {
-            Mmsg1(&mdb->errmsg, _("Media record for Volume \"%s\" not found.\n"), 
+           Mmsg1(&mdb->errmsg, _("Media record for Volume \"%s\" not found.\n"),
                  mr->VolumeName);
         }
       }
index c539bcb6c0286f1516fb5247923d095a249b4d3d..fa18ad9fac4c3435552f4cfa061eb2585e99c4d8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Bacula Catalog Database List records interface routines
- * 
+ *
  *    Kern Sibbald, March 2000
  *
  *    Version $Id$
@@ -48,10 +48,10 @@ extern void list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx,
 extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
 
 
-/* 
+/*
  * Submit general SQL query
  */
-int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, 
+int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
                      void *ctx, int verbose, e_list_type type)
 {
    db_lock(mdb);
@@ -75,18 +75,18 @@ int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
 }
 
 void
-db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) 
+db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
 {
    db_lock(mdb);
    if (type == VERT_LIST) {
       Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,"
-         "AcceptAnyVolume,VolRetention,VolUseDuration,MaxVolJobs,MaxVolBytes,"
-         "AutoPrune,Recycle,PoolType,LabelFormat,Enabled,ScratchPoolId,"
-         "RecyclePoolId "
-          "FROM Pool ORDER BY PoolId");
+        "AcceptAnyVolume,VolRetention,VolUseDuration,MaxVolJobs,MaxVolBytes,"
+        "AutoPrune,Recycle,PoolType,LabelFormat,Enabled,ScratchPoolId,"
+        "RecyclePoolId "
+         "FROM Pool ORDER BY PoolId");
    } else {
       Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,PoolType,LabelFormat "
-        "FROM Pool ORDER BY PoolId");
+       "FROM Pool ORDER BY PoolId");
    }
 
    if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
@@ -95,7 +95,7 @@ db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_
    }
 
    list_result(jcr, mdb, sendit, ctx, type);
-   
+
    sql_free_result(mdb);
    db_unlock(mdb);
 }
@@ -106,11 +106,11 @@ db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx,
    db_lock(mdb);
    if (type == VERT_LIST) {
       Mmsg(mdb->cmd, "SELECT ClientId,Name,Uname,AutoPrune,FileRetention,"
-         "FileRetention,JobRetention "
-         "FROM Client ORDER BY ClientId");
+        "FileRetention,JobRetention "
+        "FROM Client ORDER BY ClientId");
    } else {
       Mmsg(mdb->cmd, "SELECT ClientId,Name,FileRetention,JobRetention "
-         "FROM Client ORDER BY ClientId");
+        "FROM Client ORDER BY ClientId");
    }
 
    if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
@@ -119,7 +119,7 @@ db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx,
    }
 
    list_result(jcr, mdb, sendit, ctx, type);
-   
+
    sql_free_result(mdb);
    db_unlock(mdb);
 }
@@ -130,37 +130,37 @@ db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx,
  *   otherwise, list the Volumes in the Pool specified by PoolId
  */
 void
-db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, 
+db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
                      DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
 {
    db_lock(mdb);
    if (type == VERT_LIST) {
       if (mdbr->VolumeName[0] != 0) {
-         Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId,"
-            "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs,"
-            "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites,"
-            "VolCapacityBytes,VolStatus,Recycle,VolRetention,"
-            "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger,"
-            "EndFile,EndBlock "
-            "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName);
+        Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId,"
+           "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs,"
+           "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites,"
+           "VolCapacityBytes,VolStatus,Recycle,VolRetention,"
+           "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger,"
+           "EndFile,EndBlock "
+           "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName);
       } else {
-         Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId,"
-            "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs,"
-            "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites,"
-            "VolCapacityBytes,VolStatus,Recycle,VolRetention,"
-            "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger,"
-            "EndFile,EndBlock "
-            "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId);
+        Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId,"
+           "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs,"
+           "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites,"
+           "VolCapacityBytes,VolStatus,Recycle,VolRetention,"
+           "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger,"
+           "EndFile,EndBlock "
+           "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId);
       }
    } else {
       if (mdbr->VolumeName[0] != 0) {
-         Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,"
-            "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten "
-            "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName);
+        Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,"
+           "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten "
+           "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName);
       } else {
-         Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,"
-            "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten "
-            "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId);
+        Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,"
+           "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten "
+           "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId);
       }
    }
 
@@ -170,37 +170,37 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
    }
 
    list_result(jcr, mdb, sendit, ctx, type);
-   
+
    sql_free_result(mdb);
    db_unlock(mdb);
 }
 
-void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, 
+void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
                              DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
 {
    db_lock(mdb);
    if (type == VERT_LIST) {
       if (JobId > 0) {                  /* do by JobId */
-         Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName,"
-            "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock,"
-            "JobMedia.EndBlock "
-            "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId "
-            "AND JobMedia.JobId=%u", JobId);
+        Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName,"
+           "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock,"
+           "JobMedia.EndBlock "
+           "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId "
+           "AND JobMedia.JobId=%u", JobId);
       } else {
-         Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName,"
-            "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock,"
-            "JobMedia.EndBlock "
-            "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId");
+        Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName,"
+           "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock,"
+           "JobMedia.EndBlock "
+           "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId");
       }
 
    } else {
       if (JobId > 0) {                  /* do by JobId */
-         Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex "
-            "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId "
-            "AND JobMedia.JobId=%u", JobId);
+        Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex "
+           "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId "
+           "AND JobMedia.JobId=%u", JobId);
       } else {
-         Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex "
-            "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId");
+        Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex "
+           "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId");
       }
    }
    if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
@@ -209,7 +209,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
    }
 
    list_result(jcr, mdb, sendit, ctx, type);
-   
+
    sql_free_result(mdb);
    db_unlock(mdb);
 }
@@ -223,40 +223,40 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
  *  only the job with the specified id.
  */
 void
-db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, 
+db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit,
                    void *ctx, e_list_type type)
 {
    db_lock(mdb);
    if (type == VERT_LIST) {
       if (jr->JobId == 0 && jr->Job[0] == 0) {
-        Mmsg(mdb->cmd, 
-            "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level,"
-            "Job.ClientId,Client.Name,JobStatus,SchedTime,"
-            "StartTime,EndTime,JobTDate,"
-            "VolSessionId,VolSessionTime,JobFiles,JobErrors,"
-            "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet "
-            "FROM Job,Client,Pool,FileSet WHERE "
-            "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId "
-            "AND FileSet.FileSetId=Job.FileSetId  ORDER BY StartTime");
+        Mmsg(mdb->cmd,
+           "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level,"
+           "Job.ClientId,Client.Name,JobStatus,SchedTime,"
+           "StartTime,EndTime,JobTDate,"
+           "VolSessionId,VolSessionTime,JobFiles,JobErrors,"
+           "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet "
+           "FROM Job,Client,Pool,FileSet WHERE "
+           "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId "
+           "AND FileSet.FileSetId=Job.FileSetId  ORDER BY StartTime");
       } else {                          /* single record */
-        Mmsg(mdb->cmd, 
-            "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level,"
-            "Job.ClientId,Client.Name,JobStatus,SchedTime,"
-            "StartTime,EndTime,JobTDate,"
-            "VolSessionId,VolSessionTime,JobFiles,JobErrors,"
-            "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet "
-            "FROM Job,Client,Pool,FileSet WHERE Job.JobId=%u AND "
-            "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId "
-            "AND FileSet.FileSetId=Job.FileSetId", jr->JobId);
+        Mmsg(mdb->cmd,
+           "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level,"
+           "Job.ClientId,Client.Name,JobStatus,SchedTime,"
+           "StartTime,EndTime,JobTDate,"
+           "VolSessionId,VolSessionTime,JobFiles,JobErrors,"
+           "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet "
+           "FROM Job,Client,Pool,FileSet WHERE Job.JobId=%u AND "
+           "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId "
+           "AND FileSet.FileSetId=Job.FileSetId", jr->JobId);
       }
    } else {
       if (jr->JobId == 0 && jr->Job[0] == 0) {
-        Mmsg(mdb->cmd, 
-           "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
-           "FROM Job ORDER BY StartTime");
+        Mmsg(mdb->cmd,
+          "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
+          "FROM Job ORDER BY StartTime");
       } else {                          /* single record */
-         Mmsg(mdb->cmd, "SELECT JobId,Name,StartTime,Type,Level,"
-            "JobFiles,JobBytes,JobStatus FROM Job WHERE JobId=%u", jr->JobId);
+        Mmsg(mdb->cmd, "SELECT JobId,Name,StartTime,Type,Level,"
+           "JobFiles,JobBytes,JobStatus FROM Job WHERE JobId=%u", jr->JobId);
       }
    }
    if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
@@ -264,7 +264,7 @@ db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit,
       return;
    }
    list_result(jcr, mdb, sendit, ctx, type);
-   
+
    sql_free_result(mdb);
    db_unlock(mdb);
 }
@@ -288,12 +288,12 @@ db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, vo
    }
 
    list_result(jcr, mdb, sendit, ctx, HORZ_LIST);
-   
+
    sql_free_result(mdb);
 
    /* Do Grand Total */
-   Mmsg(mdb->cmd, "SELECT count(*) AS Jobs,sum(JobFiles) \
-AS Files,sum(JobBytes) As Bytes FROM Job");
+   Mmsg(mdb->cmd, "SELECT count(*) AS Jobs,sum(JobFiles) "
+"AS Files,sum(JobBytes) As Bytes FROM Job");
 
    if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
       db_unlock(mdb);
@@ -301,13 +301,13 @@ AS Files,sum(JobBytes) As Bytes FROM Job");
    }
 
    list_result(jcr, mdb, sendit, ctx, HORZ_LIST);
-   
+
    sql_free_result(mdb);
    db_unlock(mdb);
 }
 
-/* 
- * Stupid MySQL is NON-STANDARD !  
+/*
+ * Stupid MySQL is NON-STANDARD !
  */
 #ifdef HAVE_MYSQL
 #define FN "CONCAT(Path.Path,Filename.Name)"
@@ -331,7 +331,7 @@ db_list_files_for_job(JCR *jcr, B_DB *mdb, uint32_t jobid, DB_LIST_HANDLER *send
    }
 
    list_result(jcr, mdb, sendit, ctx, HORZ_LIST);
-   
+
    sql_free_result(mdb);
    db_unlock(mdb);
 }
index d2d73c998d378eaef1cc0bdbf0b6ce4fe0918425..86f65d6c3994b4a968307214e3208c47d09a2d5e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Bacula Catalog Database Update record interface routines
- * 
+ *
  *    Kern Sibbald, March 2000
  *
  *    Version $Id$
@@ -70,7 +70,7 @@ db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG,
 /* Mark the file record as being visited during database
  * verify compare. Stuff JobId into MarkedId field
  */
-int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId) 
+int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId)
 {
    int stat;
 
@@ -96,7 +96,7 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    btime_t JobTDate;
    int stat;
    char ed1[30];
-       
+
    stime = jr->StartTime;
    localtime_r(&stime, &tm);
    strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
@@ -105,7 +105,7 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    db_lock(mdb);
    Mmsg(mdb->cmd, "UPDATE Job SET JobStatus='%c',Level='%c',StartTime='%s',"
 "ClientId=%u,JobTDate=%s WHERE JobId=%u",
-      (char)(jcr->JobStatus), 
+      (char)(jcr->JobStatus),
       (char)(jr->JobLevel), dt, jr->ClientId, edit_uint64(JobTDate, ed1), jr->JobId);
 
    stat = UPDATE_DB(jcr, mdb, mdb->cmd);
@@ -120,7 +120,7 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
  *
  */
 void edit_num_or_null(char *s, size_t n, uint32_t id) {
-        bsnprintf(s, n, id ? "%u" : "NULL", id);
+       bsnprintf(s, n, id ? "%u" : "NULL", id);
 }
 
 
@@ -148,7 +148,7 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    edit_num_or_null(PoolId,    sizeof(PoolId),   jr->PoolId);
    edit_num_or_null(FileSetId, sizeof(FileSetId), jr->FileSetId);
    edit_num_or_null(ClientId,  sizeof(ClientId),  jr->ClientId);
-       
+
    ttime = jr->EndTime;
    localtime_r(&ttime, &tm);
    strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
@@ -156,11 +156,11 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 
    db_lock(mdb);
    Mmsg(mdb->cmd,
-      "UPDATE Job SET JobStatus='%c', EndTime='%s', \
-ClientId=%s, JobBytes=%s, JobFiles=%u, JobErrors=%u, VolSessionId=%u, \
-VolSessionTime=%u, PoolId=%s, FileSetId=%s, JobTDate=%s WHERE JobId=%u",
-      (char)(jr->JobStatus), dt, ClientId, edit_uint64(jr->JobBytes, ed1), 
-      jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime, 
+      "UPDATE Job SET JobStatus='%c', EndTime='%s', "
+"ClientId=%s, JobBytes=%s, JobFiles=%u, JobErrors=%u, VolSessionId=%u, "
+"VolSessionTime=%u, PoolId=%s, FileSetId=%s, JobTDate=%s WHERE JobId=%u",
+      (char)(jr->JobStatus), dt, ClientId, edit_uint64(jr->JobBytes, ed1),
+      jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime,
       PoolId, FileSetId, edit_uint64(JobTDate, ed2), jr->JobId);
 
    stat = UPDATE_DB(jcr, mdb, mdb->cmd);
@@ -170,7 +170,7 @@ VolSessionTime=%u, PoolId=%s, FileSetId=%s, JobTDate=%s WHERE JobId=%u",
 
 
 /*
- * Update Client record 
+ * Update Client record
  *   Returns: 0 on failure
  *           1 on success
  */
@@ -189,7 +189,7 @@ db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
    }
 
    Mmsg(mdb->cmd,
-"UPDATE Client SET AutoPrune=%d,FileRetention=%s,JobRetention=%s," 
+"UPDATE Client SET AutoPrune=%d,FileRetention=%s,JobRetention=%s,"
 "Uname='%s' WHERE Name='%s'",
       cr->AutoPrune,
       edit_uint64(cr->FileRetention, ed1),
@@ -212,7 +212,7 @@ int db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
    db_lock(mdb);
 
    Mmsg(mdb->cmd,
-"UPDATE Counters SET MinValue=%d,MaxValue=%d,CurrentValue=%d," 
+"UPDATE Counters SET MinValue=%d,MaxValue=%d,CurrentValue=%d,"
 "WrapCounter='%s' WHERE Counter='%s'",
       cr->MinValue, cr->MaxValue, cr->CurrentValue,
       cr->WrapCounter, cr->Counter);
@@ -231,7 +231,7 @@ db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
 
    db_lock(mdb);
    Mmsg(mdb->cmd,
-"UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d," 
+"UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d,"
 "AcceptAnyVolume=%d,VolRetention='%s',VolUseDuration='%s',"
 "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s,Recycle=%d,"
 "AutoPrune=%d,LabelFormat='%s' WHERE PoolId=%u",
@@ -248,21 +248,21 @@ db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
    return stat;
 }
 
-/* 
+/*
  * Update the Media Record at end of Session
  *
  * Returns: 0 on failure
  *         numrows on success
  */
 int
-db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) 
+db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
    char dt[MAX_TIME_LENGTH];
    time_t ttime;
    struct tm tm;
    int stat;
    char ed1[30], ed2[30], ed3[30], ed4[30];
-       
+
 
    Dmsg1(100, "update_media: FirstWritten=%d\n", mr->FirstWritten);
    db_lock(mdb);
@@ -271,8 +271,8 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
       ttime = mr->FirstWritten;
       localtime_r(&ttime, &tm);
       strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
-      Mmsg(mdb->cmd, "UPDATE Media SET FirstWritten='%s'\
- WHERE VolumeName='%s'", dt, mr->VolumeName);
+      Mmsg(mdb->cmd, "UPDATE Media SET FirstWritten='%s'"
+" WHERE VolumeName='%s'", dt, mr->VolumeName);
       stat = UPDATE_DB(jcr, mdb, mdb->cmd);
       Dmsg1(400, "Firstwritten stat=%d\n", stat);
    }
@@ -286,37 +286,37 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
       localtime_r(&ttime, &tm);
       strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
       Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' "
-           "WHERE VolumeName='%s'", dt, mr->VolumeName);
+          "WHERE VolumeName='%s'", dt, mr->VolumeName);
       stat = UPDATE_DB(jcr, mdb, mdb->cmd);
    }
-   
+
    if (mr->LastWritten != 0) {
       ttime = mr->LastWritten;
       localtime_r(&ttime, &tm);
       strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
 
       Mmsg(mdb->cmd, "UPDATE Media SET VolJobs=%u,"
-           "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u,"
-           "VolWrites=%u,MaxVolBytes=%s,LastWritten='%s',VolStatus='%s',"
-           "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s "
-           " WHERE VolumeName='%s'",
+          "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u,"
+          "VolWrites=%u,MaxVolBytes=%s,LastWritten='%s',VolStatus='%s',"
+          "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s "
+          " WHERE VolumeName='%s'",
           mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
-          mr->VolMounts, mr->VolErrors, mr->VolWrites, 
-          edit_uint64(mr->MaxVolBytes, ed2), dt, 
-          mr->VolStatus, mr->Slot, mr->InChanger, 
+          mr->VolMounts, mr->VolErrors, mr->VolWrites,
+          edit_uint64(mr->MaxVolBytes, ed2), dt,
+          mr->VolStatus, mr->Slot, mr->InChanger,
           edit_uint64(mr->VolReadTime, ed3),
           edit_uint64(mr->VolWriteTime, ed4),
           mr->VolumeName);
    } else {
       Mmsg(mdb->cmd, "UPDATE Media SET VolJobs=%u,"
-           "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u,"
-           "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s',"
-           "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s "
-           " WHERE VolumeName='%s'",
+          "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u,"
+          "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s',"
+          "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s "
+          " WHERE VolumeName='%s'",
           mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
-          mr->VolMounts, mr->VolErrors, mr->VolWrites, 
-          edit_uint64(mr->MaxVolBytes, ed2), 
-          mr->VolStatus, mr->Slot, mr->InChanger, 
+          mr->VolMounts, mr->VolErrors, mr->VolWrites,
+          edit_uint64(mr->MaxVolBytes, ed2),
+          mr->VolStatus, mr->Slot, mr->InChanger,
           edit_uint64(mr->VolReadTime, ed3),
           edit_uint64(mr->VolWriteTime, ed4),
           mr->VolumeName);
@@ -333,36 +333,36 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    return stat;
 }
 
-/* 
+/*
  * Update the Media Record Default values from Pool
  *
  * Returns: 0 on failure
  *         numrows on success
  */
 int
-db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) 
+db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
    int stat;
    char ed1[30], ed2[30], ed3[30];
-       
+
 
    db_lock(mdb);
    if (mr->VolumeName[0]) {
       Mmsg(mdb->cmd, "UPDATE Media SET "
-           "Recycle=%d,VolRetention=%s,VolUseDuration=%s,"
-           "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s"
-           " WHERE VolumeName='%s'",
-          mr->Recycle,edit_uint64(mr->VolRetention, ed1), 
+          "Recycle=%d,VolRetention=%s,VolUseDuration=%s,"
+          "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s"
+          " WHERE VolumeName='%s'",
+          mr->Recycle,edit_uint64(mr->VolRetention, ed1),
           edit_uint64(mr->VolUseDuration, ed2),
           mr->MaxVolJobs, mr->MaxVolFiles,
           edit_uint64(mr->VolBytes, ed3),
           mr->VolumeName);
    } else {
       Mmsg(mdb->cmd, "UPDATE Media SET "
-           "Recycle=%d,VolRetention=%s,VolUseDuration=%s,"
-           "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s"
-           " WHERE PoolId=%u",
-          mr->Recycle,edit_uint64(mr->VolRetention, ed1), 
+          "Recycle=%d,VolRetention=%s,VolUseDuration=%s,"
+          "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s"
+          " WHERE PoolId=%u",
+          mr->Recycle,edit_uint64(mr->VolRetention, ed1),
           edit_uint64(mr->VolUseDuration, ed2),
           mr->MaxVolJobs, mr->MaxVolFiles,
           edit_uint64(mr->VolBytes, ed3),
@@ -378,18 +378,18 @@ db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 }
 
 
-/* 
+/*
  * If we have a non-zero InChanger, ensure that no other Media
  *  record has InChanger set on the same Slot.
  *
  * This routine assumes the database is already locked.
  */
 void
-db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) 
+db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
    if (mr->InChanger != 0 && mr->Slot != 0) {
       Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE "
-           "Slot=%d AND PoolId=%u AND MediaId!=%u", 
+          "Slot=%d AND PoolId=%u AND MediaId!=%u",
            mr->Slot, mr->PoolId, mr->MediaId);
       Dmsg1(400, "%s\n", mdb->cmd);
       UPDATE_DB(jcr, mdb, mdb->cmd);
index f65414bf4a77a62c0fc78227539d6923ddf83ce9..c0398f9aa8f52dc6658f849eb3fa31103c4dc8ea 100644 (file)
@@ -60,7 +60,7 @@ int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
  */
 B_DB *
 db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
-                const char *db_address, int db_port, const char *db_socket, 
+                const char *db_address, int db_port, const char *db_socket,
                 int mult_db_connections)
 {
    B_DB *mdb;
@@ -70,7 +70,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char
    if (!mult_db_connections) {
       for (mdb=NULL; (mdb=(B_DB *)qnext(&db_list, &mdb->bq)); ) {
         if (strcmp(mdb->db_name, db_name) == 0) {
-            Dmsg2(300, "DB REopen %d %s\n", mdb->ref_count, db_name);
+           Dmsg2(300, "DB REopen %d %s\n", mdb->ref_count, db_name);
            mdb->ref_count++;
            V(mutex);
            return mdb;                  /* already open */
@@ -81,7 +81,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char
    mdb = (B_DB *) malloc(sizeof(B_DB));
    memset(mdb, 0, sizeof(B_DB));
    mdb->db_name = bstrdup(db_name);
-   mdb->have_insert_id = TRUE; 
+   mdb->have_insert_id = TRUE;
    mdb->errmsg = get_pool_memory(PM_EMSG); /* get error message buffer */
    *mdb->errmsg = 0;
    mdb->cmd = get_pool_memory(PM_EMSG);    /* get command buffer */
@@ -119,21 +119,21 @@ db_open_database(JCR *jcr, B_DB *mdb)
    mdb->connected = FALSE;
 
    if ((errstat=rwl_init(&mdb->lock)) != 0) {
-      Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), 
+      Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"),
            strerror(errstat));
       V(mutex);
       return 0;
    }
 
    /* open the database */
-   len = strlen(working_directory) + strlen(mdb->db_name) + 5; 
+   len = strlen(working_directory) + strlen(mdb->db_name) + 5;
    db_name = (char *)malloc(len);
    strcpy(db_name, working_directory);
    strcat(db_name, "/");
    strcat(db_name, mdb->db_name);
    strcat(db_name, ".db");
    if (stat(db_name, &statbuf) != 0) {
-      Mmsg1(&mdb->errmsg, _("Database %s does not exist, please create it.\n"), 
+      Mmsg1(&mdb->errmsg, _("Database %s does not exist, please create it.\n"),
         db_name);
       free(db_name);
       V(mutex);
@@ -145,10 +145,10 @@ db_open_database(JCR *jcr, B_DB *mdb)
        &mdb->sqlite_errmsg);         /* error message */
 
    Dmsg0(300, "sqlite_open\n");
-  
+
    if (mdb->db == NULL) {
       Mmsg2(&mdb->errmsg, _("Unable to open Database=%s. ERR=%s\n"),
-         db_name, mdb->sqlite_errmsg ? mdb->sqlite_errmsg : _("unknown"));
+        db_name, mdb->sqlite_errmsg ? mdb->sqlite_errmsg : _("unknown"));
       free(db_name);
       V(mutex);
       return 0;
@@ -177,7 +177,7 @@ db_close_database(JCR *jcr, B_DB *mdb)
       if (mdb->connected && mdb->db) {
         sqlite_close(mdb->db);
       }
-      rwl_destroy(&mdb->lock);      
+      rwl_destroy(&mdb->lock);
       free_pool_memory(mdb->errmsg);
       free_pool_memory(mdb->cmd);
       free_pool_memory(mdb->cached_path);
@@ -228,7 +228,7 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index)
 
    db_unlock(mdb);
    return 1;
-}   
+}
 
 
 /*
@@ -248,12 +248,12 @@ db_escape_string(char *snew, char *old, int len)
    while (len--) {
       switch (*o) {
       case '\'':
-         *n++ = '\'';
-         *n++ = '\'';
+        *n++ = '\'';
+        *n++ = '\'';
         o++;
         break;
       case 0:
-         *n++ = '\\';
+        *n++ = '\\';
         *n++ = 0;
         o++;
         break;
@@ -270,12 +270,12 @@ struct rh_data {
    void *ctx;
 };
 
-/*  
- * Convert SQLite's callback into Bacula DB callback  
+/*
+ * Convert SQLite's callback into Bacula DB callback
  */
 static int sqlite_result(void *arh_data, int num_fields, char **rows, char **col_names)
 {
-   struct rh_data *rh_data = (struct rh_data *)arh_data;   
+   struct rh_data *rh_data = (struct rh_data *)arh_data;
 
    if (rh_data->result_handler) {
       (*(rh_data->result_handler))(rh_data->ctx, num_fields, rows);
@@ -312,7 +312,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler
 /*
  * Submit a sqlite query and retrieve all the data
  */
-int my_sqlite_query(B_DB *mdb, char *cmd) 
+int my_sqlite_query(B_DB *mdb, char *cmd)
 {
    int stat;
 
@@ -348,7 +348,7 @@ void my_sqlite_free_table(B_DB *mdb)
       mdb->fields_defined = false;
    }
    sqlite_free_table(mdb->result);
-   mdb->nrow = mdb->ncolumn = 0; 
+   mdb->nrow = mdb->ncolumn = 0;
 }
 
 void my_sqlite_field_seek(B_DB *mdb, int field)
index fe242c256b332af2c63ed57bb76750407d618e6d..7cedabb5c17b2983957d9810595116688aa3f79e 100644 (file)
@@ -25,7 +25,7 @@
 
    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., 59 Temple Place - Suite 330, Boston, 
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
    MA 02111-1307, USA.
  */
 
@@ -35,7 +35,7 @@
 
 
 void senditf(const char *fmt, ...);
-void sendit(const char *buf); 
+void sendit(const char *buf);
 
 /* Commands sent to Director */
 static char hello[]    = "Hello %s calling\n";
@@ -55,7 +55,7 @@ int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons)
    char bashed_name[MAX_NAME_LENGTH];
    char *password;
 
-   /* 
+   /*
     * Send my name to the Director then do authentication
     */
    if (cons) {
@@ -70,11 +70,11 @@ int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons)
    btimer_t *tid = start_bsock_timer(dir, 60 * 5);
    bnet_fsend(dir, hello, bashed_name);
 
-   if (!cram_md5_get_auth(dir, password, ssl_need) || 
+   if (!cram_md5_get_auth(dir, password, ssl_need) ||
        !cram_md5_auth(dir, password, ssl_need)) {
       stop_bsock_timer(tid);
       sendit( _("Director authorization problem.\n"
-            "Most likely the passwords do not agree.\n"     
+           "Most likely the passwords do not agree.\n"
        "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"));
       return 0;
    }
index 889400b0a90313e0df48a0e33c574d4aed64f49c..19f10bde3fda4567e31709a1439e2f57d1f84c84 100755 (executable)
@@ -1,12 +1,12 @@
-/*       
-      Generalized console input/output handler                    
+/*
+      Generalized console input/output handler
       A maintanable replacement for readline()
 
         Updated for Bacula, Kern Sibbald, December MMIII
 
       This code is in part derived from code that I wrote in
       1981, so some of it is a bit old and could use a cleanup.
-        
+
 */
 /*
    Copyright (C) 1981-2004 Kern Sibbald and John Walker
@@ -29,7 +29,7 @@
 
  */
 
-/* 
+/*
  * UTF-8
  *  If the top bit of a UTF-8 string is 0 (8 bits), then it
  *    is a normal ASCII character.
@@ -45,7 +45,7 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <string.h>
-#include <ctype.h> 
+#include <ctype.h>
 #else
 
 /* We are in Bacula */
@@ -243,10 +243,10 @@ void con_term();
 void trapctlc();
 int usrbrk();
 void clrbrk();
-    
+
 void con_init(FILE *input)
 {
-   atexit(con_term); 
+   atexit(con_term);
    rawmode(input);
    trapctlc();
 }
@@ -313,7 +313,7 @@ char *bstrncpy(char *dest, const char *src, int maxlen)
 static unsigned do_smap(unsigned c)
 {
     char str[MAX_STAB];
-    int len = 0; 
+    int len = 0;
     stab_t *tstab;
     int i, found;
     unsigned cm;
@@ -362,7 +362,7 @@ static void dump_stab()
          for (j=0; j<tstab->len; j++) {
             c = tstab->str[j];
             if (c < 0x20 || c > 0x7F) {
-                sprintf(buf, " 0x%x ", c);
+               sprintf(buf, " 0x%x ", c);
                t_send(buf);
             } else {
                buf[0] = c;
@@ -370,7 +370,7 @@ static void dump_stab()
                t_sendl(buf, 1);
             }
          }
-          sprintf(buf, " func=%d len=%d\n\r", tstab->func, tstab->len);
+         sprintf(buf, " func=%d len=%d\n\r", tstab->func, tstab->len);
          t_send(buf);
        }
     }
@@ -384,7 +384,7 @@ static void add_smap(char *str, int func)
 {
    stab_t *tstab;
    int len;
-  
+
    if (!str) {
       return;
    }
@@ -405,7 +405,7 @@ static void add_smap(char *str, int func)
    }
    tstab->next = stab[tstab->len-1];
    stab[tstab->len-1] = tstab;
-/* printf("Add_smap tstab=%x len=%d func=%d tstab->next=%x\n\r", tstab, len, 
+/* printf("Add_smap tstab=%x len=%d func=%d tstab->next=%x\n\r", tstab, len,
          func, tstab->next); */
 
 }
@@ -460,7 +460,7 @@ input_line(char *string, int length)
        }
        switch (c=input_char()) {
        case F_RETURN:               /* CR */
-           t_sendl("\r\n", 2);       /* yes, print it and */
+          t_sendl("\r\n", 2);       /* yes, print it and */
           goto done;                /* get out */
        case F_CLRSCRN:              /* clear screen */
          asclrs();
@@ -496,7 +496,7 @@ input_line(char *string, int length)
           backup(curline);
           delchr(1, curline, sizeof(curline));
           if (cp == 0) {
-              t_char(' ');
+             t_char(' ');
              t_char(0x8);
           }
           break;
@@ -534,7 +534,7 @@ input_line(char *string, int length)
           t_clrline(0, t_width);     /* erase line */
           cp = 0;
           cl = 0;                   /* reset cursor counter */
-           t_char(' ');
+          t_char(' ');
           t_char(0x8);
           break;
        case F_SOL:
@@ -582,7 +582,7 @@ input_line(char *string, int length)
               curline[cp++] = c;    /* store character in line being built */
               t_char(c);      /* echo character to terminal */
               while (more--) {
-                 c= input_char();  
+                 c= input_char();
                  insert_hole(curline, sizeof(curline));
                  curline[cp++] = c;    /* store character in line being built */
                  t_char(c);      /* echo character to terminal */
@@ -670,7 +670,7 @@ forward(char *str, int str_len)
 }
 
 /* How many characters under the cursor */
-static int 
+static int
 char_count(int cptr, char *str)
 {
    int cnt = 1;
@@ -689,7 +689,7 @@ char_count(int cptr, char *str)
 
 /* Backup cursor keeping characters under it */
 static void
-backup(char *str) 
+backup(char *str)
 {
     if (cp == 0) {
        return;
@@ -703,7 +703,7 @@ backup(char *str)
 
 /* Delete the character under the cursor */
 static void
-delchr(int del, char *curline, int line_len) 
+delchr(int del, char *curline, int line_len)
 {
    int i, cnt;
 
@@ -873,7 +873,7 @@ dump(struct lstr *ptr, char *msg)
     printf("%s buf=%x nextl=%x prevl=%x len=%d used=%d\n",
        msg,ptr,ptr->nextl,ptr->prevl,ptr->len,ptr->used);
     if (ptr->used)
-        printf("line=%s\n",&ptr->line);
+       printf("line=%s\n",&ptr->line);
 }
 #endif /* DEBUGOUT */
 
@@ -906,7 +906,7 @@ t_clrline(int pos, int width)
     asclrl(pos, width);          /* clear to end of line */
 }
 
-/* Helper function to add string preceded by 
+/* Helper function to add string preceded by
  *  ESC to smap table */
 static void add_esc_smap(const char *str, int func)
 {
@@ -936,11 +936,11 @@ static void rawmode(FILE *input)
       exit(1);
    }
    old_term_params_set = true;
-   t = old_term_params;                        
+   t = old_term_params;
    t.c_cc[VMIN] = 1; /* satisfy read after 1 char */
    t.c_cc[VTIME] = 0;
-   t.c_iflag &= ~(BRKINT | IGNPAR | PARMRK | INPCK | 
-                 ISTRIP | ICRNL | IXON | IXOFF | INLCR | IGNCR);     
+   t.c_iflag &= ~(BRKINT | IGNPAR | PARMRK | INPCK |
+                 ISTRIP | ICRNL | IXON | IXOFF | INLCR | IGNCR);
    t.c_iflag |= IGNBRK;
    t.c_oflag |= ONLCR;
    t.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL | ICANON |
@@ -955,7 +955,7 @@ static void rawmode(FILE *input)
    signal(SIGHUP, SIG_IGN);
 // signal(SIGSTOP, SIG_IGN);
    signal(SIGINT, sigintcatcher);
-   signal(SIGWINCH, SIG_IGN);  
+   signal(SIGWINCH, SIG_IGN);
    signal(SIGQUIT, SIG_IGN);
    signal(SIGCHLD, SIG_IGN);
 // signal(SIGTSTP, SIG_IGN);
@@ -1054,9 +1054,9 @@ static unsigned t_getch(void)
    if (read(0, &c, 1) != 1) {
       c = 0;
    }
-   return (unsigned)c;  
+   return (unsigned)c;
 }
-    
+
 /* Send message to terminal - primitive routine */
 void
 t_sendl(const char *msg, int len)
@@ -1116,7 +1116,7 @@ void trapctlc()
 
 
 /* ASCLRL() -- Clear to end of line from current position */
-static void asclrl(int pos, int width) 
+static void asclrl(int pos, int width)
 {
    int i;
 
@@ -1134,7 +1134,7 @@ static void asclrl(int pos, int width)
    for (i=1; i<=width-pos+1; i++)    /* backspace to original position */
        t_char(0x8);
    return;
-  
+
 }
 
 
@@ -1143,10 +1143,10 @@ static void ascurs(int y, int x)
 {
    t_send((char *)tgoto(t_cm, x, y));
 }
-                                                                                       
+
 
 /* ASCLRS -- Clear whole screen */
-static void asclrs() 
+static void asclrs()
 {
    ascurs(0,0);
    t_send(t_cs);
index 73989938d30c6bd1d590a448e4e7d6bfbad39710..5db974b4807734b91896b6d256a2940dc0f417f6 100644 (file)
 #ifdef HAVE_CONIO
 #include "conio.h"
 #else
-#define con_init(x) 
+#define con_init(x)
 #define con_term()
 #define con_set_zed_keys();
 #define trapctlc()
 #define clrbrk()
-#define usrbrk() 0  
+#define usrbrk() 0
 #endif
 
 #ifdef HAVE_WIN32
@@ -47,7 +47,7 @@
 #define isatty(fd) (fd==0)
 DWORD  g_platform_id = VER_PLATFORM_WIN32_WINDOWS;
 #endif
+
 /* Exported variables */
 
 #ifdef HAVE_CYGWIN
@@ -77,7 +77,7 @@ extern "C" void got_sigtin(int sig);
 /* Static variables */
 static char *configfile = NULL;
 static BSOCK *UA_sock = NULL;
-static DIRRES *dir; 
+static DIRRES *dir;
 static FILE *output = stdout;
 static bool tee = false;                 /* output to output and stdout */
 static bool stop = false;
@@ -109,32 +109,32 @@ static void usage()
 "       -dnn        set debug level to nn\n"
 "       -s          no signals\n"
 "       -t          test - read configuration and exit\n"
-"       -?          print this message.\n"  
+"       -?          print this message.\n"
 "\n"), HOST_OS, DISTNAME, DISTVER);
 }
 
 
-extern "C" 
+extern "C"
 void got_sigstop(int sig)
 {
    stop = true;
 }
 
-extern "C" 
+extern "C"
 void got_sigcontinue(int sig)
 {
    stop = false;
 }
 
-extern "C" 
-void got_sigtout(int sig) 
+extern "C"
+void got_sigtout(int sig)
 {
 // printf("Got tout\n");
 }
 
-extern "C" 
+extern "C"
 void got_sigtin(int sig)
-{   
+{
 // printf("Got tin\n");
 }
 
@@ -148,7 +148,7 @@ static int zed_keyscmd(FILE *input, BSOCK *UA_sock)
 /*
  * These are the @command
  */
-struct cmdstruct { const char *key; int (*func)(FILE *input, BSOCK *UA_sock); const char *help; }; 
+struct cmdstruct { const char *key; int (*func)(FILE *input, BSOCK *UA_sock); const char *help; };
 static struct cmdstruct commands[] = {
  { N_("input"),      inputcmd,     _("input from file")},
  { N_("output"),     outputcmd,    _("output to file")},
@@ -199,18 +199,18 @@ static int do_a_command(FILE *input, BSOCK *UA_sock)
 }
 
 
-static void read_and_process_input(FILE *input, BSOCK *UA_sock) 
+static void read_and_process_input(FILE *input, BSOCK *UA_sock)
 {
    const char *prompt = "*";
    bool at_prompt = false;
    int tty_input = isatty(fileno(input));
    int stat;
 
-   for ( ;; ) { 
+   for ( ;; ) {
       if (at_prompt) {                /* don't prompt multiple times */
-         prompt = "";
+        prompt = "";
       } else {
-         prompt = "*";
+        prompt = "*";
         at_prompt = true;
       }
       if (tty_input) {
@@ -239,15 +239,15 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
       if (stat < 0) {
         break;                       /* error or interrupt */
       } else if (stat == 0) {        /* timeout */
-         if (strcmp(prompt, "*") == 0) {
-            bnet_fsend(UA_sock, ".messages");
+        if (strcmp(prompt, "*") == 0) {
+           bnet_fsend(UA_sock, ".messages");
         } else {
            continue;
         }
       } else {
         at_prompt = FALSE;
         /* @ => internal command for us */
-         if (UA_sock->msg[0] == '@') {
+        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;
@@ -264,7 +264,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
       while ((stat = bnet_recv(UA_sock)) >= 0) {
         if (at_prompt) {
            if (!stop) {
-               sendit("\n");
+              sendit("\n");
            }
            at_prompt = false;
         }
@@ -287,7 +287,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
         if (UA_sock->msglen == BNET_PROMPT) {
            at_prompt = true;
         }
-         Dmsg1(100, "Got poll %s\n", bnet_sig_to_ascii(UA_sock));
+        Dmsg1(100, "Got poll %s\n", bnet_sig_to_ascii(UA_sock));
       }
    }
 }
@@ -342,7 +342,7 @@ int main(int argc, char *argv[])
         usage();
         con_term();
         exit(1);
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -382,8 +382,8 @@ int main(int argc, char *argv[])
    UnlockRes();
    if (ndir == 0) {
       con_term();
-      Emsg1(M_ERROR_TERM, 0, _("No Director resource defined in %s\n\
-Without that I don't how to speak to the Director :-(\n"), configfile);
+      Emsg1(M_ERROR_TERM, 0, _("No Director resource defined in %s\n"
+"Without that I don't how to speak to the Director :-(\n"), configfile);
    }
 
    if (test_config) {
@@ -404,7 +404,7 @@ try_again:
       LockRes();
       ndir = 0;
       foreach_res(dir, R_DIRECTOR) {
-         senditf( _("%d  %s at %s:%d\n"), 1+ndir++, dir->hdr.name, dir->address,
+        senditf( _("%d  %s at %s:%d\n"), 1+ndir++, dir->hdr.name, dir->address,
            dir->DIRport);
       }
       UnlockRes();
@@ -414,7 +414,7 @@ try_again:
       }
       item = atoi(UA_sock->msg);
       if (item < 0 || item > ndir) {
-         senditf(_("You must enter a number between 1 and %d\n"), ndir);
+        senditf(_("You must enter a number between 1 and %d\n"), ndir);
         goto try_again;
       }
       LockRes();
@@ -429,9 +429,9 @@ try_again:
       dir = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
       UnlockRes();
    }
-      
+
    senditf(_("Connecting to Director %s:%d\n"), dir->address,dir->DIRport);
-   UA_sock = bnet_connect(NULL, 5, 15, "Director daemon", dir->address, 
+   UA_sock = bnet_connect(NULL, 5, 15, "Director daemon", dir->address,
                          NULL, dir->DIRport, 0);
    if (UA_sock == NULL) {
       terminate_console(0);
@@ -504,7 +504,7 @@ static void terminate_console(int sig)
 #include "history.h"
 
 
-int 
+int
 get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
 {
    char *line;
@@ -559,17 +559,17 @@ wait_for_data(int fd, int sec)
    }
 }
 
-/*     
- * Get next input command from terminal. 
+/*
+ * Get next input command from terminal.
  *
  *   Returns: 1 if got input
  *           0 if timeout
  *          -1 if EOF or error
  */
-int 
+int
 get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
 {
-   int len;  
+   int len;
    if (!stop) {
       if (output == stdout || tee) {
         sendit(prompt);
@@ -579,7 +579,7 @@ again:
    switch (wait_for_data(fileno(input), sec)) {
    case 0:
       return 0;                   /* timeout */
-   case -1: 
+   case -1:
       return -1;                  /* error */
    default:
       len = sizeof_pool_memory(sock->msg) - 1;
@@ -629,9 +629,9 @@ static int inputcmd(FILE *input, BSOCK *UA_sock)
    }
    fd = fopen(argk[1], "r");
    if (!fd) {
-      senditf(_("Cannot open file %s for input. ERR=%s\n"), 
+      senditf(_("Cannot open file %s for input. ERR=%s\n"),
         argk[1], strerror(errno));
-      return 1; 
+      return 1;
    }
    read_and_process_input(fd, UA_sock);
    fclose(fd);
@@ -675,9 +675,9 @@ static int do_outputcmd(FILE *input, BSOCK *UA_sock)
    }
    fd = fopen(argk[1], mode);
    if (!fd) {
-      senditf(_("Cannot open file %s for output. ERR=%s\n"), 
+      senditf(_("Cannot open file %s for output. ERR=%s\n"),
         argk[1], strerror(errno));
-      return 1; 
+      return 1;
    }
    output = fd;
    return 1;
@@ -726,18 +726,18 @@ void sendit(const char *buf)
 {
 #ifdef xHAVE_CONIO
     if (output == stdout || tee) {
-       char *p, *q;    
+       char *p, *q;
        /*
-        * Here, we convert every \n into \r\n because the
-       *  terminal is in raw mode when we are using 
+       * Here, we convert every \n into \r\n because the
+       *  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);
          }
-          t_sendl("\r\n", 2);
-          q = ++p;                    /* point after \n */
+         t_sendl("\r\n", 2);
+         q = ++p;                    /* point after \n */
        }
        if (*q) {
          t_send(q);
index 83d0f227916450e1be39e20e4eec1da5ce3547e6..54b179c94b5b5bac0d31b420285866ca3c3763ec 100644 (file)
@@ -7,7 +7,7 @@
  *
  *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
  *
- *   2. The generic config  scanner in lib/parse_config.c and 
+ *   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,
@@ -69,9 +69,9 @@ int  res_all_size = sizeof(res_all);
 #endif
 
 /* Definition of records permitted within each
- * resource with the routine to process the record 
+ * resource with the routine to process the record
  * information.
- */ 
+ */
 
 /*  Console "globals" */
 static RES_ITEM cons_items[] = {
@@ -81,7 +81,7 @@ static RES_ITEM cons_items[] = {
    {"historyfile", store_dir,      ITEM(res_cons.hist_file), 0, 0, 0},
    {"requiressl",  store_yesno,    ITEM(res_cons.require_ssl), 1, ITEM_DEFAULT, 0},
    {"password",    store_password, ITEM(res_cons.password), 0, ITEM_REQUIRED, 0},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
 
@@ -93,15 +93,15 @@ static RES_ITEM dir_items[] = {
    {"address",     store_str,      ITEM(res_dir.address),  0, 0, 0},
    {"password",    store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0},
    {"enablessl",   store_yesno,    ITEM(res_dir.enable_ssl), 1, ITEM_DEFAULT, 0},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
-/* 
- * This is the master resource definition.  
+/*
+ * This is the master resource definition.
  * It must have one item for each of the resources.
  */
 RES_TABLE resources[] = {
-   {"console",       cons_items,  R_CONSOLE},        
+   {"console",       cons_items,  R_CONSOLE},
    {"director",      dir_items,   R_DIRECTOR},
    {NULL,           NULL,        0}
 };
@@ -127,7 +127,7 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
             res->res_cons.rc_file, res->res_cons.hist_file);
       break;
    case R_DIRECTOR:
-      printf("Director: name=%s address=%s DIRport=%d\n", reshdr->name, 
+      printf("Director: name=%s address=%s DIRport=%d\n", reshdr->name,
              res->res_dir.address, res->res_dir.DIRport);
       break;
    default:
@@ -138,10 +138,10 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
    }
 }
 
-/* 
- * Free memory of resource.  
+/*
+ * 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 
+ * to other resources as they will be freed when that
  * resource chain is traversed.  Mainly we worry about freeing
  * allocated strings (names).
  */
@@ -192,16 +192,16 @@ void save_resource(int type, RES_ITEM *items, int pass)
 {
    URES *res;
    int rindex = type - r_first;
-   int i, size;    
+   int i, size;
    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.res_dir.hdr.item_present)) {  
-               Emsg2(M_ABORT, 0, "%s item is required in %s resource, but not found.\n",
+           if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
+              Emsg2(M_ABORT, 0, "%s item is required in %s resource, but not found.\n",
                 items[i].name, resources[rindex]);
             }
       }
@@ -220,7 +220,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
            break;
 
         default:
-            Emsg1(M_ERROR, 0, "Unknown resource type %d\n", type);
+           Emsg1(M_ERROR, 0, "Unknown resource type %d\n", type);
            error = 1;
            break;
       }
@@ -263,12 +263,12 @@ void save_resource(int type, RES_ITEM *items, int pass)
         for (next=res_head[rindex]; next->next; next=next->next) {
            if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
               Emsg2(M_ERROR_TERM, 0,
-                  _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
+                 _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
                  resources[rindex].name, res->res_dir.hdr.name);
            }
         }
         next->next = (RES *)res;
-         Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type),
+        Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type),
               res->res_dir.hdr.name);
       }
    }
index 55e5c87c58d763c930457561a653813136802acb..f0b7f7a59cf1b2cbf02bdf5fc7310e5ddd7c6c03 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 /*
- * Resource codes -- they must be sequential for indexing   
+ * Resource codes -- they must be sequential for indexing
  */
 
 enum {
index b26ae18c9480158732bd6968ec79400eabd989c8..f85636ef4ae15cc400470c7e4f4113188fdb0496 100644 (file)
@@ -40,11 +40,11 @@ static void admin_cleanup(JCR *jcr, int TermCode);
 
 /* External functions */
 
-/* 
+/*
  *  Returns:  0 on failure
  *           1 on success
  */
-int do_admin(JCR *jcr) 
+int do_admin(JCR *jcr)
 {
 
    jcr->jr.JobId = jcr->JobId;
@@ -76,9 +76,9 @@ static void admin_cleanup(JCR *jcr, int TermCode)
    set_jcr_job_status(jcr, TermCode);
 
    update_job_end_record(jcr);       /* update database */
-   
+
    if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
-      Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), 
+      Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"),
         db_strerror(jcr->db));
       set_jcr_job_status(jcr, JS_ErrorTerminated);
    }
@@ -90,7 +90,7 @@ static void admin_cleanup(JCR *jcr, int TermCode)
       break;
    case JS_FatalError:
    case JS_ErrorTerminated:
-      term_msg = _("*** Admin Error ***"); 
+      term_msg = _("*** Admin Error ***");
       msg_type = M_ERROR;         /* Generate error message */
       break;
    case JS_Canceled:
@@ -104,12 +104,12 @@ static void admin_cleanup(JCR *jcr, int TermCode)
    bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime);
    bstrftime(edt, sizeof(edt), jcr->jr.EndTime);
 
-   Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\
-  JobId:                  %d\n\
-  Job:                    %s\n\
-  Start time:             %s\n\
-  End time:               %s\n\
-  Termination:            %s\n\n"),
+   Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
+"  JobId:                  %d\n"
+"  Job:                    %s\n"
+"  Start time:             %s\n"
+"  End time:               %s\n"
+"  Termination:            %s\n\n"),
        edt,
        jcr->jr.JobId,
        jcr->jr.Job,
@@ -118,4 +118,4 @@ static void admin_cleanup(JCR *jcr, int TermCode)
        term_msg);
 
    Dmsg0(100, "Leave admin_cleanup()\n");
-}   
+}
index 4ad863a3eac2c5b89e540747427f311be4ff03c6..4ec64b41bdcc0ae3cd9ec20064735da6df7d9bdb 100644 (file)
@@ -52,14 +52,14 @@ static char Dir_sorry[]  = "1999 You are not authorized.\n";
 /*
  * Authenticate Storage daemon connection
  */
-bool authenticate_storage_daemon(JCR *jcr, STORE *store) 
+bool authenticate_storage_daemon(JCR *jcr, STORE *store)
 {
    BSOCK *sd = jcr->store_bsock;
    char dirname[MAX_NAME_LENGTH];
    int ssl_need = BNET_SSL_NONE;
    bool get_auth, auth = false;
 
-   /* 
+   /*
     * Send my name to the Storage daemon then do authentication
     */
    bstrncpy(dirname, director->hdr.name, sizeof(dirname));
@@ -72,11 +72,11 @@ bool authenticate_storage_daemon(JCR *jcr, STORE *store)
       Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to Storage daemon. ERR=%s\n"), bnet_strerror(sd));
       return 0;
    }
-   get_auth = cram_md5_get_auth(sd, store->password, ssl_need);   
+   get_auth = cram_md5_get_auth(sd, store->password, ssl_need);
    if (get_auth) {
-      auth = cram_md5_auth(sd, store->password, ssl_need);  
+      auth = cram_md5_auth(sd, store->password, ssl_need);
       if (!auth) {
-         Dmsg1(50, "cram_auth failed for %s\n", sd->who);
+        Dmsg1(50, "cram_auth failed for %s\n", sd->who);
       }
    } else {
       Dmsg1(50, "cram_get_auth failed for %s\n", sd->who);
@@ -85,11 +85,11 @@ bool authenticate_storage_daemon(JCR *jcr, STORE *store)
       stop_bsock_timer(tid);
       Dmsg0(50, _("Director and Storage daemon passwords or names not the same.\n"));
       Jmsg0(jcr, M_FATAL, 0,
-            _("Unable to authenticate with Storage daemon. Possible causes:\n"
-            "Passwords or names not the same or\n"
-            "Maximum Concurrent Jobs exceeded on the SD or\n"
-            "SD networking messed up (restart daemon).\n"
-            "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"));
+           _("Unable to authenticate with Storage daemon. Possible causes:\n"
+           "Passwords or names not the same or\n"
+           "Maximum Concurrent Jobs exceeded on the SD or\n"
+           "SD networking messed up (restart daemon).\n"
+           "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"));
       return 0;
    }
    Dmsg1(116, ">stored: %s", sd->msg);
@@ -119,7 +119,7 @@ int authenticate_file_daemon(JCR *jcr)
    int ssl_need = BNET_SSL_NONE;
    bool get_auth, auth = false;
 
-   /* 
+   /*
     * Send my name to the File daemon then do authentication
     */
    bstrncpy(dirname, director->hdr.name, sizeof(dirname));
@@ -131,11 +131,11 @@ int authenticate_file_daemon(JCR *jcr)
       Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to File daemon. ERR=%s\n"), bnet_strerror(fd));
       return 0;
    }
-   get_auth = cram_md5_get_auth(fd, jcr->client->password, ssl_need);  
+   get_auth = cram_md5_get_auth(fd, jcr->client->password, ssl_need);
    if (get_auth) {
-      auth = cram_md5_auth(fd, jcr->client->password, ssl_need);  
+      auth = cram_md5_auth(fd, jcr->client->password, ssl_need);
       if (!auth) {
-         Dmsg1(50, "cram_auth failed for %s\n", fd->who);
+        Dmsg1(50, "cram_auth failed for %s\n", fd->who);
       }
    } else {
       Dmsg1(50, "cram_get_auth failed for %s\n", fd->who);
@@ -144,11 +144,11 @@ int authenticate_file_daemon(JCR *jcr)
       stop_bsock_timer(tid);
       Dmsg0(50, _("Director and File daemon passwords or names not the same.\n"));
       Jmsg(jcr, M_FATAL, 0,
-            _("Unable to authenticate with File daemon. Possible causes:\n"
-            "Passwords or names not the same or\n"
-            "Maximum Concurrent Jobs exceeded on the FD or\n"
-            "FD networking messed up (restart daemon).\n"
-            "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"));
+           _("Unable to authenticate with File daemon. Possible causes:\n"
+           "Passwords or names not the same or\n"
+           "Maximum Concurrent Jobs exceeded on the FD or\n"
+           "FD networking messed up (restart daemon).\n"
+           "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"));
       return 0;
    }
    Dmsg1(116, ">filed: %s", fd->msg);
@@ -170,14 +170,14 @@ int authenticate_file_daemon(JCR *jcr)
    return 1;
 }
 
-/********************************************************************* 
+/*********************************************************************
  *
  */
-int authenticate_user_agent(UAContext *uac) 
+int authenticate_user_agent(UAContext *uac)
 {
    char name[MAX_NAME_LENGTH];
    int ssl_need = BNET_SSL_NONE;
-   bool ok;    
+   bool ok;
    BSOCK *ua = uac->UA_sock;
 
 //  Emsg4(M_INFO, 0, _("UA Hello from %s:%s:%d is invalid. Len=%d\n"), ua->who,
@@ -199,7 +199,7 @@ int authenticate_user_agent(UAContext *uac)
       ok = cram_md5_auth(ua, director->password, ssl_need) &&
           cram_md5_get_auth(ua, director->password, ssl_need);
    } else {
-      unbash_spaces(name); 
+      unbash_spaces(name);
       CONRES *cons = (CONRES *)GetResWithName(R_CONSOLE, name);
       if (cons) {
         ok = cram_md5_auth(ua, cons->password, ssl_need) &&
index 663ed00c983bc591dc1b9102ff7c750e8e7e818c..0b7c2a863a7d0976fb05163b3e37a3e27d320272 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- *   Bacula Director -- Automatic Pruning 
+ *   Bacula Director -- Automatic Pruning
  *     Applies retention periods
  *
  *     Kern Sibbald, May MMII
@@ -60,7 +60,7 @@ int do_autoprune(JCR *jcr)
    } else {
       pruned = false;
    }
-  
+
    if (jcr->job->PruneFiles || jcr->client->AutoPrune) {
       Jmsg(jcr, M_INFO, 0, _("Begin pruning Files.\n"));
       prune_files(ua, client);
@@ -71,7 +71,7 @@ int do_autoprune(JCR *jcr)
    }
 
    free_ua_context(ua);
-   return 1;   
+   return 1;
 }
 
 /*
@@ -110,7 +110,7 @@ int prune_volumes(JCR *jcr)
    for (i=0; i<num_ids; i++) {
       mr.MediaId = ids[i];
       if (!db_get_media_record(jcr, jcr->db, &mr)) {
-         Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
+        Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
         continue;
       }
       /* Prune only Volumes from current Pool */
@@ -118,14 +118,14 @@ int prune_volumes(JCR *jcr)
         continue;
       }
       /* Prune only Volumes with status "Full", "Used", or "Append" */
-      if (strcmp(mr.VolStatus, "Full")   == 0 || 
-          strcmp(mr.VolStatus, "Append") == 0 ||
-          strcmp(mr.VolStatus, "Used")   == 0) {
-         Dmsg1(200, "Prune Volume %s\n", mr.VolumeName);
-        stat += prune_volume(ua, &mr); 
-         Dmsg1(200, "Num pruned = %d\n", stat);
+      if (strcmp(mr.VolStatus, "Full")   == 0 ||
+         strcmp(mr.VolStatus, "Append") == 0 ||
+         strcmp(mr.VolStatus, "Used")   == 0) {
+        Dmsg1(200, "Prune Volume %s\n", mr.VolumeName);
+        stat += prune_volume(ua, &mr);
+        Dmsg1(200, "Num pruned = %d\n", stat);
       }
-   }   
+   }
 
 bail_out:
    db_unlock(jcr->db);
index 5ef4d3a572bdc61f074adacc5990edf670374fc8..e3f744bec62919561bccc2d07c07c67f1d77cca6 100644 (file)
@@ -46,7 +46,7 @@ static char storaddr[]  = "storage address=%s port=%d ssl=%d\n";
 static char OKbackup[]   = "2000 OK backup\n";
 static char OKstore[]    = "2000 OK storage\n";
 static char EndJob[]     = "2800 End Job TermCode=%d JobFiles=%u "
-                           "ReadBytes=%" lld " JobBytes=%" lld " Errors=%u\n";
+                          "ReadBytes=%" lld " JobBytes=%" lld " Errors=%u\n";
 
 
 /* Forward referenced functions */
@@ -54,13 +54,13 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
 
 /* External functions */
 
-/* 
+/*
  * Do a backup of the specified FileSet
- *    
+ *
  *  Returns:  0 on failure
  *           1 on success
  */
-int do_backup(JCR *jcr) 
+int do_backup(JCR *jcr)
 {
    char since[MAXSTRING];
    int stat;
@@ -83,23 +83,23 @@ int do_backup(JCR *jcr)
 
    jcr->fname = get_pool_memory(PM_FNAME);
 
-   /* 
-    * Get the Pool record -- first apply any level defined pools  
+   /*
+    * Get the Pool record -- first apply any level defined pools
     */
    switch (jcr->JobLevel) {
    case L_FULL:
       if (jcr->full_pool) {
-        jcr->pool = jcr->full_pool;   
+        jcr->pool = jcr->full_pool;
       }
       break;
    case L_INCREMENTAL:
       if (jcr->inc_pool) {
-        jcr->pool = jcr->inc_pool;   
+        jcr->pool = jcr->inc_pool;
       }
       break;
    case L_DIFFERENTIAL:
       if (jcr->dif_pool) {
-        jcr->pool = jcr->dif_pool;   
+        jcr->pool = jcr->dif_pool;
       }
       break;
    }
@@ -109,11 +109,11 @@ int do_backup(JCR *jcr)
    while (!db_get_pool_record(jcr, jcr->db, &pr)) { /* get by Name */
       /* Try to create the pool */
       if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, 
+        Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name,
            db_strerror(jcr->db));
         goto bail_out;
       } else {
-         Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name);
+        Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name);
       }
    }
    jcr->PoolId = pr.PoolId;              /****FIXME**** this can go away */
@@ -140,7 +140,7 @@ int do_backup(JCR *jcr)
    Dmsg0(110, "Open connection with storage daemon\n");
    set_jcr_job_status(jcr, JS_WaitSD);
    /*
-    * Start conversation with Storage daemon  
+    * Start conversation with Storage daemon
     */
    if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) {
       goto bail_out;
@@ -179,7 +179,7 @@ int do_backup(JCR *jcr)
       goto bail_out;
    }
 
-   /* 
+   /*
     * send Storage daemon address to the File daemon
     */
    store = jcr->store;
@@ -203,7 +203,7 @@ int do_backup(JCR *jcr)
       goto bail_out;
    }
 
-   /* Pickup Job termination data */       
+   /* Pickup Job termination data */
    stat = wait_for_job_termination(jcr);
    backup_cleanup(jcr, stat, since, &fsr);
    return 1;
@@ -217,7 +217,7 @@ bail_out:
  * Here we wait for the File daemon to signal termination,
  *   then we wait for the Storage daemon.  When both
  *   are done, we return the job status.
- * Also used by restore.c 
+ * Also used by restore.c
  */
 int wait_for_job_termination(JCR *jcr)
 {
@@ -234,9 +234,9 @@ int wait_for_job_termination(JCR *jcr)
          &ReadBytes, &JobBytes, &Errors) == 5) {
         fd_ok = true;
         set_jcr_job_status(jcr, jcr->FDJobStatus);
-         Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus);
+        Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus);
       } else {
-         Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"),
+        Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"),
            fd->msg);
       }
       if (job_canceled(jcr)) {
@@ -267,7 +267,7 @@ int wait_for_job_termination(JCR *jcr)
 //   jcr->JobStatus, jcr->SDJobStatus);
 
    /* Return the first error status we find Dir, FD, or SD */
-   if (!fd_ok || is_bnet_error(fd)) {                         
+   if (!fd_ok || is_bnet_error(fd)) {
       jcr->FDJobStatus = JS_ErrorTerminated;
    }
    if (jcr->JobStatus != JS_Terminated) {
@@ -282,7 +282,7 @@ int wait_for_job_termination(JCR *jcr)
 /*
  * Release resources allocated during backup.
  */
-static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr) 
+static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr)
 {
    char sdt[50], edt[50];
    char ec1[30], ec2[30], ec3[30], ec4[30], ec5[30], compress[50];
@@ -299,22 +299,22 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
    set_jcr_job_status(jcr, TermCode);
 
    update_job_end_record(jcr);       /* update database */
-   
+
    if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
-      Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), 
+      Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"),
         db_strerror(jcr->db));
       set_jcr_job_status(jcr, JS_ErrorTerminated);
    }
 
    bstrncpy(mr.VolumeName, jcr->VolumeName, sizeof(mr.VolumeName));
    if (!db_get_media_record(jcr, jcr->db, &mr)) {
-      Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"), 
+      Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"),
         mr.VolumeName, db_strerror(jcr->db));
       set_jcr_job_status(jcr, JS_ErrorTerminated);
    }
 
    /* Now update the bootstrap file if any */
-   if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes && 
+   if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes &&
        jcr->job->WriteBootstrap) {
       FILE *fd;
       BPIPE *bpipe = NULL;
@@ -326,18 +326,18 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
       if (*fname == '|') {
         fname++;
         got_pipe = 1;
-         bpipe = open_bpipe(fname, 0, "w");
+        bpipe = open_bpipe(fname, 0, "w");
         fd = bpipe ? bpipe->wfd : NULL;
       } else {
         /* ***FIXME*** handle BASE */
-         fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+");
+        fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+");
       }
       if (fd) {
         VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId,
                    &VolParams);
         if (VolCount == 0) {
-            Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to "      
-                 "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db));
+           Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to "
+                "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db));
             if (jcr->SDJobFiles != 0) {
                set_jcr_job_status(jcr, JS_ErrorTerminated);
             }
@@ -345,14 +345,14 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
         }
         for (int i=0; i < VolCount; i++) {
            /* Write the record */
-            fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName);
-            fprintf(fd, "VolSessionId=%u\n", jcr->VolSessionId);
-            fprintf(fd, "VolSessionTime=%u\n", jcr->VolSessionTime);
-            fprintf(fd, "VolFile=%u-%u\n", VolParams[i].StartFile,
+           fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName);
+           fprintf(fd, "VolSessionId=%u\n", jcr->VolSessionId);
+           fprintf(fd, "VolSessionTime=%u\n", jcr->VolSessionTime);
+           fprintf(fd, "VolFile=%u-%u\n", VolParams[i].StartFile,
                         VolParams[i].EndFile);
-            fprintf(fd, "VolBlock=%u-%u\n", VolParams[i].StartBlock,
+           fprintf(fd, "VolBlock=%u-%u\n", VolParams[i].StartBlock,
                         VolParams[i].EndBlock);
-            fprintf(fd, "FileIndex=%d-%d\n", VolParams[i].FirstIndex,
+           fprintf(fd, "FileIndex=%d-%d\n", VolParams[i].FirstIndex,
                         VolParams[i].LastIndex);
         }
         if (VolParams) {
@@ -365,8 +365,8 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
         }
       } else {
         berrno be;
-         Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n"
-              "%s: ERR=%s\n"), fname, be.strerror());
+        Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n"
+             "%s: ERR=%s\n"), fname, be.strerror());
         set_jcr_job_status(jcr, JS_ErrorTerminated);
       }
    }
@@ -375,14 +375,14 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
    switch (jcr->JobStatus) {
       case JS_Terminated:
         if (jcr->Errors || jcr->SDErrors) {
-            term_msg = _("Backup OK -- with warnings");
+           term_msg = _("Backup OK -- with warnings");
         } else {
-            term_msg = _("Backup OK");
+           term_msg = _("Backup OK");
         }
         break;
       case JS_FatalError:
       case JS_ErrorTerminated:
-         term_msg = _("*** Backup Error ***"); 
+        term_msg = _("*** Backup Error ***");
         msg_type = M_ERROR;          /* Generate error message */
         if (jcr->store_bsock) {
            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
@@ -392,7 +392,7 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
         }
         break;
       case JS_Canceled:
-         term_msg = _("Backup Canceled");
+        term_msg = _("Backup Canceled");
         if (jcr->store_bsock) {
            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
            if (jcr->SD_msg_chan) {
@@ -402,7 +402,7 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
         break;
       default:
         term_msg = term_code;
-         sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
+        sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
         break;
    }
    bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime);
@@ -420,8 +420,8 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
        *  it is normal.  Or look at it the other way, only for a
        *  normal exit should we complain about this error.
        */
-      if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes) {                               
-         Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
+      if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes) {
+        Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
       }
       jcr->VolumeName[0] = 0;        /* none */
    }
@@ -431,9 +431,9 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
    } else {
       compression = (double)100 - 100.0 * ((double)jcr->JobBytes / (double)jcr->ReadBytes);
       if (compression < 0.5) {
-         bstrncpy(compress, "None", sizeof(compress));
+        bstrncpy(compress, "None", sizeof(compress));
       } else {
-         bsnprintf(compress, sizeof(compress), "%.1f %%", (float)compression);
+        bsnprintf(compress, sizeof(compress), "%.1f %%", (float)compression);
       }
    }
    jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
@@ -441,31 +441,31 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
 
 // bmicrosleep(15, 0);               /* for debugging SIGHUP */
 
-   Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\
-  JobId:                  %d\n\
-  Job:                    %s\n\
-  Backup Level:           %s%s\n\
-  Client:                 %s\n\
-  FileSet:                \"%s\" %s\n\
-  Pool:                   \"%s\"\n\
-  Storage:                \"%s\"\n\
-  Start time:             %s\n\
-  End time:               %s\n\
-  FD Files Written:       %s\n\
-  SD Files Written:       %s\n\
-  FD Bytes Written:       %s\n\
-  SD Bytes Written:       %s\n\
-  Rate:                   %.1f KB/s\n\
-  Software Compression:   %s\n\
-  Volume name(s):         %s\n\
-  Volume Session Id:      %d\n\
-  Volume Session Time:    %d\n\
-  Last Volume Bytes:      %s\n\
-  Non-fatal FD errors:    %d\n\
-  SD Errors:              %d\n\
-  FD termination status:  %s\n\
-  SD termination status:  %s\n\
-  Termination:            %s\n\n"),
+   Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
+"  JobId:                  %d\n"
+"  Job:                    %s\n"
+"  Backup Level:           %s%s\n"
+"  Client:                 %s\n"
+"  FileSet:                \"%s\" %s\n"
+"  Pool:                   \"%s\"\n"
+"  Storage:                \"%s\"\n"
+"  Start time:             %s\n"
+"  End time:               %s\n"
+"  FD Files Written:       %s\n"
+"  SD Files Written:       %s\n"
+"  FD Bytes Written:       %s\n"
+"  SD Bytes Written:       %s\n"
+"  Rate:                   %.1f KB/s\n"
+"  Software Compression:   %s\n"
+"  Volume name(s):         %s\n"
+"  Volume Session Id:      %d\n"
+"  Volume Session Time:    %d\n"
+"  Last Volume Bytes:      %s\n"
+"  Non-fatal FD errors:    %d\n"
+"  SD Errors:              %d\n"
+"  FD termination status:  %s\n"
+"  SD termination status:  %s\n"
+"  Termination:            %s\n\n"),
        edt,
        jcr->jr.JobId,
        jcr->jr.Job,
index 6e6e374c3f7e13fc5f33ed5a0a9021839c7490b8..4545d65504e151de65bed92d217ae493f12a65a1 100644 (file)
@@ -2,7 +2,7 @@
  *
  *   Bacula Director -- Bootstrap Record routines.
  *
- *     BSR (bootstrap record) handling routines split from 
+ *     BSR (bootstrap record) handling routines split from
  *       ua_restore.c July MMIII
  *
  *     Kern Sibbald, July MMII
@@ -39,9 +39,9 @@ void print_bsr(UAContext *ua, RBSR *bsr);
 
 
 /*
- * Create new FileIndex entry for BSR 
+ * Create new FileIndex entry for BSR
  */
-RBSR_FINDEX *new_findex() 
+RBSR_FINDEX *new_findex()
 {
    RBSR_FINDEX *fi = (RBSR_FINDEX *)bmalloc(sizeof(RBSR_FINDEX));
    memset(fi, 0, sizeof(RBSR_FINDEX));
@@ -61,14 +61,14 @@ static void free_findex(RBSR_FINDEX *fi)
  * Our data structures were not designed completely
  *  correctly, so the file indexes cover the full
  *  range regardless of volume. The FirstIndex and LastIndex
- *  passed in here are for the current volume, so when 
+ *  passed in here are for the current volume, so when
  *  writing out the fi, constrain them to those values.
  *
  * We are called here once for each JobMedia record
  *  for each Volume.
  */
-static uint32_t write_findex(UAContext *ua, RBSR_FINDEX *fi, 
-             int32_t FirstIndex, int32_t LastIndex, FILE *fd) 
+static uint32_t write_findex(UAContext *ua, RBSR_FINDEX *fi,
+             int32_t FirstIndex, int32_t LastIndex, FILE *fd)
 {
    uint32_t count = 0;
    for ( ; fi; fi=fi->next) {
@@ -79,10 +79,10 @@ static uint32_t write_findex(UAContext *ua, RBSR_FINDEX *fi,
         findex = fi->findex < FirstIndex ? FirstIndex : fi->findex;
         findex2 = fi->findex2 > LastIndex ? LastIndex : fi->findex2;
         if (findex == findex2) {
-            fprintf(fd, "FileIndex=%d\n", findex);
+           fprintf(fd, "FileIndex=%d\n", findex);
            count++;
         } else {
-            fprintf(fd, "FileIndex=%d-%d\n", findex, findex2);
+           fprintf(fd, "FileIndex=%d-%d\n", findex, findex2);
            count += findex2 - findex + 1;
         }
       }
@@ -94,8 +94,8 @@ static uint32_t write_findex(UAContext *ua, RBSR_FINDEX *fi,
  * Find out if Volume defined with FirstIndex and LastIndex
  *   falls within the range of selected files in the bsr.
  */
-static bool is_volume_selected(RBSR_FINDEX *fi, 
-             int32_t FirstIndex, int32_t LastIndex) 
+static bool is_volume_selected(RBSR_FINDEX *fi,
+             int32_t FirstIndex, int32_t LastIndex)
 {
    if (fi) {
       if ((fi->findex >= FirstIndex && fi->findex <= LastIndex) ||
@@ -115,10 +115,10 @@ static void print_findex(UAContext *ua, RBSR_FINDEX *fi)
    bsendmsg(ua, "fi=0x%lx\n", fi);
    for ( ; fi; fi=fi->next) {
       if (fi->findex == fi->findex2) {
-         bsendmsg(ua, "FileIndex=%d\n", fi->findex);
+        bsendmsg(ua, "FileIndex=%d\n", fi->findex);
 //       Dmsg1(100, "FileIndex=%d\n", fi->findex);
       } else {
-         bsendmsg(ua, "FileIndex=%d-%d\n", fi->findex, fi->findex2);
+        bsendmsg(ua, "FileIndex=%d-%d\n", fi->findex, fi->findex2);
 //       Dmsg2(100, "FileIndex=%d-%d\n", fi->findex, fi->findex2);
       }
    }
@@ -156,14 +156,14 @@ int complete_bsr(UAContext *ua, RBSR *bsr)
       memset(&jr, 0, sizeof(jr));
       jr.JobId = bsr->JobId;
       if (!db_get_job_record(ua->jcr, ua->db, &jr)) {
-         bsendmsg(ua, _("Unable to get Job record. ERR=%s\n"), db_strerror(ua->db));
+        bsendmsg(ua, _("Unable to get Job record. ERR=%s\n"), db_strerror(ua->db));
         return 0;
       }
       bsr->VolSessionId = jr.VolSessionId;
       bsr->VolSessionTime = jr.VolSessionTime;
-      if ((bsr->VolCount=db_get_job_volume_parameters(ua->jcr, ua->db, bsr->JobId, 
+      if ((bsr->VolCount=db_get_job_volume_parameters(ua->jcr, ua->db, bsr->JobId,
           &(bsr->VolParams))) == 0) {
-         bsendmsg(ua, _("Unable to get Job Volume Parameters. ERR=%s\n"), db_strerror(ua->db));
+        bsendmsg(ua, _("Unable to get Job Volume Parameters. ERR=%s\n"), db_strerror(ua->db));
         if (bsr->VolParams) {
            free(bsr->VolParams);
            bsr->VolParams = NULL;
@@ -189,7 +189,7 @@ uint32_t write_bsr_file(UAContext *ua, RBSR *bsr)
    fd = fopen(fname, "w+");
    if (!fd) {
       berrno be;
-      bsendmsg(ua, _("Unable to create bootstrap file %s. ERR=%s\n"), 
+      bsendmsg(ua, _("Unable to create bootstrap file %s. ERR=%s\n"),
         fname, be.strerror());
       goto bail_out;
    }
@@ -237,7 +237,7 @@ bail_out:
 static uint32_t write_bsr(UAContext *ua, RBSR *bsr, FILE *fd)
 {
    uint32_t count = 0;
-   uint32_t total_count = 0; 
+   uint32_t total_count = 0;
    uint32_t LastIndex = 0;
    bool first = true;
    if (bsr) {
@@ -251,19 +251,19 @@ static uint32_t write_bsr(UAContext *ua, RBSR *bsr, FILE *fd)
            bsr->VolParams[i].VolumeName[0] = 0;  /* zap VolumeName */
            continue;
         }
-         fprintf(fd, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName);
-         fprintf(fd, "VolSessionId=%u\n", bsr->VolSessionId);
-         fprintf(fd, "VolSessionTime=%u\n", bsr->VolSessionTime);
+        fprintf(fd, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName);
+        fprintf(fd, "VolSessionId=%u\n", bsr->VolSessionId);
+        fprintf(fd, "VolSessionTime=%u\n", bsr->VolSessionTime);
         if (bsr->VolParams[i].StartFile == bsr->VolParams[i].EndFile) {
-            fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartFile);
+           fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartFile);
         } else {
-            fprintf(fd, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile, 
+           fprintf(fd, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile,
                    bsr->VolParams[i].EndFile);
         }
         if (bsr->VolParams[i].StartBlock == bsr->VolParams[i].EndBlock) {
-            fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartBlock);
+           fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartBlock);
         } else {
-            fprintf(fd, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock,
+           fprintf(fd, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock,
                    bsr->VolParams[i].EndBlock);
         }
 //       Dmsg2(100, "bsr VolParam FI=%u LI=%u\n",
@@ -272,7 +272,7 @@ static uint32_t write_bsr(UAContext *ua, RBSR *bsr, FILE *fd)
         count = write_findex(ua, bsr->fi, bsr->VolParams[i].FirstIndex,
                              bsr->VolParams[i].LastIndex, fd);
         if (count) {
-            fprintf(fd, "Count=%u\n", count);
+           fprintf(fd, "Count=%u\n", count);
         }
         total_count += count;
         /* If the same file is present on two tapes or in two files
@@ -294,12 +294,12 @@ void print_bsr(UAContext *ua, RBSR *bsr)
 {
    if (bsr) {
       for (int i=0; i < bsr->VolCount; i++) {
-         bsendmsg(ua, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName);
-         bsendmsg(ua, "VolSessionId=%u\n", bsr->VolSessionId);
-         bsendmsg(ua, "VolSessionTime=%u\n", bsr->VolSessionTime);
-         bsendmsg(ua, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile, 
+        bsendmsg(ua, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName);
+        bsendmsg(ua, "VolSessionId=%u\n", bsr->VolSessionId);
+        bsendmsg(ua, "VolSessionTime=%u\n", bsr->VolSessionTime);
+        bsendmsg(ua, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile,
                  bsr->VolParams[i].EndFile);
-         bsendmsg(ua, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock,
+        bsendmsg(ua, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock,
                  bsr->VolParams[i].EndBlock);
         print_findex(ua, bsr->fi);
       }
@@ -321,7 +321,7 @@ void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex)
    if (findex == 0) {
       return;                        /* probably a dummy directory */
    }
-   
+
    if (bsr->fi == NULL) {            /* if no FI add one */
       /* This is the first FileIndex item in the chain */
       bsr->fi = new_findex();
@@ -341,7 +341,7 @@ void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex)
 
       if (!nbsr) {                   /* Must add new JobId */
         /* Add new JobId at end of chain */
-        for (nbsr=bsr; nbsr->next; nbsr=nbsr->next) 
+        for (nbsr=bsr; nbsr->next; nbsr=nbsr->next)
            {  }
         nbsr->next = new_bsr();
         nbsr->next->JobId = JobId;
@@ -352,7 +352,7 @@ void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex)
       }
    }
 
-   /* 
+   /*
     * At this point, bsr points to bsr containing this JobId,
     *  and we are sure that there is at least one fi record.
     */
@@ -373,13 +373,13 @@ void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex)
    /* Walk down fi chain and find where to insert insert new FileIndex */
    for ( ; fi; fi=fi->next) {
       if (findex == (fi->findex2 + 1)) {  /* extend up */
-        RBSR_FINDEX *nfi;     
+        RBSR_FINDEX *nfi;
         fi->findex2 = findex;
         /*
          * If the following record contains one higher, merge its
          *   file index by extending it up.
          */
-        if (fi->next && ((findex+1) == fi->next->findex)) { 
+        if (fi->next && ((findex+1) == fi->next->findex)) {
            nfi = fi->next;
            fi->findex2 = nfi->findex2;
            fi->next = nfi->next;
index d4d9be09f3799e56e659e0710f2c8a3f3aed8831..aea7e18af2273aac4312512648a0173939d9266a 100644 (file)
@@ -2,7 +2,7 @@
  *
  *   Bootstrap Record header file
  *
- *     BSR (bootstrap record) handling routines split from 
+ *     BSR (bootstrap record) handling routines split from
  *       ua_restore.c July MMIII
  *
  *     Kern Sibbald, July MMII
@@ -38,8 +38,8 @@ struct RBSR_FINDEX {
    int32_t findex2;
 };
 
-/* 
- * Restore bootstrap record -- not the real one, but useful here   
+/*
+ * Restore bootstrap record -- not the real one, but useful here
  *  The restore bsr is a chain of BSR records (linked by next).
  *  Each BSR represents a single JobId, and within it, it
  *    contains a linked list of file indexes for that JobId.
@@ -49,7 +49,7 @@ struct RBSR_FINDEX {
 struct RBSR {
    RBSR *next;                       /* next JobId */
    uint32_t JobId;                   /* JobId this bsr */
-   uint32_t VolSessionId;                  
+   uint32_t VolSessionId;
    uint32_t VolSessionTime;
    int     VolCount;                 /* Volume parameter count */
    VOL_PARAMS *VolParams;            /* Volume, start/end file/blocks */
index cae33b8ea987cf87f0999b1eb20d407575ed2014..0c5abb76c1676857dd9358ed35a3e8eed2747932 100644 (file)
 static char Find_media[] = "CatReq Job=%127s FindMedia=%d\n";
 static char Get_Vol_Info[] = "CatReq Job=%127s GetVolInfo VolName=%127s write=%d\n";
 
-static char Update_media[] = "CatReq Job=%127s UpdateMedia VolName=%s\
- VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%" lld " VolMounts=%u\
- VolErrors=%u VolWrites=%u MaxVolBytes=%" lld " EndTime=%d VolStatus=%10s\
- Slot=%d relabel=%d InChanger=%d VolReadTime=%" lld " VolWriteTime=%" lld "\n";
+static char Update_media[] = "CatReq Job=%127s UpdateMedia VolName=%s"
+" VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%" lld " VolMounts=%u"
+" VolErrors=%u VolWrites=%u MaxVolBytes=%" lld " EndTime=%d VolStatus=%10s"
+" Slot=%d relabel=%d InChanger=%d VolReadTime=%" lld " VolWriteTime=%" lld "\n";
 
-static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia \
- FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u \
- StartBlock=%u EndBlock=%u\n";
+static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia "
+" FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u "
+" StartBlock=%u EndBlock=%u\n";
 
 
 /* Responses  sent to Storage daemon */
@@ -64,7 +64,7 @@ static char OK_media[] = "1000 OK VolName=%s VolJobs=%u VolFiles=%u"
 static char OK_create[] = "1000 OK CreateJobMedia\n";
 
 
-static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr) 
+static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr)
 {
    int stat;
    char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50];
@@ -74,8 +74,8 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr
    bash_spaces(mr->VolumeName);
    stat = bnet_fsend(sd, OK_media, mr->VolumeName, mr->VolJobs,
       mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
-      mr->VolMounts, mr->VolErrors, mr->VolWrites, 
-      edit_uint64(mr->MaxVolBytes, ed2), 
+      mr->VolMounts, mr->VolErrors, mr->VolWrites,
+      edit_uint64(mr->MaxVolBytes, ed2),
       edit_uint64(mr->VolCapacityBytes, ed3),
       mr->VolStatus, mr->Slot, mr->MaxVolJobs, mr->MaxVolFiles,
       mr->InChanger,
@@ -89,7 +89,7 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr
 
 void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
 {
-   MEDIA_DBR mr, sdmr; 
+   MEDIA_DBR mr, sdmr;
    JOBMEDIA_DBR jm;
    char Job[MAX_NAME_LENGTH];
    int index, ok, label, writing;
@@ -106,15 +106,15 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
    if (sscanf(bs->msg, Find_media, &Job, &index) == 2) {
       ok = find_next_volume_for_append(jcr, &mr, true /*permit create new vol*/);
       /*
-       * Send Find Media response to Storage daemon 
+       * Send Find Media response to Storage daemon
        */
       if (ok) {
         send_volume_info_to_storage_daemon(jcr, bs, &mr);
       } else {
-         bnet_fsend(bs, "1901 No Media.\n");
+        bnet_fsend(bs, "1901 No Media.\n");
       }
 
-   /* 
+   /*
     * Request to find specific Volume information
     */
    } else if (sscanf(bs->msg, Get_Vol_Info, &Job, &mr.VolumeName, &writing) == 3) {
@@ -125,34 +125,34 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
       unbash_spaces(mr.VolumeName);
       if (db_get_media_record(jcr, jcr->db, &mr)) {
         const char *reason = NULL;           /* detailed reason for rejection */
-        /*                   
+        /*
          * If we are reading, accept any volume (reason == NULL)
-         * If we are writing, check if the Volume is valid 
+         * If we are writing, check if the Volume is valid
          *   for this job, and do a recycle if necessary
-         */ 
+         */
         if (writing) {
-           /* 
+           /*
             * SD wants to write this Volume, so make
             *   sure it is suitable for this job, i.e.
-            *   Pool matches, and it is either Append or Recycle 
+            *   Pool matches, and it is either Append or Recycle
             *   and Media Type matches and Pool allows any volume.
             */
            if (mr.PoolId != jcr->PoolId) {
-               reason = "not in Pool";
+              reason = "not in Pool";
            } else if (strcmp(mr.MediaType, jcr->store->media_type) != 0) {
-               reason = "not correct MediaType";
+              reason = "not correct MediaType";
            } else {
-             /* 
-              * ****FIXME*** 
+             /*
+              * ****FIXME***
               *   This test (accept_any_volume) is turned off
-               *   because it doesn't properly check if the volume
+              *   because it doesn't properly check if the volume
               *   really is out of sequence!
               *
               * } else if (!jcr->pool->accept_any_volume) {
-               *    reason = "Volume not in sequence";
+              *    reason = "Volume not in sequence";
               */
 
-              /* 
+              /*
                * Now try recycling if necessary
                *   reason set non-NULL if we cannot use it
                */
@@ -161,20 +161,20 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
         }
         if (reason == NULL) {
            /*
-            * Send Find Media response to Storage daemon 
+            * Send Find Media response to Storage daemon
             */
            send_volume_info_to_storage_daemon(jcr, bs, &mr);
-        } else { 
+        } else {
            /* Not suitable volume */
-            bnet_fsend(bs, "1998 Volume \"%s\" status is %s, %s.\n", mr.VolumeName, 
+           bnet_fsend(bs, "1998 Volume \"%s\" status is %s, %s.\n", mr.VolumeName,
               mr.VolStatus, reason);
         }
 
       } else {
-         bnet_fsend(bs, "1997 Volume \"%s\" not in catalog.\n", mr.VolumeName);
+        bnet_fsend(bs, "1997 Volume \"%s\" not in catalog.\n", mr.VolumeName);
       }
 
-   
+
    /*
     * Request to update Media record. Comes typically at the end
     *  of a Storage daemon Job Session, when labeling/relabeling a
@@ -182,8 +182,8 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
     */
    } else if (sscanf(bs->msg, Update_media, &Job, &sdmr.VolumeName, &sdmr.VolJobs,
       &sdmr.VolFiles, &sdmr.VolBlocks, &sdmr.VolBytes, &sdmr.VolMounts, &sdmr.VolErrors,
-      &sdmr.VolWrites, &sdmr.MaxVolBytes, &sdmr.LastWritten, &sdmr.VolStatus, 
-      &sdmr.Slot, &label, &sdmr.InChanger, &sdmr.VolReadTime, 
+      &sdmr.VolWrites, &sdmr.MaxVolBytes, &sdmr.LastWritten, &sdmr.VolStatus,
+      &sdmr.Slot, &label, &sdmr.InChanger, &sdmr.VolReadTime,
       &sdmr.VolWriteTime) == 17) {
 
       db_lock(jcr->db);
@@ -192,9 +192,9 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
       bstrncpy(mr.VolumeName, sdmr.VolumeName, sizeof(mr.VolumeName)); /* copy Volume name */
       unbash_spaces(mr.VolumeName);
       if (!db_get_media_record(jcr, jcr->db, &mr)) {
-         Jmsg(jcr, M_ERROR, 0, _("Unable to get Media record for Volume %s: ERR=%s\n"),
+        Jmsg(jcr, M_ERROR, 0, _("Unable to get Media record for Volume %s: ERR=%s\n"),
              mr.VolumeName, db_strerror(jcr->db));
-         bnet_fsend(bs, "1991 Catalog Request failed: %s", db_strerror(jcr->db));
+        bnet_fsend(bs, "1991 Catalog Request failed: %s", db_strerror(jcr->db));
         db_unlock(jcr->db);
         return;
       }
@@ -211,7 +211,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
          * Insanity check for VolFiles get set to a smaller value
          */
         if (sdmr.VolFiles < mr.VolFiles) {
-            Jmsg(jcr, M_ERROR, 0, _("ERROR!! Volume Files at %u being set to %u. This is probably wrong.\n"),
+           Jmsg(jcr, M_ERROR, 0, _("ERROR!! Volume Files at %u being set to %u. This is probably wrong.\n"),
               mr.VolFiles, sdmr.VolFiles);
         }
       }
@@ -241,10 +241,10 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
       } else if (db_update_media_record(jcr, jcr->db, &mr)) {
         send_volume_info_to_storage_daemon(jcr, bs, &mr);
       } else {
-         Jmsg(jcr, M_ERROR, 0, _("Catalog error updating Media record. %s"),
+        Jmsg(jcr, M_ERROR, 0, _("Catalog error updating Media record. %s"),
            db_strerror(jcr->db));
-         bnet_fsend(bs, "1992 Update Media error\n");
-         Dmsg0(190, "send error\n");
+        bnet_fsend(bs, "1992 Update Media error\n");
+        Dmsg0(190, "send error\n");
       }
       db_unlock(jcr->db);
 
@@ -260,18 +260,18 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
       Dmsg6(300, "create_jobmedia JobId=%d MediaId=%d SF=%d EF=%d FI=%d LI=%d\n",
         jm.JobId, jm.MediaId, jm.StartFile, jm.EndFile, jm.FirstIndex, jm.LastIndex);
       if (!db_create_jobmedia_record(jcr, jcr->db, &jm)) {
-         Jmsg(jcr, M_ERROR, 0, _("Catalog error creating JobMedia record. %s"),
+        Jmsg(jcr, M_ERROR, 0, _("Catalog error creating JobMedia record. %s"),
            db_strerror(jcr->db));
-         bnet_fsend(bs, "1991 Update JobMedia error\n");
+        bnet_fsend(bs, "1991 Update JobMedia error\n");
       } else {
-         Dmsg0(300, "JobMedia record created\n");
+        Dmsg0(300, "JobMedia record created\n");
         bnet_fsend(bs, OK_create);
       }
 
    } else {
       omsg = get_memory(bs->msglen+1);
       pm_strcpy(omsg, bs->msg);
-      bnet_fsend(bs, "1990 Invalid Catalog Request: %s", omsg);    
+      bnet_fsend(bs, "1990 Invalid Catalog Request: %s", omsg);
       Jmsg1(jcr, M_ERROR, 0, _("Invalid Catalog request: %s"), omsg);
       free_memory(omsg);
    }
@@ -284,7 +284,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
  * Update File Attributes in the catalog with data
  *  sent by the Storage daemon.  Note, we receive the whole
  *  attribute record, but we select out only the stat packet,
- *  VolSessionId, VolSessionTime, FileIndex, and file name 
+ *  VolSessionId, VolSessionTime, FileIndex, and file name
  *  to store in the catalog.
  */
 void catalog_update(JCR *jcr, BSOCK *bs, char *msg)
@@ -332,7 +332,7 @@ void catalog_update(JCR *jcr, BSOCK *bs, char *msg)
 
       Dmsg2(300, "dird<stored: stream=%d %s\n", Stream, fname);
       Dmsg1(300, "dird<stored: attr=%s\n", attr);
-      ar.attr = attr; 
+      ar.attr = attr;
       ar.fname = fname;
       ar.FileIndex = FileIndex;
       ar.Stream = Stream;
@@ -343,15 +343,15 @@ void catalog_update(JCR *jcr, BSOCK *bs, char *msg)
       Dmsg1(120, "dird<filed: attr=%s\n", attr);
 
       if (!db_create_file_attributes_record(jcr, jcr->db, &ar)) {
-         Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db));
+        Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db));
       }
       /* Save values for SIG update */
       jcr->FileId = ar.FileId;
       jcr->FileIndex = FileIndex;
    } else if (Stream == STREAM_MD5_SIGNATURE || Stream == STREAM_SHA1_SIGNATURE) {
       fname = p;
-      if (jcr->FileIndex != FileIndex) {    
-         Jmsg(jcr, M_WARNING, 0, "Got MD5/SHA1 but not same File as attributes\n");
+      if (jcr->FileIndex != FileIndex) {
+        Jmsg(jcr, M_WARNING, 0, "Got MD5/SHA1 but not same File as attributes\n");
       } else {
         /* Update signature in catalog */
         char SIGbuf[50];           /* 24 bytes should be enough */
@@ -364,9 +364,9 @@ void catalog_update(JCR *jcr, BSOCK *bs, char *msg)
            type = SHA1_SIG;
         }
         bin_to_base64(SIGbuf, fname, len);
-         Dmsg3(190, "SIGlen=%d SIG=%s type=%d\n", strlen(SIGbuf), SIGbuf, Stream);
+        Dmsg3(190, "SIGlen=%d SIG=%s type=%d\n", strlen(SIGbuf), SIGbuf, Stream);
         if (!db_add_SIG_to_file_record(jcr, jcr->db, jcr->FileId, SIGbuf, type)) {
-            Jmsg(jcr, M_ERROR, 0, _("Catalog error updating MD5/SHA1. %s"), 
+           Jmsg(jcr, M_ERROR, 0, _("Catalog error updating MD5/SHA1. %s"),
               db_strerror(jcr->db));
         }
       }
index fb0aa191000db04e548a8ba1e3760693d031936d..e9a680feb839362617b08f70fbc78ecc61a757fd 100644 (file)
@@ -86,7 +86,7 @@ static void usage()
 "       -t          test - read configuration and exit\n"
 "       -u          userid\n"
 "       -v          verbose user messages\n"
-"       -?          print this message.\n"  
+"       -?          print this message.\n"
 "\n"));
 
    exit(1);
@@ -126,9 +126,9 @@ int main (int argc, char *argv[])
       case 'd':                    /* set debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0) {
-           debug_level = 1; 
+           debug_level = 1;
         }
-         Dmsg1(0, "Debug level = %d\n", debug_level);
+        Dmsg1(0, "Debug level = %d\n", debug_level);
         break;
 
       case 'f':                    /* run in foreground */
@@ -168,7 +168,7 @@ int main (int argc, char *argv[])
       default:
         usage();
 
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -182,7 +182,7 @@ int main (int argc, char *argv[])
         free(configfile);
       }
       configfile = bstrdup(*argv);
-      argc--; 
+      argc--;
       argv++;
    }
    if (argc) {
@@ -237,7 +237,7 @@ int main (int argc, char *argv[])
    init_jcr_subsystem();             /* start JCR watchdogs etc. */
 
    init_job_server(director->MaxConcurrentJobs);
-  
+
    Dmsg0(200, "wait for next job\n");
    /* Main loop -- call scheduler to get next job to run */
    while ((jcr = wait_for_next_job(runjob))) {
@@ -272,14 +272,14 @@ static void terminate_dird(int sig)
       free(configfile);
    }
    if (debug_level > 5) {
-      print_memory_pool_stats(); 
+      print_memory_pool_stats();
    }
    free_config_resources();
    term_ua_server();
    term_msg();                       /* terminate message handler */
    stop_watchdog();
    close_memory_pool();              /* release free memory in pool */
-   sm_dump(false);  
+   sm_dump(false);
    exit(sig);
 }
 
@@ -291,7 +291,7 @@ struct RELOAD_TABLE {
 static const int max_reloads = 10;
 static RELOAD_TABLE reload_table[max_reloads];
 
-static void init_reload(void) 
+static void init_reload(void)
 {
    for (int i=0; i < max_reloads; i++) {
       reload_table[i].job_count = 0;
@@ -350,10 +350,10 @@ static int find_free_reload_table_entry()
 
 /*
  * If we get here, we have received a SIGHUP, which means to
- *    reread our configuration file. 
+ *    reread our configuration file.
  *
  * The algorithm used is as follows: we count how many jobs are
- *   running and mark the running jobs to make a callback on 
+ *   running and mark the running jobs to make a callback on
  *   exiting. The old config is saved with the reload table
  *   id in a reload table. The new config file is read. Now, as
  *   each job exits, it calls back to the reload_job_end_cb(), which
@@ -371,7 +371,7 @@ extern "C"
 void reload_config(int sig)
 {
    static bool already_here = false;
-   sigset_t set;       
+   sigset_t set;
    JCR *jcr;
    int njobs = 0;                    /* number of running jobs */
    int table, rtable;
@@ -405,10 +405,10 @@ void reload_config(int sig)
    if (!check_resources()) {
       rtable = find_free_reload_table_entry();   /* save new, bad table */
       if (rtable < 0) {
-         Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile);
-         Jmsg(NULL, M_ERROR_TERM, 0, _("Out of reload table entries. Giving up.\n"));
+        Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile);
+        Jmsg(NULL, M_ERROR_TERM, 0, _("Out of reload table entries. Giving up.\n"));
       } else {
-         Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile);
+        Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile);
       }
       reload_table[rtable].res_table = save_config_resources();
       /* Now restore old resoure values */
@@ -420,7 +420,7 @@ void reload_config(int sig)
       table = rtable;                /* release new, bad, saved table below */
    } else {
       /*
-       * Hook all active jobs so that they release this table 
+       * Hook all active jobs so that they release this table
        */
       foreach_jcr(jcr) {
         if (jcr->JobType != JT_SYSTEM) {
@@ -437,7 +437,7 @@ void reload_config(int sig)
    FDConnectTimeout = director->FDConnectTimeout;
    SDConnectTimeout = director->SDConnectTimeout;
    Dmsg0(0, "Director's configuration file reread.\n");
-       
+
    /* Now release saved resources, if no jobs using the resources */
    if (njobs == 0) {
       free_saved_resources(table);
@@ -468,23 +468,23 @@ static int check_resources()
    job = (JOB *)GetNextRes(R_JOB, NULL);
    director = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
    if (!director) {
-      Jmsg(NULL, M_FATAL, 0, _("No Director resource defined in %s\n\
-Without that I don't know who I am :-(\n"), configfile);
+      Jmsg(NULL, M_FATAL, 0, _("No Director resource defined in %s\n"
+"Without that I don't know who I am :-(\n"), configfile);
       OK = false;
    } else {
       set_working_directory(director->working_directory);
       if (!director->messages) {       /* If message resource not specified */
         director->messages = (MSGS *)GetNextRes(R_MSGS, NULL);
         if (!director->messages) {
-            Jmsg(NULL, M_FATAL, 0, _("No Messages resource defined in %s\n"), configfile);
+           Jmsg(NULL, M_FATAL, 0, _("No Messages resource defined in %s\n"), configfile);
            OK = false;
         }
       }
       if (GetNextRes(R_DIRECTOR, (RES *)director) != NULL) {
-         Jmsg(NULL, M_FATAL, 0, _("Only one Director resource permitted in %s\n"),
+        Jmsg(NULL, M_FATAL, 0, _("Only one Director resource permitted in %s\n"),
            configfile);
         OK = false;
-      } 
+      }
    }
 
    if (!job) {
@@ -514,40 +514,40 @@ Without that I don't know who I am :-(\n"), configfile);
            int64_t *def_lvalue, *lvalue; /* 64 bit values */
            uint32_t offset;
 
-            Dmsg4(400, "Job \"%s\", field \"%s\" bit=%d def=%d\n",
-               job->hdr.name, job_items[i].name, 
-               bit_is_set(i, job->hdr.item_present),  
+           Dmsg4(400, "Job \"%s\", field \"%s\" bit=%d def=%d\n",
+               job->hdr.name, job_items[i].name,
+               bit_is_set(i, job->hdr.item_present),
                bit_is_set(i, job->jobdefs->hdr.item_present));
 
            if (!bit_is_set(i, job->hdr.item_present) &&
-                bit_is_set(i, job->jobdefs->hdr.item_present)) { 
-               Dmsg2(400, "Job \"%s\", field \"%s\": getting default.\n",
+                bit_is_set(i, job->jobdefs->hdr.item_present)) {
+              Dmsg2(400, "Job \"%s\", field \"%s\": getting default.\n",
                 job->hdr.name, job_items[i].name);
-              offset = (char *)(job_items[i].value) - (char *)&res_all;   
+              offset = (char *)(job_items[i].value) - (char *)&res_all;
               /*
                * Handle strings and directory strings
                */
               if (job_items[i].handler == store_str ||
                   job_items[i].handler == store_dir) {
                  def_svalue = (char **)((char *)(job->jobdefs) + offset);
-                  Dmsg5(400, "Job \"%s\", field \"%s\" def_svalue=%s item %d offset=%u\n", 
+                 Dmsg5(400, "Job \"%s\", field \"%s\" def_svalue=%s item %d offset=%u\n",
                       job->hdr.name, job_items[i].name, *def_svalue, i, offset);
                  svalue = (char **)((char *)job + offset);
                  if (*svalue) {
-                     Pmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue);
+                    Pmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue);
                  }
                  *svalue = bstrdup(*def_svalue);
                  set_bit(i, job->hdr.item_present);
               /*
-               * Handle resources   
+               * Handle resources
                */
               } else if (job_items[i].handler == store_res) {
                  def_svalue = (char **)((char *)(job->jobdefs) + offset);
-                  Dmsg4(400, "Job \"%s\", field \"%s\" item %d offset=%u\n", 
+                 Dmsg4(400, "Job \"%s\", field \"%s\" item %d offset=%u\n",
                       job->hdr.name, job_items[i].name, i, offset);
                  svalue = (char **)((char *)job + offset);
                  if (*svalue) {
-                     Pmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue);
+                    Pmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue);
                  }
                  *svalue = *def_svalue;
                  set_bit(i, job->hdr.item_present);
@@ -555,11 +555,11 @@ Without that I don't know who I am :-(\n"), configfile);
                * Handle alist resources
                */
               } else if (job_items[i].handler == store_alist_res) {
-                 if (bit_is_set(i, job->jobdefs->hdr.item_present)) { 
+                 if (bit_is_set(i, job->jobdefs->hdr.item_present)) {
                     set_bit(i, job->hdr.item_present);
                  }
               /*
-               * Handle integer fields 
+               * Handle integer fields
                *    Note, our store_yesno does not handle bitmaped fields
                */
               } else if (job_items[i].handler == store_yesno   ||
@@ -569,19 +569,19 @@ Without that I don't know who I am :-(\n"), configfile);
                          job_items[i].handler == store_pint    ||
                          job_items[i].handler == store_replace) {
                  def_ivalue = (int *)((char *)(job->jobdefs) + offset);
-                  Dmsg5(400, "Job \"%s\", field \"%s\" def_ivalue=%d item %d offset=%u\n", 
+                 Dmsg5(400, "Job \"%s\", field \"%s\" def_ivalue=%d item %d offset=%u\n",
                       job->hdr.name, job_items[i].name, *def_ivalue, i, offset);
                  ivalue = (int *)((char *)job + offset);
                  *ivalue = *def_ivalue;
                  set_bit(i, job->hdr.item_present);
               /*
-               * Handle 64 bit integer fields 
+               * Handle 64 bit integer fields
                */
               } else if (job_items[i].handler == store_time   ||
                          job_items[i].handler == store_size   ||
                          job_items[i].handler == store_int64) {
                  def_lvalue = (int64_t *)((char *)(job->jobdefs) + offset);
-                  Dmsg5(400, "Job \"%s\", field \"%s\" def_lvalue=%" lld " item %d offset=%u\n", 
+                 Dmsg5(400, "Job \"%s\", field \"%s\" def_lvalue=%" lld " item %d offset=%u\n",
                       job->hdr.name, job_items[i].name, *def_lvalue, i, offset);
                  lvalue = (int64_t *)((char *)job + offset);
                  *lvalue = *def_lvalue;
@@ -590,20 +590,20 @@ Without that I don't know who I am :-(\n"), configfile);
            }
         }
       }
-      /* 
+      /*
        * Ensure that all required items are present
        */
       for (i=0; job_items[i].name; i++) {
         if (job_items[i].flags & ITEM_REQUIRED) {
-              if (!bit_is_set(i, job->hdr.item_present)) {  
-                  Jmsg(NULL, M_FATAL, 0, "\"%s\" directive in Job \"%s\" resource is required, but not found.\n",
+              if (!bit_is_set(i, job->hdr.item_present)) {
+                 Jmsg(NULL, M_FATAL, 0, "\"%s\" directive in Job \"%s\" resource is required, but not found.\n",
                    job_items[i].name, job->hdr.name);
                  OK = false;
                }
         }
         /* If this triggers, take a look at lib/parse_conf.h */
         if (i >= MAX_RES_ITEMS) {
-            Emsg0(M_ERROR_TERM, 0, "Too many items in Job resource\n");
+           Emsg0(M_ERROR_TERM, 0, "Too many items in Job resource\n");
         }
       }
    } /* End loop over Job res */
@@ -618,23 +618,23 @@ Without that I don't know who I am :-(\n"), configfile);
        */
       db = db_init_database(NULL, catalog->db_name, catalog->db_user,
                         catalog->db_password, catalog->db_address,
-                        catalog->db_port, catalog->db_socket, 
+                        catalog->db_port, catalog->db_socket,
                         catalog->mult_db_connections);
       if (!db || !db_open_database(NULL, db)) {
-         Jmsg(NULL, M_FATAL, 0, _("Could not open database \"%s\".\n"),
+        Jmsg(NULL, M_FATAL, 0, _("Could not open database \"%s\".\n"),
              catalog->db_name);
         if (db) {
-            Jmsg(NULL, M_FATAL, 0, _("%s"), db_strerror(db));
+           Jmsg(NULL, M_FATAL, 0, _("%s"), db_strerror(db));
         }
         OK = false;
         continue;
-      } 
+      }
 
       /* Loop over all pools, defining/updating them in each database */
       POOL *pool;
       foreach_res(pool, R_POOL) {
         create_pool(NULL, db, pool, POOL_OP_UPDATE);  /* update request */
-      }      
+      }
       /* Loop over all counters, defining them in each database */
 
       /* Set default value in all counters */
@@ -655,9 +655,9 @@ Without that I don't know who I am :-(\n"), configfile);
            if (db_create_counter_record(NULL, db, &cr)) {
               counter->CurrentValue = cr.CurrentValue;
               counter->created = true;
-               Dmsg2(100, "Create counter %s val=%d\n", counter->hdr.name, counter->CurrentValue);
+              Dmsg2(100, "Create counter %s val=%d\n", counter->hdr.name, counter->CurrentValue);
            }
-        } 
+        }
         if (!counter->created) {
            counter->CurrentValue = counter->MinValue;  /* default value */
         }
index 433945d9bd98d4ca6dbc8144554500311ca00168..255ba70cd5706c034272fe2ddf21fb7389ba959d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
  *
- *   2. The generic config  scanner in lib/parse_config.c and 
+ *   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,
@@ -77,10 +77,10 @@ int  res_all_size = sizeof(res_all);
 
 
 /* Definition of records permitted within each
- * resource with the routine to process the record 
+ * resource with the routine to process the record
  * information.  NOTE! quoted names must be in lower case.
- */ 
-/* 
+ */
+/*
  *    Director Resource
  *
  *   name         handler     value                 code flags    default_value
@@ -106,7 +106,7 @@ static RES_ITEM dir_items[] = {
    {NULL, NULL, NULL, 0, 0, 0}
 };
 
-/* 
+/*
  *    Console Resource
  *
  *   name         handler     value                 code flags    default_value
@@ -129,7 +129,7 @@ static RES_ITEM con_items[] = {
 };
 
 
-/* 
+/*
  *    Client or File daemon resource
  *
  *   name         handler     value                 code flags    default_value
@@ -149,7 +149,7 @@ static RES_ITEM cli_items[] = {
    {"autoprune", store_yesno,     ITEM(res_client.AutoPrune), 1, ITEM_DEFAULT, 1},
    {"enablessl", store_yesno,     ITEM(res_client.enable_ssl), 1, ITEM_DEFAULT, 0},
    {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
 /* Storage daemon resource
@@ -171,10 +171,10 @@ static RES_ITEM store_items[] = {
    {"enablessl",   store_yesno,    ITEM(res_store.enable_ssl),  1, ITEM_DEFAULT, 0},
    {"maximumconcurrentjobs", store_pint, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
    {"sddport", store_pint, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
-/* 
+/*
  *    Catalog Resource Directives
  *
  *   name         handler     value                 code flags    default_value
@@ -190,12 +190,12 @@ static RES_ITEM cat_items[] = {
    {"dbpassword", store_str,    ITEM(res_cat.db_password), 0, 0, 0},
    {"user",     store_str,      ITEM(res_cat.db_user),     0, 0, 0},
    {"dbname",   store_str,      ITEM(res_cat.db_name),     0, ITEM_REQUIRED, 0},
-   {"dbsocket", store_str,      ITEM(res_cat.db_socket),   0, 0, 0}, 
+   {"dbsocket", store_str,      ITEM(res_cat.db_socket),   0, 0, 0},
    {"multipleconnections", store_yesno, ITEM(res_cat.mult_db_connections), 1, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
-/* 
+/*
  *    Job Resource Directives
  *
  *   name         handler     value                 code flags    default_value
@@ -241,7 +241,7 @@ RES_ITEM job_items[] = {
    {"rescheduleinterval", store_time, ITEM(res_job.RescheduleInterval), 0, ITEM_DEFAULT, 60 * 30},
    {"rescheduletimes", store_pint, ITEM(res_job.RescheduleTimes), 0, 0, 0},
    {"priority",   store_pint, ITEM(res_job.Priority), 0, ITEM_DEFAULT, 10},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
 /* FileSet resource
@@ -254,7 +254,7 @@ static RES_ITEM fs_items[] = {
    {"include",     store_inc,  NULL,                  0, ITEM_NO_EQUALS, 0},
    {"exclude",     store_inc,  NULL,                  1, ITEM_NO_EQUALS, 0},
    {"ignorefilesetchanges", store_yesno, ITEM(res_fs.ignore_fs_changes), 1, ITEM_DEFAULT, 0},
-   {NULL,         NULL,       NULL,                  0, 0, 0} 
+   {NULL,         NULL,       NULL,                  0, 0, 0}
 };
 
 /* Schedule -- see run_conf.c */
@@ -266,7 +266,7 @@ static RES_ITEM sch_items[] = {
    {"name",     store_name,  ITEM(res_sch.hdr.name), 0, ITEM_REQUIRED, 0},
    {"description", store_str, ITEM(res_sch.hdr.desc), 0, 0, 0},
    {"run",      store_run,   ITEM(res_sch.run),      0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
 /* Pool resource
@@ -294,10 +294,10 @@ static RES_ITEM pool_items[] = {
    {"volumeuseduration", store_time,  ITEM(res_pool.VolUseDuration),0, 0, 0},
    {"autoprune",       store_yesno, ITEM(res_pool.AutoPrune), 1, ITEM_DEFAULT, 1},
    {"recycle",         store_yesno, ITEM(res_pool.Recycle),     1, ITEM_DEFAULT, 1},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
-/* 
+/*
  * Counter Resource
  *   name            handler     value                        code flags default_value
  */
@@ -308,15 +308,15 @@ static RES_ITEM counter_items[] = {
    {"maximum",         store_pint,    ITEM(res_counter.MaxValue),        0, ITEM_DEFAULT, INT32_MAX},
    {"wrapcounter",     store_res,     ITEM(res_counter.WrapCounter),     R_COUNTER, 0, 0},
    {"catalog",         store_res,     ITEM(res_counter.Catalog),         R_CATALOG, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
 
 /* Message resource */
 extern RES_ITEM msgs_items[];
 
-/* 
- * This is the master resource definition.  
+/*
+ * This is the master resource definition.
  * It must have one item for each of the resources.
  *
  *  NOTE!!! keep it in the same order as the R_codes
@@ -341,7 +341,7 @@ RES_TABLE resources[] = {
 };
 
 
-/* Keywords (RHS) permitted in Job Level records   
+/* Keywords (RHS) permitted in Job Level records
  *
  *   level_name      level             job_type
  */
@@ -361,7 +361,7 @@ struct s_jl joblevels[] = {
    {NULL,           0,                          0}
 };
 
-/* Keywords (RHS) permitted in Job type records   
+/* Keywords (RHS) permitted in Job type records
  *
  *   type_name      job_type
  */
@@ -379,7 +379,7 @@ struct s_jt jobtypes[] = {
 static struct s_kw BakVerFields[] = {
    {"client",        'C'},
    {"fileset",       'F'},
-   {"level",         'L'}, 
+   {"level",         'L'},
    {NULL,           0}
 };
 
@@ -437,35 +437,35 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
    }
    switch (type) {
    case R_DIRECTOR:
-      sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n", 
-        reshdr->name, res->res_dir.MaxConcurrentJobs, 
+      sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n",
+        reshdr->name, res->res_dir.MaxConcurrentJobs,
         edit_uint64(res->res_dir.FDConnectTimeout, ed1),
         edit_uint64(res->res_dir.SDConnectTimeout, ed2));
       if (res->res_dir.query_file) {
-         sendit(sock, "   query_file=%s\n", res->res_dir.query_file);
+        sendit(sock, "   query_file=%s\n", res->res_dir.query_file);
       }
       if (res->res_dir.messages) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_MSGS, (RES *)res->res_dir.messages, sendit, sock);
       }
       break;
    case R_CONSOLE:
-      sendit(sock, "Console: name=%s SSL=%d\n", 
+      sendit(sock, "Console: name=%s SSL=%d\n",
         res->res_con.hdr.name, res->res_con.enable_ssl);
       break;
    case R_COUNTER:
       if (res->res_counter.WrapCounter) {
-         sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n",
-           res->res_counter.hdr.name, res->res_counter.MinValue, 
+        sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n",
+           res->res_counter.hdr.name, res->res_counter.MinValue,
            res->res_counter.MaxValue, res->res_counter.CurrentValue,
            res->res_counter.WrapCounter->hdr.name);
       } else {
-         sendit(sock, "Counter: name=%s min=%d max=%d\n",
-           res->res_counter.hdr.name, res->res_counter.MinValue, 
+        sendit(sock, "Counter: name=%s min=%d max=%d\n",
+           res->res_counter.hdr.name, res->res_counter.MinValue,
            res->res_counter.MaxValue);
       }
       if (res->res_counter.Catalog) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_CATALOG, (RES *)res->res_counter.Catalog, sendit, sock);
       }
       break;
@@ -479,29 +479,29 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
         edit_utime(res->res_client.FileRetention, ed2, sizeof(ed2)),
         res->res_client.AutoPrune);
       if (res->res_client.catalog) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_CATALOG, (RES *)res->res_client.catalog, sendit, sock);
       }
       break;
    case R_STORAGE:
-      sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n\
-      DeviceName=%s MediaType=%s\n",
+      sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n"
+"      DeviceName=%s MediaType=%s\n",
         res->res_store.hdr.name, res->res_store.address, res->res_store.SDport,
         res->res_store.MaxConcurrentJobs,
         res->res_store.dev_name, res->res_store.media_type);
       break;
    case R_CATALOG:
-      sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n\
-      db_user=%s MutliDBConn=%d\n",
+      sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n"
+"      db_user=%s MutliDBConn=%d\n",
         res->res_cat.hdr.name, NPRT(res->res_cat.db_address),
-        res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user), 
+        res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user),
         res->res_cat.mult_db_connections);
       break;
    case R_JOB:
    case R_JOBDEFS:
-      sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n", 
-         type == R_JOB ? "Job" : "JobDefs",
-        res->res_job.hdr.name, res->res_job.JobType, 
+      sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n",
+        type == R_JOB ? "Job" : "JobDefs",
+        res->res_job.hdr.name, res->res_job.JobType,
         level_to_str(res->res_job.JobLevel), res->res_job.Priority,
         res->res_job.MaxConcurrentJobs);
       sendit(sock, "     Resched=%d Times=%d Interval=%s Spool=%d\n",
@@ -509,63 +509,63 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
          edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1),
          res->res_job.spool_data);
       if (res->res_job.client) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock);
       }
       if (res->res_job.fileset) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_FILESET, (RES *)res->res_job.fileset, sendit, sock);
       }
       if (res->res_job.schedule) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_SCHEDULE, (RES *)res->res_job.schedule, sendit, sock);
       }
       if (res->res_job.RestoreWhere) {
-         sendit(sock, "  --> Where=%s\n", NPRT(res->res_job.RestoreWhere));
+        sendit(sock, "  --> Where=%s\n", NPRT(res->res_job.RestoreWhere));
       }
       if (res->res_job.RestoreBootstrap) {
-         sendit(sock, "  --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap));
+        sendit(sock, "  --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap));
       }
       if (res->res_job.RunBeforeJob) {
-         sendit(sock, "  --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob));
+        sendit(sock, "  --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob));
       }
       if (res->res_job.RunAfterJob) {
-         sendit(sock, "  --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob));
+        sendit(sock, "  --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob));
       }
       if (res->res_job.RunAfterFailedJob) {
-         sendit(sock, "  --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob));
+        sendit(sock, "  --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob));
       }
       if (res->res_job.WriteBootstrap) {
-         sendit(sock, "  --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap));
+        sendit(sock, "  --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap));
       }
       if (res->res_job.storage[0]) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         /* ***FIXME*** */
 //        dump_resource(-R_STORAGE, (RES *)res->res_job.storage, sendit, sock);
       }
       if (res->res_job.pool) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_POOL, (RES *)res->res_job.pool, sendit, sock);
       }
       if (res->res_job.full_pool) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_POOL, (RES *)res->res_job.full_pool, sendit, sock);
       }
       if (res->res_job.inc_pool) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_POOL, (RES *)res->res_job.inc_pool, sendit, sock);
       }
       if (res->res_job.dif_pool) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_POOL, (RES *)res->res_job.dif_pool, sendit, sock);
       }
       if (res->res_job.verify_job) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-type, (RES *)res->res_job.verify_job, sendit, sock);
       }
       break;
       if (res->res_job.messages) {
-         sendit(sock, "  --> ");
+        sendit(sock, "  --> ");
         dump_resource(-R_MSGS, (RES *)res->res_job.messages, sendit, sock);
       }
       break;
@@ -577,42 +577,42 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
         INCEXE *incexe = res->res_fs.include_items[i];
         for (j=0; j<incexe->num_opts; j++) {
            FOPTS *fo = incexe->opts_list[j];
-            sendit(sock, "      O %s\n", fo->opts);
+           sendit(sock, "      O %s\n", fo->opts);
            for (k=0; k<fo->regex.size(); k++) {
-               sendit(sock, "      R %s\n", fo->regex.get(k));
+              sendit(sock, "      R %s\n", fo->regex.get(k));
            }
            for (k=0; k<fo->wild.size(); k++) {
-               sendit(sock, "      W %s\n", fo->wild.get(k));
+              sendit(sock, "      W %s\n", fo->wild.get(k));
            }
            for (k=0; k<fo->base.size(); k++) {
-               sendit(sock, "      B %s\n", fo->base.get(k));
+              sendit(sock, "      B %s\n", fo->base.get(k));
            }
            for (k=0; k<fo->fstype.size(); k++) {
-               sendit(sock, "      X %s\n", fo->fstype.get(k));
+              sendit(sock, "      X %s\n", fo->fstype.get(k));
            }
            if (fo->reader) {
-               sendit(sock, "      D %s\n", fo->reader);
+              sendit(sock, "      D %s\n", fo->reader);
            }
            if (fo->writer) {
-               sendit(sock, "      T %s\n", fo->writer);
+              sendit(sock, "      T %s\n", fo->writer);
            }
-            sendit(sock, "      N\n");
+           sendit(sock, "      N\n");
         }
         for (j=0; j<incexe->name_list.size(); j++) {
-            sendit(sock, "      I %s\n", incexe->name_list.get(j));
+           sendit(sock, "      I %s\n", incexe->name_list.get(j));
         }
         if (incexe->name_list.size()) {
-            sendit(sock, "      N\n");
+           sendit(sock, "      N\n");
         }
       }
-        
+
       for (i=0; i<res->res_fs.num_excludes; i++) {
         INCEXE *incexe = res->res_fs.exclude_items[i];
         for (j=0; j<incexe->name_list.size(); j++) {
-            sendit(sock, "      E %s\n", incexe->name_list.get(j));
+           sendit(sock, "      E %s\n", incexe->name_list.get(j));
         }
         if (incexe->name_list.size()) {
-            sendit(sock, "      N\n");
+           sendit(sock, "      N\n");
         }
       }
       break;
@@ -622,77 +622,77 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
         int i;
         RUN *run = res->res_sch.run;
         char buf[1000], num[30];
-         sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
+        sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
         if (!run) {
            break;
         }
 next_run:
-         sendit(sock, "  --> Run Level=%s\n", level_to_str(run->level));
-         bstrncpy(buf, "      hour=", sizeof(buf));
+        sendit(sock, "  --> Run Level=%s\n", level_to_str(run->level));
+        bstrncpy(buf, "      hour=", sizeof(buf));
         for (i=0; i<24; i++) {
            if (bit_is_set(i, run->hour)) {
-               bsnprintf(num, sizeof(num), "%d ", i);
+              bsnprintf(num, sizeof(num), "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
-         bstrncat(buf, "\n", sizeof(buf));
+        bstrncat(buf, "\n", sizeof(buf));
         sendit(sock, buf);
-         bstrncpy(buf, "      mday=", sizeof(buf));
+        bstrncpy(buf, "      mday=", sizeof(buf));
         for (i=0; i<31; i++) {
            if (bit_is_set(i, run->mday)) {
-               bsnprintf(num, sizeof(num), "%d ", i);
+              bsnprintf(num, sizeof(num), "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
-         bstrncat(buf, "\n", sizeof(buf));
+        bstrncat(buf, "\n", sizeof(buf));
         sendit(sock, buf);
-         bstrncpy(buf, "      month=", sizeof(buf));
+        bstrncpy(buf, "      month=", sizeof(buf));
         for (i=0; i<12; i++) {
            if (bit_is_set(i, run->month)) {
-               bsnprintf(num, sizeof(num), "%d ", i);
+              bsnprintf(num, sizeof(num), "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
-         bstrncat(buf, "\n", sizeof(buf));
+        bstrncat(buf, "\n", sizeof(buf));
         sendit(sock, buf);
-         bstrncpy(buf, "      wday=", sizeof(buf));
+        bstrncpy(buf, "      wday=", sizeof(buf));
         for (i=0; i<7; i++) {
            if (bit_is_set(i, run->wday)) {
-               bsnprintf(num, sizeof(num), "%d ", i);
+              bsnprintf(num, sizeof(num), "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
-         bstrncat(buf, "\n", sizeof(buf));
+        bstrncat(buf, "\n", sizeof(buf));
         sendit(sock, buf);
-         bstrncpy(buf, "      wom=", sizeof(buf));
+        bstrncpy(buf, "      wom=", sizeof(buf));
         for (i=0; i<5; i++) {
            if (bit_is_set(i, run->wom)) {
-               bsnprintf(num, sizeof(num), "%d ", i);
+              bsnprintf(num, sizeof(num), "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
-         bstrncat(buf, "\n", sizeof(buf));
+        bstrncat(buf, "\n", sizeof(buf));
         sendit(sock, buf);
-         bstrncpy(buf, "      woy=", sizeof(buf));
+        bstrncpy(buf, "      woy=", sizeof(buf));
         for (i=0; i<54; i++) {
            if (bit_is_set(i, run->woy)) {
-               bsnprintf(num, sizeof(num), "%d ", i);
+              bsnprintf(num, sizeof(num), "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
-         bstrncat(buf, "\n", sizeof(buf));
+        bstrncat(buf, "\n", sizeof(buf));
         sendit(sock, buf);
-         sendit(sock, "      mins=%d\n", run->minute);
+        sendit(sock, "      mins=%d\n", run->minute);
         if (run->pool) {
-            sendit(sock, "     --> ");
+           sendit(sock, "     --> ");
            dump_resource(-R_POOL, (RES *)run->pool, sendit, sock);
         }
         if (run->storage) {
-            sendit(sock, "     --> ");
+           sendit(sock, "     --> ");
            dump_resource(-R_STORAGE, (RES *)run->storage, sendit, sock);
         }
         if (run->msgs) {
-            sendit(sock, "     --> ");
+           sendit(sock, "     --> ");
            dump_resource(-R_MSGS, (RES *)run->msgs, sendit, sock);
         }
         /* If another Run record is chained in, go print it */
@@ -701,7 +701,7 @@ next_run:
            goto next_run;
         }
       } else {
-         sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
+        sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name);
       }
       break;
    case R_POOL:
@@ -713,23 +713,23 @@ next_run:
       sendit(sock, "      max_vols=%d auto_prune=%d VolRetention=%s\n",
              res->res_pool.max_volumes, res->res_pool.AutoPrune,
              edit_utime(res->res_pool.VolRetention, ed1, sizeof(ed1)));
-      sendit(sock, "      VolUse=%s recycle=%d LabelFormat=%s\n", 
+      sendit(sock, "      VolUse=%s recycle=%d LabelFormat=%s\n",
              edit_utime(res->res_pool.VolUseDuration, ed1, sizeof(ed1)),
              res->res_pool.Recycle,
              NPRT(res->res_pool.label_format));
       sendit(sock, "      CleaningPrefix=%s\n",
              NPRT(res->res_pool.cleaning_prefix));
       sendit(sock, "      RecyleOldest=%d PurgeOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n",
-             res->res_pool.recycle_oldest_volume, 
-             res->res_pool.purge_oldest_volume, 
+             res->res_pool.recycle_oldest_volume,
+             res->res_pool.purge_oldest_volume,
              res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles);
       break;
    case R_MSGS:
       sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
-      if (res->res_msgs.mail_cmd) 
-         sendit(sock, "      mailcmd=%s\n", res->res_msgs.mail_cmd);
-      if (res->res_msgs.operator_cmd) 
-         sendit(sock, "      opcmd=%s\n", res->res_msgs.operator_cmd);
+      if (res->res_msgs.mail_cmd)
+        sendit(sock, "      mailcmd=%s\n", res->res_msgs.mail_cmd);
+      if (res->res_msgs.operator_cmd)
+        sendit(sock, "      opcmd=%s\n", res->res_msgs.operator_cmd);
       break;
    default:
       sendit(sock, "Unknown resource type %d in dump_resource.\n", type);
@@ -766,10 +766,10 @@ static void free_incexe(INCEXE *incexe)
    free(incexe);
 }
 
-/* 
+/*
  * Free memory of resource -- called when daemon terminates.
  * NB, we don't need to worry about freeing any references
- * to other resources as they will be freed when that 
+ * to other resources as they will be freed when that
  * resource chain is traversed.  Mainly we worry about freeing
  * allocated strings (names).
  */
@@ -869,14 +869,14 @@ void free_resource(RES *sres, int type)
       break;
    case R_FILESET:
       if ((num=res->res_fs.num_includes)) {
-        while (--num >= 0) {   
+        while (--num >= 0) {
            free_incexe(res->res_fs.include_items[num]);
         }
         free(res->res_fs.include_items);
       }
       res->res_fs.num_includes = 0;
       if ((num=res->res_fs.num_excludes)) {
-        while (--num >= 0) {   
+        while (--num >= 0) {
            free_incexe(res->res_fs.exclude_items[num]);
         }
         free(res->res_fs.exclude_items);
@@ -962,7 +962,7 @@ void free_resource(RES *sres, int 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 because they may not have been defined until 
+ * pointers because they may not have been defined until
  * later in pass 1.
  */
 void save_resource(int type, RES_ITEM *items, int pass)
@@ -971,28 +971,28 @@ void save_resource(int type, RES_ITEM *items, int pass)
    int rindex = type - r_first;
    int i, size;
    int error = 0;
-   
+
    /* Check Job requirements after applying JobDefs */
    if (type != R_JOB && type != R_JOBDEFS) {
-      /* 
+      /*
        * 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.res_dir.hdr.item_present)) {  
-                  Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n",
+              if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
+                 Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n",
                    items[i].name, resources[rindex]);
                }
         }
         /* If this triggers, take a look at lib/parse_conf.h */
         if (i >= MAX_RES_ITEMS) {
-            Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]);
+           Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]);
         }
       }
    }
 
    /*
-    * During pass 2 in each "store" routine, we looked up pointers 
+    * During pass 2 in each "store" routine, we looked up pointers
     * to all the resources referrenced in the current resource, now we
     * must copy their addresses from the static record to the allocated
     * record.
@@ -1011,14 +1011,14 @@ void save_resource(int type, RES_ITEM *items, int pass)
       /* Resources containing another resource */
       case R_DIRECTOR:
         if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) {
-            Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name);
+           Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name);
         }
         res->res_dir.messages = res_all.res_dir.messages;
         break;
       case R_JOB:
       case R_JOBDEFS:
         if ((res = (URES *)GetResWithName(type, res_all.res_dir.hdr.name)) == NULL) {
-            Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n", 
+           Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n",
                  res_all.res_dir.hdr.name);
         }
         res->res_job.messages   = res_all.res_job.messages;
@@ -1037,7 +1037,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
         break;
       case R_COUNTER:
         if ((res = (URES *)GetResWithName(R_COUNTER, res_all.res_counter.hdr.name)) == NULL) {
-            Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name);
+           Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name);
         }
         res->res_counter.Catalog = res_all.res_counter.Catalog;
         res->res_counter.WrapCounter = res_all.res_counter.WrapCounter;
@@ -1045,24 +1045,24 @@ void save_resource(int type, RES_ITEM *items, int pass)
 
       case R_CLIENT:
         if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_client.hdr.name)) == NULL) {
-            Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name);
+           Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name);
         }
         res->res_client.catalog = res_all.res_client.catalog;
         break;
       case R_SCHEDULE:
         /*
          * Schedule is a bit different in that it contains a RUN record
-          * chain which isn't a "named" resource. This chain was linked
-         * in by run_conf.c during pass 2, so here we jam the pointer 
-         * into the Schedule resource.                         
+         * chain which isn't a "named" resource. This chain was linked
+         * in by run_conf.c during pass 2, so here we jam the pointer
+         * into the Schedule resource.
          */
         if ((res = (URES *)GetResWithName(R_SCHEDULE, res_all.res_client.hdr.name)) == NULL) {
-            Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name);
+           Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name);
         }
         res->res_sch.run = res_all.res_sch.run;
         break;
       default:
-         Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type);
+        Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type);
         error = 1;
         break;
       }
@@ -1081,7 +1081,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
    }
 
    /*
-    * The following code is only executed during pass 1   
+    * The following code is only executed during pass 1
     */
    switch (type) {
    case R_DIRECTOR:
@@ -1094,7 +1094,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
       size =sizeof(CLIENT);
       break;
    case R_STORAGE:
-      size = sizeof(STORE); 
+      size = sizeof(STORE);
       break;
    case R_CATALOG:
       size = sizeof(CAT);
@@ -1130,7 +1130,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
       memcpy(res, &res_all, size);
       if (!res_head[rindex]) {
         res_head[rindex] = (RES *)res; /* store first entry */
-         Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
+        Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type),
               res->res_dir.hdr.name, rindex);
       } else {
         RES *next;
@@ -1138,24 +1138,24 @@ void save_resource(int type, RES_ITEM *items, int pass)
         for (next=res_head[rindex]; next->next; next=next->next) {
            if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
               Emsg2(M_ERROR_TERM, 0,
-                  _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
+                 _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
                  resources[rindex].name, res->res_dir.hdr.name);
            }
         }
         next->next = (RES *)res;
-         Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
+        Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type),
               res->res_dir.hdr.name, rindex, pass);
       }
    }
 }
 
-/* 
+/*
  * Store JobType (backup, verify, restore)
  *
  */
 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass)
 {
-   int token, i;   
+   int token, i;
 
    token = lex_get_token(lc, T_NAME);
    /* Store the type both pass 1 and pass 2 */
@@ -1173,7 +1173,7 @@ void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass)
    set_bit(index, res_all.hdr.item_present);
 }
 
-/* 
+/*
  * Store Job Level (Full, Incremental, ...)
  *
  */
@@ -1216,7 +1216,7 @@ void store_replace(LEX *lc, RES_ITEM *item, int index, int pass)
    set_bit(index, res_all.hdr.item_present);
 }
 
-/* 
+/*
  * Store ACL (access control list)
  *
  */
@@ -1227,12 +1227,12 @@ void store_acl(LEX *lc, RES_ITEM *item, int index, int pass)
    for (;;) {
       token = lex_get_token(lc, T_NAME);
       if (pass == 1) {
-        if (((alist **)item->value)[item->code] == NULL) {   
-           ((alist **)item->value)[item->code] = New(alist(10, owned_by_alist)); 
-            Dmsg1(900, "Defined new ACL alist at %d\n", item->code);
+        if (((alist **)item->value)[item->code] == NULL) {
+           ((alist **)item->value)[item->code] = New(alist(10, owned_by_alist));
+           Dmsg1(900, "Defined new ACL alist at %d\n", item->code);
         }
         ((alist **)item->value)[item->code]->append(bstrdup(lc->str));
-         Dmsg2(900, "Appended to %d %s\n", item->code, lc->str);
+        Dmsg2(900, "Appended to %d %s\n", item->code, lc->str);
       }
       token = lex_get_token(lc, T_ALL);
       if (token == T_COMMA) {
index d008a969f7a045993a7e3acecefedf17855e0028..30c10732ffb7bbbd85cbc641ada84f6cb393c0d6 100644 (file)
@@ -28,7 +28,7 @@
 /* NOTE:  #includes at the end of this file */
 
 /*
- * Resource codes -- they must be sequential for indexing   
+ * Resource codes -- they must be sequential for indexing
  */
 enum {
    R_DIRECTOR = 1001,
@@ -61,9 +61,9 @@ enum {
 
 
 /* Used for certain KeyWord tables */
-struct s_kw {       
+struct s_kw {
    const char *name;
-   int token;   
+   int token;
 };
 
 /* Job Level keyword structure */
@@ -87,8 +87,8 @@ struct FILESET;
 struct POOL;
 struct RUN;
 
-/* 
- *   Director Resource  
+/*
+ *   Director Resource
  *
  */
 struct DIRRES {
@@ -125,7 +125,7 @@ enum {
    Num_ACL                            /* keep last */
 };
 
-/* 
+/*
  *    Console Resource
  */
 struct CONRES {
@@ -174,7 +174,7 @@ struct CLIENT {
 
 /*
  *   Store Resource
- * 
+ *
  */
 struct STORE {
    RES   hdr;
@@ -184,7 +184,7 @@ struct STORE {
    char *address;
    char *password;
    char *media_type;
-   char *dev_name;   
+   char *dev_name;
    int  autochanger;                  /* set if autochanger */
    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
@@ -228,7 +228,7 @@ struct JOB {
    int RescheduleTimes;               /* Number of times to reschedule job */
    utime_t RescheduleInterval;        /* Reschedule interval */
    utime_t JobRetention;              /* job retention period in seconds */
-  
+
    MSGS      *messages;               /* How and where to send messages */
    SCHED     *schedule;               /* When -- Automatic schedule */
    CLIENT    *client;                 /* Who to backup */
@@ -266,7 +266,7 @@ struct INCEXE {
    alist name_list;                   /* filename list -- holds char * */
 };
 
-/* 
+/*
  *   FileSet Resource
  *
  */
@@ -284,8 +284,8 @@ struct FILESET {
    int ignore_fs_changes;             /* Don't force Full if FS changed */
 };
 
-/* 
+
+/*
  *   Schedule Resource
  *
  */
@@ -310,7 +310,7 @@ struct COUNTER {
 };
 
 /*
- *   Pool Resource   
+ *   Pool Resource
  *
  */
 struct POOL {
@@ -362,7 +362,7 @@ struct RUN {
    RUN *next;                         /* points to next run record */
    int level;                         /* level override */
    int Priority;                      /* priority override */
-   int job_type;  
+   int job_type;
    bool spool_data;                   /* Data spooling override */
    bool spool_data_set;               /* Data spooling override given */
    POOL *pool;                        /* Pool override */
index 112da2fe121906520782b356dd1e0fb9955899dc..feded84c14f44240813df9c29a4797e499ca4054 100644 (file)
@@ -32,7 +32,7 @@
 
 
 
-static int date_item(JCR *jcr, int code, 
+static int date_item(JCR *jcr, int code,
              const char **val_ptr, int *val_len, int *val_size)
 {
    struct tm tm;
@@ -71,7 +71,7 @@ static int date_item(JCR *jcr, int code,
    return 1;
 }
 
-static int job_item(JCR *jcr, int code, 
+static int job_item(JCR *jcr, int code,
              const char **val_ptr, int *val_len, int *val_size)
 {
    const char *str = " ";
@@ -97,7 +97,7 @@ static int job_item(JCR *jcr, int code,
    case 6:                           /* Client */
       str = jcr->client->hdr.name;
       if (!str) {
-         str = " ";
+        str = " ";
       }
       break;
    case 7:                           /* NumVols */
@@ -105,7 +105,7 @@ static int job_item(JCR *jcr, int code,
       str = buf;
       break;
    case 8:                           /* Pool */
-      str = jcr->pool->hdr.name;   
+      str = jcr->pool->hdr.name;
       break;
    case 9:                           /* Storage */
       str = jcr->store->hdr.name;
@@ -163,8 +163,8 @@ static struct s_built_in_vars built_in_vars[] = {
  * Search the table of built-in variables, and if found,
  *   call the appropriate subroutine to do the work.
  */
-static var_rc_t lookup_built_in_var(var_t *ctx, void *my_ctx, 
-         const char *var_ptr, int var_len, int var_index, 
+static var_rc_t lookup_built_in_var(var_t *ctx, void *my_ctx,
+         const char *var_ptr, int var_len, int var_index,
          const char **val_ptr, int *val_len, int *val_size)
 {
    JCR *jcr = (JCR *)my_ctx;
@@ -185,10 +185,10 @@ static var_rc_t lookup_built_in_var(var_t *ctx, void *my_ctx,
 
 
 /*
- * Search counter variables 
+ * Search counter variables
  */
-static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx, 
-         const char *var_ptr, int var_len, int var_inc, int var_index, 
+static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx,
+         const char *var_ptr, int var_len, int var_inc, int var_index,
          const char **val_ptr, int *val_len, int *val_size)
 {
    char buf[MAXSTRING];
@@ -202,16 +202,16 @@ static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx,
    LockRes();
    for (COUNTER *counter=NULL; (counter = (COUNTER *)GetNextRes(R_COUNTER, (RES *)counter)); ) {
       if (strcmp(counter->hdr.name, buf) == 0) {
-         Dmsg2(100, "Counter=%s val=%d\n", buf, counter->CurrentValue);
+        Dmsg2(100, "Counter=%s val=%d\n", buf, counter->CurrentValue);
         /* -1 => return size of array */
        if (var_index == -1) {
-            bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue);
-            *val_len = bsnprintf(buf, sizeof(buf), "%d", strlen(buf));
+           bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue);
+           *val_len = bsnprintf(buf, sizeof(buf), "%d", strlen(buf));
            *val_ptr = buf;
-            *val_size = 0;                  /* don't try to free val_ptr */
+           *val_size = 0;                  /* don't try to free val_ptr */
            return VAR_OK;
         } else {
-            bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue);
+           bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue);
            *val_ptr = bstrdup(buf);
            *val_len = strlen(buf);
            *val_size = *val_len + 1;
@@ -230,18 +230,18 @@ static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx,
               cr.MinValue = counter->MinValue;
               cr.MaxValue = counter->MaxValue;
               cr.CurrentValue = counter->CurrentValue;
-               Dmsg1(100, "New value=%d\n", cr.CurrentValue);
+              Dmsg1(100, "New value=%d\n", cr.CurrentValue);
               if (counter->WrapCounter) {
                  bstrncpy(cr.WrapCounter, counter->WrapCounter->hdr.name, sizeof(cr.WrapCounter));
               } else {
                  cr.WrapCounter[0] = 0;
               }
               if (!db_update_counter_record(jcr, jcr->db, &cr)) {
-                  Jmsg(jcr, M_ERROR, 0, _("Count not update counter %s: ERR=%s\n"),
+                 Jmsg(jcr, M_ERROR, 0, _("Count not update counter %s: ERR=%s\n"),
                     counter->hdr.name, db_strerror(jcr->db));
               }
            }
-        }       
+        }
         stat = VAR_OK;
         break;
       }
@@ -252,10 +252,10 @@ static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx,
 
 
 /*
- * Called here from "core" expand code to look up a variable   
+ * Called here from "core" expand code to look up a variable
  */
-static var_rc_t lookup_var(var_t *ctx, void *my_ctx, 
-         const char *var_ptr, int var_len, int var_inc, int var_index, 
+static var_rc_t lookup_var(var_t *ctx, void *my_ctx,
+         const char *var_ptr, int var_len, int var_inc, int var_index,
          const char **val_ptr, int *val_len, int *val_size)
 {
    char buf[MAXSTRING], *val, *p, *v;
@@ -286,8 +286,8 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx,
    }
    /* He wants to index the "array" */
    count = 1;
-   /* Find the size of the "array"                           
-    *  each element is separated by a |  
+   /* Find the size of the "array"
+    *  each element is separated by a |
     */
    for (p = val; *p; p++) {
       if (*p == '|') {
@@ -339,7 +339,7 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx,
    v[p-val] = 0;
    *val_ptr = v;
    *val_len = p-val;
-   *val_size = p-val+1;              
+   *val_size = p-val+1;
    Dmsg1(100, "v=%s\n", v);
    return VAR_OK;
 }
@@ -351,10 +351,10 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx,
  *   val_ptr points to the value string
  *   out_ptr points to string to be returned
  */
-static var_rc_t operate_var(var_t *var, void *my_ctx, 
-         const char *op_ptr, int op_len, 
+static var_rc_t operate_var(var_t *var, void *my_ctx,
+         const char *op_ptr, int op_len,
          const char *arg_ptr, int arg_len,
-         const char *val_ptr, int val_len, 
+         const char *val_ptr, int val_len,
          char **out_ptr, int *out_len, int *out_size)
 {
    var_rc_t stat = VAR_ERR_UNDEFINED_OPERATION;
@@ -372,12 +372,12 @@ static var_rc_t operate_var(var_t *var, void *my_ctx,
       buf[arg_len] = 0;
       Dmsg1(100, "Arg=%s\n", buf);
       memcpy(buf, val_ptr, val_len);
-      buf[val_len] = 0;   
+      buf[val_len] = 0;
       Dmsg1(100, "Val=%s\n", buf);
       LockRes();
       for (COUNTER *counter=NULL; (counter = (COUNTER *)GetNextRes(R_COUNTER, (RES *)counter)); ) {
         if (strcmp(counter->hdr.name, buf) == 0) {
-            Dmsg2(100, "counter=%s val=%s\n", counter->hdr.name, buf);
+           Dmsg2(100, "counter=%s val=%s\n", counter->hdr.name, buf);
            break;
         }
       }
@@ -389,7 +389,7 @@ static var_rc_t operate_var(var_t *var, void *my_ctx,
 }
 
 
-/* 
+/*
  * Expand an input line and return it.
  *
  *  Returns: 0 on failure
@@ -434,7 +434,7 @@ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp)
 
    /* expand variables */
    if ((stat = var_expand(var_ctx, inp, in_len, &outp, &out_len, 0)) != VAR_OK) {
-       Jmsg(jcr, M_ERROR, 0, _("Cannot expand expression \"%s\": ERR=%s\n"), 
+       Jmsg(jcr, M_ERROR, 0, _("Cannot expand expression \"%s\": ERR=%s\n"),
          inp, var_strerror(var_ctx, stat));
        goto bail_out;
    }
@@ -447,7 +447,7 @@ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp)
 
    pm_strcpy(exp, outp);
 
-   rtn_stat = 1;  
+   rtn_stat = 1;
 
 bail_out:
    /* destroy expansion context */
index 77ae25fdbf4a0a3234b733eca162e24972c83c14..20678f4f10321d59771b1ed88ec1c85e8a2a855f 100644 (file)
@@ -6,10 +6,10 @@
  *
  *    This routine is run as a separate thread.  There may be more
  *    work to be done to make it totally reentrant!!!!
- * 
+ *
  *  Utility functions for sending info to File Daemon.
  *   These functions are used by both backup and verify.
- *   
+ *
  *   Version $Id$
  */
 /*
@@ -59,14 +59,14 @@ static char OKRunAfter[]  = "2000 OK RunAfter\n";
 
 /* External functions */
 extern int debug_level;
-extern DIRRES *director; 
+extern DIRRES *director;
 extern int FDConnectTimeout;
 
 #define INC_LIST 0
 #define EXC_LIST 1
 
 /*
- * Open connection with File daemon. 
+ * Open connection with File daemon.
  * Try connecting every retry_interval (default 10 sec), and
  *   give up after max_retry_time (default 30 mins).
  */
@@ -78,7 +78,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time,
 
    if (!jcr->file_bsock) {
       fd = bnet_connect(jcr, retry_interval, max_retry_time,
-           _("File daemon"), jcr->client->address, 
+          _("File daemon"), jcr->client->address,
           NULL, jcr->client->FDport, verbose);
       if (fd == NULL) {
         set_jcr_job_status(jcr, JS_ErrorTerminated);
@@ -96,11 +96,11 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time,
       set_jcr_job_status(jcr, JS_ErrorTerminated);
       return 0;
    }
-       
+
    /*
     * Now send JobId and authorization key
     */
-   bnet_fsend(fd, jobcmd, jcr->JobId, jcr->Job, jcr->VolSessionId, 
+   bnet_fsend(fd, jobcmd, jcr->JobId, jcr->Job, jcr->VolSessionId,
       jcr->VolSessionTime, jcr->sd_auth_key);
    if (strcmp(jcr->sd_auth_key, "dummy") != 0) {
       memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key));
@@ -109,7 +109,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time,
    if (bget_dirmsg(fd) > 0) {
        Dmsg1(110, "<filed: %s", fd->msg);
        if (strncmp(fd->msg, OKjob, strlen(OKjob)) != 0) {
-          Jmsg(jcr, M_FATAL, 0, _("File daemon \"%s\" rejected Job command: %s\n"), 
+         Jmsg(jcr, M_FATAL, 0, _("File daemon \"%s\" rejected Job command: %s\n"),
             jcr->client->hdr.name, fd->msg);
          set_jcr_job_status(jcr, JS_ErrorTerminated);
          return 0;
@@ -122,7 +122,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time,
          cr.JobRetention = jcr->client->JobRetention;
          bstrncpy(cr.Uname, fd->msg+strlen(OKjob)+1, sizeof(cr.Uname));
          if (!db_update_client_record(jcr, jcr->db, &cr)) {
-             Jmsg(jcr, M_WARNING, 0, _("Error updating Client record. ERR=%s\n"),
+            Jmsg(jcr, M_WARNING, 0, _("Error updating Client record. ERR=%s\n"),
                db_strerror(jcr->db));
          }
        }
@@ -137,15 +137,15 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time,
 
 /*
  * This subroutine edits the last job start time into a
- *   "since=date/time" buffer that is returned in the  
+ *   "since=date/time" buffer that is returned in the
  *   variable since.  This is used for display purposes in
- *   the job report.  The time in jcr->stime is later 
+ *   the job report.  The time in jcr->stime is later
  *   passed to tell the File daemon what to do.
  */
 void get_level_since_time(JCR *jcr, char *since, int since_len)
 {
    int JobLevel;
-   /* Lookup the last FULL backup job to get the time/date for a 
+   /* Lookup the last FULL backup job to get the time/date for a
     * differential or incremental save.
     */
    if (!jcr->stime) {
@@ -160,24 +160,24 @@ void get_level_since_time(JCR *jcr, char *since, int since_len)
       jcr->jr.JobId = 0;     /* flag for db_find_job_start time */
       if (!db_find_job_start_time(jcr, jcr->db, &jcr->jr, &jcr->stime)) {
         /* No job found, so upgrade this one to Full */
-         Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db));
-         Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found. Doing FULL backup.\n"));
-         bsnprintf(since, since_len, " (upgraded from %s)", 
+        Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db));
+        Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found. Doing FULL backup.\n"));
+        bsnprintf(since, since_len, " (upgraded from %s)",
            level_to_str(jcr->JobLevel));
         jcr->JobLevel = jcr->jr.JobLevel = L_FULL;
       } else {
         if (jcr->job->rerun_failed_levels) {
            if (db_find_failed_job_since(jcr, jcr->db, &jcr->jr, jcr->stime, JobLevel)) {
-               Jmsg(jcr, M_INFO, 0, _("Prior failed job found. Upgrading to %s.\n"),
+              Jmsg(jcr, M_INFO, 0, _("Prior failed job found. Upgrading to %s.\n"),
                  level_to_str(JobLevel));
-               bsnprintf(since, since_len, " (upgraded from %s)", 
+              bsnprintf(since, since_len, " (upgraded from %s)",
                  level_to_str(jcr->JobLevel));
               jcr->JobLevel = jcr->jr.JobLevel = JobLevel;
               jcr->jr.JobId = jcr->JobId;
               break;
            }
-        }       
-         bstrncpy(since, ", since=", since_len);
+        }
+        bstrncpy(since, ", since=", since_len);
         bstrncat(since, jcr->stime, since_len);
       }
       jcr->jr.JobId = jcr->JobId;
@@ -188,15 +188,15 @@ void get_level_since_time(JCR *jcr, char *since, int since_len)
 
 
 /*
- * Send level command to FD. 
+ * Send level command to FD.
  * Used for backup jobs and estimate command.
  */
-int send_level_command(JCR *jcr) 
+int send_level_command(JCR *jcr)
 {
    BSOCK   *fd = jcr->file_bsock;
    utime_t stime;
    char ed1[50];
-   /* 
+   /*
     * Send Level command to File daemon
     */
    switch (jcr->JobLevel) {
@@ -213,12 +213,12 @@ int send_level_command(JCR *jcr)
       stime = str_to_utime(jcr->stime);
       bnet_fsend(fd, levelcmd, "since_utime ", edit_uint64(stime, ed1), 0);
       while (bget_dirmsg(fd) >= 0) {  /* allow him to poll us to sync clocks */
-         Jmsg(jcr, M_INFO, 0, "%s\n", fd->msg);
+        Jmsg(jcr, M_INFO, 0, "%s\n", fd->msg);
       }
       break;
    case L_SINCE:
    default:
-      Jmsg2(jcr, M_FATAL, 0, _("Unimplemented backup level %d %c\n"), 
+      Jmsg2(jcr, M_FATAL, 0, _("Unimplemented backup level %d %c\n"),
         jcr->JobLevel, jcr->JobLevel);
       return 0;
    }
@@ -265,80 +265,80 @@ static int send_list(JCR *jcr, int list)
       for (int j=0; j<ie->name_list.size(); j++) {
         p = (char *)ie->name_list.get(j);
         switch (*p) {
-         case '|':
+        case '|':
            p++;                      /* skip over the | */
-            fd->msg = edit_job_codes(jcr, fd->msg, p, "");
-            bpipe = open_bpipe(fd->msg, 0, "r");
+           fd->msg = edit_job_codes(jcr, fd->msg, p, "");
+           bpipe = open_bpipe(fd->msg, 0, "r");
            if (!bpipe) {
               berrno be;
-               Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
+              Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
                  p, be.strerror());
               goto bail_out;
            }
            /* Copy File options */
            if (ie->num_opts) {
               bstrncpy(buf, ie->opts_list[0]->opts, sizeof(buf));
-               bstrncat(buf, " ", sizeof(buf));
+              bstrncat(buf, " ", sizeof(buf));
            } else {
-               bstrncpy(buf, "0 ", sizeof(buf));
+              bstrncpy(buf, "0 ", sizeof(buf));
            }
-            Dmsg1(500, "Opts=%s\n", buf);
+           Dmsg1(500, "Opts=%s\n", buf);
            optlen = strlen(buf);
            while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) {
-               fd->msglen = Mmsg(fd->msg, "%s", buf);
-               Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg);
+              fd->msglen = Mmsg(fd->msg, "%s", buf);
+              Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg);
               if (!bnet_send(fd)) {
-                  Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
+                 Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
                  goto bail_out;
               }
            }
            if ((stat=close_bpipe(bpipe)) != 0) {
               berrno be;
-               Jmsg(jcr, M_FATAL, 0, _("Error running program %p: ERR=%s\n"),
+              Jmsg(jcr, M_FATAL, 0, _("Error running program %p: ERR=%s\n"),
                  p, be.strerror(stat));
               goto bail_out;
            }
            break;
-         case '<':
+        case '<':
            p++;                      /* skip over < */
-            if ((ffd = fopen(p, "r")) == NULL) {
-               Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"),
-                  list==INC_LIST?"included":"excluded", p, strerror(errno));
+           if ((ffd = fopen(p, "r")) == NULL) {
+              Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"),
+                 list==INC_LIST?"included":"excluded", p, strerror(errno));
               goto bail_out;
            }
            /* Copy File options */
            if (ie->num_opts) {
               bstrncpy(buf, ie->opts_list[0]->opts, sizeof(buf));
-               bstrncat(buf, " ", sizeof(buf));
+              bstrncat(buf, " ", sizeof(buf));
            } else {
-               bstrncpy(buf, "0 ", sizeof(buf));
+              bstrncpy(buf, "0 ", sizeof(buf));
            }
-            Dmsg1(500, "Opts=%s\n", buf);
+           Dmsg1(500, "Opts=%s\n", buf);
            optlen = strlen(buf);
            while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) {
-               fd->msglen = Mmsg(fd->msg, "%s", buf);
+              fd->msglen = Mmsg(fd->msg, "%s", buf);
               if (!bnet_send(fd)) {
-                  Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
+                 Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
                  goto bail_out;
               }
            }
            fclose(ffd);
            break;
-         case '\\':
-            p++;                      /* skip over \ */
+        case '\\':
+           p++;                      /* skip over \ */
            /* Note, fall through wanted */
         default:
            if (ie->num_opts) {
-               Dmsg2(500, "numopts=%d opts=%s\n", ie->num_opts, NPRT(ie->opts_list[0]->opts));
+              Dmsg2(500, "numopts=%d opts=%s\n", ie->num_opts, NPRT(ie->opts_list[0]->opts));
               pm_strcpy(fd->msg, ie->opts_list[0]->opts);
-               pm_strcat(fd->msg, " ");
+              pm_strcat(fd->msg, " ");
            } else {
-               pm_strcpy(fd->msg, "0 ");
+              pm_strcpy(fd->msg, "0 ");
            }
            fd->msglen = pm_strcat(fd->msg, p);
-            Dmsg1(500, "Inc/Exc name=%s\n", fd->msg);
+           Dmsg1(500, "Inc/Exc name=%s\n", fd->msg);
            if (!bnet_send(fd)) {
-               Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
+              Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
               goto bail_out;
            }
            break;
@@ -377,7 +377,7 @@ static int send_fileset(JCR *jcr)
         num = fileset->num_includes;
       } else {
         num = fileset->num_excludes;
-      }  
+      }
       for (int i=0; i<num; i++) {
         BPIPE *bpipe;
         FILE *ffd;
@@ -389,101 +389,101 @@ static int send_fileset(JCR *jcr)
 
         if (include) {
            ie = fileset->include_items[i];
-            bnet_fsend(fd, "I\n");
+           bnet_fsend(fd, "I\n");
         } else {
            ie = fileset->exclude_items[i];
-            bnet_fsend(fd, "E\n");
-        }       
+           bnet_fsend(fd, "E\n");
+        }
         for (j=0; j<ie->num_opts; j++) {
            FOPTS *fo = ie->opts_list[j];
-            bnet_fsend(fd, "O %s\n", fo->opts);
+           bnet_fsend(fd, "O %s\n", fo->opts);
            for (k=0; k<fo->regex.size(); k++) {
-               bnet_fsend(fd, "R %s\n", fo->regex.get(k));
+              bnet_fsend(fd, "R %s\n", fo->regex.get(k));
            }
            for (k=0; k<fo->wild.size(); k++) {
-               bnet_fsend(fd, "W %s\n", fo->wild.get(k));
+              bnet_fsend(fd, "W %s\n", fo->wild.get(k));
            }
            for (k=0; k<fo->base.size(); k++) {
-               bnet_fsend(fd, "B %s\n", fo->base.get(k));
+              bnet_fsend(fd, "B %s\n", fo->base.get(k));
            }
            for (k=0; k<fo->fstype.size(); k++) {
-               bnet_fsend(fd, "X %s\n", fo->fstype.get(k));
+              bnet_fsend(fd, "X %s\n", fo->fstype.get(k));
            }
            if (fo->reader) {
-               bnet_fsend(fd, "D %s\n", fo->reader);
+              bnet_fsend(fd, "D %s\n", fo->reader);
            }
            if (fo->writer) {
-               bnet_fsend(fd, "T %s\n", fo->writer);
+              bnet_fsend(fd, "T %s\n", fo->writer);
            }
-            bnet_fsend(fd, "N\n");
+           bnet_fsend(fd, "N\n");
         }
 
         for (j=0; j<ie->name_list.size(); j++) {
            p = (char *)ie->name_list.get(j);
            switch (*p) {
-            case '|':
+           case '|':
               p++;                      /* skip over the | */
-               fd->msg = edit_job_codes(jcr, fd->msg, p, "");
-               bpipe = open_bpipe(fd->msg, 0, "r");
+              fd->msg = edit_job_codes(jcr, fd->msg, p, "");
+              bpipe = open_bpipe(fd->msg, 0, "r");
               if (!bpipe) {
                  berrno be;
-                  Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
+                 Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
                     p, be.strerror());
                  goto bail_out;
               }
-               bstrncpy(buf, "F ", sizeof(buf));
-               Dmsg1(500, "Opts=%s\n", buf);
+              bstrncpy(buf, "F ", sizeof(buf));
+              Dmsg1(500, "Opts=%s\n", buf);
               optlen = strlen(buf);
               while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) {
-                  fd->msglen = Mmsg(fd->msg, "%s", buf);
-                  Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg);
+                 fd->msglen = Mmsg(fd->msg, "%s", buf);
+                 Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg);
                  if (!bnet_send(fd)) {
-                     Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
+                    Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
                     goto bail_out;
                  }
               }
               if ((stat=close_bpipe(bpipe)) != 0) {
                  berrno be;
-                  Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. ERR=%s\n"),
+                 Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. ERR=%s\n"),
                     p, be.strerror(stat));
                  goto bail_out;
               }
               break;
-            case '<':
+           case '<':
               p++;                      /* skip over < */
-               if ((ffd = fopen(p, "r")) == NULL) {
+              if ((ffd = fopen(p, "r")) == NULL) {
                  berrno be;
-                  Jmsg(jcr, M_FATAL, 0, _("Cannot open included file: %s. ERR=%s\n"),
+                 Jmsg(jcr, M_FATAL, 0, _("Cannot open included file: %s. ERR=%s\n"),
                     p, be.strerror());
                  goto bail_out;
               }
-               bstrncpy(buf, "F ", sizeof(buf));
-               Dmsg1(500, "Opts=%s\n", buf);
+              bstrncpy(buf, "F ", sizeof(buf));
+              Dmsg1(500, "Opts=%s\n", buf);
               optlen = strlen(buf);
               while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) {
-                  fd->msglen = Mmsg(fd->msg, "%s", buf);
+                 fd->msglen = Mmsg(fd->msg, "%s", buf);
                  if (!bnet_send(fd)) {
-                     Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
+                    Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
                     goto bail_out;
                  }
               }
               fclose(ffd);
               break;
-            case '\\':
-               p++;                      /* skip over \ */
+           case '\\':
+              p++;                      /* skip over \ */
               /* Note, fall through wanted */
            default:
-               pm_strcpy(fd->msg, "F ");
+              pm_strcpy(fd->msg, "F ");
               fd->msglen = pm_strcat(fd->msg, p);
-               Dmsg1(500, "Inc/Exc name=%s\n", fd->msg);
+              Dmsg1(500, "Inc/Exc name=%s\n", fd->msg);
               if (!bnet_send(fd)) {
-                  Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
+                 Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
                  goto bail_out;
               }
               break;
            }
         }
-         bnet_fsend(fd, "N\n");
+        bnet_fsend(fd, "N\n");
       }
       if (!include) {                /* If we just did excludes */
         break;                       /*   all done */
@@ -521,7 +521,7 @@ int send_include_list(JCR *jcr)
 
 
 /*
- * Send exclude list to File daemon 
+ * Send exclude list to File daemon
  */
 int send_exclude_list(JCR *jcr)
 {
@@ -552,14 +552,14 @@ int send_bootstrap_file(JCR *jcr)
    bs = fopen(jcr->RestoreBootstrap, "r");
    if (!bs) {
       berrno be;
-      Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), 
+      Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
         jcr->RestoreBootstrap, be.strerror());
       set_jcr_job_status(jcr, JS_ErrorTerminated);
       return 0;
    }
    bnet_fsend(fd, bootstrap);
    while (fgets(buf, sizeof(buf), bs)) {
-      bnet_fsend(fd, "%s", buf);       
+      bnet_fsend(fd, "%s", buf);
    }
    bnet_sig(fd, BNET_EOD);
    fclose(bs);
@@ -602,7 +602,7 @@ int send_run_before_and_after_commands(JCR *jcr)
 }
 
 
-/* 
+/*
  * Read the attributes from the File daemon for
  * a Verify job and store them in the catalog.
  */
@@ -621,7 +621,7 @@ int get_attributes_and_put_in_catalog(JCR *jcr)
    /* Pickup file attributes and signature */
    while (!fd->errors && (n = bget_dirmsg(fd)) > 0) {
 
-   /*****FIXME****** improve error handling to stop only on 
+   /*****FIXME****** improve error handling to stop only on
     * really fatal problems, or the number of errors is too
     * large.
     */
@@ -633,8 +633,8 @@ int get_attributes_and_put_in_catalog(JCR *jcr)
 
       jcr->fname = check_pool_memory_size(jcr->fname, fd->msglen);
       if ((len = sscanf(fd->msg, "%ld %d %s", &file_index, &stream, Opts_SIG)) != 3) {
-         Jmsg(jcr, M_FATAL, 0, _("<filed: bad attributes, expected 3 fields got %d\n\
-msglen=%d msg=%s\n"), len, fd->msglen, fd->msg);
+        Jmsg(jcr, M_FATAL, 0, _("<filed: bad attributes, expected 3 fields got %d\n"
+"msglen=%d msg=%s\n"), len, fd->msglen, fd->msg);
         set_jcr_job_status(jcr, JS_ErrorTerminated);
         return 0;
       }
@@ -643,7 +643,7 @@ msglen=%d msg=%s\n"), len, fd->msglen, fd->msg);
       skip_spaces(&p);
       skip_nonspaces(&p);            /* skip Stream */
       skip_spaces(&p);
-      skip_nonspaces(&p);            /* skip Opts_SHA1 */   
+      skip_nonspaces(&p);            /* skip Opts_SHA1 */
       p++;                           /* skip space */
       fn = jcr->fname;
       while (*p != 0) {
@@ -665,33 +665,33 @@ msglen=%d msg=%s\n"), len, fd->msglen, fd->msg);
         ar.PathId = 0;
         ar.FilenameId = 0;
 
-         Dmsg2(111, "dird<filed: stream=%d %s\n", stream, jcr->fname);
-         Dmsg1(120, "dird<filed: attr=%s\n", attr);
+        Dmsg2(111, "dird<filed: stream=%d %s\n", stream, jcr->fname);
+        Dmsg1(120, "dird<filed: attr=%s\n", attr);
 
         if (!db_create_file_attributes_record(jcr, jcr->db, &ar)) {
-            Jmsg1(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
+           Jmsg1(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
            set_jcr_job_status(jcr, JS_Error);
            continue;
         }
         jcr->FileId = ar.FileId;
       } else if (stream == STREAM_MD5_SIGNATURE || stream == STREAM_SHA1_SIGNATURE) {
         if (jcr->FileIndex != (uint32_t)file_index) {
-            Jmsg2(jcr, M_ERROR, 0, _("MD5/SHA1 index %d not same as attributes %d\n"),
+           Jmsg2(jcr, M_ERROR, 0, _("MD5/SHA1 index %d not same as attributes %d\n"),
               file_index, jcr->FileIndex);
            set_jcr_job_status(jcr, JS_Error);
            continue;
         }
         db_escape_string(SIG, Opts_SIG, strlen(Opts_SIG));
-         Dmsg2(120, "SIGlen=%d SIG=%s\n", strlen(SIG), SIG);
-        if (!db_add_SIG_to_file_record(jcr, jcr->db, jcr->FileId, SIG, 
+        Dmsg2(120, "SIGlen=%d SIG=%s\n", strlen(SIG), SIG);
+        if (!db_add_SIG_to_file_record(jcr, jcr->db, jcr->FileId, SIG,
                   stream==STREAM_MD5_SIGNATURE?MD5_SIG:SHA1_SIG)) {
-            Jmsg1(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
+           Jmsg1(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
            set_jcr_job_status(jcr, JS_Error);
         }
       }
       jcr->jr.JobFiles = jcr->JobFiles = file_index;
       jcr->jr.LastIndex = file_index;
-   } 
+   }
    if (is_bnet_error(fd)) {
       Jmsg1(jcr, M_FATAL, 0, _("<filed: Network error getting attributes. ERR=%s\n"),
                        bnet_strerror(fd));
index 50546e75c57a74c2749c34089d9ac63d7702e302..6eba9894e9000883acf228470997d20c8b53ba98 100644 (file)
@@ -9,12 +9,12 @@
  *    This routine runs as a thread and must be thread reentrant.
  *
  *  Basic tasks done here:
- *    Handle  network signals (signals).  
+ *    Handle  network signals (signals).
  *      Signals always have return status 0 from bnet_recv() and
  *      a zero or negative message length.
- *    Pass appropriate messages back to the caller (responses).  
+ *    Pass appropriate messages back to the caller (responses).
  *      Responses always have a digit as the first character.
- *    Handle requests for message and catalog services (requests).  
+ *    Handle requests for message and catalog services (requests).
  *      Requests are any message that does not begin with a digit.
  *      In affect, they are commands.
  *
@@ -58,7 +58,7 @@ static char OK_msg[] = "1000 OK\n";
  *  another daemon. If the message is in canonical message
  *  format and the type is known, it will be dispatched
  *  to the appropriate handler.  If the message is
- *  in any other format, it will be returned. 
+ *  in any other format, it will be returned.
  *
  *  E.g. any message beginning with a digit will be returned.
  *      any message beginning with Jmsg will be processed.
@@ -102,92 +102,92 @@ int bget_dirmsg(BSOCK *bs)
            break;
         case BNET_STATUS:
            /* *****FIXME***** Implement more completely */
-            bnet_fsend(bs, "Status OK\n");
+           bnet_fsend(bs, "Status OK\n");
            bnet_sig(bs, BNET_EOD);
            break;
         case BNET_BTIME:             /* send Bacula time */
            char ed1[50];
-            bnet_fsend(bs, "btime %s\n", edit_uint64(get_current_btime(),ed1));
+           bnet_fsend(bs, "btime %s\n", edit_uint64(get_current_btime(),ed1));
            break;
         default:
-            Emsg1(M_WARNING, 0, _("bget_dirmsg: unknown bnet signal %d\n"), bs->msglen);
+           Emsg1(M_WARNING, 0, _("bget_dirmsg: unknown bnet signal %d\n"), bs->msglen);
            return n;
         }
         continue;
       }
-     
+
       /* Handle normal data */
 
       if (n > 0 && B_ISDIGIT(bs->msg[0])) {     /* response? */
         return n;                    /* yes, return it */
       }
-       
+
       /*
        * If we get here, it must be a request. Either
        *  a message to dispatch, or a catalog request.
        *  Try to fulfill it.
        */
       if (sscanf(bs->msg, "%020s Job=%127s ", MsgType, Job) != 2) {
-         Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
+        Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
         continue;
       }
       if (!(jcr=get_jcr_by_full_name(Job))) {
-         Emsg1(M_ERROR, 0, _("Job not found: %s\n"), bs->msg);
+        Emsg1(M_ERROR, 0, _("Job not found: %s\n"), bs->msg);
         continue;
       }
       Dmsg1(200, "Getmsg got jcr 0x%x\n", jcr);
 
       /* Skip past "Jmsg Job=nnn" */
       if (!(msg=find_msg_start(bs->msg))) {
-         Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
+        Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
         free_jcr(jcr);
         continue;
       }
 
-      /* 
+      /*
        * Here we are expecting a message of the following format:
        *   Jmsg Job=nnn type=nnn level=nnn Message-string
        */
       if (bs->msg[0] == 'J') {           /* Job message */
-         if (sscanf(bs->msg, "Jmsg Job=%127s type=%d level=%d", 
+        if (sscanf(bs->msg, "Jmsg Job=%127s type=%d level=%d",
                    Job, &type, &level) != 3) {
-            Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
+           Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
            free_jcr(jcr);
            continue;
         }
-         Dmsg1(120, "Got msg: %s\n", bs->msg);
+        Dmsg1(120, "Got msg: %s\n", bs->msg);
         skip_spaces(&msg);
         skip_nonspaces(&msg);        /* skip type=nnn */
         skip_spaces(&msg);
         skip_nonspaces(&msg);        /* skip level=nnn */
-         if (*msg == ' ') {
+        if (*msg == ' ') {
            msg++;                    /* skip leading space */
         }
-         Dmsg1(120, "Dispatch msg: %s", msg);
+        Dmsg1(120, "Dispatch msg: %s", msg);
         dispatch_message(jcr, type, level, msg);
         free_jcr(jcr);
         continue;
       }
-      /* 
+      /*
        * Here we expact a CatReq message
        *   CatReq Job=nn Catalog-Request-Message
        */
       if (bs->msg[0] == 'C') {        /* Catalog request */
-         Dmsg2(120, "Catalog req jcr 0x%x: %s", jcr, bs->msg);
+        Dmsg2(120, "Catalog req jcr 0x%x: %s", jcr, bs->msg);
         catalog_request(jcr, bs, msg);
-         Dmsg1(200, "Calling freejcr 0x%x\n", jcr);
+        Dmsg1(200, "Calling freejcr 0x%x\n", jcr);
         free_jcr(jcr);
         continue;
       }
       if (bs->msg[0] == 'U') {        /* Catalog update */
-         Dmsg2(120, "Catalog upd jcr 0x%x: %s", jcr, bs->msg);
+        Dmsg2(120, "Catalog upd jcr 0x%x: %s", jcr, bs->msg);
         catalog_update(jcr, bs, msg);
-         Dmsg1(200, "Calling freejcr 0x%x\n", jcr);
+        Dmsg1(200, "Calling freejcr 0x%x\n", jcr);
         free_jcr(jcr);
         continue;
       }
       if (bs->msg[0] == 'M') {        /* Mount request */
-         Dmsg1(120, "Mount req: %s", bs->msg);
+        Dmsg1(120, "Mount req: %s", bs->msg);
         mount_request(jcr, bs, msg);
         free_jcr(jcr);
         continue;
@@ -227,11 +227,11 @@ int response(JCR *jcr, BSOCK *fd, char *resp, const char *cmd, e_prtmsg prtmsg)
         return 1;
       }
       if (prtmsg == DISPLAY_ERROR) {
-         Jmsg(jcr, M_FATAL, 0, _("FD gave bad response to %s command: wanted %s got: %s\n"),
+        Jmsg(jcr, M_FATAL, 0, _("FD gave bad response to %s command: wanted %s got: %s\n"),
            cmd, resp, fd->msg);
       }
       return 0;
-   } 
+   }
    Jmsg(jcr, M_FATAL, 0, _("Socket error from Filed on %s command: ERR=%s\n"),
         cmd, bnet_strerror(fd));
    return 0;
index 079904c94c186ffea41b9a3dcec7a3a0791f4886..e723ce4c7e709a85bb4dfbba568db593ccbd35ca 100644 (file)
@@ -7,7 +7,7 @@
  *     Version $Id$
  */
 /*
-   Copyright (C) 2003-2004 Kern Sibbald and John Walker
+   Copyright (C) 2003-2004 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
@@ -60,14 +60,14 @@ extern int  res_all_size;
 /* We build the current new Include and Exclude items here */
 static INCEXE res_incexe;
 
-/* 
+/*
  * new Include/Exclude items
  *   name            handler     value    code flags default_value
  */
 static RES_ITEM newinc_items[] = {
    {"file",            store_fname,   NULL,     0, 0, 0},
    {"options",         options_res,   NULL,     0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
 /*
@@ -96,7 +96,7 @@ static RES_ITEM options_items[] = {
    {"ignorecase",      store_opts,    NULL,     0, 0, 0},
    {"fstype",          store_fstype,  NULL,     0, 0, 0},
    {"hfsplussupport",  store_opts,    NULL,     0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
 
@@ -157,7 +157,7 @@ struct s_fs_opt {
 };
 
 /*
- * Options permitted for each keyword and resulting value.     
+ * Options permitted for each keyword and resulting value.
  * The output goes into opts, which are then transmitted to
  * the FD for application as options to the following list of
  * included files.
@@ -209,8 +209,8 @@ static struct s_fs_opt FS_options[] = {
 
 
 
-/* 
- * Scan for right hand side of Include options (keyword=option) is 
+/*
+ * Scan for right hand side of Include options (keyword=option) is
  *    converted into one or two characters. Verifyopts=xxxx is Vxxxx:
  *    Whatever is found is concatenated to the opts string.
  * This code is also used inside an Options resource.
@@ -219,10 +219,12 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen)
 {
    int token, i;
    char option[3];
+   int lcopts = lc->options;
 
    option[0] = 0;                    /* default option = none */
    option[2] = 0;                    /* terminate options */
-   token = lex_get_token(lc, T_NAME);            /* expect at least one option */       
+   lc->options |= LOPT_STRING;       /* force string */
+   token = lex_get_token(lc, T_STRING);         /* expect at least one option */
    if (keyword == INC_KW_VERIFY) { /* special case */
       /* ***FIXME**** ensure these are in permitted set */
       bstrncat(opts, "V", optlen);         /* indicate Verify */
@@ -231,7 +233,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen)
       Dmsg3(900, "Catopts=%s option=%s optlen=%d\n", opts, option,optlen);
 
    /*
-    * Standard keyword options for Include/Exclude 
+    * Standard keyword options for Include/Exclude
     */
    } else {
       for (i=0; FS_options[i].name; i++) {
@@ -250,6 +252,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen)
          Dmsg3(900, "Catopts=%s option=%s optlen=%d\n", opts, option,optlen);
       }
    }
+   lc->options = lcopts;
 
    /* If option terminated by comma, eat it */
    if (lc->ch == ',') {
@@ -257,9 +260,9 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen)
    }
 }
 
-/* 
- * 
- * Store FileSet Include/Exclude info  
+/*
+ *
+ * Store FileSet Include/Exclude info
  *  NEW style includes are handled in store_newinc()
  */
 void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
@@ -275,7 +278,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
     *  new Include is followed immediately by open brace, whereas the
     *  old include has options following the Include.
     */
-   token = lex_get_token(lc, T_SKIP_EOL);           
+   token = lex_get_token(lc, T_SKIP_EOL);
    if (token == T_BOB) {
       store_newinc(lc, item, index, pass);
       return;
@@ -292,7 +295,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
    /* Get include options */
    inc_opts[0] = 0;
    while ((token=lex_get_token(lc, T_SKIP_EOL)) != T_BOB) {
-        
+
       keyword = INC_KW_NONE;
       for (i=0; FS_option_kw[i].name; i++) {
         if (strcasecmp(lc->str, FS_option_kw[i].name) == 0) {
@@ -377,11 +380,11 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
            break;
         default:
             scan_err1(lc, "Expected a filename, got: %s", lc->str);
-        }                                 
+        }
       }
       /* Note, MD5Final is done in backup.c */
    } else { /* pass 2 */
-      while (lex_get_token(lc, T_ALL) != T_EOB) 
+      while (lex_get_token(lc, T_ALL) != T_EOB)
         {}
    }
    scan_to_eol(lc);
@@ -391,7 +394,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
 
 
 /*
- * Store NEW style FileSet FInclude/FExclude info   
+ * Store NEW style FileSet FInclude/FExclude info
  *
  *  Note, when this routine is called, we are inside a FileSet
  *  resource.  We treat the Include/Execlude like a sort of
@@ -401,7 +404,7 @@ static void store_newinc(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token, i;
    INCEXE *incexe;
-   bool options;  
+   bool options;
 
    if (!res_all.res_fs.have_MD5) {
       MD5Init(&res_all.res_fs.md5c);
@@ -471,7 +474,7 @@ static void store_regex(LEX *lc, RES_ITEM *item, int index, int pass)
    regex_t preg;
    char prbuf[500];
 
-   token = lex_get_token(lc, T_SKIP_EOL);           
+   token = lex_get_token(lc, T_SKIP_EOL);
    if (pass == 1) {
       /* Pickup regex string
        */
@@ -488,12 +491,12 @@ static void store_regex(LEX *lc, RES_ITEM *item, int index, int pass)
         }
         regfree(&preg);
         res_incexe.current_opts->regex.append(bstrdup(lc->str));
-         Dmsg3(900, "set regex %p size=%d %s\n", 
+         Dmsg3(900, "set regex %p size=%d %s\n",
            res_incexe.current_opts, res_incexe.current_opts->regex.size(),lc->str);
         break;
       default:
          scan_err1(lc, _("Expected a regex string, got: %s\n"), lc->str);
-      }                                
+      }
    }
    scan_to_eol(lc);
 }
@@ -503,7 +506,7 @@ static void store_base(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token;
 
-   token = lex_get_token(lc, T_NAME);          
+   token = lex_get_token(lc, T_NAME);
    if (pass == 1) {
       /*
        * Pickup Base Job Name
@@ -518,12 +521,12 @@ static void store_reader(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token;
 
-   token = lex_get_token(lc, T_NAME);          
+   token = lex_get_token(lc, T_NAME);
    if (pass == 1) {
       /*
        * Pickup reader command
        */
-      res_incexe.current_opts->reader = bstrdup(lc->str); 
+      res_incexe.current_opts->reader = bstrdup(lc->str);
    }
    scan_to_eol(lc);
 }
@@ -533,7 +536,7 @@ static void store_writer(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token;
 
-   token = lex_get_token(lc, T_NAME);          
+   token = lex_get_token(lc, T_NAME);
    if (pass == 1) {
       /*
        * Pickup writer command
@@ -550,7 +553,7 @@ static void store_wild(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token;
 
-   token = lex_get_token(lc, T_SKIP_EOL);           
+   token = lex_get_token(lc, T_SKIP_EOL);
    if (pass == 1) {
       /*
        * Pickup Wild-card string
@@ -560,12 +563,12 @@ static void store_wild(LEX *lc, RES_ITEM *item, int index, int pass)
       case T_UNQUOTED_STRING:
       case T_QUOTED_STRING:
         res_incexe.current_opts->wild.append(bstrdup(lc->str));
-         Dmsg3(900, "set wild %p size=%d %s\n", 
+         Dmsg3(900, "set wild %p size=%d %s\n",
            res_incexe.current_opts, res_incexe.current_opts->wild.size(),lc->str);
         break;
       default:
          scan_err1(lc, _("Expected a wild-card string, got: %s\n"), lc->str);
-      }                                
+      }
    }
    scan_to_eol(lc);
 }
@@ -575,7 +578,7 @@ static void store_fstype(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token;
 
-   token = lex_get_token(lc, T_SKIP_EOL);           
+   token = lex_get_token(lc, T_SKIP_EOL);
    if (pass == 1) {
       /* Pickup fstype string */
       switch (token) {
@@ -583,12 +586,12 @@ static void store_fstype(LEX *lc, RES_ITEM *item, int index, int pass)
       case T_UNQUOTED_STRING:
       case T_QUOTED_STRING:
         res_incexe.current_opts->fstype.append(bstrdup(lc->str));
-         Dmsg3(900, "set fstype %p size=%d %s\n", 
+         Dmsg3(900, "set fstype %p size=%d %s\n",
            res_incexe.current_opts, res_incexe.current_opts->fstype.size(), lc->str);
         break;
       default:
          scan_err1(lc, _("Expected an fstype string, got: %s\n"), lc->str);
-      }                                
+      }
    }
    scan_to_eol(lc);
 }
@@ -603,7 +606,7 @@ static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass)
    int token;
    INCEXE *incexe;
 
-   token = lex_get_token(lc, T_SKIP_EOL);           
+   token = lex_get_token(lc, T_SKIP_EOL);
    if (pass == 1) {
       /* Pickup Filename string
        */
@@ -623,7 +626,7 @@ static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass)
            break;
         default:
             scan_err1(lc, _("Expected a filename, got: %s"), lc->str);
-      }                                
+      }
    }
    scan_to_eol(lc);
 }
@@ -636,7 +639,7 @@ static void options_res(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token, i;
 
-   token = lex_get_token(lc, T_SKIP_EOL);           
+   token = lex_get_token(lc, T_SKIP_EOL);
    if (token != T_BOB) {
       scan_err1(lc, "Expecting open brace. Got %s", lc->str);
    }
@@ -644,7 +647,7 @@ static void options_res(LEX *lc, RES_ITEM *item, int index, int pass)
    if (pass == 1) {
       setup_current_opts();
    }
-        
+
    while ((token = lex_get_token(lc, T_ALL)) != T_EOF) {
       if (token == T_EOL) {
         continue;
index c6811ac05eac6595e2efda67e7420a8b8b3a800d..44d14fec75b8b9159ffda519f27eb5a28ebaebf4 100644 (file)
@@ -56,7 +56,7 @@ void init_job_server(int max_workers)
 {
    int stat;
    watchdog_t *wd;
-   
+
    if ((stat = jobq_init(&job_queue, max_workers, job_thread)) != 0) {
       berrno be;
       Emsg1(M_ABORT, 0, _("Could not init job queue: ERR=%s\n"), be.strerror(stat));
@@ -121,7 +121,7 @@ JobId_t run_job(JCR *jcr)
    Dmsg0(50, "DB opened\n");
 
    /*
-    * Create Job record  
+    * Create Job record
     */
    create_unique_job_name(jcr, jcr->job->hdr.name);
    set_jcr_job_status(jcr, JS_Created);
@@ -132,7 +132,7 @@ JobId_t run_job(JCR *jcr)
    }
    JobId = jcr->JobId = jcr->jr.JobId;
 
-   Dmsg4(100, "Created job record JobId=%d Name=%s Type=%c Level=%c\n", 
+   Dmsg4(100, "Created job record JobId=%d Name=%s Type=%c Level=%c\n",
        jcr->JobId, jcr->Job, jcr->jr.JobType, jcr->jr.JobLevel);
    Dmsg0(200, "Add jrc to work queue\n");
 
@@ -156,8 +156,8 @@ bail_out:
 }
 
 
-/* 
- * This is the engine called by jobq.c:jobq_add() when we were pulled               
+/*
+ * This is the engine called by jobq.c:jobq_add() when we were pulled
  *  from the work queue.
  *  At this point, we are running in our own thread and all
  *    necessary resources are allocated -- see jobq.c
@@ -195,7 +195,7 @@ static void *job_thread(void *arg)
            int status;
            BPIPE *bpipe;
            char line[MAXSTRING];
-           
+
             before = edit_job_codes(jcr, before, jcr->job->RunBeforeJob, "");
             bpipe = open_bpipe(before, 0, "r");
            free_pool_memory(before);
@@ -254,7 +254,7 @@ static void *job_thread(void *arg)
            int status;
            BPIPE *bpipe;
            char line[MAXSTRING];
-           
+
            if (jcr->JobStatus == JS_Terminated) {
                after = edit_job_codes(jcr, after, jcr->job->RunAfterJob, "");
            } else {
@@ -268,7 +268,7 @@ static void *job_thread(void *arg)
            status = close_bpipe(bpipe);
            /*
             * Note, if we get an error here, do not mark the
-            *  job in error, simply report the error condition.   
+            *  job in error, simply report the error condition.
             */
            if (status != 0) {
               berrno be;
@@ -298,7 +298,7 @@ bail_out:
 /*
  * Cancel a job -- typically called by the UA (Console program), but may also
  *             be called by the job watchdog.
- * 
+ *
  *  Returns: 1 if cancel appears to be successful
  *          0 on failure. Message sent to ua->jcr.
  */
@@ -319,7 +319,7 @@ int cancel_job(UAContext *ua, JCR *jcr)
              jcr->JobId, jcr->Job);
       jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */
       return 1;
-        
+
    default:
       set_jcr_job_status(jcr, JS_Canceled);
 
@@ -550,7 +550,7 @@ bool get_or_create_client_record(JCR *jcr)
    }
    pm_strcpy(jcr->client_name, jcr->client->hdr.name);
    if (!db_create_client_record(jcr, jcr->db, &cr)) {
-      Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"), 
+      Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"),
         db_strerror(jcr->db));
       return false;
    }
@@ -561,7 +561,7 @@ bool get_or_create_client_record(JCR *jcr)
       }
       pm_strcpy(jcr->client_uname, cr.Uname);
    }
-   Dmsg2(100, "Created Client %s record %d\n", jcr->client->hdr.name, 
+   Dmsg2(100, "Created Client %s record %d\n", jcr->client->hdr.name,
       jcr->jr.ClientId);
    return true;
 }
@@ -586,17 +586,17 @@ bool get_or_create_fileset_record(JCR *jcr, FILESET_DBR *fsr)
    if (!jcr->fileset->ignore_fs_changes ||
        !db_get_fileset_record(jcr, jcr->db, fsr)) {
       if (!db_create_fileset_record(jcr, jcr->db, fsr)) {
-         Jmsg(jcr, M_ERROR, 0, _("Could not create FileSet \"%s\" record. ERR=%s\n"), 
+         Jmsg(jcr, M_ERROR, 0, _("Could not create FileSet \"%s\" record. ERR=%s\n"),
            fsr->FileSet, db_strerror(jcr->db));
         return false;
-      }   
+      }
    }
    jcr->jr.FileSetId = fsr->FileSetId;
    if (fsr->created) {
-      Jmsg(jcr, M_INFO, 0, _("Created new FileSet record \"%s\" %s\n"), 
+      Jmsg(jcr, M_INFO, 0, _("Created new FileSet record \"%s\" %s\n"),
         fsr->FileSet, fsr->cCreateTime);
    }
-   Dmsg2(119, "Created FileSet %s record %u\n", jcr->fileset->hdr.name, 
+   Dmsg2(119, "Created FileSet %s record %u\n", jcr->fileset->hdr.name,
       jcr->jr.FileSetId);
    return true;
 }
@@ -628,7 +628,7 @@ void update_job_end_record(JCR *jcr)
    jcr->jr.VolSessionId = jcr->VolSessionId;
    jcr->jr.VolSessionTime = jcr->VolSessionTime;
    if (!db_update_job_end_record(jcr, jcr->db, &jcr->jr)) {
-      Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s"), 
+      Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s"),
         db_strerror(jcr->db));
    }
 }
@@ -652,7 +652,7 @@ void create_unique_job_name(JCR *jcr, const char *base_name)
    char *p;
 
    /* Guarantee unique start time -- maximum one per second, and
-    * thus unique Job Name 
+    * thus unique Job Name
     */
    P(mutex);                         /* lock creation of jobs */
    now = time(NULL);
@@ -666,7 +666,7 @@ void create_unique_job_name(JCR *jcr, const char *base_name)
    /* Form Unique JobName */
    localtime_r(&now, &tm);
    /* Use only characters that are permitted in Windows filenames */
-   strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm); 
+   strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm);
    bstrncpy(name, base_name, sizeof(name));
    name[sizeof(name)-22] = 0;         /* truncate if too long */
    bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s", name, dt); /* add date & time */
@@ -705,7 +705,7 @@ void dird_free_jcr(JCR *jcr)
       bnet_close(jcr->store_bsock);
       jcr->store_bsock = NULL;
    }
-   if (jcr->fname) {  
+   if (jcr->fname) {
       Dmsg0(200, "Free JCR fname\n");
       free_pool_memory(jcr->fname);
       jcr->fname = NULL;
@@ -758,9 +758,12 @@ void set_jcr_defaults(JCR *jcr, JOB *job)
    }
    jcr->JobPriority = job->Priority;
    /* Copy storage definitions -- deleted in dir_free_jcr above */
-   for (int i=0; i<MAX_STORE; i++) {
+   for (int i=0; i < MAX_STORE; i++) {
       STORE *st;
       if (job->storage[i]) {
+        if (jcr->storage[i]) {
+           delete jcr->storage[i];
+        }
         jcr->storage[i] = New(alist(10, not_owned_by_alist));
         foreach_alist(st, job->storage[i]) {
            jcr->storage[i]->append(st);
@@ -781,7 +784,7 @@ void set_jcr_defaults(JCR *jcr, JOB *job)
    jcr->dif_pool = job->dif_pool;
    jcr->catalog = job->client->catalog;
    jcr->fileset = job->fileset;
-   jcr->messages = job->messages; 
+   jcr->messages = job->messages;
    jcr->spool_data = job->spool_data;
    if (jcr->RestoreBootstrap) {
       free(jcr->RestoreBootstrap);
@@ -812,10 +815,10 @@ void set_jcr_defaults(JCR *jcr, JOB *job)
    }
 }
 
-/* 
+/*
  * copy the storage definitions from an old JCR to a new one
  */
-void copy_storage(JCR *new_jcr, JCR *old_jcr)  
+void copy_storage(JCR *new_jcr, JCR *old_jcr)
 {
    for (int i=0; i < MAX_STORE; i++) {
       if (old_jcr->storage[i]) {
index 1cde7a505cc8bff45d67d0c4ea7b05dac54cb399..4ca44bc37acb3553a89e648df9892426fb8c9e15 100755 (executable)
@@ -50,7 +50,7 @@ static int   start_server(jobq_t *jq);
 
 
 
-/*   
+/*
  * Initialize a job queue
  *
  *  Returns: 0 on success
@@ -60,7 +60,7 @@ int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg))
 {
    int stat;
    jobq_item_t *item = NULL;
-                       
+
    if ((stat = pthread_attr_init(&jq->attr)) != 0) {
       berrno be;
       Jmsg1(NULL, M_ERROR, 0, "pthread_attr_init: ERR=%s\n", be.strerror(stat));
@@ -88,7 +88,7 @@ int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg))
    jq->num_workers = 0;              /* no threads yet */
    jq->idle_workers = 0;             /* no idle threads */
    jq->engine = engine;              /* routine to run */
-   jq->valid = JOBQ_VALID; 
+   jq->valid = JOBQ_VALID;
    /* Initialize the job queues */
    jq->waiting_jobs = New(dlist(item, &item->link));
    jq->running_jobs = New(dlist(item, &item->link));
@@ -164,7 +164,7 @@ struct wait_pkt {
  *  most jobs are put into the job queue only when their
  *  scheduled time arives.
  */
-extern "C"  
+extern "C"
 void *sched_wait(void *arg)
 {
    JCR *jcr = ((wait_pkt *)arg)->jcr;
@@ -176,10 +176,10 @@ void *sched_wait(void *arg)
    set_jcr_job_status(jcr, JS_WaitStartTime);
    /* Wait until scheduled time arrives */
    if (wtime > 0) {
-      Jmsg(jcr, M_INFO, 0, _("Job %s waiting %d seconds for scheduled start time.\n"), 
+      Jmsg(jcr, M_INFO, 0, _("Job %s waiting %d seconds for scheduled start time.\n"),
         jcr->Job, wtime);
    }
-   /* Check every 30 seconds if canceled */ 
+   /* Check every 30 seconds if canceled */
    while (wtime > 0) {
       Dmsg2(300, "Waiting on sched time, jobid=%d secs=%d\n", jcr->JobId, wtime);
       if (wtime > 30) {
@@ -202,9 +202,9 @@ void *sched_wait(void *arg)
 /*
  *  Add a job to the queue
  *    jq is a queue that was created with jobq_init
- * 
+ *
  *  On entry jcr->mutex must be locked.
- *   
+ *
  */
 int jobq_add(jobq_t *jq, JCR *jcr)
 {
@@ -214,7 +214,7 @@ int jobq_add(jobq_t *jq, JCR *jcr)
    time_t wtime = jcr->sched_time - time(NULL);
    pthread_t id;
    wait_pkt *sched_pkt;
-    
+
    Dmsg3(300, "jobq_add jobid=%d jcr=0x%x use_count=%d\n", jcr->JobId, jcr, jcr->use_count);
    if (jq->valid != JOBQ_VALID) {
       Jmsg0(jcr, M_ERROR, 0, "Jobq_add queue not initialized.\n");
@@ -257,11 +257,11 @@ int jobq_add(jobq_t *jq, JCR *jcr)
    } else {
       /* Add this job to the wait queue in priority sorted order */
       foreach_dlist(li, jq->waiting_jobs) {
-         Dmsg2(300, "waiting item jobid=%d priority=%d\n",
+        Dmsg2(300, "waiting item jobid=%d priority=%d\n",
            li->jcr->JobId, li->jcr->JobPriority);
         if (li->jcr->JobPriority > jcr->JobPriority) {
            jq->waiting_jobs->insert_before(item, li);
-            Dmsg2(300, "insert_before jobid=%d before waiting job=%d\n", 
+           Dmsg2(300, "insert_before jobid=%d before waiting job=%d\n",
               li->jcr->JobId, jcr->JobId);
            inserted = true;
            break;
@@ -270,7 +270,7 @@ int jobq_add(jobq_t *jq, JCR *jcr)
       /* If not jobs in wait queue, append it */
       if (!inserted) {
         jq->waiting_jobs->append(item);
-         Dmsg1(300, "Appended item jobid=%d to waiting queue\n", jcr->JobId);
+        Dmsg1(300, "Appended item jobid=%d to waiting queue\n", jcr->JobId);
       }
    }
 
@@ -296,7 +296,7 @@ int jobq_remove(jobq_t *jq, JCR *jcr)
    int stat;
    bool found = false;
    jobq_item_t *item;
-    
+
    Dmsg2(300, "jobq_remove jobid=%d jcr=0x%x\n", jcr->JobId, jcr);
    if (jq->valid != JOBQ_VALID) {
       return EINVAL;
@@ -324,7 +324,7 @@ int jobq_remove(jobq_t *jq, JCR *jcr)
    jq->waiting_jobs->remove(item);
    jq->ready_jobs->prepend(item);
    Dmsg2(300, "jobq_remove jobid=%d jcr=0x%x moved to ready queue\n", jcr->JobId, jcr);
-   
+
    stat = start_server(jq);
 
    pthread_mutex_unlock(&jq->mutex);
@@ -363,12 +363,12 @@ static int start_server(jobq_t *jq)
 }
 
 
-/* 
+/*
  * This is the worker thread that serves the job queue.
- * When all the resources are acquired for the job, 
+ * When all the resources are acquired for the job,
  *  it will call the user's engine.
  */
-extern "C"  
+extern "C"
 void *jobq_server(void *arg)
 {
    struct timespec timeout;
@@ -400,33 +400,33 @@ void *jobq_server(void *arg)
            /*
             * Wait 4 seconds, then if no more work, exit
             */
-            Dmsg0(300, "pthread_cond_timedwait()\n");
+           Dmsg0(300, "pthread_cond_timedwait()\n");
            stat = pthread_cond_timedwait(&jq->work, &jq->mutex, &timeout);
            if (stat == ETIMEDOUT) {
-               Dmsg0(300, "timedwait timedout.\n");
+              Dmsg0(300, "timedwait timedout.\n");
               timedout = true;
               break;
            } else if (stat != 0) {
-               /* This shouldn't happen */
-               Dmsg0(300, "This shouldn't happen\n");
+              /* This shouldn't happen */
+              Dmsg0(300, "This shouldn't happen\n");
               jq->num_workers--;
               pthread_mutex_unlock(&jq->mutex);
               return NULL;
            }
            break;
-        } 
+        }
       }
-      /* 
+      /*
        * If anything is in the ready queue, run it
        */
       Dmsg0(300, "Checking ready queue.\n");
       while (!jq->ready_jobs->empty() && !jq->quit) {
         JCR *jcr;
-        je = (jobq_item_t *)jq->ready_jobs->first(); 
+        je = (jobq_item_t *)jq->ready_jobs->first();
         jcr = je->jcr;
         jq->ready_jobs->remove(je);
         if (!jq->ready_jobs->empty()) {
-            Dmsg0(300, "ready queue not empty start server\n");
+           Dmsg0(300, "ready queue not empty start server\n");
            if (start_server(jq) != 0) {
               jq->num_workers--;
               pthread_mutex_unlock(&jq->mutex);
@@ -460,7 +460,7 @@ void *jobq_server(void *arg)
         }
          Dmsg0(200, "Done lock mutex after running job. Release locks.\n");
         jq->running_jobs->remove(je);
-        /* 
+        /*
          * Release locks if acquired. Note, they will not have
          *  been acquired for jobs canceled before they were
          *  put into the ready queue.
@@ -468,7 +468,7 @@ void *jobq_server(void *arg)
         if (jcr->acquired_resource_locks) {
            jcr->store->NumConcurrentJobs--;
            if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) {
-              jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs;  
+              jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs;
            }
            jcr->client->NumConcurrentJobs--;
            jcr->job->NumConcurrentJobs--;
@@ -477,10 +477,10 @@ void *jobq_server(void *arg)
         /*
          * Reschedule the job if necessary and requested
          */
-        if (jcr->job->RescheduleOnError && 
+        if (jcr->job->RescheduleOnError &&
             jcr->JobStatus != JS_Terminated &&
-            jcr->JobStatus != JS_Canceled && 
-            jcr->job->RescheduleTimes > 0 && 
+            jcr->JobStatus != JS_Canceled &&
+            jcr->job->RescheduleTimes > 0 &&
             jcr->reschedule_count < jcr->job->RescheduleTimes) {
             char dt[50];
 
@@ -490,16 +490,16 @@ void *jobq_server(void *arg)
              */
            jcr->reschedule_count++;
            jcr->sched_time = time(NULL) + jcr->job->RescheduleInterval;
-            Dmsg2(300, "Rescheduled Job %s to re-run in %d seconds.\n", jcr->Job,
+           Dmsg2(300, "Rescheduled Job %s to re-run in %d seconds.\n", jcr->Job,
               (int)jcr->job->RescheduleInterval);
            bstrftime(dt, sizeof(dt), time(NULL));
-            Jmsg(jcr, M_INFO, 0, _("Rescheduled Job %s at %s to re-run in %d seconds.\n"),
+           Jmsg(jcr, M_INFO, 0, _("Rescheduled Job %s at %s to re-run in %d seconds.\n"),
               jcr->Job, dt, (int)jcr->job->RescheduleInterval);
            dird_free_jcr(jcr);          /* partial cleanup old stuff */
            jcr->JobStatus = JS_WaitStartTime;
            jcr->SDJobStatus = 0;
            if (jcr->JobBytes == 0) {
-               Dmsg1(300, "Requeue job=%d\n", jcr->JobId);
+              Dmsg1(300, "Requeue job=%d\n", jcr->JobId);
               jcr->JobStatus = JS_WaitStartTime;
               V(jq->mutex);
               jobq_add(jq, jcr);     /* queue the job to run again */
@@ -507,7 +507,7 @@ void *jobq_server(void *arg)
               free(je);              /* free the job entry */
               continue;              /* look for another job to run */
            }
-           /* 
+           /*
             * Something was actually backed up, so we cannot reuse
             *   the old JobId or there will be database record
             *   conflicts.  We now create a new job, copying the
@@ -520,19 +520,19 @@ void *jobq_server(void *arg)
            njcr->JobStatus = jcr->JobStatus;
            copy_storage(njcr, jcr);
            njcr->messages = jcr->messages;
-            Dmsg0(300, "Call to run new job\n");
+           Dmsg0(300, "Call to run new job\n");
            V(jq->mutex);
-            run_job(njcr);            /* This creates a "new" job */
-            free_jcr(njcr);           /* release "new" jcr */
+           run_job(njcr);            /* This creates a "new" job */
+           free_jcr(njcr);           /* release "new" jcr */
            P(jq->mutex);
-            Dmsg0(300, "Back from running new job.\n");
+           Dmsg0(300, "Back from running new job.\n");
         }
         /* Clean up and release old jcr */
         if (jcr->db) {
            db_close_database(jcr, jcr->db);
            jcr->db = NULL;
         }
-         Dmsg2(300, "====== Termination job=%d use_cnt=%d\n", jcr->JobId, jcr->use_count);
+        Dmsg2(300, "====== Termination job=%d use_cnt=%d\n", jcr->JobId, jcr->use_count);
         jcr->SDJobStatus = 0;
         V(jq->mutex);                /* release internal lock */
         free_jcr(jcr);
@@ -546,14 +546,14 @@ void *jobq_server(void *arg)
       Dmsg0(300, "Done check ready, now check wait queue.\n");
       while (!jq->waiting_jobs->empty() && !jq->quit) {
         int Priority;
-        je = (jobq_item_t *)jq->waiting_jobs->first(); 
+        je = (jobq_item_t *)jq->waiting_jobs->first();
         jobq_item_t *re = (jobq_item_t *)jq->running_jobs->first();
         if (re) {
            Priority = re->jcr->JobPriority;
-            Dmsg2(300, "JobId %d is running. Look for pri=%d\n", re->jcr->JobId, Priority);
+           Dmsg2(300, "JobId %d is running. Look for pri=%d\n", re->jcr->JobId, Priority);
         } else {
            Priority = je->jcr->JobPriority;
-            Dmsg1(300, "No job running. Look for Job pri=%d\n", Priority);
+           Dmsg1(300, "No job running. Look for Job pri=%d\n", Priority);
         }
         /*
          * Walk down the list of waiting jobs and attempt
@@ -564,7 +564,7 @@ void *jobq_server(void *arg)
            JCR *jcr = je->jcr;
            bool skip_this_jcr = false;
            jobq_item_t *jn = (jobq_item_t *)jq->waiting_jobs->next(je);
-            Dmsg3(300, "Examining Job=%d JobPri=%d want Pri=%d\n",
+           Dmsg3(300, "Examining Job=%d JobPri=%d want Pri=%d\n",
               jcr->JobId, jcr->JobPriority, Priority);
            /* Take only jobs of correct Priority */
            if (jcr->JobPriority != Priority) {
@@ -586,10 +586,10 @@ void *jobq_server(void *arg)
            } else if (jcr->store->NumConcurrentJobs == 0 &&
                       jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) {
                /* Simple case, first job */
-               jcr->store->NumConcurrentJobs = 1;  
+               jcr->store->NumConcurrentJobs = 1;
            } else if (jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) {
               /*
-               * At this point, we already have at least one Job running 
+               * At this point, we already have at least one Job running
                *  for this Storage daemon, so we must ensure that there
                *  is no Volume conflict. In general, it should be OK, if
                *  all Jobs pull from the same Pool, so we check the Pools.
@@ -604,12 +604,12 @@ void *jobq_server(void *arg)
                      skip_this_jcr = true;
                      break;
                   }
-               }  
+               }
                unlock_jcr_chain();
                if (!skip_this_jcr) {
-                  jcr->store->NumConcurrentJobs++;    
+                  jcr->store->NumConcurrentJobs++;
                }
-           } 
+           }
            if (skip_this_jcr) {
               set_jcr_job_status(jcr, JS_WaitStoreRes);
               je = jn;               /* point to next waiting job */
@@ -622,7 +622,7 @@ void *jobq_server(void *arg)
               /* Back out previous locks */
               jcr->store->NumConcurrentJobs--;
               if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) {
-                 jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs;  
+                 jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs;
               }
               set_jcr_job_status(jcr, JS_WaitClientRes);
               je = jn;               /* point to next waiting job */
@@ -634,7 +634,7 @@ void *jobq_server(void *arg)
               /* Back out previous locks */
               jcr->store->NumConcurrentJobs--;
               if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) {
-                 jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs;  
+                 jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs;
               }
               jcr->client->NumConcurrentJobs--;
               set_jcr_job_status(jcr, JS_WaitJobRes);
@@ -642,12 +642,12 @@ void *jobq_server(void *arg)
               continue;
            }
            /* Got all locks, now remove it from wait queue and append it
-            *   to the ready queue  
+            *   to the ready queue
             */
            jcr->acquired_resource_locks = true;
            jq->waiting_jobs->remove(je);
            jq->ready_jobs->append(je);
-            Dmsg1(300, "moved JobId=%d from wait to ready queue\n", je->jcr->JobId);
+           Dmsg1(300, "moved JobId=%d from wait to ready queue\n", je->jcr->JobId);
            je = jn;                  /* Point to next waiting job */
         } /* end for loop */
         break;
@@ -659,27 +659,27 @@ void *jobq_server(void *arg)
       if (jq->ready_jobs->empty() && jq->quit) {
         jq->num_workers--;
         if (jq->num_workers == 0) {
-            Dmsg0(300, "Wake up destroy routine\n");
+           Dmsg0(300, "Wake up destroy routine\n");
            /* Wake up destroy routine if he is waiting */
            pthread_cond_broadcast(&jq->work);
         }
         break;
       }
       Dmsg0(300, "Check for work request\n");
-      /* 
+      /*
        * If no more work requests, and we waited long enough, quit
        */
       Dmsg2(300, "timedout=%d read empty=%d\n", timedout,
         jq->ready_jobs->empty());
       if (jq->ready_jobs->empty() && timedout) {
-         Dmsg0(300, "break big loop\n");
+        Dmsg0(300, "break big loop\n");
         jq->num_workers--;
         break;
       }
 
       work = !jq->ready_jobs->empty() || !jq->waiting_jobs->empty();
       if (work) {
-        /*          
+        /*
           * If a job is waiting on a Resource, don't consume all
          *   the CPU time looping looking for work, and even more
          *   important, release the lock so that a job that has
index 355e61a3cf0e621c89b051665fb0fb3abcfbb653..1a919df00a32f8529947a5cae256142176344c07 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Bacula job queue routines. 
+ * Bacula job queue routines.
  *
  *  Kern Sibbald, July MMIII
  *
 
  */
 
-#ifndef __JOBQ_H 
+#ifndef __JOBQ_H
 #define __JOBQ_H 1
 
-/* 
+/*
  * Structure to keep track of job queue request
  */
 struct jobq_item_t {
@@ -40,7 +40,7 @@ struct jobq_item_t {
    JCR *jcr;
 };
 
-/* 
+/*
  * Structure describing a work queue
  */
 struct jobq_t {
index 02d86f80cc2d9598ab92629eabdef8de485effbd..c9853bdd68717b4bf28a0eb59404a80887733fa6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- *   Bacula Director -- mac.c -- responsible for doing 
+ *   Bacula Director -- mac.c -- responsible for doing
  *     migration, archive, and copy jobs.
  *
  *     Kern Sibbald, September MMIV
@@ -45,13 +45,13 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
 
 /* External functions */
 
-/* 
+/*
  * Do a Migration, Archive, or Copy of a previous job
- *    
+ *
  *  Returns:  false on failure
  *           true  on success
  */
-bool do_mac(JCR *jcr) 
+bool do_mac(JCR *jcr)
 {
    char since[MAXSTRING];
    int stat;
@@ -93,7 +93,7 @@ bool do_mac(JCR *jcr)
    Dmsg1(100, "find last jobid for: %s\n", NPRT(Name));
    if (!db_find_last_jobid(jcr, jcr->db, Name, &jr)) {
       Jmsg(jcr, M_FATAL, 0, _(
-           "Unable to find JobId of previous Job for this client.\n"));
+          "Unable to find JobId of previous Job for this client.\n"));
       goto bail_out;
    }
    input_jobid = jr.JobId;
@@ -102,23 +102,23 @@ bool do_mac(JCR *jcr)
 
    jcr->fname = get_pool_memory(PM_FNAME);
 
-   /* 
-    * Get the Pool record -- first apply any level defined pools  
+   /*
+    * Get the Pool record -- first apply any level defined pools
     */
    switch (jcr->JobLevel) {
    case L_FULL:
       if (jcr->full_pool) {
-        jcr->pool = jcr->full_pool;   
+        jcr->pool = jcr->full_pool;
       }
       break;
    case L_INCREMENTAL:
       if (jcr->inc_pool) {
-        jcr->pool = jcr->inc_pool;   
+        jcr->pool = jcr->inc_pool;
       }
       break;
    case L_DIFFERENTIAL:
       if (jcr->dif_pool) {
-        jcr->pool = jcr->dif_pool;   
+        jcr->pool = jcr->dif_pool;
       }
       break;
    }
@@ -128,11 +128,11 @@ bool do_mac(JCR *jcr)
    while (!db_get_pool_record(jcr, jcr->db, &pr)) { /* get by Name */
       /* Try to create the pool */
       if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, 
+        Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name,
            db_strerror(jcr->db));
         goto bail_out;
       } else {
-         Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name);
+        Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name);
       }
    }
    jcr->PoolId = pr.PoolId;              /****FIXME**** this can go away */
@@ -160,7 +160,7 @@ bool do_mac(JCR *jcr)
    Dmsg0(110, "Open connection with storage daemon\n");
    set_jcr_job_status(jcr, JS_WaitSD);
    /*
-    * Start conversation with Storage daemon  
+    * Start conversation with Storage daemon
     */
    if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) {
       goto bail_out;
@@ -179,7 +179,7 @@ bool do_mac(JCR *jcr)
    }
    Dmsg0(150, "Storage daemon connection OK\n");
 
-   /* Pickup Job termination data */       
+   /* Pickup Job termination data */
    set_jcr_job_status(jcr, JS_Running);
 
    /* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/Errors */
@@ -220,22 +220,22 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
    set_jcr_job_status(jcr, TermCode);
 
    update_job_end_record(jcr);       /* update database */
-   
+
    if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
-      Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), 
+      Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"),
         db_strerror(jcr->db));
       set_jcr_job_status(jcr, JS_ErrorTerminated);
    }
 
    bstrncpy(mr.VolumeName, jcr->VolumeName, sizeof(mr.VolumeName));
    if (!db_get_media_record(jcr, jcr->db, &mr)) {
-      Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"), 
+      Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"),
         mr.VolumeName, db_strerror(jcr->db));
       set_jcr_job_status(jcr, JS_ErrorTerminated);
    }
 
    /* Now update the bootstrap file if any */
-   if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes && 
+   if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes &&
        jcr->job->WriteBootstrap) {
       FILE *fd;
       BPIPE *bpipe = NULL;
@@ -247,18 +247,18 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
       if (*fname == '|') {
         fname++;
         got_pipe = 1;
-         bpipe = open_bpipe(fname, 0, "w");
+        bpipe = open_bpipe(fname, 0, "w");
         fd = bpipe ? bpipe->wfd : NULL;
       } else {
         /* ***FIXME*** handle BASE */
-         fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+");
+        fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+");
       }
       if (fd) {
         VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId,
                    &VolParams);
         if (VolCount == 0) {
-            Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to "      
-                 "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db));
+           Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to "
+                "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db));
             if (jcr->SDJobFiles != 0) {
                set_jcr_job_status(jcr, JS_ErrorTerminated);
             }
@@ -266,14 +266,14 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
         }
         for (int i=0; i < VolCount; i++) {
            /* Write the record */
-            fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName);
-            fprintf(fd, "VolSessionId=%u\n", jcr->VolSessionId);
-            fprintf(fd, "VolSessionTime=%u\n", jcr->VolSessionTime);
-            fprintf(fd, "VolFile=%u-%u\n", VolParams[i].StartFile,
+           fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName);
+           fprintf(fd, "VolSessionId=%u\n", jcr->VolSessionId);
+           fprintf(fd, "VolSessionTime=%u\n", jcr->VolSessionTime);
+           fprintf(fd, "VolFile=%u-%u\n", VolParams[i].StartFile,
                         VolParams[i].EndFile);
-            fprintf(fd, "VolBlock=%u-%u\n", VolParams[i].StartBlock,
+           fprintf(fd, "VolBlock=%u-%u\n", VolParams[i].StartBlock,
                         VolParams[i].EndBlock);
-            fprintf(fd, "FileIndex=%d-%d\n", VolParams[i].FirstIndex,
+           fprintf(fd, "FileIndex=%d-%d\n", VolParams[i].FirstIndex,
                         VolParams[i].LastIndex);
         }
         if (VolParams) {
@@ -286,8 +286,8 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
         }
       } else {
         berrno be;
-         Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n"
-              "%s: ERR=%s\n"), fname, be.strerror());
+        Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n"
+             "%s: ERR=%s\n"), fname, be.strerror());
         set_jcr_job_status(jcr, JS_ErrorTerminated);
       }
    }
@@ -296,14 +296,14 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
    switch (jcr->JobStatus) {
       case JS_Terminated:
         if (jcr->Errors || jcr->SDErrors) {
-            term_msg = _("Backup OK -- with warnings");
+           term_msg = _("Backup OK -- with warnings");
         } else {
-            term_msg = _("Backup OK");
+           term_msg = _("Backup OK");
         }
         break;
       case JS_FatalError:
       case JS_ErrorTerminated:
-         term_msg = _("*** Backup Error ***"); 
+        term_msg = _("*** Backup Error ***");
         msg_type = M_ERROR;          /* Generate error message */
         if (jcr->store_bsock) {
            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
@@ -313,7 +313,7 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
         }
         break;
       case JS_Canceled:
-         term_msg = _("Backup Canceled");
+        term_msg = _("Backup Canceled");
         if (jcr->store_bsock) {
            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
            if (jcr->SD_msg_chan) {
@@ -323,7 +323,7 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
         break;
       default:
         term_msg = term_code;
-         sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
+        sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
         break;
    }
    bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime);
@@ -341,8 +341,8 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
        *  it is normal.  Or look at it the other way, only for a
        *  normal exit should we complain about this error.
        */
-      if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes) {                               
-         Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
+      if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes) {
+        Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
       }
       jcr->VolumeName[0] = 0;        /* none */
    }
@@ -352,9 +352,9 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
    } else {
       compression = (double)100 - 100.0 * ((double)jcr->JobBytes / (double)jcr->ReadBytes);
       if (compression < 0.5) {
-         bstrncpy(compress, "None", sizeof(compress));
+        bstrncpy(compress, "None", sizeof(compress));
       } else {
-         bsnprintf(compress, sizeof(compress), "%.1f %%", (float)compression);
+        bsnprintf(compress, sizeof(compress), "%.1f %%", (float)compression);
       }
    }
    jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
@@ -362,30 +362,30 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr,
 
 // bmicrosleep(15, 0);               /* for debugging SIGHUP */
 
-   Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\
-  JobId:                  %d\n\
-  Job:                    %s\n\
-  Backup Level:           %s%s\n\
-  Client:                 %s\n\
-  FileSet:                \"%s\" %s\n\
-  Pool:                   \"%s\"\n\
-  Start time:             %s\n\
-  End time:               %s\n\
-  FD Files Written:       %s\n\
-  SD Files Written:       %s\n\
-  FD Bytes Written:       %s\n\
-  SD Bytes Written:       %s\n\
-  Rate:                   %.1f KB/s\n\
-  Software Compression:   %s\n\
-  Volume name(s):         %s\n\
-  Volume Session Id:      %d\n\
-  Volume Session Time:    %d\n\
-  Last Volume Bytes:      %s\n\
-  Non-fatal FD errors:    %d\n\
-  SD Errors:              %d\n\
-  FD termination status:  %s\n\
-  SD termination status:  %s\n\
-  Termination:            %s\n\n"),
+   Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
+"  JobId:                  %d\n"
+"  Job:                    %s\n"
+"  Backup Level:           %s%s\n"
+"  Client:                 %s\n"
+"  FileSet:                \"%s\" %s\n"
+"  Pool:                   \"%s\"\n"
+"  Start time:             %s\n"
+"  End time:               %s\n"
+"  FD Files Written:       %s\n"
+"  SD Files Written:       %s\n"
+"  FD Bytes Written:       %s\n"
+"  SD Bytes Written:       %s\n"
+"  Rate:                   %.1f KB/s\n"
+"  Software Compression:   %s\n"
+"  Volume name(s):         %s\n"
+"  Volume Session Id:      %d\n"
+"  Volume Session Time:    %d\n"
+"  Last Volume Bytes:      %s\n"
+"  Non-fatal FD errors:    %d\n"
+"  SD Errors:              %d\n"
+"  FD termination status:  %s\n"
+"  SD termination status:  %s\n"
+"  Termination:            %s\n\n"),
        edt,
        jcr->jr.JobId,
        jcr->jr.Job,
index 0df166b27d395b97acd3f2ee367f233537d1292c..f5c8ee2ff03fd7037782ae959999da86211df441 100644 (file)
@@ -39,8 +39,8 @@
 #include "dird.h"
 
 /* Commands sent to Storage daemon */
-static char jobcmd[]     = "JobId=%d job=%s job_name=%s client_name=%s \
-type=%d level=%d FileSet=%s NoAttr=%d SpoolAttr=%d FileSetMD5=%s SpoolData=%d";
+static char jobcmd[]     = "JobId=%d job=%s job_name=%s client_name=%s "
+"type=%d level=%d FileSet=%s NoAttr=%d SpoolAttr=%d FileSetMD5=%s SpoolData=%d";
 static char use_device[] = "use device=%s media_type=%s pool_name=%s pool_type=%s\n";
 
 /* Response from Storage daemon */
@@ -49,7 +49,7 @@ static char OK_device[]  = "3000 OK use device\n";
 
 /* Storage Daemon requests */
 static char Job_start[]  = "3010 Job %127s start\n";
-static char Job_end[]   = 
+static char Job_end[]   =
    "3099 Job %127s end JobStatus=%d JobFiles=%d JobBytes=%" lld "\n";
 static char Job_status[] = "3012 Job %127s jobstatus %d\n";
 
@@ -58,9 +58,9 @@ extern "C" void *msg_thread(void *arg);
 
 /*
  * Establish a message channel connection with the Storage daemon
- * and perform authentication. 
+ * and perform authentication.
  */
-bool connect_to_storage_daemon(JCR *jcr, int retry_interval,   
+bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
                              int max_retry_time, int verbose)
 {
    BSOCK *sd;
@@ -69,12 +69,12 @@ bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
    store = (STORE *)jcr->storage[0]->first();
 
    /*
-    *  Open message channel with the Storage daemon   
+    *  Open message channel with the Storage daemon
     */
    Dmsg2(200, "bnet_connect to Storage daemon %s:%d\n", store->address,
       store->SDport);
    sd = bnet_connect(jcr, retry_interval, max_retry_time,
-          _("Storage daemon"), store->address, 
+         _("Storage daemon"), store->address,
          NULL, store->SDport, verbose);
    if (sd == NULL) {
       return false;
@@ -110,8 +110,8 @@ int start_storage_daemon_job(JCR *jcr)
    if (jcr->fileset->MD5[0] == 0) {
       strcpy(jcr->fileset->MD5, "**Dummy**");
    }
-   bnet_fsend(sd, jobcmd, jcr->JobId, jcr->Job, jcr->job->hdr.name, 
-             jcr->client->hdr.name, jcr->JobType, jcr->JobLevel, 
+   bnet_fsend(sd, jobcmd, jcr->JobId, jcr->Job, jcr->job->hdr.name,
+             jcr->client->hdr.name, jcr->JobType, jcr->JobLevel,
              jcr->fileset->hdr.name, !jcr->pool->catalog_files,
              jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data);
    Dmsg1(200, "Jobcmd=%s\n", sd->msg);
@@ -120,14 +120,14 @@ int start_storage_daemon_job(JCR *jcr)
    unbash_spaces(jcr->fileset->hdr.name);
    if (bget_dirmsg(sd) > 0) {
        Dmsg1(110, "<stored: %s", sd->msg);
-       if (sscanf(sd->msg, OKjob, &jcr->VolSessionId, 
+       if (sscanf(sd->msg, OKjob, &jcr->VolSessionId,
                  &jcr->VolSessionTime, &auth_key) != 3) {
-          Dmsg1(100, "BadJob=%s\n", sd->msg);
-          Jmsg(jcr, M_FATAL, 0, _("Storage daemon rejected Job command: %s\n"), sd->msg);
+         Dmsg1(100, "BadJob=%s\n", sd->msg);
+         Jmsg(jcr, M_FATAL, 0, _("Storage daemon rejected Job command: %s\n"), sd->msg);
          return 0;
        } else {
          jcr->sd_auth_key = bstrdup(auth_key);
-          Dmsg1(150, "sd_auth_key=%s\n", jcr->sd_auth_key);
+         Dmsg1(150, "sd_auth_key=%s\n", jcr->sd_auth_key);
        }
    } else {
       Jmsg(jcr, M_FATAL, 0, _("<stored: bad response to Job command: %s\n"),
@@ -150,14 +150,14 @@ int start_storage_daemon_job(JCR *jcr)
         bash_spaces(media_type);
         bash_spaces(pool_type);
         bash_spaces(pool_name);
-        bnet_fsend(sd, use_device, device_name.c_str(), 
+        bnet_fsend(sd, use_device, device_name.c_str(),
                    media_type.c_str(), pool_name.c_str(), pool_type.c_str());
-         Dmsg1(110, ">stored: %s", sd->msg);
-         status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY);
+        Dmsg1(110, ">stored: %s", sd->msg);
+        status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY);
         if (!status) {
            pm_strcpy(pool_type, sd->msg); /* save message */
-            Jmsg(jcr, M_FATAL, 0, _("\n"
-               "     Storage daemon didn't accept Device \"%s\" because:\n     %s"),
+           Jmsg(jcr, M_FATAL, 0, _("\n"
+              "     Storage daemon didn't accept Device \"%s\" because:\n     %s"),
               device_name.c_str(), pool_type.c_str()/* sd->msg */);
         }
       }
@@ -165,7 +165,7 @@ int start_storage_daemon_job(JCR *jcr)
    return status;
 }
 
-/* 
+/*
  * Start a thread to handle Storage daemon messages and
  *  Catalog requests.
  */
@@ -182,12 +182,12 @@ int start_storage_daemon_message_thread(JCR *jcr)
    Dmsg0(100, "Start SD msg_thread.\n");
    if ((status=pthread_create(&thid, NULL, msg_thread, (void *)jcr)) != 0) {
       Jmsg1(jcr, M_ABORT, 0, _("Cannot create message thread: %s\n"), strerror(status));
-   }        
+   }
    Dmsg0(100, "SD msg_thread started.\n");
    /* Wait for thread to start */
    while (jcr->SD_msg_chan == 0) {
       bmicrosleep(0, 50);
-   }  
+   }
    return 1;
 }
 
@@ -239,13 +239,13 @@ void *msg_thread(void *arg)
         jcr->SDJobFiles = JobFiles;
         jcr->SDJobBytes = JobBytes;
         break;
-      }     
+      }
       if (sscanf(sd->msg, Job_status, &Job, &JobStatus) == 2) {
         jcr->SDJobStatus = JobStatus; /* current status */
         continue;
       }
    }
-   if (is_bnet_error(sd)) {                  
+   if (is_bnet_error(sd)) {
       jcr->SDJobStatus = JS_ErrorTerminated;
    }
    pthread_cleanup_pop(1);
index 39f3280abecb4c17b0e06b535a7e21b46688be04..2475f00502ec75c4463d98dd68002be9e1f3420b 100644 (file)
@@ -59,7 +59,7 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr)
         set_pool_dbr_defaults_in_media_dbr(mr, &pr);
         jcr->VolumeName[0] = 0;
         bstrncpy(mr->MediaType, jcr->store->media_type, sizeof(mr->MediaType));
-         if (generate_event(jcr, "NewVolume") == 1 && jcr->VolumeName[0]) {
+        if (generate_event(jcr, "NewVolume") == 1 && jcr->VolumeName[0]) {
            bstrncpy(mr->VolumeName, jcr->VolumeName, sizeof(mr->VolumeName));
         /* Check for special characters */
         } else if (is_volume_name_legal(NULL, pr.LabelFormat)) {
@@ -69,11 +69,11 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr)
            }
         } else {  /* try full substitution */
            /* Found special characters, so try substitution */
-           if (!perform_full_name_substitution(jcr, mr, &pr)) { 
+           if (!perform_full_name_substitution(jcr, mr, &pr)) {
               goto bail_out;
            }
            if (!is_volume_name_legal(NULL, mr->VolumeName)) {
-               Jmsg(jcr, M_ERROR, 0, _("Illegal character in Volume name \"%s\"\n"),
+              Jmsg(jcr, M_ERROR, 0, _("Illegal character in Volume name \"%s\"\n"),
                  mr->VolumeName);
               goto bail_out;
            }
@@ -82,11 +82,11 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr)
         if (db_create_media_record(jcr, jcr->db, mr) &&
            db_update_pool_record(jcr, jcr->db, &pr)) {
            db_unlock(jcr->db);
-            Jmsg(jcr, M_INFO, 0, _("Created new Volume \"%s\" in catalog.\n"), mr->VolumeName);
-            Dmsg1(90, "Created new Volume=%s\n", mr->VolumeName);
+           Jmsg(jcr, M_INFO, 0, _("Created new Volume \"%s\" in catalog.\n"), mr->VolumeName);
+           Dmsg1(90, "Created new Volume=%s\n", mr->VolumeName);
            return true;
         } else {
-            Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
+           Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
         }
       }
    }
@@ -110,8 +110,8 @@ static int create_simple_name(JCR *jcr, MEDIA_DBR *mr, POOL_DBR *pr)
       bstrncpy(tmr.VolumeName, name, sizeof(tmr.VolumeName));
       bstrncat(tmr.VolumeName, num, sizeof(tmr.VolumeName));
       if (db_get_media_record(jcr, jcr->db, &tmr)) {
-        Jmsg(jcr, M_WARNING, 0, 
-             _("Wanted to create Volume \"%s\", but it already exists. Trying again.\n"), 
+        Jmsg(jcr, M_WARNING, 0,
+            _("Wanted to create Volume \"%s\", but it already exists. Trying again.\n"),
             tmr.VolumeName);
         continue;
       }
index 5f58db8236d0cba4f02e8593f9c2abbbc9f7fb89..34b84b9133660cdbd53a17cfa25f377b52a9596c 100644 (file)
@@ -51,8 +51,8 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create)
    bstrncpy(mr->MediaType, store->media_type, sizeof(mr->MediaType));
    Dmsg2(120, "CatReq FindMedia: Id=%d, MediaType=%s\n", mr->PoolId, mr->MediaType);
    /*
-    * If we are using an Autochanger, restrict Volume 
-    *  search to the Autochanger on the first pass 
+    * If we are using an Autochanger, restrict Volume
+    *  search to the Autochanger on the first pass
     */
    InChanger = store->autochanger;
    /*
@@ -64,16 +64,16 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create)
       /*
        *  1. Look for volume with "Append" status.
        */
-      ok = db_find_next_volume(jcr, jcr->db, 1, InChanger, mr);  
+      ok = db_find_next_volume(jcr, jcr->db, 1, InChanger, mr);
       Dmsg2(100, "catreq after find_next_vol ok=%d FW=%d\n", ok, mr->FirstWritten);
       if (!ok) {
         /*
          * 2. Try finding a recycled volume
          */
         ok = find_recycled_volume(jcr, InChanger, mr);
-         Dmsg2(100, "find_recycled_volume %d FW=%d\n", ok, mr->FirstWritten);
+        Dmsg2(100, "find_recycled_volume %d FW=%d\n", ok, mr->FirstWritten);
         if (!ok) {
-           /* 
+           /*
             * 3. Try recycling any purged volume
             */
            ok = recycle_oldest_purged_volume(jcr, InChanger, mr);
@@ -81,7 +81,7 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create)
               /*
                * 4. Try pruning Volumes
                */
-              prune_volumes(jcr);  
+              prune_volumes(jcr);
               ok = recycle_oldest_purged_volume(jcr, InChanger, mr);
               if (InChanger) {
                  InChanger = false;
@@ -89,47 +89,47 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create)
                     continue;           /* retry again accepting any volume */
                  }
               }
-               Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr->FirstWritten);
+              Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr->FirstWritten);
               if (!ok && create) {
                  /*
-                   * 5. Try "creating" a new Volume
+                  * 5. Try "creating" a new Volume
                   */
                  ok = newVolume(jcr, mr);
               }
            }
         }
 
-        /* 
+        /*
          *  Look at more drastic ways to find an Appendable Volume
-         */ 
+         */
         if (!ok && (jcr->pool->purge_oldest_volume ||
                     jcr->pool->recycle_oldest_volume)) {
-            Dmsg2(200, "No next volume found. PurgeOldest=%d\n RecyleOldest=%d",
+           Dmsg2(200, "No next volume found. PurgeOldest=%d\n RecyleOldest=%d",
                jcr->pool->purge_oldest_volume, jcr->pool->recycle_oldest_volume);
            /* Find oldest volume to recycle */
            ok = db_find_next_volume(jcr, jcr->db, -1, InChanger, mr);
-            Dmsg1(400, "Find oldest=%d\n", ok);
+           Dmsg1(400, "Find oldest=%d\n", ok);
            if (ok) {
               UAContext *ua;
-               Dmsg0(400, "Try purge.\n");
-              /* 
+              Dmsg0(400, "Try purge.\n");
+              /*
                * 5.  Try to purging oldest volume only if not UA calling us.
                */
               ua = new_ua_context(jcr);
               if (jcr->pool->purge_oldest_volume && create) {
-                  Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"), mr->VolumeName);
+                 Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"), mr->VolumeName);
                  ok = purge_jobs_from_volume(ua, mr);
               /*
                * 5. or try recycling the oldest volume
                */
               } else if (jcr->pool->recycle_oldest_volume) {
-                  Jmsg(jcr, M_INFO, 0, _("Pruning oldest volume \"%s\"\n"), mr->VolumeName);
+                 Jmsg(jcr, M_INFO, 0, _("Pruning oldest volume \"%s\"\n"), mr->VolumeName);
                  ok = prune_volume(ua, mr);
               }
               free_ua_context(ua);
               if (ok) {
                  ok = recycle_volume(jcr, mr);
-                  Dmsg1(400, "Recycle after purge oldest=%d\n", ok);
+                 Dmsg1(400, "Recycle after purge oldest=%d\n", ok);
               }
            }
         }
@@ -167,30 +167,30 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr)
    if (strcmp(mr->VolStatus, "Append") == 0 && mr->VolJobs > 0) {
       /* First handle Max Volume Bytes */
       if ((mr->MaxVolBytes > 0 && mr->VolBytes >= mr->MaxVolBytes)) {
-         Jmsg(jcr, M_INFO, 0, _("Max Volume bytes exceeded. "             
-             "Marking Volume \"%s\" as Full.\n"), mr->VolumeName);
-         bstrncpy(mr->VolStatus, "Full", sizeof(mr->VolStatus));
+        Jmsg(jcr, M_INFO, 0, _("Max Volume bytes exceeded. "
+            "Marking Volume \"%s\" as Full.\n"), mr->VolumeName);
+        bstrncpy(mr->VolStatus, "Full", sizeof(mr->VolStatus));
         expired = true;
 
       /* Now see if Volume should only be used once */
       } else if (mr->VolBytes > 0 && jcr->pool->use_volume_once) {
-         Jmsg(jcr, M_INFO, 0, _("Volume used once. "             
-             "Marking Volume \"%s\" as Used.\n"), mr->VolumeName);
-         bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus));
+        Jmsg(jcr, M_INFO, 0, _("Volume used once. "
+            "Marking Volume \"%s\" as Used.\n"), mr->VolumeName);
+        bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus));
         expired = true;
 
       /* Now see if Max Jobs written to volume */
       } else if (mr->MaxVolJobs > 0 && mr->MaxVolJobs <= mr->VolJobs) {
-         Jmsg(jcr, M_INFO, 0, _("Max Volume jobs exceeded. "       
-             "Marking Volume \"%s\" as Used.\n"), mr->VolumeName);
-         bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus));
+        Jmsg(jcr, M_INFO, 0, _("Max Volume jobs exceeded. "
+            "Marking Volume \"%s\" as Used.\n"), mr->VolumeName);
+        bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus));
         expired = true;
 
       /* Now see if Max Files written to volume */
       } else if (mr->MaxVolFiles > 0 && mr->MaxVolFiles <= mr->VolFiles) {
-         Jmsg(jcr, M_INFO, 0, _("Max Volume files exceeded. "       
-             "Marking Volume \"%s\" as Used.\n"), mr->VolumeName);
-         bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus));
+        Jmsg(jcr, M_INFO, 0, _("Max Volume files exceeded. "
+            "Marking Volume \"%s\" as Used.\n"), mr->VolumeName);
+        bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus));
         expired = true;
 
       /* Finally, check Use duration expiration */
@@ -198,9 +198,9 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr)
         utime_t now = time(NULL);
         /* See if Vol Use has expired */
         if (mr->VolUseDuration <= (now - mr->FirstWritten)) {
-            Jmsg(jcr, M_INFO, 0, _("Max configured use duration exceeded. "       
-               "Marking Volume \"%s\" as Used.\n"), mr->VolumeName);
-            bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus));
+           Jmsg(jcr, M_INFO, 0, _("Max configured use duration exceeded. "
+              "Marking Volume \"%s\" as Used.\n"), mr->VolumeName);
+           bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus));
            expired = true;
         }
       }
@@ -208,10 +208,10 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr)
    if (expired) {
       /* Need to update media */
       if (!db_update_media_record(jcr, jcr->db, mr)) {
-         Jmsg(jcr, M_ERROR, 0, _("Catalog error updating volume \"%s\". ERR=%s"),
+        Jmsg(jcr, M_ERROR, 0, _("Catalog error updating volume \"%s\". ERR=%s"),
              mr->VolumeName, db_strerror(jcr->db));
-      }          
-   }  
+      }
+   }
    return expired;
 }
 
@@ -241,25 +241,25 @@ void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **r
       *reason = NULL;
       return;
    }
-                                                                                       
+
    /*
     * Check if the Volume is already marked for recycling
     */
    if (strcmp(mr->VolStatus, "Purged") == 0) {
       if (recycle_volume(jcr, mr)) {
-         Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName);
+        Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName);
         *reason = NULL;
         return;
       } else {
-         /* In principle this shouldn't happen */
-         *reason = "and recycling of current volume failed";
+        /* In principle this shouldn't happen */
+        *reason = "and recycling of current volume failed";
         return;
       }
    }
-                                                                                       
+
    /* At this point, the volume is not valid for writing */
    *reason = "but should be Append, Purged or Recycle";
-                                                                                       
+
    /*
     * What we're trying to do here is see if the current volume is
     * "recyclable" - ie. if we prune all expired jobs off it, is
@@ -268,30 +268,30 @@ void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **r
     */
    if ((mr->LastWritten + mr->VolRetention) < (utime_t)time(NULL)
         && mr->Recycle && jcr->pool->recycle_current_volume
-         && (strcmp(mr->VolStatus, "Full") == 0 ||
-            strcmp(mr->VolStatus, "Used") == 0)) {
+        && (strcmp(mr->VolStatus, "Full") == 0 ||
+           strcmp(mr->VolStatus, "Used") == 0)) {
       /*
        * Attempt prune of current volume to see if we can
        * recycle it for use.
        */
       UAContext *ua;
-                                                                                       
+
       ua = new_ua_context(jcr);
       ok = prune_volume(ua, mr);
       free_ua_context(ua);
-                                                                                       
+
       if (ok) {
         /* If fully purged, recycle current volume */
         if (recycle_volume(jcr, mr)) {
-            Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName);
+           Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName);
            *reason = NULL;
         } else {
-            *reason = "but should be Append, Purged or Recycle (recycling of the "
-               "current volume failed)";
+           *reason = "but should be Append, Purged or Recycle (recycling of the "
+              "current volume failed)";
         }
       } else {
-         *reason = "but should be Append, Purged or Recycle (cannot automatically "
-            "recycle current volume, as it still contains unpruned data)";
+        *reason = "but should be Append, Purged or Recycle (cannot automatically "
+           "recycle current volume, as it still contains unpruned data)";
       }
    }
 }
index c0891d1b13b231c9e8a5cbd7beae086c6f3fedcc..81ae6d5c0b569b2e15d5b879d5dadab1f1b5d767 100644 (file)
@@ -69,7 +69,7 @@ extern int send_bootstrap_file(JCR *jcr);
 extern int send_level_command(JCR *jcr);
 extern int get_attributes_and_put_in_catalog(JCR *jcr);
 extern int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId);
-extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname, 
+extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname,
                          char *link, char *attr, int stream);
 extern void get_level_since_time(JCR *jcr, char *since, int since_len);
 extern int send_run_before_and_after_commands(JCR *jcr);
@@ -97,7 +97,7 @@ extern void set_storage(JCR *jcr, STORE *store);
 extern void mount_request(JCR *jcr, BSOCK *bs, char *buf);
 
 /* msgchan.c */
-extern bool connect_to_storage_daemon(JCR *jcr, int retry_interval,    
+extern bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
                              int max_retry_time, int verbose);
 extern int start_storage_daemon_job(JCR *jcr);
 extern int start_storage_daemon_message_thread(JCR *jcr);
@@ -123,7 +123,7 @@ int qmessagescmd(UAContext *ua, const char *cmd);
 int open_db(UAContext *ua);
 void close_db(UAContext *ua);
 enum e_pool_op {
-   POOL_OP_UPDATE, 
+   POOL_OP_UPDATE,
    POOL_OP_CREATE
 };
 int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op);
@@ -163,7 +163,7 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr);
 void   start_prompt(UAContext *ua, const char *msg);
 void   add_prompt(UAContext *ua, const char *prompt);
 int    do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt);
-CAT    *get_catalog_resource(UAContext *ua);          
+CAT    *get_catalog_resource(UAContext *ua);
 STORE  *get_storage_resource(UAContext *ua, int use_default);
 int    get_media_type(UAContext *ua, char *MediaType, int max_media);
 bool   get_pool_dbr(UAContext *ua, POOL_DBR *pr);
index f84fa637eb58027b3264f074941032ec05d1192d..ba1562c148f1460095c8942e233a64f34e3d33be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 
+ *
  * Bacula interface to Python for the Director
  *
  * Kern Sibbald, November MMIV
@@ -9,7 +9,7 @@
  */
 
 /*
-   
+
    Copyright (C) 2004 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
@@ -46,7 +46,7 @@ PyObject *bacula_run(PyObject *self, PyObject *args);
 PyMethodDef BaculaMethods[] = {
     {"get", bacula_get, METH_VARARGS, "Get Bacula variables."},
     {"set", (PyCFunction)bacula_set, METH_VARARGS|METH_KEYWORDS,
-        "Set Bacula variables."}, 
+       "Set Bacula variables."},
     {"run", (PyCFunction)bacula_run, METH_VARARGS, "Run a Bacula command."},
     {NULL, NULL, 0, NULL}            /* last item */
 };
@@ -55,7 +55,7 @@ PyMethodDef BaculaMethods[] = {
 struct s_vars {
    const char *name;
    char *fmt;
-};     
+};
 
 static struct s_vars vars[] = {
    { N_("Job"),        "s"},
@@ -71,7 +71,7 @@ static struct s_vars vars[] = {
    { N_("MediaType"),  "s"},
    { N_("JobName"),    "s"},
    { N_("JobStatus"),  "s"},
-   
+
    { NULL,            NULL}
 };
 
@@ -139,7 +139,7 @@ PyObject *bacula_set(PyObject *self, PyObject *args, PyObject *keyw)
    char *msg = NULL;
    char *VolumeName = NULL;
    static char *kwlist[] = {"jcr", "JobReport", "VolumeName", NULL};
-   if (!PyArg_ParseTupleAndKeywords(args, keyw, "O|ss:set", kwlist, 
+   if (!PyArg_ParseTupleAndKeywords(args, keyw, "O|ss:set", kwlist,
        &CObject, &msg, &VolumeName)) {
       return NULL;
    }
index 84a39a9dc4ba4bcc48b75e4272f5e37071b0f157..1b785dfbde6c56af2fb632affc2c723cd9d445cd 100644 (file)
@@ -72,10 +72,10 @@ int recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
    struct s_oldest_ctx oldest;
    POOLMEM *query = get_pool_memory(PM_EMSG);
    const char *select =
-          "SELECT MediaId,LastWritten FROM Media "
-          "WHERE PoolId=%u AND Recycle=1 AND VolStatus='Purged' "
-          "AND MediaType='%s' %s"
-          "ORDER BY LastWritten ASC,MediaId LIMIT 1";
+         "SELECT MediaId,LastWritten FROM Media "
+         "WHERE PoolId=%u AND Recycle=1 AND VolStatus='Purged' "
+         "AND MediaType='%s' %s"
+         "ORDER BY LastWritten ASC,MediaId LIMIT 1";
 
    Dmsg0(100, "Enter recycle_oldest_purged_volume\n");
    oldest.MediaId = 0;
@@ -97,15 +97,15 @@ int recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
       mr->MediaId = oldest.MediaId;
       if (db_get_media_record(jcr, jcr->db, mr)) {
         if (recycle_volume(jcr, mr)) {
-            Jmsg(jcr, M_INFO, 0, "Recycled volume \"%s\"\n", mr->VolumeName);
-            Dmsg1(100, "return 1  recycle_oldest_purged_volume Vol=%s\n", mr->VolumeName);
+           Jmsg(jcr, M_INFO, 0, "Recycled volume \"%s\"\n", mr->VolumeName);
+           Dmsg1(100, "return 1  recycle_oldest_purged_volume Vol=%s\n", mr->VolumeName);
            return 1;
         }
       }
       Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
    }
    Dmsg0(100, "return 0  recycle_oldest_purged_volume end\n");
-   return 0;   
+   return 0;
 }
 
 /*
index 27c3abc025b49d74a05ed2910bb7dc69f9bc0dd8..d8a894bf243408234540d56e1cfe9c6b857a0ba1 100644 (file)
@@ -3,8 +3,8 @@
  *
  *     Kern Sibbald, November MM
  *
- *    This routine is run as a separate thread.  
- * 
+ *    This routine is run as a separate thread.
+ *
  * Current implementation is Catalog verification only (i.e. no
  *  verification versus tape).
  *
@@ -44,7 +44,7 @@
 /* Commands sent to File daemon */
 static char restorecmd[]   = "restore replace=%c prelinks=%d where=%s\n";
 static char storaddr[]     = "storage address=%s port=%d ssl=0\n";
-static char sessioncmd[]   = "session %s %ld %ld %ld %ld %ld %ld\n";  
+static char sessioncmd[]   = "session %s %ld %ld %ld %ld %ld %ld\n";
 
 /* Responses received from File daemon */
 static char OKrestore[]   = "2000 OK restore\n";
@@ -56,13 +56,13 @@ static void restore_cleanup(JCR *jcr, int status);
 
 /* External functions */
 
-/* 
+/*
  * Do a restore of the specified files
- *    
+ *
  *  Returns:  0 on failure
  *           1 on success
  */
-int do_restore(JCR *jcr) 
+int do_restore(JCR *jcr)
 {
    BSOCK   *fd;
    JOB_DBR rjr;                      /* restore job record */
@@ -84,7 +84,7 @@ int do_restore(JCR *jcr)
 
    Dmsg1(20, "RestoreJobId=%d\n", jcr->job->RestoreJobId);
 
-   /* 
+   /*
     * The following code is kept temporarily for compatibility.
     * It is the predecessor to the Bootstrap file.
     *  DEPRECATED
@@ -99,7 +99,7 @@ int do_restore(JCR *jcr)
         rjr.JobId = jcr->job->RestoreJobId; /* specified by Job Resource */
       }
       if (!db_get_job_record(jcr, jcr->db, &rjr)) {
-         Jmsg2(jcr, M_FATAL, 0, _("Cannot get job record id=%d %s"), rjr.JobId,
+        Jmsg2(jcr, M_FATAL, 0, _("Cannot get job record id=%d %s"), rjr.JobId,
            db_strerror(jcr->db));
         restore_cleanup(jcr, JS_ErrorTerminated);
         return 0;
@@ -111,14 +111,14 @@ int do_restore(JCR *jcr)
       jcr->VolumeName[0] = 0;
       if (!db_get_job_volume_names(jcr, jcr->db, rjr.JobId, &jcr->VolumeName) ||
           jcr->VolumeName[0] == 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Cannot find Volume names for restore Job %d. %s"), 
+        Jmsg(jcr, M_FATAL, 0, _("Cannot find Volume names for restore Job %d. %s"),
            rjr.JobId, db_strerror(jcr->db));
         restore_cleanup(jcr, JS_ErrorTerminated);
         return 0;
       }
       Dmsg1(20, "Got job Volume Names: %s\n", jcr->VolumeName);
    }
-      
+
 
    /* Print Job Start message */
    Jmsg(jcr, M_INFO, 0, _("Start Restore Job %s\n"), jcr->Job);
@@ -132,7 +132,7 @@ int do_restore(JCR *jcr)
    Dmsg0(10, "Open connection with storage daemon\n");
    set_jcr_job_status(jcr, JS_WaitSD);
    /*
-    * Start conversation with Storage daemon  
+    * Start conversation with Storage daemon
     */
    if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) {
       restore_cleanup(jcr, JS_ErrorTerminated);
@@ -154,8 +154,8 @@ int do_restore(JCR *jcr)
    }
    Dmsg0(50, "Storage daemon connection OK\n");
 
-   /* 
-    * Start conversation with File daemon  
+   /*
+    * Start conversation with File daemon
     */
    set_jcr_job_status(jcr, JS_WaitFD);
    if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) {
@@ -176,7 +176,7 @@ int do_restore(JCR *jcr)
       return 0;
    }
 
-   /* 
+   /*
     * send Storage daemon address to the File daemon,
     *  then wait for File daemon to make connection
     *  with Storage daemon.
@@ -191,7 +191,7 @@ int do_restore(JCR *jcr)
       return 0;
    }
 
-   /* 
+   /*
     * Send the bootstrap file -- what Volumes/files to restore
     */
    if (!send_bootstrap_file(jcr)) {
@@ -199,18 +199,18 @@ int do_restore(JCR *jcr)
       return 0;
    }
 
-   /* 
-    * The following code is deprecated  
+   /*
+    * The following code is deprecated
     */
    if (!jcr->RestoreBootstrap) {
       /*
        * Pass the VolSessionId, VolSessionTime, Start and
        * end File and Blocks on the session command.
        */
-      bnet_fsend(fd, sessioncmd, 
+      bnet_fsend(fd, sessioncmd,
                jcr->VolumeName,
-               rjr.VolSessionId, rjr.VolSessionTime, 
-               rjr.StartFile, rjr.EndFile, rjr.StartBlock, 
+               rjr.VolSessionId, rjr.VolSessionTime,
+               rjr.StartFile, rjr.EndFile, rjr.StartBlock,
                rjr.EndBlock);
       if (!response(jcr, fd, OKsession, "Session", DISPLAY_ERROR)) {
         restore_cleanup(jcr, JS_ErrorTerminated);
@@ -226,7 +226,7 @@ int do_restore(JCR *jcr)
    /* Send restore command */
    char replace, *where;
    char empty = '\0';
-   
+
    if (jcr->replace != 0) {
       replace = jcr->replace;
    } else if (jcr->job->replace != 0) {
@@ -281,14 +281,14 @@ static void restore_cleanup(JCR *jcr, int TermCode)
    switch (TermCode) {
    case JS_Terminated:
       if (jcr->ExpectedFiles > jcr->jr.JobFiles) {
-         term_msg = _("Restore OK -- warning file count mismatch");
+        term_msg = _("Restore OK -- warning file count mismatch");
       } else {
-         term_msg = _("Restore OK");
+        term_msg = _("Restore OK");
       }
       break;
    case JS_FatalError:
    case JS_ErrorTerminated:
-      term_msg = _("*** Restore Error ***"); 
+      term_msg = _("*** Restore Error ***");
       msg_type = M_ERROR;         /* Generate error message */
       if (jcr->store_bsock) {
         bnet_sig(jcr->store_bsock, BNET_TERMINATE);
@@ -325,20 +325,20 @@ static void restore_cleanup(JCR *jcr, int TermCode)
    jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
    jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
 
-   Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\
-  JobId:                  %d\n\
-  Job:                    %s\n\
-  Client:                 %s\n\
-  Start time:             %s\n\
-  End time:               %s\n\
-  Files Expected:         %s\n\
-  Files Restored:         %s\n\
-  Bytes Restored:         %s\n\
-  Rate:                   %.1f KB/s\n\
-  FD Errors:              %d\n\
-  FD termination status:  %s\n\
-  SD termination status:  %s\n\
-  Termination:            %s\n\n"),
+   Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
+"  JobId:                  %d\n"
+"  Job:                    %s\n"
+"  Client:                 %s\n"
+"  Start time:             %s\n"
+"  End time:               %s\n"
+"  Files Expected:         %s\n"
+"  Files Restored:         %s\n"
+"  Bytes Restored:         %s\n"
+"  Rate:                   %.1f KB/s\n"
+"  FD Errors:              %d\n"
+"  FD termination status:  %s\n"
+"  SD termination status:  %s\n"
+"  Termination:            %s\n\n"),
        edt,
        jcr->jr.JobId,
        jcr->jr.Job,
index 0d31987a2310a199268a79a0dd754962c47ca09e..cd3092a262ddc3c932942c242c0202c49bc3ce9e 100644 (file)
@@ -49,7 +49,7 @@ enum e_state {
    s_hourly,
    s_wom,                          /* 1st, 2nd, ...*/
    s_woy                           /* week of year w00 - w53 */
-};  
+};
 
 struct s_keyw {
   const char *name;                          /* keyword */
@@ -151,15 +151,15 @@ static struct s_kw RunFields[] = {
    {NULL,                0}
 };
 
-/* 
- * Store Schedule Run information   
- * 
+/*
+ * Store Schedule Run information
+ *
  * Parse Run statement:
  *
  *  Run <keyword=value ...> [on] 2 january at 23:45
  *
  *   Default Run time is daily at 0:0
- *  
+ *
  *   There can be multiple run statements, they are simply chained
  *   together.
  *
@@ -170,7 +170,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
    bool found;
    int token, state, state2 = 0, code = 0, code2 = 0;
    int options = lc->options;
-   RUN **run = (RUN **)(item->value);  
+   RUN **run = (RUN **)(item->value);
    RUN *trun;
    char *p;
    RES *res;
@@ -189,23 +189,23 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
         if (strcasecmp(lc->str, RunFields[i].name) == 0) {
            found = true;
            if (lex_get_token(lc, T_ALL) != T_EQUALS) {
-               scan_err1(lc, "Expected an equals, got: %s", lc->str);
-              /* NOT REACHED */ 
+              scan_err1(lc, "Expected an equals, got: %s", lc->str);
+              /* NOT REACHED */
            }
            switch (RunFields[i].token) {
-            case 's':                 /* Data spooling */
+           case 's':                 /* Data spooling */
               token = lex_get_token(lc, T_NAME);
-               if (strcasecmp(lc->str, "yes") == 0) {
+              if (strcasecmp(lc->str, "yes") == 0) {
                  lrun.spool_data = true;
                  lrun.spool_data_set = true;
-               } else if (strcasecmp(lc->str, "no") == 0) {
+              } else if (strcasecmp(lc->str, "no") == 0) {
                  lrun.spool_data = false;
                  lrun.spool_data_set = true;
               } else {
-                  scan_err1(lc, _("Expect a YES or NO, got: %s"), lc->str);
+                 scan_err1(lc, _("Expect a YES or NO, got: %s"), lc->str);
               }
               break;
-            case 'L':                 /* level */
+           case 'L':                 /* level */
               token = lex_get_token(lc, T_NAME);
               for (j=0; joblevels[j].level_name; j++) {
                  if (strcasecmp(lc->str, joblevels[j].level_name) == 0) {
@@ -216,62 +216,62 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
                  }
               }
               if (j != 0) {
-                  scan_err1(lc, _("Job level field: %s not found in run record"), lc->str);
+                 scan_err1(lc, _("Job level field: %s not found in run record"), lc->str);
                  /* NOT REACHED */
               }
               break;
-            case 'p':                 /* Priority */
+           case 'p':                 /* Priority */
               token = lex_get_token(lc, T_PINT32);
               if (pass == 2) {
                  lrun.Priority = lc->pint32_val;
               }
               break;
-            case 'P':                 /* Pool */
-            case 'f':                 /* FullPool */
-            case 'i':                 /* IncPool */
-            case 'd':                 /* DifPool */
+           case 'P':                 /* Pool */
+           case 'f':                 /* FullPool */
+           case 'i':                 /* IncPool */
+           case 'd':                 /* DifPool */
               token = lex_get_token(lc, T_NAME);
               if (pass == 2) {
                  res = GetResWithName(R_POOL, lc->str);
                  if (res == NULL) {
-                     scan_err1(lc, "Could not find specified Pool Resource: %s",
+                    scan_err1(lc, "Could not find specified Pool Resource: %s",
                                lc->str);
                     /* NOT REACHED */
                  }
                  switch(RunFields[i].token) {
-                  case 'P':
+                 case 'P':
                     lrun.pool = (POOL *)res;
                     break;
-                  case 'f':
+                 case 'f':
                     lrun.full_pool = (POOL *)res;
                     break;
-                  case 'i':
+                 case 'i':
                     lrun.inc_pool = (POOL *)res;
                     break;
-                  case 'd':
+                 case 'd':
                     lrun.dif_pool = (POOL *)res;
                     break;
                  }
               }
               break;
-            case 'S':                 /* storage */
+           case 'S':                 /* storage */
               token = lex_get_token(lc, T_NAME);
               if (pass == 2) {
                  res = GetResWithName(R_STORAGE, lc->str);
                  if (res == NULL) {
-                     scan_err1(lc, "Could not find specified Storage Resource: %s",
+                    scan_err1(lc, "Could not find specified Storage Resource: %s",
                                lc->str);
                     /* NOT REACHED */
                  }
                  lrun.storage = (STORE *)res;
               }
               break;
-            case 'M':                 /* messages */
+           case 'M':                 /* messages */
               token = lex_get_token(lc, T_NAME);
               if (pass == 2) {
                  res = GetResWithName(R_MSGS, lc->str);
                  if (res == NULL) {
-                     scan_err1(lc, "Could not find specified Messages Resource: %s",
+                    scan_err1(lc, "Could not find specified Messages Resource: %s",
                                lc->str);
                     /* NOT REACHED */
                  }
@@ -279,10 +279,10 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
               }
               break;
            default:
-               scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
+              scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
               /* NOT REACHED */
               break;
-           } /* end switch */     
+           } /* end switch */
         } /* end if strcasecmp */
       } /* end for RunFields */
 
@@ -314,24 +314,24 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
         state = s_mday;
         code = atoi(lc->str) - 1;
         if (code < 0 || code > 30) {
-            scan_err0(lc, _("Day number out of range (1-31)"));
+           scan_err0(lc, _("Day number out of range (1-31)"));
         }
         break;
       case T_NAME:                /* this handles drop through from keyword */
       case T_UNQUOTED_STRING:
-         if (strchr(lc->str, (int)'-')) {
+        if (strchr(lc->str, (int)'-')) {
            state = s_range;
            break;
         }
-         if (strchr(lc->str, (int)':')) {
+        if (strchr(lc->str, (int)':')) {
            state = s_time;
            break;
         }
-         if (lc->str_len == 3 && (lc->str[0] == 'w' || lc->str[0] == 'W') &&
+        if (lc->str_len == 3 && (lc->str[0] == 'w' || lc->str[0] == 'W') &&
             is_an_integer(lc->str+1)) {
            code = atoi(lc->str+1);
            if (code < 0 || code > 53) {
-               scan_err0(lc, _("Week number out of range (0-53)"));
+              scan_err0(lc, _("Week number out of range (0-53)"));
            }
            state = s_woy;            /* week of year */
            break;
@@ -346,14 +346,14 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
            }
         }
         if (i != 0) {
-            scan_err1(lc, _("Job type field: %s in run record not found"), lc->str);
+           scan_err1(lc, _("Job type field: %s in run record not found"), lc->str);
            /* NOT REACHED */
         }
         break;
       case T_COMMA:
         continue;
       default:
-         scan_err2(lc, _("Unexpected token: %d:%s"), token, lc->str);
+        scan_err2(lc, _("Unexpected token: %d:%s"), token, lc->str);
         /* NOT REACHED */
         break;
       }
@@ -397,27 +397,27 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
         break;
       case s_time:                /* time */
         if (!have_at) {
-            scan_err0(lc, _("Time must be preceded by keyword AT."));
+           scan_err0(lc, _("Time must be preceded by keyword AT."));
            /* NOT REACHED */
         }
         if (!have_hour) {
            clear_bits(0, 23, lrun.hour);
         }
-         p = strchr(lc->str, ':');
+        p = strchr(lc->str, ':');
         if (!p)  {
-            scan_err0(lc, _("Time logic error.\n"));
+           scan_err0(lc, _("Time logic error.\n"));
            /* NOT REACHED */
         }
         *p++ = 0;                 /* separate two halves */
         code = atoi(lc->str);
         len = strlen(p);
-         if (len > 2 && p[len-1] == 'm') {
-            if (p[len-2] == 'a') {
+        if (len > 2 && p[len-1] == 'm') {
+           if (p[len-2] == 'a') {
               pm = 0;
-            } else if (p[len-2] == 'p') {
+           } else if (p[len-2] == 'p') {
               pm = 1;
            } else {
-               scan_err0(lc, _("Bad time specification."));
+              scan_err0(lc, _("Bad time specification."));
               /* NOT REACHED */
            }
         } else {
@@ -428,7 +428,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
            code += 12;
         }
         if (code < 0 || code > 23 || code2 < 0 || code2 > 59) {
-            scan_err0(lc, _("Bad time specification."));
+           scan_err0(lc, _("Bad time specification."));
            /* NOT REACHED */
         }
         /****FIXME**** convert to UTC */
@@ -440,9 +440,9 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
         have_at = true;
         break;
       case s_range:
-         p = strchr(lc->str, '-');
+        p = strchr(lc->str, '-');
         if (!p) {
-            scan_err0(lc, _("Range logic error.\n"));
+           scan_err0(lc, _("Range logic error.\n"));
         }
         *p++ = 0;                 /* separate two halves */
 
@@ -451,7 +451,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
            code = atoi(lc->str) - 1;
            code2 = atoi(p) - 1;
            if (code < 0 || code > 30 || code2 < 0 || code2 > 30) {
-               scan_err0(lc, _("Bad day range specification."));
+              scan_err0(lc, _("Bad day range specification."));
            }
            if (!have_mday) {
               clear_bits(0, 30, lrun.mday);
@@ -467,13 +467,13 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
         }
         /* Check for week of year range */
         if (strlen(lc->str) == 3 && strlen(p) == 3 &&
-             (lc->str[0] == 'w' || lc->str[0] == 'W') &&
-             (p[0] == 'w' || p[0] == 'W') &&
+            (lc->str[0] == 'w' || lc->str[0] == 'W') &&
+            (p[0] == 'w' || p[0] == 'W') &&
             is_an_integer(lc->str+1) && is_an_integer(p+1)) {
            code = atoi(lc->str+1);
            code2 = atoi(p+1);
            if (code < 0 || code > 53 || code2 < 0 || code2 > 53) {
-               scan_err0(lc, _("Week number out of range (0-53)"));
+              scan_err0(lc, _("Week number out of range (0-53)"));
            }
            if (!have_woy) {
               clear_bits(0, 53, lrun.woy);
@@ -498,7 +498,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
            }
         }
         if (i != 0 || (state != s_month && state != s_wday && state != s_wom)) {
-            scan_err0(lc, _("Invalid month, week or position day range"));
+           scan_err0(lc, _("Invalid month, week or position day range"));
            /* NOT REACHED */
         }
 
@@ -513,7 +513,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
            }
         }
         if (i != 0 || state != state2 || code == code2) {
-            scan_err0(lc, _("Invalid month, weekday or position range"));
+           scan_err0(lc, _("Invalid month, weekday or position range"));
            /* NOT REACHED */
         }
         if (state == s_wday) {
@@ -551,7 +551,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
               set_bits(code, 4, lrun.wom);
               set_bits(0, code2, lrun.wom);
            }
-        }                      
+        }
         break;
       case s_hourly:
         have_hour = true;
@@ -572,14 +572,14 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
         set_bits(0, 11, lrun.month);
         break;
       default:
-         scan_err0(lc, _("Unexpected run state\n"));
+        scan_err0(lc, _("Unexpected run state\n"));
         /* NOT REACHED */
         break;
       }
    }
 
    /* Allocate run record, copy new stuff into it,
-    * and link it into the list of run records 
+    * and link it into the list of run records
     * in the schedule resource.
     */
    if (pass == 2) {
index 80182c26127b2b90bd5411f8c6ab83fcbe070454..abe5668a863b29e89c776effe07a3e7bb4f4df2c 100644 (file)
@@ -2,7 +2,7 @@
  *
  *   Bacula scheduler
  *     It looks at what jobs are to be run and when
- *     and waits around until it is time to 
+ *     and waits around until it is time to
  *     fire them up.
  *
  *     Kern Sibbald, May MM, major revision December MMIII
 
 
 /* Local variables */
-struct job_item {  
+struct job_item {
    RUN *run;
    JOB *job;
    time_t runtime;
    int Priority;
    dlink link;                       /* link for list */
-};             
+};
 
 /* List of jobs to be run. They were scheduled in this hour or the next */
 static dlist *jobs_to_run;              /* list of jobs to be run */
@@ -82,9 +82,9 @@ JCR *wait_for_next_job(char *one_shot_job_to_run)
       if (one_shot_job_to_run) {           /* one shot */
         job = (JOB *)GetResWithName(R_JOB, one_shot_job_to_run);
         if (!job) {
-            Emsg1(M_ABORT, 0, _("Job %s not found\n"), one_shot_job_to_run);
+           Emsg1(M_ABORT, 0, _("Job %s not found\n"), one_shot_job_to_run);
         }
-         Dmsg1(5, "Found one_shot_job_to_run %s\n", one_shot_job_to_run);
+        Dmsg1(5, "Found one_shot_job_to_run %s\n", one_shot_job_to_run);
         jcr = new_jcr(sizeof(JCR), dird_free_jcr);
         set_jcr_defaults(jcr, job);
         return jcr;
@@ -107,7 +107,7 @@ JCR *wait_for_next_job(char *one_shot_job_to_run)
       dump_job(je, "Walk queue");
    }
 #endif
-   /* 
+   /*
     * Pull the first job to run (already sorted by runtime and
     *  Priority, then wait around until it is time to run it.
     */
@@ -174,7 +174,7 @@ JCR *wait_for_next_job(char *one_shot_job_to_run)
 
 
 /*
- * Shutdown the scheduler  
+ * Shutdown the scheduler
  */
 void term_scheduler()
 {
@@ -188,7 +188,7 @@ void term_scheduler()
    }
 }
 
-/*         
+/*
  * Find all jobs to be run this hour and the next hour.
  */
 static void find_runs()
@@ -205,7 +205,7 @@ static void find_runs()
 
    Dmsg0(200, "enter find_runs()\n");
 
-   
+
    /* compute values for time now */
    now = time(NULL);
    localtime_r(&now, &tm);
@@ -217,12 +217,12 @@ static void find_runs()
    wom = mday / 7;
    woy = tm_woy(now);                    /* get week of year */
 
-   /* 
+   /*
     * Compute values for next hour from now.
     * We do this to be sure we don't miss a job while
     * sleeping.
     */
-   next_hour = now + 3600;  
+   next_hour = now + 3600;
    localtime_r(&next_hour, &tm);
    nh_hour = tm.tm_hour;
    nh_mday = tm.tm_mday - 1;
@@ -242,14 +242,14 @@ static void find_runs()
       Dmsg1(200, "Got job: %s\n", job->hdr.name);
       for (run=sched->run; run; run=run->next) {
         bool run_now, run_nh;
-        /* 
+        /*
          * Find runs scheduled between now and the next hour.
          */
 #ifdef xxxx
-         Dmsg0(000, "\n");
-         Dmsg6(000, "run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n", 
+        Dmsg0(000, "\n");
+        Dmsg6(000, "run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
            hour, month, mday, wday, wom, woy);
-         Dmsg6(000, "bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n", 
+        Dmsg6(000, "bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n",
            bit_is_set(hour, run->hour),
            bit_is_set(month, run->month),
            bit_is_set(mday, run->mday),
@@ -257,9 +257,9 @@ static void find_runs()
            bit_is_set(wom, run->wom),
            bit_is_set(woy, run->woy));
 
-         Dmsg6(000, "nh_run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n", 
+        Dmsg6(000, "nh_run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
            nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy);
-         Dmsg6(000, "nh_bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n", 
+        Dmsg6(000, "nh_bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n",
            bit_is_set(nh_hour, run->hour),
            bit_is_set(nh_month, run->month),
            bit_is_set(nh_mday, run->mday),
@@ -269,20 +269,20 @@ static void find_runs()
 #endif
 
         run_now = bit_is_set(hour, run->hour) &&
-           bit_is_set(mday, run->mday) && 
+           bit_is_set(mday, run->mday) &&
            bit_is_set(wday, run->wday) &&
            bit_is_set(month, run->month) &&
            bit_is_set(wom, run->wom) &&
            bit_is_set(woy, run->woy);
 
         run_nh = bit_is_set(nh_hour, run->hour) &&
-           bit_is_set(nh_mday, run->mday) && 
+           bit_is_set(nh_mday, run->mday) &&
            bit_is_set(nh_wday, run->wday) &&
            bit_is_set(nh_month, run->month) &&
            bit_is_set(nh_wom, run->wom) &&
            bit_is_set(nh_woy, run->woy);
 
-         Dmsg2(200, "run_now=%d run_nh=%d\n", run_now, run_nh);
+        Dmsg2(200, "run_now=%d run_nh=%d\n", run_now, run_nh);
 
         /* find time (time_t) job is to be run */
         localtime_r(&now, &tm);      /* reset tm structure */
@@ -302,7 +302,7 @@ static void find_runs()
            runtime = mktime(&tm);
            add_job(job, run, now, runtime);
         }
-      }  
+      }
    }
    UnlockRes();
    Dmsg0(200, "Leave find_runs()\n");
@@ -319,10 +319,10 @@ static void add_job(JOB *job, RUN *run, time_t now, time_t runtime)
    if (((runtime - run->last_run) < 61) || ((runtime+59) < now)) {
 #ifdef SCHED_DEBUG
       char dt[50], dt1[50], dt2[50];
-      bstrftime_nc(dt, sizeof(dt), runtime);  
+      bstrftime_nc(dt, sizeof(dt), runtime);
       bstrftime_nc(dt1, sizeof(dt1), run->last_run);
       bstrftime_nc(dt2, sizeof(dt2), now);
-      Dmsg4(000, "Drop: Job=\"%s\" run=%s. last_run=%s. now=%s\n", job->hdr.name, 
+      Dmsg4(000, "Drop: Job=\"%s\" run=%s. last_run=%s. now=%s\n", job->hdr.name,
            dt, dt1, dt2);
       fflush(stdout);
 #endif
@@ -341,10 +341,10 @@ static void add_job(JOB *job, RUN *run, time_t now, time_t runtime)
 
    /* Add this job to the wait queue in runtime, priority sorted order */
    foreach_dlist(ji, jobs_to_run) {
-      if (ji->runtime > je->runtime || 
+      if (ji->runtime > je->runtime ||
          (ji->runtime == je->runtime && ji->Priority > je->Priority)) {
         jobs_to_run->insert_before(je, ji);
-         dump_job(je, "Inserted job");
+        dump_job(je, "Inserted job");
         inserted = true;
         break;
       }
@@ -362,7 +362,7 @@ static void add_job(JOB *job, RUN *run, time_t now, time_t runtime)
 #endif
 }
 
-static void dump_job(job_item *ji, const char *msg) 
+static void dump_job(job_item *ji, const char *msg)
 {
 #ifdef SCHED_DEBUG
    char dt[MAX_TIME_LENGTH];
@@ -371,8 +371,8 @@ static void dump_job(job_item *ji, const char *msg)
    if (debug_level < 200) {
       return;
    }
-   bstrftime_nc(dt, sizeof(dt), ji->runtime);  
-   Dmsg4(200, "%s: Job=%s priority=%d run %s\n", msg, ji->job->hdr.name, 
+   bstrftime_nc(dt, sizeof(dt), ji->runtime);
+   Dmsg4(200, "%s: Job=%s priority=%d run %s\n", msg, ji->job->hdr.name,
       ji->Priority, dt);
    fflush(stdout);
    debug_level = save_debug;
index f66472212045e44aac9355ba1fa7e58998cc1973..99708e41ae9a100051dc23e1516eb2a711190c86 100644 (file)
@@ -52,13 +52,13 @@ const char *del_File     = "DELETE FROM File WHERE JobId=%u";
 const char *upd_Purged   = "UPDATE Job Set PurgedFiles=1 WHERE JobId=%u";
 const char *cnt_DelCand  = "SELECT count(*) FROM DelCandidates";
 const char *del_Job      = "DELETE FROM Job WHERE JobId=%u";
-const char *del_JobMedia = "DELETE FROM JobMedia WHERE JobId=%u"; 
+const char *del_JobMedia = "DELETE FROM JobMedia WHERE JobId=%u";
 const char *cnt_JobMedia = "SELECT count(*) FROM JobMedia WHERE MediaId=%u";
 const char *sel_JobMedia = "SELECT JobId FROM JobMedia WHERE MediaId=%u";
 
 /* Select JobIds for File deletion. */
 const char *select_job =
-   "SELECT JobId from Job "    
+   "SELECT JobId from Job "
    "WHERE JobTDate<%s "
    "AND ClientId=%u "
    "AND PurgedFiles=0";
@@ -100,11 +100,11 @@ const char *create_deltabs[] = {
 /* Fill candidates table with all Jobs subject to being deleted.
  *  This is used for pruning Jobs (first the files, then the Jobs).
  */
-const char *insert_delcand = 
+const char *insert_delcand =
    "INSERT INTO DelCandidates "
    "SELECT JobId,PurgedFiles,FileSetId,JobFiles,JobStatus FROM Job "
    "WHERE Type='%c' "
-   "AND JobTDate<%s " 
+   "AND JobTDate<%s "
    "AND ClientId=%u";
 
 /* Select Jobs from the DelCandidates table that have a
@@ -149,7 +149,7 @@ const char *select_restore_del =
    "FROM Job,DelCandidates "
    "WHERE (Job.JobTdate<%s AND delCandidates.JobStatus!='T') OR "
    "(Job.JobTDate>%s "
-   "AND Job.ClientId=%u "   
+   "AND Job.ClientId=%u "
    "AND Job.Type='R')";
 
 /* Select Jobs from the DelCandidates table.
@@ -160,7 +160,7 @@ const char *select_admin_del =
    "FROM Job,DelCandidates "
    "WHERE (Job.JobTdate<%s AND delCandidates.JobStatus!='T') OR "
    "(Job.JobTDate>%s "
-   "AND Job.ClientId=%u "   
+   "AND Job.ClientId=%u "
    "AND Job.Type='D')";
 
 
@@ -169,7 +169,7 @@ const char *uar_count_files =
    "SELECT JobFiles FROM Job WHERE JobId=%u";
 
 /* List last 20 Jobs */
-const char *uar_list_jobs = 
+const char *uar_list_jobs =
    "SELECT JobId,Client.Name as Client,StartTime,Level as "
    "JobLevel,JobFiles,JobBytes "
    "FROM Client,Job WHERE Client.ClientId=Job.ClientId AND JobStatus='T' "
@@ -178,7 +178,7 @@ const char *uar_list_jobs =
 #ifdef HAVE_MYSQL
 /*  MYSQL IS NOT STANDARD SQL !!!!! */
 /* List Jobs where a particular file is saved */
-const char *uar_file = 
+const char *uar_file =
    "SELECT Job.JobId as JobId, Client.Name as Client, "
    "CONCAT(Path.Path,Filename.Name) as Name, "
    "StartTime,Type as JobType,JobFiles,JobBytes "
@@ -188,7 +188,7 @@ const char *uar_file =
    "AND Filename.Name='%s' ORDER BY StartTime DESC LIMIT 20";
 #else
 /* List Jobs where a particular file is saved */
-const char *uar_file = 
+const char *uar_file =
    "SELECT Job.JobId as JobId, Client.Name as Client, "
    "Path.Path||Filename.Name as Name, "
    "StartTime,Type as JobType,JobFiles,JobBytes "
@@ -203,7 +203,7 @@ const char *uar_file =
  * Find all files for a particular JobId and insert them into
  *  the tree during a restore.
  */
-const char *uar_sel_files = 
+const char *uar_sel_files =
    "SELECT Path.Path,Filename.Name,FileIndex,JobId,LStat "
    "FROM File,Filename,Path "
    "WHERE File.JobId=%u AND Filename.FilenameId=File.FilenameId "
@@ -212,7 +212,7 @@ const char *uar_sel_files =
 const char *uar_del_temp  = "DROP TABLE temp";
 const char *uar_del_temp1 = "DROP TABLE temp1";
 
-const char *uar_create_temp = 
+const char *uar_create_temp =
    "CREATE TABLE temp ("
 #ifdef HAVE_POSTGRESQL
    "JobId INTEGER NOT NULL,"
@@ -238,7 +238,7 @@ const char *uar_create_temp =
    "VolSessionTime INTEGER UNSIGNED)";
 #endif
 
-const char *uar_create_temp1 = 
+const char *uar_create_temp1 =
    "CREATE TABLE temp1 ("
 #ifdef HAVE_POSTGRESQL
    "JobId INTEGER NOT NULL,"
@@ -261,8 +261,8 @@ const char *uar_last_full =
    "%s"
    "ORDER BY Job.JobTDate DESC LIMIT 1";
 
-const char *uar_full = 
-   "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,"          
+const char *uar_full =
+   "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,"
    " Job.ClientId,Job.Level,Job.JobFiles,"
    " StartTime,VolumeName,JobMedia.StartFile,VolSessionId,VolSessionTime "
    "FROM temp1,Job,JobMedia,Media WHERE temp1.JobId=Job.JobId "
@@ -270,7 +270,7 @@ const char *uar_full =
    "AND JobMedia.JobId=Job.JobId "
    "AND JobMedia.MediaId=Media.MediaId";
 
-const char *uar_dif = 
+const char *uar_dif =
    "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,Job.ClientId,"
    "Job.Level,Job.JobFiles,Job.StartTime,Media.VolumeName,JobMedia.StartFile,"
    "Job.VolSessionId,Job.VolSessionTime "
@@ -282,7 +282,7 @@ const char *uar_dif =
    "AND Job.Level='D' AND JobStatus='T' "
    "AND Job.FileSetId=FileSet.FileSetId "
    "AND FileSet.FileSet='%s' "
-   "%s" 
+   "%s"
    "ORDER BY Job.JobTDate DESC LIMIT 1";
 
 const char *uar_inc =
@@ -299,7 +299,7 @@ const char *uar_inc =
    "AND FileSet.FileSet='%s' "
    "%s";
 
-const char *uar_list_temp = 
+const char *uar_list_temp =
    "SELECT JobId,Level,JobFiles,StartTime,VolumeName,StartFile,"
    "VolSessionId,VolSessionTime FROM temp "
    "ORDER BY StartTime ASC";
@@ -314,7 +314,7 @@ const char *uar_sel_all_temp = "SELECT * FROM temp";
 
 
 /* Select FileSet names for this Client */
-const char *uar_sel_fileset = 
+const char *uar_sel_fileset =
    "SELECT DISTINCT FileSet.FileSet FROM Job,"
    "Client,FileSet WHERE Job.FileSetId=FileSet.FileSetId "
    "AND Job.ClientId=%u AND Client.ClientId=%u "
@@ -325,11 +325,11 @@ const char *uar_mediatype =
    "SELECT MediaType FROM JobMedia,Media WHERE JobMedia.JobId=%u "
    "AND JobMedia.MediaId=Media.MediaId";
 
-/* 
- *  Find JobId, FileIndex for a given path/file and date   
+/*
+ *  Find JobId, FileIndex for a given path/file and date
  *  for use when inserting individual files into the tree.
  */
-const char *uar_jobid_fileindex = 
+const char *uar_jobid_fileindex =
    "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client "
    "WHERE Job.JobId=File.JobId "
    "AND Job.StartTime<'%s' "
@@ -341,7 +341,7 @@ const char *uar_jobid_fileindex =
    "AND Filename.FilenameId=File.FilenameId "
    "ORDER BY Job.StartTime DESC LIMIT 1";
 
-const char *uar_jobids_fileindex = 
+const char *uar_jobids_fileindex =
    "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client "
    "WHERE Job.JobId IN (%s) "
    "AND Job.JobId=File.JobId "
index ac3b02dbea2a8d9e4624d2808b26662fe0e842ca..0c07a1c872c23eec7a8fbeba3de7fc65063b97da 100644 (file)
@@ -51,7 +51,7 @@ struct UAContext {
    bool batch;                        /* set for non-interactive mode */
    uint32_t pint32_val;               /* positive integer */
    int32_t  int32_val;                /* positive/negative */
-};          
+};
 
 /* Context for insert_tree_handler() */
 struct TREE_CTX {
index cb184a0a88253506bc44f4be814e0bf602230afc..ce703940754c9b8e14b4993225c6f1f9b2ef79b6 100644 (file)
@@ -2,7 +2,7 @@
  *
  *   Bacula Director -- User Agent Access Control List (ACL) handling
  *
- *     Kern Sibbald, January MMIV  
+ *     Kern Sibbald, January MMIV
  *
  *   Version  $Id$
  */
@@ -30,8 +30,8 @@
 #include "bacula.h"
 #include "dird.h"
 
-/*  
- * Check if access is permitted to item in acl   
+/*
+ * Check if access is permitted to item in acl
  */
 bool acl_access_ok(UAContext *ua, int acl, char *item)
 {
@@ -61,7 +61,7 @@ bool acl_access_ok(UAContext *ua, int acl, char *item, int len)
    /* Search list for item */
    for (int i=0; i<list->size(); i++) {
       if (strncasecmp(item, (char *)list->get(i), len) == 0) {
-         Dmsg3(400, "Found %s in %d %s\n", item, acl, (char *)list->get(i));
+        Dmsg3(400, "Found %s in %d %s\n", item, acl, (char *)list->get(i));
         return true;
       }
    }
index 3ef87610c32565847455e1c567551d05f1990ee0..3a5b0f03fba1b9569f9a223d6fec16277ad3cd40 100644 (file)
@@ -61,9 +61,9 @@ extern int relabel_cmd(UAContext *ua, const char *cmd);
 extern int update_slots(UAContext *ua);  /* ua_label.c */
 
 /* Forward referenced functions */
-static int add_cmd(UAContext *ua, const char *cmd);  
-static int create_cmd(UAContext *ua, const char *cmd); 
-static int cancel_cmd(UAContext *ua, const char *cmd); 
+static int add_cmd(UAContext *ua, const char *cmd);
+static int create_cmd(UAContext *ua, const char *cmd);
+static int cancel_cmd(UAContext *ua, const char *cmd);
 static int setdebug_cmd(UAContext *ua, const char *cmd);
 static int trace_cmd(UAContext *ua, const char *cmd);
 static int var_cmd(UAContext *ua, const char *cmd);
@@ -94,14 +94,14 @@ int qhelp_cmd(UAContext *ua, const char *cmd);
 int quit_cmd(UAContext *ua, const char *cmd);
 
 
-struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; }; 
+struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; };
 static struct cmdstruct commands[] = {
  { N_("add"),        add_cmd,         _("add media to a pool")},
  { N_("autodisplay"), autodisplay_cmd, _("autodisplay [on/off] -- console messages")},
  { N_("automount"),   automount_cmd,  _("automount [on/off] -- after label")},
  { N_("cancel"),     cancel_cmd,    _("cancel job=nnn -- cancel a job")},
- { N_("create"),     create_cmd,    _("create DB Pool from resource")},  
- { N_("delete"),     delete_cmd,    _("delete [pool=<pool-name> | media volume=<volume-name>]")},    
+ { N_("create"),     create_cmd,    _("create DB Pool from resource")},
+ { N_("delete"),     delete_cmd,    _("delete [pool=<pool-name> | media volume=<volume-name>]")},
  { N_("estimate"),   estimate_cmd,  _("performs FileSet estimate, listing gives full listing")},
  { N_("exit"),       quit_cmd,      _("exit = quit")},
  { N_("gui"),        gui_cmd,       _("gui [on/off] -- non-interactive gui mode")},
@@ -125,7 +125,7 @@ static struct cmdstruct commands[] = {
  { N_("setdebug"),   setdebug_cmd,  _("sets debug level")},
  { N_("setip"),      setip_cmd,     _("sets new client address -- if authorized")},
  { N_("show"),       show_cmd,      _("show (resource records) [jobs | pools | ... | all]")},
- { N_("sqlquery"),   sqlquerycmd,   _("use SQL to query catalog")}, 
+ { N_("sqlquery"),   sqlquerycmd,   _("use SQL to query catalog")},
  { N_("time"),       time_cmd,      _("print current time")},
  { N_("trace"),      trace_cmd,     _("turn on/off trace to file")},
  { N_("unmount"),    unmount_cmd,   _("unmount <storage-name>")},
@@ -173,7 +173,7 @@ int do_a_command(UAContext *ua, const char *cmd)
 
 /*
  * This is a common routine used to stuff the Pool DB record defaults
- *   into the Media DB record just before creating a media (Volume) 
+ *   into the Media DB record just before creating a media (Volume)
  *   record.
  */
 void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr)
@@ -192,7 +192,7 @@ void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr)
 /*
  *  Add Volumes to an existing Pool
  */
-static int add_cmd(UAContext *ua, const char *cmd) 
+static int add_cmd(UAContext *ua, const char *cmd)
 {
    POOL_DBR pr;
    MEDIA_DBR mr;
@@ -224,7 +224,7 @@ static int add_cmd(UAContext *ua, const char *cmd)
    while (pr.MaxVols > 0 && pr.NumVols >= pr.MaxVols) {
       bsendmsg(ua, _("Pool already has maximum volumes = %d\n"), pr.MaxVols);
       for (;;) {
-         if (!get_pint(ua, _("Enter new maximum (zero for unlimited): "))) {
+        if (!get_pint(ua, _("Enter new maximum (zero for unlimited): "))) {
            return 1;
         }
         pr.MaxVols = ua->pint32_val;
@@ -237,21 +237,21 @@ static int add_cmd(UAContext *ua, const char *cmd)
    } else if (!get_media_type(ua, mr.MediaType, sizeof(mr.MediaType))) {
       return 1;
    }
-      
+
    if (pr.MaxVols == 0) {
       max = 1000;
    } else {
       max = pr.MaxVols - pr.NumVols;
    }
    for (;;) {
-      char buf[100]; 
+      char buf[100];
       bsnprintf(buf, sizeof(buf), _("Enter number of Volumes to create. 0=>fixed name. Max=%d: "), max);
       if (!get_pint(ua, buf)) {
         return 1;
       }
       num = ua->pint32_val;
       if (num < 0 || num > max) {
-         bsendmsg(ua, _("The number must be between 0 and %d\n"), max);
+        bsendmsg(ua, _("The number must be between 0 and %d\n"), max);
         continue;
       }
       break;
@@ -284,12 +284,12 @@ getVolName:
       strcat(name, "%04d");
 
       for (;;) {
-         if (!get_pint(ua, _("Enter the starting number: "))) {
+        if (!get_pint(ua, _("Enter the starting number: "))) {
            return 1;
         }
         startnum = ua->pint32_val;
         if (startnum < 1) {
-            bsendmsg(ua, _("Start number must be greater than zero.\n"));
+           bsendmsg(ua, _("Start number must be greater than zero.\n"));
            continue;
         }
         break;
@@ -309,15 +309,15 @@ getVolName:
       }
       InChanger = ua->pint32_val;
    }
-          
+
    set_pool_dbr_defaults_in_media_dbr(&mr, &pr);
-   for (i=startnum; i < num+startnum; i++) { 
+   for (i=startnum; i < num+startnum; i++) {
       bsnprintf(mr.VolumeName, sizeof(mr.VolumeName), name, i);
       mr.Slot = Slot++;
       mr.InChanger = InChanger;
       Dmsg1(200, "Create Volume %s\n", mr.VolumeName);
       if (!db_create_media_record(ua->jcr, ua->db, &mr)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
         return 1;
       }
       if (i == startnum) {
@@ -325,7 +325,7 @@ getVolName:
       }
    }
    pr.NumVols += num;
-   Dmsg0(200, "Update pool record.\n"); 
+   Dmsg0(200, "Update pool record.\n");
    if (db_update_pool_record(ua->jcr, ua->db, &pr) != 1) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
       return 1;
@@ -336,9 +336,9 @@ getVolName:
 }
 
 /*
- * Turn auto mount on/off  
- * 
- *  automount on 
+ * Turn auto mount on/off
+ *
+ *  automount on
  *  automount off
  */
 int automount_cmd(UAContext *ua, const char *cmd)
@@ -355,7 +355,7 @@ int automount_cmd(UAContext *ua, const char *cmd)
    }
 
    ua->automount = (strcasecmp(onoff, _("off")) == 0) ? 0 : 1;
-   return 1; 
+   return 1;
 }
 
 
@@ -381,7 +381,7 @@ static int cancel_cmd(UAContext *ua, const char *cmd)
         }
         JobId = str_to_int64(ua->argv[i]);
         if (!(jcr=get_jcr_by_id(JobId))) {
-            bsendmsg(ua, _("JobId %d is not running.\n"),  JobId);
+           bsendmsg(ua, _("JobId %d is not running.\n"),  JobId);
            return 1;
         }
         break;
@@ -390,7 +390,7 @@ static int cancel_cmd(UAContext *ua, const char *cmd)
            break;
         }
         if (!(jcr=get_jcr_by_partial_name(ua->argv[i]))) {
-            bsendmsg(ua, _("Job %s is not running.\n"), ua->argv[i]);
+           bsendmsg(ua, _("Job %s is not running.\n"), ua->argv[i]);
            return 1;
         }
         break;
@@ -413,7 +413,7 @@ static int cancel_cmd(UAContext *ua, const char *cmd)
       unlock_jcr_chain();
 
       if (njobs == 0) {
-         bsendmsg(ua, _("No Jobs running.\n"));
+        bsendmsg(ua, _("No Jobs running.\n"));
         return 1;
       }
       start_prompt(ua, _("Select Job:\n"));
@@ -432,14 +432,14 @@ static int cancel_cmd(UAContext *ua, const char *cmd)
         return 1;
       }
       if (njobs == 1) {
-         if (!get_yesno(ua, _("Confirm cancel (yes/no): ")) || ua->pint32_val == 0) {
+        if (!get_yesno(ua, _("Confirm cancel (yes/no): ")) || ua->pint32_val == 0) {
            return 1;
         }
       }
       /* NOTE! This increments the ref_count */
       jcr = get_jcr_by_full_name(JobName);
       if (!jcr) {
-         bsendmsg(ua, _("Job %s not found.\n"), JobName);
+        bsendmsg(ua, _("Job %s not found.\n"), JobName);
         return 1;
       }
    }
@@ -529,7 +529,7 @@ int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op)
  * Create a Pool Record in the database.
  *  It is always created from the Resource record.
  */
-static int create_cmd(UAContext *ua, const char *cmd) 
+static int create_cmd(UAContext *ua, const char *cmd)
 {
    POOL *pool;
 
@@ -545,7 +545,7 @@ static int create_cmd(UAContext *ua, const char *cmd)
    switch (create_pool(ua->jcr, ua->db, pool, POOL_OP_CREATE)) {
    case 0:
       bsendmsg(ua, _("Error: Pool %s already exists.\n"
-               "Use update to change it.\n"), pool->hdr.name);
+              "Use update to change it.\n"), pool->hdr.name);
       break;
 
    case -1:
@@ -571,7 +571,7 @@ static int python_cmd(UAContext *ua, const char *cmd)
    if (strcasecmp(ua->argk[1], _("restart")) == 0) {
       term_python_interpreter();
       init_python_interpreter(director->hdr.name, director->scripts_directory ?
-         director->scripts_directory : ".");
+        director->scripts_directory : ".");
       bsendmsg(ua, _("Python interpreter restarted.\n"));
    } else {
       bsendmsg(ua, _("Nothing done.\n"));
@@ -582,13 +582,13 @@ static int python_cmd(UAContext *ua, const char *cmd)
 
 /*
  * Set a new address in a Client resource. We do this only
- *  if the Console name is the same as the Client name 
+ *  if the Console name is the same as the Client name
  *  and the Console can access the client.
  */
-static int setip_cmd(UAContext *ua, const char *cmd) 
+static int setip_cmd(UAContext *ua, const char *cmd)
 {
    CLIENT *client;
-   char buf[1024]; 
+   char buf[1024];
    if (!ua->cons || !acl_access_ok(ua, Client_ACL, ua->cons->hdr.name)) {
       bsendmsg(ua, _("Illegal command from this console.\n"));
       return 1;
@@ -604,7 +604,7 @@ static int setip_cmd(UAContext *ua, const char *cmd)
       free(client->address);
    }
    /* MA Bug 6 remove ifdef */
-   sockaddr_to_ascii(&(ua->UA_sock->client_addr), buf, sizeof(buf)); 
+   sockaddr_to_ascii(&(ua->UA_sock->client_addr), buf, sizeof(buf));
    client->address = bstrdup(buf);
    bsendmsg(ua, _("Client \"%s\" address set to %s\n"),
            client->hdr.name, client->address);
@@ -625,7 +625,7 @@ get_out:
  *    update slots [scan=...]
  *        updates autochanger slots
  */
-static int update_cmd(UAContext *ua, const char *cmd) 
+static int update_cmd(UAContext *ua, const char *cmd)
 {
    static const char *kw[] = {
       N_("media"),  /* 0 */
@@ -652,7 +652,7 @@ static int update_cmd(UAContext *ua, const char *cmd)
    default:
       break;
    }
-    
+
    start_prompt(ua, _("Update choice:\n"));
    add_prompt(ua, _("Volume parameters"));
    add_prompt(ua, _("Pool from resource"));
@@ -681,8 +681,8 @@ static void update_volstatus(UAContext *ua, const char *val, MEDIA_DBR *mr)
       "Archive",
       "Disabled",
       "Full",
-      "Used", 
-      "Cleaning", 
+      "Used",
+      "Cleaning",
       "Recycle",
       "Read-Only",
       NULL};
@@ -701,10 +701,10 @@ static void update_volstatus(UAContext *ua, const char *val, MEDIA_DBR *mr)
       bstrncpy(mr->VolStatus, kw[i], sizeof(mr->VolStatus));
       Mmsg(query, "UPDATE Media SET VolStatus='%s' WHERE MediaId=%u",
         mr->VolStatus, mr->MediaId);
-      if (!db_sql_query(ua->db, query, NULL, NULL)) {  
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+      if (!db_sql_query(ua->db, query, NULL, NULL)) {
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       } else {
-         bsendmsg(ua, _("New Volume status is: %s\n"), mr->VolStatus);
+        bsendmsg(ua, _("New Volume status is: %s\n"), mr->VolStatus);
       }
    }
    free_pool_memory(query);
@@ -721,7 +721,7 @@ static void update_volretention(UAContext *ua, char *val, MEDIA_DBR *mr)
    query = get_pool_memory(PM_MESSAGE);
    Mmsg(query, "UPDATE Media SET VolRetention=%s WHERE MediaId=%u",
       edit_uint64(mr->VolRetention, ed1), mr->MediaId);
-   if (!db_sql_query(ua->db, query, NULL, NULL)) {  
+   if (!db_sql_query(ua->db, query, NULL, NULL)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
    } else {
       bsendmsg(ua, _("New retention period is: %s\n"),
@@ -742,7 +742,7 @@ static void update_voluseduration(UAContext *ua, char *val, MEDIA_DBR *mr)
    query = get_pool_memory(PM_MESSAGE);
    Mmsg(query, "UPDATE Media SET VolUseDuration=%s WHERE MediaId=%u",
       edit_uint64(mr->VolUseDuration, ed1), mr->MediaId);
-   if (!db_sql_query(ua->db, query, NULL, NULL)) {  
+   if (!db_sql_query(ua->db, query, NULL, NULL)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
    } else {
       bsendmsg(ua, _("New use duration is: %s\n"),
@@ -756,7 +756,7 @@ static void update_volmaxjobs(UAContext *ua, char *val, MEDIA_DBR *mr)
    POOLMEM *query = get_pool_memory(PM_MESSAGE);
    Mmsg(query, "UPDATE Media SET MaxVolJobs=%s WHERE MediaId=%u",
       val, mr->MediaId);
-   if (!db_sql_query(ua->db, query, NULL, NULL)) {  
+   if (!db_sql_query(ua->db, query, NULL, NULL)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
    } else {
       bsendmsg(ua, _("New max jobs is: %s\n"), val);
@@ -769,7 +769,7 @@ static void update_volmaxfiles(UAContext *ua, char *val, MEDIA_DBR *mr)
    POOLMEM *query = get_pool_memory(PM_MESSAGE);
    Mmsg(query, "UPDATE Media SET MaxVolFiles=%s WHERE MediaId=%u",
       val, mr->MediaId);
-   if (!db_sql_query(ua->db, query, NULL, NULL)) {  
+   if (!db_sql_query(ua->db, query, NULL, NULL)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
    } else {
       bsendmsg(ua, _("New max files is: %s\n"), val);
@@ -786,11 +786,11 @@ static void update_volmaxbytes(UAContext *ua, char *val, MEDIA_DBR *mr)
    if (!size_to_uint64(val, strlen(val), &maxbytes)) {
       bsendmsg(ua, _("Invalid max. bytes specification: %s\n"), val);
       return;
-   } 
+   }
    query = get_pool_memory(PM_MESSAGE);
    Mmsg(query, "UPDATE Media SET MaxVolBytes=%s WHERE MediaId=%u",
       edit_uint64(maxbytes, ed1), mr->MediaId);
-   if (!db_sql_query(ua->db, query, NULL, NULL)) {  
+   if (!db_sql_query(ua->db, query, NULL, NULL)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
    } else {
       bsendmsg(ua, _("New Max bytes is: %s\n"), edit_uint64(maxbytes, ed1));
@@ -813,11 +813,11 @@ static void update_volrecycle(UAContext *ua, char *val, MEDIA_DBR *mr)
    query = get_pool_memory(PM_MESSAGE);
    Mmsg(query, "UPDATE Media SET Recycle=%d WHERE MediaId=%u",
       recycle, mr->MediaId);
-   if (!db_sql_query(ua->db, query, NULL, NULL)) {  
+   if (!db_sql_query(ua->db, query, NULL, NULL)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
-   } else {      
+   } else {
       bsendmsg(ua, _("New Recycle flag is: %s\n"),
-         mr->Recycle==1?_("yes"):_("no"));
+        mr->Recycle==1?_("yes"):_("no"));
    }
    free_pool_memory(query);
 }
@@ -840,17 +840,17 @@ static void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *o
    db_lock(ua->db);
    Mmsg(query, "UPDATE Media SET PoolId=%d WHERE MediaId=%u",
       mr->PoolId, mr->MediaId);
-   if (!db_sql_query(ua->db, query, NULL, NULL)) {  
+   if (!db_sql_query(ua->db, query, NULL, NULL)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
-   } else {      
+   } else {
       bsendmsg(ua, _("New Pool is: %s\n"), pr.Name);
       opr->NumVols--;
       if (!db_update_pool_record(ua->jcr, ua->db, opr)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       pr.NumVols++;
       if (!db_update_pool_record(ua->jcr, ua->db, &pr)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       db_make_inchanger_unique(ua->jcr, ua->db, mr);
    }
@@ -909,7 +909,7 @@ static void update_all_vols_from_pool(UAContext *ua)
  *  Volume status. E.g. if you want Bacula to stop
  *  writing on the volume, set it to anything other
  *  than Append.
- */             
+ */
 static int update_volume(UAContext *ua)
 {
    MEDIA_DBR mr;
@@ -963,7 +963,7 @@ static int update_volume(UAContext *ua)
            memset(&pr, 0, sizeof(POOL_DBR));
            pr.PoolId = mr.PoolId;
            if (!db_get_pool_record(ua->jcr, ua->db, &pr)) {
-               bsendmsg(ua, "%s", db_strerror(ua->db));
+              bsendmsg(ua, "%s", db_strerror(ua->db));
               break;
            }
            update_vol_pool(ua, ua->argv[j], &mr, &pr);
@@ -1002,60 +1002,60 @@ static int update_volume(UAContext *ua)
       switch (do_prompt(ua, "", _("Select parameter to modify"), NULL, 0)) {
       case 0:                        /* Volume Status */
         /* Modify Volume Status */
-         bsendmsg(ua, _("Current Volume status is: %s\n"), mr.VolStatus);
-         start_prompt(ua, _("Possible Values are:\n"));
-         add_prompt(ua, "Append");      /* Better not translate these as */
-         add_prompt(ua, "Archive");     /* They are known in the database code */
-         add_prompt(ua, "Disabled");
-         add_prompt(ua, "Full");
-         add_prompt(ua, "Used");
-         add_prompt(ua, "Cleaning");
-         if (strcmp(mr.VolStatus, "Purged") == 0) {
-            add_prompt(ua, "Recycle");
+        bsendmsg(ua, _("Current Volume status is: %s\n"), mr.VolStatus);
+        start_prompt(ua, _("Possible Values are:\n"));
+        add_prompt(ua, "Append");      /* Better not translate these as */
+        add_prompt(ua, "Archive");     /* They are known in the database code */
+        add_prompt(ua, "Disabled");
+        add_prompt(ua, "Full");
+        add_prompt(ua, "Used");
+        add_prompt(ua, "Cleaning");
+        if (strcmp(mr.VolStatus, "Purged") == 0) {
+           add_prompt(ua, "Recycle");
         }
-         add_prompt(ua, "Read-Only");
-         if (do_prompt(ua, "", _("Choose new Volume Status"), ua->cmd, sizeof(mr.VolStatus)) < 0) {
+        add_prompt(ua, "Read-Only");
+        if (do_prompt(ua, "", _("Choose new Volume Status"), ua->cmd, sizeof(mr.VolStatus)) < 0) {
            return 1;
         }
         update_volstatus(ua, ua->cmd, &mr);
         break;
       case 1:                        /* Retention */
-         bsendmsg(ua, _("Current retention period is: %s\n"),
+        bsendmsg(ua, _("Current retention period is: %s\n"),
            edit_utime(mr.VolRetention, ed1, sizeof(ed1)));
-         if (!get_cmd(ua, _("Enter Volume Retention period: "))) {
+        if (!get_cmd(ua, _("Enter Volume Retention period: "))) {
            return 0;
         }
         update_volretention(ua, ua->cmd, &mr);
         break;
 
       case 2:                        /* Use Duration */
-         bsendmsg(ua, _("Current use duration is: %s\n"),
+        bsendmsg(ua, _("Current use duration is: %s\n"),
            edit_utime(mr.VolUseDuration, ed1, sizeof(ed1)));
-         if (!get_cmd(ua, _("Enter Volume Use Duration: "))) {
+        if (!get_cmd(ua, _("Enter Volume Use Duration: "))) {
            return 0;
         }
         update_voluseduration(ua, ua->cmd, &mr);
         break;
 
       case 3:                        /* Max Jobs */
-         bsendmsg(ua, _("Current max jobs is: %u\n"), mr.MaxVolJobs);
-         if (!get_pint(ua, _("Enter new Maximum Jobs: "))) {
+        bsendmsg(ua, _("Current max jobs is: %u\n"), mr.MaxVolJobs);
+        if (!get_pint(ua, _("Enter new Maximum Jobs: "))) {
            return 0;
         }
         update_volmaxjobs(ua, ua->cmd, &mr);
         break;
 
       case 4:                        /* Max Files */
-         bsendmsg(ua, _("Current max files is: %u\n"), mr.MaxVolFiles);
-         if (!get_pint(ua, _("Enter new Maximum Files: "))) {
+        bsendmsg(ua, _("Current max files is: %u\n"), mr.MaxVolFiles);
+        if (!get_pint(ua, _("Enter new Maximum Files: "))) {
            return 0;
         }
         update_volmaxfiles(ua, ua->cmd, &mr);
         break;
 
       case 5:                        /* Max Bytes */
-         bsendmsg(ua, _("Current value is: %s\n"), edit_uint64(mr.MaxVolBytes, ed1));
-         if (!get_cmd(ua, _("Enter new Maximum Bytes: "))) {
+        bsendmsg(ua, _("Current value is: %s\n"), edit_uint64(mr.MaxVolBytes, ed1));
+        if (!get_cmd(ua, _("Enter new Maximum Bytes: "))) {
            return 0;
         }
         update_volmaxbytes(ua, ua->cmd, &mr);
@@ -1063,9 +1063,9 @@ static int update_volume(UAContext *ua)
 
 
       case 6:                        /* Recycle */
-         bsendmsg(ua, _("Current recycle flag is: %s\n"),
-            mr.Recycle==1?_("yes"):_("no"));
-         if (!get_yesno(ua, _("Enter new Recycle status: "))) {
+        bsendmsg(ua, _("Current recycle flag is: %s\n"),
+           mr.Recycle==1?_("yes"):_("no"));
+        if (!get_yesno(ua, _("Enter new Recycle status: "))) {
            return 0;
         }
         update_volrecycle(ua, ua->cmd, &mr);
@@ -1077,71 +1077,71 @@ static int update_volume(UAContext *ua)
         memset(&pr, 0, sizeof(POOL_DBR));
         pr.PoolId = mr.PoolId;
         if (!db_get_pool_record(ua->jcr, ua->db, &pr)) {
-            bsendmsg(ua, "%s", db_strerror(ua->db));
+           bsendmsg(ua, "%s", db_strerror(ua->db));
            return 0;
         }
-         bsendmsg(ua, _("Current Slot is: %d\n"), mr.Slot);
-         if (!get_pint(ua, _("Enter new Slot: "))) {
+        bsendmsg(ua, _("Current Slot is: %d\n"), mr.Slot);
+        if (!get_pint(ua, _("Enter new Slot: "))) {
            return 0;
         }
         Slot = ua->pint32_val;
         if (pr.MaxVols > 0 && Slot > (int)pr.MaxVols) {
-            bsendmsg(ua, _("Invalid slot, it must be between 0 and %d\n"),
+           bsendmsg(ua, _("Invalid slot, it must be between 0 and %d\n"),
               pr.MaxVols);
            break;
         }
         mr.Slot = Slot;
         /*
          * Make sure to use db_update... rather than doing this directly,
-         *   so that any Slot is handled correctly. 
+         *   so that any Slot is handled correctly.
          */
         if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
-            bsendmsg(ua, _("Error updating media record Slot: ERR=%s"), db_strerror(ua->db));
+           bsendmsg(ua, _("Error updating media record Slot: ERR=%s"), db_strerror(ua->db));
         } else {
-            bsendmsg(ua, _("New Slot is: %d\n"), mr.Slot);
+           bsendmsg(ua, _("New Slot is: %d\n"), mr.Slot);
         }
         break;
 
       case 8:                        /* InChanger */
-         bsendmsg(ua, _("Current InChanger flag is: %d\n"), mr.InChanger);
-         if (!get_yesno(ua, _("Set InChanger flag? yes/no: "))) {
+        bsendmsg(ua, _("Current InChanger flag is: %d\n"), mr.InChanger);
+        if (!get_yesno(ua, _("Set InChanger flag? yes/no: "))) {
            return 0;
         }
         mr.InChanger = ua->pint32_val;
         /*
          * Make sure to use db_update... rather than doing this directly,
-         *   so that any Slot is handled correctly. 
+         *   so that any Slot is handled correctly.
          */
         if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
-            bsendmsg(ua, _("Error updating media record Slot: ERR=%s"), db_strerror(ua->db));
+           bsendmsg(ua, _("Error updating media record Slot: ERR=%s"), db_strerror(ua->db));
         } else {
-            bsendmsg(ua, _("New InChanger flag is: %d\n"), mr.InChanger);
+           bsendmsg(ua, _("New InChanger flag is: %d\n"), mr.InChanger);
         }
         break;
 
 
       case 9:                        /* Volume Files */
         int32_t VolFiles;
-         bsendmsg(ua, _("Warning changing Volume Files can result\n"
-                        "in loss of data on your Volume\n\n"));
-         bsendmsg(ua, _("Current Volume Files is: %u\n"), mr.VolFiles);
-         if (!get_pint(ua, _("Enter new number of Files for Volume: "))) {
+        bsendmsg(ua, _("Warning changing Volume Files can result\n"
+                       "in loss of data on your Volume\n\n"));
+        bsendmsg(ua, _("Current Volume Files is: %u\n"), mr.VolFiles);
+        if (!get_pint(ua, _("Enter new number of Files for Volume: "))) {
            return 0;
         }
         VolFiles = ua->pint32_val;
         if (VolFiles != (int)(mr.VolFiles + 1)) {
-            bsendmsg(ua, _("Normally, you should only increase Volume Files by one!\n"));
-            if (!get_yesno(ua, _("Continue? (yes/no): ")) || ua->pint32_val == 0) {
+           bsendmsg(ua, _("Normally, you should only increase Volume Files by one!\n"));
+           if (!get_yesno(ua, _("Continue? (yes/no): ")) || ua->pint32_val == 0) {
               break;
            }
         }
         query = get_pool_memory(PM_MESSAGE);
-         Mmsg(query, "UPDATE Media SET VolFiles=%u WHERE MediaId=%u",
+        Mmsg(query, "UPDATE Media SET VolFiles=%u WHERE MediaId=%u",
            VolFiles, mr.MediaId);
-        if (!db_sql_query(ua->db, query, NULL, NULL)) {  
-            bsendmsg(ua, "%s", db_strerror(ua->db));
+        if (!db_sql_query(ua->db, query, NULL, NULL)) {
+           bsendmsg(ua, "%s", db_strerror(ua->db));
         } else {
-            bsendmsg(ua, _("New Volume Files is: %u\n"), VolFiles);
+           bsendmsg(ua, _("New Volume Files is: %u\n"), VolFiles);
         }
         free_pool_memory(query);
         break;
@@ -1150,11 +1150,11 @@ static int update_volume(UAContext *ua)
         memset(&pr, 0, sizeof(POOL_DBR));
         pr.PoolId = mr.PoolId;
         if (!db_get_pool_record(ua->jcr, ua->db, &pr)) {
-            bsendmsg(ua, "%s", db_strerror(ua->db));
+           bsendmsg(ua, "%s", db_strerror(ua->db));
            return 0;
         }
-         bsendmsg(ua, _("Current Pool is: %s\n"), pr.Name);
-         if (!get_cmd(ua, _("Enter new Pool name: "))) {
+        bsendmsg(ua, _("Current Pool is: %s\n"), pr.Name);
+        if (!get_cmd(ua, _("Enter new Pool name: "))) {
            return 0;
         }
         update_vol_pool(ua, ua->cmd, &mr, &pr);
@@ -1167,14 +1167,14 @@ static int update_volume(UAContext *ua)
         update_all_vols_from_pool(ua);
         return 1;
       default:                       /* Done or error */
-         bsendmsg(ua, "Selection done.\n");
+        bsendmsg(ua, "Selection done.\n");
         return 1;
       }
    }
    return 1;
 }
 
-/* 
+/*
  * Update pool record -- pull info from current POOL resource
  */
 static int update_pool(UAContext *ua)
@@ -1182,8 +1182,8 @@ static int update_pool(UAContext *ua)
    POOL_DBR  pr;
    int id;
    POOL *pool;
-   POOLMEM *query;      
-   
+   POOLMEM *query;
+
    pool = get_pool_resource(ua);
    if (!pool) {
       return 0;
@@ -1218,7 +1218,7 @@ static void do_storage_setdebug(UAContext *ua, STORE *store, int level, int trac
 
    set_storage(jcr, store);
    /* Try connecting for up to 15 seconds */
-   bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), 
+   bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"),
       store->hdr.name, store->address, store->SDport);
    if (!connect_to_storage_daemon(jcr, 1, 15, 0)) {
       bsendmsg(ua, _("Failed to connect to Storage daemon.\n"));
@@ -1233,9 +1233,9 @@ static void do_storage_setdebug(UAContext *ua, STORE *store, int level, int trac
    bnet_sig(sd, BNET_TERMINATE);
    bnet_close(sd);
    jcr->store_bsock = NULL;
-   return;  
+   return;
 }
-   
+
 static void do_client_setdebug(UAContext *ua, CLIENT *client, int level, int trace_flag)
 {
    BSOCK *fd;
@@ -1244,7 +1244,7 @@ static void do_client_setdebug(UAContext *ua, CLIENT *client, int level, int tra
 
    ua->jcr->client = client;
    /* Try to connect for 15 seconds */
-   bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"), 
+   bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"),
       client->hdr.name, client->address, client->FDport);
    if (!connect_to_file_daemon(ua->jcr, 1, 15, 0)) {
       bsendmsg(ua, _("Failed to connect to Client.\n"));
@@ -1259,7 +1259,7 @@ static void do_client_setdebug(UAContext *ua, CLIENT *client, int level, int tra
    bnet_sig(fd, BNET_TERMINATE);
    bnet_close(fd);
    ua->jcr->file_bsock = NULL;
-   return;  
+   return;
 }
 
 
@@ -1280,7 +1280,7 @@ static void do_all_setdebug(UAContext *ua, int level, int trace_flag)
       i++;
    }
    unique_store = (STORE **) malloc(i * sizeof(STORE));
-   /* Find Unique Storage address/port */        
+   /* Find Unique Storage address/port */
    store = (STORE *)GetNextRes(R_STORAGE, NULL);
    i = 0;
    unique_store[i++] = store;
@@ -1295,7 +1295,7 @@ static void do_all_setdebug(UAContext *ua, int level, int trace_flag)
       }
       if (!found) {
         unique_store[i++] = store;
-         Dmsg2(140, "Stuffing: %s:%d\n", store->address, store->SDport);
+        Dmsg2(140, "Stuffing: %s:%d\n", store->address, store->SDport);
       }
    }
    UnlockRes();
@@ -1314,7 +1314,7 @@ static void do_all_setdebug(UAContext *ua, int level, int trace_flag)
       i++;
    }
    unique_client = (CLIENT **) malloc(i * sizeof(CLIENT));
-   /* Find Unique Client address/port */        
+   /* Find Unique Client address/port */
    client = (CLIENT *)GetNextRes(R_CLIENT, NULL);
    i = 0;
    unique_client[i++] = client;
@@ -1329,7 +1329,7 @@ static void do_all_setdebug(UAContext *ua, int level, int trace_flag)
       }
       if (!found) {
         unique_client[i++] = client;
-         Dmsg2(140, "Stuffing: %s:%d\n", client->address, client->FDport);
+        Dmsg2(140, "Stuffing: %s:%d\n", client->address, client->FDport);
       }
    }
    UnlockRes();
@@ -1385,13 +1385,13 @@ static int setdebug_cmd(UAContext *ua, const char *cmd)
         return 1;
       }
       if (strcasecmp(ua->argk[i], _("dir")) == 0 ||
-          strcasecmp(ua->argk[i], _("director")) == 0) {
+         strcasecmp(ua->argk[i], _("director")) == 0) {
         debug_level = level;
         set_trace(trace_flag);
         return 1;
       }
       if (strcasecmp(ua->argk[i], _("client")) == 0 ||
-          strcasecmp(ua->argk[i], _("fd")) == 0) {
+         strcasecmp(ua->argk[i], _("fd")) == 0) {
         client = NULL;
         if (ua->argv[i]) {
            client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
@@ -1400,7 +1400,7 @@ static int setdebug_cmd(UAContext *ua, const char *cmd)
               return 1;
            }
         }
-        client = select_client_resource(ua);   
+        client = select_client_resource(ua);
         if (client) {
            do_client_setdebug(ua, client, level, trace_flag);
            return 1;
@@ -1408,8 +1408,8 @@ static int setdebug_cmd(UAContext *ua, const char *cmd)
       }
 
       if (strcasecmp(ua->argk[i], _("store")) == 0 ||
-          strcasecmp(ua->argk[i], _("storage")) == 0 ||
-          strcasecmp(ua->argk[i], _("sd")) == 0) {
+         strcasecmp(ua->argk[i], _("storage")) == 0 ||
+         strcasecmp(ua->argk[i], _("sd")) == 0) {
         store = NULL;
         if (ua->argv[i]) {
            store = (STORE *)GetResWithName(R_STORAGE, ua->argv[i]);
@@ -1424,7 +1424,7 @@ static int setdebug_cmd(UAContext *ua, const char *cmd)
            return 1;
         }
       }
-   } 
+   }
    /*
     * We didn't find an appropriate keyword above, so
     * prompt the user.
@@ -1477,7 +1477,7 @@ static int trace_cmd(UAContext *ua, const char *cmd)
    }
 
    set_trace((strcasecmp(onoff, _("off")) == 0) ? false : true);
-   return 1; 
+   return 1;
 
 }
 
@@ -1496,7 +1496,7 @@ static int var_cmd(UAContext *ua, const char *cmd)
       var++;
    }
    Dmsg1(100, "Var=%s:\n", var);
-   variable_expansion(ua->jcr, var, &val);  
+   variable_expansion(ua->jcr, var, &val);
    bsendmsg(ua, "%s\n", val);
    free_pool_memory(val);
    return 1;
@@ -1515,7 +1515,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd)
    jcr->JobLevel = L_FULL;
    for (int i=1; i<ua->argc; i++) {
       if (strcasecmp(ua->argk[i], _("client")) == 0 ||
-          strcasecmp(ua->argk[i], _("fd")) == 0) {
+         strcasecmp(ua->argk[i], _("fd")) == 0) {
         if (ua->argv[i]) {
            client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
            continue;
@@ -1539,11 +1539,11 @@ static int estimate_cmd(UAContext *ua, const char *cmd)
       }
       if (strcasecmp(ua->argk[i], _("level")) == 0) {
         if (!get_level_from_name(ua->jcr, ua->argv[i])) {
-            bsendmsg(ua, _("Level %s not valid.\n"), ua->argv[i]);
+           bsendmsg(ua, _("Level %s not valid.\n"), ua->argv[i]);
         }
         continue;
       }
-   } 
+   }
    if (!job && !(client && fileset)) {
       if (!(job = select_job_resource(ua))) {
         return 1;
@@ -1552,7 +1552,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd)
    if (!job) {
       job = (JOB *)GetResWithName(R_JOB, ua->argk[1]);
       if (!job) {
-         bsendmsg(ua, _("No job specified.\n"));
+        bsendmsg(ua, _("No job specified.\n"));
         return 1;
       }
    }
@@ -1581,7 +1581,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd)
    if (!get_or_create_fileset_record(jcr, &fsr)) {
       return 1;
    }
-   
+
    get_level_since_time(ua->jcr, since, sizeof(since));
 
    bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"),
@@ -1641,7 +1641,7 @@ extern "C" void reload_config(int sig);
 
 static int reload_cmd(UAContext *ua, const char *cmd)
 {
-   reload_config(1);   
+   reload_config(1);
    return 1;
 }
 
@@ -1665,9 +1665,9 @@ static int delete_cmd(UAContext *ua, const char *cmd)
       return 1;
    }
 
-   switch (find_arg_keyword(ua, keywords)) {     
+   switch (find_arg_keyword(ua, keywords)) {
    case 0:
-      delete_volume(ua);     
+      delete_volume(ua);
       return 1;
    case 1:
       delete_pool(ua);
@@ -1710,7 +1710,7 @@ static int delete_cmd(UAContext *ua, const char *cmd)
  * delete_job has been modified to parse JobID lists like the
  * following:
  * delete job JobID=3,4,6,7-11,14
- * 
+ *
  * Thanks to Phil Stracchino for the above addition.
  */
 
@@ -1725,32 +1725,32 @@ static void delete_job(UAContext *ua)
        s = bstrdup(ua->argv[i]);
        tok = s;
        /*
-         * We could use strtok() here.  But we're not going to, because:
+        * We could use strtok() here.  But we're not going to, because:
         * (a) strtok() is deprecated, having been replaced by strsep();
         * (b) strtok() is broken in significant ways.
-         * we could use strsep() instead, but it's not universally available.
+        * we could use strsep() instead, but it's not universally available.
         * so we grow our own using strchr().
         */
-        sep = strchr(tok, ',');
+       sep = strchr(tok, ',');
        while (sep != NULL) {
-           *sep = '\0';
-           if (strchr(tok, '-')) {
+          *sep = '\0';
+          if (strchr(tok, '-')) {
               delete_job_id_range(ua, tok);
           } else {
              JobId = str_to_int64(tok);
              do_job_delete(ua, JobId);
           }
           tok = ++sep;
-           sep = strchr(tok, ',');
+          sep = strchr(tok, ',');
        }
        /* pick up the last token */
-        if (strchr(tok, '-')) {
+       if (strchr(tok, '-')) {
            delete_job_id_range(ua, tok);
        } else {
            JobId = str_to_int64(tok);
            do_job_delete(ua, JobId);
        }
-       
+
         free(s);
       } else {
         JobId = str_to_int64(ua->argv[i]);
@@ -1802,7 +1802,7 @@ static void do_job_delete(UAContext *ua, JobId_t JobId)
 }
 
 /*
- * Delete media records from database -- dangerous 
+ * Delete media records from database -- dangerous
  */
 static int delete_volume(UAContext *ua)
 {
@@ -1825,12 +1825,12 @@ static int delete_volume(UAContext *ua)
 }
 
 /*
- * Delete a pool record from the database -- dangerous  
+ * Delete a pool record from the database -- dangerous
  */
 static int delete_pool(UAContext *ua)
 {
    POOL_DBR  pr;
-   
+
    memset(&pr, 0, sizeof(pr));
 
    if (!get_pool_dbr(ua, &pr)) {
@@ -1937,16 +1937,16 @@ static int use_cmd(UAContext *ua, const char *cmd)
    return 1;
 }
 
-int quit_cmd(UAContext *ua, const char *cmd) 
+int quit_cmd(UAContext *ua, const char *cmd)
 {
    ua->quit = TRUE;
    return 1;
 }
 
 /*
- * Wait until no job is running 
+ * Wait until no job is running
  */
-int wait_cmd(UAContext *ua, const char *cmd) 
+int wait_cmd(UAContext *ua, const char *cmd)
 {
    JCR *jcr;
    bmicrosleep(0, 200000);           /* let job actually start */
@@ -2012,11 +2012,11 @@ int open_db(UAContext *ua)
       LockRes();
       ua->catalog = (CAT *)GetNextRes(R_CATALOG, NULL);
       UnlockRes();
-      if (!ua->catalog) {    
-         bsendmsg(ua, _("Could not find a Catalog resource\n"));
+      if (!ua->catalog) {
+        bsendmsg(ua, _("Could not find a Catalog resource\n"));
         return 0;
       } else {
-         bsendmsg(ua, _("Using default Catalog name=%s DB=%s\n"), 
+        bsendmsg(ua, _("Using default Catalog name=%s DB=%s\n"),
            ua->catalog->hdr.name, ua->catalog->db_name);
       }
    }
@@ -2032,7 +2032,7 @@ int open_db(UAContext *ua)
       bsendmsg(ua, _("Could not open database \"%s\".\n"),
                 ua->catalog->db_name);
       if (ua->db) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       close_db(ua);
       return 0;
index 291613ccb79950b6ec6023dd943a26177d7bad05..aa18973a422e456817ed82c4bc5d287f18c4b9d6 100644 (file)
@@ -60,7 +60,7 @@ static int typescmd(UAContext *ua, const char *cmd);
 static int backupscmd(UAContext *ua, const char *cmd);
 static int levelscmd(UAContext *ua, const char *cmd);
 
-struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; }; 
+struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; };
 static struct cmdstruct commands[] = {
  { N_(".die"),        diecmd,       NULL},
  { N_(".jobs"),       jobscmd,      NULL},
@@ -77,7 +77,7 @@ static struct cmdstruct commands[] = {
  { N_(".messages"),   qmessagescmd, NULL},
  { N_(".help"),       qhelp_cmd,    NULL},
  { N_(".quit"),       quit_cmd,     NULL},
- { N_(".exit"),       quit_cmd,     NULL} 
+ { N_(".exit"),       quit_cmd,     NULL}
             };
 #define comsize (sizeof(commands)/sizeof(struct cmdstruct))
 
@@ -87,7 +87,7 @@ static struct cmdstruct commands[] = {
 int do_a_dot_command(UAContext *ua, const char *cmd)
 {
    int i;
-   int len, stat;  
+   int len, stat;
    bool found = false;
 
    stat = 1;
@@ -117,13 +117,13 @@ int do_a_dot_command(UAContext *ua, const char *cmd)
 }
 
 /*
- * Create segmentation fault 
+ * Create segmentation fault
  */
 static int diecmd(UAContext *ua, const char *cmd)
 {
    JCR *jcr = NULL;
    int a;
-   
+
    bsendmsg(ua, "The Director will segment fault.\n");
    a = jcr->JobId; /* ref NULL pointer */
    jcr->JobId = 1000; /* another ref NULL pointer */
@@ -249,21 +249,21 @@ static int levelscmd(UAContext *ua, const char *cmd)
  */
 static int defaultscmd(UAContext *ua, const char *cmd)
 {
-   JOB *job;      
+   JOB *job;
    if (ua->argc == 2 && strcmp(ua->argk[1], "job") == 0) {
       job = (JOB *)GetResWithName(R_JOB, ua->argv[1]);
       if (job) {
         STORE *store;
-         bsendmsg(ua, "job=%s", job->hdr.name);
-         bsendmsg(ua, "pool=%s", job->pool->hdr.name);
-         bsendmsg(ua, "messages=%s", job->messages->hdr.name);
-         bsendmsg(ua, "client=%s", job->client->hdr.name);
+        bsendmsg(ua, "job=%s", job->hdr.name);
+        bsendmsg(ua, "pool=%s", job->pool->hdr.name);
+        bsendmsg(ua, "messages=%s", job->messages->hdr.name);
+        bsendmsg(ua, "client=%s", job->client->hdr.name);
         store = (STORE *)job->storage[0]->first();
-         bsendmsg(ua, "storage=%s", store->hdr.name);
-         bsendmsg(ua, "where=%s", job->RestoreWhere?job->RestoreWhere:"");
-         bsendmsg(ua, "level=%s", level_to_str(job->JobLevel));
-         bsendmsg(ua, "type=%s", job_type_to_str(job->JobType));
-         bsendmsg(ua, "fileset=%s", job->fileset->hdr.name);
+        bsendmsg(ua, "storage=%s", store->hdr.name);
+        bsendmsg(ua, "where=%s", job->RestoreWhere?job->RestoreWhere:"");
+        bsendmsg(ua, "level=%s", level_to_str(job->JobLevel));
+        bsendmsg(ua, "type=%s", job_type_to_str(job->JobType));
+        bsendmsg(ua, "fileset=%s", job->fileset->hdr.name);
       }
    }
    return 1;
index 3c3afeac99a6c20706bf77b6e89c0ea1115b75a0..658d5e8425d9ee3991560b235a62b6c222517073 100644 (file)
@@ -69,7 +69,7 @@ int get_cmd(UAContext *ua, const char *prompt)
    return 1;
 }
 
-/* 
+/*
  * Get a positive integer
  *  Returns:  0 if failure
  *           1 if success => value in ua->pint32_val
@@ -83,13 +83,13 @@ int get_pint(UAContext *ua, const char *prompt)
         return 0;
       }
       if (!is_a_number(ua->cmd)) {
-         bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd);
+        bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd);
         continue;
       }
       errno = 0;
       dval = strtod(ua->cmd, NULL);
       if (errno != 0 || dval < 0) {
-         bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd);
+        bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd);
         continue;
       }
       ua->pint32_val = (uint32_t)dval;
@@ -97,7 +97,7 @@ int get_pint(UAContext *ua, const char *prompt)
    }
 }
 
-/* 
+/*
  * Gets a yes or no response
  *  Returns:  0 if failure
  *           1 if success => ua->pint32_val == 1 for yes
@@ -126,7 +126,7 @@ int get_yesno(UAContext *ua, const char *prompt)
       bsendmsg(ua, _("Invalid response. You must answer yes or no.\n"));
    }
 }
-  
+
 
 void parse_ua_args(UAContext *ua)
 {
index bd260da887e85b469f3262bf0e29142ff6b5adf2..a6d939688965792ef2ea0058a653da3b808a5ce2 100644 (file)
@@ -41,7 +41,7 @@ typedef struct s_vol_list {
 /* Forward referenced functions */
 static int do_label(UAContext *ua, const char *cmd, int relabel);
 static void label_from_barcodes(UAContext *ua);
-static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, 
+static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
               POOL_DBR *pr, int relabel, bool media_record_exits);
 static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan);
 static void free_vol_list(vol_list_t *vol_list);
@@ -52,8 +52,8 @@ static char *get_volume_name_from_SD(UAContext *ua, int Slot);
 
 
 /*
- * Label a tape 
- *  
+ * Label a tape
+ *
  *   label storage=xxx volume=vvv
  */
 int label_cmd(UAContext *ua, const char *cmd)
@@ -85,54 +85,54 @@ static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots)
       strip_trailing_junk(ua->argv[i]);
       for (p=ua->argv[i]; p && *p; p=e) {
         /* Check for list */
-         e = strchr(p, ',');
+        e = strchr(p, ',');
         if (e) {
            *e++ = 0;
         }
         /* Check for range */
-         h = strchr(p, '-');             /* range? */
+        h = strchr(p, '-');             /* range? */
         if (h == p) {
-            msg = _("Negative numbers not permitted\n");
+           msg = _("Negative numbers not permitted\n");
            goto bail_out;
         }
         if (h) {
            *h++ = 0;
            if (!is_an_integer(h)) {
-               msg = _("Range end is not integer.\n");
+              msg = _("Range end is not integer.\n");
               goto bail_out;
            }
            skip_spaces(&p);
            if (!is_an_integer(p)) {
-               msg = _("Range start is not an integer.\n");
+              msg = _("Range start is not an integer.\n");
               goto bail_out;
            }
            beg = atoi(p);
            end = atoi(h);
            if (end < beg) {
-               msg = _("Range end not bigger than start.\n");
+              msg = _("Range end not bigger than start.\n");
               goto bail_out;
            }
         } else {
            skip_spaces(&p);
            if (!is_an_integer(p)) {
-               msg = _("Input value is not an integer.\n");
+              msg = _("Input value is not an integer.\n");
               goto bail_out;
            }
            beg = end = atoi(p);
         }
         if (beg <= 0 || end <= 0) {
-            msg = _("Values must be be greater than zero.\n");
+           msg = _("Values must be be greater than zero.\n");
            goto bail_out;
         }
         if (end >= num_slots) {
-            msg = _("Slot too large.\n");
+           msg = _("Slot too large.\n");
            goto bail_out;
         }
         for (i=beg; i<=end; i++) {
            slot_list[i] = 1;         /* Turn on specified range */
         }
       }
-   } else { 
+   } else {
       /* Turn everything on */
       for (i=0; i<num_slots; i++) {
         slot_list[i] = 1;
@@ -142,7 +142,7 @@ static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots)
    printf("Slots turned on:\n");
    for (i=1; i<num_slots; i++) {
       if (slot_list[i]) {
-         printf("%d\n", i); 
+        printf("%d\n", i);
       }
    }
 #endif
@@ -153,7 +153,7 @@ bail_out:
 }
 
 /*
- * Update Slots corresponding to Volumes in autochanger 
+ * Update Slots corresponding to Volumes in autochanger
  */
 int update_slots(UAContext *ua)
 {
@@ -161,7 +161,7 @@ int update_slots(UAContext *ua)
    vol_list_t *vl, *vol_list = NULL;
    MEDIA_DBR mr;
    char *slot_list;
-   bool scan;       
+   bool scan;
 
    if (!open_db(ua)) {
       return 1;
@@ -190,12 +190,12 @@ int update_slots(UAContext *ua)
    /* Walk through the list updating the media records */
    for (vl=vol_list; vl; vl=vl->next) {
       if (vl->Slot >= max_slots) {
-         bsendmsg(ua, _("Slot %d larger than max %d ignored.\n"));
+        bsendmsg(ua, _("Slot %d larger than max %d ignored.\n"));
         continue;
       }
       /* Check if user wants us to look at this slot */
       if (!slot_list[vl->Slot]) {
-         Dmsg1(100, "Skipping slot=%d\n", vl->Slot);
+        Dmsg1(100, "Skipping slot=%d\n", vl->Slot);
         continue;
       }
       /* If scanning, we read the label rather than the barcode */
@@ -205,11 +205,11 @@ int update_slots(UAContext *ua)
            vl->VolName = NULL;
         }
         vl->VolName = get_volume_name_from_SD(ua, vl->Slot);
-         Dmsg2(100, "Got Vol=%s from SD for Slot=%d\n", vl->VolName, vl->Slot);
+        Dmsg2(100, "Got Vol=%s from SD for Slot=%d\n", vl->VolName, vl->Slot);
       }
       slot_list[vl->Slot] = 0;       /* clear Slot */
       if (!vl->VolName) {
-         Dmsg1(100, "No VolName for Slot=%d setting InChanger to zero.\n", vl->Slot);
+        Dmsg1(100, "No VolName for Slot=%d setting InChanger to zero.\n", vl->Slot);
         memset(&mr, 0, sizeof(mr));
         mr.Slot = vl->Slot;
         mr.InChanger = 1;
@@ -217,7 +217,7 @@ int update_slots(UAContext *ua)
         db_lock(ua->db);
         db_make_inchanger_unique(ua->jcr, ua->db, &mr);
         db_unlock(ua->db);
-         bsendmsg(ua, _("No VolName for Slot=%d set InChanger to zero.\n"), vl->Slot);
+        bsendmsg(ua, _("No VolName for Slot=%d set InChanger to zero.\n"), vl->Slot);
         continue;
       }
       memset(&mr, 0, sizeof(mr));
@@ -228,20 +228,20 @@ int update_slots(UAContext *ua)
             mr.Slot = vl->Slot;
             mr.InChanger = 1;
             if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
-                bsendmsg(ua, "%s", db_strerror(ua->db));
+               bsendmsg(ua, "%s", db_strerror(ua->db));
             } else {
                bsendmsg(ua, _(
-                  "Catalog record for Volume \"%s\" updated to reference slot %d.\n"),
+                 "Catalog record for Volume \"%s\" updated to reference slot %d.\n"),
                  mr.VolumeName, mr.Slot);
             }
          } else {
-             bsendmsg(ua, _("Catalog record for Volume \"%s\" is up to date.\n"),
+            bsendmsg(ua, _("Catalog record for Volume \"%s\" is up to date.\n"),
                mr.VolumeName);
-         }   
+         }
          db_unlock(ua->db);
          continue;
       } else {
-          bsendmsg(ua, _("Record for Volume \"%s\" not found in catalog.\n"), 
+         bsendmsg(ua, _("Record for Volume \"%s\" not found in catalog.\n"),
             mr.VolumeName);
       }
       db_unlock(ua->db);
@@ -257,7 +257,7 @@ int update_slots(UAContext *ua)
       }
    }
    db_unlock(ua->db);
-      
+
 bail_out:
 
    free_vol_list(vol_list);
@@ -306,14 +306,14 @@ static int do_label(UAContext *ua, const char *cmd, int relabel)
    /* If relabel get name of Volume to relabel */
    if (relabel) {
       /* Check for oldvolume=name */
-      i = find_arg_with_value(ua, "oldvolume"); 
+      i = find_arg_with_value(ua, "oldvolume");
       if (i >= 0) {
         memset(&omr, 0, sizeof(omr));
         bstrncpy(omr.VolumeName, ua->argv[i], sizeof(omr.VolumeName));
         if (db_get_media_record(ua->jcr, ua->db, &omr)) {
            goto checkVol;
-        } 
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        }
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       /* No keyword or Vol not found, ask user to select */
       if (!select_media_dbr(ua, &omr)) {
@@ -323,7 +323,7 @@ static int do_label(UAContext *ua, const char *cmd, int relabel)
       /* Require Volume to be Purged or Recycled */
 checkVol:
       if (strcmp(omr.VolStatus, "Purged") != 0 && strcmp(omr.VolStatus, "Recycle") != 0) {
-         bsendmsg(ua, _("Volume \"%s\" has VolStatus %s. It must be Purged or Recycled before relabeling.\n"),
+        bsendmsg(ua, _("Volume \"%s\" has VolStatus %s. It must be Purged or Recycled before relabeling.\n"),
            omr.VolumeName, omr.VolStatus);
         return 1;
       }
@@ -352,7 +352,7 @@ checkName:
       /* If VolBytes are zero the Volume is not labeled */
       if (db_get_media_record(ua->jcr, ua->db, &mr)) {
         if (mr.VolBytes != 0) {
-             bsendmsg(ua, _("Media record for new Volume \"%s\" already exists.\n"), 
+            bsendmsg(ua, _("Media record for new Volume \"%s\" already exists.\n"),
                mr.VolumeName);
             continue;
          }
@@ -363,7 +363,7 @@ checkName:
 
    /* If autochanger, request slot */
    if (store->autochanger) {
-      i = find_arg_with_value(ua, "slot"); 
+      i = find_arg_with_value(ua, "slot");
       if (i >= 0) {
         mr.Slot = atoi(ua->argv[i]);
       } else if (!get_pint(ua, _("Enter slot (0 for none): "))) {
@@ -392,34 +392,34 @@ checkName:
       if (relabel) {
         /* Delete the old media record */
         if (!db_delete_media_record(ua->jcr, ua->db, &omr)) {
-            bsendmsg(ua, _("Delete of Volume \"%s\" failed. ERR=%s"),
+           bsendmsg(ua, _("Delete of Volume \"%s\" failed. ERR=%s"),
               omr.VolumeName, db_strerror(ua->db));
         } else {
-            bsendmsg(ua, _("Old volume \"%s\" deleted from catalog.\n"), 
+           bsendmsg(ua, _("Old volume \"%s\" deleted from catalog.\n"),
               omr.VolumeName);
            /* Update the number of Volumes in the pool */
            pr.NumVols--;
            if (!db_update_pool_record(ua->jcr, ua->db, &pr)) {
-               bsendmsg(ua, "%s", db_strerror(ua->db));
+              bsendmsg(ua, "%s", db_strerror(ua->db));
            }
         }
       }
       if (ua->automount) {
         bstrncpy(dev_name, store->dev_name, sizeof(dev_name));
-         bsendmsg(ua, _("Requesting to mount %s ...\n"), dev_name);
+        bsendmsg(ua, _("Requesting to mount %s ...\n"), dev_name);
         bash_spaces(dev_name);
-         bnet_fsend(sd, "mount %s", dev_name);
+        bnet_fsend(sd, "mount %s", dev_name);
         unbash_spaces(dev_name);
         while (bnet_recv(sd) >= 0) {
-            bsendmsg(ua, "%s", sd->msg);
+           bsendmsg(ua, "%s", sd->msg);
            /* Here we can get
             *  3001 OK mount. Device=xxx      or
             *  3001 Mounted Volume vvvv
             *  3906 is cannot mount non-tape
             * So for those, no need to print a reminder
             */
-            if (strncmp(sd->msg, "3001 ", 5) == 0 ||
-                strncmp(sd->msg, "3906 ", 5) == 0) {
+           if (strncmp(sd->msg, "3001 ", 5) == 0 ||
+               strncmp(sd->msg, "3906 ", 5) == 0) {
               print_reminder = false;
            }
         }
@@ -460,8 +460,8 @@ static void label_from_barcodes(UAContext *ua)
 
    /* Display list of Volumes and ask if he really wants to proceed */
    bsendmsg(ua, _("The following Volumes will be labeled:\n"
-                  "Slot  Volume\n"
-                  "==============\n"));
+                 "Slot  Volume\n"
+                 "==============\n"));
    for (vl=vol_list; vl; vl=vl->next) {
       if (!vl->VolName || !slot_list[vl->Slot]) {
         continue;
@@ -489,16 +489,16 @@ static void label_from_barcodes(UAContext *ua)
       media_record_exists = false;
       if (db_get_media_record(ua->jcr, ua->db, &mr)) {
          if (mr.VolBytes != 0) {
-             bsendmsg(ua, _("Media record for Slot %d Volume \"%s\" already exists.\n"), 
+            bsendmsg(ua, _("Media record for Slot %d Volume \"%s\" already exists.\n"),
                vl->Slot, mr.VolumeName);
             if (!mr.InChanger) {
                mr.InChanger = 1;
                if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
-                   bsendmsg(ua, "Error setting InChanger: ERR=%s", db_strerror(ua->db));
+                  bsendmsg(ua, "Error setting InChanger: ERR=%s", db_strerror(ua->db));
                }
             }
             continue;
-         } 
+         }
          media_record_exists = true;
       }
       mr.InChanger = 1;
@@ -510,19 +510,19 @@ static void label_from_barcodes(UAContext *ua)
         if (media_record_exists) {      /* we update it */
            mr.VolBytes = 1;
            if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
-                bsendmsg(ua, "%s", db_strerror(ua->db));
+               bsendmsg(ua, "%s", db_strerror(ua->db));
            }
         } else {                        /* create the media record */
            set_pool_dbr_defaults_in_media_dbr(&mr, &pr);
            if (db_create_media_record(ua->jcr, ua->db, &mr)) {
-               bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"),
+              bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"),
                  mr.VolumeName);
               pr.NumVols++;          /* this is a bit suspect */
               if (!db_update_pool_record(ua->jcr, ua->db, &pr)) {
-                  bsendmsg(ua, "%s", db_strerror(ua->db));
+                 bsendmsg(ua, "%s", db_strerror(ua->db));
               }
            } else {
-               bsendmsg(ua, "Catalog error on cleaning tape: %s", db_strerror(ua->db));
+              bsendmsg(ua, "Catalog error on cleaning tape: %s", db_strerror(ua->db));
            }
         }
         continue;                    /* done, go handle next volume */
@@ -542,7 +542,7 @@ bail_out:
    return;
 }
 
-/* 
+/*
  * Check if the Volume name has legal characters
  * If ua is non-NULL send the message
  */
@@ -558,20 +558,20 @@ bool is_volume_name_legal(UAContext *ua, const char *name)
         continue;
       }
       if (ua) {
-         bsendmsg(ua, _("Illegal character \"%c\" in a volume name.\n"), *p);
+        bsendmsg(ua, _("Illegal character \"%c\" in a volume name.\n"), *p);
       }
       return 0;
    }
    len = strlen(name);
    if (len >= MAX_NAME_LENGTH) {
       if (ua) {
-         bsendmsg(ua, _("Volume name too long.\n"));
+        bsendmsg(ua, _("Volume name too long.\n"));
       }
       return 0;
    }
    if (len == 0) {
       if (ua) {
-         bsendmsg(ua, _("Volume name must be at least one character long.\n"));
+        bsendmsg(ua, _("Volume name must be at least one character long.\n"));
       }
       return 0;
    }
@@ -581,7 +581,7 @@ bool is_volume_name_legal(UAContext *ua, const char *name)
 /*
  * NOTE! This routine opens the SD socket but leaves it open
  */
-static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, 
+static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
                               POOL_DBR *pr, int relabel, bool media_record_exists)
 {
    BSOCK *sd;
@@ -598,16 +598,16 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
    bash_spaces(pr->Name);
    if (relabel) {
       bash_spaces(omr->VolumeName);
-      bnet_fsend(sd, "relabel %s OldName=%s NewName=%s PoolName=%s MediaType=%s Slot=%d", 
+      bnet_fsend(sd, "relabel %s OldName=%s NewName=%s PoolName=%s MediaType=%s Slot=%d",
         dev_name, omr->VolumeName, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot);
       bsendmsg(ua, _("Sending relabel command from \"%s\" to \"%s\" ...\n"),
         omr->VolumeName, mr->VolumeName);
    } else {
-      bnet_fsend(sd, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d", 
+      bnet_fsend(sd, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d",
         dev_name, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot);
-      bsendmsg(ua, _("Sending label command for Volume \"%s\" Slot %d ...\n"), 
+      bsendmsg(ua, _("Sending label command for Volume \"%s\" Slot %d ...\n"),
         mr->VolumeName, mr->Slot);
-      Dmsg5(200, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d\n", 
+      Dmsg5(200, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d\n",
         dev_name, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot);
    }
 
@@ -615,7 +615,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
       bsendmsg(ua, "%s", sd->msg);
       if (strncmp(sd->msg, "3000 OK label.", 14) == 0) {
         ok = true;
-      } 
+      }
    }
    unbash_spaces(mr->VolumeName);
    unbash_spaces(mr->MediaType);
@@ -626,7 +626,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
         mr->VolBytes = 1;
         mr->InChanger = 1;
         if (!db_update_media_record(ua->jcr, ua->db, mr)) {
-             bsendmsg(ua, "%s", db_strerror(ua->db));
+            bsendmsg(ua, "%s", db_strerror(ua->db));
             ok = false;
         }
       } else {                       /* create the media record */
@@ -634,15 +634,15 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
         mr->VolBytes = 1;               /* flag indicating Volume labeled */
         mr->InChanger = 1;
         if (db_create_media_record(ua->jcr, ua->db, mr)) {
-            bsendmsg(ua, _("Catalog record for Volume \"%s\", Slot %d  successfully created.\n"),
+           bsendmsg(ua, _("Catalog record for Volume \"%s\", Slot %d  successfully created.\n"),
            mr->VolumeName, mr->Slot);
            /* Update number of volumes in pool */
            pr->NumVols++;
            if (!db_update_pool_record(ua->jcr, ua->db, pr)) {
-               bsendmsg(ua, "%s", db_strerror(ua->db));
+              bsendmsg(ua, "%s", db_strerror(ua->db));
            }
         } else {
-            bsendmsg(ua, "%s", db_strerror(ua->db));
+           bsendmsg(ua, "%s", db_strerror(ua->db));
            ok = false;
         }
       }
@@ -652,15 +652,15 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
    return ok;
 }
 
-static BSOCK *open_sd_bsock(UAContext *ua) 
+static BSOCK *open_sd_bsock(UAContext *ua)
 {
    STORE *store = ua->jcr->store;
 
    if (!ua->jcr->store_bsock) {
-      bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d ...\n"), 
+      bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d ...\n"),
         store->hdr.name, store->address, store->SDport);
       if (!connect_to_storage_daemon(ua->jcr, 10, SDConnectTimeout, 1)) {
-         bsendmsg(ua, _("Failed to connect to Storage daemon.\n"));
+        bsendmsg(ua, _("Failed to connect to Storage daemon.\n"));
         return NULL;
       }
    }
@@ -676,7 +676,7 @@ static void close_sd_bsock(UAContext *ua)
    }
 }
 
-static char *get_volume_name_from_SD(UAContext *ua, int Slot) 
+static char *get_volume_name_from_SD(UAContext *ua, int Slot)
 {
    STORE *store = ua->jcr->store;
    BSOCK *sd;
@@ -700,7 +700,7 @@ static char *get_volume_name_from_SD(UAContext *ua, int Slot)
       Dmsg1(100, "Got: %s", sd->msg);
       if (strncmp(sd->msg, "3001 Volume=", 12) == 0) {
         VolName = (char *)malloc(sd->msglen);
-         if (sscanf(sd->msg, "3001 Volume=%s Slot=%d", VolName, &rtn_slot) == 2) {
+        if (sscanf(sd->msg, "3001 Volume=%s Slot=%d", VolName, &rtn_slot) == 2) {
            break;
         }
         free(VolName);
@@ -717,7 +717,7 @@ static char *get_volume_name_from_SD(UAContext *ua, int Slot)
  *  If scan is set, we return all slots found,
  *  otherwise, we return only slots with valid barcodes (Volume names)
  */
-static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) 
+static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan)
 {
    STORE *store = ua->jcr->store;
    char dev_name[MAX_NAME_LENGTH];
@@ -744,8 +744,8 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan)
       /* Check for returned SD messages */
       if (sd->msg[0] == '3'     && B_ISDIGIT(sd->msg[1]) &&
          B_ISDIGIT(sd->msg[2]) && B_ISDIGIT(sd->msg[3]) &&
-          sd->msg[4] == ' ') {
-         bsendmsg(ua, "%s\n", sd->msg);   /* pass them on to user */
+         sd->msg[4] == ' ') {
+        bsendmsg(ua, "%s\n", sd->msg);   /* pass them on to user */
         continue;
       }
 
@@ -756,8 +756,8 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan)
         Slot = atoi(sd->msg);
         if (Slot <= 0) {
            p--;
-            *p = ':';
-            bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg); 
+           *p = ':';
+           bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg);
            continue;
         }
       } else {
@@ -766,8 +766,8 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan)
            *p++ = 0;
            if (!is_an_integer(sd->msg) || (Slot=atoi(sd->msg)) <= 0) {
               p--;
-               *p = ':';
-               bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg); 
+              *p = ':';
+              bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg);
               continue;
            }
         } else {
@@ -775,8 +775,8 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan)
         }
         if (!is_volume_name_legal(ua, p)) {
            p--;
-            *p = ':';
-            bsendmsg(ua, _("Invalid Volume name: %s\n"), sd->msg); 
+           *p = ':';
+           bsendmsg(ua, _("Invalid Volume name: %s\n"), sd->msg);
            continue;
         }
       }
@@ -785,7 +785,7 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan)
       vl = (vol_list_t *)malloc(sizeof(vol_list_t));
       vl->Slot = Slot;
       if (p) {
-         if (*p == ':') {
+        if (*p == ':') {
            p++;                      /* skip separator */
         }
         vl->VolName = bstrdup(p);
@@ -830,7 +830,7 @@ static void free_vol_list(vol_list_t *vol_list)
 
 /*
  * Check if this is a cleaning tape by comparing the Volume name
- *  with the Cleaning Prefix. If they match, this is a cleaning 
+ *  with the Cleaning Prefix. If they match, this is a cleaning
  *  tape.
  */
 static bool is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr)
@@ -846,7 +846,7 @@ static bool is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr)
    }
    Dmsg4(100, "CLNprefix=%s: Vol=%s: len=%d strncmp=%d\n",
       ua->jcr->pool->cleaning_prefix, mr->VolumeName,
-      strlen(ua->jcr->pool->cleaning_prefix), 
+      strlen(ua->jcr->pool->cleaning_prefix),
       strncmp(mr->VolumeName, ua->jcr->pool->cleaning_prefix,
                  strlen(ua->jcr->pool->cleaning_prefix)));
    return strncmp(mr->VolumeName, ua->jcr->pool->cleaning_prefix,
index d9eed92902cd313570743eb2ba5ef8d0b90fa59e..41ad6b3cc250a33e06716269a7c46129f1584af3 100644 (file)
@@ -54,7 +54,7 @@ static bool list_nextvol(UAContext *ua);
 int autodisplay_cmd(UAContext *ua, const char *cmd)
 {
    static const char *kw[] = {
-      N_("on"), 
+      N_("on"),
       N_("off"),
       NULL};
 
@@ -69,7 +69,7 @@ int autodisplay_cmd(UAContext *ua, const char *cmd)
       bsendmsg(ua, _("ON or OFF keyword missing.\n"));
       break;
    }
-   return 1; 
+   return 1;
 }
 
 /*
@@ -78,7 +78,7 @@ int autodisplay_cmd(UAContext *ua, const char *cmd)
 int gui_cmd(UAContext *ua, const char *cmd)
 {
    static const char *kw[] = {
-      N_("on"), 
+      N_("on"),
       N_("off"),
       NULL};
 
@@ -95,7 +95,7 @@ int gui_cmd(UAContext *ua, const char *cmd)
       bsendmsg(ua, _("ON or OFF keyword missing.\n"));
       break;
    }
-   return 1; 
+   return 1;
 }
 
 
@@ -128,7 +128,7 @@ static struct showstruct reses[] = {
  */
 int show_cmd(UAContext *ua, const char *cmd)
 {
-   int i, j, type, len; 
+   int i, j, type, len;
    int recurse;
    char *res_name;
    RES *res = NULL;
@@ -139,7 +139,7 @@ int show_cmd(UAContext *ua, const char *cmd)
    LockRes();
    for (i=1; i<ua->argc; i++) {
       type = 0;
-      res_name = ua->argk[i]; 
+      res_name = ua->argk[i];
       if (!ua->argv[i]) {            /* was a name given? */
         /* No name, dump all resources of specified type */
         recurse = 1;
@@ -176,21 +176,21 @@ int show_cmd(UAContext *ua, const char *cmd)
       switch (type) {
       case -1:                          /* all */
         for (j=r_first; j<=r_last; j++) {
-           dump_resource(j, res_head[j-r_first], bsendmsg, ua);     
-//         dump_resource(j, resources[j-r_first].res_head, bsendmsg, ua);     
+           dump_resource(j, res_head[j-r_first], bsendmsg, ua);
+//         dump_resource(j, resources[j-r_first].res_head, bsendmsg, ua);
         }
         break;
       case -2:
-         bsendmsg(ua, _("Keywords for the show command are:\n"));
+        bsendmsg(ua, _("Keywords for the show command are:\n"));
         for (j=0; reses[j].res_name; j++) {
-            bsendmsg(ua, "%s\n", _(reses[j].res_name));
+           bsendmsg(ua, "%s\n", _(reses[j].res_name));
         }
         goto bail_out;
       case -3:
-         bsendmsg(ua, _("%s resource %s not found.\n"), res_name, ua->argv[i]);
+        bsendmsg(ua, _("%s resource %s not found.\n"), res_name, ua->argv[i]);
         goto bail_out;
       case 0:
-         bsendmsg(ua, _("Resource %s not found\n"), res_name);
+        bsendmsg(ua, _("Resource %s not found\n"), res_name);
         goto bail_out;
       default:
         dump_resource(recurse?type:-type, res, bsendmsg, ua);
@@ -289,12 +289,12 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
       } else if (strcasecmp(ua->argk[i], _("files")) == 0) {
 
         for (j=i+1; j<ua->argc; j++) {
-            if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) {
+           if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) {
               bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH);
               jr.JobId = 0;
               db_get_job_record(ua->jcr, ua->db, &jr);
               jobid = jr.JobId;
-            } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) {
+           } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) {
               jobid = atoi(ua->argv[j]);
            } else {
               continue;
@@ -303,17 +303,17 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
               db_list_files_for_job(ua->jcr, ua->db, jobid, prtit, ua);
            }
         }
-      
+
       /* List JOBMEDIA */
       } else if (strcasecmp(ua->argk[i], _("jobmedia")) == 0) {
         int done = FALSE;
         for (j=i+1; j<ua->argc; j++) {
-            if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) {
+           if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) {
               bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH);
               jr.JobId = 0;
               db_get_job_record(ua->jcr, ua->db, &jr);
               jobid = jr.JobId;
-            } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) {
+           } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) {
               jobid = atoi(ua->argv[j]);
            } else {
               continue;
@@ -336,22 +336,22 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
 
       /* List MEDIA or VOLUMES */
       } else if (strcasecmp(ua->argk[i], _("media")) == 0 ||
-                 strcasecmp(ua->argk[i], _("volumes")) == 0) {
+                strcasecmp(ua->argk[i], _("volumes")) == 0) {
         bool done = false;
         for (j=i+1; j<ua->argc; j++) {
-            if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) {
+           if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) {
               bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH);
               jr.JobId = 0;
               db_get_job_record(ua->jcr, ua->db, &jr);
               jobid = jr.JobId;
-            } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) {
+           } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) {
               jobid = atoi(ua->argv[j]);
            } else {
               continue;
            }
            VolumeName = get_pool_memory(PM_FNAME);
            n = db_get_job_volume_names(ua->jcr, ua->db, jobid, &VolumeName);
-            bsendmsg(ua, _("Jobid %d used %d Volume(s): %s\n"), jobid, n, VolumeName);
+           bsendmsg(ua, _("Jobid %d used %d Volume(s): %s\n"), jobid, n, VolumeName);
            free_pool_memory(VolumeName);
            done = true;
         }
@@ -361,9 +361,9 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
            uint32_t *ids;
            /* Is a specific pool wanted? */
            for (i=1; i<ua->argc; i++) {
-               if (strcasecmp(ua->argk[i], _("pool")) == 0) {
+              if (strcasecmp(ua->argk[i], _("pool")) == 0) {
                  if (!get_pool_dbr(ua, &pr)) {
-                     bsendmsg(ua, _("No Pool specified.\n"));
+                    bsendmsg(ua, _("No Pool specified.\n"));
                     return 1;
                  }
                  mr.PoolId = pr.PoolId;
@@ -373,7 +373,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
            }
            /* List Volumes in all pools */
            if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) {
-               bsendmsg(ua, _("Error obtaining pool ids. ERR=%s\n"), 
+              bsendmsg(ua, _("Error obtaining pool ids. ERR=%s\n"),
                        db_strerror(ua->db));
               return 1;
            }
@@ -383,7 +383,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
            for (i=0; i < num_pools; i++) {
               pr.PoolId = ids[i];
               if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
-                  bsendmsg(ua, _("Pool: %s\n"), pr.Name);
+                 bsendmsg(ua, _("Pool: %s\n"), pr.Name);
               }
               mr.PoolId = ids[i];
               db_list_media_records(ua->jcr, ua->db, &mr, prtit, ua, llist);
@@ -394,18 +394,18 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
       /* List a specific volume */
       } else if (strcasecmp(ua->argk[i], _("volume")) == 0) {
         if (!ua->argv[i]) {
-            bsendmsg(ua, _("No Volume Name specified.\n"));
+           bsendmsg(ua, _("No Volume Name specified.\n"));
            return 1;
         }
         bstrncpy(mr.VolumeName, ua->argv[i], sizeof(mr.VolumeName));
         db_list_media_records(ua->jcr, ua->db, &mr, prtit, ua, llist);
         return 1;
       /* List next volume */
-      } else if (strcasecmp(ua->argk[i], _("nextvol")) == 0 || 
-                 strcasecmp(ua->argk[i], _("nextvolume")) == 0) {
+      } else if (strcasecmp(ua->argk[i], _("nextvol")) == 0 ||
+                strcasecmp(ua->argk[i], _("nextvolume")) == 0) {
         list_nextvol(ua);
       } else {
-         bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i]));
+        bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i]));
       }
    }
    return 1;
@@ -430,7 +430,7 @@ static bool list_nextvol(UAContext *ua)
    } else {
       job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
       if (!job) {
-         Jmsg(jcr, M_ERROR, 0, _("%s is not a job name.\n"), ua->argv[i]);
+        Jmsg(jcr, M_ERROR, 0, _("%s is not a job name.\n"), ua->argv[i]);
         if ((job = select_job_resource(ua)) == NULL) {
            return false;
         }
@@ -441,11 +441,11 @@ static bool list_nextvol(UAContext *ua)
       if (!complete_jcr_for_job(jcr, job, pool)) {
         return false;
       }
-     
+
       if (!find_next_volume_for_append(jcr, &mr, 0)) {
-         bsendmsg(ua, _("Could not find next Volume.\n"));
+        bsendmsg(ua, _("Could not find next Volume.\n"));
       } else {
-         bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"), 
+        bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"),
            job->hdr.name, mr.VolumeName);
         found = true;
       }
@@ -462,7 +462,7 @@ static bool list_nextvol(UAContext *ua)
 }
 
 
-/* 
+/*
  * For a given job, we examine all his run records
  *  to see if it is scheduled today or tomorrow.
  */
@@ -479,7 +479,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
    if (sched == NULL) {           /* scheduled? */
       return NULL;                /* no nothing to report */
    }
-   /* Break down current time into components */ 
+   /* Break down current time into components */
    now = time(NULL);
    localtime_r(&now, &tm);
    mday = tm.tm_mday - 1;
@@ -503,10 +503,10 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
       run = run->next;
    }
    for ( ; run; run=run->next) {
-      /* 
+      /*
        * Find runs in next 24 hours
        */
-      tod = bit_is_set(mday, run->mday) && bit_is_set(wday, run->wday) && 
+      tod = bit_is_set(mday, run->mday) && bit_is_set(wday, run->wday) &&
            bit_is_set(month, run->month) && bit_is_set(wom, run->wom) &&
            bit_is_set(woy, run->woy);
 
@@ -525,16 +525,16 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
       if (tod) {                  /* Jobs scheduled today (next 24 hours) */
 #ifdef xxx
         char buf[300], num[10];
-         bsnprintf(buf, sizeof(buf), "tm.hour=%d hour=", tm.tm_hour);
+        bsnprintf(buf, sizeof(buf), "tm.hour=%d hour=", tm.tm_hour);
         for (i=0; i<24; i++) {
            if (bit_is_set(i, run->hour)) {
-               bsnprintf(num, sizeof(num), "%d ", i);
+              bsnprintf(num, sizeof(num), "%d ", i);
               bstrncat(buf, num, sizeof(buf));
            }
         }
-         bstrncat(buf, "\n", sizeof(buf));
-         Dmsg1(000, "%s", buf);
-#endif 
+        bstrncat(buf, "\n", sizeof(buf));
+        Dmsg1(000, "%s", buf);
+#endif
         /* find time (time_t) job is to be run */
         localtime_r(&now, &tm);
         for (i=tm.tm_hour; i < 24; i++) {
@@ -543,9 +543,9 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
               tm.tm_min = run->minute;
               tm.tm_sec = 0;
               runtime = mktime(&tm);
-               Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
+              Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
               if (runtime > now) {
-                  Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
+                 Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
                  return run;         /* found it, return run resource */
               }
            }
@@ -561,19 +561,19 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime)
               tm.tm_min = run->minute;
               tm.tm_sec = 0;
               runtime = mktime(&tm);
-               Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
+              Dmsg2(200, "now=%d runtime=%d\n", now, runtime);
               if (runtime < tomorrow) {
-                  Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
+                 Dmsg2(200, "Found it level=%d %c\n", run->level, run->level);
                  return run;         /* found it, return run resource */
               }
            }
         }
       }
-   } /* end for loop over runs */ 
+   } /* end for loop over runs */
    /* Nothing found */
    return NULL;
 }
-/* 
+/*
  * Fill in the remaining fields of the jcr as if it
  *  is going to run the job.
  */
@@ -581,20 +581,20 @@ int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool)
 {
    POOL_DBR pr;
 
-   memset(&pr, 0, sizeof(POOL_DBR));   
+   memset(&pr, 0, sizeof(POOL_DBR));
    set_jcr_defaults(jcr, job);
    if (pool) {
       jcr->pool = pool;              /* override */
    }
    jcr->db = jcr->db=db_init_database(jcr, jcr->catalog->db_name, jcr->catalog->db_user,
                      jcr->catalog->db_password, jcr->catalog->db_address,
-                     jcr->catalog->db_port, jcr->catalog->db_socket,   
+                     jcr->catalog->db_port, jcr->catalog->db_socket,
                      jcr->catalog->mult_db_connections);
    if (!jcr->db || !db_open_database(jcr, jcr->db)) {
       Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"),
                 jcr->catalog->db_name);
       if (jcr->db) {
-         Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
+        Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
       }
       return 0;
    }
@@ -602,7 +602,7 @@ int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool)
    while (!db_get_pool_record(jcr, jcr->db, &pr)) { /* get by Name */
       /* Try to create the pool */
       if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, 
+        Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name,
            db_strerror(jcr->db));
         if (jcr->db) {
            db_close_database(jcr, jcr->db);
@@ -610,10 +610,10 @@ int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool)
         }
         return 0;
       } else {
-         Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name);
+        Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name);
       }
    }
-   jcr->PoolId = pr.PoolId; 
+   jcr->PoolId = pr.PoolId;
    jcr->jr.PoolId = pr.PoolId;
    return 1;
 }
@@ -627,7 +627,7 @@ static void con_lock_release(void *arg)
 void do_messages(UAContext *ua, const char *cmd)
 {
    char msg[2000];
-   int mlen; 
+   int mlen;
    int do_truncate = FALSE;
 
    Pw(con_lock);
@@ -675,12 +675,12 @@ int messagescmd(UAContext *ua, const char *cmd)
 void prtit(void *ctx, const char *msg)
 {
    UAContext *ua = (UAContext *)ctx;
+
    bnet_fsend(ua->UA_sock, "%s", msg);
 }
 
-/* 
- * Format message and send to other end.  
+/*
+ * Format message and send to other end.
 
  * If the UA_sock is NULL, it means that there is no user
  * agent, so we are being called from Bacula core. In
index d72fe1d370854552dd1eed55afe3880e703be570..7f769c75d93d21a7a36fb253751b90ba97f36783 100644 (file)
@@ -82,7 +82,7 @@ struct s_count_ctx {
 
 
 /*
- * Called here to count entries to be deleted 
+ * Called here to count entries to be deleted
  */
 static int count_handler(void *ctx, int num_fields, char **row)
 {
@@ -120,7 +120,7 @@ static int job_delete_handler(void *ctx, int num_fields, char **row)
 {
    struct s_job_del_ctx *del = (struct s_job_del_ctx *)ctx;
 
-   if (del->num_ids == MAX_DEL_LIST_LEN) {  
+   if (del->num_ids == MAX_DEL_LIST_LEN) {
       return 1;
    }
    if (del->num_ids == del->max_ids) {
@@ -137,7 +137,7 @@ static int file_delete_handler(void *ctx, int num_fields, char **row)
 {
    struct s_file_del_ctx *del = (struct s_file_del_ctx *)ctx;
 
-   if (del->num_ids == MAX_DEL_LIST_LEN) {  
+   if (del->num_ids == MAX_DEL_LIST_LEN) {
       return 1;
    }
    if (del->num_ids == del->max_ids) {
@@ -154,7 +154,7 @@ static int file_delete_handler(void *ctx, int num_fields, char **row)
  *
  *    prune files (from) client=xxx
  *    prune jobs (from) client=xxx
- *    prune volume=xxx 
+ *    prune volume=xxx
  */
 int prunecmd(UAContext *ua, const char *cmd)
 {
@@ -174,12 +174,12 @@ int prunecmd(UAContext *ua, const char *cmd)
    }
 
    /* First search args */
-   kw = find_arg_keyword(ua, keywords);  
+   kw = find_arg_keyword(ua, keywords);
    if (kw < 0 || kw > 2) {
       /* no args, so ask user */
-      kw = do_keyword_prompt(ua, _("Choose item to prune"), keywords);  
-   }      
-    
+      kw = do_keyword_prompt(ua, _("Choose item to prune"), keywords);
+   }
+
    switch (kw) {
    case 0:  /* prune files */
       client = get_client_resource(ua);
@@ -243,21 +243,21 @@ int prune_files(UAContext *ua, CLIENT *client)
 
    period = client->FileRetention;
    now = (utime_t)time(NULL);
-       
+
    /* Select Jobs -- for counting */
    Mmsg(query, select_job, edit_uint64(now - period, ed1), cr.ClientId);
    Dmsg1(050, "select sql=%s\n", query);
    if (!db_sql_query(ua->db, query, file_count_handler, (void *)&del)) {
       if (ua->verbose) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       Dmsg0(050, "Count failed\n");
       goto bail_out;
    }
-      
+
    if (del.tot_ids == 0) {
       if (ua->verbose) {
-         bsendmsg(ua, _("No Files found to prune.\n"));
+        bsendmsg(ua, _("No Files found to prune.\n"));
       }
       goto bail_out;
    }
@@ -265,7 +265,7 @@ int prune_files(UAContext *ua, CLIENT *client)
    if (del.tot_ids < MAX_DEL_LIST_LEN) {
       del.max_ids = del.tot_ids + 1;
    } else {
-      del.max_ids = MAX_DEL_LIST_LEN; 
+      del.max_ids = MAX_DEL_LIST_LEN;
    }
    del.tot_ids = 0;
 
@@ -283,7 +283,7 @@ int prune_files(UAContext *ua, CLIENT *client)
       del.tot_ids += cnt.count;
       Mmsg(query, del_File, del.JobId[i]);
       db_sql_query(ua->db, query, NULL, (void *)NULL);
-      /* 
+      /*
        * Now mark Job as having files purged. This is necessary to
        * avoid having too many Jobs to process in future prunings. If
        * we don't do this, the number of JobId's in our in memory list
@@ -295,9 +295,9 @@ int prune_files(UAContext *ua, CLIENT *client)
    }
    edit_uint64_with_commas(del.tot_ids, ed1);
    edit_uint64_with_commas(del.num_ids, ed2);
-   bsendmsg(ua, _("Pruned %s Files from %s Jobs for client %s from catalog.\n"), 
+   bsendmsg(ua, _("Pruned %s Files from %s Jobs for client %s from catalog.\n"),
       ed1, ed2, client->hdr.name);
-   
+
 bail_out:
    db_unlock(ua->db);
    if (del.JobId) {
@@ -308,7 +308,7 @@ bail_out:
 }
 
 
-static void drop_temp_tables(UAContext *ua) 
+static void drop_temp_tables(UAContext *ua)
 {
    int i;
    for (i=0; drop_deltabs[i]; i++) {
@@ -316,14 +316,14 @@ static void drop_temp_tables(UAContext *ua)
    }
 }
 
-static int create_temp_tables(UAContext *ua) 
+static int create_temp_tables(UAContext *ua)
 {
    int i;
    /* Create temp tables and indicies */
    for (i=0; create_deltabs[i]; i++) {
       if (!db_sql_query(ua->db, create_deltabs[i], NULL, (void *)NULL)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
-         Dmsg0(050, "create DelTables table failed\n");
+        bsendmsg(ua, "%s", db_strerror(ua->db));
+        Dmsg0(050, "create DelTables table failed\n");
         return 0;
       }
    }
@@ -374,7 +374,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
       goto bail_out;
    }
 
-   /* 
+   /*
     * Select all files that are older than the JobRetention period
     *  and stuff them into the "DeletionCandidates" table.
     */
@@ -382,7 +382,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
    Mmsg(query, insert_delcand, (char)JobType, ed1, cr.ClientId);
    if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) {
       if (ua->verbose) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       Dmsg0(050, "insert delcand failed\n");
       goto bail_out;
@@ -397,10 +397,10 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
       Dmsg0(050, "Count failed\n");
       goto bail_out;
    }
-      
+
    if (cnt.count == 0) {
       if (ua->verbose) {
-         bsendmsg(ua, _("No Jobs found to prune.\n"));
+        bsendmsg(ua, _("No Jobs found to prune.\n"));
       }
       goto bail_out;
    }
@@ -408,7 +408,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
    if (cnt.count < MAX_DEL_LIST_LEN) {
       del.max_ids = cnt.count + 1;
    } else {
-      del.max_ids = MAX_DEL_LIST_LEN; 
+      del.max_ids = MAX_DEL_LIST_LEN;
    }
    del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids);
    del.PurgedFiles = (char *)malloc(del.max_ids);
@@ -431,7 +431,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
       bsendmsg(ua, "%s", db_strerror(ua->db));
    }
 
-   /* 
+   /*
     * OK, now we have the list of JobId's to be pruned, first check
     * if the Files have been purged, if not, purge (delete) them.
     * Then delete the Job entry, and finally and JobMedia records.
@@ -441,26 +441,26 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
       if (!del.PurgedFiles[i]) {
         Mmsg(query, del_File, del.JobId[i]);
         if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) {
-            bsendmsg(ua, "%s", db_strerror(ua->db));
+           bsendmsg(ua, "%s", db_strerror(ua->db));
         }
-         Dmsg1(050, "Del sql=%s\n", query);
+        Dmsg1(050, "Del sql=%s\n", query);
       }
 
       Mmsg(query, del_Job, del.JobId[i]);
       if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       Dmsg1(050, "Del sql=%s\n", query);
 
       Mmsg(query, del_JobMedia, del.JobId[i]);
       if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       Dmsg1(050, "Del sql=%s\n", query);
    }
    bsendmsg(ua, _("Pruned %d %s for client %s from catalog.\n"), del.num_ids,
       del.num_ids==1?_("Job"):_("Jobs"), client->hdr.name);
-   
+
 bail_out:
    drop_temp_tables(ua);
    db_unlock(ua->db);
@@ -491,7 +491,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr)
    memset(&del, 0, sizeof(del));
 
    /*
-    * Find out how many Jobs remain on this Volume by 
+    * Find out how many Jobs remain on this Volume by
     *  counting the JobMedia records.
     */
    cnt.count = 0;
@@ -501,10 +501,10 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr)
       Dmsg0(050, "Count failed\n");
       goto bail_out;
    }
-      
+
    if (cnt.count == 0) {
       if (strcmp(mr->VolStatus, "Purged") != 0 && verbose) {
-         bsendmsg(ua, "There are no Jobs associated with Volume \"%s\". Marking it purged.\n",
+        bsendmsg(ua, "There are no Jobs associated with Volume \"%s\". Marking it purged.\n",
            mr->VolumeName);
       }
       stat = mark_media_purged(ua, mr);
@@ -514,10 +514,10 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr)
    if (cnt.count < MAX_DEL_LIST_LEN) {
       del.max_ids = cnt.count + 1;
    } else {
-      del.max_ids = MAX_DEL_LIST_LEN; 
+      del.max_ids = MAX_DEL_LIST_LEN;
    }
 
-   /* 
+   /*
     * Now get a list of JobIds for Jobs written to this Volume
     *  Could optimize here by adding JobTDate > (now - period).
     */
@@ -525,7 +525,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr)
    Mmsg(query, sel_JobMedia, mr->MediaId);
    if (!db_sql_query(ua->db, query, file_delete_handler, (void *)&del)) {
       if (ua->verbose) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       Dmsg0(050, "Count failed\n");
       goto bail_out;
@@ -562,7 +562,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr)
    }
    if (ua->verbose && del.num_del != 0) {
       bsendmsg(ua, _("Pruned %d %s on Volume \"%s\" from catalog.\n"), del.num_del,
-         del.num_del == 1 ? "Job" : "Jobs", mr->VolumeName);
+        del.num_del == 1 ? "Job" : "Jobs", mr->VolumeName);
    }
 
    /* If purged, mark it so */
index 87d43b3d76d5d282f039e572167689c98e4619f8..349fc68e2c8c1116778ad374351afde233c90dcf 100644 (file)
@@ -79,7 +79,7 @@ struct s_count_ctx {
 };
 
 /*
- * Called here to count entries to be deleted 
+ * Called here to count entries to be deleted
  */
 static int count_handler(void *ctx, int num_fields, char **row)
 {
@@ -94,7 +94,7 @@ static int count_handler(void *ctx, int num_fields, char **row)
 }
 
 /*
- * Called here to count entries to be deleted 
+ * Called here to count entries to be deleted
  */
 static int file_count_handler(void *ctx, int num_fields, char **row)
 {
@@ -124,7 +124,7 @@ static int job_delete_handler(void *ctx, int num_fields, char **row)
 {
    struct s_job_del_ctx *del = (struct s_job_del_ctx *)ctx;
 
-   if (del->num_ids == MAX_DEL_LIST_LEN) {  
+   if (del->num_ids == MAX_DEL_LIST_LEN) {
       return 1;
    }
    if (del->num_ids == del->max_ids) {
@@ -141,7 +141,7 @@ static int file_delete_handler(void *ctx, int num_fields, char **row)
 {
    struct s_file_del_ctx *del = (struct s_file_del_ctx *)ctx;
 
-   if (del->num_ids == MAX_DEL_LIST_LEN) {  
+   if (del->num_ids == MAX_DEL_LIST_LEN) {
       return 1;
    }
    if (del->num_ids == del->max_ids) {
@@ -184,13 +184,13 @@ int purgecmd(UAContext *ua, const char *cmd)
       N_("Client"),
       N_("Volume"),
       NULL};
-      
+
    bsendmsg(ua, _(
       "\nThis command is can be DANGEROUS!!!\n\n"
       "It purges (deletes) all Files from a Job,\n"
       "JobId, Client or Volume; or it purges (deletes)\n"
       "all Jobs from a Client or Volume without regard\n"
-      "for retention periods. Normally you should use the\n" 
+      "for retention periods. Normally you should use the\n"
       "PRUNE command, which respects retention periods.\n"));
 
    if (!open_db(ua)) {
@@ -240,7 +240,7 @@ int purgecmd(UAContext *ua, const char *cmd)
            purge_jobs_from_volume(ua, &mr);
         }
         *ua->argk[i] = 0;            /* zap keyword already seen */
-         bsendmsg(ua, "\n");
+        bsendmsg(ua, "\n");
       }
       return 1;
    default:
@@ -294,13 +294,13 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client)
    Mmsg(query, select_jobsfiles_from_client, cr.ClientId);
 
    Dmsg1(050, "select sql=%s\n", query);
+
    if (!db_sql_query(ua->db, query, file_count_handler, (void *)&del)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
       Dmsg0(050, "Count failed\n");
       goto bail_out;
    }
-      
+
    if (del.tot_ids == 0) {
       bsendmsg(ua, _("No Files found for client %s to purge from %s catalog.\n"),
         client->hdr.name, client->catalog->hdr.name);
@@ -310,7 +310,7 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client)
    if (del.tot_ids < MAX_DEL_LIST_LEN) {
       del.max_ids = del.tot_ids + 1;
    } else {
-      del.max_ids = MAX_DEL_LIST_LEN; 
+      del.max_ids = MAX_DEL_LIST_LEN;
    }
    del.tot_ids = 0;
 
@@ -322,7 +322,7 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client)
       Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]);
       Mmsg(query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]);
       db_sql_query(ua->db, query, NULL, (void *)NULL);
-      /* 
+      /*
        * Now mark Job as having files purged. This is necessary to
        * avoid having too many Jobs to process in future prunings. If
        * we don't do this, the number of JobId's in our in memory list
@@ -334,7 +334,7 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client)
    }
    bsendmsg(ua, _("%d Files for client \"%s\" purged from %s catalog.\n"), del.num_ids,
       client->hdr.name, client->catalog->hdr.name);
-   
+
 bail_out:
    if (del.JobId) {
       free(del.JobId);
@@ -372,7 +372,7 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client)
    Mmsg(query, select_jobs_from_client, cr.ClientId);
 
    Dmsg1(050, "select sql=%s\n", query);
+
    if (!db_sql_query(ua->db, query, job_count_handler, (void *)&del)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
       Dmsg0(050, "Count failed\n");
@@ -387,7 +387,7 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client)
    if (del.tot_ids < MAX_DEL_LIST_LEN) {
       del.max_ids = del.tot_ids + 1;
    } else {
-      del.max_ids = MAX_DEL_LIST_LEN; 
+      del.max_ids = MAX_DEL_LIST_LEN;
    }
 
    del.tot_ids = 0;
@@ -397,7 +397,7 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client)
 
    db_sql_query(ua->db, query, job_delete_handler, (void *)&del);
 
-   /* 
+   /*
     * OK, now we have the list of JobId's to be purged, first check
     * if the Files have been purged, if not, purge (delete) them.
     * Then delete the Job entry, and finally and JobMedia records.
@@ -405,9 +405,9 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client)
    for (i=0; i < del.num_ids; i++) {
       Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]);
       if (!del.PurgedFiles[i]) {
-         Mmsg(query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]);
+        Mmsg(query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]);
         db_sql_query(ua->db, query, NULL, (void *)NULL);
-         Dmsg1(050, "Del sql=%s\n", query);
+        Dmsg1(050, "Del sql=%s\n", query);
       }
 
       Mmsg(query, "DELETE FROM Job WHERE JobId=%d", del.JobId[i]);
@@ -420,7 +420,7 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client)
    }
    bsendmsg(ua, _("%d Jobs for client %s purged from %s catalog.\n"), del.num_ids,
       client->hdr.name, client->catalog->hdr.name);
-   
+
 bail_out:
    if (del.JobId) {
       free(del.JobId);
@@ -435,7 +435,7 @@ bail_out:
 void purge_files_from_job(UAContext *ua, JOB_DBR *jr)
 {
    char *query = (char *)get_pool_memory(PM_MESSAGE);
-   
+
    Mmsg(query, "DELETE FROM File WHERE JobId=%u", jr->JobId);
    db_sql_query(ua->db, query, NULL, (void *)NULL);
 
@@ -445,14 +445,14 @@ void purge_files_from_job(UAContext *ua, JOB_DBR *jr)
    free_pool_memory(query);
 }
 
-void purge_files_from_volume(UAContext *ua, MEDIA_DBR *mr ) 
+void purge_files_from_volume(UAContext *ua, MEDIA_DBR *mr )
 {} /* ***FIXME*** implement */
 
 /*
  * Returns: 1 if Volume purged
  *         0 if Volume not purged
  */
-int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) 
+int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr)
 {
    char *query = (char *)get_pool_memory(PM_MESSAGE);
    struct s_count_ctx cnt;
@@ -460,18 +460,18 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr)
    int i, stat = 0;
    JOB_DBR jr;
 
-   stat = strcmp(mr->VolStatus, "Append") == 0 || 
-          strcmp(mr->VolStatus, "Full")   == 0 ||
-          strcmp(mr->VolStatus, "Used")   == 0 || 
-          strcmp(mr->VolStatus, "Error")  == 0; 
+   stat = strcmp(mr->VolStatus, "Append") == 0 ||
+         strcmp(mr->VolStatus, "Full")   == 0 ||
+         strcmp(mr->VolStatus, "Used")   == 0 ||
+         strcmp(mr->VolStatus, "Error")  == 0;
    if (!stat) {
       bsendmsg(ua, "\n");
       bsendmsg(ua, _("Volume \"%s\" has VolStatus \"%s\" and cannot be purged.\n"
-                     "The VolStatus must be: Append, Full, Used, or Error to be purged.\n"),
+                    "The VolStatus must be: Append, Full, Used, or Error to be purged.\n"),
                     mr->VolumeName, mr->VolStatus);
       goto bail_out;
    }
-   
+
    memset(&jr, 0, sizeof(jr));
    memset(&del, 0, sizeof(del));
    cnt.count = 0;
@@ -481,12 +481,12 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr)
       Dmsg0(050, "Count failed\n");
       goto bail_out;
    }
-      
+
    if (cnt.count == 0) {
       bsendmsg(ua, "There are no Jobs associated with Volume \"%s\". Marking it purged.\n",
         mr->VolumeName);
       if (!mark_media_purged(ua, mr)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
         goto bail_out;
       }
       goto bail_out;
@@ -495,11 +495,11 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr)
    if (cnt.count < MAX_DEL_LIST_LEN) {
       del.max_ids = cnt.count + 1;
    } else {
-      del.max_ids = MAX_DEL_LIST_LEN; 
+      del.max_ids = MAX_DEL_LIST_LEN;
    }
 
    /*
-    * Check if he wants to purge a single jobid 
+    * Check if he wants to purge a single jobid
     */
    i = find_arg_with_value(ua, "jobid");
    if (i >= 0) {
@@ -507,15 +507,15 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr)
       del.num_ids = 1;
       del.JobId[0] = str_to_int64(ua->argv[i]);
    } else {
-      /* 
-       * Purge ALL JobIds 
+      /*
+       * Purge ALL JobIds
        */
       del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids);
 
       Mmsg(query, "SELECT JobId FROM JobMedia WHERE MediaId=%d", mr->MediaId);
       if (!db_sql_query(ua->db, query, file_delete_handler, (void *)&del)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
-         Dmsg0(050, "Count failed\n");
+        bsendmsg(ua, "%s", db_strerror(ua->db));
+        Dmsg0(050, "Count failed\n");
         goto bail_out;
       }
    }
@@ -545,17 +545,17 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr)
       Dmsg0(050, "Count failed\n");
       goto bail_out;
    }
-      
+
    if (cnt.count == 0) {
       bsendmsg(ua, "There are no more Jobs associated with Volume \"%s\". Marking it purged.\n",
         mr->VolumeName);
       if (!(stat = mark_media_purged(ua, mr))) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
         goto bail_out;
       }
    }
 
-bail_out:   
+bail_out:
    free_pool_memory(query);
    return stat;
 }
@@ -566,9 +566,9 @@ bail_out:
  */
 int mark_media_purged(UAContext *ua, MEDIA_DBR *mr)
 {
-   if (strcmp(mr->VolStatus, "Append") == 0 || 
+   if (strcmp(mr->VolStatus, "Append") == 0 ||
        strcmp(mr->VolStatus, "Full")   == 0 ||
-       strcmp(mr->VolStatus, "Used")   == 0 || 
+       strcmp(mr->VolStatus, "Used")   == 0 ||
        strcmp(mr->VolStatus, "Error")  == 0) {
       bstrncpy(mr->VolStatus, "Purged", sizeof(mr->VolStatus));
       if (!db_update_media_record(ua->jcr, ua->db, mr)) {
index 5cf84260a3c6ab18166627271b7e0851460b8c89..9b18ac9406972c70dc089cec07ac4dbb66fad607 100644 (file)
@@ -32,7 +32,7 @@
 
 extern DIRRES *director;
 
-static POOLMEM *substitute_prompts(UAContext *ua, 
+static POOLMEM *substitute_prompts(UAContext *ua,
                       POOLMEM *query, char **prompt, int nprompt);
 
 /*
@@ -57,7 +57,7 @@ int querycmd(UAContext *ua, const char *cmd)
    char *prompt[9];
    int nprompt = 0;;
    char *query_file = director->query_file;
-   
+
    if (!open_db(ua)) {
       goto bail_out;
    }
@@ -106,16 +106,16 @@ int querycmd(UAContext *ua, const char *cmd)
       len = strlen(line);
       if (line[0] == '*') {            /* prompt */
         if (nprompt >= 9) {
-            bsendmsg(ua, _("Too many prompts in query, max is 9.\n"));
+           bsendmsg(ua, _("Too many prompts in query, max is 9.\n"));
         } else {
-            line[len++] = ' ';
+           line[len++] = ' ';
            line[len] = 0;
            prompt[nprompt++] = bstrdup(line+1);
            continue;
         }
-      }  
+      }
       if (*query != 0) {
-         pm_strcat(query, " ");
+        pm_strcat(query, " ");
       }
       pm_strcat(query, line);
       if (line[len-1] != ';') {
@@ -124,11 +124,11 @@ int querycmd(UAContext *ua, const char *cmd)
       line[len-1] = 0;            /* zap ; */
       if (query[0] != 0) {
         query = substitute_prompts(ua, query, prompt, nprompt);
-         Dmsg1(100, "Query2=%s\n", query);
-         if (query[0] == '!') {
+        Dmsg1(100, "Query2=%s\n", query);
+        if (query[0] == '!') {
            db_list_sql_query(ua->jcr, ua->db, query+1, prtit, ua, 0, VERT_LIST);
         } else if (!db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST)) {
-            bsendmsg(ua, "%s\n", query);
+           bsendmsg(ua, "%s\n", query);
         }
         query[0] = 0;
       }
@@ -137,10 +137,10 @@ int querycmd(UAContext *ua, const char *cmd)
    if (query[0] != 0) {
       query = substitute_prompts(ua, query, prompt, nprompt);
       Dmsg1(100, "Query2=%s\n", query);
-         if (query[0] == '!') {
+        if (query[0] == '!') {
            db_list_sql_query(ua->jcr, ua->db, query+1, prtit, ua, 0, VERT_LIST);
         } else if (!db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST)) {
-            bsendmsg(ua, "%s\n", query);
+           bsendmsg(ua, "%s\n", query);
         }
    }
 
@@ -155,7 +155,7 @@ bail_out:
    return 1;
 }
 
-static POOLMEM *substitute_prompts(UAContext *ua, 
+static POOLMEM *substitute_prompts(UAContext *ua,
                       POOLMEM *query, char **prompt, int nprompt)
 {
    char *p, *q, *o;
@@ -181,16 +181,16 @@ static POOLMEM *substitute_prompts(UAContext *ua,
         }
         p++;
         switch (*p) {
-         case '1':
-         case '2':
-         case '3':
-         case '4':
-         case '5':
-         case '6':
-         case '7':
-         case '8':
-         case '9':
-            n = (int)(*p) - (int)'1';
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+           n = (int)(*p) - (int)'1';
            if (prompt[n]) {
               if (!subst[n]) {
                  if (!get_cmd(ua, prompt[n])) {
@@ -209,16 +209,16 @@ static POOLMEM *substitute_prompts(UAContext *ua,
                  *o++ = *p++;
               }
            } else {
-               bsendmsg(ua, _("Warning prompt %d missing.\n"), n+1);
+              bsendmsg(ua, _("Warning prompt %d missing.\n"), n+1);
            }
            q += 2;
            break;
-         case '%':
-            *o++ = '%';
+        case '%':
+           *o++ = '%';
            q += 2;
            break;
         default:
-            *o++ = '%';
+           *o++ = '%';
            q++;
            break;
         }
@@ -255,9 +255,9 @@ int sqlquerycmd(UAContext *ua, const char *cmd)
    }
    *query = 0;
 
-   bsendmsg(ua, _("Entering SQL query mode.\n\
-Terminate each query with a semicolon.\n\
-Terminate query mode with a blank line.\n"));
+   bsendmsg(ua, _("Entering SQL query mode.\n"
+"Terminate each query with a semicolon.\n"
+"Terminate query mode with a blank line.\n"));
    msg = "Enter SQL query: ";
    while (get_cmd(ua, msg)) {
       len = strlen(ua->cmd);
@@ -267,7 +267,7 @@ Terminate query mode with a blank line.\n"));
       }
       query = check_pool_memory_size(query, len + 1);
       if (*query != 0) {
-         strcat(query, " ");
+        strcat(query, " ");
       }
       strcat(query, ua->cmd);
       if (ua->cmd[len-1] == ';') {
@@ -275,12 +275,12 @@ Terminate query mode with a blank line.\n"));
         /* Submit query */
         db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST);
         *query = 0;                  /* start new query */
-         msg = _("Enter SQL query: ");
+        msg = _("Enter SQL query: ");
       } else {
-         msg = _("Add to SQL query: ");
+        msg = _("Add to SQL query: ");
       }
    }
    free_pool_memory(query);
    bsendmsg(ua, _("End query mode.\n"));
-   return 1; 
+   return 1;
 }
index 7f0d5eb8a496dbc99cc90db1519c65373f7441a8..a62b4ec9612dde4d852197529ced8a93e5ff9387 100644 (file)
@@ -149,12 +149,12 @@ int restore_cmd(UAContext *ua, const char *cmd)
    UnlockRes();
    if (!rx.restore_jobs) {
       bsendmsg(ua, _(
-         "No Restore Job Resource found. You must create at least\n"
-         "one before running this command.\n"));
+        "No Restore Job Resource found. You must create at least\n"
+        "one before running this command.\n"));
       goto bail_out;
    }
 
-   /* 
+   /*
     * Request user to select JobIds or files by various different methods
     *  last 20 jobs, where File saved, most recent backup, ...
     *  In the end, a list of files are pumped into
@@ -165,7 +165,7 @@ int restore_cmd(UAContext *ua, const char *cmd)
       goto bail_out;
    case 1:                           /* select by jobid */
       if (!build_directory_tree(ua, &rx)) {
-         bsendmsg(ua, _("Restore not done.\n"));
+        bsendmsg(ua, _("Restore not done.\n"));
         goto bail_out;
       }
       break;
@@ -175,14 +175,14 @@ int restore_cmd(UAContext *ua, const char *cmd)
 
    if (rx.bsr->JobId) {
       if (!complete_bsr(ua, rx.bsr)) {  /* find Vol, SessId, SessTime from JobIds */
-         bsendmsg(ua, _("Unable to construct a valid BSR. Cannot continue.\n"));
+        bsendmsg(ua, _("Unable to construct a valid BSR. Cannot continue.\n"));
         goto bail_out;
       }
       if (!write_bsr_file(ua, rx.bsr)) {
         goto bail_out;
       }
       bsendmsg(ua, _("\n%u file%s selected to be restored.\n\n"), rx.selected_files,
-         rx.selected_files==1?"":"s");
+        rx.selected_files==1?"":"s");
    } else {
       bsendmsg(ua, _("No files selected to be restored.\n"));
       goto bail_out;
@@ -205,16 +205,16 @@ int restore_cmd(UAContext *ua, const char *cmd)
 
    /* Build run command */
    if (rx.where) {
-      Mmsg(ua->cmd, 
-          "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\""
-          " where=\"%s\" files=%d catalog=\"%s\"",
-          job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"",
+      Mmsg(ua->cmd,
+         "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\""
+         " where=\"%s\" files=%d catalog=\"%s\"",
+         job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"",
          working_directory, rx.where, rx.selected_files, ua->catalog->hdr.name);
    } else {
-      Mmsg(ua->cmd, 
-          "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\""
-          " files=%d catalog=\"%s\"",
-          job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"",
+      Mmsg(ua->cmd,
+         "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\""
+         " files=%d catalog=\"%s\"",
+         job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"",
          working_directory, rx.selected_files, ua->catalog->hdr.name);
    }
    if (find_arg(ua, _("yes")) > 0) {
@@ -232,7 +232,7 @@ bail_out:
 
 }
 
-static void free_rx(RESTORE_CTX *rx) 
+static void free_rx(RESTORE_CTX *rx)
 {
    free_bsr(rx->bsr);
    rx->bsr = NULL;
@@ -276,7 +276,7 @@ static int get_client_name(UAContext *ua, RESTORE_CTX *rx)
 }
 
 /*
- * The first step in the restore process is for the user to 
+ * The first step in the restore process is for the user to
  *  select a list of JobIds from which he will subsequently
  *  select which files are to be restored.
  */
@@ -289,11 +289,11 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
    JOB_DBR jr;
    bool done = false;
    int i, j;
-   const char *list[] = { 
+   const char *list[] = {
       "List last 20 Jobs run",
       "List Jobs where a given File is saved",
       "Enter list of comma separated JobIds to select",
-      "Enter SQL list command", 
+      "Enter SQL list command",
       "Select the most recent backup for a client",
       "Select backup for a client before a specified time",
       "Enter a list of files to restore",
@@ -329,14 +329,14 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
         }
       }
       if (!found_kw) {
-         bsendmsg(ua, _("Unknown keyword: %s\n"), ua->argk[i]);
+        bsendmsg(ua, _("Unknown keyword: %s\n"), ua->argk[i]);
         return 0;
       }
       /* Found keyword in kw[] list, process it */
       switch (j) {
       case 0:                           /* jobid */
         if (*rx->JobIds != 0) {
-            pm_strcat(rx->JobIds, ",");
+           pm_strcat(rx->JobIds, ",");
         }
         pm_strcat(rx->JobIds, ua->argv[i]);
         done = true;
@@ -347,7 +347,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
         break;
       case 2:                           /* before */
         if (str_to_utime(ua->argv[i]) == 0) {
-            bsendmsg(ua, _("Improper date format: %s\n"), ua->argv[i]);
+           bsendmsg(ua, _("Improper date format: %s\n"), ua->argv[i]);
            return 0;
         }
         bstrncpy(date, ua->argv[i], sizeof(date));
@@ -380,19 +380,19 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
       case 5:                           /* pool specified */
         rx->pool = (POOL *)GetResWithName(R_POOL, ua->argv[i]);
         if (!rx->pool) {
-            bsendmsg(ua, _("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]);
+           bsendmsg(ua, _("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]);
            return 0;
         }
         if (!acl_access_ok(ua, Pool_ACL, ua->argv[i])) {
            rx->pool = NULL;
-            bsendmsg(ua, _("Error: Pool resource \"%s\" access not allowed.\n"), ua->argv[i]);
+           bsendmsg(ua, _("Error: Pool resource \"%s\" access not allowed.\n"), ua->argv[i]);
            return 0;
         }
         break;
       case 6:                        /* all specified */
         rx->all = true;
         break;
-      /*     
+      /*
        * All keywords 7 or greater are ignored or handled by a select prompt
        */
       default:
@@ -402,12 +402,12 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
    if (rx->name_list.num_ids) {
       return 2;                      /* filename list made */
    }
-       
+
    if (!done) {
       bsendmsg(ua, _("\nFirst you select one or more JobIds that contain files\n"
-                  "to be restored. You will be presented several methods\n"
-                  "of specifying the JobIds. Then you will be allowed to\n"
-                  "select which files from those JobIds are to be restored.\n\n"));
+                 "to be restored. You will be presented several methods\n"
+                 "of specifying the JobIds. Then you will be allowed to\n"
+                 "select which files from those JobIds are to be restored.\n\n"));
    }
 
    /* If choice not already made above, prompt */
@@ -432,7 +432,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
         done = false;
         break;
       case 1:                        /* list where a file is saved */
-         if (!get_cmd(ua, _("Enter Filename (no path):"))) {
+        if (!get_cmd(ua, _("Enter Filename (no path):"))) {
            return 0;
         }
         len = strlen(ua->cmd);
@@ -447,13 +447,13 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
         done = false;
         break;
       case 2:                        /* enter a list of JobIds */
-         if (!get_cmd(ua, _("Enter JobId(s), comma separated, to restore: "))) {
+        if (!get_cmd(ua, _("Enter JobId(s), comma separated, to restore: "))) {
            return 0;
         }
         pm_strcpy(rx->JobIds, ua->cmd);
         break;
       case 3:                        /* Enter an SQL list command */
-         if (!get_cmd(ua, _("Enter SQL list command: "))) {
+        if (!get_cmd(ua, _("Enter SQL list command: "))) {
            return 0;
         }
         gui_save = ua->jcr->gui;
@@ -481,11 +481,11 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
         if (!get_client_name(ua, rx)) {
            return 0;
         }
-         bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n"      
-                        "containg a list of file names with paths, and terminate\n"
-                        "them with a blank line.\n"));
+        bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n"
+                       "containg a list of file names with paths, and terminate\n"
+                       "them with a blank line.\n"));
         for ( ;; ) {
-            if (!get_cmd(ua, _("Enter full filename: "))) {
+           if (!get_cmd(ua, _("Enter full filename: "))) {
               return 0;
            }
            len = strlen(ua->cmd);
@@ -506,11 +506,11 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
         if (!get_client_name(ua, rx)) {
            return 0;
         }
-         bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n"      
-                        "containg a list of file names with paths, and terminate\n"
-                        "them with a blank line.\n"));
+        bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n"
+                       "containg a list of file names with paths, and terminate\n"
+                       "them with a blank line.\n"));
         for ( ;; ) {
-            if (!get_cmd(ua, _("Enter full filename: "))) {
+           if (!get_cmd(ua, _("Enter full filename: "))) {
               return 0;
            }
            len = strlen(ua->cmd);
@@ -525,7 +525,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
         }
         return 2;
 
-      
+
       case 8:                        /* Cancel or quit */
         return 0;
       }
@@ -535,7 +535,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
       bsendmsg(ua, _("No Jobs selected.\n"));
       return 0;
    }
-   bsendmsg(ua, _("You have selected the following JobId%s: %s\n"), 
+   bsendmsg(ua, _("You have selected the following JobId%s: %s\n"),
       strchr(rx->JobIds,',')?"s":"",rx->JobIds);
 
    memset(&jr, 0, sizeof(JOB_DBR));
@@ -544,7 +544,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
    for (p=rx->JobIds; ; ) {
       int stat = get_next_jobid_from_list(&p, &JobId);
       if (stat < 0) {
-         bsendmsg(ua, _("Invalid JobId in list.\n"));
+        bsendmsg(ua, _("Invalid JobId in list.\n"));
         return 0;
       }
       if (stat == 0) {
@@ -555,27 +555,27 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
       }
       jr.JobId = JobId;
       if (!db_get_job_record(ua->jcr, ua->db, &jr)) {
-         bsendmsg(ua, _("Unable to get Job record for JobId=%u: ERR=%s\n"), 
+        bsendmsg(ua, _("Unable to get Job record for JobId=%u: ERR=%s\n"),
            JobId, db_strerror(ua->db));
         return 0;
       }
       if (!acl_access_ok(ua, Job_ACL, jr.Name)) {
-         bsendmsg(ua, _("No authorization. Job \"%s\" not selected.\n"), 
+        bsendmsg(ua, _("No authorization. Job \"%s\" not selected.\n"),
            jr.Name);
-        continue; 
+        continue;
       }
       rx->TotalFiles += jr.JobFiles;
    }
    return 1;
 }
 
-/* 
+/*
  * Get date from user
  */
 static int get_date(UAContext *ua, char *date, int date_len)
 {
    bsendmsg(ua, _("The restored files will the most current backup\n"
-                  "BEFORE the date you specify below.\n\n"));
+                 "BEFORE the date you specify below.\n\n"));
    for ( ;; ) {
       if (!get_cmd(ua, _("Enter date as YYYY-MM-DD HH:MM:SS :"))) {
         return 0;
@@ -584,13 +584,13 @@ static int get_date(UAContext *ua, char *date, int date_len)
         break;
       }
       bsendmsg(ua, _("Improper date format.\n"));
-   }             
+   }
    bstrncpy(date, ua->cmd, date_len);
    return 1;
 }
 
 /*
- * Insert a single file, or read a list of files from a file 
+ * Insert a single file, or read a list of files from a file
  */
 static void insert_one_file(UAContext *ua, RESTORE_CTX *rx, char *date)
 {
@@ -598,19 +598,19 @@ static void insert_one_file(UAContext *ua, RESTORE_CTX *rx, char *date)
    char file[5000];
    char *p = ua->cmd;
    int line = 0;
-  
+
    switch (*p) {
    case '<':
       p++;
       if ((ffd = fopen(p, "r")) == NULL) {
-         bsendmsg(ua, _("Cannot open file %s: ERR=%s\n"),
+        bsendmsg(ua, _("Cannot open file %s: ERR=%s\n"),
            p, strerror(errno));
         break;
       }
       while (fgets(file, sizeof(file), ffd)) {
         line++;
         if (!insert_file_into_findex_list(ua, rx, file, date)) {
-            bsendmsg(ua, _("Error occurred on line %d of %s\n"), line, p);
+           bsendmsg(ua, _("Error occurred on line %d of %s\n"), line, p);
         }
       }
       fclose(ffd);
@@ -626,7 +626,7 @@ static void insert_one_file(UAContext *ua, RESTORE_CTX *rx, char *date)
  *   lookup the most recent backup in the catalog to get the JobId
  *   and FileIndex, then insert them into the findex list.
  */
-static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *file, 
+static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *file,
                                        char *date)
 {
    strip_trailing_junk(file);
@@ -634,13 +634,13 @@ static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *fi
    if (*rx->JobIds == 0) {
       Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName);
    } else {
-      Mmsg(rx->query, uar_jobids_fileindex, rx->JobIds, date, 
+      Mmsg(rx->query, uar_jobids_fileindex, rx->JobIds, date,
           rx->path, rx->fname, rx->ClientName);
    }
    rx->found = false;
    /* Find and insert jobid and File Index */
    if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) {
-      bsendmsg(ua, _("Query failed: %s. ERR=%s\n"), 
+      bsendmsg(ua, _("Query failed: %s. ERR=%s\n"),
         rx->query, db_strerror(ua->db));
    }
    if (!rx->found) {
@@ -663,7 +663,7 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name)
 {
    char *p, *f;
 
-   /* Find path without the filename.  
+   /* Find path without the filename.
     * I.e. everything after the last / is a "filename".
     * OK, maybe it is a directory name, but we treat it like
     * a filename. If we don't find a / then the whole name
@@ -681,7 +681,7 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name)
    }
 
    /* If filename doesn't exist (i.e. root directory), we
-    * simply create a blank name consisting of a single 
+    * simply create a blank name consisting of a single
     * space. This makes handling zero length filenames
     * easier.
     */
@@ -695,7 +695,7 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name)
       rx->fnl = 0;
    }
 
-   rx->pnl = f - name;   
+   rx->pnl = f - name;
    if (rx->pnl > 0) {
       rx->path = check_pool_memory_size(rx->path, rx->pnl+1);
       memcpy(rx->path, name, rx->pnl);
@@ -716,7 +716,7 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx)
    bool OK = true;
 
    memset(&tree, 0, sizeof(TREE_CTX));
-   /* 
+   /*
     * Build the directory tree containing JobIds user selected
     */
    tree.root = new_tree(rx->TotalFiles);
@@ -734,7 +734,7 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx)
       /* Use first JobId as estimate of the number of files to restore */
       Mmsg(rx->query, uar_count_files, JobId);
       if (!db_sql_query(ua->db, rx->query, count_handler, (void *)rx)) {
-         bsendmsg(ua, "%s\n", db_strerror(ua->db));
+        bsendmsg(ua, "%s\n", db_strerror(ua->db));
       }
       if (rx->found) {
         /* Add about 25% more than this job for over estimate */
@@ -744,7 +744,7 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx)
    }
    for (p=rx->JobIds; get_next_jobid_from_list(&p, &JobId) > 0; ) {
 
-      if (JobId == last_JobId) {            
+      if (JobId == last_JobId) {
         continue;                    /* eliminate duplicate JobIds */
       }
       last_JobId = JobId;
@@ -755,18 +755,18 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx)
        */
       Mmsg(rx->query, uar_sel_files, JobId);
       if (!db_sql_query(ua->db, rx->query, insert_tree_handler, (void *)&tree)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       /*
        * Find the MediaTypes for this JobId and add to the name_list
        */
       Mmsg(rx->query, uar_mediatype, JobId);
       if (!db_sql_query(ua->db, rx->query, unique_name_list_handler, (void *)&rx->name_list)) {
-         bsendmsg(ua, "%s", db_strerror(ua->db));
+        bsendmsg(ua, "%s", db_strerror(ua->db));
       }
    }
    char ec1[50];
-   bsendmsg(ua, "\n%d Job%s, %s files inserted into the tree%s.\n", 
+   bsendmsg(ua, "\n%d Job%s, %s files inserted into the tree%s.\n",
       items, items==1?"":"s", edit_uint64_with_commas(tree.FileCount, ec1),
       tree.all?" and marked for extraction":"");
 
@@ -779,14 +779,14 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx)
    }
 
    /*
-    * Walk down through the tree finding all files marked to be 
+    * Walk down through the tree finding all files marked to be
     *  extracted making a bootstrap file.
     */
    if (OK) {
       for (TREE_NODE *node=first_tree_node(tree.root); node; node=next_tree_node(node)) {
-         Dmsg2(400, "FI=%d node=0x%x\n", node->FileIndex, node);
+        Dmsg2(400, "FI=%d node=0x%x\n", node->FileIndex, node);
         if (node->extract || node->extract_dir) {
-            Dmsg2(400, "type=%d FI=%d\n", node->type, node->FileIndex);
+           Dmsg2(400, "type=%d FI=%d\n", node->type, node->FileIndex);
            add_findex(rx->bsr, node->JobId, node->FileIndex);
            if (node->extract && node->type != TN_NEWDIR) {
               rx->selected_files++;  /* count only saved files */
@@ -834,14 +834,14 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date
    bstrncpy(rx->ClientName, cr.Name, sizeof(rx->ClientName));
 
    /*
-    * Get FileSet 
+    * Get FileSet
     */
    memset(&fsr, 0, sizeof(fsr));
-   i = find_arg_with_value(ua, "FileSet"); 
+   i = find_arg_with_value(ua, "FileSet");
    if (i >= 0) {
       bstrncpy(fsr.FileSet, ua->argv[i], sizeof(fsr.FileSet));
       if (!db_get_fileset_record(ua->jcr, ua->db, &fsr)) {
-         bsendmsg(ua, _("Error getting FileSet \"%s\": ERR=%s\n"), fsr.FileSet, 
+        bsendmsg(ua, _("Error getting FileSet \"%s\": ERR=%s\n"), fsr.FileSet,
            db_strerror(ua->db));
         i = -1;
       }
@@ -850,18 +850,18 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date
       Mmsg(rx->query, uar_sel_fileset, cr.ClientId, cr.ClientId);
       start_prompt(ua, _("The defined FileSet resources are:\n"));
       if (!db_sql_query(ua->db, rx->query, fileset_handler, (void *)ua)) {
-         bsendmsg(ua, "%s\n", db_strerror(ua->db));
+        bsendmsg(ua, "%s\n", db_strerror(ua->db));
       }
-      if (do_prompt(ua, _("FileSet"), _("Select FileSet resource"), 
+      if (do_prompt(ua, _("FileSet"), _("Select FileSet resource"),
                 fileset_name, sizeof(fileset_name)) < 0) {
         goto bail_out;
       }
 
       bstrncpy(fsr.FileSet, fileset_name, sizeof(fsr.FileSet));
       if (!db_get_fileset_record(ua->jcr, ua->db, &fsr)) {
-         bsendmsg(ua, _("Error getting FileSet record: %s\n"), db_strerror(ua->db));
-         bsendmsg(ua, _("This probably means you modified the FileSet.\n"
-                     "Continuing anyway.\n"));
+        bsendmsg(ua, _("Error getting FileSet record: %s\n"), db_strerror(ua->db));
+        bsendmsg(ua, _("This probably means you modified the FileSet.\n"
+                    "Continuing anyway.\n"));
       }
    }
 
@@ -872,9 +872,9 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date
       memset(&pr, 0, sizeof(pr));
       bstrncpy(pr.Name, rx->pool->hdr.name, sizeof(pr.Name));
       if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
-         bsnprintf(pool_select, sizeof(pool_select), "AND Media.PoolId=%u ", pr.PoolId);
+        bsnprintf(pool_select, sizeof(pool_select), "AND Media.PoolId=%u ", pr.PoolId);
       } else {
-         bsendmsg(ua, _("Pool \"%s\" not found, using any pool.\n"), pr.Name);
+        bsendmsg(ua, _("Pool \"%s\" not found, using any pool.\n"), pr.Name);
       }
    }
 
@@ -937,11 +937,11 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date
       /* Display a list of Jobs selected for this restore */
       db_list_sql_query(ua->jcr, ua->db, uar_list_temp, prtit, ua, 1, HORZ_LIST);
    } else {
-      bsendmsg(ua, _("No jobs found.\n")); 
+      bsendmsg(ua, _("No jobs found.\n"));
    }
 
    stat = 1;
+
 bail_out:
    db_sql_query(ua->db, uar_del_temp, NULL, NULL);
    db_sql_query(ua->db, uar_del_temp1, NULL, NULL);
@@ -999,7 +999,7 @@ static int jobid_handler(void *ctx, int num_fields, char **row)
 {
    RESTORE_CTX *rx = (RESTORE_CTX *)ctx;
 
-   if (strcmp(rx->last_jobid, row[0]) == 0) {          
+   if (strcmp(rx->last_jobid, row[0]) == 0) {
       return 0;                      /* duplicate id */
    }
    bstrncpy(rx->last_jobid, row[0], sizeof(rx->last_jobid));
@@ -1018,7 +1018,7 @@ static int last_full_handler(void *ctx, int num_fields, char **row)
 {
    RESTORE_CTX *rx = (RESTORE_CTX *)ctx;
 
-   rx->JobTDate = str_to_int64(row[1]); 
+   rx->JobTDate = str_to_int64(row[1]);
    return 0;
 }
 
@@ -1044,7 +1044,7 @@ static int unique_name_list_handler(void *ctx, int num_fields, char **row)
 {
    NAME_LIST *name = (NAME_LIST *)ctx;
 
-   if (name->num_ids == MAX_ID_LIST_LEN) {  
+   if (name->num_ids == MAX_ID_LIST_LEN) {
       return 1;
    }
    if (name->num_ids == name->max_ids) {
@@ -1071,7 +1071,7 @@ static int unique_name_list_handler(void *ctx, int num_fields, char **row)
  * Print names in the list
  */
 static void print_name_list(UAContext *ua, NAME_LIST *name_list)
-{ 
+{
    for (int i=0; i < name_list->num_ids; i++) {
       bsendmsg(ua, "%s\n", name_list->name[i]);
    }
@@ -1082,7 +1082,7 @@ static void print_name_list(UAContext *ua, NAME_LIST *name_list)
  * Free names in the list
  */
 static void free_name_list(NAME_LIST *name_list)
-{ 
+{
    for (int i=0; i < name_list->num_ids; i++) {
       free(name_list->name[i]);
    }
@@ -1100,7 +1100,7 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST
 
    if (name_list->num_ids > 1) {
       bsendmsg(ua, _("Warning, the JobIds that you selected refer to more than one MediaType.\n"
-         "Restore is not possible. The MediaTypes used are:\n"));
+        "Restore is not possible. The MediaTypes used are:\n"));
       print_name_list(ua, name_list);
       rx->store = select_storage_resource(ua);
       return;
@@ -1115,7 +1115,7 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST
       return;
    }
    /*
-    * We have a single MediaType, look it up in our Storage resource 
+    * We have a single MediaType, look it up in our Storage resource
     */
    LockRes();
    foreach_res(store, R_STORAGE) {
@@ -1131,7 +1131,7 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST
    if (rx->store) {
       /* Check if an explicit storage resource is given */
       store = NULL;
-      int i = find_arg_with_value(ua, "storage");        
+      int i = find_arg_with_value(ua, "storage");
       if (i > 0) {
         store = (STORE *)GetResWithName(R_STORAGE, ua->argv[i]);
         if (store && !acl_access_ok(ua, Storage_ACL, store->hdr.name)) {
@@ -1139,7 +1139,7 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST
         }
       }
       if (store && (store != rx->store)) {
-         bsendmsg(ua, _("Warning default storage overridden by %s on command line.\n"),
+        bsendmsg(ua, _("Warning default storage overridden by %s on command line.\n"),
            store->hdr.name);
         rx->store = store;
       }
@@ -1151,8 +1151,8 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST
 
    if (!rx->store) {
       bsendmsg(ua, _("\nWarning. Unable to find Storage resource for\n"
-         "MediaType \"%s\", needed by the Jobs you selected.\n"
-         "You will be allowed to select a Storage device later.\n"),
-        name_list->name[0]); 
+        "MediaType \"%s\", needed by the Jobs you selected.\n"
+        "You will be allowed to select a Storage device later.\n"),
+        name_list->name[0]);
    }
 }
index 57c69c8263285133cdfcbfba290014079a80ac36..94dfb2d937016efe685a996be7dca2e58753edc0 100644 (file)
@@ -66,7 +66,7 @@ int run_cmd(UAContext *ua, const char *cmd)
       N_("job"),                      /*  Used in a switch() */
       N_("jobid"),                    /* 1 */
       N_("client"),                   /* 2 */
-      N_("fd"), 
+      N_("fd"),
       N_("fileset"),                  /* 4 */
       N_("level"),                    /* 5 */
       N_("storage"),                  /* 6 */
@@ -110,7 +110,7 @@ int run_cmd(UAContext *ua, const char *cmd)
       for (j=0; !kw_ok && kw[j]; j++) {
         if (strcasecmp(ua->argk[i], _(kw[j])) == 0) {
            /* Note, yes and run have no value, so do not err */
-           if (!ua->argv[i] && j != YES_POS /*yes*/) {  
+           if (!ua->argv[i] && j != YES_POS /*yes*/) {
                bsendmsg(ua, _("Value missing for keyword %s\n"), ua->argk[i]);
               return 1;
            }
@@ -126,7 +126,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 1: /* JobId */
               if (jid) {
-                  bsendmsg(ua, _("JobId specified twice.\n"));
+                 bsendmsg(ua, _("JobId specified twice.\n"));
                  return 0;
               }
               jid = ua->argv[i];
@@ -135,7 +135,7 @@ int run_cmd(UAContext *ua, const char *cmd)
            case 2: /* client */
            case 3: /* fd */
               if (client_name) {
-                  bsendmsg(ua, _("Client specified twice.\n"));
+                 bsendmsg(ua, _("Client specified twice.\n"));
                  return 0;
               }
               client_name = ua->argv[i];
@@ -143,7 +143,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 4: /* fileset */
               if (fileset_name) {
-                  bsendmsg(ua, _("FileSet specified twice.\n"));
+                 bsendmsg(ua, _("FileSet specified twice.\n"));
                  return 0;
               }
               fileset_name = ua->argv[i];
@@ -151,7 +151,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 5: /* level */
               if (level_name) {
-                  bsendmsg(ua, _("Level specified twice.\n"));
+                 bsendmsg(ua, _("Level specified twice.\n"));
                  return 0;
               }
               level_name = ua->argv[i];
@@ -160,7 +160,7 @@ int run_cmd(UAContext *ua, const char *cmd)
            case 6: /* storage */
            case 7: /* sd */
               if (store_name) {
-                  bsendmsg(ua, _("Storage specified twice.\n"));
+                 bsendmsg(ua, _("Storage specified twice.\n"));
                  return 0;
               }
               store_name = ua->argv[i];
@@ -168,7 +168,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 8: /* pool */
               if (pool_name) {
-                  bsendmsg(ua, _("Pool specified twice.\n"));
+                 bsendmsg(ua, _("Pool specified twice.\n"));
                  return 0;
               }
               pool_name = ua->argv[i];
@@ -176,7 +176,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 9: /* where */
               if (where) {
-                  bsendmsg(ua, _("Where specified twice.\n"));
+                 bsendmsg(ua, _("Where specified twice.\n"));
                  return 0;
               }
               where = ua->argv[i];
@@ -184,7 +184,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 10: /* bootstrap */
               if (bootstrap) {
-                  bsendmsg(ua, _("Bootstrap specified twice.\n"));
+                 bsendmsg(ua, _("Bootstrap specified twice.\n"));
                  return 0;
               }
               bootstrap = ua->argv[i];
@@ -192,7 +192,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 11: /* replace */
               if (replace) {
-                  bsendmsg(ua, _("Replace specified twice.\n"));
+                 bsendmsg(ua, _("Replace specified twice.\n"));
                  return 0;
               }
               replace = ua->argv[i];
@@ -200,7 +200,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 12: /* When */
               if (when) {
-                  bsendmsg(ua, _("When specified twice.\n"));
+                 bsendmsg(ua, _("When specified twice.\n"));
                  return 0;
               }
               when = ua->argv[i];
@@ -208,12 +208,12 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 13:  /* Priority */
               if (Priority) {
-                  bsendmsg(ua, _("Priority specified twice.\n"));
+                 bsendmsg(ua, _("Priority specified twice.\n"));
                  return 0;
               }
               Priority = atoi(ua->argv[i]);
               if (Priority <= 0) {
-                  bsendmsg(ua, _("Priority must be positive nonzero setting it to 10.\n"));
+                 bsendmsg(ua, _("Priority must be positive nonzero setting it to 10.\n"));
                  Priority = 10;
               }
               kw_ok = true;
@@ -223,7 +223,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               break;
            case 15: /* Verify Job */
               if (verify_job_name) {
-                  bsendmsg(ua, _("Verify Job specified twice.\n"));
+                 bsendmsg(ua, _("Verify Job specified twice.\n"));
                  return 0;
               }
               verify_job_name = ua->argv[i];
@@ -248,16 +248,16 @@ int run_cmd(UAContext *ua, const char *cmd)
        * End of keyword for loop -- if not found, we got a bogus keyword
        */
       if (!kw_ok) {
-         Dmsg1(200, "%s not found\n", ua->argk[i]);
+        Dmsg1(200, "%s not found\n", ua->argk[i]);
         /*
          * Special case for Job Name, it can be the first
          * keyword that has no value.
          */
         if (!job_name && !ua->argv[i]) {
            job_name = ua->argk[i];   /* use keyword as job name */
-            Dmsg1(200, "Set jobname=%s\n", job_name);
+           Dmsg1(200, "Set jobname=%s\n", job_name);
         } else {
-            bsendmsg(ua, _("Invalid keyword: %s\n"), ua->argk[i]);
+           bsendmsg(ua, _("Invalid keyword: %s\n"), ua->argk[i]);
            return 0;
         }
       }
@@ -269,7 +269,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    if (catalog_name != NULL) {
        catalog = (CAT *)GetResWithName(R_CATALOG, catalog_name);
        if (catalog == NULL) {
-            bsendmsg(ua, _("Catalog \"%s\" not found\n"), catalog_name);
+           bsendmsg(ua, _("Catalog \"%s\" not found\n"), catalog_name);
           return 0;
        }
    }
@@ -280,11 +280,11 @@ int run_cmd(UAContext *ua, const char *cmd)
       job = (JOB *)GetResWithName(R_JOB, job_name);
       if (!job) {
         if (*job_name != 0) {
-            bsendmsg(ua, _("Job \"%s\" not found\n"), job_name);
+           bsendmsg(ua, _("Job \"%s\" not found\n"), job_name);
         }
         job = select_job_resource(ua);
       } else {
-         Dmsg1(200, "Found job=%s\n", job_name);
+        Dmsg1(200, "Found job=%s\n", job_name);
       }
    } else {
       bsendmsg(ua, _("A job name must be specified.\n"));
@@ -302,7 +302,7 @@ int run_cmd(UAContext *ua, const char *cmd)
       store = (STORE *)GetResWithName(R_STORAGE, store_name);
       if (!store) {
         if (*store_name != 0) {
-            bsendmsg(ua, _("Storage \"%s\" not found.\n"), store_name);
+           bsendmsg(ua, _("Storage \"%s\" not found.\n"), store_name);
         }
         store = select_storage_resource(ua);
       }
@@ -322,7 +322,7 @@ int run_cmd(UAContext *ua, const char *cmd)
       pool = (POOL *)GetResWithName(R_POOL, pool_name);
       if (!pool) {
         if (*pool_name != 0) {
-            bsendmsg(ua, _("Pool \"%s\" not found.\n"), pool_name);
+           bsendmsg(ua, _("Pool \"%s\" not found.\n"), pool_name);
         }
         pool = select_pool_resource(ua);
       }
@@ -342,7 +342,7 @@ int run_cmd(UAContext *ua, const char *cmd)
       client = (CLIENT *)GetResWithName(R_CLIENT, client_name);
       if (!client) {
         if (*client_name != 0) {
-            bsendmsg(ua, _("Client \"%s\" not found.\n"), client_name);
+           bsendmsg(ua, _("Client \"%s\" not found.\n"), client_name);
         }
         client = select_client_resource(ua);
       }
@@ -361,7 +361,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    if (fileset_name) {
       fileset = (FILESET *)GetResWithName(R_FILESET, fileset_name);
       if (!fileset) {
-         bsendmsg(ua, _("FileSet \"%s\" not found.\n"), fileset_name);
+        bsendmsg(ua, _("FileSet \"%s\" not found.\n"), fileset_name);
         fileset = select_fileset_resource(ua);
       }
    } else {
@@ -378,7 +378,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    if (verify_job_name) {
       verify_job = (JOB *)GetResWithName(R_JOB, verify_job_name);
       if (!verify_job) {
-         bsendmsg(ua, _("Verify Job \"%s\" not found.\n"), verify_job_name);
+        bsendmsg(ua, _("Verify Job \"%s\" not found.\n"), verify_job_name);
         verify_job = select_job_resource(ua);
       }
    } else {
@@ -411,11 +411,11 @@ int run_cmd(UAContext *ua, const char *cmd)
    if (when) {
       jcr->sched_time = str_to_utime(when);
       if (jcr->sched_time == 0) {
-         bsendmsg(ua, _("Invalid time, using current time.\n"));
+        bsendmsg(ua, _("Invalid time, using current time.\n"));
         jcr->sched_time = time(NULL);
       }
    }
-        
+
    if (bootstrap) {
       if (jcr->RestoreBootstrap) {
         free(jcr->RestoreBootstrap);
@@ -431,7 +431,7 @@ int run_cmd(UAContext *ua, const char *cmd)
         }
       }
       if (!jcr->replace) {
-         bsendmsg(ua, _("Invalid replace option: %s\n"), replace);
+        bsendmsg(ua, _("Invalid replace option: %s\n"), replace);
         goto bail_out;
       }
    } else if (job->replace) {
@@ -443,7 +443,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    if (Priority) {
       jcr->JobPriority = Priority;
    }
-      
+
    if (find_arg(ua, _("fdcalled")) > 0) {
       jcr->file_bsock = dup_bsock(ua->UA_sock);
       ua->quit = true;
@@ -458,7 +458,7 @@ try_again:
    }
    if (level_name) {
       if (!get_level_from_name(jcr, level_name)) {
-         bsendmsg(ua, _("Level %s not valid.\n"), level_name);
+        bsendmsg(ua, _("Level %s not valid.\n"), level_name);
         goto bail_out;
       }
    }
@@ -471,7 +471,7 @@ try_again:
       goto start_job;
    }
 
-   /*  
+   /*
     * Prompt User to see if all run job parameters are correct, and
     *  allow him to modify them.
     */
@@ -480,41 +480,41 @@ try_again:
       char ec1[30];
       char dt[MAX_TIME_LENGTH];
    case JT_ADMIN:
-         bsendmsg(ua, _("Run %s job\n\
-JobName:  %s\n\
-FileSet:  %s\n\
-Client:   %s\n\
-Storage:  %s\n\
-When:     %s\n\
-Priority: %d\n"),
-                 _("Admin"),
+        bsendmsg(ua, _("Run %s job\n"
+"JobName:  %s\n"
+"FileSet:  %s\n"
+"Client:   %s\n"
+"Storage:  %s\n"
+"When:     %s\n"
+"Priority: %d\n"),
+                _("Admin"),
                 job->hdr.name,
                 jcr->fileset->hdr.name,
                 NPRT(jcr->client->hdr.name),
-                NPRT(jcr->store->hdr.name), 
-                bstrutime(dt, sizeof(dt), jcr->sched_time), 
+                NPRT(jcr->store->hdr.name),
+                bstrutime(dt, sizeof(dt), jcr->sched_time),
                 jcr->JobPriority);
       jcr->JobLevel = L_FULL;
       break;
    case JT_BACKUP:
    case JT_VERIFY:
       if (jcr->JobType == JT_BACKUP) {
-         bsendmsg(ua, _("Run %s job\n\
-JobName:  %s\n\
-FileSet:  %s\n\
-Level:    %s\n\
-Client:   %s\n\
-Storage:  %s\n\
-Pool:     %s\n\
-When:     %s\n\
-Priority: %d\n"),
-                 _("Backup"),
+        bsendmsg(ua, _("Run %s job\n"
+"JobName:  %s\n"
+"FileSet:  %s\n"
+"Level:    %s\n"
+"Client:   %s\n"
+"Storage:  %s\n"
+"Pool:     %s\n"
+"When:     %s\n"
+"Priority: %d\n"),
+                _("Backup"),
                 job->hdr.name,
                 jcr->fileset->hdr.name,
                 level_to_str(jcr->JobLevel),
                 jcr->client->hdr.name,
                 jcr->store->hdr.name,
-                NPRT(jcr->pool->hdr.name), 
+                NPRT(jcr->pool->hdr.name),
                 bstrutime(dt, sizeof(dt), jcr->sched_time),
                 jcr->JobPriority);
       } else { /* JT_VERIFY */
@@ -522,26 +522,26 @@ Priority: %d\n"),
         if (jcr->verify_job) {
            Name = jcr->verify_job->hdr.name;
         } else {
-            Name = "";
+           Name = "";
         }
-         bsendmsg(ua, _("Run %s job\n\
-JobName:     %s\n\
-FileSet:     %s\n\
-Level:       %s\n\
-Client:      %s\n\
-Storage:     %s\n\
-Pool:        %s\n\
-Verify Job:  %s\n\
-When:        %s\n\
-Priority:    %d\n"),
-              _("Verify"),
+        bsendmsg(ua, _("Run %s job\n"
+"JobName:     %s\n"
+"FileSet:     %s\n"
+"Level:       %s\n"
+"Client:      %s\n"
+"Storage:     %s\n"
+"Pool:        %s\n"
+"Verify Job:  %s\n"
+"When:        %s\n"
+"Priority:    %d\n"),
+             _("Verify"),
              job->hdr.name,
              jcr->fileset->hdr.name,
              level_to_str(jcr->JobLevel),
              jcr->client->hdr.name,
              jcr->store->hdr.name,
-             NPRT(jcr->pool->hdr.name), 
-             Name,            
+             NPRT(jcr->pool->hdr.name),
+             Name,
              bstrutime(dt, sizeof(dt), jcr->sched_time),
              jcr->JobPriority);
       }
@@ -551,55 +551,55 @@ Priority:    %d\n"),
         if (jid) {
            jcr->RestoreJobId = atoi(jid);
         } else {
-            if (!get_pint(ua, _("Please enter a JobId for restore: "))) {
+           if (!get_pint(ua, _("Please enter a JobId for restore: "))) {
               goto bail_out;
-           }  
+           }
            jcr->RestoreJobId = ua->pint32_val;
         }
       }
       jcr->JobLevel = L_FULL;     /* default level */
       Dmsg1(20, "JobId to restore=%d\n", jcr->RestoreJobId);
       if (jcr->RestoreJobId == 0) {
-         bsendmsg(ua, _("Run Restore job\n"
-                        "JobName:    %s\n"
-                        "Bootstrap:  %s\n"
-                        "Where:      %s\n"
-                        "Replace:    %s\n"
-                        "FileSet:    %s\n"
-                        "Client:     %s\n"
-                        "Storage:    %s\n"
-                        "When:       %s\n"
-                        "Catalog:    %s\n"
-                        "Priority:   %d\n"),
+        bsendmsg(ua, _("Run Restore job\n"
+                       "JobName:    %s\n"
+                       "Bootstrap:  %s\n"
+                       "Where:      %s\n"
+                       "Replace:    %s\n"
+                       "FileSet:    %s\n"
+                       "Client:     %s\n"
+                       "Storage:    %s\n"
+                       "When:       %s\n"
+                       "Catalog:    %s\n"
+                       "Priority:   %d\n"),
              job->hdr.name,
              NPRT(jcr->RestoreBootstrap),
              jcr->where?jcr->where:NPRT(job->RestoreWhere),
              replace,
              jcr->fileset->hdr.name,
              jcr->client->hdr.name,
-             jcr->store->hdr.name, 
+             jcr->store->hdr.name,
              bstrutime(dt, sizeof(dt), jcr->sched_time),
              jcr->catalog->hdr.name,
              jcr->JobPriority);
       } else {
-         bsendmsg(ua, _("Run Restore job\n"
-                       "JobName:    %s\n"
-                       "Bootstrap:  %s\n"
-                       "Where:      %s\n"
-                       "Replace:    %s\n"
-                       "Client:     %s\n"
-                       "Storage:    %s\n"
-                       "JobId:      %s\n"
-                       "When:       %s\n"
-                       "Catalog:    %s\n"
-                       "Priority:   %d\n"),
+        bsendmsg(ua, _("Run Restore job\n"
+                      "JobName:    %s\n"
+                      "Bootstrap:  %s\n"
+                      "Where:      %s\n"
+                      "Replace:    %s\n"
+                      "Client:     %s\n"
+                      "Storage:    %s\n"
+                      "JobId:      %s\n"
+                      "When:       %s\n"
+                      "Catalog:    %s\n"
+                      "Priority:   %d\n"),
              job->hdr.name,
              NPRT(jcr->RestoreBootstrap),
              jcr->where?jcr->where:NPRT(job->RestoreWhere),
              replace,
              jcr->client->hdr.name,
-             jcr->store->hdr.name, 
-              jcr->RestoreJobId==0?"*None*":edit_uint64(jcr->RestoreJobId, ec1), 
+             jcr->store->hdr.name,
+             jcr->RestoreJobId==0?"*None*":edit_uint64(jcr->RestoreJobId, ec1),
              bstrutime(dt, sizeof(dt), jcr->sched_time),
              jcr->catalog->hdr.name,
              jcr->JobPriority);
@@ -633,27 +633,27 @@ Priority:    %d\n"),
       add_prompt(ua, _("Priority"));         /* 6 */
       if (jcr->JobType == JT_BACKUP ||
          jcr->JobType == JT_VERIFY) {
-         add_prompt(ua, _("Pool"));          /* 7 */
+        add_prompt(ua, _("Pool"));          /* 7 */
         if (jcr->JobType == JT_VERIFY) {
-            add_prompt(ua, _("Verify Job"));  /* 8 */
+           add_prompt(ua, _("Verify Job"));  /* 8 */
         }
       } else if (jcr->JobType == JT_RESTORE) {
-         add_prompt(ua, _("Bootstrap"));     /* 7 */
-         add_prompt(ua, _("Where"));         /* 8 */
-         add_prompt(ua, _("Replace"));       /* 9 */
-         add_prompt(ua, _("JobId"));         /* 10 */
+        add_prompt(ua, _("Bootstrap"));     /* 7 */
+        add_prompt(ua, _("Where"));         /* 8 */
+        add_prompt(ua, _("Replace"));       /* 9 */
+        add_prompt(ua, _("JobId"));         /* 10 */
       }
       switch (do_prompt(ua, "", _("Select parameter to modify"), NULL, 0)) {
       case 0:
         /* Level */
         if (jcr->JobType == JT_BACKUP) {
-            start_prompt(ua, _("Levels:\n"));
-            add_prompt(ua, _("Base"));
-            add_prompt(ua, _("Full"));
-            add_prompt(ua, _("Incremental"));
-            add_prompt(ua, _("Differential"));
-            add_prompt(ua, _("Since"));
-            switch (do_prompt(ua, "", _("Select level"), NULL, 0)) {
+           start_prompt(ua, _("Levels:\n"));
+           add_prompt(ua, _("Base"));
+           add_prompt(ua, _("Full"));
+           add_prompt(ua, _("Incremental"));
+           add_prompt(ua, _("Differential"));
+           add_prompt(ua, _("Since"));
+           switch (do_prompt(ua, "", _("Select level"), NULL, 0)) {
            case 0:
               jcr->JobLevel = L_BASE;
               break;
@@ -674,13 +674,13 @@ Priority:    %d\n"),
            }
            goto try_again;
         } else if (jcr->JobType == JT_VERIFY) {
-            start_prompt(ua, _("Levels:\n"));
-            add_prompt(ua, _("Initialize Catalog"));
-            add_prompt(ua, _("Verify Catalog"));
-            add_prompt(ua, _("Verify Volume to Catalog"));
-            add_prompt(ua, _("Verify Disk to Catalog"));
-            add_prompt(ua, _("Verify Volume Data (not yet implemented)"));
-            switch (do_prompt(ua, "",  _("Select level"), NULL, 0)) {
+           start_prompt(ua, _("Levels:\n"));
+           add_prompt(ua, _("Initialize Catalog"));
+           add_prompt(ua, _("Verify Catalog"));
+           add_prompt(ua, _("Verify Volume to Catalog"));
+           add_prompt(ua, _("Verify Disk to Catalog"));
+           add_prompt(ua, _("Verify Volume Data (not yet implemented)"));
+           switch (do_prompt(ua, "",  _("Select level"), NULL, 0)) {
            case 0:
               jcr->JobLevel = L_VERIFY_INIT;
               break;
@@ -701,7 +701,7 @@ Priority:    %d\n"),
            }
            goto try_again;
         } else {
-            bsendmsg(ua, _("Level not appropriate for this Job. Cannot be changed.\n"));
+           bsendmsg(ua, _("Level not appropriate for this Job. Cannot be changed.\n"));
         }
         goto try_again;
       case 1:
@@ -727,7 +727,7 @@ Priority:    %d\n"),
         if (fileset) {
            jcr->fileset = fileset;
            goto try_again;
-        }      
+        }
         break;
       case 4:
         /* Client */
@@ -739,7 +739,7 @@ Priority:    %d\n"),
         break;
       case 5:
         /* When */
-         if (!get_cmd(ua, _("Please enter desired start time as YYYY-MM-DD HH:MM:SS (return for now): "))) {
+        if (!get_cmd(ua, _("Please enter desired start time as YYYY-MM-DD HH:MM:SS (return for now): "))) {
            break;
         }
         if (ua->cmd[0] == 0) {
@@ -747,18 +747,18 @@ Priority:    %d\n"),
         } else {
            jcr->sched_time = str_to_utime(ua->cmd);
            if (jcr->sched_time == 0) {
-               bsendmsg(ua, _("Invalid time, using current time.\n"));
+              bsendmsg(ua, _("Invalid time, using current time.\n"));
               jcr->sched_time = time(NULL);
            }
         }
         goto try_again;
       case 6:
         /* Priority */
-         if (!get_pint(ua, _("Enter new Priority: "))) {
+        if (!get_pint(ua, _("Enter new Priority: "))) {
            break;
         }
         if (ua->pint32_val == 0) {
-            bsendmsg(ua, _("Priority must be a positive integer.\n"));
+           bsendmsg(ua, _("Priority must be a positive integer.\n"));
         } else {
            jcr->JobPriority = ua->pint32_val;
         }
@@ -776,7 +776,7 @@ Priority:    %d\n"),
         }
 
         /* Bootstrap */
-         if (!get_cmd(ua, _("Please enter the Bootstrap file name: "))) {
+        if (!get_cmd(ua, _("Please enter the Bootstrap file name: "))) {
            break;
         }
         if (jcr->RestoreBootstrap) {
@@ -785,9 +785,9 @@ Priority:    %d\n"),
         }
         if (ua->cmd[0] != 0) {
            jcr->RestoreBootstrap = bstrdup(ua->cmd);
-            fd = fopen(jcr->RestoreBootstrap, "r");
+           fd = fopen(jcr->RestoreBootstrap, "r");
            if (!fd) {
-               bsendmsg(ua, _("Warning cannot open %s: ERR=%s\n"),
+              bsendmsg(ua, _("Warning cannot open %s: ERR=%s\n"),
                  jcr->RestoreBootstrap, strerror(errno));
               free(jcr->RestoreBootstrap);
               jcr->RestoreBootstrap = NULL;
@@ -806,25 +806,25 @@ Priority:    %d\n"),
            goto try_again;
         }
         /* Where */
-         if (!get_cmd(ua, _("Please enter path prefix for restore (/ for none): "))) {
+        if (!get_cmd(ua, _("Please enter path prefix for restore (/ for none): "))) {
            break;
         }
         if (jcr->where) {
            free(jcr->where);
            jcr->where = NULL;
         }
-         if (ua->cmd[0] == '/' && ua->cmd[1] == 0) {
+        if (ua->cmd[0] == '/' && ua->cmd[1] == 0) {
            ua->cmd[0] = 0;
         }
         jcr->where = bstrdup(ua->cmd);
         goto try_again;
       case 9:
         /* Replace */
-         start_prompt(ua, _("Replace:\n"));
+        start_prompt(ua, _("Replace:\n"));
         for (i=0; ReplaceOptions[i].name; i++) {
            add_prompt(ua, ReplaceOptions[i].name);
         }
-         opt = do_prompt(ua, "", _("Select replace option"), NULL, 0);
+        opt = do_prompt(ua, "", _("Select replace option"), NULL, 0);
         if (opt >=  0) {
            jcr->replace = ReplaceOptions[opt].token;
         }
@@ -834,10 +834,10 @@ Priority:    %d\n"),
         jid = NULL;                  /* force reprompt */
         jcr->RestoreJobId = 0;
         if (jcr->RestoreBootstrap) {
-            bsendmsg(ua, _("You must set the bootstrap file to NULL to be able to specify a JobId.\n"));
+           bsendmsg(ua, _("You must set the bootstrap file to NULL to be able to specify a JobId.\n"));
         }
         goto try_again;
-      default: 
+      default:
         goto try_again;
       }
       goto bail_out;
@@ -850,9 +850,9 @@ start_job:
       JobId = run_job(jcr);
       free_jcr(jcr);                 /* release jcr */
       if (JobId == 0) {
-         bsendmsg(ua, _("Job failed.\n"));
+        bsendmsg(ua, _("Job failed.\n"));
       } else {
-         bsendmsg(ua, _("Job started. JobId=%u\n"), JobId);
+        bsendmsg(ua, _("Job started. JobId=%u\n"), JobId);
       }
       return JobId;
    }
index 4ea140929d22dc39081dd30b80448bd81b3658ee..eb8b21533ee38e166431397b1a3c42e1409453c5 100644 (file)
@@ -42,17 +42,17 @@ int confirm_retention(UAContext *ua, utime_t *ret, const char *msg)
    char ed1[100];
 
    for ( ;; ) {
-       bsendmsg(ua, _("The current %s retention period is: %s\n"), 
+       bsendmsg(ua, _("The current %s retention period is: %s\n"),
          msg, edit_utime(*ret, ed1, sizeof(ed1)));
        if (!get_cmd(ua, _("Continue? (yes/mod/no): "))) {
          return 0;
        }
        if (strcasecmp(ua->cmd, _("mod")) == 0) {
-          if (!get_cmd(ua, _("Enter new retention period: "))) {
+         if (!get_cmd(ua, _("Enter new retention period: "))) {
             return 0;
          }
          if (!duration_to_utime(ua->cmd, ret)) {
-             bsendmsg(ua, _("Invalid period.\n"));
+            bsendmsg(ua, _("Invalid period.\n"));
             continue;
          }
          continue;
@@ -67,7 +67,7 @@ int confirm_retention(UAContext *ua, utime_t *ret, const char *msg)
     return 1;
 }
 
-/* 
+/*
  * Given a list of keywords, find the first one
  *  that is in the argument list.
  * Returns: -1 if not found
@@ -85,7 +85,7 @@ int find_arg_keyword(UAContext *ua, const char **list)
    return -1;
 }
 
-/* 
+/*
  * Given one keyword, find the first one that
  *   is in the argument list.
  * Returns: argk index (always gt 0)
@@ -101,7 +101,7 @@ int find_arg(UAContext *ua, const char *keyword)
    return -1;
 }
 
-/* 
+/*
  * Given a single keyword, find it in the argument list, but
  *   it must have a value
  * Returns: -1 if not found or no value
@@ -121,8 +121,8 @@ int find_arg_with_value(UAContext *ua, const char *keyword)
    return -1;
 }
 
-/* 
- * Given a list of keywords, prompt the user 
+/*
+ * Given a list of keywords, prompt the user
  * to choose one.
  *
  * Returns: -1 on failure
@@ -139,12 +139,12 @@ int do_keyword_prompt(UAContext *ua, const char *msg, const char **list)
 }
 
 
-/* 
+/*
  * Select a Storage resource from prompt list
  */
 STORE *select_storage_resource(UAContext *ua)
 {
-   char name[MAX_NAME_LENGTH];   
+   char name[MAX_NAME_LENGTH];
    STORE *store;
 
    start_prompt(ua, _("The defined Storage resources are:\n"));
@@ -160,12 +160,12 @@ STORE *select_storage_resource(UAContext *ua)
    return store;
 }
 
-/* 
+/*
  * Select a FileSet resource from prompt list
  */
 FILESET *select_fileset_resource(UAContext *ua)
 {
-   char name[MAX_NAME_LENGTH];   
+   char name[MAX_NAME_LENGTH];
    FILESET *fs;
 
    start_prompt(ua, _("The defined FileSet resources are:\n"));
@@ -182,12 +182,12 @@ FILESET *select_fileset_resource(UAContext *ua)
 }
 
 
-/* 
+/*
  * Get a catalog resource from prompt list
  */
 CAT *get_catalog_resource(UAContext *ua)
 {
-   char name[MAX_NAME_LENGTH];   
+   char name[MAX_NAME_LENGTH];
    CAT *catalog = NULL;
    int i;
 
@@ -215,12 +215,12 @@ CAT *get_catalog_resource(UAContext *ua)
 }
 
 
-/* 
+/*
  * Select a Job resource from prompt list
  */
 JOB *select_job_resource(UAContext *ua)
 {
-   char name[MAX_NAME_LENGTH];   
+   char name[MAX_NAME_LENGTH];
    JOB *job;
 
    start_prompt(ua, _("The defined Job resources are:\n"));
@@ -236,12 +236,12 @@ JOB *select_job_resource(UAContext *ua)
    return job;
 }
 
-/* 
+/*
  * Select a Restore Job resource from prompt list
  */
 JOB *select_restore_job_resource(UAContext *ua)
 {
-   char name[MAX_NAME_LENGTH];   
+   char name[MAX_NAME_LENGTH];
    JOB *job;
 
    start_prompt(ua, _("The defined Restore Job resources are:\n"));
@@ -259,12 +259,12 @@ JOB *select_restore_job_resource(UAContext *ua)
 
 
 
-/* 
+/*
  * Select a client resource from prompt list
  */
 CLIENT *select_client_resource(UAContext *ua)
 {
-   char name[MAX_NAME_LENGTH];   
+   char name[MAX_NAME_LENGTH];
    CLIENT *client;
 
    start_prompt(ua, _("The defined Client resources are:\n"));
@@ -289,10 +289,10 @@ CLIENT *get_client_resource(UAContext *ua)
 {
    CLIENT *client = NULL;
    int i;
-   
+
    for (i=1; i<ua->argc; i++) {
       if ((strcasecmp(ua->argk[i], _("client")) == 0 ||
-           strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) {
+          strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) {
         if (!acl_access_ok(ua, Client_ACL, ua->argv[i])) {
            break;
         }
@@ -300,7 +300,7 @@ CLIENT *get_client_resource(UAContext *ua)
         if (client) {
            return client;
         }
-         bsendmsg(ua, _("Error: Client resource %s does not exist.\n"), ua->argv[i]);
+        bsendmsg(ua, _("Error: Client resource %s does not exist.\n"), ua->argv[i]);
         break;
       }
    }
@@ -308,7 +308,7 @@ CLIENT *get_client_resource(UAContext *ua)
 }
 
 /* Scan what the user has entered looking for:
- * 
+ *
  *  client=<client-name>
  *
  *  if error or not found, put up a list of client DBRs
@@ -328,14 +328,14 @@ int get_client_dbr(UAContext *ua, CLIENT_DBR *cr)
       bsendmsg(ua, _("Could not find Client %s: ERR=%s"), cr->Name, db_strerror(ua->db));
    }
    for (i=1; i<ua->argc; i++) {
-      if ((strcasecmp(ua->argk[i], _("client")) == 0 ||               
-           strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) {
+      if ((strcasecmp(ua->argk[i], _("client")) == 0 ||
+          strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) {
         if (!acl_access_ok(ua, Client_ACL, ua->argv[i])) {
            break;
         }
         bstrncpy(cr->Name, ua->argv[i], sizeof(cr->Name));
         if (!db_get_client_record(ua->jcr, ua->db, cr)) {
-            bsendmsg(ua, _("Could not find Client \"%s\": ERR=%s"), ua->argv[i],
+           bsendmsg(ua, _("Could not find Client \"%s\": ERR=%s"), ua->argv[i],
                     db_strerror(ua->db));
            cr->ClientId = 0;
            break;
@@ -359,7 +359,7 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr)
    CLIENT_DBR ocr;
    char name[MAX_NAME_LENGTH];
    int num_clients, i;
-   uint32_t *ids; 
+   uint32_t *ids;
 
 
    cr->ClientId = 0;
@@ -371,7 +371,7 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr)
       bsendmsg(ua, _("No clients defined. You must run a job before using this command.\n"));
       return 0;
    }
-     
+
    start_prompt(ua, _("Defined Clients:\n"));
    for (i=0; i < num_clients; i++) {
       ocr.ClientId = ids[i];
@@ -399,8 +399,8 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr)
 
 
 /* Scan what the user has entered looking for:
- * 
- *  pool=<pool-name>   
+ *
+ *  pool=<pool-name>
  *
  *  if error or not found, put up a list of pool DBRs
  *  to choose from.
@@ -412,7 +412,7 @@ bool get_pool_dbr(UAContext *ua, POOL_DBR *pr)
 {
    if (pr->Name[0]) {                /* If name already supplied */
       if (db_get_pool_record(ua->jcr, ua->db, pr) &&
-         acl_access_ok(ua, Pool_ACL, pr->Name)) { 
+         acl_access_ok(ua, Pool_ACL, pr->Name)) {
         return true;
       }
       bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), pr->Name, db_strerror(ua->db));
@@ -431,14 +431,14 @@ bool select_pool_dbr(UAContext *ua, POOL_DBR *pr)
    POOL_DBR opr;
    char name[MAX_NAME_LENGTH];
    int num_pools, i;
-   uint32_t *ids; 
+   uint32_t *ids;
 
    for (i=1; i<ua->argc; i++) {
       if (strcasecmp(ua->argk[i], _("pool")) == 0 && ua->argv[i] &&
          acl_access_ok(ua, Pool_ACL, ua->argv[i])) {
         bstrncpy(pr->Name, ua->argv[i], sizeof(pr->Name));
         if (!db_get_pool_record(ua->jcr, ua->db, pr)) {
-            bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), ua->argv[i],
+           bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), ua->argv[i],
                     db_strerror(ua->db));
            pr->PoolId = 0;
            break;
@@ -456,7 +456,7 @@ bool select_pool_dbr(UAContext *ua, POOL_DBR *pr)
       bsendmsg(ua, _("No pools defined. Use the \"create\" command to create one.\n"));
       return false;
    }
-     
+
    start_prompt(ua, _("Defined Pools:\n"));
    for (i=0; i < num_pools; i++) {
       opr.PoolId = ids[i];
@@ -541,12 +541,12 @@ int select_media_dbr(UAContext *ua, MEDIA_DBR *mr)
 }
 
 
-/* 
+/*
  * Select a pool resource from prompt list
  */
 POOL *select_pool_resource(UAContext *ua)
 {
-   char name[MAX_NAME_LENGTH];   
+   char name[MAX_NAME_LENGTH];
    POOL *pool;
 
    start_prompt(ua, _("The defined Pool resources are:\n"));
@@ -565,14 +565,14 @@ POOL *select_pool_resource(UAContext *ua)
 
 /*
  *  If you are thinking about using it, you
- *  probably want to use select_pool_dbr() 
+ *  probably want to use select_pool_dbr()
  *  or get_pool_dbr() above.
  */
 POOL *get_pool_resource(UAContext *ua)
 {
    POOL *pool = NULL;
    int i;
-   
+
    i = find_arg_with_value(ua, "pool");
    if (i >= 0 && acl_access_ok(ua, Pool_ACL, ua->argv[i])) {
       pool = (POOL *)GetResWithName(R_POOL, ua->argv[i]);
@@ -604,7 +604,7 @@ int select_job_dbr(UAContext *ua, JOB_DBR *jr)
 
 
 /* Scan what the user has entered looking for:
- * 
+ *
  *  jobid=nn
  *
  *  if error or not found, put up a list of Jobs
@@ -627,7 +627,7 @@ int get_job_dbr(UAContext *ua, JOB_DBR *jr)
         continue;
       }
       if (!db_get_job_record(ua->jcr, ua->db, jr)) {
-         bsendmsg(ua, _("Could not find Job \"%s\": ERR=%s"), ua->argv[i],
+        bsendmsg(ua, _("Could not find Job \"%s\": ERR=%s"), ua->argv[i],
                  db_strerror(ua->db));
         jr->JobId = 0;
         break;
@@ -642,7 +642,7 @@ int get_job_dbr(UAContext *ua, JOB_DBR *jr)
 }
 
 /*
- * Implement unique set of prompts 
+ * Implement unique set of prompts
  */
 void start_prompt(UAContext *ua, const char *msg)
 {
@@ -655,7 +655,7 @@ void start_prompt(UAContext *ua, const char *msg)
 }
 
 /*
- * Add to prompts -- keeping them unique 
+ * Add to prompts -- keeping them unique
  */
 void add_prompt(UAContext *ua, const char *prompt)
 {
@@ -710,30 +710,30 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt,
 
    for ( ;; ) {
       /* First item is the prompt string, not the items */
-      if (ua->num_prompts == 1) { 
-         bsendmsg(ua, _("Selection is empty!\n"));
+      if (ua->num_prompts == 1) {
+        bsendmsg(ua, _("Selection is empty!\n"));
         item = 0;                    /* list is empty ! */
         break;
       }
       if (ua->num_prompts == 2) {
         item = 1;
-         bsendmsg(ua, _("Item 1 selected automatically.\n"));
+        bsendmsg(ua, _("Item 1 selected automatically.\n"));
         if (prompt) {
            bstrncpy(prompt, ua->prompt[1], max_prompt);
         }
         break;
       } else {
-         sprintf(pmsg, "%s (1-%d): ", msg, ua->num_prompts-1);
+        sprintf(pmsg, "%s (1-%d): ", msg, ua->num_prompts-1);
       }
       /* Either a . or an @ will get you out of the loop */
       if (!get_pint(ua, pmsg)) {
         item = -1;                   /* error */
-         bsendmsg(ua, _("Selection aborted, nothing done.\n"));
+        bsendmsg(ua, _("Selection aborted, nothing done.\n"));
         break;
       }
       item = ua->pint32_val;
       if (item < 1 || item >= ua->num_prompts) {
-         bsendmsg(ua, _("Please enter a number between 1 and %d\n"), ua->num_prompts-1);
+        bsendmsg(ua, _("Please enter a number between 1 and %d\n"), ua->num_prompts-1);
         continue;
       }
       if (prompt) {
@@ -741,7 +741,7 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt,
       }
       break;
    }
-                             
+
 done:
    for (i=0; i < ua->num_prompts; i++) {
       free(ua->prompt[i]);
@@ -769,53 +769,53 @@ STORE *get_storage_resource(UAContext *ua, int use_default)
    int jobid;
    JCR *jcr;
    int i;
-      
+
 
    for (i=1; i<ua->argc; i++) {
       if (use_default && !ua->argv[i]) {
         /* Ignore slots, scan and barcode(s) keywords */
-         if (strncasecmp("scan", ua->argk[i], 4) == 0 ||
-             strncasecmp("barcode", ua->argk[i], 7) == 0 ||
-             strncasecmp("slots", ua->argk[i], 5) == 0) {
+        if (strncasecmp("scan", ua->argk[i], 4) == 0 ||
+            strncasecmp("barcode", ua->argk[i], 7) == 0 ||
+            strncasecmp("slots", ua->argk[i], 5) == 0) {
            continue;
         }
         /* Default argument is storage */
         if (store_name) {
-            bsendmsg(ua, _("Storage name given twice.\n"));
+           bsendmsg(ua, _("Storage name given twice.\n"));
            return NULL;
         }
         store_name = ua->argk[i];
-         if (*store_name == '?') {
+        if (*store_name == '?') {
            *store_name = 0;
            break;
         }
       } else {
-         if (strcasecmp(ua->argk[i], _("storage")) == 0 ||
-             strcasecmp(ua->argk[i], _("sd")) == 0) {
+        if (strcasecmp(ua->argk[i], _("storage")) == 0 ||
+            strcasecmp(ua->argk[i], _("sd")) == 0) {
            store_name = ua->argv[i];
            break;
 
-         } else if (strcasecmp(ua->argk[i], _("jobid")) == 0) {
+        } else if (strcasecmp(ua->argk[i], _("jobid")) == 0) {
            jobid = str_to_int64(ua->argv[i]);
            if (jobid <= 0) {
-               bsendmsg(ua, _("Expecting jobid=nn command, got: %s\n"), ua->argk[i]);
+              bsendmsg(ua, _("Expecting jobid=nn command, got: %s\n"), ua->argk[i]);
               return NULL;
            }
            if (!(jcr=get_jcr_by_id(jobid))) {
-               bsendmsg(ua, _("JobId %d is not running.\n"), jobid);
+              bsendmsg(ua, _("JobId %d is not running.\n"), jobid);
               return NULL;
            }
            store = jcr->store;
            free_jcr(jcr);
            break;
 
-         } else if (strcasecmp(ua->argk[i], _("job")) == 0) {
+        } else if (strcasecmp(ua->argk[i], _("job")) == 0) {
            if (!ua->argv[i]) {
-               bsendmsg(ua, _("Expecting job=xxx, got: %s.\n"), ua->argk[i]);
+              bsendmsg(ua, _("Expecting job=xxx, got: %s.\n"), ua->argk[i]);
               return NULL;
            }
            if (!(jcr=get_jcr_by_partial_name(ua->argv[i]))) {
-               bsendmsg(ua, _("Job \"%s\" is not running.\n"), ua->argv[i]);
+              bsendmsg(ua, _("Job \"%s\" is not running.\n"), ua->argv[i]);
               return NULL;
            }
            store = jcr->store;
@@ -827,11 +827,11 @@ STORE *get_storage_resource(UAContext *ua, int use_default)
    if (store && !acl_access_ok(ua, Storage_ACL, store->hdr.name)) {
       store = NULL;
    }
-   
+
    if (!store && store_name) {
       store = (STORE *)GetResWithName(R_STORAGE, store_name);
       if (!store) {
-         bsendmsg(ua, "Storage resource \"%s\": not found\n", store_name);
+        bsendmsg(ua, "Storage resource \"%s\": not found\n", store_name);
       }
    }
    if (store && !acl_access_ok(ua, Storage_ACL, store->hdr.name)) {
@@ -846,7 +846,7 @@ STORE *get_storage_resource(UAContext *ua, int use_default)
 
 
 /*
- * Scan looking for mediatype= 
+ * Scan looking for mediatype=
  *
  *  if not found or error, put up selection list
  *
index 1c6da1fbefe337e5ecb567aa61027f7253adb25f..3e4adef377dd602172df8a585853cbbb22cc71d7 100644 (file)
@@ -81,7 +81,7 @@ void start_UA_server(dlist *addrs)
    return;
 }
 
-extern "C" 
+extern "C"
 void *connect_thread(void *arg)
 {
    pthread_detach(pthread_self());
@@ -119,7 +119,7 @@ JCR *new_control_jcr(const char *base_name, int job_type)
 }
 
 /*
- * Handle Director User Agent commands  
+ * Handle Director User Agent commands
  *
  */
 static void *handle_UA_client_request(void *arg)
@@ -146,18 +146,18 @@ static void *handle_UA_client_request(void *arg)
       if (stat >= 0) {
         pm_strcpy(ua->cmd, ua->UA_sock->msg);
         parse_ua_args(ua);
-         if (ua->argc > 0 && ua->argk[0][0] == '.') {
+        if (ua->argc > 0 && ua->argk[0][0] == '.') {
            do_a_dot_command(ua, ua->cmd);
         } else {
            do_a_command(ua, ua->cmd);
         }
         if (!ua->quit) {
            if (ua->auto_display_messages) {
-               strcpy(ua->cmd, "messages");
+              strcpy(ua->cmd, "messages");
               qmessagescmd(ua, ua->cmd);
               ua->user_notified_msg_pending = FALSE;
            } else if (!ua->user_notified_msg_pending && console_msg_pending) {
-               bsendmsg(ua, _("You have messages.\n"));
+              bsendmsg(ua, _("You have messages.\n"));
               ua->user_notified_msg_pending = TRUE;
            }
            bnet_sig(ua->UA_sock, BNET_EOD); /* send end of command */
@@ -179,7 +179,7 @@ getout:
 
 /*
  * Create a UAContext for a Job that is running so that
- *   it can the User Agent routines and    
+ *   it can the User Agent routines and
  *   to ensure that the Job gets the proper output.
  *   This is a sort of mini-kludge, and should be
  *   unified at some point.
@@ -219,7 +219,7 @@ void free_ua_context(UAContext *ua)
 
 
 /*
- * Called from main Bacula thread 
+ * Called from main Bacula thread
  */
 void term_ua_server()
 {
index 78adcfb54b3bf7c0660cedb5cc9b51c8c255e93a..4040e9af6e3f7a6e439a60a9116f76978f95a67d 100644 (file)
@@ -52,7 +52,7 @@ int qstatus_cmd(UAContext *ua, const char *cmd)
 {
    JCR* njcr;
    s_last_job* job;
-   
+
    if (!open_db(ua)) {
       return 1;
    }
@@ -62,7 +62,7 @@ int qstatus_cmd(UAContext *ua, const char *cmd)
       bsendmsg(ua, "1900 Bad .status command, missing arguments.\n");
       return 1;
    }
-   
+
    if (strcasecmp(ua->argk[2], "current") == 0) {
       bsendmsg(ua, OKqstatus, ua->argk[2]);
       lock_jcr_chain();
@@ -85,7 +85,7 @@ int qstatus_cmd(UAContext *ua, const char *cmd)
       bsendmsg(ua, "1900 Bad .status command, wrong argument.\n");
       return 1;
    }
-  
+
    return 1;
 }
 
@@ -108,7 +108,7 @@ int status_cmd(UAContext *ua, const char *cmd)
         do_all_status(ua);
         return 1;
       } else if (strcasecmp(ua->argk[i], _("dir")) == 0 ||
-                 strcasecmp(ua->argk[i], _("director")) == 0) {
+                strcasecmp(ua->argk[i], _("director")) == 0) {
         do_director_status(ua);
         return 1;
       } else if (strcasecmp(ua->argk[i], _("client")) == 0) {
@@ -126,9 +126,9 @@ int status_cmd(UAContext *ua, const char *cmd)
       }
    }
    /* If no args, ask for status type */
-   if (ua->argc == 1) {                                   
-       char prmt[MAX_NAME_LENGTH];             
-       
+   if (ua->argc == 1) {
+       char prmt[MAX_NAME_LENGTH];
+
       start_prompt(ua, _("Status available for:\n"));
       add_prompt(ua, _("Director"));
       add_prompt(ua, _("Storage"));
@@ -139,7 +139,7 @@ int status_cmd(UAContext *ua, const char *cmd)
         return 1;
       }
       Dmsg1(20, "item=%d\n", item);
-      switch (item) { 
+      switch (item) {
       case 0:                        /* Director */
         do_director_status(ua);
         break;
@@ -181,7 +181,7 @@ static void do_all_status(UAContext *ua)
       i++;
    }
    unique_store = (STORE **) malloc(i * sizeof(STORE));
-   /* Find Unique Storage address/port */        
+   /* Find Unique Storage address/port */
    i = 0;
    foreach_res(store, R_STORAGE) {
       found = false;
@@ -197,7 +197,7 @@ static void do_all_status(UAContext *ua)
       }
       if (!found) {
         unique_store[i++] = store;
-         Dmsg2(40, "Stuffing: %s:%d\n", store->address, store->SDport);
+        Dmsg2(40, "Stuffing: %s:%d\n", store->address, store->SDport);
       }
    }
    UnlockRes();
@@ -215,7 +215,7 @@ static void do_all_status(UAContext *ua)
       i++;
    }
    unique_client = (CLIENT **)malloc(i * sizeof(CLIENT));
-   /* Find Unique Client address/port */        
+   /* Find Unique Client address/port */
    i = 0;
    foreach_res(client, R_CLIENT) {
       found = false;
@@ -231,7 +231,7 @@ static void do_all_status(UAContext *ua)
       }
       if (!found) {
         unique_client[i++] = client;
-         Dmsg2(40, "Stuffing: %s:%d\n", client->address, client->FDport);
+        Dmsg2(40, "Stuffing: %s:%d\n", client->address, client->FDport);
       }
    }
    UnlockRes();
@@ -241,7 +241,7 @@ static void do_all_status(UAContext *ua)
       do_client_status(ua, unique_client[j]);
    }
    free(unique_client);
-   
+
 }
 
 static void do_director_status(UAContext *ua)
@@ -251,8 +251,8 @@ static void do_director_status(UAContext *ua)
    bsendmsg(ua, "%s Version: " VERSION " (" BDATE ") %s %s %s\n", my_name,
            HOST_OS, DISTNAME, DISTVER);
    bstrftime_nc(dt, sizeof(dt), daemon_start_time);
-   bsendmsg(ua, _("Daemon started %s, %d Job%s run since started.\n"), 
-        dt, num_jobs_run, num_jobs_run == 1 ? "" : "s");
+   bsendmsg(ua, _("Daemon started %s, %d Job%s run since started.\n"),
+       dt, num_jobs_run, num_jobs_run == 1 ? "" : "s");
    if (debug_level > 0) {
       char b1[35], b2[35], b3[35], b4[35];
       bsendmsg(ua, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"),
@@ -266,12 +266,12 @@ static void do_director_status(UAContext *ua)
     */
    list_scheduled_jobs(ua);
 
-   /* 
+   /*
     * List running jobs
     */
    list_running_jobs(ua);
 
-   /* 
+   /*
     * List terminated jobs
     */
    list_terminated_jobs(ua);
@@ -284,7 +284,7 @@ static void do_storage_status(UAContext *ua, STORE *store)
 
    set_storage(ua->jcr, store);
    /* Try connecting for up to 15 seconds */
-   bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), 
+   bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"),
       store->hdr.name, store->address, store->SDport);
    if (!connect_to_storage_daemon(ua->jcr, 1, 15, 0)) {
       bsendmsg(ua, _("\nFailed to connect to Storage daemon %s.\n====\n"),
@@ -292,7 +292,7 @@ static void do_storage_status(UAContext *ua, STORE *store)
       if (ua->jcr->store_bsock) {
         bnet_close(ua->jcr->store_bsock);
         ua->jcr->store_bsock = NULL;
-      }        
+      }
       return;
    }
    Dmsg0(20, _("Connected to storage daemon\n"));
@@ -304,9 +304,9 @@ static void do_storage_status(UAContext *ua, STORE *store)
    bnet_sig(sd, BNET_TERMINATE);
    bnet_close(sd);
    ua->jcr->store_bsock = NULL;
-   return;  
+   return;
 }
-   
+
 static void do_client_status(UAContext *ua, CLIENT *client)
 {
    BSOCK *fd;
@@ -322,7 +322,7 @@ static void do_client_status(UAContext *ua, CLIENT *client)
    ua->jcr->sd_auth_key = bstrdup("dummy");
 
    /* Try to connect for 15 seconds */
-   bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"), 
+   bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"),
       client->hdr.name, client->address, client->FDport);
    if (!connect_to_file_daemon(ua->jcr, 1, 15, 0)) {
       bsendmsg(ua, _("Failed to connect to Client %s.\n====\n"),
@@ -330,7 +330,7 @@ static void do_client_status(UAContext *ua, CLIENT *client)
       if (ua->jcr->file_bsock) {
         bnet_close(ua->jcr->file_bsock);
         ua->jcr->file_bsock = NULL;
-      }        
+      }
       return;
    }
    Dmsg0(20, _("Connected to file daemon\n"));
@@ -343,7 +343,7 @@ static void do_client_status(UAContext *ua, CLIENT *client)
    bnet_close(fd);
    ua->jcr->file_bsock = NULL;
 
-   return;  
+   return;
 }
 
 static void prt_runhdr(UAContext *ua)
@@ -365,7 +365,7 @@ struct sched_pkt {
 
 static void prt_runtime(UAContext *ua, sched_pkt *sp)
 {
-   char dt[MAX_TIME_LENGTH];      
+   char dt[MAX_TIME_LENGTH];
    const char *level_ptr;
    bool ok = false;
    bool close_db = false;
@@ -382,7 +382,7 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp)
         ok = find_next_volume_for_append(jcr, &mr, 0);
       }
       if (!ok) {
-         bstrncpy(mr.VolumeName, "*unknown*", sizeof(mr.VolumeName));
+        bstrncpy(mr.VolumeName, "*unknown*", sizeof(mr.VolumeName));
       }
    }
    bstrftime_nc(dt, sizeof(dt), sp->runtime);
@@ -395,8 +395,8 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp)
       level_ptr = level_to_str(sp->level);
       break;
    }
-   bsendmsg(ua, _("%-14s %-8s %3d  %-18s %-18s %s\n"), 
-      level_ptr, job_type_to_str(sp->job->JobType), sp->priority, dt, 
+   bsendmsg(ua, _("%-14s %-8s %3d  %-18s %-18s %s\n"),
+      level_ptr, job_type_to_str(sp->job->JobType), sp->priority, dt,
       sp->job->hdr.name, mr.VolumeName);
    if (close_db) {
       db_close_database(jcr, jcr->db);
@@ -416,7 +416,7 @@ static int my_compare(void *item1, void *item2)
       return -1;
    } else if (p1->runtime > p2->runtime) {
       return 1;
-   }    
+   }
    if (p1->priority < p2->priority) {
       return -1;
    } else if (p1->priority > p2->priority) {
@@ -425,7 +425,7 @@ static int my_compare(void *item1, void *item2)
    return 0;
 }
 
-/*         
+/*
  * Find all jobs to be run in roughly the
  *  next 24 hours.
  */
@@ -453,7 +453,7 @@ static void list_scheduled_jobs(UAContext *ua)
         if (run->level) {
            level = run->level;
         }
-        priority = job->Priority;   
+        priority = job->Priority;
         if (run->Priority) {
            priority = run->Priority;
         }
@@ -477,7 +477,7 @@ static void list_scheduled_jobs(UAContext *ua)
    }
    if (num_jobs == 0) {
       bsendmsg(ua, _("No Scheduled Jobs.\n"));
-   } 
+   }
    bsendmsg(ua, "====\n");
    Dmsg0(200, "Leave list_sched_jobs_runs()\n");
 }
@@ -503,7 +503,7 @@ static void list_running_jobs(UAContext *ua)
          */
         if (jcr->JobType == JT_CONSOLE) {
            bstrftime_nc(dt, sizeof(dt), jcr->start_time);
-            bsendmsg(ua, _("Console connected at %s\n"), dt);
+           bsendmsg(ua, _("Console connected at %s\n"), dt);
         }
         njobs--;
       }
@@ -527,72 +527,72 @@ static void list_running_jobs(UAContext *ua)
       njobs++;
       switch (jcr->JobStatus) {
       case JS_Created:
-         msg = _("is waiting execution");
+        msg = _("is waiting execution");
         break;
       case JS_Running:
-         msg = _("is running");
+        msg = _("is running");
         break;
       case JS_Blocked:
-         msg = _("is blocked");
+        msg = _("is blocked");
         break;
       case JS_Terminated:
-         msg = _("has terminated");
+        msg = _("has terminated");
         break;
       case JS_ErrorTerminated:
-         msg = _("has erred");
+        msg = _("has erred");
         break;
       case JS_Error:
-         msg = _("has errors");
+        msg = _("has errors");
         break;
       case JS_FatalError:
-         msg = _("has a fatal error");
+        msg = _("has a fatal error");
         break;
       case JS_Differences:
-         msg = _("has verify differences");
+        msg = _("has verify differences");
         break;
       case JS_Canceled:
-         msg = _("has been canceled");
+        msg = _("has been canceled");
         break;
       case JS_WaitFD:
         emsg = (char *) get_pool_memory(PM_FNAME);
-         Mmsg(emsg, _("is waiting on Client %s"), jcr->client->hdr.name);
+        Mmsg(emsg, _("is waiting on Client %s"), jcr->client->hdr.name);
         pool_mem = true;
         msg = emsg;
         break;
       case JS_WaitSD:
         emsg = (char *) get_pool_memory(PM_FNAME);
-         Mmsg(emsg, _("is waiting on Storage %s"), jcr->store->hdr.name);
+        Mmsg(emsg, _("is waiting on Storage %s"), jcr->store->hdr.name);
         pool_mem = true;
         msg = emsg;
         break;
       case JS_WaitStoreRes:
-         msg = _("is waiting on max Storage jobs");
+        msg = _("is waiting on max Storage jobs");
         break;
       case JS_WaitClientRes:
-         msg = _("is waiting on max Client jobs");
+        msg = _("is waiting on max Client jobs");
         break;
       case JS_WaitJobRes:
-         msg = _("is waiting on max Job jobs");
+        msg = _("is waiting on max Job jobs");
         break;
       case JS_WaitMaxJobs:
-         msg = _("is waiting on max total jobs");
+        msg = _("is waiting on max total jobs");
         break;
       case JS_WaitStartTime:
-         msg = _("is waiting for its start time");
+        msg = _("is waiting for its start time");
         break;
       case JS_WaitPriority:
-         msg = _("is waiting for higher priority jobs to finish");
+        msg = _("is waiting for higher priority jobs to finish");
         break;
 
       default:
         emsg = (char *) get_pool_memory(PM_FNAME);
-         Mmsg(emsg, _("is in unknown state %c"), jcr->JobStatus);
+        Mmsg(emsg, _("is in unknown state %c"), jcr->JobStatus);
         pool_mem = true;
         msg = emsg;
         break;
       }
-      /* 
-       * Now report Storage daemon status code 
+      /*
+       * Now report Storage daemon status code
        */
       switch (jcr->SDJobStatus) {
       case JS_WaitMount:
@@ -600,21 +600,21 @@ static void list_running_jobs(UAContext *ua)
            free_pool_memory(emsg);
            pool_mem = false;
         }
-         msg = _("is waiting for a mount request");
+        msg = _("is waiting for a mount request");
         break;
       case JS_WaitMedia:
         if (pool_mem) {
            free_pool_memory(emsg);
            pool_mem = false;
         }
-         msg = _("is waiting for an appendable Volume");
+        msg = _("is waiting for an appendable Volume");
         break;
       case JS_WaitFD:
         if (!pool_mem) {
            emsg = (char *) get_pool_memory(PM_FNAME);
            pool_mem = true;
         }
-         Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"),
+        Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"),
              jcr->client->hdr.name, jcr->store->hdr.name);
         msg = emsg;
         break;
@@ -622,7 +622,7 @@ static void list_running_jobs(UAContext *ua)
       switch (jcr->JobType) {
       case JT_ADMIN:
       case JT_RESTORE:
-         bstrncpy(level, "      ", sizeof(level));
+        bstrncpy(level, "      ", sizeof(level));
         break;
       default:
         bstrncpy(level, level_to_str(jcr->JobLevel), sizeof(level));
@@ -630,9 +630,9 @@ static void list_running_jobs(UAContext *ua)
         break;
       }
 
-      bsendmsg(ua, _("%6d %-6s  %-20s %s\n"), 
+      bsendmsg(ua, _("%6d %-6s  %-20s %s\n"),
         jcr->JobId,
-        level, 
+        level,
         jcr->Job,
         msg);
 
@@ -669,7 +669,7 @@ static void list_terminated_jobs(UAContext *ua)
       switch (je->JobType) {
       case JT_ADMIN:
       case JT_RESTORE:
-         bstrncpy(level, "    ", sizeof(level));
+        bstrncpy(level, "    ", sizeof(level));
         break;
       default:
         bstrncpy(level, level_to_str(je->JobLevel), sizeof(level));
@@ -678,38 +678,38 @@ static void list_terminated_jobs(UAContext *ua)
       }
       switch (je->JobStatus) {
       case JS_Created:
-         termstat = "Created";
+        termstat = "Created";
         break;
       case JS_FatalError:
       case JS_ErrorTerminated:
-         termstat = "Error";
+        termstat = "Error";
         break;
       case JS_Differences:
-         termstat = "Diffs";
+        termstat = "Diffs";
         break;
       case JS_Canceled:
-         termstat = "Cancel";
+        termstat = "Cancel";
         break;
       case JS_Terminated:
-         termstat = "OK";
+        termstat = "OK";
         break;
       default:
-         termstat = "Other";
+        termstat = "Other";
         break;
       }
       bstrncpy(JobName, je->Job, sizeof(JobName));
       /* There are three periods after the Job name */
       char *p;
       for (int i=0; i<3; i++) {
-         if ((p=strrchr(JobName, '.')) != NULL) {
+        if ((p=strrchr(JobName, '.')) != NULL) {
            *p = 0;
         }
       }
-      bsendmsg(ua, _("%6d  %-6s %8s %14s %-7s  %-8s %s\n"), 
+      bsendmsg(ua, _("%6d  %-6s %8s %14s %-7s  %-8s %s\n"),
         je->JobId,
-        level, 
+        level,
         edit_uint64_with_commas(je->JobFiles, b1),
-        edit_uint64_with_commas(je->JobBytes, b2), 
+        edit_uint64_with_commas(je->JobBytes, b2),
         termstat,
         dt, JobName);
    }
index 024938b2a9e57f452ed31aade7b9065cdb3f729d..533e0ae86b7f9377dc11b788a62214a881448771 100644 (file)
@@ -58,25 +58,25 @@ static int quitcmd(UAContext *ua, TREE_CTX *tree);
 static int donecmd(UAContext *ua, TREE_CTX *tree);
 
 
-struct cmdstruct { const char *key; int (*func)(UAContext *ua, TREE_CTX *tree); const char *help; }; 
+struct cmdstruct { const char *key; int (*func)(UAContext *ua, TREE_CTX *tree); const char *help; };
 static struct cmdstruct commands[] = {
  { N_("cd"),         cdcmd,        _("change current directory")},
  { N_("count"),      countcmd,     _("count marked files in and below the cd")},
- { N_("dir"),        dircmd,       _("list current directory")},    
+ { N_("dir"),        dircmd,       _("list current directory")},
  { N_("done"),       donecmd,      _("leave file selection mode")},
  { N_("estimate"),   estimatecmd,  _("estimate restore size")},
  { N_("exit"),       donecmd,      _("exit = done")},
  { N_("find"),       findcmd,      _("find files -- wildcards allowed")},
  { N_("help"),       helpcmd,      _("print help")},
- { N_("ls"),         lscmd,        _("list current directory -- wildcards allowed")},    
- { N_("lsmark"),     lsmarkcmd,    _("list the marked files in and below the cd")},    
+ { N_("ls"),         lscmd,        _("list current directory -- wildcards allowed")},
+ { N_("lsmark"),     lsmarkcmd,    _("list the marked files in and below the cd")},
  { N_("mark"),       markcmd,      _("mark dir/file to be restored -- recursively in dirs")},
  { N_("markdir"),    markdircmd,   _("mark directory name to be restored (no files)")},
  { N_("pwd"),        pwdcmd,       _("print current working directory")},
  { N_("unmark"),     unmarkcmd,    _("unmark dir/file to be restored -- recursively in dir")},
  { N_("unmarkdir"),  unmarkdircmd, _("unmark directory name only -- no recursion")},
  { N_("quit"),       quitcmd,      _("quit")},
- { N_("?"),          helpcmd,      _("print help")},    
+ { N_("?"),          helpcmd,      _("print help")},
             };
 #define comsize (sizeof(commands)/sizeof(struct cmdstruct))
 
@@ -94,7 +94,7 @@ bool user_select_files_from_tree(TREE_CTX *tree)
    UAContext *ua = new_ua_context(tree->ua->jcr);
    ua->UA_sock = tree->ua->UA_sock;   /* patch in UA socket */
 
-   bsendmsg(tree->ua, _( 
+   bsendmsg(tree->ua, _(
       "\nYou are now entering file selection mode where you add (mark) and\n"
       "remove (unmark) files to be restored. No files are initially added, unless\n"
       "you used the \"all\" keyword on the command line.\n"
@@ -106,7 +106,7 @@ bool user_select_files_from_tree(TREE_CTX *tree)
    tree->node = (TREE_NODE *)tree->root;
    tree_getpath(tree->node, cwd, sizeof(cwd));
    bsendmsg(tree->ua, _("cwd is: %s\n"), cwd);
-   for ( ;; ) {       
+   for ( ;; ) {
       int found, len, i;
       if (!get_cmd(ua, "$ ")) {
         break;
@@ -126,7 +126,7 @@ bool user_select_files_from_tree(TREE_CTX *tree)
            break;
         }
       if (!found) {
-         bsendmsg(tree->ua, _("Illegal command. Enter \"done\" to exit.\n"));
+        bsendmsg(tree->ua, _("Illegal command. Enter \"done\" to exit.\n"));
         continue;
       }
       if (!stat) {
@@ -208,7 +208,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row)
    if (node->inserted) {
       tree->FileCount++;
       if (tree->DeltaCount > 0 && (tree->FileCount-tree->LastCount) > tree->DeltaCount) {
-         bsendmsg(tree->ua, "+");
+        bsendmsg(tree->ua, "+");
         tree->LastCount = tree->FileCount;
       }
    }
@@ -219,7 +219,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row)
 
 /*
  * Set extract to value passed. We recursively walk
- *  down the tree setting all children if the 
+ *  down the tree setting all children if the
  *  node is a directory.
  */
 static int set_extract(UAContext *ua, TREE_NODE *node, TREE_CTX *tree, bool extract)
@@ -287,7 +287,7 @@ static int set_extract(UAContext *ua, TREE_NODE *node, TREE_CTX *tree, bool extr
 }
 
 /*
- * Recursively mark the current directory to be restored as 
+ * Recursively mark the current directory to be restored as
  *  well as all directories and files below it.
  */
 static int markcmd(UAContext *ua, TREE_CTX *tree)
@@ -310,8 +310,8 @@ static int markcmd(UAContext *ua, TREE_CTX *tree)
    if (count == 0) {
       bsendmsg(ua, _("No files marked.\n"));
    } else {
-      bsendmsg(ua, _("%s file%s marked.\n"),        
-               edit_uint64_with_commas(count, ec1), count==0?"":"s");
+      bsendmsg(ua, _("%s file%s marked.\n"),
+              edit_uint64_with_commas(count, ec1), count==0?"":"s");
    }
    return 1;
 }
@@ -339,8 +339,8 @@ static int markdircmd(UAContext *ua, TREE_CTX *tree)
    if (count == 0) {
       bsendmsg(ua, _("No directories marked.\n"));
    } else {
-      bsendmsg(ua, _("%s director%s marked.\n"), 
-               edit_uint64_with_commas(count, ec1), count==1?"y":"ies");
+      bsendmsg(ua, _("%s director%s marked.\n"),
+              edit_uint64_with_commas(count, ec1), count==1?"y":"ies");
    }
    return 1;
 }
@@ -360,8 +360,8 @@ static int countcmd(UAContext *ua, TREE_CTX *tree)
         }
       }
    }
-   bsendmsg(ua, "%s total files/dirs. %s marked to be restored.\n", 
-           edit_uint64_with_commas(total, ec1), 
+   bsendmsg(ua, "%s total files/dirs. %s marked to be restored.\n",
+           edit_uint64_with_commas(total, ec1),
            edit_uint64_with_commas(num_extract, ec2));
    return 1;
 }
@@ -374,20 +374,20 @@ static int findcmd(UAContext *ua, TREE_CTX *tree)
       bsendmsg(ua, _("No file specification given.\n"));
       return 0;
    }
-   
+
    for (int i=1; i < ua->argc; i++) {
       for (TREE_NODE *node=first_tree_node(tree->root); node; node=next_tree_node(node)) {
         if (fnmatch(ua->argk[i], node->fname, 0) == 0) {
            const char *tag;
            tree_getpath(node, cwd, sizeof(cwd));
            if (node->extract) {
-               tag = "*";
+              tag = "*";
            } else if (node->extract_dir) {
-               tag = "+";
+              tag = "+";
            } else {
-               tag = "";
+              tag = "";
            }
-            bsendmsg(ua, "%s%s\n", tag, cwd);
+           bsendmsg(ua, "%s%s\n", tag, cwd);
         }
       }
    }
@@ -400,20 +400,20 @@ static int lscmd(UAContext *ua, TREE_CTX *tree)
 {
    TREE_NODE *node;
 
-   if (!tree_node_has_child(tree->node)) {     
+   if (!tree_node_has_child(tree->node)) {
       return 1;
    }
    foreach_child(node, tree->node) {
       if (ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) {
         const char *tag;
         if (node->extract) {
-            tag = "*";
+           tag = "*";
         } else if (node->extract_dir) {
-            tag = "+";
+           tag = "+";
         } else {
-            tag = "";
+           tag = "";
         }
-         bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
+        bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
       }
    }
    return 1;
@@ -422,10 +422,10 @@ static int lscmd(UAContext *ua, TREE_CTX *tree)
 /*
  * Ls command that lists only the marked files
  */
-static void rlsmark(UAContext *ua, TREE_NODE *tnode) 
+static void rlsmark(UAContext *ua, TREE_NODE *tnode)
 {
    TREE_NODE *node;
-   if (!tree_node_has_child(tnode)) {    
+   if (!tree_node_has_child(tnode)) {
       return;
    }
    foreach_child(node, tnode) {
@@ -433,13 +433,13 @@ static void rlsmark(UAContext *ua, TREE_NODE *tnode)
          (node->extract || node->extract_dir)) {
         const char *tag;
         if (node->extract) {
-            tag = "*";
+           tag = "*";
         } else if (node->extract_dir) {
-            tag = "+";
+           tag = "+";
         } else {
-            tag = "";
+           tag = "";
         }
-         bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
+        bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
         if (tree_node_has_child(node)) {
            rlsmark(ua, node);
         }
@@ -498,7 +498,7 @@ static int dircmd(UAContext *ua, TREE_CTX *tree)
    char buf[1100];
    char cwd[1100], *pcwd;
 
-   if (!tree_node_has_child(tree->node)) {     
+   if (!tree_node_has_child(tree->node)) {
       bsendmsg(ua, "Node %s has no children.\n", tree->node->fname);
       return 1;
    }
@@ -507,11 +507,11 @@ static int dircmd(UAContext *ua, TREE_CTX *tree)
       const char *tag;
       if (ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) {
         if (node->extract) {
-            tag = "*";
+           tag = "*";
         } else if (node->extract_dir) {
-            tag = "+";
+           tag = "+";
         } else {
-            tag = " ";
+           tag = " ";
         }
         tree_getpath(node, cwd, sizeof(cwd));
         fdbr.FileId = 0;
@@ -541,7 +541,7 @@ static int dircmd(UAContext *ua, TREE_CTX *tree)
            memset(&statp, 0, sizeof(statp));
         }
         ls_output(buf, cwd, tag, &statp);
-         bsendmsg(ua, "%s\n", buf);
+        bsendmsg(ua, "%s\n", buf);
       }
    }
    return 1;
@@ -580,14 +580,14 @@ static int estimatecmd(UAContext *ua, TREE_CTX *tree)
         }
       }
    }
-   bsendmsg(ua, "%d total files; %d marked to be restored; %s bytes.\n", 
+   bsendmsg(ua, "%d total files; %d marked to be restored; %s bytes.\n",
            total, num_extract, edit_uint64_with_commas(total_bytes, ec1));
    return 1;
 }
 
 
 
-static int helpcmd(UAContext *ua, TREE_CTX *tree) 
+static int helpcmd(UAContext *ua, TREE_CTX *tree)
 {
    unsigned int i;
 
@@ -605,7 +605,7 @@ static int helpcmd(UAContext *ua, TREE_CTX *tree)
  *   we assume it is a Win32 absolute cd rather than relative and
  *   try a second time with /x: ...  Win32 kludge.
  */
-static int cdcmd(UAContext *ua, TREE_CTX *tree) 
+static int cdcmd(UAContext *ua, TREE_CTX *tree)
 {
    TREE_NODE *node;
    char cwd[2000];
@@ -617,12 +617,12 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree)
    if (!node) {
       /* Try once more if Win32 drive -- make absolute */
       if (ua->argk[1][1] == ':') {  /* win32 drive */
-         bstrncpy(cwd, "/", sizeof(cwd));
+        bstrncpy(cwd, "/", sizeof(cwd));
         bstrncat(cwd, ua->argk[1], sizeof(cwd));
         node = tree_cwd(cwd, tree->root, tree->node);
       }
       if (!node) {
-         bsendmsg(ua, _("Invalid path given.\n"));
+        bsendmsg(ua, _("Invalid path given.\n"));
       } else {
         tree->node = node;
       }
@@ -634,7 +634,7 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree)
    return 1;
 }
 
-static int pwdcmd(UAContext *ua, TREE_CTX *tree) 
+static int pwdcmd(UAContext *ua, TREE_CTX *tree)
 {
    char cwd[2000];
    tree_getpath(tree->node, cwd, sizeof(cwd));
@@ -648,7 +648,7 @@ static int unmarkcmd(UAContext *ua, TREE_CTX *tree)
    TREE_NODE *node;
    int count = 0;
 
-   if (ua->argc < 2 || !tree_node_has_child(tree->node)) {     
+   if (ua->argc < 2 || !tree_node_has_child(tree->node)) {
       bsendmsg(ua, _("No files unmarked.\n"));
       return 1;
    }
@@ -697,12 +697,12 @@ static int unmarkdircmd(UAContext *ua, TREE_CTX *tree)
 }
 
 
-static int donecmd(UAContext *ua, TREE_CTX *tree) 
+static int donecmd(UAContext *ua, TREE_CTX *tree)
 {
    return 0;
 }
 
-static int quitcmd(UAContext *ua, TREE_CTX *tree) 
+static int quitcmd(UAContext *ua, TREE_CTX *tree)
 {
    ua->quit = true;
    return 0;
index f239fa57b8809ad3d0fc87cc2b3f8cb91e5a8728..0d55d702db6eae7ded0c587745d332c637bb2002 100644 (file)
@@ -44,7 +44,7 @@ extern int debug_level;
 /* Commands sent to File daemon */
 static char verifycmd[]    = "verify level=%s\n";
 static char storaddr[]     = "storage address=%s port=%d ssl=0\n";
-static char sessioncmd[]   = "session %s %ld %ld %ld %ld %ld %ld\n";  
+static char sessioncmd[]   = "session %s %ld %ld %ld %ld %ld %ld\n";
 
 /* Responses received from File daemon */
 static char OKverify[]    = "2000 OK verify\n";
@@ -56,13 +56,13 @@ static void verify_cleanup(JCR *jcr, int TermCode);
 static void prt_fname(JCR *jcr);
 static int missing_handler(void *ctx, int num_fields, char **row);
 
-/* 
+/*
  * Do a verification of the specified files against the Catlaog
- *    
+ *
  *  Returns:  false on failure
  *           true  on success
  */
-bool do_verify(JCR *jcr) 
+bool do_verify(JCR *jcr)
 {
    const char *level, *Name;
    BSOCK   *fd;
@@ -81,12 +81,12 @@ bool do_verify(JCR *jcr)
    Dmsg1(9, "bdird: created client %s record\n", jcr->client->hdr.name);
 
    /*
-    * Find JobId of last job that ran. E.g. 
+    * Find JobId of last job that ran. E.g.
     *  for VERIFY_CATALOG we want the JobId of the last INIT.
-    *  for VERIFY_VOLUME_TO_CATALOG, we want the JobId of the 
+    *  for VERIFY_VOLUME_TO_CATALOG, we want the JobId of the
     *      last backup Job.
     */
-   if (jcr->JobLevel == L_VERIFY_CATALOG || 
+   if (jcr->JobLevel == L_VERIFY_CATALOG ||
        jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG ||
        jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) {
       memcpy(&jr, &jcr->jr, sizeof(jr));
@@ -101,18 +101,18 @@ bool do_verify(JCR *jcr)
       if (!db_find_last_jobid(jcr, jcr->db, Name, &jr)) {
         if (jcr->JobLevel == L_VERIFY_CATALOG) {
            Jmsg(jcr, M_FATAL, 0, _(
-                 "Unable to find JobId of previous InitCatalog Job.\n"
-                 "Please run a Verify with Level=InitCatalog before\n"
-                 "running the current Job.\n"));
+                "Unable to find JobId of previous InitCatalog Job.\n"
+                "Please run a Verify with Level=InitCatalog before\n"
+                "running the current Job.\n"));
          } else {
            Jmsg(jcr, M_FATAL, 0, _(
-                 "Unable to find JobId of previous Job for this client.\n"));
-        }   
+                "Unable to find JobId of previous Job for this client.\n"));
+        }
         goto bail_out;
       }
       verify_jobid = jr.JobId;
       Dmsg1(100, "Last full jobid=%d\n", verify_jobid);
-   } 
+   }
 
    if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
       Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
@@ -131,25 +131,25 @@ bool do_verify(JCR *jcr)
     * Now get the job record for the previous backup that interests
     *  us. We use the verify_jobid that we found above.
     */
-   if (jcr->JobLevel == L_VERIFY_CATALOG || 
+   if (jcr->JobLevel == L_VERIFY_CATALOG ||
        jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG ||
        jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) {
       verify_jr.JobId = verify_jobid;
       if (!db_get_job_record(jcr, jcr->db, &verify_jr)) {
-         Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), 
+        Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"),
              db_strerror(jcr->db));
         goto bail_out;
       }
       if (verify_jr.JobStatus != 'T') {
-         Jmsg(jcr, M_FATAL, 0, _("Last Job %d did not terminate normally. JobStatus=%c\n"),
+        Jmsg(jcr, M_FATAL, 0, _("Last Job %d did not terminate normally. JobStatus=%c\n"),
            verify_jobid, verify_jr.JobStatus);
         goto bail_out;
       }
       Jmsg(jcr, M_INFO, 0, _("Verifying against JobId=%d Job=%s\n"),
-        verify_jr.JobId, verify_jr.Job); 
+        verify_jr.JobId, verify_jr.Job);
    }
 
-   /* 
+   /*
     * If we are verifying a Volume, we need the Storage
     *  daemon, so open a connection, otherwise, just
     *  create a dummy authorization key (passed to
@@ -181,7 +181,7 @@ bool do_verify(JCR *jcr)
       free_pool_memory(fname);
 
       /*
-       * Start conversation with Storage daemon  
+       * Start conversation with Storage daemon
        */
       set_jcr_job_status(jcr, JS_Blocked);
       if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) {
@@ -232,7 +232,7 @@ bool do_verify(JCR *jcr)
       goto bail_out;
    }
 
-   /* 
+   /*
     * Send Level command to File daemon, as well
     *  as the Storage address if appropriate.
     */
@@ -244,7 +244,7 @@ bool do_verify(JCR *jcr)
       level = "catalog";
       break;
    case L_VERIFY_VOLUME_TO_CATALOG:
-      /* 
+      /*
        * send Storage daemon address to the File daemon
        */
       if (jcr->store->SDDport == 0) {
@@ -255,27 +255,27 @@ bool do_verify(JCR *jcr)
         goto bail_out;
       }
 
-      /* 
+      /*
        * Send the bootstrap file -- what Volumes/files to restore
        */
       if (!send_bootstrap_file(jcr)) {
         goto bail_out;
       }
 
-      /* 
-       * The following code is deprecated   
+      /*
+       * The following code is deprecated
        */
       if (!jcr->RestoreBootstrap) {
         /*
          * Pass the VolSessionId, VolSessionTime, Start and
          * end File and Blocks on the session command.
          */
-        bnet_fsend(fd, sessioncmd, 
+        bnet_fsend(fd, sessioncmd,
                   jcr->VolumeName,
-                  jr.VolSessionId, jr.VolSessionTime, 
-                  jr.StartFile, jr.EndFile, jr.StartBlock, 
+                  jr.VolSessionId, jr.VolSessionTime,
+                  jr.StartFile, jr.EndFile, jr.StartBlock,
                   jr.EndBlock);
-         if (!response(jcr, fd, OKsession, "Session", DISPLAY_ERROR)) {
+        if (!response(jcr, fd, OKsession, "Session", DISPLAY_ERROR)) {
            goto bail_out;
         }
       }
@@ -297,7 +297,7 @@ bool do_verify(JCR *jcr)
       goto bail_out;
    }
 
-   /* 
+   /*
     * Send verify command/level to File daemon
     */
    bnet_fsend(fd, verifycmd, level);
@@ -311,7 +311,7 @@ bool do_verify(JCR *jcr)
     *  catalog depending on the run type.
     */
    /* Compare to catalog */
-   switch (jcr->JobLevel) { 
+   switch (jcr->JobLevel) {
    case L_VERIFY_CATALOG:
       Dmsg0(10, "Verify level=catalog\n");
       jcr->sd_msg_thread_done = true;  /* no SD msg thread, so it is done */
@@ -389,7 +389,7 @@ static void verify_cleanup(JCR *jcr, int TermCode)
       break;
    case JS_FatalError:
    case JS_ErrorTerminated:
-      term_msg = _("*** Verify Error ***"); 
+      term_msg = _("*** Verify Error ***");
       msg_type = M_ERROR;         /* Generate error message */
       break;
    case JS_Error:
@@ -403,8 +403,8 @@ static void verify_cleanup(JCR *jcr, int TermCode)
       break;
    default:
       term_msg = term_code;
-      bsnprintf(term_code, sizeof(term_code), 
-                _("Inappropriate term code: %d %c\n"), TermCode, TermCode);
+      bsnprintf(term_code, sizeof(term_code),
+               _("Inappropriate term code: %d %c\n"), TermCode, TermCode);
       break;
    }
    bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime);
@@ -418,22 +418,22 @@ static void verify_cleanup(JCR *jcr, int TermCode)
    jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
    if (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG) {
       jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
-      Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\
-  JobId:                  %d\n\
-  Job:                    %s\n\
-  FileSet:                %s\n\
-  Verify Level:           %s\n\
-  Client:                 %s\n\
-  Verify JobId:           %d\n\
-  Verify Job:             %s\n\
-  Start time:             %s\n\
-  End time:               %s\n\
-  Files Expected:         %s\n\
-  Files Examined:         %s\n\
-  Non-fatal FD errors:    %d\n\
-  FD termination status:  %s\n\
-  SD termination status:  %s\n\
-  Termination:            %s\n\n"),
+      Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
+"  JobId:                  %d\n"
+"  Job:                    %s\n"
+"  FileSet:                %s\n"
+"  Verify Level:           %s\n"
+"  Client:                 %s\n"
+"  Verify JobId:           %d\n"
+"  Verify Job:             %s\n"
+"  Start time:             %s\n"
+"  End time:               %s\n"
+"  Files Expected:         %s\n"
+"  Files Examined:         %s\n"
+"  Non-fatal FD errors:    %d\n"
+"  FD termination status:  %s\n"
+"  SD termination status:  %s\n"
+"  Termination:            %s\n\n"),
         edt,
         jcr->jr.JobId,
         jcr->jr.Job,
@@ -451,20 +451,20 @@ static void verify_cleanup(JCR *jcr, int TermCode)
         sd_term_msg,
         term_msg);
    } else {
-      Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\
-  JobId:                  %d\n\
-  Job:                    %s\n\
-  FileSet:                %s\n\
-  Verify Level:           %s\n\
-  Client:                 %s\n\
-  Verify JobId:           %d\n\
-  Verify Job:             %s\n\
-  Start time:             %s\n\
-  End time:               %s\n\
-  Files Examined:         %s\n\
-  Non-fatal FD errors:    %d\n\
-  FD termination status:  %s\n\
-  Termination:            %s\n\n"),
+      Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
+"  JobId:                  %d\n"
+"  Job:                    %s\n"
+"  FileSet:                %s\n"
+"  Verify Level:           %s\n"
+"  Client:                 %s\n"
+"  Verify JobId:           %d\n"
+"  Verify Job:             %s\n"
+"  Start time:             %s\n"
+"  End time:               %s\n"
+"  Files Examined:         %s\n"
+"  Non-fatal FD errors:    %d\n"
+"  FD termination status:  %s\n"
+"  Termination:            %s\n\n"),
         edt,
         jcr->jr.JobId,
         jcr->jr.Job,
@@ -507,7 +507,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
    fd = jcr->file_bsock;
    fdbr.JobId = JobId;
    jcr->FileIndex = 0;
-   
+
    Dmsg0(20, "bdird: waiting to receive file attributes\n");
    /*
     * Get Attributes and Signature from File daemon
@@ -527,14 +527,14 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
       fname = check_pool_memory_size(fname, fd->msglen);
       jcr->fname = check_pool_memory_size(jcr->fname, fd->msglen);
       Dmsg1(200, "Atts+SIG=%s\n", fd->msg);
-      if ((len = sscanf(fd->msg, "%ld %d %100s", &file_index, &stream, 
+      if ((len = sscanf(fd->msg, "%ld %d %100s", &file_index, &stream,
            fname)) != 3) {
-         Jmsg3(jcr, M_FATAL, 0, _("bird<filed: bad attributes, expected 3 fields got %d\n\
- mslen=%d msg=%s\n"), len, fd->msglen, fd->msg);
+        Jmsg3(jcr, M_FATAL, 0, _("bird<filed: bad attributes, expected 3 fields got %d\n"
+" mslen=%d msg=%s\n"), len, fd->msglen, fd->msg);
         goto bail_out;
       }
       /*
-       * We read the Options or Signature into fname                               
+       * We read the Options or Signature into fname
        *  to prevent overrun, now copy it to proper location.
        */
       bstrncpy(Opts_SIG, fname, sizeof(Opts_SIG));
@@ -543,7 +543,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
       skip_spaces(&p);
       skip_nonspaces(&p);            /* skip Stream */
       skip_spaces(&p);
-      skip_nonspaces(&p);            /* skip Opts_SIG */   
+      skip_nonspaces(&p);            /* skip Opts_SIG */
       p++;                           /* skip space */
       fn = fname;
       while (*p != 0) {
@@ -556,7 +556,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
        */
       if (stream == STREAM_UNIX_ATTRIBUTES || stream == STREAM_UNIX_ATTRIBUTES_EX) {
         int32_t LinkFIf, LinkFIc;
-         Dmsg2(400, "file_index=%d attr=%s\n", file_index, attr);
+        Dmsg2(400, "file_index=%d attr=%s\n", file_index, attr);
         jcr->JobFiles++;
         jcr->FileIndex = file_index;    /* remember attribute file_index */
         decode_stat(attr, &statf, &LinkFIf);  /* decode file stat packet */
@@ -564,28 +564,28 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
         jcr->fn_printed = false;
         pm_strcpy(jcr->fname, fname);  /* move filename into JCR */
 
-         Dmsg2(040, "dird<filed: stream=%d %s\n", stream, jcr->fname);
-         Dmsg1(020, "dird<filed: attr=%s\n", attr);
+        Dmsg2(040, "dird<filed: stream=%d %s\n", stream, jcr->fname);
+        Dmsg1(020, "dird<filed: attr=%s\n", attr);
 
-        /* 
-         * Find equivalent record in the database 
+        /*
+         * Find equivalent record in the database
          */
         fdbr.FileId = 0;
-        if (!db_get_file_attributes_record(jcr, jcr->db, jcr->fname, 
+        if (!db_get_file_attributes_record(jcr, jcr->db, jcr->fname,
              jcr->verify_jr, &fdbr)) {
-            Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->fname);
-            Dmsg1(020, _("File not in catalog: %s\n"), jcr->fname);
+           Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->fname);
+           Dmsg1(020, _("File not in catalog: %s\n"), jcr->fname);
            stat = JS_Differences;
            continue;
         } else {
-           /* 
+           /*
             * mark file record as visited by stuffing the
             * current JobId, which is unique, into the MarkId field.
             */
            db_mark_file_record(jcr, jcr->db, fdbr.FileId, jcr->JobId);
         }
 
-         Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->fname, 
+        Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->fname,
            file_index, Opts_SIG);
         decode_stat(fdbr.LStat, &statc, &LinkFIc); /* decode catalog stat */
         /*
@@ -595,95 +595,95 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
         for (p=Opts_SIG; *p; p++) {
            char ed1[30], ed2[30];
            switch (*p) {
-            case 'i':                /* compare INODEs */
+           case 'i':                /* compare INODEs */
               if (statc.st_ino != statf.st_ino) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_ino   differ. Cat: %s File: %s\n"), 
+                 Jmsg(jcr, M_INFO, 0, _("      st_ino   differ. Cat: %s File: %s\n"),
                     edit_uint64((uint64_t)statc.st_ino, ed1),
                     edit_uint64((uint64_t)statf.st_ino, ed2));
                  stat = JS_Differences;
               }
               break;
-            case 'p':                /* permissions bits */
+           case 'p':                /* permissions bits */
               if (statc.st_mode != statf.st_mode) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_mode  differ. Cat: %x File: %x\n"), 
+                 Jmsg(jcr, M_INFO, 0, _("      st_mode  differ. Cat: %x File: %x\n"),
                     (uint32_t)statc.st_mode, (uint32_t)statf.st_mode);
                  stat = JS_Differences;
               }
               break;
-            case 'n':                /* number of links */
+           case 'n':                /* number of links */
               if (statc.st_nlink != statf.st_nlink) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_nlink differ. Cat: %d File: %d\n"), 
+                 Jmsg(jcr, M_INFO, 0, _("      st_nlink differ. Cat: %d File: %d\n"),
                     (uint32_t)statc.st_nlink, (uint32_t)statf.st_nlink);
                  stat = JS_Differences;
               }
               break;
-            case 'u':                /* user id */
+           case 'u':                /* user id */
               if (statc.st_uid != statf.st_uid) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_uid   differ. Cat: %u File: %u\n"), 
+                 Jmsg(jcr, M_INFO, 0, _("      st_uid   differ. Cat: %u File: %u\n"),
                     (uint32_t)statc.st_uid, (uint32_t)statf.st_uid);
                  stat = JS_Differences;
               }
               break;
-            case 'g':                /* group id */
+           case 'g':                /* group id */
               if (statc.st_gid != statf.st_gid) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_gid   differ. Cat: %u File: %u\n"), 
+                 Jmsg(jcr, M_INFO, 0, _("      st_gid   differ. Cat: %u File: %u\n"),
                     (uint32_t)statc.st_gid, (uint32_t)statf.st_gid);
                  stat = JS_Differences;
               }
               break;
-            case 's':                /* size */
+           case 's':                /* size */
               if (statc.st_size != statf.st_size) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_size  differ. Cat: %s File: %s\n"), 
+                 Jmsg(jcr, M_INFO, 0, _("      st_size  differ. Cat: %s File: %s\n"),
                     edit_uint64((uint64_t)statc.st_size, ed1),
                     edit_uint64((uint64_t)statf.st_size, ed2));
                  stat = JS_Differences;
               }
               break;
-            case 'a':                /* access time */
+           case 'a':                /* access time */
               if (statc.st_atime != statf.st_atime) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_atime differs\n"));
+                 Jmsg(jcr, M_INFO, 0, _("      st_atime differs\n"));
                  stat = JS_Differences;
               }
               break;
-            case 'm':
+           case 'm':
               if (statc.st_mtime != statf.st_mtime) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_mtime differs\n"));
+                 Jmsg(jcr, M_INFO, 0, _("      st_mtime differs\n"));
                  stat = JS_Differences;
               }
               break;
-            case 'c':                /* ctime */
+           case 'c':                /* ctime */
               if (statc.st_ctime != statf.st_ctime) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_ctime differs\n"));
+                 Jmsg(jcr, M_INFO, 0, _("      st_ctime differs\n"));
                  stat = JS_Differences;
               }
               break;
-            case 'd':                /* file size decrease */
+           case 'd':                /* file size decrease */
               if (statc.st_size > statf.st_size) {
                  prt_fname(jcr);
-                  Jmsg(jcr, M_INFO, 0, _("      st_size  decrease. Cat: %s File: %s\n"), 
+                 Jmsg(jcr, M_INFO, 0, _("      st_size  decrease. Cat: %s File: %s\n"),
                     edit_uint64((uint64_t)statc.st_size, ed1),
                     edit_uint64((uint64_t)statf.st_size, ed2));
                  stat = JS_Differences;
               }
               break;
-            case '5':                /* compare MD5 */
-               Dmsg1(500, "set Do_MD5 for %s\n", jcr->fname);
+           case '5':                /* compare MD5 */
+              Dmsg1(500, "set Do_MD5 for %s\n", jcr->fname);
               do_SIG = MD5_SIG;
               break;
-            case '1':                 /* compare SHA1 */
+           case '1':                 /* compare SHA1 */
               do_SIG = SHA1_SIG;
               break;
-            case ':':
-            case 'V':
+           case ':':
+           case 'V':
            default:
               break;
            }
@@ -693,26 +693,26 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
        *  It came across in the Opts_SIG field.
        */
       } else if (stream == STREAM_MD5_SIGNATURE || stream == STREAM_SHA1_SIGNATURE) {
-         Dmsg2(400, "stream=SIG inx=%d SIG=%s\n", file_index, Opts_SIG);
-        /* 
+        Dmsg2(400, "stream=SIG inx=%d SIG=%s\n", file_index, Opts_SIG);
+        /*
          * When ever we get a signature is MUST have been
          * preceded by an attributes record, which sets attr_file_index
          */
         if (jcr->FileIndex != (uint32_t)file_index) {
-            Jmsg2(jcr, M_FATAL, 0, _("MD5/SHA1 index %d not same as attributes %d\n"),
+           Jmsg2(jcr, M_FATAL, 0, _("MD5/SHA1 index %d not same as attributes %d\n"),
               file_index, jcr->FileIndex);
            goto bail_out;
-        } 
+        }
         if (do_SIG) {
            db_escape_string(buf, Opts_SIG, strlen(Opts_SIG));
            if (strcmp(buf, fdbr.SIG) != 0) {
               prt_fname(jcr);
               if (debug_level >= 10) {
-                  Jmsg(jcr, M_INFO, 0, _("      %s not same. File=%s Cat=%s\n"), 
-                       stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1", buf, fdbr.SIG);
+                 Jmsg(jcr, M_INFO, 0, _("      %s not same. File=%s Cat=%s\n"),
+                      stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1", buf, fdbr.SIG);
               } else {
-                  Jmsg(jcr, M_INFO, 0, _("      %s differs.\n"), 
-                       stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1");
+                 Jmsg(jcr, M_INFO, 0, _("      %s differs.\n"),
+                      stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1");
               }
               stat = JS_Differences;
            }
@@ -720,7 +720,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
         }
       }
       jcr->JobFiles = file_index;
-   } 
+   }
    if (is_bnet_error(fd)) {
       Jmsg2(jcr, M_FATAL, 0, _("bdird<filed: bad attributes from filed n=%d : %s\n"),
                        n, strerror(errno));
@@ -731,11 +731,11 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
     *  the database where the MarkedId != current JobId
     */
    jcr->fn_printed = false;
-   sprintf(buf, 
+   sprintf(buf,
 "SELECT Path.Path,Filename.Name FROM File,Path,Filename "
 "WHERE File.JobId=%d "
 "AND File.MarkedId!=%d AND File.PathId=Path.PathId "
-"AND File.FilenameId=Filename.FilenameId", 
+"AND File.FilenameId=Filename.FilenameId",
       JobId, jcr->JobId);
    /* missing_handler is called for each file found */
    db_sql_query(jcr->db, buf, missing_handler, (void *)jcr);
@@ -745,7 +745,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
    free_pool_memory(fname);
    set_jcr_job_status(jcr, stat);
    return 1;
-    
+
 bail_out:
    free_pool_memory(fname);
    set_jcr_job_status(jcr, JS_ErrorTerminated);
@@ -772,7 +772,7 @@ static int missing_handler(void *ctx, int num_fields, char **row)
 }
 
 
-/* 
+/*
  * Print filename for verify
  */
 static void prt_fname(JCR *jcr)
index d0ad7ab74e25ba1166dd65381e6785bb72994a96..a5728416a76f850556c9b8ce3885eba883b52556 100644 (file)
@@ -4,7 +4,7 @@
  *   Kern Sibbald, October 2000
  *
  *   Version $Id$
- * 
+ *
  */
 /*
    Copyright (C) 2000-2004 Kern Sibbald and John Walker
@@ -25,7 +25,7 @@
    MA 02111-1307, USA.
 
  */
-  
+
 #include "bacula.h"
 #include "filed.h"
 
@@ -33,7 +33,7 @@ static char OK_hello[]  = "2000 OK Hello\n";
 static char Dir_sorry[] = "2999 No go\n";
 
 
-/********************************************************************* 
+/*********************************************************************
  *
  */
 static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
@@ -49,9 +49,9 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
       return 0;
    }
    if (bs->msglen < 25 || bs->msglen > 200) {
-      Dmsg2(50, _("Bad Hello command from Director at %s. Len=%d.\n"), 
+      Dmsg2(50, _("Bad Hello command from Director at %s. Len=%d.\n"),
            bs->who, bs->msglen);
-      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s. Len=%d.\n"), 
+      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s. Len=%d.\n"),
            bs->who, bs->msglen);
       return 0;
    }
@@ -61,9 +61,9 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    if (sscanf(bs->msg, "Hello Director %s calling\n", dirname) != 1) {
       free_pool_memory(dirname);
       bs->msg[100] = 0;
-      Dmsg2(50, _("Bad Hello command from Director at %s: %s\n"), 
+      Dmsg2(50, _("Bad Hello command from Director at %s: %s\n"),
            bs->who, bs->msg);
-      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"), 
+      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"),
            bs->who, bs->msg);
       return 0;
    }
@@ -77,25 +77,25 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    if (!director) {
       Dmsg2(50, _("Connection from unknown Director %s at %s rejected.\n"),
            dirname, bs->who);
-      Emsg2(M_FATAL, 0, _("Connection from unknown Director %s at %s rejected.\n"   
-       "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"), 
+      Emsg2(M_FATAL, 0, _("Connection from unknown Director %s at %s rejected.\n"
+       "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"),
            dirname, bs->who);
       free_pool_memory(dirname);
       return 0;
    }
    btimer_t *tid = start_bsock_timer(bs, AUTH_TIMEOUT);
-   auth = cram_md5_auth(bs, director->password, ssl_need);  
+   auth = cram_md5_auth(bs, director->password, ssl_need);
    if (auth) {
-      get_auth = cram_md5_get_auth(bs, director->password, ssl_need);  
+      get_auth = cram_md5_get_auth(bs, director->password, ssl_need);
       if (!get_auth) {
-         Dmsg1(50, "cram_get_auth failed for %s\n", bs->who);
+        Dmsg1(50, "cram_get_auth failed for %s\n", bs->who);
       }
    } else {
       Dmsg1(50, "cram_auth failed for %s\n", bs->who);
    }
    if (!auth || !get_auth) {
-      Emsg1(M_FATAL, 0, _("Incorrect password given by Director at %s.\n"  
-       "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"), 
+      Emsg1(M_FATAL, 0, _("Incorrect password given by Director at %s.\n"
+       "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"),
            bs->who);
       director = NULL;
    }
@@ -108,7 +108,7 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
 /*
  * Inititiate the communications with the Director.
  * He has made a connection to our server.
- * 
+ *
  * Basic tasks done here:
  *   We read Director's initial message and authorize him.
  *
@@ -137,19 +137,19 @@ int authenticate_storagedaemon(JCR *jcr)
    bool get_auth, auth = false;
 
    btimer_t *tid = start_bsock_timer(sd, AUTH_TIMEOUT);
-   get_auth = cram_md5_get_auth(sd, jcr->sd_auth_key, ssl_need);  
+   get_auth = cram_md5_get_auth(sd, jcr->sd_auth_key, ssl_need);
    if (!get_auth) {
       Dmsg1(50, "cram_get_auth failed for %s\n", sd->who);
    } else {
       auth = cram_md5_auth(sd, jcr->sd_auth_key, ssl_need);
       if (!auth) {
-         Dmsg1(50, "cram_auth failed for %s\n", sd->who);
+        Dmsg1(50, "cram_auth failed for %s\n", sd->who);
       }
    }
    stop_bsock_timer(tid);
    memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key));
    if (!get_auth || !auth) {
-      Jmsg(jcr, M_FATAL, 0, _("Authorization key rejected by Storage daemon.\n"   
+      Jmsg(jcr, M_FATAL, 0, _("Authorization key rejected by Storage daemon.\n"
        "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"));
    }
    return get_auth && auth;
index 2ade1050b1a467cd6deb79c4b90551b75222bc4d..afbb66032955e9bd0ddb03745605c293f3f48539 100644 (file)
@@ -38,9 +38,9 @@
 static int save_file(FF_PKT *ff_pkt, void *pkt);
 static int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *chksum);
 
-/* 
+/*
  * Find all the requested files and send them
- * to the Storage daemon. 
+ * to the Storage daemon.
  *
  * Note, we normally carry on a one-way
  * conversation from this point on with the SD, simply blasting
@@ -48,9 +48,9 @@ static int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHK
  * also run a "heartbeat" monitor which reads the socket and
  * reacts accordingly (at the moment it has nothing to do
  * except echo the heartbeat to the Director).
- * 
+ *
  */
-bool blast_data_to_storage_daemon(JCR *jcr, char *addr) 
+bool blast_data_to_storage_daemon(JCR *jcr, char *addr)
 {
    BSOCK *sd;
    bool ok = true;
@@ -76,7 +76,7 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr)
       return false;
    }
 
-   jcr->buf_size = sd->msglen;            
+   jcr->buf_size = sd->msglen;
    /* Adjust for compression so that output buffer is
     * 12 bytes + 0.1% larger than input buffer plus 18 bytes.
     * This gives a bit extra plus room for the sparse addr if any.
@@ -113,9 +113,9 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr)
    }
    Dmsg1(300, "end blast_data stat=%d\n", ok);
    return ok;
-}         
+}
 
-/* 
+/*
  * Called here by find() for each file included.
  *
  *  *****FIXME*****   add FSMs File System Modules
@@ -162,13 +162,13 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    case FT_INVALIDFS:
    case FT_DIREND:
       if (ff_pkt->type == FT_NORECURSE) {
-         Jmsg(jcr, M_INFO, 1, _("     Recursion turned off. Will not descend into %s\n"), 
+        Jmsg(jcr, M_INFO, 1, _("     Recursion turned off. Will not descend into %s\n"),
            ff_pkt->fname);
       } else if (ff_pkt->type == FT_NOFSCHG) {
-         Jmsg(jcr, M_INFO, 1, _("     File system change prohibited. Will not descend into %s\n"), 
+        Jmsg(jcr, M_INFO, 1, _("     File system change prohibited. Will not descend into %s\n"),
            ff_pkt->fname);
       } else if (ff_pkt->type == FT_INVALIDFS) {
-         Jmsg(jcr, M_INFO, 1, _("     Disallowed filesystem. Will not descend into %s\n"), 
+        Jmsg(jcr, M_INFO, 1, _("     Disallowed filesystem. Will not descend into %s\n"),
            ff_pkt->fname);
       }
       ff_pkt->type = FT_DIREND;       /* value is used below */
@@ -186,7 +186,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    case FT_NOACCESS: {
       berrno be;
       be.set_errno(ff_pkt->ff_errno);
-      Jmsg(jcr, M_NOTSAVED, 0, _("     Could not access %s: ERR=%s\n"), ff_pkt->fname, 
+      Jmsg(jcr, M_NOTSAVED, 0, _("     Could not access %s: ERR=%s\n"), ff_pkt->fname,
         be.strerror());
       jcr->Errors++;
       return 1;
@@ -194,7 +194,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    case FT_NOFOLLOW: {
       berrno be;
       be.set_errno(ff_pkt->ff_errno);
-      Jmsg(jcr, M_NOTSAVED, 0, _("     Could not follow link %s: ERR=%s\n"), ff_pkt->fname, 
+      Jmsg(jcr, M_NOTSAVED, 0, _("     Could not follow link %s: ERR=%s\n"), ff_pkt->fname,
         be.strerror());
       jcr->Errors++;
       return 1;
@@ -202,7 +202,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    case FT_NOSTAT: {
       berrno be;
       be.set_errno(ff_pkt->ff_errno);
-      Jmsg(jcr, M_NOTSAVED, 0, _("     Could not stat %s: ERR=%s\n"), ff_pkt->fname, 
+      Jmsg(jcr, M_NOTSAVED, 0, _("     Could not stat %s: ERR=%s\n"), ff_pkt->fname,
         be.strerror());
       jcr->Errors++;
       return 1;
@@ -217,7 +217,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    case FT_NOOPEN: {
       berrno be;
       be.set_errno(ff_pkt->ff_errno);
-      Jmsg(jcr, M_NOTSAVED, 0, _("     Could not open directory %s: ERR=%s\n"), ff_pkt->fname, 
+      Jmsg(jcr, M_NOTSAVED, 0, _("     Could not open directory %s: ERR=%s\n"), ff_pkt->fname,
         be.strerror());
       jcr->Errors++;
       return 1;
@@ -238,13 +238,13 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    attr_stream = encode_attribsEx(jcr, attribsEx, ff_pkt);
 
    Dmsg3(300, "File %s\nattribs=%s\nattribsEx=%s\n", ff_pkt->fname, attribs, attribsEx);
-     
+
    P(jcr->mutex);
    jcr->JobFiles++;                   /* increment number of files sent */
    ff_pkt->FileIndex = jcr->JobFiles;  /* return FileIndex */
    pm_strcpy(jcr->last_fname, ff_pkt->fname);
    V(jcr->mutex);
-    
+
    /*
     * Send Attributes header to Storage daemon
     *   <file-index> <stream> <info>
@@ -271,15 +271,15 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
     */
    if (ff_pkt->type == FT_LNK || ff_pkt->type == FT_LNKSAVED) {
       Dmsg2(300, "Link %s to %s\n", ff_pkt->fname, ff_pkt->link);
-      stat = bnet_fsend(sd, "%ld %d %s%c%s%c%s%c%s%c", jcr->JobFiles, 
+      stat = bnet_fsend(sd, "%ld %d %s%c%s%c%s%c%s%c", jcr->JobFiles,
               ff_pkt->type, ff_pkt->fname, 0, attribs, 0, ff_pkt->link, 0,
               attribsEx, 0);
    } else if (ff_pkt->type == FT_DIREND) {
       /* Here link is the canonical filename (i.e. with trailing slash) */
-      stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles, 
+      stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles,
               ff_pkt->type, ff_pkt->link, 0, attribs, 0, 0, attribsEx, 0);
    } else {
-      stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles, 
+      stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles,
               ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0, attribsEx, 0);
    }
 
@@ -306,17 +306,17 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
       set_prog(&ff_pkt->bfd, ff_pkt->reader, jcr);
    }
 
-   /* 
+   /*
     * Open any file with data that we intend to save, then save it.
     *
     * Note, if is_win32_backup, we must open the Directory so that
     * the BackupRead will save its permissions and ownership streams.
     */
-   if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && 
-        ff_pkt->statp.st_size > 0) || 
+   if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) &&
+        ff_pkt->statp.st_size > 0) ||
         ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO ||
         (!is_portable_backup(&ff_pkt->bfd) && ff_pkt->type == FT_DIREND)) {
-      btimer_t *tid;   
+      btimer_t *tid;
       if (ff_pkt->type == FT_FIFO) {
         tid = start_thread_timer(pthread_self(), 60);
       } else {
@@ -325,7 +325,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
       if (bopen(&ff_pkt->bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) {
         ff_pkt->ff_errno = errno;
         berrno be;
-         Jmsg(jcr, M_NOTSAVED, 0, _("     Cannot open %s: ERR=%s.\n"), ff_pkt->fname, 
+        Jmsg(jcr, M_NOTSAVED, 0, _("     Cannot open %s: ERR=%s.\n"), ff_pkt->fname,
              be.strerror());
         jcr->Errors++;
         if (tid) {
@@ -354,7 +354,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
         if (!bopen_rsrc(&ff_pkt->bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) {
            ff_pkt->ff_errno = errno;
            berrno be;
-            Jmsg(jcr, M_NOTSAVED, -1, _("     Cannot open resource fork for %s: ERR=%s.\n"), ff_pkt->fname, 
+           Jmsg(jcr, M_NOTSAVED, -1, _("     Cannot open resource fork for %s: ERR=%s.\n"), ff_pkt->fname,
                  be.strerror());
            jcr->Errors++;
            if (is_bopen(&ff_pkt->bfd)) {
@@ -389,51 +389,51 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    if (ff_pkt->flags & FO_ACL) {
       char *acl_text = NULL;
       char *aclDef_text = NULL;
-      
+
       /* Read ACLs for files, dirs and links */
       if (ff_pkt->type == FT_DIREND) {
         /* Directory: Check for default ACL*/
         acl_t myDefAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_DEFAULT);
-         /* Check for Access ACL */
-         acl_t myAccAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS);
-         if (!myDefAcl || !myAccAcl) {
-            Jmsg1(jcr, M_WARNING, 0, "Error while trying to get ACL of directory: %s!\n", ff_pkt->fname);
-         }
-         if(myDefAcl){
-            aclDef_text = acl_to_any_text(myDefAcl, NULL, ',', TEXT_ABBREVIATE);
-            acl_free(myDefAcl);
-         }
-         if(myAccAcl){
-            acl_text = acl_to_any_text(myAccAcl, NULL, ',', TEXT_ABBREVIATE);
-            acl_free(myAccAcl);
-         }
+        /* Check for Access ACL */
+        acl_t myAccAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS);
+        if (!myDefAcl || !myAccAcl) {
+           Jmsg1(jcr, M_WARNING, 0, "Error while trying to get ACL of directory: %s!\n", ff_pkt->fname);
+        }
+        if(myDefAcl){
+           aclDef_text = acl_to_any_text(myDefAcl, NULL, ',', TEXT_ABBREVIATE);
+           acl_free(myDefAcl);
+        }
+        if(myAccAcl){
+           acl_text = acl_to_any_text(myAccAcl, NULL, ',', TEXT_ABBREVIATE);
+           acl_free(myAccAcl);
+        }
       } else {
         /* Files or links */
-         acl_t myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS);
+        acl_t myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS);
         if (!myAcl) {
-            Jmsg1(jcr, M_WARNING, 0, "Error while trying to get ACL of file: %s!\n", ff_pkt->fname);
+           Jmsg1(jcr, M_WARNING, 0, "Error while trying to get ACL of file: %s!\n", ff_pkt->fname);
            acl_free(myAcl);
         }
-         acl_text = acl_to_any_text(myAcl, NULL, ',', TEXT_ABBREVIATE);
+        acl_text = acl_to_any_text(myAcl, NULL, ',', TEXT_ABBREVIATE);
         acl_free(myAcl);
       }
-      
+
       POOLMEM *msgsave;
-      
+
       /* If there is an ACL, send it to the Storage daemon */
       if (acl_text != NULL) {
         sd = jcr->store_bsock;
         pm_strcpy(&jcr->last_fname, ff_pkt->fname);
-      
-        
+
+
         // Send ACL header
-         if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_ACCESS_ACL)) {
+        if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_ACCESS_ACL)) {
            berrno be;
-            Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+           Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
                  bnet_strerror(sd));
            return 0;
         }
-      
+
         /* Send the buffer to the storage deamon */
         msgsave = sd->msg;
         sd->msg = acl_text;
@@ -442,34 +442,34 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
            berrno be;
            sd->msg = msgsave;
            sd->msglen = 0;
-            Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+           Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
                  bnet_strerror(sd));
         } else {
            jcr->JobBytes += sd->msglen;
            sd->msg = msgsave;
            if (!bnet_sig(sd, BNET_EOD)) {
               berrno be;
-               Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+              Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
                     bnet_strerror(sd));
            } else {
-               Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname);
+              Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname);
            }
-        }  
+        }
       }
       /* If there is an Default ACL, send it to the Storage daemon */
       if (aclDef_text != NULL) {
         sd = jcr->store_bsock;
         pm_strcpy(&jcr->last_fname, ff_pkt->fname);
-      
-        
+
+
         // Send ACL header
         if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_DEFAULT_ACL)) {
            berrno be;
-            Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+           Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
                  bnet_strerror(sd));
            return 0;
         }
-      
+
         // Send the buffer to the storage deamon
         msgsave = sd->msg;
         sd->msg = aclDef_text;
@@ -478,21 +478,21 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
            berrno be;
            sd->msg = msgsave;
            sd->msglen = 0;
-            Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+           Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
                  bnet_strerror(sd));
         } else {
            jcr->JobBytes += sd->msglen;
            sd->msg = msgsave;
            if (!bnet_sig(sd, BNET_EOD)) {
               berrno be;
-               Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+              Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
                     bnet_strerror(sd));
            } else {
-               Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname);
+              Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname);
            }
-        }  
+        }
       }
-   }   
+   }
 #endif
 
    /* Terminate any signature and send it to Storage daemon and the Director */
@@ -504,11 +504,11 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
       } else if (chksum.type == CHKSUM_SHA1) {
         stream = STREAM_SHA1_SIGNATURE;
       } else {
-         Jmsg1(jcr, M_WARNING, 0, _("Unknown signature type %i."), chksum.type);
+        Jmsg1(jcr, M_WARNING, 0, _("Unknown signature type %i."), chksum.type);
       }
       if (stream != 0) {
-         bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, stream);
-         Dmsg1(300, "bfiled>stored:header %s\n", sd->msg);
+        bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, stream);
+        Dmsg1(300, "bfiled>stored:header %s\n", sd->msg);
         memcpy(sd->msg, chksum.signature, chksum.length);
         sd->msglen = chksum.length;
         bnet_send(sd);
@@ -537,7 +537,7 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch
    POOLMEM *msgsave;
 
    msgsave = sd->msg;
-   rbuf = sd->msg;                   /* read buffer */             
+   rbuf = sd->msg;                   /* read buffer */
    wbuf = sd->msg;                   /* write buffer */
 
 
@@ -574,13 +574,13 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch
 
    /*
     * Make space at beginning of buffer for fileAddr because this
-    *  same buffer will be used for writing if compression if off. 
+    *  same buffer will be used for writing if compression if off.
     */
    if (ff_pkt->flags & FO_SPARSE) {
       rbuf += SPARSE_FADDR_SIZE;
       rsize -= SPARSE_FADDR_SIZE;
 #ifdef HAVE_FREEBSD_OS
-      /* 
+      /*
        * To read FreeBSD partitions, the read size must be
        *  a multiple of 512.
        */
@@ -588,7 +588,7 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch
 #endif
    }
 
-   /* 
+   /*
     * Read the file data
     */
    while ((sd->msglen=(uint32_t)bread(&ff_pkt->bfd, rbuf, rsize)) > 0) {
@@ -597,14 +597,14 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch
       /* Check for sparse blocks */
       if (ff_pkt->flags & FO_SPARSE) {
         ser_declare;
-        if (sd->msglen == rsize && 
+        if (sd->msglen == rsize &&
             (fileAddr+sd->msglen < (uint64_t)ff_pkt->statp.st_size)) {
            sparseBlock = is_buf_zero(rbuf, rsize);
         }
-           
+
         ser_begin(wbuf, SPARSE_FADDR_SIZE);
         ser_uint64(fileAddr);     /* store fileAddr in begin of buffer */
-      } 
+      }
 
       jcr->ReadBytes += sd->msglen;        /* count bytes read */
       fileAddr += sd->msglen;
@@ -617,19 +617,19 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch
       if (!sparseBlock && ff_pkt->flags & FO_GZIP) {
         int zstat;
         compress_len = max_compress_len;
-         Dmsg4(400, "cbuf=0x%x len=%u rbuf=0x%x len=%u\n", cbuf, compress_len,
+        Dmsg4(400, "cbuf=0x%x len=%u rbuf=0x%x len=%u\n", cbuf, compress_len,
            rbuf, sd->msglen);
         /* NOTE! This call modifies compress_len !!! */
-        if ((zstat=compress2((Bytef *)cbuf, &compress_len, 
+        if ((zstat=compress2((Bytef *)cbuf, &compress_len,
               (const Bytef *)rbuf, (uLong)sd->msglen,
               ff_pkt->GZIP_level)) != Z_OK) {
-            Jmsg(jcr, M_FATAL, 0, _("Compression error: %d\n"), zstat);
+           Jmsg(jcr, M_FATAL, 0, _("Compression error: %d\n"), zstat);
            sd->msg = msgsave;
            sd->msglen = 0;
            set_jcr_job_status(jcr, JS_ErrorTerminated);
            return 0;
         }
-         Dmsg2(400, "compressed len=%d uncompressed len=%d\n", 
+        Dmsg2(400, "compressed len=%d uncompressed len=%d\n",
            compress_len, sd->msglen);
 
         sd->msglen = compress_len;      /* set compressed length */
@@ -644,7 +644,7 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch
         sd->msg = wbuf;              /* set correct write buffer */
         if (!bnet_send(sd)) {
            berrno be;
-            Jmsg2(jcr, M_FATAL, 0, _("Network send error %d to SD. ERR=%s\n"),
+           Jmsg2(jcr, M_FATAL, 0, _("Network send error %d to SD. ERR=%s\n"),
                  sd->msglen, bnet_strerror(sd));
            sd->msg = msgsave;     /* restore bnet buffer */
            sd->msglen = 0;
index 4453d7d6af1964b0feaaff75d670d0a0d7618e49..300b492852df99aacc59f6396dde035381a0c271 100644 (file)
@@ -45,7 +45,7 @@ int chksum_init(CHKSUM *chksum, int flags)
       status = SHA1Init(&chksum->context.sha1);
       if (status == 0) {
         chksum->type = CHKSUM_SHA1;
-         bstrncpy(chksum->name, "SHA1", sizeof(chksum->name));
+        bstrncpy(chksum->name, "SHA1", sizeof(chksum->name));
       }
    }
    return status;
index eaa181a6b2a1809ae9f74542a562ec373fe7dc68..56ff5e736ccdcba724cf57d066bde2f23569ad21 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Bacula File Daemon estimate.c                  
+ *  Bacula File Daemon estimate.c
  *   Make and estimate of the number of files and size to be saved.
  *
  *    Kern Sibbald, September MMI
@@ -32,7 +32,7 @@
 
 static int tally_file(FF_PKT *ff_pkt, void *pkt);
 
-/* 
+/*
  * Find all the requested files and count them.
  */
 int make_estimate(JCR *jcr)
@@ -45,9 +45,9 @@ int make_estimate(JCR *jcr)
    stat = find_files(jcr, (FF_PKT *)jcr->ff, tally_file, (void *)jcr);
 
    return stat;
-}         
+}
 
-/* 
+/*
  * Called here by find() for each file included.
  *
  */
@@ -86,14 +86,14 @@ static int tally_file(FF_PKT *ff_pkt, void *ijcr)
 
    if (ff_pkt->type != FT_LNKSAVED && S_ISREG(ff_pkt->statp.st_mode)) {
       if (ff_pkt->statp.st_size > 0) {
-         jcr->JobBytes += ff_pkt->statp.st_size;
+        jcr->JobBytes += ff_pkt->statp.st_size;
       }
 #ifdef HAVE_DARWIN_OS
       if (ff_pkt->flags & FO_HFSPLUS) {
-         if (ff_pkt->hfsinfo.rsrclength > 0) {
-            jcr->JobBytes += ff_pkt->hfsinfo.rsrclength;
-         }
-         jcr->JobBytes += 32;    /* Finder info */
+        if (ff_pkt->hfsinfo.rsrclength > 0) {
+           jcr->JobBytes += ff_pkt->hfsinfo.rsrclength;
+        }
+        jcr->JobBytes += 32;    /* Finder info */
       }
 #endif
    }
index 7e0b61effc1087cbe83549948c0bd5d951009314..71c2b14bbdcdbdda2b95cfaaeab4eed7cd6e2692 100644 (file)
@@ -65,7 +65,7 @@ static void usage()
    fprintf(stderr, _(
 "Copyright (C) 2000-2004 Kern Sibbald and John Walker\n"
 "\nVersion: " VERSION " (" BDATE ")\n\n"
-"Usage: bacula-fd [-f -s] [-c config_file] [-d debug_level]\n"  
+"Usage: bacula-fd [-f -s] [-c config_file] [-d debug_level]\n"
 "        -c <file>   use <file> as configuration file\n"
 "        -dnn        set debug level to nn\n"
 "        -f          run in foreground (for debugging)\n"
@@ -76,14 +76,14 @@ static void usage()
 "        -u          userid\n"
 "        -v          verbose user messages\n"
 "        -?          print this message.\n"
-"\n"));         
+"\n"));
    exit(1);
 }
 
 
-/********************************************************************* 
+/*********************************************************************
  *
- *  Main Bacula Unix Client Program                       
+ *  Main Bacula Unix Client Program
  *
  */
 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
@@ -116,7 +116,7 @@ int main (int argc, char *argv[])
       case 'd':                    /* debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0) {
-           debug_level = 1; 
+           debug_level = 1;
         }
         break;
 
@@ -151,7 +151,7 @@ int main (int argc, char *argv[])
       default:
         usage();
 
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -160,7 +160,7 @@ int main (int argc, char *argv[])
       if (configfile != NULL)
         free(configfile);
       configfile = bstrdup(*argv);
-      argc--; 
+      argc--;
       argv++;
    }
    if (argc) {
@@ -193,8 +193,8 @@ int main (int argc, char *argv[])
    me = (CLIENT *)GetNextRes(R_CLIENT, NULL);
    UnlockRes();
    if (!me) {
-      Emsg1(M_ABORT, 0, _("No File daemon resource defined in %s\n\
-Without that I don't know who I am :-(\n"), configfile);
+      Emsg1(M_ABORT, 0, _("No File daemon resource defined in %s\n"
+"Without that I don't know who I am :-(\n"), configfile);
    } else {
       my_name_is(0, NULL, me->hdr.name);
       if (!me->messages) {
@@ -202,7 +202,7 @@ Without that I don't know who I am :-(\n"), configfile);
         me->messages = (MSGS *)GetNextRes(R_MSGS, NULL);
         UnlockRes();
         if (!me->messages) {
-             Emsg1(M_ABORT, 0, _("No Messages resource defined in %s\n"), configfile);
+            Emsg1(M_ABORT, 0, _("No Messages resource defined in %s\n"), configfile);
         }
       }
       close_msg(NULL);               /* close temp message handler */
@@ -239,7 +239,7 @@ Without that I don't know who I am :-(\n"), configfile);
    server_tid = pthread_self();
 
    if (inetd_request) {
-      /* Socket is on fd 0 */         
+      /* Socket is on fd 0 */
       struct sockaddr client_addr;
       int port = -1;
       socklen_t client_addr_len = sizeof(client_addr);
@@ -253,7 +253,7 @@ Without that I don't know who I am :-(\n"), configfile);
       /* Become server, and handle requests */
       IPADDR *p;
       foreach_dlist(p, me->FDaddrs) {
-         Dmsg1(10, "filed: listening on port %d\n", p->get_port_host_order());
+        Dmsg1(10, "filed: listening on port %d\n", p->get_port_host_order());
       }
       bnet_thread_server(me->FDaddrs, me->MaxConcurrentJobs, &dir_workq, handle_client_request);
    }
@@ -271,7 +271,7 @@ void terminate_filed(int sig)
       free(configfile);
    }
    if (debug_level > 5) {
-      print_memory_pool_stats(); 
+      print_memory_pool_stats();
    }
    free_config_resources();
    term_msg();
index 48817cd13636bea0658a8073613584444e097c87..a49139a996afe752d1db4710fd36fc741d56408b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Bacula File Daemon specific configuration and defines
  *
- *     Kern Sibbald, Jan MMI 
+ *     Kern Sibbald, Jan MMI
  *
  *   Version $Id$
  */
index aaa3b33707c5888f441377568048e1480c5fee06..47bd9a6ba85286da5b62f0befd339fbfb2b81cad 100644 (file)
@@ -7,7 +7,7 @@
  *
  *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
  *
- *   2. The generic config  scanner in lib/parse_config.c and 
+ *   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,
@@ -74,9 +74,9 @@ int  res_all_size = sizeof(res_all);
 #endif
 
 /* Definition of records permitted within each
- * resource with the routine to process the record 
+ * resource with the routine to process the record
  * information.
- */ 
+ */
 
 /* Client or File daemon "Global" resources */
 static RES_ITEM cli_items[] = {
@@ -86,16 +86,16 @@ static RES_ITEM cli_items[] = {
    {"fdaddress",   store_addresses_address, ITEM(res_client.FDaddrs),  0, ITEM_DEFAULT, 9102},
    {"fdaddresses", store_addresses,         ITEM(res_client.FDaddrs),  0, ITEM_DEFAULT, 9102},
 
-   {"workingdirectory",  store_dir, ITEM(res_client.working_directory), 0, ITEM_REQUIRED, 0}, 
-   {"piddirectory",  store_dir,     ITEM(res_client.pid_directory),     0, ITEM_REQUIRED, 0}, 
-   {"subsysdirectory",  store_dir,  ITEM(res_client.subsys_directory),  0, 0, 0}, 
+   {"workingdirectory",  store_dir, ITEM(res_client.working_directory), 0, ITEM_REQUIRED, 0},
+   {"piddirectory",  store_dir,     ITEM(res_client.pid_directory),     0, ITEM_REQUIRED, 0},
+   {"subsysdirectory",  store_dir,  ITEM(res_client.subsys_directory),  0, 0, 0},
    {"requiressl",  store_yesno,     ITEM(res_client.require_ssl),       1, ITEM_DEFAULT, 0},
    {"maximumconcurrentjobs", store_pint,  ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 10},
    {"messages",      store_res, ITEM(res_client.messages), R_MSGS, 0, 0},
    {"heartbeatinterval", store_time, ITEM(res_client.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {"sdconnecttimeout", store_time,ITEM(res_client.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
    {"maximumnetworkbuffersize", store_pint, ITEM(res_client.max_network_buffer_size), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
 /* Directors that can use our services */
@@ -106,14 +106,14 @@ static RES_ITEM dir_items[] = {
    {"address",     store_str,      ITEM(res_dir.address),   0, 0, 0},
    {"enablessl",   store_yesno,    ITEM(res_dir.enable_ssl),1, ITEM_DEFAULT, 0},
    {"monitor",     store_yesno,    ITEM(res_dir.monitor),   1, ITEM_DEFAULT, 0},
-   {NULL, NULL, NULL, 0, 0, 0} 
+   {NULL, NULL, NULL, 0, 0, 0}
 };
 
 /* Message resource */
 extern RES_ITEM msgs_items[];
 
-/* 
- * This is the master resource definition.  
+/*
+ * This is the master resource definition.
  * It must have one item for each of the resources.
  */
 RES_TABLE resources[] = {
@@ -141,31 +141,31 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
    }
    switch (type) {
       case R_DIRECTOR:
-         sendit(sock, "Director: name=%s password=%s\n", reshdr->name, 
+        sendit(sock, "Director: name=%s password=%s\n", reshdr->name,
                 res->res_dir.password);
         break;
       case R_CLIENT:
-         sendit(sock, "Client: name=%s FDport=%d\n", reshdr->name,
+        sendit(sock, "Client: name=%s FDport=%d\n", reshdr->name,
                 get_first_port_host_order(res->res_client.FDaddrs));
         break;
       case R_MSGS:
-         sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
-        if (res->res_msgs.mail_cmd) 
-            sendit(sock, "      mailcmd=%s\n", res->res_msgs.mail_cmd);
-        if (res->res_msgs.operator_cmd) 
-            sendit(sock, "      opcmd=%s\n", res->res_msgs.operator_cmd);
+        sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
+        if (res->res_msgs.mail_cmd)
+           sendit(sock, "      mailcmd=%s\n", res->res_msgs.mail_cmd);
+        if (res->res_msgs.operator_cmd)
+           sendit(sock, "      opcmd=%s\n", res->res_msgs.operator_cmd);
         break;
       default:
-         sendit(sock, "Unknown resource type %d\n", type);
+        sendit(sock, "Unknown resource type %d\n", type);
    }
    if (recurse && res->res_dir.hdr.next)
       dump_resource(type, res->res_dir.hdr.next, sendit, sock);
 }
 
-/* 
- * Free memory of resource.  
+/*
+ * 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 
+ * to other resources as they will be freed when that
  * resource chain is traversed.  Mainly we worry about freeing
  * allocated strings (names).
  */
@@ -240,13 +240,13 @@ void save_resource(int type, RES_ITEM *items, int pass)
    int i, size;
    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.res_dir.hdr.item_present)) {  
-               Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found.\n"),
+           if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
+              Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found.\n"),
                 items[i].name, resources[rindex]);
             }
       }
@@ -267,12 +267,12 @@ void save_resource(int type, RES_ITEM *items, int pass)
         /* Resources containing another resource */
         case R_CLIENT:
            if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_dir.hdr.name)) == NULL) {
-               Emsg1(M_ABORT, 0, "Cannot find Client resource %s\n", res_all.res_dir.hdr.name);
+              Emsg1(M_ABORT, 0, "Cannot find Client resource %s\n", res_all.res_dir.hdr.name);
            }
            res->res_client.messages = res_all.res_client.messages;
            break;
         default:
-            Emsg1(M_ERROR, 0, _("Unknown resource type %d\n"), type);
+           Emsg1(M_ERROR, 0, _("Unknown resource type %d\n"), type);
            error = 1;
            break;
       }
@@ -302,7 +302,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
         size = sizeof(MSGS);
         break;
       default:
-         printf(_("Unknown resource type %d\n"), type);
+        printf(_("Unknown resource type %d\n"), type);
         error = 1;
         size = 1;
         break;
@@ -319,12 +319,12 @@ void save_resource(int type, RES_ITEM *items, int pass)
         for (next=res_head[rindex]; next->next; next=next->next) {
            if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
               Emsg2(M_ERROR_TERM, 0,
-                  _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
+                 _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
                  resources[rindex].name, res->res_dir.hdr.name);
            }
         }
         next->next = (RES *)res;
-         Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type),
+        Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type),
               res->res_dir.hdr.name);
       }
    }
index f1d9fa5210e30b50b7fad5742d05f7d3b5982c5a..4abd87f1acacbdb0baa8a3cfc28fe2c94abfb2c1 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 /*
- * Resource codes -- they must be sequential for indexing   
+ * Resource codes -- they must be sequential for indexing
  */
 #define R_FIRST                       1001
 
index edbad95136fbb0caaa7376d2a2f56319da20b647..c13a6feff126abe4708ae922f74148b382f029d1 100644 (file)
@@ -36,7 +36,7 @@
 #define pthread_kill(x, y)
 /* Use shorter wait interval on Cygwin because no kill */
 #define WAIT_INTERVAL 10
+
 #else  /* Unix systems */
 #define WAIT_INTERVAL 60
 #endif
@@ -45,7 +45,7 @@ extern "C" void *sd_heartbeat_thread(void *arg);
 extern "C" void *dir_heartbeat_thread(void *arg);
 extern bool no_signals;
 
-/* 
+/*
  * Listen on the SD socket for heartbeat signals.
  * Send heartbeats to the Director every HB_TIME
  *   seconds.
@@ -83,9 +83,9 @@ extern "C" void *sd_heartbeat_thread(void *arg)
       if (n == 1) {                  /* input waiting */
         bnet_recv(sd);               /* read it -- probably heartbeat from sd */
         if (sd->msglen <= 0) {
-            Dmsg1(100, "Got BNET_SIG %d from SD\n", sd->msglen);     
+           Dmsg1(100, "Got BNET_SIG %d from SD\n", sd->msglen);
         } else {
-            Dmsg2(100, "Got %d bytes from SD. MSG=%s\n", sd->msglen, sd->msg);
+           Dmsg2(100, "Got %d bytes from SD. MSG=%s\n", sd->msglen, sd->msg);
         }
       }
    }
@@ -98,7 +98,7 @@ extern "C" void *sd_heartbeat_thread(void *arg)
 /* Startup the heartbeat thread -- see above */
 void start_heartbeat_monitor(JCR *jcr)
 {
-   /* 
+   /*
     * If no signals are set, do not start the heartbeat because
     * it gives a constant stream of TIMEOUT_SIGNAL signals that
     * make debugging impossible.
@@ -110,7 +110,7 @@ void start_heartbeat_monitor(JCR *jcr)
 }
 
 /* Terminate the heartbeat thread. Used for both SD and DIR */
-void stop_heartbeat_monitor(JCR *jcr) 
+void stop_heartbeat_monitor(JCR *jcr)
 {
    int cnt = 0;
    if (no_signals) {
index 1cbb589aa00494bd4f8e9a9ef765579e3be4e422..e931e3179110f01f57abbb3edbb97b94703c4bc0 100644 (file)
@@ -31,7 +31,7 @@
 
 extern char my_name[];
 extern CLIENT *me;                   /* our client resource */
-                       
+
 /* Imported functions */
 extern int status_cmd(JCR *jcr);
 extern int qstatus_cmd(JCR *jcr);
@@ -70,8 +70,8 @@ struct s_cmds {
    int monitoraccess; /* specify if monitors have access to this function */
 };
 
-/*  
- * The following are the recognized commands from the Director. 
+/*
+ * The following are the recognized commands from the Director.
  */
 static struct s_cmds cmds[] = {
    {"backup",       backup_cmd,    0},
@@ -146,7 +146,7 @@ static char read_open[]    = "read open session = %s %ld %ld %ld %ld %ld %ld\n";
 static char read_data[]    = "read data %d\n";
 static char read_close[]   = "read close session %d\n";
 
-/* 
+/*
  * Accept requests from a Director
  *
  * NOTE! We are running as a separate thread
@@ -165,7 +165,7 @@ static char read_close[]   = "read close session %d\n";
  */
 void *handle_client_request(void *dirp)
 {
-   int i; 
+   int i;
    bool found, quit;
    JCR *jcr;
    BSOCK *dir = (BSOCK *)dirp;
@@ -201,15 +201,15 @@ void *handle_client_request(void *dirp)
               break;
            }
            if ((jcr->authenticated) && (!cmds[i].monitoraccess) && (jcr->director->monitor)) {
-               Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd);
+              Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd);
               bnet_fsend(dir, illegal_cmd);
               bnet_sig(dir, BNET_EOD);
               break;
            }
-            Dmsg1(100, "Executing %s command.\n", cmds[i].cmd);
+           Dmsg1(100, "Executing %s command.\n", cmds[i].cmd);
            if (!cmds[i].func(jcr)) {         /* do command */
               quit = true;         /* error or fully terminated,       get out */
-               Dmsg0(20, "Quit command loop due to command error or Job done.\n");
+              Dmsg0(20, "Quit command loop due to command error or Job done.\n");
            }
            break;
         }
@@ -288,7 +288,7 @@ void *handle_client_request(void *dirp)
 }
 
 /*
- * Hello from Director he must identify himself and provide his 
+ * Hello from Director he must identify himself and provide his
  *  password.
  */
 static int hello_cmd(JCR *jcr)
@@ -313,13 +313,13 @@ static int cancel_cmd(JCR *jcr)
 
    if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) {
       if (!(cjcr=get_jcr_by_full_name(Job))) {
-         bnet_fsend(dir, "2901 Job %s not found.\n", Job);
+        bnet_fsend(dir, "2901 Job %s not found.\n", Job);
       } else {
         if (cjcr->store_bsock) {
            P(cjcr->mutex);
            cjcr->store_bsock->timed_out = 1;
            cjcr->store_bsock->terminated = 1;
-/* 
+/*
  * #if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
  */
 #if !defined(HAVE_CYGWIN)
@@ -329,7 +329,7 @@ static int cancel_cmd(JCR *jcr)
         }
         set_jcr_job_status(cjcr, JS_Canceled);
         free_jcr(cjcr);
-         bnet_fsend(dir, _("2001 Job %s marked to be canceled.\n"), Job);
+        bnet_fsend(dir, _("2001 Job %s marked to be canceled.\n"), Job);
       }
    } else {
       bnet_fsend(dir, _("2902 Error scanning cancel command.\n"));
@@ -352,7 +352,7 @@ static int setdebug_cmd(JCR *jcr)
    if (sscanf(dir->msg, "setdebug=%d trace=%d", &level, &trace_flag) != 2 || level < 0) {
       pm_strcpy(jcr->errmsg, dir->msg);
       bnet_fsend(dir, "2991 Bad setdebug command: %s\n", jcr->errmsg);
-      return 0;   
+      return 0;
    }
    debug_level = level;
    set_trace(trace_flag);
@@ -372,7 +372,7 @@ static int estimate_cmd(JCR *jcr)
       return 0;
    }
    make_estimate(jcr);
-   bnet_fsend(dir, OKest, jcr->num_files_examined, 
+   bnet_fsend(dir, OKest, jcr->num_files_examined,
       edit_uint64_with_commas(jcr->JobBytes, ed2));
    bnet_sig(dir, BNET_EOD);
    return 1;
@@ -387,7 +387,7 @@ static int job_cmd(JCR *jcr)
    POOLMEM *sd_auth_key;
 
    sd_auth_key = get_memory(dir->msglen);
-   if (sscanf(dir->msg, jobcmd,  &jcr->JobId, jcr->Job,  
+   if (sscanf(dir->msg, jobcmd,  &jcr->JobId, jcr->Job,
              &jcr->VolSessionId, &jcr->VolSessionTime,
              sd_auth_key) != 5) {
       pm_strcpy(jcr->errmsg, dir->msg);
@@ -459,7 +459,7 @@ static int run_cmd(JCR *jcr, char *cmd, const char *name)
    int status;
    BPIPE *bpipe;
    char line[MAXSTRING];
-   
+
    ecmd = edit_job_codes(jcr, ecmd, cmd, "");
    bpipe = open_bpipe(ecmd, 0, "r");
    free_pool_memory(ecmd);
@@ -513,7 +513,7 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list)
       bpipe = open_bpipe(fn, 0, "r");
       free_pool_memory(fn);
       if (!bpipe) {
-         Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
+        Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
            p, strerror(errno));
         return;
       }
@@ -521,7 +521,7 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list)
       if (list == INC_LIST) {
         *q = 0;                      /* terminate options */
         strcpy(buf, fname);
-         strcat(buf, " ");
+        strcat(buf, " ");
         optlen = strlen(buf);
       } else {
         optlen = 0;
@@ -535,7 +535,7 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list)
         }
       }
       if ((stat=close_bpipe(bpipe)) != 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
+        Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
            p, stat, strerror(errno));
         return;
       }
@@ -544,15 +544,15 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list)
       p++;                     /* skip over < */
       if ((ffd = fopen(p, "r")) == NULL) {
         berrno be;
-         Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"),
-            list==INC_LIST?"included":"excluded", p, be.strerror());
+        Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"),
+           list==INC_LIST?"included":"excluded", p, be.strerror());
         return;
       }
       /* Copy File options */
       if (list == INC_LIST) {
         *q = 0;                      /* terminate options */
         strcpy(buf, fname);
-         strcat(buf, " ");
+        strcat(buf, " ");
         optlen = strlen(buf);
       } else {
         optlen = 0;
@@ -577,8 +577,8 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list)
    }
 }
 
-/* 
- * 
+/*
+ *
  * Get list of files/directories to include from Director
  *
  */
@@ -596,12 +596,12 @@ static int include_cmd(JCR *jcr)
    return bnet_fsend(dir, OKinc);
 }
 
-static bool init_fileset(JCR *jcr) 
+static bool init_fileset(JCR *jcr)
 {
    FF_PKT *ff;
    findFILESET *fileset;
 
-   if (!jcr->ff) {     
+   if (!jcr->ff) {
       return false;
    }
    ff = (FF_PKT *)jcr->ff;
@@ -659,7 +659,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese
       bpipe = open_bpipe(fn, 0, "r");
       free_pool_memory(fn);
       if (!bpipe) {
-         Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
+        Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
            p, strerror(errno));
         return;
       }
@@ -668,7 +668,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese
         fileset->incexe->name_list.append(bstrdup(buf));
       }
       if ((stat=close_bpipe(bpipe)) != 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
+        Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
            p, stat, strerror(errno));
         return;
       }
@@ -677,7 +677,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese
       p++;                     /* skip over < */
       if ((ffd = fopen(p, "r")) == NULL) {
         berrno be;
-         Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"),
+        Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"),
            p, be.strerror());
         return;
       }
@@ -693,7 +693,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese
    }
 }
 
-   
+
 static void add_fileset(JCR *jcr, const char *item)
 {
    FF_PKT *ff = (FF_PKT *)jcr->ff;
@@ -742,15 +742,15 @@ static void add_fileset(JCR *jcr, const char *item)
       char prbuf[500];
       preg = (regex_t *)malloc(sizeof(regex_t));
       if (current_opts->flags & FO_IGNORECASE) {
-         rc = regcomp(preg, item, REG_EXTENDED|REG_ICASE);
+        rc = regcomp(preg, item, REG_EXTENDED|REG_ICASE);
       } else {
-         rc = regcomp(preg, item, REG_EXTENDED);
+        rc = regcomp(preg, item, REG_EXTENDED);
       }
       if (rc != 0) {
         regerror(rc, preg, prbuf, sizeof(prbuf));
         regfree(preg);
         free(preg);
-         Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf);
+        Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf);
         state = state_error;
         break;
       }
@@ -772,7 +772,7 @@ static void add_fileset(JCR *jcr, const char *item)
       current_opts->wild.append(bstrdup(item));
       state = state_options;
       break;
-   case 'O':   
+   case 'O':
       current_opts = start_options(ff);
       set_options(current_opts, item);
       state = state_options;
@@ -807,26 +807,26 @@ static bool term_fileset(JCR *jcr)
       for (j=0; j<incexe->opts_list.size(); j++) {
         findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
         for (k=0; k<fo->regex.size(); k++) {
-            Dmsg1(400, "R %s\n", (char *)fo->regex.get(k));
+           Dmsg1(400, "R %s\n", (char *)fo->regex.get(k));
         }
         for (k=0; k<fo->wild.size(); k++) {
-            Dmsg1(400, "W %s\n", (char *)fo->wild.get(k));
+           Dmsg1(400, "W %s\n", (char *)fo->wild.get(k));
         }
         for (k=0; k<fo->base.size(); k++) {
-            Dmsg1(400, "B %s\n", (char *)fo->base.get(k));
+           Dmsg1(400, "B %s\n", (char *)fo->base.get(k));
         }
         for (k=0; k<fo->fstype.size(); k++) {
-            Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k));
+           Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k));
         }
         if (fo->reader) {
-            Dmsg1(400, "D %s\n", fo->reader);
+           Dmsg1(400, "D %s\n", fo->reader);
         }
         if (fo->writer) {
-            Dmsg1(400, "T %s\n", fo->writer);
+           Dmsg1(400, "T %s\n", fo->writer);
         }
       }
       for (j=0; j<incexe->name_list.size(); j++) {
-         Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j));
+        Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j));
       }
    }
    for (i=0; i<fileset->exclude_list.size(); i++) {
@@ -835,20 +835,20 @@ static bool term_fileset(JCR *jcr)
       for (j=0; j<incexe->opts_list.size(); j++) {
         findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
         for (k=0; k<fo->regex.size(); k++) {
-            Dmsg1(400, "R %s\n", (char *)fo->regex.get(k));
+           Dmsg1(400, "R %s\n", (char *)fo->regex.get(k));
         }
         for (k=0; k<fo->wild.size(); k++) {
-            Dmsg1(400, "W %s\n", (char *)fo->wild.get(k));
+           Dmsg1(400, "W %s\n", (char *)fo->wild.get(k));
         }
         for (k=0; k<fo->base.size(); k++) {
-            Dmsg1(400, "B %s\n", (char *)fo->base.get(k));
+           Dmsg1(400, "B %s\n", (char *)fo->base.get(k));
         }
         for (k=0; k<fo->fstype.size(); k++) {
-            Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k));
+           Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k));
         }
       }
       for (j=0; j<incexe->name_list.size(); j++) {
-         Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j));
+        Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j));
       }
    }
    return ff->fileset->state != state_error;
@@ -916,7 +916,7 @@ static void set_options(findFOPTS *fo, const char *opts)
         break;
       case 'V':                  /* verify options */
         /* Copy Verify Options */
-         for (j=0; *p && *p != ':'; p++) {
+        for (j=0; *p && *p != ':'; p++) {
            fo->VerifyOpts[j] = *p;
            if (j < (int)sizeof(fo->VerifyOpts) - 1) {
               j++;
@@ -929,19 +929,19 @@ static void set_options(findFOPTS *fo, const char *opts)
         break;
       case 'Z':                 /* gzip compression */
         fo->flags |= FO_GZIP;
-         fo->GZIP_level = *++p - '0';
-         Dmsg1(200, "Compression level=%d\n", fo->GZIP_level);
+        fo->GZIP_level = *++p - '0';
+        Dmsg1(200, "Compression level=%d\n", fo->GZIP_level);
         break;
       default:
-         Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *p);
+        Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *p);
         break;
       }
    }
-} 
+}
 
 
 /*
- * Director is passing his Fileset   
+ * Director is passing his Fileset
  */
 static int fileset_cmd(JCR *jcr)
 {
@@ -998,7 +998,7 @@ static int bootstrap_cmd(JCR *jcr)
    bs = fopen(fname, "a+");           /* create file */
    if (!bs) {
       berrno be;
-      /* 
+      /*
        * Suck up what he is sending to us so that he will then
        *   read our error message.
        */
@@ -1043,24 +1043,24 @@ static int level_cmd(JCR *jcr)
    /* Base backup requested? */
    if (strcmp(level, "base") == 0) {
       jcr->JobLevel = L_BASE;
-   /* Full backup requested? */ 
+   /* Full backup requested? */
    } else if (strcmp(level, "full") == 0) {
       jcr->JobLevel = L_FULL;
-   /* 
+   /*
     * Backup requested since <date> <time>
     *  This form is also used for incremental and differential
     *  This code is deprecated.  See since_utime for new code.
     */
    } else if (strcmp(level, "since") == 0) {
       jcr->JobLevel = L_SINCE;
-      if (sscanf(dir->msg, "level = since %d-%d-%d %d:%d:%d mtime_only=%d", 
+      if (sscanf(dir->msg, "level = since %d-%d-%d %d:%d:%d mtime_only=%d",
                 &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
                 &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &mtime_only) != 7) {
         goto bail_out;
       }
       tm.tm_year -= 1900;
       tm.tm_mon  -= 1;
-      tm.tm_wday = tm.tm_yday = 0;             
+      tm.tm_wday = tm.tm_yday = 0;
       tm.tm_isdst = -1;
       mtime = mktime(&tm);
       Dmsg2(100, "Got since time: %s mtime_only=%d\n", ctime(&mtime), mtime_only);
@@ -1075,14 +1075,14 @@ static int level_cmd(JCR *jcr)
       utime_t since_time, adj;
       btime_t his_time, bt_start, rt=0, bt_adj=0;
       jcr->JobLevel = L_SINCE;
-      if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d", 
-                buf, &mtime_only) != 2) { 
+      if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d",
+                buf, &mtime_only) != 2) {
         goto bail_out;
       }
       since_time = str_to_uint64(buf); /* this is the since time */
       char ed1[50], ed2[50];
-      /* 
-       * Sync clocks by polling him for the time. We take       
+      /*
+       * Sync clocks by polling him for the time. We take
        *   10 samples of his time throwing out the first two.
        */
       for (int i=0; i<10; i++) {
@@ -1091,7 +1091,7 @@ static int level_cmd(JCR *jcr)
         if (bnet_recv(dir) <= 0) {   /* get response */
            goto bail_out;
         }
-         if (sscanf(dir->msg, "btime %s", buf) != 1) {
+        if (sscanf(dir->msg, "btime %s", buf) != 1) {
            goto bail_out;
         }
         if (i < 2) {                 /* toss first two results */
@@ -1100,7 +1100,7 @@ static int level_cmd(JCR *jcr)
         his_time = str_to_uint64(buf);
         rt = get_current_btime() - bt_start; /* compute round trip time */
         bt_adj -= his_time - bt_start - rt/2;
-         Dmsg2(200, "rt=%s adj=%s\n", edit_uint64(rt, ed1), edit_uint64(bt_adj, ed2));
+        Dmsg2(200, "rt=%s adj=%s\n", edit_uint64(rt, ed1), edit_uint64(bt_adj, ed2));
       }
 
       bt_adj = bt_adj / 8;           /* compute average time */
@@ -1108,7 +1108,7 @@ static int level_cmd(JCR *jcr)
       adj = btime_to_utime(bt_adj);
       since_time += adj;             /* adjust for clock difference */
       if (adj != 0) {
-         Jmsg(jcr, M_INFO, 0, _("Since time adjusted by %d seconds.\n"), adj);
+        Jmsg(jcr, M_INFO, 0, _("Since time adjusted by %d seconds.\n"), adj);
       }
       bnet_sig(dir, BNET_EOD);
 
@@ -1146,7 +1146,7 @@ static int session_cmd(JCR *jcr)
    Dmsg1(100, "SessionCmd: %s", dir->msg);
    if (sscanf(dir->msg, sessioncmd, jcr->VolumeName,
              &jcr->VolSessionId, &jcr->VolSessionTime,
-             &jcr->StartFile, &jcr->EndFile, 
+             &jcr->StartFile, &jcr->EndFile,
              &jcr->StartBlock, &jcr->EndBlock) != 7) {
       pm_strcpy(jcr->errmsg, dir->msg);
       Jmsg(jcr, M_FATAL, 0, "Bad session command: %s", jcr->errmsg);
@@ -1176,7 +1176,7 @@ static int storage_cmd(JCR *jcr)
    Dmsg3(110, "Open storage: %s:%d ssl=%d\n", jcr->stored_addr, stored_port, enable_ssl);
    /* Open command communications with Storage daemon */
    /* Try to connect for 1 hour at 10 second intervals */
-   sd = bnet_connect(jcr, 10, (int)me->SDConnectTimeout, _("Storage daemon"), 
+   sd = bnet_connect(jcr, 10, (int)me->SDConnectTimeout, _("Storage daemon"),
                     jcr->stored_addr, NULL, stored_port, 1);
    if (sd == NULL) {
       Jmsg(jcr, M_FATAL, 0, _("Failed to connect to Storage daemon: %s:%d\n"),
@@ -1201,11 +1201,11 @@ static int storage_cmd(JCR *jcr)
 }
 
 
-/*  
+/*
  * Do a backup. For now, we handle only Full and Incremental.
  */
 static int backup_cmd(JCR *jcr)
-{ 
+{
    BSOCK *dir = jcr->dir_bsock;
    BSOCK *sd = jcr->store_bsock;
    int ok = 0;
@@ -1224,18 +1224,18 @@ static int backup_cmd(JCR *jcr)
    bnet_fsend(dir, OKbackup);
    Dmsg1(110, "bfiled>dird: %s", dir->msg);
 
-   /* 
+   /*
     * Send Append Open Session to Storage daemon
     */
    bnet_fsend(sd, append_open);
    Dmsg1(110, ">stored: %s", sd->msg);
-   /* 
+   /*
     * Expect to receive back the Ticket number
     */
    if (bget_msg(sd) >= 0) {
       Dmsg1(110, "<stored: %s", sd->msg);
       if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) {
-         Jmsg(jcr, M_FATAL, 0, _("Bad response to append open: %s\n"), sd->msg);
+        Jmsg(jcr, M_FATAL, 0, _("Bad response to append open: %s\n"), sd->msg);
         goto cleanup;
       }
       Dmsg1(110, "Got Ticket=%d\n", jcr->Ticket);
@@ -1244,20 +1244,20 @@ static int backup_cmd(JCR *jcr)
       goto cleanup;
    }
 
-   /* 
+   /*
     * Send Append data command to Storage daemon
     */
    bnet_fsend(sd, append_data, jcr->Ticket);
    Dmsg1(110, ">stored: %s", sd->msg);
 
-   /* 
-    * Expect to get OK data 
+   /*
+    * Expect to get OK data
     */
    Dmsg1(110, "<stored: %s", sd->msg);
    if (!response(jcr, sd, OK_data, "Append Data")) {
       goto cleanup;
    }
-      
+
    /*
     * Send Files to Storage daemon
     */
@@ -1272,15 +1272,15 @@ static int backup_cmd(JCR *jcr)
         bnet_suppress_error_messages(sd, 1);
         goto cleanup;                /* bail out now */
       }
-      /* 
+      /*
        * Expect to get response to append_data from Storage daemon
        */
       if (!response(jcr, sd, OK_append, "Append Data")) {
         set_jcr_job_status(jcr, JS_ErrorTerminated);
         goto cleanup;
       }
-     
-      /* 
+
+      /*
        * Send Append End Data to Storage daemon
        */
       bnet_fsend(sd, append_end, jcr->Ticket);
@@ -1297,34 +1297,34 @@ static int backup_cmd(JCR *jcr)
       while (bget_msg(sd) >= 0) {    /* stop on signal or error */
         if (sscanf(sd->msg, OK_close, &SDJobStatus) == 1) {
            ok = 1;
-            Dmsg2(200, "SDJobStatus = %d %c\n", SDJobStatus, (char)SDJobStatus);
+           Dmsg2(200, "SDJobStatus = %d %c\n", SDJobStatus, (char)SDJobStatus);
         }
       }
       if (!ok) {
-         Jmsg(jcr, M_FATAL, 0, _("Append Close with SD failed.\n"));
+        Jmsg(jcr, M_FATAL, 0, _("Append Close with SD failed.\n"));
         goto cleanup;
       }
       if (SDJobStatus != JS_Terminated) {
-         Jmsg(jcr, M_FATAL, 0, _("Bad status %d returned from Storage Daemon.\n"),
+        Jmsg(jcr, M_FATAL, 0, _("Bad status %d returned from Storage Daemon.\n"),
            SDJobStatus);
       }
    }
 
 cleanup:
-   bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles, 
-      edit_uint64(jcr->ReadBytes, ed1), 
-      edit_uint64(jcr->JobBytes, ed2), jcr->Errors);   
+   bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
+      edit_uint64(jcr->ReadBytes, ed1),
+      edit_uint64(jcr->JobBytes, ed2), jcr->Errors);
    Dmsg1(110, "End FD msg: %s\n", dir->msg);
 
    return 0;                         /* return and stop command loop */
 }
 
-/*  
+/*
  * Do a Verify for Director
  *
  */
 static int verify_cmd(JCR *jcr)
-{ 
+{
    BSOCK *dir = jcr->dir_bsock;
    BSOCK *sd  = jcr->store_bsock;
    char level[100], ed1[50], ed2[50];
@@ -1332,7 +1332,7 @@ static int verify_cmd(JCR *jcr)
    jcr->JobType = JT_VERIFY;
    if (sscanf(dir->msg, verifycmd, level) != 1) {
       bnet_fsend(dir, "2994 Bad verify command: %s\n", dir->msg);
-      return 0;   
+      return 0;
    }
    if (strcasecmp(level, "init") == 0) {
       jcr->JobLevel = L_VERIFY_INIT;
@@ -1344,9 +1344,9 @@ static int verify_cmd(JCR *jcr)
       jcr->JobLevel = L_VERIFY_DATA;
    } else if (strcasecmp(level, "disk_to_catalog") == 0) {
       jcr->JobLevel = L_VERIFY_DISK_TO_CATALOG;
-   } else {   
+   } else {
       bnet_fsend(dir, "2994 Bad verify level: %s\n", dir->msg);
-      return 0;   
+      return 0;
    }
 
    bnet_fsend(dir, OKverify);
@@ -1364,7 +1364,7 @@ static int verify_cmd(JCR *jcr)
       start_dir_heartbeat(jcr);
       do_verify_volume(jcr);
       stop_dir_heartbeat(jcr);
-      /* 
+      /*
        * Send Close session command to Storage daemon
        */
       bnet_fsend(sd, read_close, jcr->Ticket);
@@ -1382,27 +1382,27 @@ static int verify_cmd(JCR *jcr)
       break;
    default:
       bnet_fsend(dir, "2994 Bad verify level: %s\n", dir->msg);
-      return 0; 
+      return 0;
    }
 
    bnet_sig(dir, BNET_EOD);
 
    /* Send termination status back to Dir */
-   bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles, 
-      edit_uint64(jcr->ReadBytes, ed1), 
-      edit_uint64(jcr->JobBytes, ed2), jcr->Errors);   
+   bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
+      edit_uint64(jcr->ReadBytes, ed1),
+      edit_uint64(jcr->JobBytes, ed2), jcr->Errors);
 
    /* Inform Director that we are done */
    bnet_sig(dir, BNET_TERMINATE);
    return 0;                         /* return and terminate command loop */
 }
 
-/*  
+/*
  * Do a Restore for Director
  *
  */
 static int restore_cmd(JCR *jcr)
-{ 
+{
    BSOCK *dir = jcr->dir_bsock;
    BSOCK *sd = jcr->store_bsock;
    POOLMEM *where;
@@ -1421,7 +1421,7 @@ static int restore_cmd(JCR *jcr)
    if (sscanf(dir->msg, restorecmd, &replace, &prefix_links, where) != 3) {
       if (sscanf(dir->msg, restorecmd1, &replace, &prefix_links) != 2) {
         pm_strcpy(jcr->errmsg, dir->msg);
-         Jmsg(jcr, M_FATAL, 0, _("Bad replace command. CMD=%s\n"), jcr->errmsg);
+        Jmsg(jcr, M_FATAL, 0, _("Bad replace command. CMD=%s\n"), jcr->errmsg);
         return 0;
       }
       *where = 0;
@@ -1430,7 +1430,7 @@ static int restore_cmd(JCR *jcr)
    if (where[0] == '/' && where[1] == 0) {
       where[0] = 0;
    }
-      
+
    Dmsg2(150, "Got replace %c, where=%s\n", replace, where);
    unbash_spaces(where);
    jcr->where = bstrdup(where);
@@ -1451,19 +1451,19 @@ static int restore_cmd(JCR *jcr)
 
    set_jcr_job_status(jcr, JS_Running);
 
-   /* 
+   /*
     * Do restore of files and data
     */
    start_dir_heartbeat(jcr);
    do_restore(jcr);
    stop_dir_heartbeat(jcr);
-   
+
    set_jcr_job_status(jcr, JS_Terminated);
    if (jcr->JobStatus != JS_Terminated) {
       bnet_suppress_error_messages(sd, 1);
    }
 
-   /* 
+   /*
     * Send Close session command to Storage daemon
     */
    bnet_fsend(sd, read_close, jcr->Ticket);
@@ -1480,9 +1480,9 @@ bail_out:
       set_jcr_job_status(jcr, JS_ErrorTerminated);
    }
    /* Send termination status back to Dir */
-   bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles, 
-      edit_uint64(jcr->ReadBytes, ed1), 
-      edit_uint64(jcr->JobBytes, ed2), jcr->Errors);   
+   bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
+      edit_uint64(jcr->ReadBytes, ed1),
+      edit_uint64(jcr->JobBytes, ed2), jcr->Errors);
 
    /* Inform Director that we are done */
    bnet_sig(dir, BNET_TERMINATE);
@@ -1502,21 +1502,21 @@ static int open_sd_read_session(JCR *jcr)
    Dmsg4(120, "VolSessId=%ld VolsessT=%ld SF=%ld EF=%ld\n",
       jcr->VolSessionId, jcr->VolSessionTime, jcr->StartFile, jcr->EndFile);
    Dmsg2(120, "JobId=%d vol=%s\n", jcr->JobId, "DummyVolume");
-   /* 
+   /*
     * Open Read Session with Storage daemon
     */
    bnet_fsend(sd, read_open, jcr->VolumeName,
-      jcr->VolSessionId, jcr->VolSessionTime, jcr->StartFile, jcr->EndFile, 
+      jcr->VolSessionId, jcr->VolSessionTime, jcr->StartFile, jcr->EndFile,
       jcr->StartBlock, jcr->EndBlock);
    Dmsg1(110, ">stored: %s", sd->msg);
 
-   /* 
+   /*
     * Get ticket number
     */
    if (bget_msg(sd) >= 0) {
       Dmsg1(110, "bfiled<stored: %s", sd->msg);
       if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) {
-         Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg);
+        Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg);
         return 0;
       }
       Dmsg1(110, "bfiled: got Ticket=%d\n", jcr->Ticket);
@@ -1529,13 +1529,13 @@ static int open_sd_read_session(JCR *jcr)
       return 0;
    }
 
-   /* 
+   /*
     * Start read of data with Storage daemon
     */
    bnet_fsend(sd, read_data, jcr->Ticket);
    Dmsg1(110, ">stored: %s", sd->msg);
 
-   /* 
+   /*
     * Get OK data
     */
    if (!response(jcr, sd, OK_data, "Read Data")) {
@@ -1544,11 +1544,11 @@ static int open_sd_read_session(JCR *jcr)
    return 1;
 }
 
-/* 
+/*
  * Destroy the Job Control Record and associated
  * resources (sockets).
  */
-static void filed_free_jcr(JCR *jcr) 
+static void filed_free_jcr(JCR *jcr)
 {
    if (jcr->store_bsock) {
       bnet_close(jcr->store_bsock);
@@ -1565,7 +1565,7 @@ static void filed_free_jcr(JCR *jcr)
       free_pool_memory(jcr->RunAfterJob);
    }
 
-      
+
    return;
 }
 
@@ -1586,7 +1586,7 @@ int response(JCR *jcr, BSOCK *sd, char *resp, const char *cmd)
       if (strcmp(sd->msg, resp) == 0) {
         return 1;
       }
-   } 
+   }
    if (job_canceled(jcr)) {
       return 0;                      /* if canceled avoid useless error messages */
    }
@@ -1615,16 +1615,16 @@ static int send_bootstrap_file(JCR *jcr)
    bs = fopen(jcr->RestoreBootstrap, "r");
    if (!bs) {
       berrno be;
-      Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), 
+      Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
         jcr->RestoreBootstrap, be.strerror());
       set_jcr_job_status(jcr, JS_ErrorTerminated);
       goto bail_out;
    }
-   sd->msglen = pm_strcpy(sd->msg, bootstrap); 
+   sd->msglen = pm_strcpy(sd->msg, bootstrap);
    bnet_send(sd);
    while (fgets(buf, sizeof(buf), bs)) {
       sd->msglen = Mmsg(sd->msg, "%s", buf);
-      bnet_send(sd);      
+      bnet_send(sd);
    }
    bnet_sig(sd, BNET_EOD);
    fclose(bs);
index d02a1647a1eda470e9cadf11642433fe14f4341d..b5db573bd3839460d92841384a5ee3b66f86e512 100644 (file)
@@ -59,17 +59,17 @@ int bclose_chksize(JCR *jcr, BFILE *bfd, off_t osize)
    bclose(bfd);                              /* first close file */
    if (fsize > 0 && fsize != osize) {
       Jmsg3(jcr, M_ERROR, 0, _("File size of resource fork for restored file %s not correct. Original %s, restored %s.\n"),
-            jcr->last_fname, edit_uint64(osize, ec1),
-            edit_uint64(fsize, ec2));
+           jcr->last_fname, edit_uint64(osize, ec1),
+           edit_uint64(fsize, ec2));
       return -1;
    }
    return 0;
 }
 #endif
 
-/* 
+/*
  * Restore the requested files.
- * 
+ *
  */
 void do_restore(JCR *jcr)
 {
@@ -134,8 +134,8 @@ void do_restore(JCR *jcr)
    jcr->compress_buf = (char *)bmalloc(compress_buf_size);
 #endif
 
-   /* 
-    * Get a record from the Storage daemon. We are guaranteed to 
+   /*
+    * Get a record from the Storage daemon. We are guaranteed to
     *  receive records in the following order:
     *  1. Stream record header
     *  2. Stream data
@@ -149,24 +149,24 @@ void do_restore(JCR *jcr)
     */
    while (bget_msg(sd) >= 0 && !job_canceled(jcr)) {
       /*
-       * First we expect a Stream Record Header 
+       * First we expect a Stream Record Header
        */
       if (sscanf(sd->msg, rec_header, &VolSessionId, &VolSessionTime, &file_index,
          &stream, &size) != 5) {
-         Jmsg1(jcr, M_FATAL, 0, _("Record header scan error: %s\n"), sd->msg);
+        Jmsg1(jcr, M_FATAL, 0, _("Record header scan error: %s\n"), sd->msg);
         goto bail_out;
       }
       Dmsg2(30, "Got hdr: FilInx=%d Stream=%d.\n", file_index, stream);
 
-      /* 
+      /*
        * Now we expect the Stream Data
        */
       if (bget_msg(sd) < 0) {
-         Jmsg1(jcr, M_FATAL, 0, _("Data record error. ERR=%s\n"), bnet_strerror(sd));
+        Jmsg1(jcr, M_FATAL, 0, _("Data record error. ERR=%s\n"), bnet_strerror(sd));
         goto bail_out;
       }
       if (size != (uint32_t)sd->msglen) {
-         Jmsg2(jcr, M_FATAL, 0, _("Actual data size %d not same as header %d\n"), sd->msglen, size);
+        Jmsg2(jcr, M_FATAL, 0, _("Actual data size %d not same as header %d\n"), sd->msglen, size);
         goto bail_out;
       }
       Dmsg1(30, "Got stream data, len=%d\n", sd->msglen);
@@ -175,24 +175,24 @@ void do_restore(JCR *jcr)
       switch (stream) {
       case STREAM_UNIX_ATTRIBUTES:
       case STREAM_UNIX_ATTRIBUTES_EX:
-         Dmsg1(30, "Stream=Unix Attributes. extract=%d\n", extract);
+        Dmsg1(30, "Stream=Unix Attributes. extract=%d\n", extract);
         /* If extracting, it was from previous stream, so
          * close the output file.
          */
         if (extract) {
            if (!is_bopen(&bfd) && !is_bopen(&rsrc_bfd)) {
-               Jmsg0(jcr, M_ERROR, 0, _("Logic error output file should be open\n"));
+              Jmsg0(jcr, M_ERROR, 0, _("Logic error output file should be open\n"));
            }
 #ifdef HAVE_DARWIN_OS
-            if (is_bopen(&rsrc_bfd)) {
-               bclose_chksize(jcr, &rsrc_bfd, rsrc_len);
-            }
+           if (is_bopen(&rsrc_bfd)) {
+              bclose_chksize(jcr, &rsrc_bfd, rsrc_len);
+           }
 #endif
-            if (is_bopen(&bfd)) {
-               set_attributes(jcr, attr, &bfd);
-            }
+           if (is_bopen(&bfd)) {
+              set_attributes(jcr, attr, &bfd);
+           }
            extract = false;
-            Dmsg0(30, "Stop extracting.\n");
+           Dmsg0(30, "Stop extracting.\n");
         }
 
 
@@ -200,20 +200,20 @@ void do_restore(JCR *jcr)
            goto bail_out;
         }
         if (file_index != attr->file_index) {
-            Jmsg(jcr, M_FATAL, 0, _("Record header file index %ld not equal record index %ld\n"),
+           Jmsg(jcr, M_FATAL, 0, _("Record header file index %ld not equal record index %ld\n"),
                 file_index, attr->file_index);
-            Dmsg0(100, "File index error\n");
+           Dmsg0(100, "File index error\n");
            goto bail_out;
         }
-           
-         Dmsg3(200, "File %s\nattrib=%s\nattribsEx=%s\n", attr->fname, 
+
+        Dmsg3(200, "File %s\nattrib=%s\nattribsEx=%s\n", attr->fname,
               attr->attr, attr->attrEx);
 
         attr->data_stream = decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
 
         if (!is_stream_supported(attr->data_stream)) {
            if (!non_support_data++) {
-               Jmsg(jcr, M_ERROR, 0, _("%s stream not supported on this Client.\n"),
+              Jmsg(jcr, M_ERROR, 0, _("%s stream not supported on this Client.\n"),
                  stream_to_ascii(attr->data_stream));
            }
            continue;
@@ -222,12 +222,12 @@ void do_restore(JCR *jcr)
         build_attr_output_fnames(jcr, attr);
 
 #ifdef HAVE_DARWIN_OS
-         from_base64(&rsrc_len, attr->attrEx);
+        from_base64(&rsrc_len, attr->attrEx);
 #endif
 
         jcr->num_files_examined++;
 
-         Dmsg1(30, "Outfile=%s\n", attr->ofname);
+        Dmsg1(30, "Outfile=%s\n", attr->ofname);
         extract = false;
         stat = create_file(jcr, attr, &bfd, jcr->replace);
         switch (stat) {
@@ -244,12 +244,12 @@ void do_restore(JCR *jcr)
            jcr->JobFiles++;
            fileAddr = 0;
            print_ls_output(jcr, attr);
-            if (!extract) {
-               /* set attributes now because file will not be extracted */
-               set_attributes(jcr, attr, &bfd);
-            }
+           if (!extract) {
+              /* set attributes now because file will not be extracted */
+              set_attributes(jcr, attr, &bfd);
+           }
 #ifdef HAVE_DARWIN_OS
-            if (rsrc_len > 0) {
+           if (rsrc_len > 0) {
               rsrcAddr = 0;
               if (bopen_rsrc(&rsrc_bfd, jcr->last_fname, O_WRONLY | O_TRUNC | O_BINARY, 0) < 0) {
                  Jmsg(jcr, M_ERROR, 0, _("     Cannot open resource fork for %s"), jcr->last_fname);
@@ -260,13 +260,13 @@ void do_restore(JCR *jcr)
            }
 #endif
            break;
-        }  
+        }
         break;
 
       /* Data stream */
       case STREAM_FILE_DATA:
-      case STREAM_SPARSE_DATA: 
-      case STREAM_WIN32_DATA:  
+      case STREAM_SPARSE_DATA:
+      case STREAM_WIN32_DATA:
         if (extract) {
            if (stream == STREAM_SPARSE_DATA) {
               ser_declare;
@@ -282,7 +282,7 @@ void do_restore(JCR *jcr)
                  if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) {
                     berrno be;
                     be.set_errno(bfd.berrno);
-                     Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
+                    Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
                         edit_uint64(fileAddr, ec1), attr->ofname, be.strerror());
                     extract = false;
                     bclose(&bfd);
@@ -296,12 +296,12 @@ void do_restore(JCR *jcr)
               wbuf = sd->msg;
               wsize = sd->msglen;
            }
-            Dmsg2(30, "Write %u bytes, total before write=%u\n", wsize, total);
+           Dmsg2(30, "Write %u bytes, total before write=%u\n", wsize, total);
            if ((uint32_t)bwrite(&bfd, wbuf, wsize) != wsize) {
-               Dmsg0(0, "===Write error===\n");
+              Dmsg0(0, "===Write error===\n");
               berrno be;
               be.set_errno(bfd.berrno);
-               Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: ERR=%s\n"), attr->ofname, 
+              Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: ERR=%s\n"), attr->ofname,
                     be.strerror());
               extract = false;
               bclose(&bfd);
@@ -309,7 +309,7 @@ void do_restore(JCR *jcr)
                  bclose(&rsrc_bfd);
               }
               continue;
-           } 
+           }
            total += wsize;
            jcr->JobBytes += wsize;
            jcr->ReadBytes += wsize;
@@ -319,8 +319,8 @@ void do_restore(JCR *jcr)
 
       /* GZIP data stream */
       case STREAM_GZIP_DATA:
-      case STREAM_SPARSE_GZIP_DATA:  
-      case STREAM_WIN32_GZIP_DATA:  
+      case STREAM_SPARSE_GZIP_DATA:
+      case STREAM_WIN32_GZIP_DATA:
 #ifdef HAVE_LIBZ
         if (extract) {
            uLong compress_len;
@@ -339,7 +339,7 @@ void do_restore(JCR *jcr)
                  if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) {
                     berrno be;
                     be.set_errno(bfd.berrno);
-                     Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
+                    Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
                         edit_uint64(fileAddr, ec1), attr->ofname, be.strerror());
                     extract = false;
                     bclose(&bfd);
@@ -354,10 +354,10 @@ void do_restore(JCR *jcr)
               wsize = sd->msglen;
            }
            compress_len = compress_buf_size;
-            Dmsg2(100, "Comp_len=%d msglen=%d\n", compress_len, wsize);
-           if ((stat=uncompress((Byte *)jcr->compress_buf, &compress_len, 
+           Dmsg2(100, "Comp_len=%d msglen=%d\n", compress_len, wsize);
+           if ((stat=uncompress((Byte *)jcr->compress_buf, &compress_len,
                  (const Byte *)wbuf, (uLong)wsize)) != Z_OK) {
-               Jmsg(jcr, M_ERROR, 0, _("Uncompression error on file %s. ERR=%s\n"), 
+              Jmsg(jcr, M_ERROR, 0, _("Uncompression error on file %s. ERR=%s\n"),
                  attr->ofname, zlib_strerror(stat));
               extract = false;
               bclose(&bfd);
@@ -367,12 +367,12 @@ void do_restore(JCR *jcr)
               continue;
            }
 
-            Dmsg2(100, "Write uncompressed %d bytes, total before write=%d\n", compress_len, total);
+           Dmsg2(100, "Write uncompressed %d bytes, total before write=%d\n", compress_len, total);
            if ((uLong)bwrite(&bfd, jcr->compress_buf, compress_len) != compress_len) {
-               Dmsg0(0, "===Write error===\n");
+              Dmsg0(0, "===Write error===\n");
               berrno be;
               be.set_errno(bfd.berrno);
-               Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), attr->ofname, be.strerror());
+              Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), attr->ofname, be.strerror());
               extract = false;
               bclose(&bfd);
               if (is_bopen(&rsrc_bfd)) {
@@ -387,7 +387,7 @@ void do_restore(JCR *jcr)
         }
 #else
         if (extract) {
-            Jmsg(jcr, M_ERROR, 0, _("GZIP data stream found, but GZIP not configured!\n"));
+           Jmsg(jcr, M_ERROR, 0, _("GZIP data stream found, but GZIP not configured!\n"));
            extract = false;
            bclose(&bfd);
            if (is_bopen(&rsrc_bfd)) {
@@ -402,70 +402,70 @@ void do_restore(JCR *jcr)
       /* Silently ignore if we cannot write - we already reported that */
       case STREAM_MACOS_FORK_DATA:
 #ifdef HAVE_DARWIN_OS
-         if (is_bopen(&rsrc_bfd) && sd->msglen) {
-            Dmsg2(30, "Write %u bytes, total before write=%u\n", sd->msglen, total);
-            if (bwrite(&rsrc_bfd, sd->msg, sd->msglen) != sd->msglen) {
-               Dmsg0(0, "===Write error===\n");
-               berrno be;
-               be.set_errno(rsrc_bfd.berrno);
-               Jmsg2(jcr, M_ERROR, 0, _("Write error on resource fork of %s: ERR=%s\n"), jcr->last_fname,
-                     be.strerror());
-               extract = false;
+        if (is_bopen(&rsrc_bfd) && sd->msglen) {
+           Dmsg2(30, "Write %u bytes, total before write=%u\n", sd->msglen, total);
+           if (bwrite(&rsrc_bfd, sd->msg, sd->msglen) != sd->msglen) {
+              Dmsg0(0, "===Write error===\n");
+              berrno be;
+              be.set_errno(rsrc_bfd.berrno);
+              Jmsg2(jcr, M_ERROR, 0, _("Write error on resource fork of %s: ERR=%s\n"), jcr->last_fname,
+                    be.strerror());
+              extract = false;
               if (is_bopen(&bfd)) {
                  bclose(&bfd);
               }
-               bclose(&rsrc_bfd);
-               continue;
-            } 
-            total += sd->msglen;
-            jcr->JobBytes += sd->msglen;
-            jcr->ReadBytes += sd->msglen;
-            rsrcAddr += sd->msglen;
-         }
+              bclose(&rsrc_bfd);
+              continue;
+           }
+           total += sd->msglen;
+           jcr->JobBytes += sd->msglen;
+           jcr->ReadBytes += sd->msglen;
+           rsrcAddr += sd->msglen;
+        }
         break;
 #else
-         non_support_rsrc++;
+        non_support_rsrc++;
 #endif
 
       case STREAM_HFSPLUS_ATTRIBUTES:
 #ifdef HAVE_DARWIN_OS
-         Dmsg0(30, "Restoring Finder Info");
-         if (sd->msglen != 32) {
-            Jmsg(jcr, M_ERROR, 0, _("     Invalid length of Finder Info (got %d, not 32)"), sd->msglen);
-            continue;
-         }
-         if (setattrlist(jcr->last_fname, &attrList, sd->msg, sd->msglen, 0) != 0) {
-            Jmsg(jcr, M_ERROR, 0, _("     Could not set Finder Info on %s"), jcr->last_fname);
-            continue;
-         }
-         break;
+        Dmsg0(30, "Restoring Finder Info");
+        if (sd->msglen != 32) {
+           Jmsg(jcr, M_ERROR, 0, _("     Invalid length of Finder Info (got %d, not 32)"), sd->msglen);
+           continue;
+        }
+        if (setattrlist(jcr->last_fname, &attrList, sd->msg, sd->msglen, 0) != 0) {
+           Jmsg(jcr, M_ERROR, 0, _("     Could not set Finder Info on %s"), jcr->last_fname);
+           continue;
+        }
+        break;
 #else
-         non_support_finfo++;
+        non_support_finfo++;
 #endif
 /*** FIXME ***/
-case STREAM_UNIX_ATTRIBUTES_ACCESS_ACL:         
+case STREAM_UNIX_ATTRIBUTES_ACCESS_ACL:
 #ifdef HAVE_ACL
         /* Recover Acess ACL from stream and check it */
         acl = acl_from_text(sd->msg);
         if (acl_valid(acl) != 0) {
-            Jmsg1(jcr, M_WARNING, 0, "Failure in the ACL of %s! FD is not able to restore it!\n", jcr->last_fname);
+           Jmsg1(jcr, M_WARNING, 0, "Failure in the ACL of %s! FD is not able to restore it!\n", jcr->last_fname);
            acl_free(acl);
         }
-        
+
         /* Try to restore ACL */
         if (attr->type == FT_DIREND) {
            /* Directory */
            if (acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
-               Jmsg1(jcr, M_WARNING, 0, "Error! Can't restore ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
+              Jmsg1(jcr, M_WARNING, 0, "Error! Can't restore ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
            }
         /* File or Link */
         } else if (acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
-            Jmsg1(jcr, M_WARNING, 0, "Error! Can't restore ACL of file: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
+           Jmsg1(jcr, M_WARNING, 0, "Error! Can't restore ACL of file: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
         }
         acl_free(acl);
-         Dmsg1(200, "ACL of file: %s successfully restored!", jcr->last_fname);
+        Dmsg1(200, "ACL of file: %s successfully restored!", jcr->last_fname);
         break;
-#else 
+#else
         non_support_acl++;
         break;                       /* unconfigured, ignore */
 #endif
@@ -474,26 +474,26 @@ case STREAM_UNIX_ATTRIBUTES_ACCESS_ACL:
       /* Recover Default ACL from stream and check it */
         acl = acl_from_text(sd->msg);
         if (acl_valid(acl) != 0) {
-            Jmsg1(jcr, M_WARNING, 0, "Failure in the Default ACL of %s! FD is not able to restore it!\n", jcr->last_fname);
+           Jmsg1(jcr, M_WARNING, 0, "Failure in the Default ACL of %s! FD is not able to restore it!\n", jcr->last_fname);
            acl_free(acl);
         }
-        
+
         /* Try to restore ACL */
         if (attr->type == FT_DIREND) {
            /* Directory */
            if (acl_set_file(jcr->last_fname, ACL_TYPE_DEFAULT, acl) != 0) {
-               Jmsg1(jcr, M_WARNING, 0, "Error! Can't restore Default ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
+              Jmsg1(jcr, M_WARNING, 0, "Error! Can't restore Default ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
             }
-         }
+        }
         acl_free(acl);
-         Dmsg1(200, "Default ACL of file: %s successfully restored!", jcr->last_fname);
+        Dmsg1(200, "Default ACL of file: %s successfully restored!", jcr->last_fname);
         break;
-#else 
+#else
         non_support_acl++;
         break;                       /* unconfigured, ignore */
 #endif
 /*** FIXME ***/
-        
+
       case STREAM_MD5_SIGNATURE:
       case STREAM_SHA1_SIGNATURE:
         break;
@@ -501,7 +501,7 @@ case STREAM_UNIX_ATTRIBUTES_ACCESS_ACL:
       case STREAM_PROGRAM_NAMES:
       case STREAM_PROGRAM_DATA:
         if (!prog_name_msg) {
-            Pmsg0(000, "Got Program Name or Data Stream. Ignored.\n");
+           Pmsg0(000, "Got Program Name or Data Stream. Ignored.\n");
            prog_name_msg++;
         }
         break;
@@ -509,22 +509,22 @@ case STREAM_UNIX_ATTRIBUTES_ACCESS_ACL:
       default:
         /* If extracting, wierd stream (not 1 or 2), close output file anyway */
         if (extract) {
-            Dmsg1(30, "Found wierd stream %d\n", stream);
+           Dmsg1(30, "Found wierd stream %d\n", stream);
            if (!is_bopen(&bfd)) {
-               Jmsg0(jcr, M_ERROR, 0, _("Logic error output file should be open but is not.\n"));
+              Jmsg0(jcr, M_ERROR, 0, _("Logic error output file should be open but is not.\n"));
            }
            set_attributes(jcr, attr, &bfd);
            extract = false;
         }
-         Jmsg(jcr, M_ERROR, 0, _("Unknown stream=%d ignored. This shouldn't happen!\n"), stream);
-         Dmsg2(0, "None of above!!! stream=%d data=%s\n", stream,sd->msg);
+        Jmsg(jcr, M_ERROR, 0, _("Unknown stream=%d ignored. This shouldn't happen!\n"), stream);
+        Dmsg2(0, "None of above!!! stream=%d data=%s\n", stream,sd->msg);
         break;
       } /* end switch(stream) */
 
    } /* end while get_msg() */
 
    /* If output file is still open, it was the last one in the
-    * archive since we just hit an end of file, so close the file. 
+    * archive since we just hit an end of file, so close the file.
     */
    if (is_bopen(&bfd)) {
       set_attributes(jcr, attr, &bfd);
@@ -562,7 +562,7 @@ ok_out:
       Jmsg(jcr, M_INFO, 0, _("%d non-supported acl streams ignored.\n"), non_support_acl);
    }
 
-}         
+}
 
 #ifdef HAVE_LIBZ
 /*
index 3ca00fe8bceee4d0c7e714a9f89b66a0d703a5ff..5ef99d39b7de5051e613c616d8c15d76ab250aa7 100755 (executable)
@@ -52,7 +52,7 @@ static int privs = 0;
 /*
  * General status generator
  */
-static void do_status(void sendit(const char *msg, int len, void *sarg), void *arg) 
+static void do_status(void sendit(const char *msg, int len, void *sarg), void *arg)
 {
    int sec, bps;
    char *msg, b1[32], b2[32], b3[32], b4[32];
@@ -66,23 +66,23 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a
              HOST_OS, DISTNAME, DISTVER);
    sendit(msg, len, arg);
    bstrftime_nc(dt, sizeof(dt), daemon_start_time);
-   len = Mmsg(msg, _("Daemon started %s, %d Job%s run since started.\n"), 
-        dt, num_jobs_run, num_jobs_run == 1 ? "" : "s");
+   len = Mmsg(msg, _("Daemon started %s, %d Job%s run since started.\n"),
+       dt, num_jobs_run, num_jobs_run == 1 ? "" : "s");
    sendit(msg, len, arg);
 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
    if (debug_level > 0) {
       if (!privs) {
         privs = enable_backup_privileges(NULL, 1);
       }
-      len = Mmsg(msg, 
-         _(" Priv 0x%x APIs=%sOPT,%sATP,%sLPV,%sGFAE,%sBR,%sBW,%sSPSP\n"), privs,
-         p_OpenProcessToken?"":"!",
-         p_AdjustTokenPrivileges?"":"!",
-         p_LookupPrivilegeValue?"":"!",
-         p_GetFileAttributesEx?"":"!",
-         p_BackupRead?"":"!",
-         p_BackupWrite?"":"!",
-         p_SetProcessShutdownParameters?"":"!");
+      len = Mmsg(msg,
+        _(" Priv 0x%x APIs=%sOPT,%sATP,%sLPV,%sGFAE,%sBR,%sBW,%sSPSP\n"), privs,
+        p_OpenProcessToken?"":"!",
+        p_AdjustTokenPrivileges?"":"!",
+        p_LookupPrivilegeValue?"":"!",
+        p_GetFileAttributesEx?"":"!",
+        p_BackupRead?"":"!",
+        p_BackupWrite?"":"!",
+        p_SetProcessShutdownParameters?"":"!");
       sendit(msg, len, arg);
    }
 #endif
@@ -93,7 +93,7 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a
            edit_uint64_with_commas(sm_buffers, b3),
            edit_uint64_with_commas(sm_max_buffers, b4));
       sendit(msg, len, arg);
-      len = Mmsg(msg, _(" Sizeof: off_t=%d size_t=%d debug=%d trace=%d\n"), 
+      len = Mmsg(msg, _(" Sizeof: off_t=%d size_t=%d debug=%d trace=%d\n"),
            sizeof(off_t), sizeof(size_t), debug_level, get_trace());
       sendit(msg, len, arg);
    }
@@ -101,7 +101,7 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a
    list_terminated_jobs(sendit, arg);
 
    /*
-    * List running jobs  
+    * List running jobs
     */
    Dmsg0(1000, "Begin status jcr loop.\n");
    len = Mmsg(msg, _("Running Jobs:\n"));
@@ -110,12 +110,12 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a
    foreach_jcr(njcr) {
       bstrftime_nc(dt, sizeof(dt), njcr->start_time);
       if (njcr->JobId == 0) {
-         len = Mmsg(msg, _("Director connected at: %s\n"), dt);
+        len = Mmsg(msg, _("Director connected at: %s\n"), dt);
       } else {
-         len = Mmsg(msg, _("JobId %d Job %s is running.\n"), 
+        len = Mmsg(msg, _("JobId %d Job %s is running.\n"),
                    njcr->JobId, njcr->Job);
         sendit(msg, len, arg);
-         len = Mmsg(msg, _("    %s Job started: %s\n"), 
+        len = Mmsg(msg, _("    %s Job started: %s\n"),
                    job_type_to_str(njcr->JobType), dt);
       }
       sendit(msg, len, arg);
@@ -128,28 +128,28 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a
         sec = 1;
       }
       bps = (int)(njcr->JobBytes / sec);
-      len = Mmsg(msg,  _("    Files=%s Bytes=%s Bytes/sec=%s\n"), 
+      len = Mmsg(msg,  _("    Files=%s Bytes=%s Bytes/sec=%s\n"),
           edit_uint64_with_commas(njcr->JobFiles, b1),
           edit_uint64_with_commas(njcr->JobBytes, b2),
           edit_uint64_with_commas(bps, b3));
       sendit(msg, len, arg);
-      len = Mmsg(msg, _("    Files Examined=%s\n"), 
+      len = Mmsg(msg, _("    Files Examined=%s\n"),
           edit_uint64_with_commas(njcr->num_files_examined, b1));
       sendit(msg, len, arg);
       if (njcr->JobFiles > 0) {
         P(njcr->mutex);
-         len = Mmsg(msg, _("    Processing file: %s\n"), njcr->last_fname);
+        len = Mmsg(msg, _("    Processing file: %s\n"), njcr->last_fname);
         V(njcr->mutex);
         sendit(msg, len, arg);
       }
 
       found = 1;
       if (njcr->store_bsock) {
-         len = Mmsg(msg, "    SDReadSeqNo=%" lld " fd=%d\n",
+        len = Mmsg(msg, "    SDReadSeqNo=%" lld " fd=%d\n",
             njcr->store_bsock->read_seqno, njcr->store_bsock->fd);
         sendit(msg, len, arg);
       } else {
-         len = Mmsg(msg, _("    SDSocket closed.\n"));
+        len = Mmsg(msg, _("    SDSocket closed.\n"));
         sendit(msg, len, arg);
       }
       free_locked_jcr(njcr);
@@ -165,7 +165,7 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a
    free_pool_memory(msg);
 }
 
-static void  list_terminated_jobs(void sendit(const char *msg, int len, void *sarg), void *arg) 
+static void  list_terminated_jobs(void sendit(const char *msg, int len, void *sarg), void *arg)
 {
    char dt[MAX_TIME_LENGTH], b1[30], b2[30];
    char level[10];
@@ -173,17 +173,17 @@ static void  list_terminated_jobs(void sendit(const char *msg, int len, void *sa
    const char *msg;
 
    if (last_jobs->size() == 0) {
-      msg = _("No Terminated Jobs.\n"); 
+      msg = _("No Terminated Jobs.\n");
       sendit(msg, strlen(msg), arg);
       return;
    }
    lock_last_jobs_list();
    sendit("\n", 1, arg);               /* send separately */
-   msg =  _("Terminated Jobs:\n"); 
+   msg =  _("Terminated Jobs:\n");
    sendit(msg, strlen(msg), arg);
    msg =  _(" JobId  Level     Files         Bytes  Status   Finished        Name \n");
    sendit(msg, strlen(msg), arg);
-   msg = _("======================================================================\n"); 
+   msg = _("======================================================================\n");
    sendit(msg, strlen(msg), arg);
    foreach_dlist(je, last_jobs) {
       char JobName[MAX_NAME_LENGTH];
@@ -194,7 +194,7 @@ static void  list_terminated_jobs(void sendit(const char *msg, int len, void *sa
       switch (je->JobType) {
       case JT_ADMIN:
       case JT_RESTORE:
-         bstrncpy(level, "    ", sizeof(level));
+        bstrncpy(level, "    ", sizeof(level));
         break;
       default:
         bstrncpy(level, level_to_str(je->JobLevel), sizeof(level));
@@ -203,38 +203,38 @@ static void  list_terminated_jobs(void sendit(const char *msg, int len, void *sa
       }
       switch (je->JobStatus) {
       case JS_Created:
-         termstat = "Created";
+        termstat = "Created";
         break;
       case JS_FatalError:
       case JS_ErrorTerminated:
-         termstat = "Error";
+        termstat = "Error";
         break;
       case JS_Differences:
-         termstat = "Diffs";
+        termstat = "Diffs";
         break;
       case JS_Canceled:
-         termstat = "Cancel";
+        termstat = "Cancel";
         break;
       case JS_Terminated:
-         termstat = "OK";
+        termstat = "OK";
         break;
       default:
-         termstat = "Other";
+        termstat = "Other";
         break;
       }
       bstrncpy(JobName, je->Job, sizeof(JobName));
       /* There are three periods after the Job name */
       char *p;
       for (int i=0; i<3; i++) {
-         if ((p=strrchr(JobName, '.')) != NULL) {
+        if ((p=strrchr(JobName, '.')) != NULL) {
            *p = 0;
         }
       }
-      bsnprintf(buf, sizeof(buf), _("%6d  %-6s %8s %14s %-7s  %-8s %s\n"), 
+      bsnprintf(buf, sizeof(buf), _("%6d  %-6s %8s %14s %-7s  %-8s %s\n"),
         je->JobId,
-        level, 
+        level,
         edit_uint64_with_commas(je->JobFiles, b1),
-        edit_uint64_with_commas(je->JobBytes, b2), 
+        edit_uint64_with_commas(je->JobBytes, b2),
         termstat,
         dt, JobName);
       sendit(buf, strlen(buf), arg);
@@ -256,7 +256,7 @@ static void bsock_sendit(const char *msg, int len, void *arg)
    user->msglen = len+1;
    bnet_send(user);
 }
-                                  
+
 /*
  * Status command from Director
  */
@@ -282,7 +282,7 @@ int qstatus_cmd(JCR *jcr)
    s_last_job* job;
 
    time = get_memory(dir->msglen+1);
-   
+
    if (sscanf(dir->msg, qstatus, time) != 1) {
       pm_strcpy(&jcr->errmsg, dir->msg);
       Jmsg1(jcr, M_FATAL, 0, _("Bad .status command: %s\n"), jcr->errmsg);
@@ -292,7 +292,7 @@ int qstatus_cmd(JCR *jcr)
       return 0;
    }
    unbash_spaces(time);
-   
+
    if (strcmp(time, "current") == 0) {
       bnet_fsend(dir, OKqstatus, time);
       lock_jcr_chain();
@@ -319,7 +319,7 @@ int qstatus_cmd(JCR *jcr)
       free_memory(time);
       return 0;
    }
-   
+
    bnet_sig(dir, BNET_EOD);
    free_memory(time);
    return 1;
@@ -328,7 +328,7 @@ int qstatus_cmd(JCR *jcr)
 /*
  * Convert Job Level into a string
  */
-static const char *level_to_str(int level) 
+static const char *level_to_str(int level)
 {
    const char *str;
 
@@ -391,14 +391,14 @@ static void win32_sendit(const char *msg, int len, void *marg)
    struct s_win32_arg *arg = (struct s_win32_arg *)marg;
 
    if (len > 0 && msg[len-1] == '\n') {
-       // when compiling with visual studio some strings are read-only 
+       // when compiling with visual studio some strings are read-only
        // and cause access violations. So we creat a tmp copy.
        char *_msg = (char *)alloca(len);
        bstrncpy(_msg, msg, len);
        msg = _msg;
    }
    SendDlgItemMessage(arg->hwnd, arg->idlist, LB_ADDSTRING, 0, (LONG)msg);
-   
+
 }
 
 void FillStatusBox(HWND hwnd, int idlist)
@@ -429,7 +429,7 @@ char *bac_status(char *buf, int buf_len)
    foreach_jcr(njcr) {
       if (njcr->JobId != 0) {
         stat = JS_Running;
-         termstat = _("Bacula Running");
+        termstat = _("Bacula Running");
         free_locked_jcr(njcr);
         break;
       }
@@ -444,15 +444,15 @@ char *bac_status(char *buf, int buf_len)
       stat = job->JobStatus;
       switch (job->JobStatus) {
       case JS_Canceled:
-         termstat = _("Last Job Canceled");
+        termstat = _("Last Job Canceled");
         break;
       case JS_ErrorTerminated:
-      case JS_FatalError:  
-         termstat = _("Last Job Failed");
+      case JS_FatalError:
+        termstat = _("Last Job Failed");
         break;
       default:
         if (job->Errors) {
-            termstat = _("Last Job had Warnings");
+           termstat = _("Last Job had Warnings");
         }
         break;
       }
index 35b28e6ab1513e5e60f8243ed15cc4cedc0bb6d1..883596817ddf7be15dc14b3a66c1917f979ad9cb 100644 (file)
 static int verify_file(FF_PKT *ff_pkt, void *my_pkt);
 static int read_chksum(BFILE *bfd, CHKSUM *chksum, JCR *jcr, char *fname);
 
-/* 
+/*
  * Find all the requested files and send attributes
  * to the Director.
- * 
+ *
  */
 void do_verify(JCR *jcr)
 {
    set_jcr_job_status(jcr, JS_Running);
    jcr->buf_size = DEFAULT_NETWORK_BUFFER_SIZE;
    if ((jcr->big_buf = (char *) malloc(jcr->buf_size)) == NULL) {
-      Jmsg1(jcr, M_ABORT, 0, _("Cannot malloc %d network read buffer\n"), 
+      Jmsg1(jcr, M_ABORT, 0, _("Cannot malloc %d network read buffer\n"),
         DEFAULT_NETWORK_BUFFER_SIZE);
    }
    set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime);
    Dmsg0(10, "Start find files\n");
    /* Subroutine verify_file() is called for each file */
-   find_files(jcr, (FF_PKT *)jcr->ff, verify_file, (void *)jcr);  
+   find_files(jcr, (FF_PKT *)jcr->ff, verify_file, (void *)jcr);
    Dmsg0(10, "End find files\n");
 
    if (jcr->big_buf) {
@@ -56,14 +56,14 @@ void do_verify(JCR *jcr)
       jcr->big_buf = NULL;
    }
    set_jcr_job_status(jcr, JS_Terminated);
-}         
+}
 
-/* 
+/*
  * Called here by find() for each file.
  *
  *  Find the file, compute the MD5 or SHA1 and send it back to the Director
  */
-static int verify_file(FF_PKT *ff_pkt, void *pkt) 
+static int verify_file(FF_PKT *ff_pkt, void *pkt)
 {
    char attribs[MAXSTRING];
    char attribsEx[MAXSTRING];
@@ -76,7 +76,7 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt)
    if (job_canceled(jcr)) {
       return 0;
    }
-   
+
    dir = jcr->dir_bsock;
    jcr->num_files_examined++;        /* bump total file count */
 
@@ -163,7 +163,7 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt)
    pm_strcpy(jcr->last_fname, ff_pkt->fname);
    V(jcr->mutex);
 
-   /* 
+   /*
     * Send file attributes to Director
     *  File_index
     *  Stream
@@ -178,16 +178,16 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt)
    Dmsg2(400, "send ATTR inx=%d fname=%s\n", jcr->JobFiles, ff_pkt->fname);
    if (ff_pkt->type == FT_LNK || ff_pkt->type == FT_LNKSAVED) {
       stat = bnet_fsend(dir, "%d %d %s %s%c%s%c%s%c", jcr->JobFiles,
-           STREAM_UNIX_ATTRIBUTES, ff_pkt->VerifyOpts, ff_pkt->fname, 
+           STREAM_UNIX_ATTRIBUTES, ff_pkt->VerifyOpts, ff_pkt->fname,
            0, attribs, 0, ff_pkt->link, 0);
    } else if (ff_pkt->type == FT_DIREND) {
         /* Here link is the canonical filename (i.e. with trailing slash) */
-         stat = bnet_fsend(dir,"%d %d %s %s%c%s%c%c", jcr->JobFiles,
-              STREAM_UNIX_ATTRIBUTES, ff_pkt->VerifyOpts, ff_pkt->link, 
+        stat = bnet_fsend(dir,"%d %d %s %s%c%s%c%c", jcr->JobFiles,
+              STREAM_UNIX_ATTRIBUTES, ff_pkt->VerifyOpts, ff_pkt->link,
               0, attribs, 0, 0);
    } else {
       stat = bnet_fsend(dir,"%d %d %s %s%c%s%c%c", jcr->JobFiles,
-           STREAM_UNIX_ATTRIBUTES, ff_pkt->VerifyOpts, ff_pkt->fname, 
+           STREAM_UNIX_ATTRIBUTES, ff_pkt->VerifyOpts, ff_pkt->fname,
            0, attribs, 0, 0);
    }
    Dmsg2(20, "bfiled>bdird: attribs len=%d: msg=%s\n", dir->msglen, dir->msg);
@@ -200,7 +200,7 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt)
     * The remainder of the function is all about getting the checksum.
     * First we initialise, then we read files, other streams and Finder Info.
     */
-   if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && 
+   if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) &&
            ff_pkt->flags & (FO_MD5|FO_SHA1))) {
       chksum_init(&chksum, ff_pkt->flags);
       binit(&bfd);
@@ -211,7 +211,7 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt)
            ff_pkt->ff_errno = errno;
            berrno be;
            be.set_errno(bfd.berrno);
-            Jmsg(jcr, M_NOTSAVED, 1, _("     Cannot open %s: ERR=%s.\n"),
+           Jmsg(jcr, M_NOTSAVED, 1, _("     Cannot open %s: ERR=%s.\n"),
                 ff_pkt->fname, be.strerror());
            jcr->Errors++;
            return 1;
@@ -226,7 +226,7 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt)
         if (bopen_rsrc(&bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) {
            ff_pkt->ff_errno = errno;
            berrno be;
-            Jmsg(jcr, M_NOTSAVED, -1, _("     Cannot open resource fork for %s: ERR=%s\n"),
+           Jmsg(jcr, M_NOTSAVED, -1, _("     Cannot open resource fork for %s: ERR=%s\n"),
                  ff_pkt->fname, be.strerror());
            jcr->Errors++;
            if (is_bopen(&ff_pkt->bfd)) {
@@ -254,10 +254,10 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt)
            stream = STREAM_SHA1_SIGNATURE;
         }
         bin_to_base64(chksumbuf, (char *)chksum.signature, chksum.length);
-         Dmsg3(400, "send inx=%d %s=%s\n", jcr->JobFiles, chksum.name, chksumbuf);
-         bnet_fsend(dir, "%d %d %s *%s-%d*", jcr->JobFiles, stream, chksumbuf,
+        Dmsg3(400, "send inx=%d %s=%s\n", jcr->JobFiles, chksum.name, chksumbuf);
+        bnet_fsend(dir, "%d %d %s *%s-%d*", jcr->JobFiles, stream, chksumbuf,
               chksum.name, jcr->JobFiles);
-         Dmsg3(20, "bfiled>bdird: %s len=%d: msg=%s\n", chksum.name,
+        Dmsg3(20, "bfiled>bdird: %s len=%d: msg=%s\n", chksum.name,
               dir->msglen, dir->msg);
       }
    }
@@ -281,7 +281,7 @@ int read_chksum(BFILE *bfd, CHKSUM *chksum, JCR *jcr, char *fname)
    if (n < 0) {
       berrno be;
       be.set_errno(bfd->berrno);
-      Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"), 
+      Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"),
            fname, be.strerror());
       jcr->Errors++;
       return -1;
index 57bcfaf5536b1c1bd8be235d6c041516f0e79870..99e296d09b7ebbee582a44d30396c651630c4820 100644 (file)
@@ -36,9 +36,9 @@ static char rec_header[] = "rechdr %ld %ld %ld %ld %ld";
 /* Forward referenced functions */
 
 
-/* 
+/*
  * Verify attributes of the requested files on the Volume
- * 
+ *
  */
 void do_verify_volume(JCR *jcr)
 {
@@ -50,7 +50,7 @@ void do_verify_volume(JCR *jcr)
    uint32_t VolSessionId, VolSessionTime, file_index;
    uint32_t record_file_index;
    int type, stat;
-   
+
    sd = jcr->store_bsock;
    if (!sd) {
       Jmsg(jcr, M_FATAL, 0, _("Storage command not issued before Verify.\n"));
@@ -78,29 +78,29 @@ void do_verify_volume(JCR *jcr)
    fname = get_pool_memory(PM_FNAME);
    lname = get_pool_memory(PM_FNAME);
 
-   /* 
+   /*
     * Get a record from the Storage daemon
     */
    while (bget_msg(sd) >= 0 && !job_canceled(jcr)) {
       /*
-       * First we expect a Stream Record Header 
+       * First we expect a Stream Record Header
        */
       if (sscanf(sd->msg, rec_header, &VolSessionId, &VolSessionTime, &file_index,
          &stream, &size) != 5) {
-         Jmsg1(jcr, M_FATAL, 0, _("Record header scan error: %s\n"), sd->msg);
+        Jmsg1(jcr, M_FATAL, 0, _("Record header scan error: %s\n"), sd->msg);
         goto bail_out;
       }
       Dmsg2(30, "Got hdr: FilInx=%d Stream=%d.\n", file_index, stream);
 
-      /* 
+      /*
        * Now we expect the Stream Data
        */
       if (bget_msg(sd) < 0) {
-         Jmsg1(jcr, M_FATAL, 0, _("Data record error. ERR=%s\n"), bnet_strerror(sd));
+        Jmsg1(jcr, M_FATAL, 0, _("Data record error. ERR=%s\n"), bnet_strerror(sd));
         goto bail_out;
       }
       if (size != ((uint32_t)sd->msglen)) {
-         Jmsg2(jcr, M_FATAL, 0, _("Actual data size %d not same as header %d\n"), sd->msglen, size);
+        Jmsg2(jcr, M_FATAL, 0, _("Actual data size %d not same as header %d\n"), sd->msglen, size);
         goto bail_out;
       }
       Dmsg1(30, "Got stream data, len=%d\n", sd->msglen);
@@ -111,7 +111,7 @@ void do_verify_volume(JCR *jcr)
       case STREAM_UNIX_ATTRIBUTES_EX:
         char *ap, *lp, *fp;
 
-         Dmsg0(400, "Stream=Unix Attributes.\n");
+        Dmsg0(400, "Stream=Unix Attributes.\n");
 
         if ((int)sizeof_pool_memory(fname) < sd->msglen) {
            fname = realloc_pool_memory(fname, sd->msglen + 1);
@@ -123,7 +123,7 @@ void do_verify_volume(JCR *jcr)
         *fname = 0;
         *lname = 0;
 
-        /*              
+        /*
          * An Attributes record consists of:
          *    File_index
          *    Type   (FT_types)
@@ -132,38 +132,38 @@ void do_verify_volume(JCR *jcr)
          *    Link name (if file linked i.e. FT_LNK)
          *    Extended Attributes (if Win32)
          */
-         if (sscanf(sd->msg, "%d %d", &record_file_index, &type) != 2) {
-            Jmsg(jcr, M_FATAL, 0, _("Error scanning record header: %s\n"), sd->msg);
-            Dmsg0(0, "\nError scanning header\n");
+        if (sscanf(sd->msg, "%d %d", &record_file_index, &type) != 2) {
+           Jmsg(jcr, M_FATAL, 0, _("Error scanning record header: %s\n"), sd->msg);
+           Dmsg0(0, "\nError scanning header\n");
            goto bail_out;
         }
-         Dmsg2(30, "Got Attr: FilInx=%d type=%d\n", record_file_index, type);
+        Dmsg2(30, "Got Attr: FilInx=%d type=%d\n", record_file_index, type);
         if (record_file_index != file_index) {
-            Jmsg(jcr, M_FATAL, 0, _("Record header file index %ld not equal record index %ld\n"),
+           Jmsg(jcr, M_FATAL, 0, _("Record header file index %ld not equal record index %ld\n"),
               file_index, record_file_index);
-            Dmsg0(0, "File index error\n");
+           Dmsg0(0, "File index error\n");
            goto bail_out;
         }
         ap = sd->msg;
-         while (*ap++ != ' ')         /* skip record file index */
+        while (*ap++ != ' ')         /* skip record file index */
            ;
-         while (*ap++ != ' ')         /* skip type */
+        while (*ap++ != ' ')         /* skip type */
            ;
         /* Save filename and position to attributes */
-        fp = fname;     
+        fp = fname;
         while (*ap != 0) {
            *fp++  = *ap++;           /* copy filename to fname */
         }
         *fp = *ap++;                 /* terminate filename & point to attribs */
 
-         Dmsg1(200, "Attr=%s\n", ap);
+        Dmsg1(200, "Attr=%s\n", ap);
         /* Skip to Link name */
         if (type == FT_LNK || type == FT_LNKSAVED) {
            lp = ap;
            while (*lp++ != 0) {
               ;
            }
-            strcat(lname, lp);        /* "save" link name */
+           strcat(lname, lp);        /* "save" link name */
         } else {
            *lname = 0;
         }
@@ -173,7 +173,7 @@ void do_verify_volume(JCR *jcr)
         pm_strcpy(&jcr->last_fname, fname); /* last file examined */
         V(jcr->mutex);
 
-        /* 
+        /*
          * Send file attributes to Director
          *   File_index
          *   Stream
@@ -185,19 +185,19 @@ void do_verify_volume(JCR *jcr)
          * slash. For a linked file, link is the link.
          */
         /* Send file attributes to Director */
-         Dmsg2(200, "send ATTR inx=%d fname=%s\n", jcr->JobFiles, fname);
+        Dmsg2(200, "send ATTR inx=%d fname=%s\n", jcr->JobFiles, fname);
         if (type == FT_LNK || type == FT_LNKSAVED) {
-            stat = bnet_fsend(dir, "%d %d %s %s%c%s%c%s%c", jcr->JobFiles,
-                          STREAM_UNIX_ATTRIBUTES, "pinsug5", fname, 
+           stat = bnet_fsend(dir, "%d %d %s %s%c%s%c%s%c", jcr->JobFiles,
+                         STREAM_UNIX_ATTRIBUTES, "pinsug5", fname,
                          0, ap, 0, lname, 0);
         } else {
-            stat = bnet_fsend(dir,"%d %d %s %s%c%s%c%c", jcr->JobFiles,
-                          STREAM_UNIX_ATTRIBUTES, "pinsug5", fname, 
+           stat = bnet_fsend(dir,"%d %d %s %s%c%s%c%c", jcr->JobFiles,
+                         STREAM_UNIX_ATTRIBUTES, "pinsug5", fname,
                          0, ap, 0, 0);
         }
-         Dmsg2(200, "bfiled>bdird: attribs len=%d: msg=%s\n", dir->msglen, dir->msg);
+        Dmsg2(200, "bfiled>bdird: attribs len=%d: msg=%s\n", dir->msglen, dir->msg);
         if (!stat) {
-            Jmsg(jcr, M_FATAL, 0, _("Network error in send to Director: ERR=%s\n"), bnet_strerror(dir));
+           Jmsg(jcr, M_FATAL, 0, _("Network error in send to Director: ERR=%s\n"), bnet_strerror(dir));
            goto bail_out;
         }
         break;
@@ -216,23 +216,23 @@ void do_verify_volume(JCR *jcr)
       case STREAM_MD5_SIGNATURE:
         char MD5buf[30];
         bin_to_base64(MD5buf, (char *)sd->msg, 16); /* encode 16 bytes */
-         Dmsg2(400, "send inx=%d MD5=%s\n", jcr->JobFiles, MD5buf);
-         bnet_fsend(dir, "%d %d %s *MD5-%d*", jcr->JobFiles, STREAM_MD5_SIGNATURE, MD5buf,
+        Dmsg2(400, "send inx=%d MD5=%s\n", jcr->JobFiles, MD5buf);
+        bnet_fsend(dir, "%d %d %s *MD5-%d*", jcr->JobFiles, STREAM_MD5_SIGNATURE, MD5buf,
            jcr->JobFiles);
-         Dmsg2(20, "bfiled>bdird: MD5 len=%d: msg=%s\n", dir->msglen, dir->msg);
+        Dmsg2(20, "bfiled>bdird: MD5 len=%d: msg=%s\n", dir->msglen, dir->msg);
         break;
-  
+
       case STREAM_SHA1_SIGNATURE:
         char SHA1buf[30];
         bin_to_base64(SHA1buf, (char *)sd->msg, 20); /* encode 20 bytes */
-         Dmsg2(400, "send inx=%d SHA1=%s\n", jcr->JobFiles, SHA1buf);
-         bnet_fsend(dir, "%d %d %s *SHA1-%d*", jcr->JobFiles, STREAM_SHA1_SIGNATURE, 
+        Dmsg2(400, "send inx=%d SHA1=%s\n", jcr->JobFiles, SHA1buf);
+        bnet_fsend(dir, "%d %d %s *SHA1-%d*", jcr->JobFiles, STREAM_SHA1_SIGNATURE,
            SHA1buf, jcr->JobFiles);
-         Dmsg2(20, "bfiled>bdird: SHA1 len=%d: msg=%s\n", dir->msglen, dir->msg);
+        Dmsg2(20, "bfiled>bdird: SHA1 len=%d: msg=%s\n", dir->msglen, dir->msg);
         break;
 
       default:
-         Pmsg2(0, "None of above!!! stream=%d data=%s\n", stream,sd->msg);
+        Pmsg2(0, "None of above!!! stream=%d data=%s\n", stream,sd->msg);
         break;
       } /* end switch */
    } /* end while bnet_get */
@@ -251,4 +251,4 @@ ok_out:
    free_pool_memory(lname);
    Dmsg2(050, "End Verify-Vol. Files=%d Bytes=%" lld "\n", jcr->JobFiles,
       jcr->JobBytes);
-}         
+}
index c556fa8a68544f5e76f425bb2bd343b35cfa3e46..e3e3420b73da900307243a5b07f1affde4b3b772 100644 (file)
@@ -1,15 +1,15 @@
-/* 
+/*
  * Dumb Windows program to put up a message box
  * containing the command line.  Any leading and
  * trailing quotes are stripped.
- * 
+ *
  *  Kern E. Sibbald
- *   July MM  
+ *   July MM
  */
 #include "windows.h"
 
 
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
 {
    int len = strlen(szCmdLine);
index 5408a752830592f8ac3accb78bdb6ccece611f1e..46a6e94e3dff8ef940413e8eef523f35cbed96df 100755 (executable)
@@ -17,7 +17,7 @@
    MA 02111-1307, USA.
 
    This file was inspired by the VNC Win32 code by ATT
-  
+
    Kern E. Sibbald, 2000
 */
 
index 589f94a54cc8726c7bb8cf2a2c7c1ebf624da6b0..2195b58fca16110d244f4e301bb19be46258c86c 100755 (executable)
@@ -17,7 +17,7 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 //  USA.
 //
-// If the source code for the ups system is not available from the place 
+// If the source code for the ups system is not available from the place
 // whence you received this file, check http://www.uk.research.att.com/vnc or contact
 // the authors on ups@uk.research.att.com for information on obtaining it.
 //
@@ -46,7 +46,7 @@ class bacService;
 class bacService
 {
 public:
-        bacService();
+       bacService();
 
    // SERVICE INSTALL & START FUNCTIONS
 
index e5c29a859ba31b96ae3efab82d70f1949576283e..3486a0079612f38e3573e3dae2bf278c85de295f 100755 (executable)
@@ -25,7 +25,7 @@
 
 class bacStatus;
 
-#ifndef _WINSTAT_H_ 
+#ifndef _WINSTAT_H_
 #define _WINSTAT_H_
 
 class bacStatus
index 54f418355b004fcd8e25fd6bccfb4ee738151e7b..2f40492df9e6e7fa4e4096adda02da146894262e 100755 (executable)
@@ -17,7 +17,7 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 //  USA.
 //
-// If the source code for the VNC system is not available from the place 
+// If the source code for the VNC system is not available from the place
 // whence you received this file, check http://www.uk.research.att.com/vnc or contact
 // the authors on vnc@uk.research.att.com for information on obtaining it.
 //
index ec9ecd6c9112974a0e2e1ed7dcf6c86635362542..ad867702f87a20dd9aad7039c553d096fad4ebf3 100755 (executable)
@@ -52,7 +52,7 @@ HANDLE bget_handle(BFILE *bfd);
 /*=============================================================*/
 
 /*
- * Return the data stream that will be used 
+ * Return the data stream that will be used
  */
 int select_data_stream(FF_PKT *ff_pkt)
 {
@@ -82,8 +82,8 @@ int select_data_stream(FF_PKT *ff_pkt)
 }
 
 
-/* 
- * Encode a stat structure into a base64 character string   
+/*
+ * Encode a stat structure into a base64 character string
  *   All systems must create such a structure.
  *   In addition, we tack on the LinkFI, which is non-zero in
  *   the case of a hard linked file that has no data.  This
@@ -160,7 +160,7 @@ template <class T> void plug(T &st, uint64_t val)
 
 
 /* Decode a stat packet from base64 characters */
-int decode_stat(char *buf, struct stat *statp, int32_t *LinkFI) 
+int decode_stat(char *buf, struct stat *statp, int32_t *LinkFI)
 {
    char *p = buf;
    int64_t val;
@@ -233,7 +233,7 @@ int decode_stat(char *buf, struct stat *statp, int32_t *LinkFI)
       statp->st_flags  = 0;
 #endif
    }
-    
+
    /* Look for data stream id */
    if (*p == ' ' || (*p != 0 && *(p+1) == ' ')) {
       p++;
@@ -289,7 +289,7 @@ int32_t decode_LinkFI(char *buf, struct stat *statp)
 /*
  * Set file modes, permissions and times
  *
- *  fname is the original filename  
+ *  fname is the original filename
  *  ofile is the output filename (may be in a different directory)
  *
  * Returns:  true  on success
@@ -297,7 +297,7 @@ int32_t decode_LinkFI(char *buf, struct stat *statp)
  */
 bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
 {
-   struct utimbuf ut;   
+   struct utimbuf ut;
    mode_t old_mask;
    bool ok = true;
    off_t fsize;
@@ -306,7 +306,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
    if (attr->stream == STREAM_UNIX_ATTRIBUTES_EX &&
        set_win32_attributes(jcr, attr, ofd)) {
        if (is_bopen(ofd)) {
-          bclose(ofd); 
+          bclose(ofd);
        }
        pm_strcpy(attr->ofname, "*none*");
        return true;
@@ -314,7 +314,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
    if (attr->data_stream == STREAM_WIN32_DATA ||
        attr->data_stream == STREAM_WIN32_GZIP_DATA) {
       if (is_bopen(ofd)) {
-        bclose(ofd); 
+        bclose(ofd);
       }
       pm_strcpy(attr->ofname, "*none*");
       return true;
@@ -323,7 +323,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
 
    /*
     * If Windows stuff failed, e.g. attempt to restore Unix file
-    *  to Windows, simply fall through and we will do it the    
+    *  to Windows, simply fall through and we will do it the
     *  universal way.
     */
 #endif
@@ -334,7 +334,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
       fsize = blseek(ofd, 0, SEEK_CUR);
       bclose(ofd);                   /* first close file */
       if (fsize > 0 && fsize != attr->statp.st_size) {
-         Jmsg3(jcr, M_ERROR, 0, _("File size of restored file %s not correct. Original %s, restored %s.\n"),
+        Jmsg3(jcr, M_ERROR, 0, _("File size of restored file %s not correct. Original %s, restored %s.\n"),
            attr->ofname, edit_uint64(attr->statp.st_size, ec1),
            edit_uint64(fsize, ec2));
       }
@@ -344,7 +344,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
    ut.modtime = attr->statp.st_mtime;
 
    /* ***FIXME**** optimize -- don't do if already correct */
-   /* 
+   /*
     * For link, change owner of link using lchown, but don't
     *  try to do a chmod as that will update the file behind it.
     */
@@ -352,20 +352,20 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
       /* Change owner of link, not of real file */
       if (lchown(attr->ofname, attr->statp.st_uid, attr->statp.st_gid) < 0) {
         berrno be;
-         Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"),
+        Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"),
            attr->ofname, be.strerror());
         ok = false;
       }
    } else {
       if (chown(attr->ofname, attr->statp.st_uid, attr->statp.st_gid) < 0) {
         berrno be;
-         Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"),
+        Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"),
            attr->ofname, be.strerror());
         ok = false;
       }
       if (chmod(attr->ofname, attr->statp.st_mode) < 0) {
         berrno be;
-         Jmsg2(jcr, M_ERROR, 0, _("Unable to set file modes %s: ERR=%s\n"),
+        Jmsg2(jcr, M_ERROR, 0, _("Unable to set file modes %s: ERR=%s\n"),
            attr->ofname, be.strerror());
         ok = false;
       }
@@ -375,7 +375,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
        */
       if (utime(attr->ofname, &ut) < 0) {
         berrno be;
-         Jmsg2(jcr, M_ERROR, 0, _("Unable to set file times %s: ERR=%s\n"),
+        Jmsg2(jcr, M_ERROR, 0, _("Unable to set file times %s: ERR=%s\n"),
            attr->ofname, be.strerror());
         ok = false;
       }
@@ -389,7 +389,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
        */
       if (chflags(attr->ofname, attr->statp.st_flags) < 0) {
         berrno be;
-         Jmsg2(jcr, M_ERROR, 0, _("Unable to set file flags %s: ERR=%s\n"),
+        Jmsg2(jcr, M_ERROR, 0, _("Unable to set file flags %s: ERR=%s\n"),
            attr->ofname, be.strerror());
         ok = false;
       }
@@ -408,7 +408,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
 /*=============================================================*/
 
 #if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
-    
+
 /*
  * It is possible to piggyback additional data e.g. ACLs on
  *   the encode_stat() data by returning the extended attributes
@@ -453,7 +453,7 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
 
    attribsEx[0] = 0;                 /* no extended attributes */
 
-   if (!p_GetFileAttributesEx) {                                
+   if (!p_GetFileAttributesEx) {
       return STREAM_UNIX_ATTRIBUTES;
    }
 
@@ -487,20 +487,20 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
 
 /* Define attributes that are legal to set with SetFileAttributes() */
 #define SET_ATTRS ( \
-         FILE_ATTRIBUTE_ARCHIVE| \
-         FILE_ATTRIBUTE_HIDDEN| \
-         FILE_ATTRIBUTE_NORMAL| \
-         FILE_ATTRIBUTE_NOT_CONTENT_INDEXED| \
-         FILE_ATTRIBUTE_OFFLINE| \
-         FILE_ATTRIBUTE_READONLY| \
-         FILE_ATTRIBUTE_SYSTEM| \
+        FILE_ATTRIBUTE_ARCHIVE| \
+        FILE_ATTRIBUTE_HIDDEN| \
+        FILE_ATTRIBUTE_NORMAL| \
+        FILE_ATTRIBUTE_NOT_CONTENT_INDEXED| \
+        FILE_ATTRIBUTE_OFFLINE| \
+        FILE_ATTRIBUTE_READONLY| \
+        FILE_ATTRIBUTE_SYSTEM| \
         FILE_ATTRIBUTE_TEMPORARY)
 
 
 /*
  * Set Extended File Attributes for Win32
  *
- *  fname is the original filename  
+ *  fname is the original filename
  *  ofile is the output filename (may be in a different directory)
  *
  * Returns:  true  on success
@@ -514,7 +514,7 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
    ULARGE_INTEGER li;
    POOLMEM *win32_ofile;
 
-   if (!p_GetFileAttributesEx) {                                
+   if (!p_GetFileAttributesEx) {
       return false;
    }
 
@@ -545,7 +545,7 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
    li.QuadPart = val;
    atts.ftLastWriteTime.dwLowDateTime = li.LowPart;
    atts.ftLastWriteTime.dwHighDateTime = li.HighPart;
-   p++;   
+   p++;
    p += from_base64(&val, p);
    plug(atts.nFileSizeHigh, val);
    p++;
@@ -571,7 +571,7 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
                         &atts.ftCreationTime,
                         &atts.ftLastAccessTime,
                         &atts.ftLastWriteTime)) {
-         win_error(jcr, "SetFileTime:", win32_ofile);
+        win_error(jcr, "SetFileTime:", win32_ofile);
       }
       bclose(ofd);
    }
@@ -579,7 +579,7 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
    Dmsg1(100, "SetFileAtts %s\n", attr->ofname);
    if (!(atts.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
       if (!SetFileAttributes(win32_ofile, atts.dwFileAttributes & SET_ATTRS)) {
-         win_error(jcr, "SetFileAttributes:", win32_ofile);
+        win_error(jcr, "SetFileAttributes:", win32_ofile);
       }
    }
    free_pool_memory(win32_ofile);
index dc72bbc7bc7464ec7022b35ea2c2781505b030d8..0a82b743988d32538ee8f662fc6fe09560d8e20c 100644 (file)
@@ -36,7 +36,7 @@
 #endif
 
 /* ===============================================================
- * 
+ *
  *           U N I X   AND   W I N D O W S
  *
  * ===============================================================
@@ -94,7 +94,7 @@ const char *stream_to_ascii(int stream)
 
 
 /* ===============================================================
- * 
+ *
  *           W I N D O W S
  *
  * ===============================================================
@@ -120,7 +120,7 @@ void binit(BFILE *bfd)
  *   Returns 1 if function worked
  *   Returns 0 if failed (i.e. do not have Backup API on this machine)
  */
-int set_win32_backup(BFILE *bfd) 
+int set_win32_backup(BFILE *bfd)
 {
    /* We enable if possible here */
    bfd->use_backup_api = have_win32_api();
@@ -141,10 +141,10 @@ void set_prog(BFILE *bfd, char *prog, JCR *jcr)
 }
 
 /*
- * Return 1 if we are NOT using Win32 BackupWrite() 
+ * Return 1 if we are NOT using Win32 BackupWrite()
  * return 0 if are
  */
-int is_portable_backup(BFILE *bfd) 
+int is_portable_backup(BFILE *bfd)
 {
    return !bfd->use_backup_api;
 }
@@ -212,7 +212,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
 
    if (flags & O_CREAT) {            /* Create */
       if (bfd->use_backup_api) {
-        dwaccess = GENERIC_WRITE|FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY;                
+        dwaccess = GENERIC_WRITE|FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY;
         dwflags = FILE_FLAG_BACKUP_SEMANTICS;
       } else {
         dwaccess = GENERIC_WRITE;
@@ -276,12 +276,12 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
    return bfd->mode == BF_CLOSED ? -1 : 1;
 }
 
-/* 
+/*
  * Returns  0 on success
  *        -1 on error
  */
 int bclose(BFILE *bfd)
-{ 
+{
    int stat = 0;
 
    if (bfd->errmsg) {
@@ -293,7 +293,7 @@ int bclose(BFILE *bfd)
    }
    if (bfd->use_backup_api && bfd->mode == BF_READ) {
       BYTE buf[10];
-      if (!bfd->lpContext && !p_BackupRead(bfd->fh,   
+      if (!bfd->lpContext && !p_BackupRead(bfd->fh,
              buf,                    /* buffer */
              (DWORD)0,               /* bytes to read */
              &bfd->rw_bytes,         /* bytes read */
@@ -302,10 +302,10 @@ int bclose(BFILE *bfd)
              &bfd->lpContext)) {     /* Read context */
         errno = b_errno_win32;
         stat = -1;
-      } 
+      }
    } else if (bfd->use_backup_api && bfd->mode == BF_WRITE) {
       BYTE buf[10];
-      if (!bfd->lpContext && !p_BackupWrite(bfd->fh,   
+      if (!bfd->lpContext && !p_BackupWrite(bfd->fh,
              buf,                    /* buffer */
              (DWORD)0,               /* bytes to read */
              &bfd->rw_bytes,         /* bytes written */
@@ -314,7 +314,7 @@ int bclose(BFILE *bfd)
              &bfd->lpContext)) {     /* Write context */
         errno = b_errno_win32;
         stat = -1;
-      } 
+      }
    }
    if (!CloseHandle(bfd->fh)) {
       stat = -1;
@@ -408,7 +408,7 @@ off_t blseek(BFILE *bfd, off_t offset, int whence)
 #else  /* Unix systems */
 
 /* ===============================================================
- * 
+ *
  *           U N I X
  *
  * ===============================================================
@@ -420,16 +420,16 @@ void binit(BFILE *bfd)
 }
 
 int have_win32_api()
-{ 
+{
    return 0;                         /* no can do */
-} 
+}
 
 /*
  * Enables using the Backup API (win32_data).
  *   Returns 1 if function worked
  *   Returns 0 if failed (i.e. do not have Backup API on this machine)
  */
-int set_win32_backup(BFILE *bfd) 
+int set_win32_backup(BFILE *bfd)
 {
    return 0;                         /* no can do */
 }
@@ -444,7 +444,7 @@ int set_portable_backup(BFILE *bfd)
  * Return 1 if we are writing in portable format
  * return 0 if not
  */
-int is_portable_backup(BFILE *bfd) 
+int is_portable_backup(BFILE *bfd)
 {
    return 1;                         /* portable by definition */
 }
@@ -500,9 +500,9 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
       ecmd = edit_job_codes(bfd->jcr, ecmd, bfd->prog, fname);
       const char *pmode;
       if (flags & O_RDONLY) {
-         pmode = "r";
+        pmode = "r";
       } else {
-         pmode = "w";
+        pmode = "w";
       }
       bfd->bpipe = open_bpipe(ecmd, 0, pmode);
       if (bfd->bpipe == NULL) {
@@ -548,8 +548,8 @@ int bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode)
 #endif
 
 int bclose(BFILE *bfd)
-{ 
-   int stat;  
+{
+   int stat;
    Dmsg1(400, "Close file %d\n", bfd->fid);
    if (bfd->fid == -1) {
       return 0;
@@ -562,7 +562,7 @@ int bclose(BFILE *bfd)
       bfd->bpipe = NULL;
       return stat;
    }
-   
+
    /* Close normal file */
    stat = close(bfd->fid);
    bfd->berrno = errno;
index 21a25c0cabfd600416c7eb329617a3084fa25288..4d4c25b55525562b9819eb228a42f5f26d1ab7f6 100644 (file)
@@ -30,7 +30,7 @@
 
 /*  =======================================================
  *
- *   W I N D O W S 
+ *   W I N D O W S
  *
  *  =======================================================
  */
@@ -61,7 +61,7 @@ struct BFILE {
    char *prog;                        /* reader/writer program if any */
    BPIPE *bpipe;                      /* pipe for reader */
    JCR *jcr;                          /* jcr for editing job codes */
-};      
+};
 
 HANDLE bget_handle(BFILE *bfd);
 
@@ -69,7 +69,7 @@ HANDLE bget_handle(BFILE *bfd);
 
 /*  =======================================================
  *
- *   U N I X 
+ *   U N I X
  *
  *  =======================================================
  */
@@ -81,7 +81,7 @@ struct BFILE {
    char *prog;                        /* reader/writer program if any */
    BPIPE *bpipe;                      /* pipe for reader */
    JCR *jcr;                          /* jcr for editing job codes */
-};      
+};
 
 #endif
 
index 0a64a564dc18525a0419df3de263dd1fca892b4d..ad18fea9a4852b36e4c0d69e9ca6ceb6fb8fbab4 100644 (file)
@@ -45,19 +45,19 @@ static int path_already_seen(JCR *jcr, char *path, int pnl);
 /*
  * Create the file, or the directory
  *
- *  fname is the original filename  
+ *  fname is the original filename
  *  ofile is the output filename (may be in a different directory)
  *
  * Returns:  CF_SKIP    if file should be skipped
  *          CF_ERROR    on error
- *          CF_EXTRACT  file created and data to restore  
+ *          CF_EXTRACT  file created and data to restore
  *          CF_CREATED  file created no data to restore
  *
  *   Note, we create the file here, except for special files,
- *     we do not set the attributes because we want to first 
+ *     we do not set the attributes because we want to first
  *     write the file, then when the writing is done, set the
  *     attributes.
- *   So, we return with the file descriptor open for normal 
+ *   So, we return with the file descriptor open for normal
  *     files.
  *
  */
@@ -70,7 +70,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
    bool exists = false;
    struct stat mstatp;
 
-   if (is_win32_stream(attr->data_stream)) { 
+   if (is_win32_stream(attr->data_stream)) {
       set_win32_backup(bfd);
    } else {
       set_portable_backup(bfd);
@@ -88,20 +88,20 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
       switch (replace) {
       case REPLACE_IFNEWER:
         if (attr->statp.st_mtime <= mstatp.st_mtime) {
-            Jmsg(jcr, M_SKIPPED, 0, _("File skipped. Not newer: %s\n"), attr->ofname);
+           Jmsg(jcr, M_SKIPPED, 0, _("File skipped. Not newer: %s\n"), attr->ofname);
            return CF_SKIP;
         }
         break;
 
       case REPLACE_IFOLDER:
         if (attr->statp.st_mtime >= mstatp.st_mtime) {
-            Jmsg(jcr, M_SKIPPED, 0, _("File skipped. Not older: %s\n"), attr->ofname);
+           Jmsg(jcr, M_SKIPPED, 0, _("File skipped. Not older: %s\n"), attr->ofname);
            return CF_SKIP;
         }
         break;
 
       case REPLACE_NEVER:
-         Jmsg(jcr, M_SKIPPED, 0, _("File skipped. Already exists: %s\n"), attr->ofname);
+        Jmsg(jcr, M_SKIPPED, 0, _("File skipped. Already exists: %s\n"), attr->ofname);
         return CF_SKIP;
 
       case REPLACE_ALWAYS:
@@ -120,12 +120,12 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
         /* Get rid of old copy */
         if (unlink(attr->ofname) == -1) {
            berrno be;
-            Jmsg(jcr, M_ERROR, 0, _("File %s already exists and could not be replaced. ERR=%s.\n"),
+           Jmsg(jcr, M_ERROR, 0, _("File %s already exists and could not be replaced. ERR=%s.\n"),
               attr->ofname, be.strerror());
            /* Continue despite error */
         }
       }
-      /* 
+      /*
        * Here we do some preliminary work for all the above
        *   types to create the path to the file if it does
        *   not already exist.  Below, we will split to
@@ -146,14 +146,14 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
         attr->ofname[pnl] = 0;                 /* terminate path */
 
         if (!path_already_seen(jcr, attr->ofname, pnl)) {
-            Dmsg1(50, "Make path %s\n", attr->ofname);
+           Dmsg1(50, "Make path %s\n", attr->ofname);
            /*
             * If we need to make the directory, ensure that it is with
             * execute bit set (i.e. parent_mode), and preserve what already
             * exists. Normally, this should do nothing.
             */
            if (make_path(jcr, attr->ofname, parent_mode, parent_mode, uid, gid, 1, NULL) != 0) {
-               Dmsg1(10, "Could not make path. %s\n", attr->ofname);
+              Dmsg1(10, "Could not make path. %s\n", attr->ofname);
               attr->ofname[pnl] = savechr;     /* restore full name */
               return CF_ERROR;
            }
@@ -165,20 +165,20 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
       switch(attr->type) {
       case FT_REGE:
       case FT_REG:
-         Dmsg1(100, "Create file %s\n", attr->ofname);
+        Dmsg1(100, "Create file %s\n", attr->ofname);
         mode =  O_WRONLY | O_CREAT | O_TRUNC | O_BINARY; /*  O_NOFOLLOW; */
         if (IS_CTG(attr->statp.st_mode)) {
            mode |= O_CTG;               /* set contiguous bit if needed */
         }
-         Dmsg1(50, "Create file: %s\n", attr->ofname);
+        Dmsg1(50, "Create file: %s\n", attr->ofname);
         if (is_bopen(bfd)) {
-            Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
+           Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
            bclose(bfd);
         }
         if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) {
            berrno be;
            be.set_errno(bfd->berrno);
-            Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"), 
+           Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"),
                  attr->ofname, be.strerror());
            return CF_ERROR;
         }
@@ -186,27 +186,27 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
 #ifndef HAVE_WIN32  // none of these exists on MS Windows
       case FT_RAW:                   /* Bacula raw device e.g. /dev/sda1 */
       case FT_FIFO:                  /* Bacula fifo to save data */
-      case FT_SPEC:                     
+      case FT_SPEC:
         if (S_ISFIFO(attr->statp.st_mode)) {
-            Dmsg1(200, "Restore fifo: %s\n", attr->ofname);
+           Dmsg1(200, "Restore fifo: %s\n", attr->ofname);
            if (mkfifo(attr->ofname, attr->statp.st_mode) != 0 && errno != EEXIST) {
               berrno be;
-               Jmsg2(jcr, M_ERROR, 0, _("Cannot make fifo %s: ERR=%s\n"), 
+              Jmsg2(jcr, M_ERROR, 0, _("Cannot make fifo %s: ERR=%s\n"),
                     attr->ofname, be.strerror());
               return CF_ERROR;
            }
-        } else {          
-            Dmsg1(200, "Restore node: %s\n", attr->ofname);
+        } else {
+           Dmsg1(200, "Restore node: %s\n", attr->ofname);
            if (mknod(attr->ofname, attr->statp.st_mode, attr->statp.st_rdev) != 0 && errno != EEXIST) {
               berrno be;
-               Jmsg2(jcr, M_ERROR, 0, _("Cannot make node %s: ERR=%s\n"), 
+              Jmsg2(jcr, M_ERROR, 0, _("Cannot make node %s: ERR=%s\n"),
                     attr->ofname, be.strerror());
               return CF_ERROR;
            }
-        }       
+        }
         if (attr->type == FT_RAW || attr->type == FT_FIFO) {
            btimer_t *tid;
-            Dmsg1(200, "FT_RAW|FT_FIFO %s\n", attr->ofname);
+           Dmsg1(200, "FT_RAW|FT_FIFO %s\n", attr->ofname);
            mode =  O_WRONLY | O_BINARY;
            /* Timeout open() in 60 seconds */
            if (attr->type == FT_FIFO) {
@@ -215,12 +215,12 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
               tid = NULL;
            }
            if (is_bopen(bfd)) {
-               Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
+              Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
            }
            if ((bopen(bfd, attr->ofname, mode, 0)) < 0) {
               berrno be;
               be.set_errno(bfd->berrno);
-               Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"), 
+              Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"),
                     attr->ofname, be.strerror());
               stop_thread_timer(tid);
               return CF_ERROR;
@@ -228,24 +228,24 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
            stop_thread_timer(tid);
            return CF_EXTRACT;
         }
-         Dmsg1(200, "FT_SPEC %s\n", attr->ofname);
+        Dmsg1(200, "FT_SPEC %s\n", attr->ofname);
         return CF_CREATED;
 
       case FT_LNK:
-         Dmsg2(130, "FT_LNK should restore: %s -> %s\n", attr->ofname, attr->olname);
+        Dmsg2(130, "FT_LNK should restore: %s -> %s\n", attr->ofname, attr->olname);
         if (symlink(attr->olname, attr->ofname) != 0 && errno != EEXIST) {
            berrno be;
-            Jmsg3(jcr, M_ERROR, 0, _("Could not symlink %s -> %s: ERR=%s\n"),
+           Jmsg3(jcr, M_ERROR, 0, _("Could not symlink %s -> %s: ERR=%s\n"),
                  attr->ofname, attr->olname, be.strerror());
            return CF_ERROR;
         }
         return CF_CREATED;
 
       case FT_LNKSAVED:                 /* Hard linked, file already saved */
-         Dmsg2(130, "Hard link %s => %s\n", attr->ofname, attr->olname);
+        Dmsg2(130, "Hard link %s => %s\n", attr->ofname, attr->olname);
         if (link(attr->olname, attr->ofname) != 0) {
            berrno be;
-            Jmsg3(jcr, M_ERROR, 0, _("Could not hard link %s -> %s: ERR=%s\n"),
+           Jmsg3(jcr, M_ERROR, 0, _("Could not hard link %s -> %s: ERR=%s\n"),
                  attr->ofname, attr->olname, be.strerror());
            return CF_ERROR;
         }
@@ -266,12 +266,12 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
        */
       if (!is_portable_backup(bfd)) {
         if (is_bopen(bfd)) {
-            Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
+           Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
         }
         if ((bopen(bfd, attr->ofname, O_WRONLY|O_BINARY, 0)) < 0) {
            berrno be;
            be.set_errno(bfd->berrno);
-            Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"), 
+           Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"),
                  attr->ofname, be.strerror());
            return CF_ERROR;
         }
@@ -303,7 +303,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
  *  Returns: > 0 index into path where last path char is.
  *          0  no path
  *          -1 filename is zero length
- */ 
+ */
 static int separate_path_and_file(JCR *jcr, char *fname, char *ofile)
 {
    char *f, *p;
@@ -327,12 +327,12 @@ static int separate_path_and_file(JCR *jcr, char *fname, char *ofile)
       Jmsg1(jcr, M_ERROR, 0, _("Zero length filename: %s\n"), fname);
       return -1;
    }
-   pnl = f - ofile - 1;    
+   pnl = f - ofile - 1;
    return pnl;
 }
 
-/* 
- * Primitive caching of path to prevent recreating a pathname 
+/*
+ * Primitive caching of path to prevent recreating a pathname
  *   each time as long as we remain in the same directory.
  */
 static int path_already_seen(JCR *jcr, char *path, int pnl)
index 9c23183774bf316ca13ef7a665a2582ff2bb82a8..a5a1e388ff2b858a780cf5ec440654b607254b07 100755 (executable)
@@ -38,7 +38,7 @@
 /*=============================================================*/
 
 #if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
-    
+
 int enable_backup_privileges(JCR *jcr, int ignore_errors)
  { return 0; }
 
@@ -67,10 +67,10 @@ enable_priv(JCR *jcr, HANDLE hToken, char *name, int ignore_errors)
        return 0;                     /* not avail on this OS */
     }
 
-    // Get the LUID for the security privilege. 
+    // Get the LUID for the security privilege.
     if (!p_LookupPrivilegeValue(NULL, name,  &tkp.Privileges[0].Luid)) {
-       if (!ignore_errors) {  
-          win_error(jcr, "LookupPrivilegeValue", GetLastError());
+       if (!ignore_errors) {
+         win_error(jcr, "LookupPrivilegeValue", GetLastError());
        }
     }
 
@@ -82,12 +82,12 @@ enable_priv(JCR *jcr, HANDLE hToken, char *name, int ignore_errors)
     if (lerror != ERROR_SUCCESS) {
        if (!ignore_errors) {
          char buf[200];
-          strcpy(buf, "AdjustTokenPrivileges set ");
+         strcpy(buf, "AdjustTokenPrivileges set ");
          bstrncat(buf, name, sizeof(buf));
          win_error(jcr, buf, lerror);
        }
        return 0;
-    } 
+    }
     return 1;
 }
 
@@ -107,14 +107,14 @@ int enable_backup_privileges(JCR *jcr, int ignore_errors)
 
     hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
 
-    // Get a token for this process. 
+    // Get a token for this process.
     if (!p_OpenProcessToken(hProcess,
            TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
-       if (!ignore_errors) {  
-          win_error(jcr, "OpenProcessToken", GetLastError());
+       if (!ignore_errors) {
+         win_error(jcr, "OpenProcessToken", GetLastError());
        }
        /* Forge on anyway */
-    } 
+    }
 
     /* Return a bit map of permissions set. */
     if (enable_priv(jcr, hToken, SE_SECURITY_NAME, ignore_errors)) {
index 2b587e25e4198f91ce54895bb645f594ea49f031..826251a8f1fdc2bf0e99a14cb4844849b07ddfe8 100644 (file)
@@ -51,12 +51,12 @@ static const int fnmode = 0;
 #endif
 
 
-/* 
+/*
  * Initialize the find files "global" variables
  */
 FF_PKT *init_find_files()
 {
-  FF_PKT *ff;   
+  FF_PKT *ff;
 
   ff = (FF_PKT *)bmalloc(sizeof(FF_PKT));
   memset(ff, 0, sizeof(FF_PKT));
@@ -82,7 +82,7 @@ FF_PKT *init_find_files()
   return ff;
 }
 
-/* 
+/*
  * Set find_files options. For the moment, we only
  * provide for full/incremental saves, and setting
  * of save_time. For additional options, see above
@@ -97,12 +97,12 @@ set_find_options(FF_PKT *ff, int incremental, time_t save_time)
 }
 
 
-/* 
+/*
  * Find all specified files (determined by calls to name_add()
  * This routine calls the (handle_file) subroutine with all
  * sorts of good information for the final disposition of
  * the file.
- * 
+ *
  * Call this subroutine with a callback subroutine as the first
  * argument and a packet as the second argument, this packet
  * will be passed back to the callback subroutine as the last
@@ -114,7 +114,7 @@ set_find_options(FF_PKT *ff, int incremental, time_t save_time)
  *
  */
 int
-find_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt), void *his_pkt) 
+find_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt), void *his_pkt)
 {
    ff->callback = callback;
 
@@ -137,10 +137,10 @@ find_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt), void
            ff->flags |= fo->flags;
            ff->GZIP_level = fo->GZIP_level;
            ff->fstypes = fo->fstype;
-           bstrncat(ff->VerifyOpts, fo->VerifyOpts, sizeof(ff->VerifyOpts)); 
+           bstrncat(ff->VerifyOpts, fo->VerifyOpts, sizeof(ff->VerifyOpts));
         }
         for (j=0; j<incexe->name_list.size(); j++) {
-            Dmsg1(100, "F %s\n", (char *)incexe->name_list.get(j));
+           Dmsg1(100, "F %s\n", (char *)incexe->name_list.get(j));
            char *fname = (char *)incexe->name_list.get(j);
            if (find_one_file(jcr, ff, our_callback, his_pkt, fname, (dev_t)-1, 1) == 0) {
               return 0;                  /* error return */
@@ -153,8 +153,8 @@ find_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt), void
       /* This is the old deprecated way */
       while (!job_canceled(jcr) && (inc = get_next_included_file(ff, inc))) {
         /* Copy options for this file */
-        bstrncat(ff->VerifyOpts, inc->VerifyOpts, sizeof(ff->VerifyOpts)); 
-         Dmsg1(100, "find_files: file=%s\n", inc->fname);
+        bstrncat(ff->VerifyOpts, inc->VerifyOpts, sizeof(ff->VerifyOpts));
+        Dmsg1(100, "find_files: file=%s\n", inc->fname);
         if (!file_is_excluded(ff, inc->fname)) {
            if (find_one_file(jcr, ff, callback, his_pkt, inc->fname, (dev_t)-1, 1) ==0) {
               return 0;                  /* error return */
@@ -183,7 +183,7 @@ static bool accept_file(FF_PKT *ff)
       for (k=0; k<fo->wild.size(); k++) {
         if (fnmatch((char *)fo->wild.get(k), ff->fname, fnmode|ic) == 0) {
            if (ff->flags & FO_EXCLUDE) {
-               Dmsg2(100, "Exclude wild: %s file=%s\n", (char *)fo->wild.get(k),
+              Dmsg2(100, "Exclude wild: %s file=%s\n", (char *)fo->wild.get(k),
                  ff->fname);
               return false;          /* reject file */
            }
@@ -211,7 +211,7 @@ static bool accept_file(FF_PKT *ff)
         ic = (fo->flags & FO_IGNORECASE) ? FNM_CASEFOLD : 0;
         for (k=0; k<fo->wild.size(); k++) {
            if (fnmatch((char *)fo->wild.get(k), ff->fname, fnmode|ic) == 0) {
-               Dmsg1(100, "Reject wild1: %s\n", ff->fname);
+              Dmsg1(100, "Reject wild1: %s\n", ff->fname);
               return false;          /* reject file */
            }
         }
@@ -220,7 +220,7 @@ static bool accept_file(FF_PKT *ff)
             ? FNM_CASEFOLD : 0;
       for (j=0; j<incexe->name_list.size(); j++) {
         if (fnmatch((char *)incexe->name_list.get(j), ff->fname, fnmode|ic) == 0) {
-            Dmsg1(100, "Reject wild2: %s\n", ff->fname);
+           Dmsg1(100, "Reject wild2: %s\n", ff->fname);
            return false;          /* reject file */
         }
       }
@@ -231,7 +231,7 @@ static bool accept_file(FF_PKT *ff)
 /*
  * The code comes here for each file examined.
  * We filter the files, then call the user's callback if
- *    the file is included. 
+ *    the file is included.
  */
 static int our_callback(FF_PKT *ff, void *hpkt)
 {
@@ -261,7 +261,7 @@ static int our_callback(FF_PKT *ff, void *hpkt)
       if (accept_file(ff)) {
         return ff->callback(ff, hpkt);
       } else {
-         Dmsg1(100, "Skip file %s\n", ff->fname);
+        Dmsg1(100, "Skip file %s\n", ff->fname);
         return -1;                   /* ignore this file */
       }
 
@@ -274,7 +274,7 @@ static int our_callback(FF_PKT *ff, void *hpkt)
 
 /*
  * Terminate find_files() and release
- * all allocated memory   
+ * all allocated memory
  */
 int
 term_find_files(FF_PKT *ff)
index 11038e5df0afe9b77b5436399f825d692b83ff2e..5caed56e27f79557f515f3335b5159e281db3ae0 100755 (executable)
@@ -4,7 +4,7 @@
  *     Kern Sibbald MIM
  */
 /*
-   Copyright (C) 2000-2004 Kern Sibbald 
+   Copyright (C) 2000-2004 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
@@ -59,7 +59,7 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
 #endif
 
 
-/* 
+/*
  * Status codes returned by create_file()
  */
 enum {
@@ -71,7 +71,7 @@ enum {
 
 
 /* Options saved int "options" of the include/exclude lists.
- * They are directly jammed ito  "flag" of ff packet 
+ * They are directly jammed ito  "flag" of ff packet
  */
 #define FO_MD5          (1<<1)        /* Do MD5 checksum */
 #define FO_GZIP         (1<<2)        /* Do Zlib compression */
@@ -112,7 +112,7 @@ struct s_excluded_file {
  *  of the structure are passed by the Director to the
  *  File daemon and recompiled back into this structure
  */
-#undef  MAX_FOPTS 
+#undef  MAX_FOPTS
 #define MAX_FOPTS 30
 
 enum {
@@ -143,7 +143,7 @@ struct findINCEXE {
    alist name_list;                   /* filename list -- holds char * */
 };
 
-/* 
+/*
  *   FileSet Resource
  *
  */
@@ -188,7 +188,7 @@ struct FF_PKT {
    findFILESET *fileset;
    int (*callback)(FF_PKT *, void *); /* User's callback */
 
-   /* Values set by accept_file while processing Options */  
+   /* Values set by accept_file while processing Options */
    uint32_t flags;                    /* backup options */
    int GZIP_level;                    /* compression level */
    char *reader;                      /* reader program */
index 2cce54fa10a548523444ae3a9a28b357cd86446f..d32940dd4153beeedd60429fe5d441e592d484e7 100755 (executable)
@@ -1,4 +1,4 @@
-/* 
+/*
    Copyright (C) 2000-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
@@ -37,7 +37,7 @@ extern int32_t name_max;            /* filename max length */
 extern int32_t path_max;             /* path name max length */
 
 /*
- * Structure for keeping track of hard linked files, we   
+ * Structure for keeping track of hard linked files, we
  *   keep an entry for each hardlinked file that we save,
  *   which is the first one found. For all the other files that
  *   are linked to this one, we save only the directory
@@ -73,15 +73,15 @@ static int accept_fstype(FF_PKT *ff, void *dummy) {
       accept = false;
       fs = fstype(ff->fname);
       if (fs == NULL) {
-         Dmsg1(50, "Cannot determine file system type for \"%s\"\n", ff->fname);
+        Dmsg1(50, "Cannot determine file system type for \"%s\"\n", ff->fname);
       } else {
         for (i = 0; i < ff->fstypes.size(); ++i) {
            if (strcmp(fs, (char *)ff->fstypes.get(i)) == 0) {
-               Dmsg2(100, "Accepting fstype %s for \"%s\"\n", fs, ff->fname);
+              Dmsg2(100, "Accepting fstype %s for \"%s\"\n", fs, ff->fname);
               accept = true;
               break;
            }
-            Dmsg3(200, "fstype %s for \"%s\" does not match %s\n", fs,
+           Dmsg3(200, "fstype %s for \"%s\" does not match %s\n", fs,
                  ff->fname, ff->fstypes.get(i));
         }
         free(fs);
@@ -91,15 +91,15 @@ static int accept_fstype(FF_PKT *ff, void *dummy) {
 }
 
 /*
- * Find a single file.                       
+ * Find a single file.
  * handle_file is the callback for handling the file.
  * p is the filename
- * parent_device is the device we are currently on 
- * top_level is 1 when not recursing or 0 when 
+ * parent_device is the device we are currently on
+ * top_level is 1 when not recursing or 0 when
  *  descending into a directory.
  */
 int
-find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt), 
+find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
               void *pkt, char *fname, dev_t parent_device, int top_level)
 {
    struct utimbuf restore_times;
@@ -134,7 +134,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
       return 1;      /* Just ignore this error - or the whole backup is cancelled */
    }
 
-   /* 
+   /*
     * If this is an Incremental backup, see if file was modified
     * since our last "save_time", presumably the last Full save
     * or Incremental.
@@ -143,7 +143,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
       Dmsg1(300, "Non-directory incremental: %s\n", ff_pkt->fname);
       /* Not a directory */
       if (ff_pkt->statp.st_mtime < ff_pkt->save_time
-         && ((ff_pkt->flags & FO_MTIMEONLY) || 
+         && ((ff_pkt->flags & FO_MTIMEONLY) ||
              ff_pkt->statp.st_ctime < ff_pkt->save_time)) {
         /* Incremental option, file not changed */
         ff_pkt->type = FT_NOCHG;
@@ -177,11 +177,11 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
    }
 #endif
    ff_pkt->LinkFI = 0;
-   /* 
+   /*
     * Handle hard linked files
     *
     * Maintain a list of hard linked files already backed up. This
-    *  allows us to ensure that the data of each file gets backed 
+    *  allows us to ensure that the data of each file gets backed
     *  up only once.
     */
    if (!(ff_pkt->flags & FO_NO_HARDLINK)
@@ -196,11 +196,11 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
 
       /* Search link list of hard linked files */
       for (lp = ff_pkt->linklist; lp; lp = lp->next)
-        if (lp->ino == (ino_t)ff_pkt->statp.st_ino && 
+        if (lp->ino == (ino_t)ff_pkt->statp.st_ino &&
             lp->dev == (dev_t)ff_pkt->statp.st_dev) {
-             /* If we have already backed up the hard linked file don't do it again */
+            /* If we have already backed up the hard linked file don't do it again */
             if (strcmp(lp->name, fname) == 0) {
-                Jmsg1(jcr, M_WARNING, 0, _("Attempt to backup hard linked file %s twice ignored.\n"),
+               Jmsg1(jcr, M_WARNING, 0, _("Attempt to backup hard linked file %s twice ignored.\n"),
                   fname);
                return 1;             /* ignore */
             }
@@ -249,7 +249,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
 
       size = readlink(fname, buffer, path_max + name_max + 101);
       if (size < 0) {
-        /* Could not follow link */                             
+        /* Could not follow link */
         ff_pkt->type = FT_NOFOLLOW;
         ff_pkt->ff_errno = errno;
         rtn_stat = handle_file(ff_pkt, pkt);
@@ -272,12 +272,12 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
       struct dirent *entry, *result;
       char *link;
       int link_len;
-      int len;  
+      int len;
       int status;
       dev_t our_device = ff_pkt->statp.st_dev;
       bool recurse = true;
 
-      /*  
+      /*
        * If we are using Win32 (non-portable) backup API, don't check
        *  access as everything is more complicated, and
        *  in principle, we should be able to access everything.
@@ -315,9 +315,9 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
       } else {
         ff_pkt->type = FT_DIRBEGIN;
       }
-      /* 
+      /*
        * Note, we return the directory to the calling program (handle_file)
-       * when we first see the directory (FT_DIRBEGIN. 
+       * when we first see the directory (FT_DIRBEGIN.
        * This allows the program to apply matches and make a
        * choice whether or not to accept it.  If it is accepted, we
        * do not immediately save it, but do so only after everything
@@ -352,7 +352,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
       dir_ff_pkt->excluded_paths_list = NULL;
       dir_ff_pkt->linklist = NULL;
 
-      /* 
+      /*
        * Do not descend into subdirectories (recurse) if the
        * user has turned it off for this directory.
        *
@@ -379,7 +379,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
         }
         free(link);
         free_dir_ff_pkt(dir_ff_pkt);
-         ff_pkt->link = ff_pkt->fname;     /* reset "link" */
+        ff_pkt->link = ff_pkt->fname;     /* reset "link" */
         if (ff_pkt->flags & FO_KEEPATIME) {
            utime(fname, &restore_times);
         }
@@ -388,7 +388,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
 
       ff_pkt->link = ff_pkt->fname;     /* reset "link" */
 
-      /* 
+      /*
        * Descend into or "recurse" into the directory to read
        *   all the files in it.
        */
@@ -424,9 +424,9 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
         }
         ASSERT(name_max+1 > (int)sizeof(struct dirent) + (int)NAMELEN(entry));
         p = entry->d_name;
-         /* Skip `.', `..', and excluded file names.  */
-         if (p[0] == '\0' || (p[0] == '.' && (p[1] == '\0' ||
-             (p[1] == '.' && p[2] == '\0')))) {
+        /* Skip `.', `..', and excluded file names.  */
+        if (p[0] == '\0' || (p[0] == '.' && (p[1] == '\0' ||
+            (p[1] == '.' && p[2] == '\0')))) {
            continue;
         }
 
@@ -505,7 +505,7 @@ int term_find_one(FF_PKT *ff)
 {
    struct f_link *lp, *lc;
    int count = 0;
-  
+
    /* Free up list of hard linked files */
    for (lp = ff->linklist; lp;) {
       lc = lp;
index 1de11ef27c371905c2eb4b2c469a45df3c51439b..c6e4620a87685a9094c5d3a4061d3a7c43cf4dcd 100644 (file)
@@ -2,7 +2,7 @@
  *  Implement routines to determine file system types.
  *
  *   Written by Preben 'Peppe' Guldberg, December MMIV
- * 
+ *
  *   Version $Id$
  */
 
 #include <stdlib.h>
 #include <string.h>
 #define SUPPORTEDOSES      "HAVE_DARWIN_OS\n" \
-                           "HAVE_FREEBSD_OS\n" \
-                           "HAVE_HPUX_OS\n" \
-                           "HAVE_IRIX_OS\n" \
-                           "HAVE_LINUX_OS\n" \
-                           "HAVE_NETBSD_OS\n" \
-                           "HAVE_OPENBSD_OS\n" \
-                           "HAVE_SUN_OS\n"
+                          "HAVE_FREEBSD_OS\n" \
+                          "HAVE_HPUX_OS\n" \
+                          "HAVE_IRIX_OS\n" \
+                          "HAVE_LINUX_OS\n" \
+                          "HAVE_NETBSD_OS\n" \
+                          "HAVE_OPENBSD_OS\n" \
+                          "HAVE_SUN_OS\n"
 #define POOLMEM           char
 #define bstrdup           strdup
 #define Dmsg0(n,s)         fprintf(stderr, s "\n");
@@ -90,7 +90,7 @@ POOLMEM *fstype(const char *fname)
    struct statfs st;
    if (statfs(fname, &st) == 0) {
       /*
-       * Values nicked from statfs(2), testing and 
+       * Values nicked from statfs(2), testing and
        *
        *    $ grep -r SUPER_MAGIC /usr/include/linux
        *
@@ -172,7 +172,7 @@ POOLMEM *fstype(const char *fname)
 #endif
 
       default:
-         Dmsg2(10, "Unknown file system type \"0x%x\" for \"%s\".", st.f_type,
+        Dmsg2(10, "Unknown file system type \"0x%x\" for \"%s\".", st.f_type,
               fname);
         return NULL;
       }
@@ -216,7 +216,7 @@ int main(int argc, char **argv)
    if (argc < 2) {
       p = (argc < 1) ? "fstype" : argv[0];
       printf("usage:\t%s path ...\n"
-            "\t%s prints the file system type and pathname of the paths.\n",
+           "\t%s prints the file system type and pathname of the paths.\n",
            p, p);
       return EXIT_FAILURE;
    }
@@ -224,7 +224,7 @@ int main(int argc, char **argv)
       if ((p = fstype(*argv)) == NULL) {
         status = EXIT_FAILURE;
       } else {
-         printf("%s\t%s\n", p, *argv);
+        printf("%s\t%s\n", p, *argv);
       }
    }
    return status;
index c1d07223ff6a1bc75e72792b66da9977600dba44..452c45bcfd7d3b7f68e1bec0b140b8d935a2554d 100644 (file)
@@ -18,7 +18,7 @@
 
 /* Written by David MacKenzie <djm@gnu.ai.mit.edu> and Jim Meyering.  */
 
-/* 
+/*
  *   Modified by Kern Sibbald for use in Bacula, December 2000
  *
  *   Version $Id$
@@ -106,19 +106,19 @@ make_dir(JCR *jcr, const char *dir, const char *dirpath, mode_t mode, int *creat
       /* The mkdir and stat calls below may appear to be reversed.
         They are not.  It is important to call mkdir first and then to
         call stat (to distinguish the three cases) only if mkdir fails.
-         The alternative to this approach is to `stat' each directory,
-         then to call mkdir if it doesn't exist.  But if some other process
+        The alternative to this approach is to `stat' each directory,
+        then to call mkdir if it doesn't exist.  But if some other process
         were to create the directory between the stat & mkdir, the mkdir
         would fail with EEXIST.  */
 
       if (stat(dir, &stats)) {
          berrno be;
          be.set_errno(save_errno);
-          Jmsg(jcr, M_ERROR, 0, _("Cannot create directory %s: ERR=%s\n"), 
+         Jmsg(jcr, M_ERROR, 0, _("Cannot create directory %s: ERR=%s\n"),
                  dirpath, be.strerror());
          fail = 1;
       } else if (!S_ISDIR(stats.st_mode)) {
-          Jmsg(jcr, M_ERROR, 0, _("%s exists but is not a directory\n"), quote(dirpath));
+         Jmsg(jcr, M_ERROR, 0, _("%s exists but is not a directory\n"), quote(dirpath));
          fail = 1;
       } else {
          /* DIR (aka DIRPATH) already exists and is a directory. */
@@ -140,15 +140,15 @@ isAbsolute(const char *path)
     return path[1] == ':' || *path == '/' || *path == '\\';     /* drivespec:/blah is absolute */
 #else
     return *path == '/';
-#endif   
+#endif
 }
-    
+
 /* Ensure that the directory ARGPATH exists.
    Remove any trailing slashes from ARGPATH before calling this function.
 
    Create any leading directories that don't already exist, with
    permissions PARENT_MODE.
-    
+
    If the last element of ARGPATH does not exist, create it as
    a new directory with permissions MODE.
 
@@ -224,8 +224,8 @@ make_path(
       cwd.do_chdir = !save_cwd(&cwd);
 
       /* If we've saved the cwd and DIRPATH is an absolute pathname,
-         we must chdir to `/' in order to enable the chdir optimization.
-         So if chdir ("/") fails, turn off the optimization.  */
+        we must chdir to `/' in order to enable the chdir optimization.
+        So if chdir ("/") fails, turn off the optimization.  */
       if (cwd.do_chdir && isAbsolute(dirpath) && (chdir("/") < 0)) {
         cwd.do_chdir = 0;
       }
@@ -243,18 +243,18 @@ make_path(
          /* slash points to the leftmost unprocessed component of dirpath.  */
          basename_dir = slash;
 
-          slash = strchr (slash, '/');
+         slash = strchr (slash, '/');
          if (slash == NULL) {
             break;
          }
 
-          /* If we're *not* doing chdir before each mkdir, then we have to refer
+         /* If we're *not* doing chdir before each mkdir, then we have to refer
             to the target using the full (multi-component) directory name.  */
          if (!cwd.do_chdir) {
             basename_dir = dirpath;
          }
 
-          *slash = '\0';
+         *slash = '\0';
          fail = make_dir(jcr, basename_dir, dirpath, tmp_mode, &newly_created_dir);
          if (fail) {
              umask(oldmask);
@@ -263,7 +263,7 @@ make_path(
          }
 
          if (newly_created_dir) {
-              Dmsg0(300, "newly_created_dir\n");
+             Dmsg0(300, "newly_created_dir\n");
 
              if ((owner != (uid_t)-1 || group != (gid_t)-1)
                  && chown(basename_dir, owner, group)
@@ -273,10 +273,10 @@ make_path(
                  ) {
                 /* Note, if we are restoring as NON-root, this may not be fatal */
                 berrno be;
-                 Jmsg(jcr, M_ERROR, 0, _("Cannot change owner and/or group of %s: ERR=%s\n"),
+                Jmsg(jcr, M_ERROR, 0, _("Cannot change owner and/or group of %s: ERR=%s\n"),
                      quote(dirpath), be.strerror());
              }
-              Dmsg0(300, "Chown done.\n");
+             Dmsg0(300, "Chown done.\n");
 
              if (re_protect) {
                 struct ptr_list *pnew = (struct ptr_list *)
@@ -284,7 +284,7 @@ make_path(
                 pnew->dirname_end = slash;
                 pnew->next = leading_dirs;
                 leading_dirs = pnew;
-                 Dmsg0(300, "re_protect\n");
+                Dmsg0(300, "re_protect\n");
              }
          }
 
@@ -294,18 +294,18 @@ make_path(
             stat and mkdir process O(n^2) file name components.  */
          if (cwd.do_chdir && chdir(basename_dir) < 0) {
              berrno be;
-              Jmsg(jcr, M_ERROR, 0, _("Cannot chdir to directory, %s: ERR=%s\n"),
+             Jmsg(jcr, M_ERROR, 0, _("Cannot chdir to directory, %s: ERR=%s\n"),
                     quote(dirpath), be.strerror());
              umask(oldmask);
              cleanup(&cwd);
              return 1;
          }
 
-          *slash++ = '/';
+         *slash++ = '/';
 
-          /* Avoid unnecessary calls to `stat' when given
+         /* Avoid unnecessary calls to `stat' when given
             pathnames containing multiple adjacent slashes.  */
-          while (*slash == '/')
+         while (*slash == '/')
             slash++;
       } /* end while (1) */
 
@@ -334,7 +334,7 @@ make_path(
              )
            {
              berrno be;
-              Jmsg(jcr, M_WARNING, 0, _("Cannot change owner and/or group of %s: ERR=%s\n"),
+             Jmsg(jcr, M_WARNING, 0, _("Cannot change owner and/or group of %s: ERR=%s\n"),
                     quote(dirpath), be.strerror());
            }
       }
@@ -342,14 +342,14 @@ make_path(
       /* The above chown may have turned off some permission bits in MODE.
         Another reason we may have to use chmod here is that mkdir(2) is
         required to honor only the file permission bits.  In particular,
-         it need not honor the `special' bits, so if MODE includes any
+        it need not honor the `special' bits, so if MODE includes any
         special bits, set them here.  */
       if (mode & ~S_IRWXUGO) {
-         Dmsg1(300, "Final chmod mode=%o\n", mode);
+        Dmsg1(300, "Final chmod mode=%o\n", mode);
       }
       if ((mode & ~S_IRWXUGO) && chmod(basename_dir, mode)) {
          berrno be;
-          Jmsg(jcr, M_WARNING, 0, _("Cannot change permissions of %s: ERR=%s\n"), 
+         Jmsg(jcr, M_WARNING, 0, _("Cannot change permissions of %s: ERR=%s\n"),
             quote(dirpath), be.strerror());
       }
 
@@ -361,11 +361,11 @@ make_path(
         privileges, we have to reset their protections to the correct
         value.  */
       for (p = leading_dirs; p != NULL; p = p->next) {
-          *(p->dirname_end) = '\0';
-          Dmsg2(300, "Reset parent mode=%o dir=%s\n", parent_mode, dirpath);
+         *(p->dirname_end) = '\0';
+         Dmsg2(300, "Reset parent mode=%o dir=%s\n", parent_mode, dirpath);
          if (chmod(dirpath, parent_mode)) {
              berrno be;
-              Jmsg(jcr, M_WARNING, 0, _("Cannot change permissions of %s: ERR=%s\n"),
+             Jmsg(jcr, M_WARNING, 0, _("Cannot change permissions of %s: ERR=%s\n"),
                     quote(dirpath), be.strerror());
          }
       }
@@ -375,17 +375,17 @@ make_path(
       const char *dirpath = argpath;
 
       if (!S_ISDIR(stats.st_mode)) {
-          Jmsg(jcr, M_ERROR, 0, _("%s exists but is not a directory\n"), quote(dirpath));
+         Jmsg(jcr, M_ERROR, 0, _("%s exists but is not a directory\n"), quote(dirpath));
          return 1;
       }
 
       if (!preserve_existing) {
-          Dmsg0(300, "Do not preserve existing.\n");
+         Dmsg0(300, "Do not preserve existing.\n");
          /* chown must precede chmod because on some systems,
             chown clears the set[ug]id bits for non-superusers,
             resulting in incorrect permissions.
             On System V, users can give away files with chown and then not
-             be able to chmod them.  So don't give files away.  */
+            be able to chmod them.  So don't give files away.  */
 
          if ((owner != (uid_t)-1 || group != (gid_t)-1)
              && chown(dirpath, owner, group)
@@ -394,15 +394,15 @@ make_path(
 #endif
              ) {
              berrno be;
-              Jmsg(jcr, M_WARNING, 0, _("Cannot change owner and/or group of %s: ERR=%s\n"),
+             Jmsg(jcr, M_WARNING, 0, _("Cannot change owner and/or group of %s: ERR=%s\n"),
                     quote(dirpath), be.strerror());
            }
          if (chmod(dirpath, mode)) {
              berrno be;
-              Jmsg(jcr, M_WARNING, 0, _("Cannot change permissions of %s: ERR=%s\n"),
+             Jmsg(jcr, M_WARNING, 0, _("Cannot change permissions of %s: ERR=%s\n"),
                                 quote(dirpath), be.strerror());
          }
-          Dmsg2(300, "pathexists chmod mode=%o dir=%s\n", mode, dirpath);
+         Dmsg2(300, "pathexists chmod mode=%o dir=%s\n", mode, dirpath);
       }
   }
   return retval;
index a1b811418daf8ba1c644b7ad5f11c15e72b47553..fe84276b3cb74da018fe2d828a0dc9b0bb2b8aba 100644 (file)
@@ -3,7 +3,7 @@
  *   filename/pathname patterns.
  *
  *  Note, this file is used for the old style include and
- *   excludes, so is deprecated. The new style code is 
+ *   excludes, so is deprecated. The new style code is
  *   found in find.c
  *
  *   Kern E. Sibbald, December MMI
@@ -52,7 +52,7 @@ static const int fnmode = 0;
 #define bmalloc(x) sm_malloc(__FILE__, __LINE__, x)
 
 extern const int win32_client;
-       
+
 /*
  * Initialize structures for filename matching
  */
@@ -61,7 +61,7 @@ void init_include_exclude_files(FF_PKT *ff)
 }
 
 /*
- * Done doing filename matching, release all 
+ * Done doing filename matching, release all
  *  resources used.
  */
 void term_include_exclude_files(FF_PKT *ff)
@@ -86,7 +86,7 @@ void term_include_exclude_files(FF_PKT *ff)
       free(exc);
       exc = next_exc;
    }
-   
+
 }
 
 /*
@@ -103,7 +103,7 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
 
    inc =(struct s_included_file *)bmalloc(sizeof(struct s_included_file) + len + 1);
    inc->options = 0;
-   inc->VerifyOpts[0] = 'V'; 
+   inc->VerifyOpts[0] = 'V';
    inc->VerifyOpts[1] = ':';
    inc->VerifyOpts[2] = 0;
 
@@ -111,42 +111,42 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
    if (prefixed) {
       for (rp=fname; *rp && *rp != ' '; rp++) {
         switch (*rp) {
-         case 'a':                 /* alway replace */
-         case '0':                 /* no option */
+        case 'a':                 /* alway replace */
+        case '0':                 /* no option */
            break;
-         case 'f':
+        case 'f':
            inc->options |= FO_MULTIFS;
            break;
-         case 'h':                 /* no recursion */
+        case 'h':                 /* no recursion */
            inc->options |= FO_NO_RECURSION;
            break;
-         case 'M':                 /* MD5 */
+        case 'M':                 /* MD5 */
            inc->options |= FO_MD5;
            break;
-         case 'n':
+        case 'n':
            inc->options |= FO_NOREPLACE;
            break;
-         case 'p':                 /* use portable data format */
+        case 'p':                 /* use portable data format */
            inc->options |= FO_PORTABLE;
            break;
-         case 'r':                 /* read fifo */
+        case 'r':                 /* read fifo */
            inc->options |= FO_READFIFO;
            break;
-         case 'S':
+        case 'S':
            inc->options |= FO_SHA1;
            break;
-         case 's':
+        case 's':
            inc->options |= FO_SPARSE;
            break;
-         case 'm':
+        case 'm':
            inc->options |= FO_MTIMEONLY;
            break;
-         case 'k':
+        case 'k':
            inc->options |= FO_KEEPATIME;
            break;
-         case 'V':                  /* verify options */
+        case 'V':                  /* verify options */
            /* Copy Verify Options */
-            for (j=0; *rp && *rp != ':'; rp++) {
+           for (j=0; *rp && *rp != ':'; rp++) {
               inc->VerifyOpts[j] = *rp;
               if (j < (int)sizeof(inc->VerifyOpts) - 1) {
                  j++;
@@ -154,19 +154,19 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
            }
            inc->VerifyOpts[j] = 0;
            break;
-         case 'w':
+        case 'w':
            inc->options |= FO_IF_NEWER;
            break;
-         case 'A':
+        case 'A':
            inc->options |= FO_ACL;
            break;
-         case 'Z':                 /* gzip compression */
+        case 'Z':                 /* gzip compression */
            inc->options |= FO_GZIP;
-            inc->level = *++rp - '0';
-            Dmsg1(200, "Compression level=%d\n", inc->level);
+           inc->level = *++rp - '0';
+           Dmsg1(200, "Compression level=%d\n", inc->level);
            break;
         default:
-            Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *rp);
+           Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *rp);
            break;
         }
       }
@@ -177,7 +177,7 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
       rp = fname;
    }
 
-   strcpy(inc->fname, rp);               
+   strcpy(inc->fname, rp);
    p = inc->fname;
    len = strlen(p);
    /* Zap trailing slashes.  */
@@ -199,7 +199,7 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
    /* Convert any \'s into /'s */
    for (p=inc->fname; *p; p++) {
       if (*p == '\\') {
-         *p = '/';
+        *p = '/';
       }
    }
 #endif
@@ -214,7 +214,7 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
       for (next=ff->included_files_list; next->next; next=next->next)
         { }
       next->next = inc;
-   }  
+   }
    Dmsg1(50, "add_fname_to_include fname=%s\n", inc->fname);
 }
 
@@ -238,18 +238,18 @@ void add_fname_to_exclude_list(FF_PKT *ff, const char *fname)
    } else {
       list = &ff->excluded_files_list;
    }
-  
+
    len = strlen(fname);
 
    exc = (struct s_excluded_file *)bmalloc(sizeof(struct s_excluded_file) + len + 1);
    exc->next = *list;
    exc->len = len;
-   strcpy(exc->fname, fname);                
+   strcpy(exc->fname, fname);
 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
    /* Convert any \'s into /'s */
    for (char *p=exc->fname; *p; p++) {
       if (*p == '\\') {
-         *p = '/';
+        *p = '/';
       }
    }
 #endif
@@ -264,7 +264,7 @@ struct s_included_file *get_next_included_file(FF_PKT *ff, struct s_included_fil
 {
    struct s_included_file *inc;
 
-   if (ainc == NULL) { 
+   if (ainc == NULL) {
       inc = ff->included_files_list;
    } else {
       inc = ainc->next;
@@ -295,7 +295,7 @@ int file_is_included(FF_PKT *ff, const char *file)
            return 1;
         }
         continue;
-      }                            
+      }
       /*
        * No wild cards. We accept a match to the
        *  end of any component.
@@ -305,7 +305,7 @@ int file_is_included(FF_PKT *ff, const char *file)
       if (inc->len == len && strcmp(inc->fname, file) == 0) {
         return 1;
       }
-      if (inc->len < len && file[inc->len] == '/' && 
+      if (inc->len < len && file[inc->len] == '/' &&
          strncmp(inc->fname, file, inc->len) == 0) {
         return 1;
       }
@@ -329,7 +329,7 @@ file_in_excluded_list(struct s_excluded_file *exc, const char *file)
    }
    for ( ; exc; exc=exc->next ) {
       if (fnmatch(exc->fname, file, fnmode|FNM_PATHNAME) == 0) {
-         Dmsg2(900, "Match exc pat=%s: file=%s:\n", exc->fname, file);
+        Dmsg2(900, "Match exc pat=%s: file=%s:\n", exc->fname, file);
         return 1;
       }
       Dmsg2(900, "No match exc pat=%s: file=%s:\n", exc->fname, file);
@@ -348,7 +348,7 @@ int file_is_excluded(FF_PKT *ff, const char *file)
 {
    const char *p;
 
-   /* 
+   /*
     *  ***NB*** this removes the drive from the exclude
     *  rule.  Why?????
     */
@@ -365,7 +365,7 @@ int file_is_excluded(FF_PKT *ff, const char *file)
       /* Match from the beginning of a component only */
       if ((p == file || (*p != '/' && *(p-1) == '/'))
           && file_in_excluded_list(ff->excluded_files_list, p)) {
-        return 1;   
+        return 1;
       }
    }
    return 0;
index 97dbbc8033233854608d5722e60675a20f362c8b..2419e9e80b2e5ddd1d271000432614fe0fadda85 100644 (file)
@@ -46,11 +46,11 @@ void  add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname);
 void  add_fname_to_exclude_list(FF_PKT *ff, const char *fname);
 int   file_is_excluded(FF_PKT *ff, const char *file);
 int   file_is_included(FF_PKT *ff, const char *file);
-struct s_included_file *get_next_included_file(FF_PKT *ff, 
+struct s_included_file *get_next_included_file(FF_PKT *ff,
                           struct s_included_file *inc);
 
 /* From find_one.c */
-int   find_one_file(JCR *jcr, FF_PKT *ff, int handle_file(FF_PKT *ff_pkt, void *hpkt), 
+int   find_one_file(JCR *jcr, FF_PKT *ff, int handle_file(FF_PKT *ff_pkt, void *hpkt),
               void *pkt, char *p, dev_t parent_device, int top_level);
 int   term_find_one(FF_PKT *ff);
 
index 8d6d75080a5844da55b33440ef65157a534ff0e6..4ce4678772e8fbae196fa00599d317f6a8811888 100644 (file)
@@ -45,7 +45,7 @@ save_cwd(struct saved_cwd *cwd)
       cwd->desc = open(".", O_RDONLY);
       if (cwd->desc < 0) {
         berrno be;
-         Emsg1(M_ERROR, 0, "Cannot open current directory: %s\n", be.strerror());
+        Emsg1(M_ERROR, 0, "Cannot open current directory: %s\n", be.strerror());
         return 1;
       }
 
@@ -59,7 +59,7 @@ save_cwd(struct saved_cwd *cwd)
              have_working_fchdir = 0;
          } else {
              berrno be;
-              Emsg1(M_ERROR, 0, "Current directory: %s\n", be.strerror());
+             Emsg1(M_ERROR, 0, "Current directory: %s\n", be.strerror());
              close(cwd->desc);
              cwd->desc = -1;
              return 1;
@@ -81,7 +81,7 @@ save_cwd(struct saved_cwd *cwd)
       cwd->name = (POOLMEM *)getcwd(buf, sizeof_pool_memory(buf));
       if (cwd->name == NULL) {
         berrno be;
-         Emsg1(M_ERROR, 0, "Cannot get current directory: %s\n", be.strerror());
+        Emsg1(M_ERROR, 0, "Cannot get current directory: %s\n", be.strerror());
         free_pool_memory(buf);
         return 1;
       }
@@ -100,10 +100,10 @@ restore_cwd(const struct saved_cwd *cwd, const char *dest, const char *from)
   if (cwd->desc >= 0) {
       if (fchdir(cwd->desc)) {
         berrno be;
-         Emsg4(M_ERROR, 0, "Cannot return to %s%s%s: %s\n", 
-                 (dest ? dest : "saved working directory"),
-                 (from ? " from " : ""),
-                 (from ? from : ""), be.strerror());
+        Emsg4(M_ERROR, 0, "Cannot return to %s%s%s: %s\n",
+                (dest ? dest : "saved working directory"),
+                (from ? " from " : ""),
+                (from ? from : ""), be.strerror());
         fail = 1;
       }
   } else if (chdir(cwd->name) < 0) {
index 0af93ece2a690d705b725dc0366fa2b8616f9c06..07a2988e560d2b94c4c48b1e01af80968e262113 100644 (file)
@@ -12,7 +12,7 @@ struct saved_cwd
 
 int save_cwd(struct saved_cwd *cwd);
 int restore_cwd(const struct saved_cwd *cwd, const char *dest,
-                         const char *from);
+                        const char *from);
 void free_cwd(struct saved_cwd *cwd);
 
 #endif
index bdd7a931a1097ed5df9186c5fac806001f80d54b..801e6a666666bad1a1e6298820727159579ea12d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Windows APIs that are different for each system.
- *   We use pointers to the entry points so that a 
+ *   We use pointers to the entry points so that a
  *   single binary will run on all Windows systems.
  *
  *     Kern Sibbald MMIII
index e7f9ec4330feebc9b6c5e1c903e6ad84c3ec55b8..59eda43c84a804fa897329409b04d7e8d467111e 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef __WINAPI_H
 #define __WINAPI_H
 #if defined(HAVE_WIN32)
-/* Commented out native.h include statement, which is not distributed with the 
+/* Commented out native.h include statement, which is not distributed with the
  * free version of VC++, and which is not used in bacula. */
 /*#if !defined(HAVE_MINGW) // native.h not present on mingw
 #include <native.h>
@@ -40,7 +40,7 @@
 
 typedef BOOL (WINAPI * t_OpenProcessToken)(HANDLE, DWORD, PHANDLE);
 typedef BOOL (WINAPI * t_AdjustTokenPrivileges)(HANDLE, BOOL,
-          PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
+         PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
 typedef BOOL (WINAPI * t_LookupPrivilegeValue)(LPCTSTR, LPCTSTR, PLUID);
 
 extern t_OpenProcessToken      p_OpenProcessToken;
index 80c52f4e55f6f33026ae74843972f08aa8c7fc35..c382d499748afae2f176646a327c92ff94114d34 100644 (file)
@@ -28,7 +28,7 @@
    MA 02111-1307, USA.
 
  */
+
 #ifndef __JCR_H_
 #define __JCR_H_ 1
 
@@ -84,7 +84,7 @@
    jcr->JobStatus == JS_FatalError)
 
 #define foreach_jcr(jcr) \
-   for ((jcr)=NULL; ((jcr)=get_next_jcr(jcr)); ) 
+   for ((jcr)=NULL; ((jcr)=get_next_jcr(jcr)); )
 
 
 
@@ -117,7 +117,7 @@ struct JCR {
    uint64_t JobBytes;                 /* Number of bytes processed this job */
    uint64_t ReadBytes;                /* Bytes read -- before compression */
    uint32_t Errors;                   /* Number of non-fatal errors */
-   volatile int JobStatus;            /* ready, running, blocked, terminated */ 
+   volatile int JobStatus;            /* ready, running, blocked, terminated */
    int JobType;                       /* backup, restore, verify ... */
    int JobLevel;                      /* Job level */
    int JobPriority;                   /* Job priority */
@@ -176,7 +176,7 @@ struct JCR {
    JOB_DBR jr;                        /* Job DB record for current job */
    JOB_DBR *verify_jr;                /* Pointer to target job */
    uint32_t RestoreJobId;             /* Id specified by UA */
-   POOLMEM *client_uname;             /* client uname */ 
+   POOLMEM *client_uname;             /* client uname */
    int replace;                       /* Replace option */
    int saveMaxConcurrentJobs;         /* save for restore jobs */
    int NumVols;                       /* Number of Volume used in pool */
@@ -238,7 +238,7 @@ struct JCR {
    bool spool_data;                   /* set to spool data */
    int CurVol;                        /* Current Volume count */
    DIRRES* director;                  /* Director resource */
-   
+
    uint32_t FileId;                   /* Last file id inserted */
 
    /* Parmaters for Open Read Session */
@@ -252,11 +252,11 @@ struct JCR {
 
 #endif /* STORAGE_DAEMON */
 
-}; 
+};
 
 
 
-/* 
+/*
  * Structure for all daemons that keeps some summary
  *  info on the last job run.
  */
@@ -276,7 +276,7 @@ struct s_last_job {
    char Job[MAX_NAME_LENGTH];
 };
 
-extern struct s_last_job last_job;               
+extern struct s_last_job last_job;
 extern dlist *last_jobs;
 
 
index 9e655f380e6b7001ea799c4754546df6c574edd5..3b692025d849d534c2dee855ed957245e767b8d4 100644 (file)
@@ -42,7 +42,7 @@ IPADDR::IPADDR(const IPADDR &src) : type(src.type)
 {
   memcpy(&saddrbuf, &src.saddrbuf, sizeof(saddrbuf));
   saddr  = &saddrbuf.dontuse;
-  saddr4 = &saddrbuf.dontuse4; 
+  saddr4 = &saddrbuf.dontuse4;
 #ifdef HAVE_IPV6
   saddr6 = &saddrbuf.dontuse6;
 #endif
@@ -60,7 +60,7 @@ IPADDR::IPADDR(int af) : type(R_EMPTY)
   }
 #endif
   saddr  = &saddrbuf.dontuse;
-  saddr4 = &saddrbuf.dontuse4; 
+  saddr4 = &saddrbuf.dontuse4;
 #ifdef HAVE_IPV6
   saddr6 = &saddrbuf.dontuse6;
 #endif
@@ -80,8 +80,8 @@ IPADDR::IPADDR(int af) : type(R_EMPTY)
   saddr->sa_len = sizeof(sockaddr_in);
 #endif
 #endif
-   set_addr_any(); 
-} 
+   set_addr_any();
+}
 
 void IPADDR::set_type(i_type o)
 {
@@ -122,7 +122,7 @@ void IPADDR::set_port_net(unsigned short port)
 int IPADDR::get_family() const
 {
     return saddr->sa_family;
-}      
+}
 
 struct sockaddr *IPADDR::get_sockaddr()
 {
@@ -147,7 +147,7 @@ void IPADDR::copy_addr(IPADDR *src)
       saddr6->sin6_addr = src->saddr6->sin6_addr;
    }
 #endif
-} 
+}
 
 void IPADDR::set_addr_any()
 {
@@ -162,7 +162,7 @@ void IPADDR::set_addr_any()
 }
 
 void IPADDR::set_addr4(struct in_addr *ip4)
-{ 
+{
    if (saddr->sa_family != AF_INET) {
       Emsg1(M_ERROR_TERM, 0, _("It was tried to assign a ipv6 address to a ipv4(%d)\n"), saddr->sa_family);
    }
@@ -171,7 +171,7 @@ void IPADDR::set_addr4(struct in_addr *ip4)
 
 #ifdef HAVE_IPV6
 void IPADDR::set_addr6(struct in6_addr *ip6)
-{ 
+{
    if (saddr->sa_family != AF_INET6) {
       Emsg1(M_ERROR_TERM, 0, _("It was tried to assign a ipv4 address to a ipv6(%d)\n"), saddr->sa_family);
    }
@@ -196,16 +196,16 @@ const char *IPADDR::get_address(char *outputbuf, int outlen)
    return outputbuf;
 }
 
-const char *IPADDR::build_address_str(char *buf, int blen) 
+const char *IPADDR::build_address_str(char *buf, int blen)
 {
    char tmp[1024];
    bsnprintf(buf, blen, "host[%s:%s:%hu] ",
-            get_family() == AF_INET ? "ipv4" : "ipv6",
+           get_family() == AF_INET ? "ipv4" : "ipv6",
            get_address(tmp, sizeof(tmp) - 1), get_port_host_order());
    return buf;
 }
 
-const char *build_addresses_str(dlist *addrs, char *buf, int blen) 
+const char *build_addresses_str(dlist *addrs, char *buf, int blen)
 {
    if (addrs->size() == 0) {
       bstrncpy(buf, "", blen);
@@ -231,12 +231,12 @@ const char *get_first_address(dlist * addrs, char *outputbuf, int outlen)
 
 int get_first_port_net_order(dlist * addrs)
 {
-   return ((IPADDR *)(addrs->first()))->get_port_net_order();                            
+   return ((IPADDR *)(addrs->first()))->get_port_net_order();
 }
 
 int get_first_port_host_order(dlist * addrs)
 {
-   return ((IPADDR *)(addrs->first()))->get_port_host_order();                           
+   return ((IPADDR *)(addrs->first()))->get_port_host_order();
 }
 
 void init_default_addresses(dlist **out, int port)
@@ -274,7 +274,7 @@ static int add_address(dlist **out, IPADDR::i_type type, unsigned short defaultp
         } else if (iaddr->get_type() != type) {
            *errstr = (char *)malloc(1024);
            bsnprintf(*errstr, 1023,
-                      "the old style addresses cannot be mixed with new style");
+                     "the old style addresses cannot be mixed with new style");
            return 0;
         }
       }
@@ -292,12 +292,12 @@ static int add_address(dlist **out, IPADDR::i_type type, unsigned short defaultp
       if (0 < pnum && pnum < 0xffff) {
         port = htons(pnum);
       } else {
-         struct servent *s = getservbyname(port_str, "tcp");
+        struct servent *s = getservbyname(port_str, "tcp");
         if (s) {
            port = s->s_port;
         } else {
            *errstr = (char *)malloc(1024);
-            bsnprintf(*errstr, 1023, "can't resolve service(%s)", port_str);
+           bsnprintf(*errstr, 1023, "can't resolve service(%s)", port_str);
            return 0;
         }
       }
@@ -317,7 +317,7 @@ static int add_address(dlist **out, IPADDR::i_type type, unsigned short defaultp
       if (addrs->size()) {
         addr = (IPADDR *)addrs->first();
       } else {
-        addr = New(IPADDR(family)); 
+        addr = New(IPADDR(family));
         addr->set_type(type);
         addr->set_port_net(defaultport);
         addr->set_addr_any();
@@ -335,13 +335,13 @@ static int add_address(dlist **out, IPADDR::i_type type, unsigned short defaultp
         /* for duplicates */
         foreach_dlist(jaddr, addrs) {
            if (iaddr->get_sockaddr_len() == jaddr->get_sockaddr_len() &&
-           !memcmp(iaddr->get_sockaddr(), jaddr->get_sockaddr(), 
+           !memcmp(iaddr->get_sockaddr(), jaddr->get_sockaddr(),
                    iaddr->get_sockaddr_len()))
                {
               goto skip;          /* no price */
            }
         }
-        clone = New(IPADDR(*iaddr)); 
+        clone = New(IPADDR(*iaddr));
         clone->set_type(type);
         clone->set_port_net(port);
         addrs->append(clone);
@@ -357,27 +357,27 @@ static int add_address(dlist **out, IPADDR::i_type type, unsigned short defaultp
  *   my tests
  *   positiv
  *   = { ip = { addr = 1.2.3.4; port = 1205; } ipv4 = { addr = 1.2.3.4; port = http; } }
- *   = { ip = { 
- *        addr = 1.2.3.4; port = 1205; } 
- *     ipv4 = { 
- *        addr = 1.2.3.4; port = http; } 
- *     ipv6 = { 
- *      addr = 1.2.3.4; 
+ *   = { ip = {
+ *        addr = 1.2.3.4; port = 1205; }
+ *     ipv4 = {
+ *        addr = 1.2.3.4; port = http; }
+ *     ipv6 = {
+ *      addr = 1.2.3.4;
  *      port = 1205;
- *     } 
+ *     }
  *     ip = {
  *      addr = 1.2.3.4
  *      port = 1205
- *     } 
+ *     }
  *     ip = {
  *      addr = 1.2.3.4
- *     } 
+ *     }
  *     ip = {
  *      addr = 2001:220:222::2
- *     } 
+ *     }
  *     ip = {
  *      addr = bluedot.thun.net
- (     } 
+ (     }
  *   }
  *   negativ
  *   = { ip = { } }
@@ -405,7 +405,7 @@ void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
    }
    do {
       if (!(token == T_UNQUOTED_STRING || token == T_IDENTIFIER)) {
-         scan_err1(lc, _("Expected a string, got: %s"), lc->str);
+        scan_err1(lc, _("Expected a string, got: %s"), lc->str);
       }
       if (strcasecmp("ip", lc->str) == 0 || strcasecmp("ipv4", lc->str) == 0) {
         family = AF_INET;
@@ -414,46 +414,46 @@ void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
       else if (strcasecmp("ipv6", lc->str) == 0) {
         family = AF_INET6;
       } else {
-         scan_err1(lc, _("Expected a string [ip|ipv4|ipv6], got: %s"), lc->str);
+        scan_err1(lc, _("Expected a string [ip|ipv4|ipv6], got: %s"), lc->str);
       }
 #else
       else {
-         scan_err1(lc, _("Expected a string [ip|ipv4], got: %s"), lc->str);
+        scan_err1(lc, _("Expected a string [ip|ipv4], got: %s"), lc->str);
       }
 #endif
       token = lex_get_token(lc, T_SKIP_EOL);
       if (token != T_EQUALS) {
-         scan_err1(lc, _("Expected a equal =, got: %s"), lc->str);
+        scan_err1(lc, _("Expected a equal =, got: %s"), lc->str);
       }
       token = lex_get_token(lc, T_SKIP_EOL);
       if (token != T_BOB) {
-         scan_err1(lc, _("Expected a block beginn { , got: %s"), lc->str);
+        scan_err1(lc, _("Expected a block beginn { , got: %s"), lc->str);
       }
       token = lex_get_token(lc, T_SKIP_EOL);
       exist = EMPTYLINE;
       port_str[0] = hostname_str[0] = '\0';
       do {
         if (token != T_IDENTIFIER) {
-            scan_err1(lc, _("Expected a identifier [addr|port], got: %s"), lc->str);
+           scan_err1(lc, _("Expected a identifier [addr|port], got: %s"), lc->str);
         }
-         if (strcasecmp("port", lc->str) == 0) {
+        if (strcasecmp("port", lc->str) == 0) {
            next_line = PORTLINE;
            if (exist & PORTLINE) {
-               scan_err0(lc, _("Only one port per address block"));
+              scan_err0(lc, _("Only one port per address block"));
            }
            exist |= PORTLINE;
-         } else if (strcasecmp("addr", lc->str) == 0) {
+        } else if (strcasecmp("addr", lc->str) == 0) {
            next_line = ADDRLINE;
            if (exist & ADDRLINE) {
-               scan_err0(lc, _("Only one addr per address block"));
+              scan_err0(lc, _("Only one addr per address block"));
            }
            exist |= ADDRLINE;
         } else {
-            scan_err1(lc, _("Expected a identifier [addr|port], got: %s"), lc->str);
+           scan_err1(lc, _("Expected a identifier [addr|port], got: %s"), lc->str);
         }
         token = lex_get_token(lc, T_SKIP_EOL);
         if (token != T_EQUALS) {
-            scan_err1(lc, _("Expected a equal =, got: %s"), lc->str);
+           scan_err1(lc, _("Expected a equal =, got: %s"), lc->str);
         }
         token = lex_get_token(lc, T_SKIP_EOL);
         switch (next_line) {
@@ -461,31 +461,31 @@ void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
            if (!
                (token == T_UNQUOTED_STRING || token == T_NUMBER
                 || token == T_IDENTIFIER)) {
-               scan_err1(lc, _("Expected a number or a string, got: %s"), lc->str);
+              scan_err1(lc, _("Expected a number or a string, got: %s"), lc->str);
            }
            bstrncpy(port_str, lc->str, sizeof(port_str));
            break;
         case ADDRLINE:
            if (!(token == T_UNQUOTED_STRING || token == T_IDENTIFIER)) {
-               scan_err1(lc, _("Expected an IP number or a hostname, got: %s"),
+              scan_err1(lc, _("Expected an IP number or a hostname, got: %s"),
                         lc->str);
            }
            bstrncpy(hostname_str, lc->str, sizeof(hostname_str));
            break;
         case EMPTYLINE:
-            scan_err0(lc, _("State machine missmatch"));
+           scan_err0(lc, _("State machine missmatch"));
            break;
         }
         token = lex_get_token(lc, T_SKIP_EOL);
       } while (token == T_IDENTIFIER);
       if (token != T_EOB) {
-         scan_err1(lc, _("Expected a end of block }, got: %s"), lc->str);
+        scan_err1(lc, _("Expected a end of block }, got: %s"), lc->str);
       }
 
       char *errstr;
-      if (pass == 1 && !add_address((dlist **)(item->value), IPADDR::R_MULTIPLE, 
+      if (pass == 1 && !add_address((dlist **)(item->value), IPADDR::R_MULTIPLE,
               htons(item->default_value), family, hostname_str, port_str, &errstr)) {
-           scan_err3(lc, _("Can't add hostname(%s) and port(%s) to addrlist (%s)"),
+          scan_err3(lc, _("Can't add hostname(%s) and port(%s) to addrlist (%s)"),
                   hostname_str, port_str, errstr);
           free(errstr);
        }
index 42fe083d6007a9e3b131f129e37697d34a22f043..779c68ee691a12c6aa4fb72e527d9a3c450dc3d1 100644 (file)
@@ -34,7 +34,7 @@ class IPADDR : public SMARTALLOC {
    IPADDR(int af);
    IPADDR(const IPADDR & src);
  private:
-   IPADDR() {  /* block this construction */ } 
+   IPADDR() {  /* block this construction */ }
    i_type type;
    union {
       struct sockaddr dontuse;
index af703f223bc8935f00dd15cea5e129cf90fbb944..53275832b164a0c15dc5f54505d9050bebeff7a2 100644 (file)
@@ -1,8 +1,8 @@
 /*
- *  Bacula array list routines    
+ *  Bacula array list routines
  *
  *    alist is a simple malloc'ed array of pointers.  For the moment,
- *      it simply malloc's a bigger array controlled by num_grow.         
+ *      it simply malloc's a bigger array controlled by num_grow.
  *     Default is to realloc the pointer array for each new member.
  *
  *   Kern Sibbald, June MMIII
@@ -33,7 +33,7 @@
 #include "bacula.h"
 
 /*
- * Private grow list function. Used to insure that 
+ * Private grow list function. Used to insure that
  *   at least one more "slot" is available.
  */
 void alist::grow_list()
@@ -65,7 +65,7 @@ void *alist::last()
    if (num_items == 0) {
       return NULL;
    } else {
-      cur_item = num_items;    
+      cur_item = num_items;
       return items[num_items-1];
    }
 }
@@ -171,13 +171,13 @@ int main()
    fileset->mylist.init();
 
    printf("Manual allocation/destruction of list:\n");
-   
+
    for (int i=0; i<20; i++) {
       sprintf(buf, "This is item %d", i);
       fileset->mylist.append(bstrdup(buf));
-   } 
+   }
    for (int i=0; i< fileset->mylist.size(); i++) {
-      printf("Item %d = %s\n", i, (char *)fileset->mylist[i]);  
+      printf("Item %d = %s\n", i, (char *)fileset->mylist[i]);
    }
    fileset->mylist.destroy();
    free(fileset);
@@ -188,9 +188,9 @@ int main()
    for (int i=0; i<20; i++) {
       sprintf(buf, "This is item %d", i);
       mlist->append(bstrdup(buf));
-   } 
+   }
    for (int i=0; i< mlist->size(); i++) {
-      printf("Item %d = %s\n", i, (char *)mlist->get(i));  
+      printf("Item %d = %s\n", i, (char *)mlist->get(i));
    }
 
    delete mlist;
index fee12c3c1c9e64d0680d4b8bf25ce87b4895e78a..2a1a26d18241d6695ea64265abd9202f7270f253 100644 (file)
@@ -24,7 +24,7 @@
 
  */
 
-/* 
+/*
  * There is a lot of extra casting here to work around the fact
  * that some compilers (Sun and Visual C++) do not accept
  * (void *) as an lvalue on the left side of an equal.
@@ -36,7 +36,7 @@
 
 #ifdef the_easy_way
 #define foreach_alist(var, list) \
-        for((void*(var))=(list)->first(); (var); (void *(var))=(list)->next(var)); )
+       for((void*(var))=(list)->first(); (var); (void *(var))=(list)->next(var)); )
 #endif
 
 
@@ -46,7 +46,7 @@ enum {
   not_owned_by_alist = false
 };
 
-/* 
+/*
  * Array list -- much like a simplified STL vector
  *   array of pointers to inserted items
  */
@@ -90,7 +90,7 @@ inline bool alist::empty() const
    return this ? num_items == 0 : true;
 }
 
-/*                            
+/*
  * This allows us to do explicit initialization,
  *   allowing us to mix C++ classes inside malloc'ed
  *   C structures. Define before called in constructor.
@@ -112,11 +112,11 @@ inline alist::alist(int num, bool own) {
 inline alist::~alist() {
    destroy();
 }
-   
+
 
 
 /* Current size of list */
-inline int alist::size() const 
+inline int alist::size() const
 {
    /*
     * Check for null pointer, which allows test
@@ -127,7 +127,7 @@ inline int alist::size() const
 }
 
 /* How much to grow by each time */
-inline void alist::grow(int num) 
+inline void alist::grow(int num)
 {
    num_grow = num;
 }
index 241749a4396acdbc557ab5505f6cd0c9ac05295f..8de592cf1dc4ec5f49549dfff2125ab192904358 100644 (file)
@@ -52,8 +52,8 @@ void *sm_alloc(char *fname, int lineno, unsigned int nbytes)
        if ((buf = sm_malloc(fname, lineno, nbytes)) != NULL) {
           return buf;
        }
-        V fprintf(stderr, "\nBoom!!!  Memory capacity exceeded.\n");
-        V fprintf(stderr, "  Requested %u bytes at line %d of %s.\n",
+       V fprintf(stderr, "\nBoom!!!  Memory capacity exceeded.\n");
+       V fprintf(stderr, "  Requested %u bytes at line %d of %s.\n",
           nbytes, lineno, fname);
        abort();
        /*NOTREACHED*/
@@ -69,8 +69,8 @@ void *alloc(unsigned int nbytes)
        if ((buf = malloc(nbytes)) != NULL) {
           return buf;
        }
-        V fprintf(stderr, "\nBoom!!!  Memory capacity exceeded.\n");
-        V fprintf(stderr, "  Requested %u bytes.\n", nbytes);
+       V fprintf(stderr, "\nBoom!!!  Memory capacity exceeded.\n");
+       V fprintf(stderr, "  Requested %u bytes.\n", nbytes);
        abort();
        /*NOTREACHED*/
 }
index 4091331aa478317cf6348578a28764267583149d..443260f1d7aec8d216c01367e9e2f1fa05e4ad60 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *   attr.c  Unpack an Attribute record returned from the tape
- * 
+ *
  *    Kern Sibbald, June MMIII (code pulled from filed/restore.c and updated)
  *
  *   Version $Id$
@@ -52,7 +52,7 @@ void free_attr(ATTR *attr)
 int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr)
 {
    char *p;
-   /*             
+   /*
     * An Attributes record consists of:
     *   File_index
     *   Type   (FT_types)
@@ -83,7 +83,7 @@ int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr)
       { }
    while (*p++ != ' ')               /* skip type */
       { }
-   
+
    attr->fname = p;                  /* set filname position */
    while (*p++ != 0)                 /* skip filename */
       { }
@@ -112,7 +112,7 @@ int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr)
 
 /*
  * Build attr->ofname from attr->fname and
- *      attr->olname from attr->olname 
+ *      attr->olname from attr->olname
  */
 void build_attr_output_fnames(JCR *jcr, ATTR *attr)
 {
@@ -124,7 +124,7 @@ void build_attr_output_fnames(JCR *jcr, ATTR *attr)
     *  a drive letter -- we simply change the drive
     *  from, for example, c: to c/ for
     *  every filename if a prefix is supplied.
-    *    
+    *
     */
    if (jcr->where[0] == 0) {
       pm_strcpy(attr->ofname, attr->fname);
@@ -134,13 +134,13 @@ void build_attr_output_fnames(JCR *jcr, ATTR *attr)
       int wherelen = strlen(jcr->where);
       pm_strcpy(attr->ofname, jcr->where);  /* copy prefix */
       if (win32_client && attr->fname[1] == ':') {
-         attr->fname[1] = '/';     /* convert : to / */
+        attr->fname[1] = '/';     /* convert : to / */
       }
       fn = attr->fname;           /* take whole name */
       /* Ensure where is terminated with a slash */
       if (jcr->where[wherelen-1] != '/' && fn[0] != '/') {
-         pm_strcat(attr->ofname, "/");
-      }   
+        pm_strcat(attr->ofname, "/");
+      }
       pm_strcat(attr->ofname, fn); /* copy rest of name */
       /*
        * Fixup link name -- if it is an absolute path
@@ -150,7 +150,7 @@ void build_attr_output_fnames(JCR *jcr, ATTR *attr)
         /* Always add prefix to hard links (FT_LNKSAVED) and
          *  on user request to soft links
          */
-         if (attr->lname[0] == '/' &&
+        if (attr->lname[0] == '/' &&
             (attr->type == FT_LNKSAVED || jcr->prefix_links)) {
            pm_strcpy(attr->olname, jcr->where);
            add_link = true;
@@ -158,14 +158,14 @@ void build_attr_output_fnames(JCR *jcr, ATTR *attr)
            attr->olname[0] = 0;
            add_link = false;
         }
-         if (win32_client && attr->lname[1] == ':') {
-            attr->lname[1] = '/';    /* turn : into / */
+        if (win32_client && attr->lname[1] == ':') {
+           attr->lname[1] = '/';    /* turn : into / */
         }
         fn = attr->lname;       /* take whole name */
         /* Ensure where is terminated with a slash */
-         if (add_link && jcr->where[wherelen-1] != '/' && fn[0] != '/') {
-            pm_strcat(attr->olname, "/");
-        }   
+        if (add_link && jcr->where[wherelen-1] != '/' && fn[0] != '/') {
+           pm_strcat(attr->olname, "/");
+        }
         pm_strcat(attr->olname, fn);     /* copy rest of link */
       }
    }
@@ -179,7 +179,7 @@ extern char *getgroup(gid_t gid, char *name, int len);
  */
 void print_ls_output(JCR *jcr, ATTR *attr)
 {
-   char buf[5000]; 
+   char buf[5000];
    char ec1[30];
    char en1[30], en2[30];
    char *p, *f;
index 29d057c2a180448c0d5fce110ae5b2f45b62ac6e..b393b492365520bfe739e79a75d65e25da25c95d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *   attr.h Definition of attributes packet for unpacking from tape
- * 
+ *
  *    Kern Sibbald, June MMIII
  *
  *   Version $Id$
@@ -37,8 +37,8 @@ struct ATTR {
    POOLMEM *ofname;                   /* output filename */
    POOLMEM *olname;                   /* output link name */
    /*
-    * Note the following three variables point into the 
-    *  current BSOCK record, so they are invalid after    
+    * Note the following three variables point into the
+    *  current BSOCK record, so they are invalid after
     *  the next socket read!
     */
    char *attr;                        /* attributes position */
index d956dca29eb784193ae583a097f273eab6edf583..5d4ed4ddbf88401741b228d2729aff426ffb2e22 100644 (file)
@@ -1,4 +1,4 @@
-/*   
+/*
  *   Generic base 64 input and output routines
  *
  *    Written by Kern E. Sibbald, March MM.
@@ -45,13 +45,13 @@ static uint8_t const base64_digits[64] =
 
 static int base64_inited = 0;
 static uint8_t base64_map[128];
-  
+
 
 /* Initialize the Base 64 conversion routines */
 void
 base64_init(void)
-{     
-   int i; 
+{
+   int i;
    memset(base64_map, 0, sizeof(base64_map));
    for (i=0; i<64; i++)
       base64_map[(uint8_t)base64_digits[i]] = i;
@@ -105,11 +105,11 @@ to_base64(intmax_t value, char *where)
  */
 int
 from_base64(intmax_t *value, char *where)
-{ 
+{
    uintmax_t val = 0;
    int i, neg;
 
-   if (!base64_inited) 
+   if (!base64_inited)
       base64_init();
    /* Check if it is negative */
    i = neg = 0;
@@ -122,7 +122,7 @@ from_base64(intmax_t *value, char *where)
       val <<= 6;
       val += base64_map[(uint8_t)where[i++]];
    }
-        
+
    *value = neg ? -(intmax_t)val : (intmax_t)val;
    return i;
 }
@@ -205,7 +205,7 @@ static int errfunc(const char *epath, int eernoo)
  * Test the base64 routines by encoding and decoding
  * lstat() packets.
  */
-int main(int argc, char *argv[]) 
+int main(int argc, char *argv[])
 {
    char where[500];
    int i;
@@ -218,7 +218,7 @@ int main(int argc, char *argv[])
    time_t t = 1028712799;
 
    if (argc > 1 && strcmp(argv[1], "-v") == 0)
-      debug_level++;  
+      debug_level++;
 
    base64_init();
 
@@ -228,13 +228,13 @@ int main(int argc, char *argv[])
    for (i=0; my_glob.gl_pathv[i]; i++) {
       fname = my_glob.gl_pathv[i];
       if (lstat(fname, &statp) < 0) {
-         printf("Cannot stat %s: %s\n", fname, strerror(errno));
+        printf("Cannot stat %s: %s\n", fname, strerror(errno));
         continue;
       }
       encode_stat(where, &statp);
 
       printf("Encoded stat=%s\n", where);
-     
+
 #ifdef xxx
       p = where;
       p += to_base64((intmax_t)(statp.st_atime), p);
@@ -258,11 +258,11 @@ int main(int argc, char *argv[])
 #endif
 
       if (debug_level)
-         printf("%s: len=%d val=%s\n", fname, strlen(where), where);
-      
+        printf("%s: len=%d val=%s\n", fname, strlen(where), where);
+
       decode_stat(where, &statn);
 
-      if (statp.st_dev != statn.st_dev || 
+      if (statp.st_dev != statn.st_dev ||
          statp.st_ino != statn.st_ino ||
          statp.st_mode != statn.st_mode ||
          statp.st_nlink != statn.st_nlink ||
@@ -276,10 +276,10 @@ int main(int argc, char *argv[])
          statp.st_mtime != statn.st_mtime ||
          statp.st_ctime != statn.st_ctime) {
 
-         printf("%s: %s\n", fname, where);
+        printf("%s: %s\n", fname, where);
         encode_stat(where, &statn);
-         printf("%s: %s\n", fname, where);
-         printf("NOT EQAL\n");
+        printf("%s: %s\n", fname, where);
+        printf("NOT EQAL\n");
       }
 
    }
@@ -291,5 +291,5 @@ int main(int argc, char *argv[])
    printf("UINT32_MAX=%s\n", where);
 
    return 0;
-}   
+}
 #endif
index 9354bb8ca93a8a65d824c56d12db11f02a17f241..23bb6feb476fa2ac3382b20acba87bea856f32be 100644 (file)
@@ -41,7 +41,7 @@ extern int execvp_errors[];
 
 const char *berrno::strerror()
 {
-   int stat = 0; 
+   int stat = 0;
 #ifdef HAVE_WIN32
    LPVOID msg;
 
@@ -63,17 +63,17 @@ const char *berrno::strerror()
    if (berrno_ & b_errno_exit) {
       stat = (berrno_ & ~b_errno_exit);       /* remove bit */
       if (stat == 0) {
-         return "Child exited normally.";    /* this really shouldn't happen */
+        return "Child exited normally.";    /* this really shouldn't happen */
       } else {
         /* Maybe an execvp failure */
         if (stat >= 200) {
            if (stat < 200 + num_execvp_errors) {
               berrno_ = execvp_errors[stat - 200];
            } else {
-               return "Unknown error during program execvp";
+              return "Unknown error during program execvp";
            }
         } else {
-            Mmsg(&buf_, "Child exited with code %d", stat);
+           Mmsg(&buf_, "Child exited with code %d", stat);
            return buf_;
         }
         /* If we drop out here, berrno_ is set to an execvp errno */
@@ -87,7 +87,7 @@ const char *berrno::strerror()
 #endif
    /* Normal errno */
    if (bstrerror(berrno_, buf_, 1024) < 0) {
-      return "Invalid errno. No error message possible."; 
+      return "Invalid errno. No error message possible.";
    }
    return buf_;
 }
index 0fb16426c80f455717dd48c73e64919121999512..e6b6923872de2fed476e176fcf9dc90f49f74a18 100644 (file)
@@ -34,7 +34,7 @@
  * A more generalized way of handling errno that works with Unix, Windows,
  *  and with Bacula bpipes.
  *
- * It works by picking up errno and creating a memory pool buffer 
+ * It works by picking up errno and creating a memory pool buffer
  *  for editing the message. strerror() does the actual editing, and
  *  it is thread safe.
  *
@@ -55,14 +55,14 @@ public:
 };
 
 /* Constructor */
-inline berrno::berrno(int pool) 
+inline berrno::berrno(int pool)
 {
    berrno_ = errno;
    buf_ = get_pool_memory(pool);
 }
-   
+
 inline berrno::~berrno()
-{   
+{
    free_pool_memory(buf_);
 }
 
index 7451424e8f2b8be93a00cb7d1bbbd19db6973b48..18e8fc26df7cf1469b2a511a667554e651f345fe 100644 (file)
@@ -5,7 +5,7 @@
  *   Kern Sibbald, May MMI previously in src/stored/fdmsg.c
  *
  *   Version $Id$
- *                           
+ *
  */
 /*
    Copyright (C) 2001-2004 Kern Sibbald and John Walker
@@ -34,14 +34,14 @@ extern char TERM_msg[];
 
 #define msglvl 500
 
-/*      
+/*
  * This routine does a bnet_recv(), then if a signal was
  *   sent, it handles it.  The return codes are the same as
  *   bne_recv() except the BNET_SIGNAL messages that can
  *   be handled are done so without returning.
  *
  * Returns number of bytes read (may return zero)
- * Returns -1 on signal (BNET_SIGNAL) 
+ * Returns -1 on signal (BNET_SIGNAL)
  * Returns -2 on hard end of file (BNET_HARDEOF)
  * Returns -3 on error (BNET_ERROR)
  */
@@ -52,7 +52,7 @@ int bget_msg(BSOCK *sock)
       n = bnet_recv(sock);
       if (n >= 0) {                 /* normal return */
         return n;
-      }  
+      }
       if (is_bnet_stop(sock)) {      /* error return */
         return n;
       }
@@ -60,10 +60,10 @@ int bget_msg(BSOCK *sock)
       /* BNET_SIGNAL (-1) return from bnet_recv() => network signal */
       switch (sock->msglen) {
       case BNET_EOD:              /* end of data */
-         Dmsg0(msglvl, "Got BNET_EOD\n");
+        Dmsg0(msglvl, "Got BNET_EOD\n");
         return n;
       case BNET_EOD_POLL:
-         Dmsg0(msglvl, "Got BNET_EOD_POLL\n");
+        Dmsg0(msglvl, "Got BNET_EOD_POLL\n");
         if (sock->terminated) {
            bnet_fsend(sock, TERM_msg);
         } else {
@@ -71,11 +71,11 @@ int bget_msg(BSOCK *sock)
         }
         return n;                 /* end of data */
       case BNET_TERMINATE:
-         Dmsg0(msglvl, "Got BNET_TERMINATE\n");
+        Dmsg0(msglvl, "Got BNET_TERMINATE\n");
         sock->terminated = 1;
         return n;
       case BNET_POLL:
-         Dmsg0(msglvl, "Got BNET_POLL\n");
+        Dmsg0(msglvl, "Got BNET_POLL\n");
         if (sock->terminated) {
            bnet_fsend(sock, TERM_msg);
         } else {
@@ -87,12 +87,12 @@ int bget_msg(BSOCK *sock)
         break;
       case BNET_STATUS:
         /* *****FIXME***** Implement BNET_STATUS */
-         Dmsg0(msglvl, "Got BNET_STATUS\n");
-         bnet_fsend(sock, "Status OK\n");
+        Dmsg0(msglvl, "Got BNET_STATUS\n");
+        bnet_fsend(sock, "Status OK\n");
         bnet_sig(sock, BNET_EOD);
         break;
       default:
-         Emsg1(M_ERROR, 0, "bget_msg: unknown signal %d\n", sock->msglen);
+        Emsg1(M_ERROR, 0, "bget_msg: unknown signal %d\n", sock->msglen);
         break;
       }
    }
index 26e0a6c02c15e275c5ceb31dcca0f6ed6b6e9efc..5f3f0c85f08ddfd9e6f1fb37e6cda610f8d64a20 100644 (file)
@@ -30,7 +30,7 @@
 #define __BITS_H_
 
 /* number of bytes to hold n bits */
-#define nbytes_for_bits(n) ((((n)-1)>>3)+1) 
+#define nbytes_for_bits(n) ((((n)-1)>>3)+1)
 
 /* test if bit is set */
 #define bit_is_set(b, var) (((var)[(b)>>3] & (1<<((b)&0x7))) != 0)
@@ -50,7 +50,7 @@
    for (i=f; i<=l; i++)  \
       set_bit(i, var); \
 }
+
 /* clear range of bits */
 #define clear_bits(f, l, var) { \
    int i; \
index bf8fe9d457bdfdad2db0d42423f30bc4e108a3f7..f0e21a628d77fbf46638358d5bf3ff71057f663f 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  by Kern Sibbald
  *
- * Adapted and enhanced for Bacula, originally written 
+ * Adapted and enhanced for Bacula, originally written
  * for inclusion in the Apcupsd package
  *
  *   Version $Id$
@@ -109,9 +109,9 @@ static int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes)
       if (nwritten != nbytes) {
         berrno be;
         bsock->b_errno = errno;
-         Qmsg1(bsock->jcr, M_FATAL, 0, _("Attr spool write error. ERR=%s\n"),
+        Qmsg1(bsock->jcr, M_FATAL, 0, _("Attr spool write error. ERR=%s\n"),
               be.strerror());
-         Dmsg2(400, "nwritten=%d nbytes=%d.\n", nwritten, nbytes);
+        Dmsg2(400, "nwritten=%d nbytes=%d.\n", nwritten, nbytes);
         errno = bsock->b_errno;
         return -1;
       }
@@ -151,12 +151,12 @@ static int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes)
    return nbytes - nleft;
 }
 
-/* 
+/*
  * Receive a message from the other end. Each message consists of
  * two packets. The first is a header that contains the size
  * of the data that follows in the second packet.
  * Returns number of bytes read (may return zero)
- * Returns -1 on signal (BNET_SIGNAL) 
+ * Returns -1 on signal (BNET_SIGNAL)
  * Returns -2 on hard end of file (BNET_HARDEOF)
  * Returns -3 on error (BNET_ERROR)
  *
@@ -164,7 +164,7 @@ static int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes)
  *    four return types:
  *    1. Normal data
  *    2. Signal including end of data stream
- *    3. Hard end of file                
+ *    3. Hard end of file
  *    4. Error
  *  Using is_bnet_stop() and is_bnet_error() you can figure this all out.
  */
@@ -217,7 +217,7 @@ int32_t bnet_recv(BSOCK * bsock)
    if (pktsiz < 0 || pktsiz > 1000000) {
       if (pktsiz > 0) {           /* if packet too big */
         Qmsg3(bsock->jcr, M_FATAL, 0,
-               _("Packet size too big from \"%s:%s:%d. Terminating connection.\n"),
+              _("Packet size too big from \"%s:%s:%d. Terminating connection.\n"),
               bsock->who, bsock->host, bsock->port);
         pktsiz = BNET_TERMINATE;  /* hang up */
       }
@@ -271,7 +271,7 @@ int32_t bnet_recv(BSOCK * bsock)
 
 
 /*
- * Return 1 if there are errors on this bsock or it is closed, 
+ * Return 1 if there are errors on this bsock or it is closed,
  *   i.e. stop communicating on this line.
  */
 bool is_bnet_stop(BSOCK * bsock)
@@ -280,7 +280,7 @@ bool is_bnet_stop(BSOCK * bsock)
 }
 
 /*
- * Return number of errors on socket 
+ * Return number of errors on socket
  */
 int is_bnet_error(BSOCK * bsock)
 {
@@ -320,8 +320,8 @@ int bnet_despool_to_bsock(BSOCK * bsock, void update_attr_spool_size(ssize_t siz
         nbytes = fread(bsock->msg, 1, bsock->msglen, bsock->spool_fd);
         if (nbytes != (size_t) bsock->msglen) {
            berrno be;
-            Dmsg2(400, "nbytes=%d msglen=%d\n", nbytes, bsock->msglen);
-            Qmsg1(bsock->jcr, M_FATAL, 0, _("fread attr spool error. ERR=%s\n"),
+           Dmsg2(400, "nbytes=%d msglen=%d\n", nbytes, bsock->msglen);
+           Qmsg1(bsock->jcr, M_FATAL, 0, _("fread attr spool error. ERR=%s\n"),
                  be.strerror());
            update_attr_spool_size(tsize - last);
            return 0;
@@ -381,12 +381,12 @@ bool bnet_send(BSOCK * bsock)
       if (rc < 0) {
         if (!bsock->suppress_error_msgs && !bsock->timed_out) {
            Qmsg4(bsock->jcr, M_ERROR, 0,
-                  _("Write error sending to %s:%s:%d: ERR=%s\n"), bsock->who,
+                 _("Write error sending to %s:%s:%d: ERR=%s\n"), bsock->who,
                  bsock->host, bsock->port, bnet_strerror(bsock));
         }
       } else {
         Qmsg5(bsock->jcr, M_ERROR, 0,
-               _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"), bsock->who,
+              _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"), bsock->who,
               bsock->host, bsock->port, bsock->msglen, rc);
       }
       return false;
@@ -412,12 +412,12 @@ bool bnet_send(BSOCK * bsock)
       if (rc < 0) {
         if (!bsock->suppress_error_msgs) {
            Qmsg4(bsock->jcr, M_ERROR, 0,
-                  _("Write error sending to %s:%s:%d: ERR=%s\n"), bsock->who,
+                 _("Write error sending to %s:%s:%d: ERR=%s\n"), bsock->who,
                  bsock->host, bsock->port, bnet_strerror(bsock));
         }
       } else {
         Qmsg5(bsock->jcr, M_ERROR, 0,
-               _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"),
+              _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"),
               bsock->msglen, bsock->who, bsock->host, bsock->port, rc);
       }
       return false;
@@ -426,7 +426,7 @@ bool bnet_send(BSOCK * bsock)
 }
 
 /*
- * Establish an SSL connection -- server side        
+ * Establish an SSL connection -- server side
  *  Codes that ssl_need and ssl_has can take
  *    BNET_SSL_NONE     I cannot do ssl
  *    BNET_SSL_OK       I can do ssl, but it is not required on my end
@@ -440,7 +440,7 @@ int bnet_ssl_server(BSOCK * bsock, char *password, int ssl_need, int ssl_has)
 }
 
 /*
- * Establish an SSL connection -- client side  
+ * Establish an SSL connection -- client side
  */
 int bnet_ssl_client(BSOCK * bsock, char *password, int ssl_need)
 {
@@ -669,7 +669,7 @@ dlist *bnet_host2ipaddrs(const char *host, int family, const char **errstr)
    return addr_list;
 }
 
-/*     
+/*
  * Open a TCP connection to the UPS network server
  * Returns NULL
  * Returns BSOCK * pointer on success
@@ -686,7 +686,7 @@ static BSOCK *bnet_open(JCR * jcr, const char *name, char *host, char *service,
    const char *errstr;
    int save_errno = 0;
 
-   /* 
+   /*
     * Fill in the structure serv_addr with the address of
     * the server that we want to connect with.
     */
@@ -704,15 +704,15 @@ static BSOCK *bnet_open(JCR * jcr, const char *name, char *host, char *service,
       ipaddr->set_port_net(htons(port));
       char allbuf[256 * 10];
       char curbuf[256];
-      Dmsg2(100, "Current %sAll %s\n", 
-                  ipaddr->build_address_str(curbuf, sizeof(curbuf)), 
+      Dmsg2(100, "Current %sAll %s\n",
+                  ipaddr->build_address_str(curbuf, sizeof(curbuf)),
                   build_addresses_str(addr_list, allbuf, sizeof(allbuf)));
       /* Open a TCP socket */
       if ((sockfd = socket(ipaddr->get_family(), SOCK_STREAM, 0)) < 0) {
         berrno be;
         save_errno = errno;
         *fatal = 1;
-         Pmsg3(000, "Socket open error. proto=%d port=%d. ERR=%s\n", 
+        Pmsg3(000, "Socket open error. proto=%d port=%d. ERR=%s\n",
            ipaddr->get_family(), ipaddr->get_port_host_order(), be.strerror());
         continue;
       }
@@ -721,7 +721,7 @@ static BSOCK *bnet_open(JCR * jcr, const char *name, char *host, char *service,
        */
       if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t)&turnon, sizeof(turnon)) < 0) {
         berrno be;
-         Qmsg1(jcr, M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"),
+        Qmsg1(jcr, M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"),
               be.strerror());
       }
       /* connect to server */
@@ -776,13 +776,13 @@ BSOCK *bnet_connect(JCR * jcr, int retry_interval, int max_retry_time,
       if (i < 0) {
         i = 60 * 5;               /* complain again in 5 minutes */
         if (verbose)
-            Qmsg4(jcr, M_WARNING, 0, "Could not connect to %s on %s:%d. ERR=%s\n\
-Retrying ...\n", name, host, port, be.strerror());
+           Qmsg4(jcr, M_WARNING, 0, "Could not connect to %s on %s:%d. ERR=%s\n"
+"Retrying ...\n", name, host, port, be.strerror());
       }
       bmicrosleep(retry_interval, 0);
       max_retry_time -= retry_interval;
       if (max_retry_time <= 0) {
-         Qmsg4(jcr, M_FATAL, 0, _("Unable to connect to %s on %s:%d. ERR=%s\n"),
+        Qmsg4(jcr, M_FATAL, 0, _("Unable to connect to %s on %s:%d. ERR=%s\n"),
               name, host, port, be.strerror());
         return NULL;
       }
@@ -836,7 +836,7 @@ bool bnet_fsend(BSOCK * bs, const char *fmt, ...)
    return bnet_send(bs);
 }
 
-/* 
+/*
  * Set the network buffer size, suggested size is in size.
  *  Actual size obtained is returned in bs->msglen
  *
@@ -864,20 +864,20 @@ bool bnet_set_buffer_size(BSOCK * bs, uint32_t size, int rw)
       return false;
    }
    if (rw & BNET_SETBUF_READ) {
-      while ((dbuf_size > TAPE_BSIZE) && (setsockopt(bs->fd, SOL_SOCKET, 
+      while ((dbuf_size > TAPE_BSIZE) && (setsockopt(bs->fd, SOL_SOCKET,
              SO_RCVBUF, (sockopt_val_t) & dbuf_size, sizeof(dbuf_size)) < 0)) {
         berrno be;
-         Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), be.strerror());
+        Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), be.strerror());
         dbuf_size -= TAPE_BSIZE;
       }
       Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
       if (dbuf_size != start_size) {
         Qmsg1(bs->jcr, M_WARNING, 0,
-               _("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
+              _("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
       }
       if (dbuf_size % TAPE_BSIZE != 0) {
         Qmsg1(bs->jcr, M_ABORT, 0,
-               _("Network buffer size %d not multiple of tape block size.\n"),
+              _("Network buffer size %d not multiple of tape block size.\n"),
               dbuf_size);
       }
    }
@@ -888,20 +888,20 @@ bool bnet_set_buffer_size(BSOCK * bs, uint32_t size, int rw)
    }
    start_size = dbuf_size;
    if (rw & BNET_SETBUF_WRITE) {
-      while ((dbuf_size > TAPE_BSIZE) && (setsockopt(bs->fd, SOL_SOCKET, 
+      while ((dbuf_size > TAPE_BSIZE) && (setsockopt(bs->fd, SOL_SOCKET,
              SO_SNDBUF, (sockopt_val_t) & dbuf_size, sizeof(dbuf_size)) < 0)) {
         berrno be;
-         Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), be.strerror());
+        Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), be.strerror());
         dbuf_size -= TAPE_BSIZE;
       }
       Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
       if (dbuf_size != start_size) {
         Qmsg1(bs->jcr, M_WARNING, 0,
-               _("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
+              _("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
       }
       if (dbuf_size % TAPE_BSIZE != 0) {
         Qmsg1(bs->jcr, M_ABORT, 0,
-               _("Network buffer size %d not multiple of tape block size.\n"),
+              _("Network buffer size %d not multiple of tape block size.\n"),
               dbuf_size);
       }
    }
@@ -911,7 +911,7 @@ bool bnet_set_buffer_size(BSOCK * bs, uint32_t size, int rw)
 }
 
 /*
- * Send a network "signal" to the other end 
+ * Send a network "signal" to the other end
  *  This consists of sending a negative packet length
  *
  *  Returns: false on failure
@@ -954,7 +954,7 @@ const char *bnet_sig_to_ascii(BSOCK * bs)
 }
 
 
-/* Initialize internal socket structure.  
+/* Initialize internal socket structure.
  *  This probably should be done in net_open
  */
 BSOCK *init_bsock(JCR * jcr, int sockfd, const char *who, const char *host, int port,
@@ -972,7 +972,7 @@ BSOCK *init_bsock(JCR * jcr, int sockfd, const char *who, const char *host, int
    bsock->port = port;
    memcpy(&bsock->client_addr, client_addr, sizeof(bsock->client_addr));
    /*
-    * ****FIXME**** reduce this to a few hours once   
+    * ****FIXME**** reduce this to a few hours once
     *  heartbeats are implemented
     */
    bsock->timeout = 60 * 60 * 6 * 24;  /* 6 days timeout */
index a803866c3c5054cb23a153757bd6822a54369338..d84d241b5f65bc967bfc2cb0f3998141abbb41e8 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "bacula.h"
 
-/* 
+/*
  * Receive a message from the other end. Each message consists of
  * two packets. The first is a header that contains the size
  * of the data that follows in the second packet.
@@ -39,7 +39,7 @@
  * Returns -1 on hard end of file (i.e. network connection close)
  * Returns -2 on error
  */
-int32_t 
+int32_t
 bnet_recv_pkt(BSOCK *bsock, BPKT *pkt, int *version)
 {
    unser_declare;
@@ -50,7 +50,7 @@ bnet_recv_pkt(BSOCK *bsock, BPKT *pkt, int *version)
    unser_uint16(lversion);
    *version = (int)lversion;
 
-   
+
    for ( ; pkt->type != BP_EOF; pkt++) {
       if (pkt->id) {
         ser_int8(BP_ID);
@@ -86,11 +86,11 @@ bnet_recv_pkt(BSOCK *bsock, BPKT *pkt, int *version)
         ser_bytes((char *)pkt->value, pkt->len);
         break;
       default:
-         Emsg1(M_ABORT, 0, _("Unknown BPKT type: %d\n"), pkt->type);
+        Emsg1(M_ABORT, 0, _("Unknown BPKT type: %d\n"), pkt->type);
       }
    }
    unser_end(bsock->msg, 0);
-   
+
 }
 
 /*
@@ -144,7 +144,7 @@ bnet_send_pkt(BSOCK *bsock, BPKT *pkt, int version)
         ser_bytes((char *)pkt->value, pkt->len);
         break;
       default:
-         Emsg1(M_ABORT, 0, _("Unknown BPKT type: %d\n"), pkt->type);
+        Emsg1(M_ABORT, 0, _("Unknown BPKT type: %d\n"), pkt->type);
       }
    }
    ser_end(bsock->msg, 0);
index 7a70051fa63c0950d5b212be174d10639fe869bf..30e00c3eea28012baf4d483351396efa32851db1 100644 (file)
@@ -17,7 +17,7 @@
    MA 02111-1307, USA.
 
  */
- /* 
+ /*
   * Originally written by Kern Sibbald for inclusion in apcupsd,
   *  but heavily modified for Bacula
   *
@@ -57,8 +57,8 @@ void bnet_stop_thread_server(pthread_t tid)
    }
 }
 
-/* 
-       Become Threaded Network Server 
+/*
+       Become Threaded Network Server
     This function is able to handle multiple server ips in
     ipv4 and ipv6 style. The Addresse are give in a comma
     seperated string in bind_addr
@@ -93,26 +93,26 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
       fd_ptr = (s_sockfd *)alloca(sizeof(s_sockfd));
       fd_ptr->port = p->get_port_net_order();
       /*
-       * Open a TCP socket  
+       * Open a TCP socket
        */
       for (tlog= 60; (fd_ptr->fd=socket(p->get_family(), SOCK_STREAM, 0)) < 0; tlog -= 10) {
         if (tlog <= 0) {
            berrno be;
            char curbuf[256];
-            Emsg3(M_ABORT, 0, _("Cannot open stream socket. ERR=%s. Current %s All %s\n"),
+           Emsg3(M_ABORT, 0, _("Cannot open stream socket. ERR=%s. Current %s All %s\n"),
                       be.strerror(),
-                      p->build_address_str(curbuf, sizeof(curbuf)), 
+                      p->build_address_str(curbuf, sizeof(curbuf)),
                       build_addresses_str(addrs, allbuf, sizeof(allbuf)));
         }
         bmicrosleep(10, 0);
       }
       /*
-       * Reuse old sockets 
+       * Reuse old sockets
        */
       if (setsockopt(fd_ptr->fd, SOL_SOCKET, SO_REUSEADDR, (sockopt_val_t)&turnon,
           sizeof(turnon)) < 0) {
         berrno be;
-         Emsg1(M_WARNING, 0, _("Cannot set SO_REUSEADDR on socket: %s\n"),
+        Emsg1(M_WARNING, 0, _("Cannot set SO_REUSEADDR on socket: %s\n"),
               be.strerror());
       }
 
@@ -122,12 +122,12 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
         berrno be;
         if (tlog <= 0) {
            tlog = 2 * 60;         /* Complain every 2 minutes */
-            Emsg2(M_WARNING, 0, _("Cannot bind port %d: ERR=%s. Retrying ...\n"),
+           Emsg2(M_WARNING, 0, _("Cannot bind port %d: ERR=%s. Retrying ...\n"),
                  ntohs(fd_ptr->port), be.strerror());
         }
         bmicrosleep(5, 0);
         if (--tmax <= 0) {
-            Emsg2(M_ABORT, 0, _("Cannot bind port %d: ERR=%s.\n"), ntohs(fd_ptr->port),
+           Emsg2(M_ABORT, 0, _("Cannot bind port %d: ERR=%s.\n"), ntohs(fd_ptr->port),
                  be.strerror());
         }
       }
@@ -140,7 +140,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
       be.set_errno(stat);
       Emsg1(M_ABORT, 0, _("Could not init client queue: ERR=%s\n"), be.strerror());
    }
-   /* 
+   /*
     * Wait for a connection from the client process.
     */
    for (; !quit;) {
@@ -162,7 +162,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
            close(fd_ptr->fd);
            free((void *)fd_ptr);
         }
-         Emsg1(M_FATAL, 0, _("Error in select: %s\n"), be.strerror());
+        Emsg1(M_FATAL, 0, _("Error in select: %s\n"), be.strerror());
         break;
       }
 
@@ -198,7 +198,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
            if (setsockopt(newsockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t)&turnon,
                 sizeof(turnon)) < 0) {
               berrno be;
-               Emsg1(M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"),
+              Emsg1(M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"),
                     be.strerror());
            }
 
@@ -206,17 +206,17 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
            P(mutex);
            sockaddr_to_ascii(&cli_addr, buf, sizeof(buf));
            V(mutex);
-           BSOCK *bs; 
-            bs = init_bsock(NULL, newsockfd, "client", buf, fd_ptr->port, &cli_addr);
+           BSOCK *bs;
+           bs = init_bsock(NULL, newsockfd, "client", buf, fd_ptr->port, &cli_addr);
            if (bs == NULL) {
-               Jmsg0(NULL, M_ABORT, 0, _("Could not create client BSOCK.\n"));
+              Jmsg0(NULL, M_ABORT, 0, _("Could not create client BSOCK.\n"));
            }
 
            /* Queue client to be served */
            if ((stat = workq_add(client_wq, (void *)bs, NULL, 0)) != 0) {
               berrno be;
               be.set_errno(stat);
-               Jmsg1(NULL, M_ABORT, 0, _("Could not add job to client queue: ERR=%s\n"),
+              Jmsg1(NULL, M_ABORT, 0, _("Could not add job to client queue: ERR=%s\n"),
                     be.strerror());
            }
         }
@@ -246,7 +246,7 @@ BSOCK *bnet_bind(int port)
    int turnon = 1;
 
    /*
-    * Open a TCP socket  
+    * Open a TCP socket
     */
    for (tlog = 0; (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0; tlog -= 10) {
       if (errno == EINTR || errno == EAGAIN) {
@@ -254,20 +254,20 @@ BSOCK *bnet_bind(int port)
       }
       if (tlog <= 0) {
         tlog = 2 * 60;
-         Emsg1(M_ERROR, 0, _("Cannot open stream socket: %s\n"), strerror(errno));
+        Emsg1(M_ERROR, 0, _("Cannot open stream socket: %s\n"), strerror(errno));
       }
       bmicrosleep(60, 0);
    }
 
    /*
-    * Reuse old sockets 
+    * Reuse old sockets
     */
    if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (sockopt_val_t)&turnon, sizeof(turnon)) < 0) {
       Emsg1(M_WARNING, 0, _("Cannot set SO_REUSEADDR on socket: %s\n"),
            strerror(errno));
    }
 
-   /* 
+   /*
     * Bind our local address so that the client can send to us.
     */
    bzero((char *)&serv_addr, sizeof(serv_addr));
@@ -283,7 +283,7 @@ BSOCK *bnet_bind(int port)
       }
       if (tlog <= 0) {
         tlog = 2 * 60;
-         Emsg2(M_WARNING, 0, _("Cannot bind port %d: ERR=%s: retrying ...\n"), port,
+        Emsg2(M_WARNING, 0, _("Cannot bind port %d: ERR=%s: retrying ...\n"), port,
               be.strerror());
       }
       bmicrosleep(5, 0);
@@ -294,7 +294,7 @@ BSOCK *bnet_bind(int port)
 }
 
 /*
- * Accept a single connection 
+ * Accept a single connection
  */
 BSOCK *bnet_accept(BSOCK * bsock, char *who)
 {
@@ -309,14 +309,14 @@ BSOCK *bnet_accept(BSOCK * bsock, char *who)
    struct request_info request;
 #endif
 
-   /* 
+   /*
     * Wait for a connection from the client process.
     */
    FD_ZERO(&sockset);
    FD_SET((unsigned)bsock->fd, &sockset);
 
    for (;;) {
-      /* 
+      /*
        * Wait for a connection from a client process.
        */
       ready = sockset;
@@ -325,7 +325,7 @@ BSOCK *bnet_accept(BSOCK * bsock, char *who)
            errno = 0;
            continue;
         }
-         Emsg1(M_FATAL, 0, _("Error in select: %s\n"), strerror(errno));
+        Emsg1(M_FATAL, 0, _("Error in select: %s\n"), strerror(errno));
         newsockfd = -1;
         break;
       }
@@ -376,7 +376,7 @@ BSOCK *bnet_accept(BSOCK * bsock, char *who)
       return NULL;
    } else {
       if (caller == NULL) {
-         caller = "unknown";
+        caller = "unknown";
       }
       len = strlen(caller) + strlen(who) + 3;
       buf = (char *)malloc(len);
index 93238b26e28e258249d313a06eda2de08b1eb528..f7a340034b93010b7d19e88cd547fba2ddb88890 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *   bpipe.c bi-directional pipe
- * 
+ *
  *    Kern Sibbald, November MMII
  *
  *   Version $Id$
@@ -29,7 +29,7 @@
 #include "bacula.h"
 #include "jcr.h"
 
-int execvp_errors[] = {EACCES, ENOEXEC, EFAULT, EINTR, E2BIG, 
+int execvp_errors[] = {EACCES, ENOEXEC, EFAULT, EINTR, E2BIG,
                     ENAMETOOLONG, ENOMEM, ETXTBSY, ENOENT};
 int num_execvp_errors = (int)(sizeof(execvp_errors)/sizeof(int));
 
@@ -41,7 +41,7 @@ static void build_argc_argv(char *cmd, int *bargc, char *bargv[], int max_arg);
  * Run an external program. Optionally wait a specified number
  *   of seconds. Program killed if wait exceeded. We open
  *   a bi-directional pipe so that the user can read from and
- *   write to the program. 
+ *   write to the program.
  */
 BPIPE *open_bpipe(char *prog, int wait, const char *mode)
 {
@@ -161,16 +161,16 @@ int close_wpipe(BPIPE *bpipe)
    return stat;
 }
 
-/* 
- * Close both pipes and free resources  
+/*
+ * Close both pipes and free resources
  *
  *  Returns: 0 on success
  *          berrno on failure
  */
-int close_bpipe(BPIPE *bpipe) 
+int close_bpipe(BPIPE *bpipe)
 {
    int chldstatus = 0;
-   int stat = 0;    
+   int stat = 0;
    int wait_option;
    int remaining_wait;
    pid_t wpid = 0;
@@ -201,35 +201,35 @@ int close_bpipe(BPIPE *bpipe)
       } while (wpid == -1 && (errno == EINTR || errno == EAGAIN));
       if (wpid == bpipe->worker_pid || wpid == -1) {
         stat = errno;
-         Dmsg3(200, "Got break wpid=%d status=%d ERR=%s\n", wpid, chldstatus,
-            wpid==-1?strerror(errno):"none");
+        Dmsg3(200, "Got break wpid=%d status=%d ERR=%s\n", wpid, chldstatus,
+           wpid==-1?strerror(errno):"none");
         break;
       }
       Dmsg3(200, "Got wpid=%d status=%d ERR=%s\n", wpid, chldstatus,
-            wpid==-1?strerror(errno):"none");
+           wpid==-1?strerror(errno):"none");
       if (remaining_wait > 0) {
         bmicrosleep(1, 0);           /* wait one second */
         remaining_wait--;
       } else {
         stat = ETIME;                /* set error status */
         wpid = -1;
-         break;                       /* don't wait any longer */
+        break;                       /* don't wait any longer */
       }
    }
    if (wpid > 0) {
       if (WIFEXITED(chldstatus)) {    /* process exit()ed */
         stat = WEXITSTATUS(chldstatus);
         if (stat != 0) {
-            Dmsg1(200, "Non-zero status %d returned from child.\n", stat);
+           Dmsg1(200, "Non-zero status %d returned from child.\n", stat);
            stat |= b_errno_exit;        /* exit status returned */
         }
-         Dmsg1(200, "child status=%d\n", stat & ~b_errno_exit);
+        Dmsg1(200, "child status=%d\n", stat & ~b_errno_exit);
       } else if (WIFSIGNALED(chldstatus)) {  /* process died */
         stat = WTERMSIG(chldstatus);
-         Dmsg1(200, "Child died from signale %d\n", stat);
+        Dmsg1(200, "Child died from signale %d\n", stat);
         stat |= b_errno_signal;      /* exit signal returned */
       }
-   }      
+   }
    if (bpipe->timer_id) {
       stop_child_timer(bpipe->timer_id);
    }
@@ -244,7 +244,7 @@ int close_bpipe(BPIPE *bpipe)
  *   of seconds. Program killed if wait exceeded. Optionally
  *   return the output from the program (normally a single line).
  *
- * Contrary to my normal calling conventions, this program 
+ * Contrary to my normal calling conventions, this program
  *
  *  Returns: 0 on success
  *          non-zero on error == berrno status
@@ -262,16 +262,16 @@ int run_program(char *prog, int wait, POOLMEM *results)
    }
    if (results) {
       results[0] = 0;
-      fgets(results, sizeof_pool_memory(results), bpipe->rfd);       
+      fgets(results, sizeof_pool_memory(results), bpipe->rfd);
       if (feof(bpipe->rfd)) {
         stat1 = 0;
       } else {
         stat1 = ferror(bpipe->rfd);
       }
       if (stat1 < 0) {
-         Dmsg2(100, "Run program fgets stat=%d ERR=%s\n", stat1, strerror(errno));
+        Dmsg2(100, "Run program fgets stat=%d ERR=%s\n", stat1, strerror(errno));
       } else if (stat1 != 0) {
-         Dmsg1(100, "Run program fgets stat=%d\n", stat1);
+        Dmsg1(100, "Run program fgets stat=%d\n", stat1);
       }
    } else {
       stat1 = 0;
@@ -288,7 +288,7 @@ int run_program(char *prog, int wait, POOLMEM *results)
  */
 static void build_argc_argv(char *cmd, int *bargc, char *bargv[], int max_argv)
 {
-   int i;      
+   int i;
    char *p, *q, quote;
    int argc = 0;
 
@@ -312,16 +312,16 @@ static void build_argc_argv(char *cmd, int *bargc, char *bargv[], int max_argv)
            q++;
            quote = 0;
         } else {
-            while (*q && *q != ' ')
+           while (*q && *q != ' ')
            q++;
         }
         if (*q)
-            *(q++) = '\0';
+           *(q++) = '\0';
         bargv[argc++] = p;
         p = q;
-         while (*p && (*p == ' ' || *p == '\t'))
+        while (*p && (*p == ' ' || *p == '\t'))
            p++;
-         if (*p == '\"' || *p == '\'') {
+        if (*p == '\"' || *p == '\'') {
            quote = *p;
            p++;
         }
index de9c98951f587ca38469444a20ec8fc4ee215304..353dd553f0ae767f45ae8ad51edf574277e69731 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  *   Bi-directional pipe structure
  *
  *   Version $Id$
index be3c928d3d0eb37458c15f7568ba87d3782cd7f7..b8c1614ef624a45666d06d385c74b6e943a47d42 100644 (file)
@@ -43,7 +43,7 @@
 #define _LOCAL_SYS_QUEUE_H_
 
 /*
- * This file defines five types of data structures: singly-linked lists, 
+ * This file defines five types of data structures: singly-linked lists,
  * lists, simple queues, tail queues, and circular queues.
  *
  *
  */
 #define SLIST_HEAD(name, type)                                          \
 struct name {                                                           \
-        struct type *slh_first; /* first element */                     \
+       struct type *slh_first; /* first element */                     \
 }
+
 #define SLIST_HEAD_INITIALIZER(head)                                    \
-        { NULL }
+       { NULL }
+
 /* Conflicts with winnt.h */
 #define bSLIST_ENTRY(type)                                               \
 struct {                                                                \
-        struct type *sle_next;  /* next element */                      \
+       struct type *sle_next;  /* next element */                      \
 }
+
 /*
  * Singly-linked List access methods.
  */
@@ -115,48 +115,48 @@ struct {                                                                \
 #define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
 
 #define SLIST_FOREACH(var, head, field)                                 \
-        for((var) = SLIST_FIRST(head);                                  \
-            (var) != SLIST_END(head);                                   \
-            (var) = SLIST_NEXT(var, field))
+       for((var) = SLIST_FIRST(head);                                  \
+           (var) != SLIST_END(head);                                   \
+           (var) = SLIST_NEXT(var, field))
 
 #define SLIST_FOREACH_SAFE(var, head, field, tvar)                      \
-        for((var) = SLIST_FIRST(head);                                  \
-            (var) != SLIST_END(head) &&                                 \
-            ((tvar) = SLIST_NEXT(var, field), 1);                       \
-            (var) = (tvar))
+       for((var) = SLIST_FIRST(head);                                  \
+           (var) != SLIST_END(head) &&                                 \
+           ((tvar) = SLIST_NEXT(var, field), 1);                       \
+           (var) = (tvar))
 
 /*
  * Singly-linked List functions.
  */
 #define SLIST_INIT(head) {                                              \
-        SLIST_FIRST(head) = SLIST_END(head);                            \
+       SLIST_FIRST(head) = SLIST_END(head);                            \
 }
 
 #define SLIST_INSERT_AFTER(slistelm, elm, field) do {                   \
-        (elm)->field.sle_next = (slistelm)->field.sle_next;             \
-        (slistelm)->field.sle_next = (elm);                             \
+       (elm)->field.sle_next = (slistelm)->field.sle_next;             \
+       (slistelm)->field.sle_next = (elm);                             \
 } while (0)
 
 #define SLIST_INSERT_HEAD(head, elm, field) do {                        \
-        (elm)->field.sle_next = (head)->slh_first;                      \
-        (head)->slh_first = (elm);                                      \
+       (elm)->field.sle_next = (head)->slh_first;                      \
+       (head)->slh_first = (elm);                                      \
 } while (0)
 
 #define SLIST_REMOVE_HEAD(head, field) do {                             \
-        (head)->slh_first = (head)->slh_first->field.sle_next;          \
+       (head)->slh_first = (head)->slh_first->field.sle_next;          \
 } while (0)
 
 #define SLIST_REMOVE(head, elm, type, field) do {                       \
-        if ((head)->slh_first == (elm)) {                               \
-                SLIST_REMOVE_HEAD((head), field);                       \
-        }                                                               \
-        else {                                                          \
-                struct type *curelm = (head)->slh_first;                \
-                while( curelm->field.sle_next != (elm) )                \
-                        curelm = curelm->field.sle_next;                \
-                curelm->field.sle_next =                                \
-                    curelm->field.sle_next->field.sle_next;             \
-        }                                                               \
+       if ((head)->slh_first == (elm)) {                               \
+               SLIST_REMOVE_HEAD((head), field);                       \
+       }                                                               \
+       else {                                                          \
+               struct type *curelm = (head)->slh_first;                \
+               while( curelm->field.sle_next != (elm) )                \
+                       curelm = curelm->field.sle_next;                \
+               curelm->field.sle_next =                                \
+                   curelm->field.sle_next->field.sle_next;             \
+       }                                                               \
 } while (0)
 
 /*
@@ -164,16 +164,16 @@ struct {                                                                \
  */
 #define LIST_HEAD(name, type)                                           \
 struct name {                                                           \
-        struct type *lh_first;  /* first element */                     \
+       struct type *lh_first;  /* first element */                     \
 }
 
 #define LIST_HEAD_INITIALIZER(head)                                     \
-        { NULL }
+       { NULL }
 
 #define LIST_ENTRY(type)                                                \
 struct {                                                                \
-        struct type *le_next;   /* next element */                      \
-        struct type **le_prev;  /* address of previous next element */  \
+       struct type *le_next;   /* next element */                      \
+       struct type **le_prev;  /* address of previous next element */  \
 }
 
 /*
@@ -185,59 +185,59 @@ struct {                                                                \
 #define LIST_NEXT(elm, field)           ((elm)->field.le_next)
 
 #define LIST_FOREACH(var, head, field)                                  \
-        for((var) = LIST_FIRST(head);                                   \
-            (var)!= LIST_END(head);                                     \
-            (var) = LIST_NEXT(var, field))
+       for((var) = LIST_FIRST(head);                                   \
+           (var)!= LIST_END(head);                                     \
+           (var) = LIST_NEXT(var, field))
 
 #define LIST_FOREACH_SAFE(var, head, field, tvar)                       \
-        for((var) = LIST_FIRST(head);                                   \
-            (var)!= LIST_END(head) &&                                   \
-            ((tvar) = LIST_NEXT(var, field), 1);                        \
-            (var) = (tvar))
+       for((var) = LIST_FIRST(head);                                   \
+           (var)!= LIST_END(head) &&                                   \
+           ((tvar) = LIST_NEXT(var, field), 1);                        \
+           (var) = (tvar))
 
 
 /*
  * List functions.
  */
 #define LIST_INIT(head) do {                                            \
-        LIST_FIRST(head) = LIST_END(head);                              \
+       LIST_FIRST(head) = LIST_END(head);                              \
 } while (0)
 
 #define LIST_INSERT_AFTER(listelm, elm, field) do {                     \
-        if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)  \
-                (listelm)->field.le_next->field.le_prev =               \
-                    &(elm)->field.le_next;                              \
-        (listelm)->field.le_next = (elm);                               \
-        (elm)->field.le_prev = &(listelm)->field.le_next;               \
+       if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)  \
+               (listelm)->field.le_next->field.le_prev =               \
+                   &(elm)->field.le_next;                              \
+       (listelm)->field.le_next = (elm);                               \
+       (elm)->field.le_prev = &(listelm)->field.le_next;               \
 } while (0)
 
 #define LIST_INSERT_BEFORE(listelm, elm, field) do {                    \
-        (elm)->field.le_prev = (listelm)->field.le_prev;                \
-        (elm)->field.le_next = (listelm);                               \
-        *(listelm)->field.le_prev = (elm);                              \
-        (listelm)->field.le_prev = &(elm)->field.le_next;               \
+       (elm)->field.le_prev = (listelm)->field.le_prev;                \
+       (elm)->field.le_next = (listelm);                               \
+       *(listelm)->field.le_prev = (elm);                              \
+       (listelm)->field.le_prev = &(elm)->field.le_next;               \
 } while (0)
 
 #define LIST_INSERT_HEAD(head, elm, field) do {                         \
-        if (((elm)->field.le_next = (head)->lh_first) != NULL)          \
-                (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
-        (head)->lh_first = (elm);                                       \
-        (elm)->field.le_prev = &(head)->lh_first;                       \
+       if (((elm)->field.le_next = (head)->lh_first) != NULL)          \
+               (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+       (head)->lh_first = (elm);                                       \
+       (elm)->field.le_prev = &(head)->lh_first;                       \
 } while (0)
 
 #define LIST_REMOVE(elm, field) do {                                    \
-        if ((elm)->field.le_next != NULL)                               \
-                (elm)->field.le_next->field.le_prev =                   \
-                    (elm)->field.le_prev;                               \
-        *(elm)->field.le_prev = (elm)->field.le_next;                   \
+       if ((elm)->field.le_next != NULL)                               \
+               (elm)->field.le_next->field.le_prev =                   \
+                   (elm)->field.le_prev;                               \
+       *(elm)->field.le_prev = (elm)->field.le_next;                   \
 } while (0)
 
 #define LIST_REPLACE(elm, elm2, field) do {                             \
-        if (((elm2)->field.le_next = (elm)->field.le_next) != NULL)     \
-                (elm2)->field.le_next->field.le_prev =                  \
-                    &(elm2)->field.le_next;                             \
-        (elm2)->field.le_prev = (elm)->field.le_prev;                   \
-        *(elm2)->field.le_prev = (elm2);                                \
+       if (((elm2)->field.le_next = (elm)->field.le_next) != NULL)     \
+               (elm2)->field.le_next->field.le_prev =                  \
+                   &(elm2)->field.le_next;                             \
+       (elm2)->field.le_prev = (elm)->field.le_prev;                   \
+       *(elm2)->field.le_prev = (elm2);                                \
 } while (0)
 
 /*
@@ -245,16 +245,16 @@ struct {                                                                \
  */
 #define SIMPLEQ_HEAD(name, type)                                        \
 struct name {                                                           \
-        struct type *sqh_first; /* first element */                     \
-        struct type **sqh_last; /* addr of last next element */         \
+       struct type *sqh_first; /* first element */                     \
+       struct type **sqh_last; /* addr of last next element */         \
 }
 
 #define SIMPLEQ_HEAD_INITIALIZER(head)                                  \
-        { NULL, &(head).sqh_first }
+       { NULL, &(head).sqh_first }
 
 #define SIMPLEQ_ENTRY(type)                                             \
 struct {                                                                \
-        struct type *sqe_next;  /* next element */                      \
+       struct type *sqe_next;  /* next element */                      \
 }
 
 /*
@@ -266,45 +266,45 @@ struct {                                                                \
 #define SIMPLEQ_NEXT(elm, field)    ((elm)->field.sqe_next)
 
 #define SIMPLEQ_FOREACH(var, head, field)                               \
-        for((var) = SIMPLEQ_FIRST(head);                                \
-            (var) != SIMPLEQ_END(head);                                 \
-            (var) = SIMPLEQ_NEXT(var, field))
+       for((var) = SIMPLEQ_FIRST(head);                                \
+           (var) != SIMPLEQ_END(head);                                 \
+           (var) = SIMPLEQ_NEXT(var, field))
 
 #define SIMPLEQ_FOREACH_SAFE(var, head, field, tvar)                    \
-        for((var) = SIMPLEQ_FIRST(head);                                \
-            (var) != SIMPLEQ_END(head) &&                               \
-            ((tvar) = SIMPLEQ_NEXT(var, field), 1);                     \
-            (var) = (tvar))
+       for((var) = SIMPLEQ_FIRST(head);                                \
+           (var) != SIMPLEQ_END(head) &&                               \
+           ((tvar) = SIMPLEQ_NEXT(var, field), 1);                     \
+           (var) = (tvar))
 
 /*
  * Simple queue functions.
  */
 #define SIMPLEQ_INIT(head) do {                                         \
-        (head)->sqh_first = NULL;                                       \
-        (head)->sqh_last = &(head)->sqh_first;                          \
+       (head)->sqh_first = NULL;                                       \
+       (head)->sqh_last = &(head)->sqh_first;                          \
 } while (0)
 
 #define SIMPLEQ_INSERT_HEAD(head, elm, field) do {                      \
-        if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)        \
-                (head)->sqh_last = &(elm)->field.sqe_next;              \
-        (head)->sqh_first = (elm);                                      \
+       if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)        \
+               (head)->sqh_last = &(elm)->field.sqe_next;              \
+       (head)->sqh_first = (elm);                                      \
 } while (0)
 
 #define SIMPLEQ_INSERT_TAIL(head, elm, field) do {                      \
-        (elm)->field.sqe_next = NULL;                                   \
-        *(head)->sqh_last = (elm);                                      \
-        (head)->sqh_last = &(elm)->field.sqe_next;                      \
+       (elm)->field.sqe_next = NULL;                                   \
+       *(head)->sqh_last = (elm);                                      \
+       (head)->sqh_last = &(elm)->field.sqe_next;                      \
 } while (0)
 
 #define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {            \
-        if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
-                (head)->sqh_last = &(elm)->field.sqe_next;              \
-        (listelm)->field.sqe_next = (elm);                              \
+       if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+               (head)->sqh_last = &(elm)->field.sqe_next;              \
+       (listelm)->field.sqe_next = (elm);                              \
 } while (0)
 
 #define SIMPLEQ_REMOVE_HEAD(head, elm, field) do {                      \
-        if (((head)->sqh_first = (elm)->field.sqe_next) == NULL)        \
-                (head)->sqh_last = &(head)->sqh_first;                  \
+       if (((head)->sqh_first = (elm)->field.sqe_next) == NULL)        \
+               (head)->sqh_last = &(head)->sqh_first;                  \
 } while (0)
 
 /*
@@ -312,114 +312,114 @@ struct {                                                                \
  */
 #define TAILQ_HEAD(name, type)                                          \
 struct name {                                                           \
-        struct type *tqh_first; /* first element */                     \
-        struct type **tqh_last; /* addr of last next element */         \
+       struct type *tqh_first; /* first element */                     \
+       struct type **tqh_last; /* addr of last next element */         \
 }
 
 #define TAILQ_HEAD_INITIALIZER(head)                                    \
-        { NULL, &(head).tqh_first }
+       { NULL, &(head).tqh_first }
 
 #define TAILQ_ENTRY(type)                                               \
 struct {                                                                \
-        struct type *tqe_next;  /* next element */                      \
-        struct type **tqe_prev; /* address of previous next element */  \
+       struct type *tqe_next;  /* next element */                      \
+       struct type **tqe_prev; /* address of previous next element */  \
 }
 
-/* 
- * tail queue access methods 
+/*
+ * tail queue access methods
  */
 #define TAILQ_FIRST(head)               ((head)->tqh_first)
 #define TAILQ_END(head)                 NULL
 #define TAILQ_NEXT(elm, field)          ((elm)->field.tqe_next)
 #define TAILQ_LAST(head, headname)                                      \
-        (*(((struct headname *)((head)->tqh_last))->tqh_last))
+       (*(((struct headname *)((head)->tqh_last))->tqh_last))
 /* XXX */
 #define TAILQ_PREV(elm, headname, field)                                \
-        (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+       (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
 #define TAILQ_EMPTY(head)                                               \
-        (TAILQ_FIRST(head) == TAILQ_END(head))
+       (TAILQ_FIRST(head) == TAILQ_END(head))
 
 #define TAILQ_FOREACH(var, head, field)                                 \
-        for((var) = TAILQ_FIRST(head);                                  \
-            (var) != TAILQ_END(head);                                   \
-            (var) = TAILQ_NEXT(var, field))
+       for((var) = TAILQ_FIRST(head);                                  \
+           (var) != TAILQ_END(head);                                   \
+           (var) = TAILQ_NEXT(var, field))
 
 #define TAILQ_FOREACH_SAFE(var, head, field, tvar)                      \
-        for((var) = TAILQ_FIRST(head);                                  \
-            (var) != TAILQ_END(head) &&                                 \
-            ((tvar) = TAILQ_NEXT(var, field), 1);                       \
-            (var) = (tvar))
+       for((var) = TAILQ_FIRST(head);                                  \
+           (var) != TAILQ_END(head) &&                                 \
+           ((tvar) = TAILQ_NEXT(var, field), 1);                       \
+           (var) = (tvar))
 
 #define TAILQ_FOREACH_REVERSE(var, head, field, headname)               \
-        for((var) = TAILQ_LAST(head, headname);                         \
-            (var) != TAILQ_END(head);                                   \
-            (var) = TAILQ_PREV(var, headname, field))
+       for((var) = TAILQ_LAST(head, headname);                         \
+           (var) != TAILQ_END(head);                                   \
+           (var) = TAILQ_PREV(var, headname, field))
 
 #define TAILQ_FOREACH_REVERSE_SAFE(var, head, field, headname, tvar)    \
-        for((var) = TAILQ_LAST(head, headname);                         \
-            (var) != TAILQ_END(head) &&                                 \
-            ((tvar) = TAILQ_PREV(var, headname, field), 1);             \
-            (var) = (tvar))
+       for((var) = TAILQ_LAST(head, headname);                         \
+           (var) != TAILQ_END(head) &&                                 \
+           ((tvar) = TAILQ_PREV(var, headname, field), 1);             \
+           (var) = (tvar))
 
 /*
  * Tail queue functions.
  */
 #define TAILQ_INIT(head) do {                                           \
-        (head)->tqh_first = NULL;                                       \
-        (head)->tqh_last = &(head)->tqh_first;                          \
+       (head)->tqh_first = NULL;                                       \
+       (head)->tqh_last = &(head)->tqh_first;                          \
 } while (0)
 
 #define TAILQ_INSERT_HEAD(head, elm, field) do {                        \
-        if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)        \
-                (head)->tqh_first->field.tqe_prev =                     \
-                    &(elm)->field.tqe_next;                             \
-        else                                                            \
-                (head)->tqh_last = &(elm)->field.tqe_next;              \
-        (head)->tqh_first = (elm);                                      \
-        (elm)->field.tqe_prev = &(head)->tqh_first;                     \
+       if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)        \
+               (head)->tqh_first->field.tqe_prev =                     \
+                   &(elm)->field.tqe_next;                             \
+       else                                                            \
+               (head)->tqh_last = &(elm)->field.tqe_next;              \
+       (head)->tqh_first = (elm);                                      \
+       (elm)->field.tqe_prev = &(head)->tqh_first;                     \
 } while (0)
 
 #define TAILQ_INSERT_TAIL(head, elm, field) do {                        \
-        (elm)->field.tqe_next = NULL;                                   \
-        (elm)->field.tqe_prev = (head)->tqh_last;                       \
-        *(head)->tqh_last = (elm);                                      \
-        (head)->tqh_last = &(elm)->field.tqe_next;                      \
+       (elm)->field.tqe_next = NULL;                                   \
+       (elm)->field.tqe_prev = (head)->tqh_last;                       \
+       *(head)->tqh_last = (elm);                                      \
+       (head)->tqh_last = &(elm)->field.tqe_next;                      \
 } while (0)
 
 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {              \
-        if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
-                (elm)->field.tqe_next->field.tqe_prev =                 \
-                    &(elm)->field.tqe_next;                             \
-        else                                                            \
-                (head)->tqh_last = &(elm)->field.tqe_next;              \
-        (listelm)->field.tqe_next = (elm);                              \
-        (elm)->field.tqe_prev = &(listelm)->field.tqe_next;             \
+       if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+               (elm)->field.tqe_next->field.tqe_prev =                 \
+                   &(elm)->field.tqe_next;                             \
+       else                                                            \
+               (head)->tqh_last = &(elm)->field.tqe_next;              \
+       (listelm)->field.tqe_next = (elm);                              \
+       (elm)->field.tqe_prev = &(listelm)->field.tqe_next;             \
 } while (0)
 
 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do {                   \
-        (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \
-        (elm)->field.tqe_next = (listelm);                              \
-        *(listelm)->field.tqe_prev = (elm);                             \
-        (listelm)->field.tqe_prev = &(elm)->field.tqe_next;             \
+       (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \
+       (elm)->field.tqe_next = (listelm);                              \
+       *(listelm)->field.tqe_prev = (elm);                             \
+       (listelm)->field.tqe_prev = &(elm)->field.tqe_next;             \
 } while (0)
 
 #define TAILQ_REMOVE(head, elm, field) do {                             \
-        if (((elm)->field.tqe_next) != NULL)                            \
-                (elm)->field.tqe_next->field.tqe_prev =                 \
-                    (elm)->field.tqe_prev;                              \
-        else                                                            \
-                (head)->tqh_last = (elm)->field.tqe_prev;               \
-        *(elm)->field.tqe_prev = (elm)->field.tqe_next;                 \
+       if (((elm)->field.tqe_next) != NULL)                            \
+               (elm)->field.tqe_next->field.tqe_prev =                 \
+                   (elm)->field.tqe_prev;                              \
+       else                                                            \
+               (head)->tqh_last = (elm)->field.tqe_prev;               \
+       *(elm)->field.tqe_prev = (elm)->field.tqe_next;                 \
 } while (0)
 
 #define TAILQ_REPLACE(head, elm, elm2, field) do {                      \
-        if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL)   \
-                (elm2)->field.tqe_next->field.tqe_prev =                \
-                    &(elm2)->field.tqe_next;                            \
-        else                                                            \
-                (head)->tqh_last = &(elm2)->field.tqe_next;             \
-        (elm2)->field.tqe_prev = (elm)->field.tqe_prev;                 \
-        *(elm2)->field.tqe_prev = (elm2);                               \
+       if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL)   \
+               (elm2)->field.tqe_next->field.tqe_prev =                \
+                   &(elm2)->field.tqe_next;                            \
+       else                                                            \
+               (head)->tqh_last = &(elm2)->field.tqe_next;             \
+       (elm2)->field.tqe_prev = (elm)->field.tqe_prev;                 \
+       *(elm2)->field.tqe_prev = (elm2);                               \
 } while (0)
 
 /*
@@ -427,21 +427,21 @@ struct {                                                                \
  */
 #define CIRCLEQ_HEAD(name, type)                                        \
 struct name {                                                           \
-        struct type *cqh_first;         /* first element */             \
-        struct type *cqh_last;          /* last element */              \
+       struct type *cqh_first;         /* first element */             \
+       struct type *cqh_last;          /* last element */              \
 }
 
 #define CIRCLEQ_HEAD_INITIALIZER(head)                                  \
-        { CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
+       { CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
 
 #define CIRCLEQ_ENTRY(type)                                             \
 struct {                                                                \
-        struct type *cqe_next;          /* next element */              \
-        struct type *cqe_prev;          /* previous element */          \
+       struct type *cqe_next;          /* next element */              \
+       struct type *cqe_prev;          /* previous element */          \
 }
 
 /*
- * Circular queue access methods 
+ * Circular queue access methods
  */
 #define CIRCLEQ_FIRST(head)             ((head)->cqh_first)
 #define CIRCLEQ_LAST(head)              ((head)->cqh_last)
@@ -449,102 +449,102 @@ struct {                                                                \
 #define CIRCLEQ_NEXT(elm, field)        ((elm)->field.cqe_next)
 #define CIRCLEQ_PREV(elm, field)        ((elm)->field.cqe_prev)
 #define CIRCLEQ_EMPTY(head)                                             \
-        (CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
+       (CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
 
 #define CIRCLEQ_FOREACH(var, head, field)                               \
-        for((var) = CIRCLEQ_FIRST(head);                                \
-            (var) != CIRCLEQ_END(head);                                 \
-            (var) = CIRCLEQ_NEXT(var, field))
+       for((var) = CIRCLEQ_FIRST(head);                                \
+           (var) != CIRCLEQ_END(head);                                 \
+           (var) = CIRCLEQ_NEXT(var, field))
 
 #define CIRCLEQ_FOREACH_SAFE(var, head, field, tvar)                    \
-        for((var) = CIRCLEQ_FIRST(head);                                \
-            (var) != CIRCLEQ_END(head) &&                               \
-            ((tvar) = CIRCLEQ_NEXT(var, field), 1);                     \
-            (var) = (tvar))
+       for((var) = CIRCLEQ_FIRST(head);                                \
+           (var) != CIRCLEQ_END(head) &&                               \
+           ((tvar) = CIRCLEQ_NEXT(var, field), 1);                     \
+           (var) = (tvar))
 
 #define CIRCLEQ_FOREACH_REVERSE(var, head, field)                       \
-        for((var) = CIRCLEQ_LAST(head);                                 \
-            (var) != CIRCLEQ_END(head);                                 \
-            (var) = CIRCLEQ_PREV(var, field))
+       for((var) = CIRCLEQ_LAST(head);                                 \
+           (var) != CIRCLEQ_END(head);                                 \
+           (var) = CIRCLEQ_PREV(var, field))
 
 #define CIRCLEQ_FOREACH_REVERSE_SAFE(var, head, field, tvar)            \
-        for((var) = CIRCLEQ_LAST(head);                                 \
-            (var) != CIRCLEQ_END(head) &&                               \
-            ((tvar) = CIRCLEQ_PREV(var, field), 1);                     \
-            (var) = (tvar))
+       for((var) = CIRCLEQ_LAST(head);                                 \
+           (var) != CIRCLEQ_END(head) &&                               \
+           ((tvar) = CIRCLEQ_PREV(var, field), 1);                     \
+           (var) = (tvar))
 
 /*
  * Circular queue functions.
  */
 #define CIRCLEQ_INIT(head) do {                                         \
-        (head)->cqh_first = CIRCLEQ_END(head);                          \
-        (head)->cqh_last = CIRCLEQ_END(head);                           \
+       (head)->cqh_first = CIRCLEQ_END(head);                          \
+       (head)->cqh_last = CIRCLEQ_END(head);                           \
 } while (0)
 
 #define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {            \
-        (elm)->field.cqe_next = (listelm)->field.cqe_next;              \
-        (elm)->field.cqe_prev = (listelm);                              \
-        if ((listelm)->field.cqe_next == CIRCLEQ_END(head))             \
-                (head)->cqh_last = (elm);                               \
-        else                                                            \
-                (listelm)->field.cqe_next->field.cqe_prev = (elm);      \
-        (listelm)->field.cqe_next = (elm);                              \
+       (elm)->field.cqe_next = (listelm)->field.cqe_next;              \
+       (elm)->field.cqe_prev = (listelm);                              \
+       if ((listelm)->field.cqe_next == CIRCLEQ_END(head))             \
+               (head)->cqh_last = (elm);                               \
+       else                                                            \
+               (listelm)->field.cqe_next->field.cqe_prev = (elm);      \
+       (listelm)->field.cqe_next = (elm);                              \
 } while (0)
 
 #define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {           \
-        (elm)->field.cqe_next = (listelm);                              \
-        (elm)->field.cqe_prev = (listelm)->field.cqe_prev;              \
-        if ((listelm)->field.cqe_prev == CIRCLEQ_END(head))             \
-                (head)->cqh_first = (elm);                              \
-        else                                                            \
-                (listelm)->field.cqe_prev->field.cqe_next = (elm);      \
-        (listelm)->field.cqe_prev = (elm);                              \
+       (elm)->field.cqe_next = (listelm);                              \
+       (elm)->field.cqe_prev = (listelm)->field.cqe_prev;              \
+       if ((listelm)->field.cqe_prev == CIRCLEQ_END(head))             \
+               (head)->cqh_first = (elm);                              \
+       else                                                            \
+               (listelm)->field.cqe_prev->field.cqe_next = (elm);      \
+       (listelm)->field.cqe_prev = (elm);                              \
 } while (0)
 
 #define CIRCLEQ_INSERT_HEAD(head, elm, field) do {                      \
-        (elm)->field.cqe_next = (head)->cqh_first;                      \
-        (elm)->field.cqe_prev = CIRCLEQ_END(head);                      \
-        if ((head)->cqh_last == CIRCLEQ_END(head))                      \
-                (head)->cqh_last = (elm);                               \
-        else                                                            \
-                (head)->cqh_first->field.cqe_prev = (elm);              \
-        (head)->cqh_first = (elm);                                      \
+       (elm)->field.cqe_next = (head)->cqh_first;                      \
+       (elm)->field.cqe_prev = CIRCLEQ_END(head);                      \
+       if ((head)->cqh_last == CIRCLEQ_END(head))                      \
+               (head)->cqh_last = (elm);                               \
+       else                                                            \
+               (head)->cqh_first->field.cqe_prev = (elm);              \
+       (head)->cqh_first = (elm);                                      \
 } while (0)
 
 #define CIRCLEQ_INSERT_TAIL(head, elm, field) do {                      \
-        (elm)->field.cqe_next = CIRCLEQ_END(head);                      \
-        (elm)->field.cqe_prev = (head)->cqh_last;                       \
-        if ((head)->cqh_first == CIRCLEQ_END(head))                     \
-                (head)->cqh_first = (elm);                              \
-        else                                                            \
-                (head)->cqh_last->field.cqe_next = (elm);               \
-        (head)->cqh_last = (elm);                                       \
+       (elm)->field.cqe_next = CIRCLEQ_END(head);                      \
+       (elm)->field.cqe_prev = (head)->cqh_last;                       \
+       if ((head)->cqh_first == CIRCLEQ_END(head))                     \
+               (head)->cqh_first = (elm);                              \
+       else                                                            \
+               (head)->cqh_last->field.cqe_next = (elm);               \
+       (head)->cqh_last = (elm);                                       \
 } while (0)
 
 #define CIRCLEQ_REMOVE(head, elm, field) do {                           \
-        if ((elm)->field.cqe_next == CIRCLEQ_END(head))                 \
-                (head)->cqh_last = (elm)->field.cqe_prev;               \
-        else                                                            \
-                (elm)->field.cqe_next->field.cqe_prev =                 \
-                    (elm)->field.cqe_prev;                              \
-        if ((elm)->field.cqe_prev == CIRCLEQ_END(head))                 \
-                (head)->cqh_first = (elm)->field.cqe_next;              \
-        else                                                            \
-                (elm)->field.cqe_prev->field.cqe_next =                 \
-                    (elm)->field.cqe_next;                              \
+       if ((elm)->field.cqe_next == CIRCLEQ_END(head))                 \
+               (head)->cqh_last = (elm)->field.cqe_prev;               \
+       else                                                            \
+               (elm)->field.cqe_next->field.cqe_prev =                 \
+                   (elm)->field.cqe_prev;                              \
+       if ((elm)->field.cqe_prev == CIRCLEQ_END(head))                 \
+               (head)->cqh_first = (elm)->field.cqe_next;              \
+       else                                                            \
+               (elm)->field.cqe_prev->field.cqe_next =                 \
+                   (elm)->field.cqe_next;                              \
 } while (0)
 
 #define CIRCLEQ_REPLACE(head, elm, elm2, field) do {                    \
-        if (((elm2)->field.cqe_next = (elm)->field.cqe_next) ==         \
-            CIRCLEQ_END(head))                                          \
-                (head).cqh_last = (elm2);                               \
-        else                                                            \
-                (elm2)->field.cqe_next->field.cqe_prev = (elm2);        \
-        if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) ==         \
-            CIRCLEQ_END(head))                                          \
-                (head).cqh_first = (elm2);                              \
-        else                                                            \
-                (elm2)->field.cqe_prev->field.cqe_next = (elm2);        \
+       if (((elm2)->field.cqe_next = (elm)->field.cqe_next) ==         \
+           CIRCLEQ_END(head))                                          \
+               (head).cqh_last = (elm2);                               \
+       else                                                            \
+               (elm2)->field.cqe_next->field.cqe_prev = (elm2);        \
+       if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) ==         \
+           CIRCLEQ_END(head))                                          \
+               (head).cqh_first = (elm2);                              \
+       else                                                            \
+               (elm2)->field.cqe_prev->field.cqe_next = (elm2);        \
 } while (0)
 
 #endif  /* !_LOCAL_SYS_QUEUE_H_ */
index 063290481305289b70abff7cb573eca15d1097b6..ade0e4b8db2b14658051f5f1bad536b6ffc4945b 100644 (file)
@@ -4,7 +4,7 @@
  * To avoid problems with several return arguments, we
  * pass a packet.
  *
- *  BSHM definition is in bshm.h  
+ *  BSHM definition is in bshm.h
  *
  *  By Kern Sibbald, May MM
  *
@@ -66,20 +66,20 @@ void shm_create(BSHM *shm)
    Dmsg1(110, "shm_create size=%d\n", shm->size);
    for (i=0; i<MAX_TRIES; i++) {
       if ((shmid = shmget(shmkey, shm->size, shm->perms | IPC_CREAT)) < 0) {
-         Emsg1(M_WARN, 0, "shmget failure key = %x\n", shmkey);
+        Emsg1(M_WARN, 0, "shmget failure key = %x\n", shmkey);
         shmkey++;
         continue;
       }
       not_found = FALSE;
       break;
    }
-   if (not_found) 
+   if (not_found)
       Emsg2(M_ABORT, 0, "Could not get %d bytes of shared memory: %s\n", shm->size, strerror(errno));
    shm->shmkey = shmkey;
    shm->shmid = shmid;
    Dmsg2(110, "shm_create return key=%x id=%d\n", shmkey, shmid);
    shmkey++;                         /* leave set for next time */
-#else 
+#else
    shm->shmbuf = NULL;
    shm->shmkey = 0;                  /* reference count */
 #endif
@@ -96,7 +96,7 @@ void *shm_open(BSHM *shm)
    if ((shmid = shmget(shm->shmkey, shm->size, 0)) < 0)
       Emsg2(M_ABORT, 0, "Could not get %d bytes of shared memory: %s\n", shm->size, strerror(errno));
    Dmsg1(110, "shm_open shmat with id=%d\n", shmid);
-   shmbuf = shmat(shmid, NULL, 0);     
+   shmbuf = shmat(shmid, NULL, 0);
    Dmsg1(110, "shm_open buf=%x\n", shmbuf);
    if (shmbuf == (char *) -1)
       Emsg1(M_ABORT, 0, "Could not attach shared memory: %s\n", strerror(errno));
@@ -120,7 +120,7 @@ void shm_close(BSHM *shm)
 #ifdef NEED_SHARED_MEMORY
    if (shm->size) {
       if (shmdt(shm->shmbuf) < 0) {
-         Emsg1(M_ERROR, 0, "Error detaching shared memory: %s\n", strerror(errno));
+        Emsg1(M_ERROR, 0, "Error detaching shared memory: %s\n", strerror(errno));
       }
    }
 #else
@@ -136,7 +136,7 @@ void shm_destroy(BSHM *shm)
 #ifdef NEED_SHARED_MEMORY
    if (shm->size) {
       if (shmctl(shm->shmid, IPC_RMID, NULL) < 0) {
-         Emsg1(M_ERROR, 0, "Could not destroy shared memory: %s\n", strerror(errno));
+        Emsg1(M_ERROR, 0, "Could not destroy shared memory: %s\n", strerror(errno));
       }
    }
 #else
index 71af6a700cc66661c54dc8399d4ae01e1ece80c2..da3f9ce82bc537d7662a25e3d72159535d068665 100644 (file)
@@ -56,7 +56,7 @@ struct BSOCK {
    FILE *spool_fd;                    /* spooling file */
    JCR *jcr;                          /* jcr or NULL for error msgs */
    struct sockaddr client_addr;    /* client's IP address */
-};      
+};
 
 /* Signal definitions for use in bnet_sig() */
 enum {
@@ -95,11 +95,11 @@ typedef struct s_bpkt {
    void *value;                       /* pointer to value */
 } BPKT;
 
-/*  
+/*
  * These are the data types that can be sent.
  * For all values other than string, the storage space
  *  is assumed to be allocated in the receiving packet.
- *  For BP_STRING if the *value is non-zero, it is a        
+ *  For BP_STRING if the *value is non-zero, it is a
  *  pointer to a POOLMEM buffer, and the Memory Pool
  *  routines will be used to assure that the length is
  *  adequate. NOTE!!! This pointer will be changed
index 088faad840b893ee94646517b671ce1f21977193..bfd167accfd3cd86ead6d67a73eeeb8637dbb7cc 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Miscellaneous Bacula memory and thread safe routines
  *   Generally, these are interfaces to system or standard
- *   library routines. 
- * 
+ *   library routines.
+ *
  *  Bacula utility functions are in util.c
  *
  *   Version $Id$
@@ -126,7 +126,7 @@ void *bcalloc (size_t size1, size_t size2)
 /*
  * Implement snprintf
  */
-int bsnprintf(char *str, int32_t size, const char *fmt,  ...) 
+int bsnprintf(char *str, int32_t size, const char *fmt,  ...)
 {
    va_list   arg_ptr;
    int len;
@@ -171,7 +171,7 @@ struct tm *localtime_r(const time_t *timep, struct tm *tm)
 {
     static pthread_mutex_t mutex;
     static bool first = true;
-    struct tm *ltm, 
+    struct tm *ltm,
 
     if (first) {
        pthread_mutex_init(&mutex, NULL);
@@ -258,12 +258,12 @@ void _p(char *file, int line, pthread_mutex_t *m)
       e_msg(file, line, M_ERROR, 0, _("Possible mutex deadlock.\n"));
       /* We didn't get the lock, so do it definitely now */
       if ((errstat=pthread_mutex_lock(m))) {
-         e_msg(file, line, M_ABORT, 0, _("Mutex lock failure. ERR=%s\n"),
+        e_msg(file, line, M_ABORT, 0, _("Mutex lock failure. ERR=%s\n"),
               strerror(errstat));
       } else {
-         e_msg(file, line, M_ERROR, 0, _("Possible mutex deadlock resolved.\n"));
+        e_msg(file, line, M_ERROR, 0, _("Possible mutex deadlock resolved.\n"));
       }
-        
+
    }
 }
 
@@ -315,14 +315,14 @@ void create_pid_file(char *dir, const char *progname, int port)
    if (stat(fname, &statp) == 0) {
       /* File exists, see what we have */
       *pidbuf = 0;
-      if ((pidfd = open(fname, O_RDONLY|O_BINARY, 0)) < 0 || 
+      if ((pidfd = open(fname, O_RDONLY|O_BINARY, 0)) < 0 ||
           read(pidfd, &pidbuf, sizeof(pidbuf)) < 0 ||
-           sscanf(pidbuf, "%d", &oldpid) != 1) {
-         Emsg2(M_ERROR_TERM, 0, _("Cannot open pid file. %s ERR=%s\n"), fname, strerror(errno));
+          sscanf(pidbuf, "%d", &oldpid) != 1) {
+        Emsg2(M_ERROR_TERM, 0, _("Cannot open pid file. %s ERR=%s\n"), fname, strerror(errno));
       }
       /* See if other Bacula is still alive */
       if (kill(oldpid, 0) != -1 || errno != ESRCH) {
-         Emsg3(M_ERROR_TERM, 0, _("%s is already running. pid=%d\nCheck file %s\n"),
+        Emsg3(M_ERROR_TERM, 0, _("%s is already running. pid=%d\nCheck file %s\n"),
               progname, oldpid, fname);
       }
       /* He is not alive, so take over file ownership */
@@ -369,7 +369,7 @@ struct s_state_hdr {
    uint64_t reserved[20];
 };
 
-static struct s_state_hdr state_hdr = { 
+static struct s_state_hdr state_hdr = {
    "Bacula State\n",
    3,
    0
@@ -390,17 +390,17 @@ void read_state_file(char *dir, const char *progname, int port)
    /* If file exists, see what we have */
 // Dmsg1(10, "O_BINARY=%d\n", O_BINARY);
    if ((sfd = open(fname, O_RDONLY|O_BINARY, 0)) < 0) {
-      Dmsg3(010, "Could not open state file. sfd=%d size=%d: ERR=%s\n", 
+      Dmsg3(010, "Could not open state file. sfd=%d size=%d: ERR=%s\n",
                    sfd, sizeof(hdr), strerror(errno));
           goto bail_out;
    }
    if ((stat=read(sfd, &hdr, hdr_size)) != hdr_size) {
-      Dmsg4(010, "Could not read state file. sfd=%d stat=%d size=%d: ERR=%s\n", 
+      Dmsg4(010, "Could not read state file. sfd=%d stat=%d size=%d: ERR=%s\n",
                    sfd, (int)stat, hdr_size, strerror(errno));
       goto bail_out;
    }
    if (hdr.version != state_hdr.version) {
-      Dmsg2(010, "Bad hdr version. Wanted %d got %d\n", 
+      Dmsg2(010, "Bad hdr version. Wanted %d got %d\n",
         state_hdr.version, hdr.version);
    }
    hdr.id[13] = 0;
@@ -438,12 +438,12 @@ void write_state_file(char *dir, const char *progname, int port)
    }
 // Dmsg1(010, "Wrote header of %d bytes\n", sizeof(state_hdr));
    state_hdr.last_jobs_addr = sizeof(state_hdr);
-   state_hdr.reserved[0] = write_last_jobs_list(sfd, state_hdr.last_jobs_addr);   
+   state_hdr.reserved[0] = write_last_jobs_list(sfd, state_hdr.last_jobs_addr);
 // Dmsg1(010, "write last job end = %d\n", (int)state_hdr.reserved[0]);
    if (lseek(sfd, 0, SEEK_SET) < 0) {
       Dmsg1(000, "lseek error: ERR=%s\n", strerror(errno));
       goto bail_out;
-   }  
+   }
    if (write(sfd, &state_hdr, sizeof(state_hdr)) != sizeof(state_hdr)) {
       Pmsg1(000, "Write final hdr error: ERR=%s\n", strerror(errno));
    }
@@ -467,14 +467,14 @@ void drop(char *uid, char *gid)
       gid_t gr_list[1];
 
       if ((group = getgrnam(gid)) == NULL) {
-         Emsg1(M_ERROR_TERM, 0, _("Could not find specified group: %s\n"), gid);
+        Emsg1(M_ERROR_TERM, 0, _("Could not find specified group: %s\n"), gid);
       }
       if (setgid(group->gr_gid)) {
-         Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
+        Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
       }
       gr_list[0] = group->gr_gid;
       if (setgroups(1, gr_list)) {
-         Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
+        Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
       }
    }
 #endif
@@ -483,21 +483,21 @@ void drop(char *uid, char *gid)
    if (uid) {
       struct passwd *passw;
       if ((passw = getpwnam(uid)) == NULL) {
-         Emsg1(M_ERROR_TERM, 0, _("Could not find specified userid: %s\n"), uid);
+        Emsg1(M_ERROR_TERM, 0, _("Could not find specified userid: %s\n"), uid);
       }
       if (setuid(passw->pw_uid)) {
-         Emsg1(M_ERROR_TERM, 0, _("Could not set specified userid: %s\n"), uid);
+        Emsg1(M_ERROR_TERM, 0, _("Could not set specified userid: %s\n"), uid);
       }
    }
 #endif
-         
+
 }
 
 static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t timer = PTHREAD_COND_INITIALIZER;
 
 /*
- * This routine will sleep (sec, microsec).  Note, however, that if a 
+ * This routine will sleep (sec, microsec).  Note, however, that if a
  *   signal occurs, it will return early.  It is up to the caller
  *   to recall this routine if he/she REALLY wants to sleep the
  *   requested time.
@@ -515,7 +515,7 @@ int bmicrosleep(time_t sec, long usec)
 #ifdef HAVE_NANOSLEEP
    stat = nanosleep(&timeout, NULL);
    if (!(stat < 0 && errno == ENOSYS)) {
-      return stat;                  
+      return stat;
    }
    /* If we reach here it is because nanosleep is not supported by the OS */
 #endif
@@ -547,7 +547,7 @@ int bmicrosleep(time_t sec, long usec)
 long long int
 strtoll(const char *ptr, char **endptr, int base)
 {
-   return (long long int)strtod(ptr, endptr);  
+   return (long long int)strtod(ptr, endptr);
 }
 #endif
 
@@ -559,7 +559,7 @@ strtoll(const char *ptr, char **endptr, int base)
 char *bfgets(char *s, int size, FILE *fd)
 {
    char *p = s;
-   int ch;      
+   int ch;
    *p = 0;
    for (int i=0; i < size-1; i++) {
       do {
@@ -577,15 +577,15 @@ char *bfgets(char *s, int size, FILE *fd)
       *p = 0;
       if (ch == '\r') { /* Support for Mac/Windows file format */
         ch = fgetc(fd);
-         if (ch == '\n') { /* Windows (\r\n) */
+        if (ch == '\n') { /* Windows (\r\n) */
            *p++ = ch;
            *p = 0;
         }
-         else { /* Mac (\r only) */
+        else { /* Mac (\r only) */
            ungetc(ch, fd); /* Push next character back to fd */
         }
         break;
-      }      
+      }
       if (ch == '\n') {
         break;
       }
index d77b3e679d5334af77b8ea24c4a8de710930cef8..943a8860883b67356e7c00545a855fa840af7c73 100644 (file)
@@ -28,9 +28,9 @@
  * in Bacula (fdate_t, ftime_t, time_t (Unix standard), btime_t, and
  *  utime_t).  fdate_t and ftime_t are deprecated and should no longer
  *  be used, and in general, Unix time time_t should no longer be used,
- *  it is being phased out. 
- *     
- *  Epoch is the base of Unix time in seconds (time_t, ...) 
+ *  it is being phased out.
+ *
+ *  Epoch is the base of Unix time in seconds (time_t, ...)
  *     and is 1 Jan 1970 at 0:0 UTC
  *
  *  The major two times that should be left are:
@@ -46,7 +46,7 @@ char *bstrftime(char *dt, int maxlen, utime_t tim)
 {
    time_t ttime = (time_t)tim;
    struct tm tm;
-   
+
    /* ***FIXME**** the format and localtime_r() should be user configurable */
    localtime_r(&ttime, &tm);
    strftime(dt, maxlen, "%d-%b-%Y %H:%M", &tm);
@@ -58,7 +58,7 @@ char *bstrftimes(char *dt, int maxlen, utime_t tim)
 {
    time_t ttime = (time_t)tim;
    struct tm tm;
-   
+
    /* ***FIXME**** the format and localtime_r() should be user configurable */
    localtime_r(&ttime, &tm);
    strftime(dt, maxlen, "%d-%b-%Y %H:%M:%S", &tm);
@@ -71,7 +71,7 @@ char *bstrftime_ny(char *dt, int maxlen, utime_t tim)
 {
    time_t ttime = (time_t)tim;
    struct tm tm;
-   
+
    /* ***FIXME**** the format and localtime_r() should be user configurable */
    localtime_r(&ttime, &tm);
    strftime(dt, maxlen, "%d-%b %H:%M", &tm);
@@ -84,7 +84,7 @@ char *bstrftime_nc(char *dt, int maxlen, utime_t tim)
 {
    time_t ttime = (time_t)tim;
    struct tm tm;
-   
+
    /* ***FIXME**** the format and localtime_r() should be user configurable */
    localtime_r(&ttime, &tm);
    /* NOTE! since the compiler complains about %y, I use %y and cut the century */
@@ -105,7 +105,7 @@ char *bstrutime(char *dt, int maxlen, utime_t tim)
 }
 
 /* Convert standard time string yyyy-mm-dd hh:mm:ss to Unix time */
-utime_t str_to_utime(char *str) 
+utime_t str_to_utime(char *str)
 {
    struct tm tm;
    time_t ttime;
@@ -116,7 +116,7 @@ utime_t str_to_utime(char *str)
    }
    if (tm.tm_mon > 0) {
       tm.tm_mon--;
-   } else { 
+   } else {
       return 0;
    }
    if (tm.tm_year >= 1900) {
@@ -127,7 +127,7 @@ utime_t str_to_utime(char *str)
    tm.tm_wday = tm.tm_yday = 0;
    tm.tm_isdst = -1;
    ttime = mktime(&tm);
-   if (ttime == -1) {      
+   if (ttime == -1) {
       ttime = 0;
    }
    return (utime_t)ttime;
@@ -152,7 +152,7 @@ btime_t get_current_btime()
 /* Convert btime to Unix time */
 time_t btime_to_unix(btime_t bt)
 {
-   return (time_t)(bt/1000000);                   
+   return (time_t)(bt/1000000);
 }
 
 /* Convert btime to utime */
@@ -180,7 +180,7 @@ int tm_wom(int mday, int wday)
    int wom = 1 + (mday - fs - 1) / 7;
 // Dmsg4(100, "mday=%d wom=%d wday=%d fs=%d\n", mday, wom, wday, fs);
    return wom;
-}  
+}
 
 /*
  * Given a Unix date return the week of the year.
@@ -354,13 +354,13 @@ void date_time_decode(struct date_time *dt,
     time_decode(dt->julian_day_fraction, hour, minute, second, second_fraction);
 }
 
-/*  tm_encode  --  Encode a civil date and time from a tm structure   
+/*  tm_encode  --  Encode a civil date and time from a tm structure
  *                to a Julian day and day fraction.
  */
 
 /* Deprecated. Do not use. */
 void tm_encode(struct date_time *dt,
-                     struct tm *tm) 
+                     struct tm *tm)
 {
     uint32_t year;
     uint8_t month, day, hour, minute, second;
@@ -381,7 +381,7 @@ void tm_encode(struct date_time *dt,
 
 /* Deprecated. Do not use. */
 void tm_decode(struct date_time *dt,
-                     struct tm *tm) 
+                     struct tm *tm)
 {
     uint32_t year;
     uint8_t month, day, hour, minute, second;
index e8649eee1aab4c00454d232cd0b3115989bbe7dd..60d49fe1ca629bd277218b09d32247e54423fbe9 100644 (file)
@@ -1,5 +1,5 @@
 
-/*  
+/*
 
   See btime.c for defintions.
 
index a35e154656b1ec30b88395e0e3a607e54bb077ed..e58ba75aa6ff951d4779a25a58e7d1b9c625ad3b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Process and thread timer routines, built on top of watchdogs.
- * 
+ *
  *    Nic Bellamy <nic@bellamy.co.nz>, October 2004.
  *
 */
@@ -39,7 +39,7 @@ static void destructor_thread_timer(watchdog_t *self);
 static void destructor_child_timer(watchdog_t *self);
 #endif
 
-/* 
+/*
  * Start a timer on a child process of pid, kill it after wait seconds.
  *
  *  Returns: btimer_t *(pointer to btimer_t struct) on success
@@ -116,7 +116,7 @@ static void callback_child_timer(watchdog_t *self)
    }
 }
 
-/* 
+/*
  * Start a timer on a thread. kill it after wait seconds.
  *
  *  Returns: btimer_t *(pointer to btimer_t struct) on success
@@ -143,7 +143,7 @@ btimer_t *start_thread_timer(pthread_t tid, uint32_t wait)
    return wid;
 }
 
-/* 
+/*
  * Start a timer on a BSOCK. kill it after wait seconds.
  *
  *  Returns: btimer_t *(pointer to btimer_t struct) on success
@@ -165,7 +165,7 @@ btimer_t *start_bsock_timer(BSOCK *bsock, uint32_t wait)
    wid->wd->interval = wait;
    register_watchdog(wid->wd);
 
-   Dmsg4(50, "Start bsock timer %p tid=%p for %d secs at %d\n", wid, 
+   Dmsg4(50, "Start bsock timer %p tid=%p for %d secs at %d\n", wid,
         wid->tid, wait, time(NULL));
 
    return wid;
@@ -211,7 +211,7 @@ static void callback_thread_timer(watchdog_t *self)
 {
    btimer_t *wid = (btimer_t *)self->data;
 
-   Dmsg4(50, "thread timer %p kill %s tid=%p at %d.\n", self, 
+   Dmsg4(50, "thread timer %p kill %s tid=%p at %d.\n", self,
       wid->type == TYPE_BSOCK ? "bsock" : "thread", wid->tid, time(NULL));
 
    if (wid->type == TYPE_BSOCK && wid->bsock) {
index 6b14b53d3bfd59d2029e40ba37ddf8615564eca8..f529784e796d1ec96a95f947b2f7dc8d1f4451af 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Process and thread timer routines, built on top of watchdogs.
- * 
+ *
  *    Nic Bellamy <nic@bellamy.co.nz>, October 2003.
  *
 */
index af36c8993d34bccaf903d9d70168b109eb140c31..ca144ae16d9621cf0b6da336274c54d63aeff672 100644 (file)
@@ -2,7 +2,7 @@
  *  Challenge Response Authentication Method using MD5 (CRAM-MD5)
  *
  * cram-md5 is based on RFC2104.
- * 
+ *
  * Written for Bacula by Kern E. Sibbald, May MMI.
  *
  *   Version $Id$
@@ -101,8 +101,8 @@ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need)
    if (sscanf(bs->msg, "auth cram-md5 %s ssl=%d\n", chal, &ssl_has) != 2) {
       ssl_has = BNET_SSL_NONE;
       if (sscanf(bs->msg, "auth cram-md5 %s\n", chal) != 1) {
-         Dmsg1(50, "Cannot scan challenge: %s", bs->msg);
-         bnet_fsend(bs, "1999 Authorization failed.\n");
+        Dmsg1(50, "Cannot scan challenge: %s", bs->msg);
+        bnet_fsend(bs, "1999 Authorization failed.\n");
         bmicrosleep(5, 0);
         return 0;
       }
index 6451c0a24c7f2dfc29f92aca88535b52893f9252..8b379a727fc356a4707d12e453cbb1f34749620c 100644 (file)
@@ -31,7 +31,7 @@
  * The following code can be used to generate the static CRC table.
  *
  * Note, the magic number 0xedb88320L below comes from the terms
- * of the defining polynomial x^n, 
+ * of the defining polynomial x^n,
  * where n=0,1,2,4,5,7,8,10,11,12,16,22,23,26
  */
 #include <stdio.h>
@@ -54,7 +54,7 @@ main()
       buf[k++] = crc;
       if (k == 5) {
         k = 0;
-         printf("  0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x,\n", 
+        printf("  0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x,\n",
            buf[0], buf[1], buf[2], buf[3], buf[4]);
       }
    }
index fd87b12cd0a9c5392e773ff21b557c10cc73b6fb..177ffe7c3de646c032f565b48a1d9395f7131cdf 100644 (file)
@@ -9,9 +9,9 @@
  *   in the UNIX Environment"
  *
  * Initialize a daemon process completely detaching us from
- * any terminal processes. 
+ * any terminal processes.
  *
- */ 
+ */
 
 /*
    Copyright (C) 2000-2004 Kern Sibbald and John Walker
@@ -37,7 +37,7 @@
 #include "bacula.h"
 extern int debug_level;
 
-void 
+void
 daemon_start()
 {
 #if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
@@ -59,7 +59,7 @@ daemon_start()
    else if (cpid > 0)
       exit(0);             /* parent exits */
    /* Child continues */
-      
+
    setsid();
 
    /* In the PRODUCTION system, we close ALL
@@ -79,7 +79,7 @@ daemon_start()
    chdir("/");
 #endif
 
-   /* 
+   /*
     * Avoid creating files 666 but don't override any
     * more restrictive mask set by the user.
     */
index 6a6d6a4bbe7c93a9e49035bd7dfa69dabdb90349..fab9cc404c0ba99afc191c3784cfe758f6e07de4 100644 (file)
@@ -1,9 +1,9 @@
 /*
- *  Bacula doubly linked list routines.         
+ *  Bacula doubly linked list routines.
  *
  *    dlist is a doubly linked list with the links being in the
  *      list data item.
- *               
+ *
  *   Kern Sibbald, July MMIII
  *
  *   Version $Id$
@@ -38,7 +38,7 @@
 /*
  * Append an item to the list
  */
-void dlist::append(void *item) 
+void dlist::append(void *item)
 {
    ((dlink *)(((char *)item)+loffset))->next = NULL;
    ((dlink *)(((char *)item)+loffset))->prev = tail;
@@ -55,7 +55,7 @@ void dlist::append(void *item)
 /*
  * Append an item to the list
  */
-void dlist::prepend(void *item) 
+void dlist::prepend(void *item)
 {
    ((dlink *)(((char *)item)+loffset))->next = head;
    ((dlink *)(((char *)item)+loffset))->prev = NULL;
@@ -63,15 +63,15 @@ void dlist::prepend(void *item)
       ((dlink *)(((char *)head)+loffset))->prev = item;
    }
    head = item;
-   if (tail == NULL) {               /* if empty list, */                    
+   if (tail == NULL) {               /* if empty list, */
       tail = item;                   /* item is tail too */
    }
    num_items++;
 }
 
-void dlist::insert_before(void *item, void *where)      
+void dlist::insert_before(void *item, void *where)
 {
-   dlink *where_link = (dlink *)((char *)where+loffset);     
+   dlink *where_link = (dlink *)((char *)where+loffset);
 
    ((dlink *)(((char *)item)+loffset))->next = where;
    ((dlink *)(((char *)item)+loffset))->prev = where_link->prev;
@@ -86,9 +86,9 @@ void dlist::insert_before(void *item, void *where)
    num_items++;
 }
 
-void dlist::insert_after(void *item, void *where)      
+void dlist::insert_after(void *item, void *where)
 {
-   dlink *where_link = (dlink *)((char *)where+loffset);     
+   dlink *where_link = (dlink *)((char *)where+loffset);
 
    ((dlink *)(((char *)item)+loffset))->next = where_link->next;
    ((dlink *)(((char *)item)+loffset))->prev = where;
@@ -122,7 +122,7 @@ void *dlist::unique_binary_insert(void *item, int compare(void *item1, void *ite
       return item;
    }
    if (num_items == 1) {
-      comp = compare(item, first());     
+      comp = compare(item, first());
       if (comp < 0) {
         prepend(item);
        //Dmsg0(000, "Insert before first.\n");
@@ -173,7 +173,7 @@ void *dlist::unique_binary_insert(void *item, int compare(void *item1, void *ite
         cur++;
       }
       while (nxt < cur) {
-        cur_item = prev(cur_item); 
+        cur_item = prev(cur_item);
         cur--;
       }
     //Dmsg1(000, "Compare item to %d\n", cur);
@@ -304,7 +304,7 @@ int main()
 
    jcr_chain = (dlist *)malloc(sizeof(dlist));
    jcr_chain->init(jcr, &jcr->link);
-    
+
    printf("Prepend 20 items 0-19\n");
    for (int i=0; i<20; i++) {
       sprintf(buf, "This is dlist item %d", i);
@@ -324,7 +324,7 @@ int main()
    jcr_chain->remove(save_jcr);
    printf("Re-insert 10th item\n");
    jcr_chain->insert_before(jcr, next_jcr);
-   
+
    printf("Print remaining list.\n");
    foreach_dlist (jcr, jcr_chain) {
       printf("Dlist item = %s\n", jcr->buf);
@@ -353,7 +353,7 @@ int main()
    jcr_chain->remove(save_jcr);
    printf("Re-insert 10th item\n");
    jcr_chain->insert_before(jcr, next_jcr);
-   
+
    printf("Print remaining list.\n");
    foreach_dlist (jcr, jcr_chain) {
       printf("Dlist item = %s\n", jcr->buf);
@@ -374,17 +374,17 @@ int main()
         for (int k=0; k<CNT; k++) {
            count++;
            if ((count & 0x3FF) == 0) {
-               Dmsg1(000, "At %d\n", count);
+              Dmsg1(000, "At %d\n", count);
            }
            jcr = (MYJCR *)malloc(sizeof(MYJCR));
            jcr->buf = bstrdup(buf);
            jcr1 = (MYJCR *)jcr_chain->binary_insert(jcr, my_compare);
            if (jcr != jcr1) {
-               Dmsg2(000, "Insert of %s vs %s failed.\n", jcr->buf, jcr1->buf);
+              Dmsg2(000, "Insert of %s vs %s failed.\n", jcr->buf, jcr1->buf);
            }
            buf[1]--;
         }
-         buf[1] = 'Z';
+        buf[1] = 'Z';
         buf[2]--;
       }
       buf[2] = 'Z';
index e0b35b7663269914afc82344b8dde6263c653da1..d0071f589cc31b271ecd53201f8cd653e9593ad8 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 /* ========================================================================
- * 
+ *
  *   Doubly linked list  -- dlist
  *
  *    Kern Sibbald, MMIV
@@ -34,7 +34,7 @@
 
 /* In case you want to specifically specify the offset to the link */
 #define OFFSET(item, link) ((char *)(link) - (char *)(item))
-/* 
+/*
  * There is a lot of extra casting here to work around the fact
  * that some compilers (Sun and Visual C++) do not accept
  * (void *) as an lvalue on the left side of an equal.
@@ -46,7 +46,7 @@
 
 #ifdef the_old_way
 #define foreach_dlist(var, list) \
-        for((var)=NULL; (((void *)(var))=(list)->next(var)); )
+       for((var)=NULL; (((void *)(var))=(list)->next(var)); )
 #endif
 
 
@@ -82,12 +82,12 @@ public:
 };
 
 
-/*                            
+/*
  * This allows us to do explicit initialization,
  *   allowing us to mix C++ classes inside malloc'ed
  *   C structures. Define before called in constructor.
  */
-inline void dlist::init(void *item, dlink *link) 
+inline void dlist::init(void *item, dlink *link)
 {
    head = tail = NULL;
    loffset = (char *)link - (char *)item;
@@ -97,12 +97,12 @@ inline void dlist::init(void *item, dlink *link)
    num_items = 0;
 }
 
-/*             
- * Constructor called with the address of a 
+/*
+ * Constructor called with the address of a
  *   member of the list (not the list head), and
  *   the address of the link within that member.
  * If the link is at the beginning of the list member,
- *   then there is no need to specify the link address 
+ *   then there is no need to specify the link address
  *   since the offset is zero.
  */
 inline dlist::dlist(void *item, dlink *link)
@@ -125,7 +125,7 @@ inline int dlist::size() const
    return num_items;
 }
 
-   
+
 
 inline void * dlist::first() const
 {
index d988f46dbcf18dffb4948a04f7a1cfeb60532a03..97cdb810dad8036fa6ad63c059a6cea838b4c560 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *   edit.c  edit string to ascii, and ascii to internal 
- * 
+ *   edit.c  edit string to ascii, and ascii to internal
+ *
  *    Kern Sibbald, December MMII
  *
  *   Version $Id$
@@ -30,7 +30,7 @@
 #include <math.h>
 
 /* We assume ASCII input and don't worry about overflow */
-uint64_t str_to_uint64(char *str) 
+uint64_t str_to_uint64(char *str)
 {
    register char *p = str;
    register uint64_t value = 0;
@@ -51,7 +51,7 @@ uint64_t str_to_uint64(char *str)
    return value;
 }
 
-int64_t str_to_int64(char *str) 
+int64_t str_to_int64(char *str)
 {
    register char *p = str;
    register int64_t value;
@@ -84,7 +84,7 @@ int64_t str_to_int64(char *str)
  */
 char *edit_uint64_with_commas(uint64_t val, char *buf)
 {
-   /*  
+   /*
     * Replacement for sprintf(buf, "%" llu, val)
     */
    char mbuf[50];
@@ -94,7 +94,7 @@ char *edit_uint64_with_commas(uint64_t val, char *buf)
       mbuf[i--] = '0';
    } else {
       while (val != 0) {
-         mbuf[i--] = "0123456789"[val%10];
+        mbuf[i--] = "0123456789"[val%10];
         val /= 10;
       }
    }
@@ -109,7 +109,7 @@ char *edit_uint64_with_commas(uint64_t val, char *buf)
  */
 char *edit_uint64(uint64_t val, char *buf)
 {
-   /*  
+   /*
     * Replacement for sprintf(buf, "%" llu, val)
     */
    char mbuf[50];
@@ -119,7 +119,7 @@ char *edit_uint64(uint64_t val, char *buf)
       mbuf[i--] = '0';
    } else {
       while (val != 0) {
-         mbuf[i--] = "0123456789"[val%10];
+        mbuf[i--] = "0123456789"[val%10];
         val /= 10;
       }
    }
@@ -134,7 +134,7 @@ char *edit_uint64(uint64_t val, char *buf)
 static bool get_modifier(char *str, char *num, int num_len, char *mod, int mod_len)
 {
    int i, len, num_begin, num_end, mod_begin, mod_end;
-        
+
    /*
     * Look for modifier by walking back looking for the first
     *  space or digit.
@@ -202,12 +202,12 @@ int duration_to_utime(char *str, utime_t *value)
    char num_str[50];
    /*
     * The "n" = mins and months appears before minutes so that m maps
-    *   to months. These "kludges" make it compatible with pre 1.31 
+    *   to months. These "kludges" make it compatible with pre 1.31
     *  Baculas.
     */
-   static const char *mod[] = {"n", "seconds", "months", "minutes", 
-                  "hours", "days", "weeks",   "quarters",   "years", NULL};
-   static const int32_t mult[] = {60,  1, 60*60*24*30, 60, 
+   static const char *mod[] = {"n", "seconds", "months", "minutes",
+                 "hours", "days", "weeks",   "quarters",   "years", NULL};
+   static const int32_t mult[] = {60,  1, 60*60*24*30, 60,
                  60*60, 60*60*24, 60*60*24*7, 60*60*24*91, 60*60*24*365};
 
    while (*str) {
@@ -256,11 +256,11 @@ char *edit_utime(utime_t val, char *buf, int buf_len)
       times = (uint32_t)(val / mult[i]);
       if (times > 0) {
         val = val - (utime_t)times * mult[i];
-         bsnprintf(mybuf, sizeof(mybuf), "%d %s%s ", times, mod[i], times>1?"s":"");
+        bsnprintf(mybuf, sizeof(mybuf), "%d %s%s ", times, mod[i], times>1?"s":"");
         bstrncat(buf, mybuf, buf_len);
       }
    }
-   if (val == 0 && strlen(buf) == 0) {    
+   if (val == 0 && strlen(buf) == 0) {
       bstrncat(buf, "0 secs", buf_len);
    } else if (val != 0) {
       bsnprintf(mybuf, sizeof(mybuf), "%d sec%s", (uint32_t)val, val>1?"s":"");
@@ -340,7 +340,7 @@ bool is_a_number(const char *n)
 }
 
 /*
- * Check if the specified string is an integer  
+ * Check if the specified string is an integer
  */
 bool is_an_integer(const char *n)
 {
@@ -355,7 +355,7 @@ bool is_an_integer(const char *n)
 /*
  * Check if Bacula Resoure Name is valid
  */
-/* 
+/*
  * Check if the Volume name has legal characters
  * If ua is non-NULL send the message
  */
@@ -372,20 +372,20 @@ bool is_name_valid(char *name, POOLMEM **msg)
         continue;
       }
       if (msg) {
-         Mmsg(msg, _("Illegal character \"%c\" in name.\n"), *p);
+        Mmsg(msg, _("Illegal character \"%c\" in name.\n"), *p);
       }
       return false;
    }
    len = strlen(name);
    if (len >= MAX_NAME_LENGTH) {
       if (msg) {
-         Mmsg(msg, _("Name too long.\n"));
+        Mmsg(msg, _("Name too long.\n"));
       }
       return false;
    }
    if (len == 0) {
       if (msg) {
-         Mmsg(msg,  _("Volume name must be at least one character long.\n"));
+        Mmsg(msg,  _("Volume name must be at least one character long.\n"));
       }
       return false;
    }
@@ -396,7 +396,7 @@ bool is_name_valid(char *name, POOLMEM **msg)
 
 /*
  * Add commas to a string, which is presumably
- * a number.  
+ * a number.
  */
 char *add_commas(char *val, char *buf)
 {
@@ -420,7 +420,7 @@ char *add_commas(char *val, char *buf)
          *q-- = *p--;
       }
       *q-- = ',';
-   }   
+   }
    return buf;
 }
 
@@ -437,7 +437,7 @@ int main(int argc, char *argv[])
    for (int i=0; i<8; i++) {
       strcpy(buf, str[i]);
       if (!duration_to_utime(buf, &val)) {
-         printf("Error return from duration_to_utime for in=%s\n", str[i]);
+        printf("Error return from duration_to_utime for in=%s\n", str[i]);
         continue;
       }
       edit_utime(val, outval);
index 30e61ccf5cd4b187d016a19bf0922d05cfc8282d..187793e2ea8cc57213a862cffce19cd87d4f21b8 100644 (file)
@@ -54,11 +54,11 @@ void log_event(UPSINFO *ups, int level, char *fmt, ...)
 
        time(&nowtime);
        localtime_r(&nowtime, &tm);
-        strftime(datetime, sizeof(datetime), "%a %b %d %X %Z %Y  ", &tm);
+       strftime(datetime, sizeof(datetime), "%a %b %d %X %Z %Y  ", &tm);
        write(event_fd, datetime, strlen(datetime));
        lm = strlen(msg);
-        if (msg[lm-1] != '\n') 
-           msg[lm++] = '\n';
+       if (msg[lm-1] != '\n')
+          msg[lm++] = '\n';
        write(event_fd, msg, lm);
     }
 }
@@ -68,7 +68,7 @@ void log_event(UPSINFO *ups, int level, char *fmt, ...)
 #define MAXLE 50                     /* truncate file when this many events */
 
 /*
- * If the EVENTS file exceeds MAXLE records, truncate it. 
+ * If the EVENTS file exceeds MAXLE records, truncate it.
  *
  * Returns:
  *
@@ -84,7 +84,7 @@ int truncate_events_file(UPSINFO *ups)
     int trunc = FALSE;
     FILE *events_file;
     int stat = 0;
-    
+
     if ((events_file = fopen(ups->eventfile, "r+")) == NULL)
        return 0;
     for (i=0; i<NLE; i++)
@@ -114,7 +114,7 @@ int truncate_events_file(UPSINFO *ups)
     *buf = 0;
     /* Put records in single buffer in correct order */
     for (j=0; j < nrec; j++) {
-       strcat(buf, le[i++]); 
+       strcat(buf, le[i++]);
        if (i >= NLE)
            i = 0;
     }
@@ -145,27 +145,27 @@ bailout:
 extern UPSINFO myUPS;
 extern int shm_OK;
 
-/*  
+/*
  * Fill the Events list box with the last events
- * 
+ *
  */
 void FillEventsBox(HWND hwnd, int idlist)
 {
     char buf[1000];
     int len;
     FILE *events_file;
-    
+
     if (!shm_OK || myUPS.eventfile[0] == 0 ||
-        (events_file = fopen(myUPS.eventfile, "r")) == NULL) {
-       SendDlgItemMessage(hwnd, idlist, LB_ADDSTRING, 0, 
-           (LONG)"Events not available");
+       (events_file = fopen(myUPS.eventfile, "r")) == NULL) {
+       SendDlgItemMessage(hwnd, idlist, LB_ADDSTRING, 0,
+          (LONG)"Events not available");
        return;
     }
 
     while (fgets(buf, sizeof(buf), events_file) != NULL) {
        len = strlen(buf);
        /* strip trailing cr/lfs */
-        while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r'))
+       while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r'))
            buf[--len] = 0;
        SendDlgItemMessage(hwnd, idlist, LB_ADDSTRING, 0, (LONG)buf);
     }
index 6b0ceb6b992f1657fc202c1ad7bf8fd1323a816a..729373ced3fac9a0c26e45fe3978d355f2e6764d 100644 (file)
@@ -68,22 +68,22 @@ fnmatch (const char *pattern, const char *string, int flags)
 
       switch (c)
        {
-        case '?':
-          if (*n == '\0')
+       case '?':
+         if (*n == '\0')
            return FNM_NOMATCH;
-          else if ((flags & FNM_FILE_NAME) && *n == '/')
+         else if ((flags & FNM_FILE_NAME) && *n == '/')
            return FNM_NOMATCH;
-          else if ((flags & FNM_PERIOD) && *n == '.' &&
-                   (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+         else if ((flags & FNM_PERIOD) && *n == '.' &&
+                  (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
            return FNM_NOMATCH;
          break;
 
-        case '\\':
+       case '\\':
          if (!(flags & FNM_NOESCAPE))
            {
              c = *p++;
-              if (c == '\0')
-                /* Trailing \ loses.  */
+             if (c == '\0')
+               /* Trailing \ loses.  */
                return FNM_NOMATCH;
              c = FOLD (c);
            }
@@ -91,56 +91,56 @@ fnmatch (const char *pattern, const char *string, int flags)
            return FNM_NOMATCH;
          break;
 
-        case '*':
-          if ((flags & FNM_PERIOD) && *n == '.' &&
-              (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+       case '*':
+         if ((flags & FNM_PERIOD) && *n == '.' &&
+             (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
            return FNM_NOMATCH;
 
-          for (c = *p++; c == '?' || c == '*'; c = *p++)
+         for (c = *p++; c == '?' || c == '*'; c = *p++)
            {
-              if ((flags & FNM_FILE_NAME) && *n == '/')
+             if ((flags & FNM_FILE_NAME) && *n == '/')
                /* A slash does not match a wildcard under FNM_FILE_NAME.  */
                return FNM_NOMATCH;
-              else if (c == '?')
+             else if (c == '?')
                {
                  /* A ? needs to match one character.  */
-                  if (*n == '\0')
-                    /* There isn't another character; no match.  */
+                 if (*n == '\0')
+                   /* There isn't another character; no match.  */
                    return FNM_NOMATCH;
                  else
                    /* One character of the string is consumed in matching
-                       this ? wildcard, so *??? won't match if there are
+                      this ? wildcard, so *??? won't match if there are
                       less than three characters.  */
                    ++n;
                }
            }
 
-          if (c == '\0')
+         if (c == '\0')
            return 0;
 
          {
-            char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
+           char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
            c1 = FOLD (c1);
-            for (--p; *n != '\0'; ++n)
-              if ((c == '[' || FOLD (*n) == c1) &&
+           for (--p; *n != '\0'; ++n)
+             if ((c == '[' || FOLD (*n) == c1) &&
                  fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
                return 0;
            return FNM_NOMATCH;
          }
 
-        case '[':
+       case '[':
          {
            /* Nonzero if the sense of the character class is inverted.  */
            register int nnot;
 
-            if (*n == '\0')
+           if (*n == '\0')
              return FNM_NOMATCH;
 
-            if ((flags & FNM_PERIOD) && *n == '.' &&
-                (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+           if ((flags & FNM_PERIOD) && *n == '.' &&
+               (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
              return FNM_NOMATCH;
 
-            nnot = (*p == '!' || *p == '^');
+           nnot = (*p == '!' || *p == '^');
            if (nnot)
              ++p;
 
@@ -149,32 +149,32 @@ fnmatch (const char *pattern, const char *string, int flags)
              {
                register char cstart = c, cend = c;
 
-                if (!(flags & FNM_NOESCAPE) && c == '\\')
+               if (!(flags & FNM_NOESCAPE) && c == '\\')
                  {
-                    if (*p == '\0')
+                   if (*p == '\0')
                      return FNM_NOMATCH;
                    cstart = cend = *p++;
                  }
 
                cstart = cend = FOLD (cstart);
 
-                if (c == '\0')
+               if (c == '\0')
                  /* [ (unterminated) loses.  */
                  return FNM_NOMATCH;
 
                c = *p++;
                c = FOLD (c);
 
-                if ((flags & FNM_FILE_NAME) && c == '/')
+               if ((flags & FNM_FILE_NAME) && c == '/')
                  /* [/] can never match.  */
                  return FNM_NOMATCH;
 
-                if (c == '-' && *p != ']')
+               if (c == '-' && *p != ']')
                  {
                    cend = *p++;
-                    if (!(flags & FNM_NOESCAPE) && cend == '\\')
+                   if (!(flags & FNM_NOESCAPE) && cend == '\\')
                      cend = *p++;
-                    if (cend == '\0')
+                   if (cend == '\0')
                      return FNM_NOMATCH;
                    cend = FOLD (cend);
 
@@ -184,7 +184,7 @@ fnmatch (const char *pattern, const char *string, int flags)
                if (FOLD (*n) >= cstart && FOLD (*n) <= cend)
                  goto matched;
 
-                if (c == ']')
+               if (c == ']')
                  break;
              }
            if (!nnot)
@@ -193,16 +193,16 @@ fnmatch (const char *pattern, const char *string, int flags)
 
          matched:;
            /* Skip the rest of the [...] that already matched.  */
-            while (c != ']')
+           while (c != ']')
              {
-                if (c == '\0')
+               if (c == '\0')
                  /* [... (unterminated) loses.  */
                  return FNM_NOMATCH;
 
                c = *p++;
-                if (!(flags & FNM_NOESCAPE) && c == '\\')
+               if (!(flags & FNM_NOESCAPE) && c == '\\')
                  {
-                    if (*p == '\0')
+                   if (*p == '\0')
                      return FNM_NOMATCH;
                    /* XXX 1003.2d11 is unclear if this is right.  */
                    ++p;
index b0147e9d2ac314401941304659c3c19575f025df..31e4a235db62ac0cd4efb81c4f0960757cbf8c2a 100644 (file)
@@ -138,15 +138,15 @@ extern int getopt ();
 
 # ifndef __need_getopt
 extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
-                       const struct option *__longopts, int *__longind);
+                       const struct option *__longopts, int *__longind);
 extern int getopt_long_only (int __argc, char *const *__argv,
                             const char *__shortopts,
-                            const struct option *__longopts, int *__longind);
+                            const struct option *__longopts, int *__longind);
 
 /* Internal only.  Users should not call this directly.  */
 extern int _getopt_internal (int __argc, char *const *__argv,
                             const char *__shortopts,
-                            const struct option *__longopts, int *__longind,
+                            const struct option *__longopts, int *__longind,
                             int __long_only);
 # endif
 #else /* not __STDC__ */
index 2c5d747c8690bd55cf0836f45e715967f3f9901f..bfe0bc9d1e0491fd20e1f83ed95ccaecdd6f9a17 100644 (file)
@@ -2,7 +2,7 @@
  *  Hashed Message Authentication Code using MD5 (HMAC-MD5)
  *
  * hmac_md5 was based on sample code in RFC2104 (thanks guys).
- * 
+ *
  * Adapted to Bacula by Kern E. Sibbald, February MMI.
  *
  *   Version $Id$
@@ -73,7 +73,7 @@ hmac_md5(
    /* Zero pads and store key */
    memset(k_ipad, 0, PAD_LEN);
    memcpy(k_ipad, key, key_len);
-   memcpy(k_opad, k_ipad, PAD_LEN); 
+   memcpy(k_opad, k_ipad, PAD_LEN);
 
    /* XOR key with ipad and opad values */
    for (i=0; i<PAD_LEN; i++) {
index 3769c8bec8b484306c7a117a488683b6de9e3a19..1d440c40fa60c4423cb0344043de2cd7a5ae8520 100644 (file)
@@ -16,7 +16,7 @@
  *    Just create a new larger table, walk the old table and
  *    re-hash insert each entry into the new table.
  *
- *               
+ *
  *   Kern Sibbald, July MMIII
  *
  *   Version $Id$
@@ -96,7 +96,7 @@ void * htable::operator new(size_t)
    return malloc(sizeof(htable));
 }
 
-void htable::operator delete(void *tbl) 
+void htable::operator delete(void *tbl)
 {
    ((htable *)tbl)->destroy();
    free(tbl);
@@ -108,7 +108,7 @@ uint32_t htable::size()
    return num_items;
 }
 
-void htable::stats() 
+void htable::stats()
 {
    int count[10];
    int max = 0;
@@ -120,7 +120,7 @@ void htable::stats()
    }
    for (i=0; i<(int)buckets; i++) {
       p = table[i];
-      j = 0;    
+      j = 0;
       while (p) {
         p = (hlink *)(p->next);
         j++;
@@ -155,7 +155,7 @@ void htable::grow_table()
    big->walk_index = 0;
    /* Insert all the items in the new hash table */
    Dmsg1(100, "Before copy num_items=%d\n", num_items);
-   /* 
+   /*
     * We walk through the old smaller tree getting items,
     * but since we are overwriting the colision links, we must
     * explicitly save the item->next pointer and walk each
@@ -169,7 +169,7 @@ void htable::grow_table()
       if (ni) {
         item = (void *)((char *)ni-loffset);
       } else {
-        walkptr = NULL;       
+        walkptr = NULL;
         item = next();
       }
    }
@@ -217,7 +217,7 @@ void *htable::lookup(char *key)
    for (hlink *hp=table[index]; hp; hp=(hlink *)hp->next) {
 //    Dmsg2(100, "hp=0x%x key=%s\n", (long)hp, hp->key);
       if (hash == hp->hash && strcmp(key, hp->key) == 0) {
-         Dmsg1(100, "lookup return %x\n", ((char *)hp)-loffset);
+        Dmsg1(100, "lookup return %x\n", ((char *)hp)-loffset);
         return ((char *)hp)-loffset;
       }
    }
@@ -233,15 +233,15 @@ void *htable::next()
    while (!walkptr && walk_index < buckets) {
       walkptr = table[walk_index++];
       if (walkptr) {
-         Dmsg3(100, "new walkptr=0x%x next=0x%x inx=%d\n", (unsigned)walkptr,
+        Dmsg3(100, "new walkptr=0x%x next=0x%x inx=%d\n", (unsigned)walkptr,
            (unsigned)(walkptr->next), walk_index-1);
       }
    }
    if (walkptr) {
-      Dmsg2(100, "next: rtn 0x%x walk_index=%d\n", 
+      Dmsg2(100, "next: rtn 0x%x walk_index=%d\n",
         (unsigned)(((char *)walkptr)-loffset), walk_index);
       return ((char *)walkptr)-loffset;
-   } 
+   }
    Dmsg0(100, "next: return NULL\n");
    return NULL;
 }
@@ -254,14 +254,14 @@ void *htable::first()
    while (!walkptr && walk_index < buckets) {
       walkptr = table[walk_index++];  /* go to next bucket */
       if (walkptr) {
-         Dmsg3(100, "first new walkptr=0x%x next=0x%x inx=%d\n", (unsigned)walkptr,
+        Dmsg3(100, "first new walkptr=0x%x next=0x%x inx=%d\n", (unsigned)walkptr,
            (unsigned)(walkptr->next), walk_index-1);
       }
    }
    if (walkptr) {
       Dmsg1(100, "Leave first walkptr=0x%x\n", (unsigned)walkptr);
       return ((char *)walkptr)-loffset;
-   } 
+   }
    Dmsg0(100, "Leave first walkptr=NULL\n");
    return NULL;
 }
@@ -300,10 +300,10 @@ int main()
    MYJCR *save_jcr = NULL, *item;
    MYJCR *jcr = NULL;
    int count = 0;
-    
+
    jcrtbl = (htable *)malloc(sizeof(htable));
    jcrtbl->init(jcr, &jcr->link, NITEMS);
-    
+
    Dmsg1(000, "Inserting %d items\n", NITEMS);
    for (int i=0; i<NITEMS; i++) {
       sprintf(mkey, "This is htable item %d", i);
index f4c0cc97353dcbcb1be8ab7dcdbb9ce1c0209d85..1573f22338def2e82efabcfef7241b5aa4d3c957 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 /* ========================================================================
- * 
+ *
  *   Hash table class -- htable
  *
  */
@@ -32,9 +32,9 @@
  * Loop var through each member of table
  */
 #define foreach_htable(var, tbl) \
-        for(((void *)(var))=(tbl)->first(); \
-            (var); \
-            ((void *)(var))=(tbl)->next())
+       for(((void *)(var))=(tbl)->first(); \
+           (var); \
+           ((void *)(var))=(tbl)->next())
 
 struct hlink {
    void *next;                        /* next hash item */
index 596232df07eab18c33ef6e9da26892d36ab324c6..5b61b5da9258092393d05b658b5af6120032022f 100755 (executable)
@@ -53,7 +53,7 @@ void init_last_jobs_list()
    if (!last_jobs) {
       last_jobs = New(dlist(job_entry, &job_entry->link));
       if ((errstat=rwl_init(&lock)) != 0) {
-         Emsg1(M_ABORT, 0, _("Unable to initialize jcr_chain lock. ERR=%s\n"), 
+        Emsg1(M_ABORT, 0, _("Unable to initialize jcr_chain lock. ERR=%s\n"),
               strerror(errstat));
       }
    }
@@ -64,9 +64,9 @@ void term_last_jobs_list()
 {
    if (last_jobs) {
       while (!last_jobs->empty()) {
-        void *je = last_jobs->first(); 
+        void *je = last_jobs->first();
         last_jobs->remove(je);
-        free(je);     
+        free(je);
       }
       delete last_jobs;
       last_jobs = NULL;
@@ -92,7 +92,7 @@ void read_last_jobs_list(int fd, uint64_t addr)
    }
    for ( ; num; num--) {
       if (read(fd, &job, sizeof(job)) != sizeof(job)) {
-         Dmsg1(000, "Read job entry. ERR=%s\n", strerror(errno));
+        Dmsg1(000, "Read job entry. ERR=%s\n", strerror(errno));
         return;
       }
       if (job.JobId > 0) {
@@ -124,12 +124,12 @@ uint64_t write_last_jobs_list(int fd, uint64_t addr)
       /* First record is number of entires */
       num = last_jobs->size();
       if (write(fd, &num, sizeof(num)) != sizeof(num)) {
-         Dmsg1(000, "Error writing num_items: ERR=%s\n", strerror(errno));
+        Dmsg1(000, "Error writing num_items: ERR=%s\n", strerror(errno));
         return 0;
       }
       foreach_dlist(je, last_jobs) {
         if (write(fd, je, sizeof(struct s_last_job)) != sizeof(struct s_last_job)) {
-            Dmsg1(000, "Error writing job: ERR=%s\n", strerror(errno));
+           Dmsg1(000, "Error writing job: ERR=%s\n", strerror(errno));
            return 0;
         }
       }
@@ -140,16 +140,16 @@ uint64_t write_last_jobs_list(int fd, uint64_t addr)
       stat = 0;
    }
    return stat;
-      
+
 }
 
-void lock_last_jobs_list() 
+void lock_last_jobs_list()
 {
    /* Use jcr chain mutex */
    lock_jcr_chain();
 }
 
-void unlock_last_jobs_list() 
+void unlock_last_jobs_list()
 {
    /* Use jcr chain mutex */
    unlock_jcr_chain();
@@ -251,7 +251,7 @@ static void remove_jcr(JCR *jcr)
 
 /*
  * Free stuff common to all JCRs.  N.B. Be careful to include only
- *  generic stuff in the common part of the jcr. 
+ *  generic stuff in the common part of the jcr.
  */
 static void free_common_jcr(JCR *jcr)
 {
@@ -336,7 +336,7 @@ static void free_common_jcr(JCR *jcr)
    free(jcr);
 }
 
-/* 
+/*
  * Global routine to free a jcr
  */
 #ifdef DEBUG
@@ -381,7 +381,7 @@ void free_jcr(JCR *jcr)
 }
 
 
-/* 
+/*
  * Global routine to free a jcr
  *  JCR chain is already locked
  */
@@ -400,13 +400,13 @@ void free_locked_jcr(JCR *jcr)
 
 
 /*
- * Given a JobId, find the JCR     
+ * Given a JobId, find the JCR
  *   Returns: jcr on success
  *           NULL on failure
  */
 JCR *get_jcr_by_id(uint32_t JobId)
 {
-   JCR *jcr;      
+   JCR *jcr;
 
    lock_jcr_chain();                   /* lock chain */
    for (jcr = jobs; jcr; jcr=jcr->next) {
@@ -414,41 +414,41 @@ JCR *get_jcr_by_id(uint32_t JobId)
         P(jcr->mutex);
         jcr->use_count++;
         V(jcr->mutex);
-         Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
+        Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
         break;
       }
    }
    unlock_jcr_chain();
-   return jcr; 
+   return jcr;
 }
 
 /*
- * Given a SessionId and SessionTime, find the JCR     
+ * Given a SessionId and SessionTime, find the JCR
  *   Returns: jcr on success
  *           NULL on failure
  */
 JCR *get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime)
 {
-   JCR *jcr;      
+   JCR *jcr;
 
    lock_jcr_chain();
    for (jcr = jobs; jcr; jcr=jcr->next) {
-      if (jcr->VolSessionId == SessionId && 
+      if (jcr->VolSessionId == SessionId &&
          jcr->VolSessionTime == SessionTime) {
         P(jcr->mutex);
         jcr->use_count++;
         V(jcr->mutex);
-         Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
+        Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
         break;
       }
    }
    unlock_jcr_chain();
-   return jcr; 
+   return jcr;
 }
 
 
 /*
- * Given a Job, find the JCR     
+ * Given a Job, find the JCR
  *  compares on the number of characters in Job
  *  thus allowing partial matches.
  *   Returns: jcr on success
@@ -456,7 +456,7 @@ JCR *get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime)
  */
 JCR *get_jcr_by_partial_name(char *Job)
 {
-   JCR *jcr;      
+   JCR *jcr;
    int len;
 
    if (!Job) {
@@ -469,24 +469,24 @@ JCR *get_jcr_by_partial_name(char *Job)
         P(jcr->mutex);
         jcr->use_count++;
         V(jcr->mutex);
-         Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
+        Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
         break;
       }
    }
    unlock_jcr_chain();
-   return jcr; 
+   return jcr;
 }
 
 
 /*
- * Given a Job, find the JCR     
+ * Given a Job, find the JCR
  *  requires an exact match of names.
  *   Returns: jcr on success
  *           NULL on failure
  */
 JCR *get_jcr_by_full_name(char *Job)
 {
-   JCR *jcr;      
+   JCR *jcr;
 
    if (!Job) {
       return NULL;
@@ -497,12 +497,12 @@ JCR *get_jcr_by_full_name(char *Job)
         P(jcr->mutex);
         jcr->use_count++;
         V(jcr->mutex);
-         Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
+        Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
         break;
       }
    }
    unlock_jcr_chain();
-   return jcr; 
+   return jcr;
 }
 
 void set_jcr_job_status(JCR *jcr, int JobStatus)
@@ -527,7 +527,7 @@ void set_jcr_job_status(JCR *jcr, int JobStatus)
 static int lock_count = 0;
 #endif
 
-/* 
+/*
  * Lock the chain
  */
 #ifdef TRACE_JCR_CHAIN
@@ -537,7 +537,7 @@ void lock_jcr_chain()
 #endif
 {
    int errstat;
-#ifdef TRACE_JCR_CHAIN 
+#ifdef TRACE_JCR_CHAIN
    Dmsg3(400, "Lock jcr chain %d from %s:%d\n", ++lock_count,
       fname, line);
 #endif
@@ -557,7 +557,7 @@ void unlock_jcr_chain()
 #endif
 {
    int errstat;
-#ifdef TRACE_JCR_CHAIN 
+#ifdef TRACE_JCR_CHAIN
    Dmsg3(400, "Unlock jcr chain %d from %s:%d\n", lock_count--,
       fname, line);
 #endif
@@ -608,7 +608,7 @@ static void jcr_timeout_check(watchdog_t *self)
 
    Dmsg0(400, "Start JCR timeout checks\n");
 
-   /* Walk through all JCRs checking if any one is 
+   /* Walk through all JCRs checking if any one is
     * blocked for more than specified max time.
     */
    lock_jcr_chain();
index b3445d7f4ed20cce60c715c68e1474b0c10b7de8..c73016e138854b5052698daa83a16d9f0a84e7f3 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 /*
-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 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
@@ -43,8 +43,8 @@ void scan_to_eol(LEX *lc)
    Dmsg0(2000, "start scan to eof\n");
    while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
       if (token == T_EOB) {
-        lex_unget_char(lc);
-        return;
+         lex_unget_char(lc);
+         return;
       }
    }
 }
@@ -61,9 +61,9 @@ int scan_to_next_not_eol(LEX * lc)
    return token;
 }
 
-   
+
 /*
- * Format a scanner error message 
+ * Format a scanner error message
  */
 static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
 {
@@ -74,15 +74,15 @@ static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
    va_start(arg_ptr, msg);
    bvsnprintf(buf, sizeof(buf), msg, arg_ptr);
    va_end(arg_ptr);
-     
+
    if (lc->line_no > lc->begin_line_no) {
-      bsnprintf(more, sizeof(more), 
+      bsnprintf(more, sizeof(more),
                 _("Problem probably begins at line %d.\n"), lc->begin_line_no);
    } else {
       more[0] = 0;
    }
-   e_msg(file, line, M_ERROR_TERM, 0, _("Config error: %s\n\
-            : line %d, col %d of file %s\n%s\n%s"),
+   e_msg(file, line, M_ERROR_TERM, 0, _("Config error: %s\n"
+"            : line %d, col %d of file %s\n%s\n%s"),
       buf, lc->line_no, lc->col_no, lc->fname, lc->line, more);
 }
 
@@ -115,7 +115,7 @@ LEX *lex_close_file(LEX *lf)
    return lf;
 }
 
-/*     
+/*
  * Open a new configuration file. We push the
  * state of the current file (lf) so that we
  * can do includes.  This is a bit of a hammer.
@@ -126,29 +126,29 @@ LEX *lex_close_file(LEX *lf)
  * the next field.
  *
  */
-LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error) 
-             
+LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error)
+
 {
    LEX *nf;
    FILE *fd;
    char *fname = bstrdup(filename);
 
-   
+
    if ((fd = fopen(fname, "r")) == NULL) {
       berrno be;
-      Emsg2(M_ERROR_TERM, 0, _("Cannot open config file %s: %s\n"), 
-           fname, be.strerror());
+      Emsg2(M_ERROR_TERM, 0, _("Cannot open config file %s: %s\n"),
+            fname, be.strerror());
       return NULL; /* Never reached if exit_on_error == 1 */
    }
    Dmsg1(2000, "Open config file: %s\n", fname);
    nf = (LEX *)malloc(sizeof(LEX));
-   if (lf) {    
+   if (lf) {
       memcpy(nf, lf, sizeof(LEX));
       memset(lf, 0, sizeof(LEX));
-      lf->next = nf;                 /* if have lf, push it behind new one */
+      lf->next = nf;                  /* if have lf, push it behind new one */
       lf->options = nf->options;      /* preserve user options */
    } else {
-      lf = nf;                       /* start new packet */
+      lf = nf;                        /* start new packet */
       memset(lf, 0, sizeof(LEX));
    }
    lf->fd = fd;
@@ -164,7 +164,7 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error)
    return lf;
 }
 
-/*    
+/*
  * Get the next character from the input.
  *  Returns the character or
  *    L_EOF if end of file
@@ -177,11 +177,11 @@ int lex_get_char(LEX *lf)
    }
    if (lf->ch == L_EOL) {
       if (bfgets(lf->line, MAXSTRING, lf->fd) == NULL) {
-        lf->ch = L_EOF;
-        if (lf->next) {
-           lex_close_file(lf);
-        }
-        return lf->ch;
+         lf->ch = L_EOF;
+         if (lf->next) {
+            lex_close_file(lf);
+         }
+         return lf->ch;
       }
       lf->line_no++;
       lf->col_no = 0;
@@ -198,7 +198,7 @@ int lex_get_char(LEX *lf)
 
 void lex_unget_char(LEX *lf)
 {
-   lf->col_no--;      
+   lf->col_no--;
    if (lf->ch == L_EOL)
       lf->ch = 0;
 }
@@ -211,8 +211,8 @@ static void add_str(LEX *lf, int ch)
 {
    if (lf->str_len >= MAXSTRING-3) {
       Emsg3(M_ERROR_TERM, 0, _(
-           _("Config token too long, file: %s, line %d, begins at line %d\n")), 
-            lf->fname, lf->line_no, lf->begin_line_no);
+           _("Config token too long, file: %s, line %d, begins at line %d\n")),
+             lf->fname, lf->line_no, lf->begin_line_no);
    }
    lf->str[lf->str_len++] = ch;
    lf->str[lf->str_len] = 0;
@@ -221,7 +221,7 @@ static void add_str(LEX *lf, int ch)
 /*
  * Begin the string
  */
-static void begin_str(LEX *lf, int ch) 
+static void begin_str(LEX *lf, int ch)
 {
    lf->str_len = 0;
    lf->str[0] = 0;
@@ -284,14 +284,14 @@ static uint32_t scan_pint(LEX *lf, char *str)
       val = str_to_int64(str);
       if (errno != 0 || val < 0) {
          scan_err1(lf, _("expected a postive integer number, got: %s"), str);
-        /* NOT REACHED */
+         /* NOT REACHED */
       }
    }
    return (uint32_t)val;
 }
 
-/*       
- * 
+/*
+ *
  * Get the next token from the input
  *
  */
@@ -308,199 +308,204 @@ lex_get_token(LEX *lf, int expect)
       switch (lf->state) {
       case lex_none:
          Dmsg2(2000, "Lex state lex_none ch=%d,%x\n", ch, ch);
-        if (B_ISSPACE(ch))  
-           break;
-        if (B_ISALPHA(ch)) {
-           if (lf->options & LOPT_NO_IDENT)
-              lf->state = lex_string;
-           else
-              lf->state = lex_identifier;
-           begin_str(lf, ch);
-           break;
-        }
-        if (B_ISDIGIT(ch)) {
-           lf->state = lex_number;
-           begin_str(lf, ch);
-           break;
-        }
+         if (B_ISSPACE(ch))
+            break;
+         if (B_ISALPHA(ch)) {
+            if (lf->options & LOPT_NO_IDENT || lf->options & LOPT_STRING) {
+               lf->state = lex_string;
+            } else {
+               lf->state = lex_identifier;
+            }
+            begin_str(lf, ch);
+            break;
+         }
+         if (B_ISDIGIT(ch)) {
+            if (lf->options & LOPT_STRING) {
+               lf->state = lex_string;
+            } else {
+               lf->state = lex_number;
+            }
+            begin_str(lf, ch);
+            break;
+         }
          Dmsg0(2000, "Enter lex_none switch\n");
-        switch (ch) {
-        case L_EOF:
-           token = T_EOF;
+         switch (ch) {
+         case L_EOF:
+            token = T_EOF;
             Dmsg0(2000, "got L_EOF set token=T_EOF\n");
-           break;
+            break;
          case '#':
-           lf->state = lex_comment;
-           break;
+            lf->state = lex_comment;
+            break;
          case '{':
-           token = T_BOB;
-           begin_str(lf, ch);
-           break;
+            token = T_BOB;
+            begin_str(lf, ch);
+            break;
          case '}':
-           token = T_EOB;
-           begin_str(lf, ch);
-           break;
+            token = T_EOB;
+            begin_str(lf, ch);
+            break;
          case '"':
-           lf->state = lex_quoted_string;
-           begin_str(lf, 0);
-           break;
-         case '=': 
-           token = T_EQUALS;
-           begin_str(lf, ch);
-           break;
+            lf->state = lex_quoted_string;
+            begin_str(lf, 0);
+            break;
+         case '=':
+            token = T_EQUALS;
+            begin_str(lf, ch);
+            break;
          case ',':
-           token = T_COMMA;
-           begin_str(lf, ch);
-           break;
+            token = T_COMMA;
+            begin_str(lf, ch);
+            break;
          case ';':
-           if (expect != T_SKIP_EOL) {
-              token = T_EOL;      /* treat ; like EOL */
-           }
-           break;
-        case L_EOL:
+            if (expect != T_SKIP_EOL) {
+               token = T_EOL;      /* treat ; like EOL */
+            }
+            break;
+         case L_EOL:
             Dmsg0(2000, "got L_EOL set token=T_EOL\n");
-           if (expect != T_SKIP_EOL) {
-              token = T_EOL;
-           }
-           break;
+            if (expect != T_SKIP_EOL) {
+               token = T_EOL;
+            }
+            break;
          case '@':
-           lf->state = lex_include;
-           begin_str(lf, 0);
-           break;
-        default:
-           lf->state = lex_string;
-           begin_str(lf, ch);
-           break;
-        }
-        break;
+            lf->state = lex_include;
+            begin_str(lf, 0);
+            break;
+         default:
+            lf->state = lex_string;
+            begin_str(lf, ch);
+            break;
+         }
+         break;
       case lex_comment:
          Dmsg1(2000, "Lex state lex_comment ch=%x\n", ch);
-        if (ch == L_EOL) {
-           lf->state = lex_none;
-           if (expect != T_SKIP_EOL) {
-              token = T_EOL;
-           }
-        } else if (ch == L_EOF) {
-           token = T_ERROR;
-        }
-        break;
+         if (ch == L_EOL) {
+            lf->state = lex_none;
+            if (expect != T_SKIP_EOL) {
+               token = T_EOL;
+            }
+         } else if (ch == L_EOF) {
+            token = T_ERROR;
+         }
+         break;
       case lex_number:
          Dmsg2(2000, "Lex state lex_number ch=%x %c\n", ch, ch);
-        if (ch == L_EOF) {
-           token = T_ERROR;
-           break;
-        }
-        /* Might want to allow trailing specifications here */
-        if (B_ISDIGIT(ch)) {
-           add_str(lf, ch);
-           break;
-        }
-
-        /* A valid number can be terminated by the following */
+         if (ch == L_EOF) {
+            token = T_ERROR;
+            break;
+         }
+         /* Might want to allow trailing specifications here */
+         if (B_ISDIGIT(ch)) {
+            add_str(lf, ch);
+            break;
+         }
+
+         /* A valid number can be terminated by the following */
          if (B_ISSPACE(ch) || ch == L_EOL || ch == ',' || ch == ';') {
-           token = T_NUMBER;
-           lf->state = lex_none;
-        } else {
-           lf->state = lex_string;
-        }
-        lex_unget_char(lf);
-        break;
+            token = T_NUMBER;
+            lf->state = lex_none;
+         } else {
+            lf->state = lex_string;
+         }
+         lex_unget_char(lf);
+         break;
       case lex_ip_addr:
-        if (ch == L_EOF) {
-           token = T_ERROR;
-           break;
-        }
+         if (ch == L_EOF) {
+            token = T_ERROR;
+            break;
+         }
          Dmsg1(2000, "Lex state lex_ip_addr ch=%x\n", ch);
-        break;
+         break;
       case lex_string:
          Dmsg1(2000, "Lex state lex_string ch=%x\n", ch);
-        if (ch == L_EOF) {
-           token = T_ERROR;
-           break;
-        }
+         if (ch == L_EOF) {
+            token = T_ERROR;
+            break;
+         }
          if (ch == '\n' || ch == L_EOL || ch == '=' || ch == '}' || ch == '{' ||
              ch == '\r' || ch == ';' || ch == ',' || ch == '#' || (B_ISSPACE(ch)) ) {
-           lex_unget_char(lf);    
-           token = T_UNQUOTED_STRING;
-           lf->state = lex_none;
-           break;
-        } 
-        add_str(lf, ch);
-        break;
+            lex_unget_char(lf);
+            token = T_UNQUOTED_STRING;
+            lf->state = lex_none;
+            break;
+         }
+         add_str(lf, ch);
+         break;
       case lex_identifier:
          Dmsg2(2000, "Lex state lex_identifier ch=%x %c\n", ch, ch);
-        if (B_ISALPHA(ch)) {
-           add_str(lf, ch);
-           break;
-        } else if (B_ISSPACE(ch)) {
-           break;
+         if (B_ISALPHA(ch)) {
+            add_str(lf, ch);
+            break;
+         } else if (B_ISSPACE(ch)) {
+            break;
          } else if (ch == '\n' || ch == L_EOL || ch == '=' || ch == '}' || ch == '{' ||
                     ch == '\r' || ch == ';' || ch == ','   || ch == '"' || ch == '#') {
-           lex_unget_char(lf);    
-           token = T_IDENTIFIER;
-           lf->state = lex_none;
-           break;
-        } else if (ch == L_EOF) {
-           token = T_ERROR;
-           lf->state = lex_none;
-           begin_str(lf, ch);
-           break;
-        }
-        /* Some non-alpha character => string */
-        lf->state = lex_string;
-        add_str(lf, ch);
-        break;
+            lex_unget_char(lf);
+            token = T_IDENTIFIER;
+            lf->state = lex_none;
+            break;
+         } else if (ch == L_EOF) {
+            token = T_ERROR;
+            lf->state = lex_none;
+            begin_str(lf, ch);
+            break;
+         }
+         /* Some non-alpha character => string */
+         lf->state = lex_string;
+         add_str(lf, ch);
+         break;
       case lex_quoted_string:
          Dmsg2(2000, "Lex state lex_quoted_string ch=%x %c\n", ch, ch);
-        if (ch == L_EOF) {
-           token = T_ERROR;
-           break;
-        }
-        if (ch == L_EOL) {
-           esc_next = false;
-           break;
-        }
-        if (esc_next) {
-           add_str(lf, ch);
-           esc_next = false;
-           break;
-        }
+         if (ch == L_EOF) {
+            token = T_ERROR;
+            break;
+         }
+         if (ch == L_EOL) {
+            esc_next = false;
+            break;
+         }
+         if (esc_next) {
+            add_str(lf, ch);
+            esc_next = false;
+            break;
+         }
          if (ch == '\\') {
-           esc_next = true;
-           break;
-        }
+            esc_next = true;
+            break;
+         }
          if (ch == '"') {
-           token = T_QUOTED_STRING;
-           lf->state = lex_none;
-           break;
-        }
-        add_str(lf, ch);
-        break;
-      case lex_include:           /* scanning a filename */
-        if (ch == L_EOF) {
-           token = T_ERROR;
-           break;
-        }
+            token = T_QUOTED_STRING;
+            lf->state = lex_none;
+            break;
+         }
+         add_str(lf, ch);
+         break;
+      case lex_include:            /* scanning a filename */
+         if (ch == L_EOF) {
+            token = T_ERROR;
+            break;
+         }
          if (B_ISSPACE(ch) || ch == '\n' || ch == L_EOL || ch == '}' || ch == '{' ||
              ch == ';' || ch == ','   || ch == '"' || ch == '#') {
-           lf->state = lex_none;
-           lf = lex_open_file(lf, lf->str, NULL);
+            lf->state = lex_none;
+            lf = lex_open_file(lf, lf->str, NULL);
        if (lf == NULL) {
-        return T_ERROR;
+         return T_ERROR;
        }
-           break;
-        }
-        add_str(lf, ch);
-        break;
+            break;
+         }
+         add_str(lf, ch);
+         break;
       }
       Dmsg4(2000, "ch=%d state=%s token=%s %c\n", ch, lex_state_to_str(lf->state),
-       lex_tok_to_str(token), ch);
+        lex_tok_to_str(token), ch);
    }
    Dmsg2(2000, "lex returning: line %d token: %s\n", lf->line_no, lex_tok_to_str(token));
    lf->token = token;
 
-   /* 
-    * Here is where we check to see if the user has set certain 
+   /*
+    * Here is where we check to see if the user has set certain
     *  expectations (e.g. 32 bit integer). If so, we do type checking
     *  and possible additional scanning (e.g. for range).
     */
@@ -513,87 +518,87 @@ lex_get_token(LEX *lf, int expect)
 
    case T_PINT32_RANGE:
       if (token == T_NUMBER) {
-        lf->pint32_val = scan_pint(lf, lf->str);
-        lf->pint32_val2 = lf->pint32_val;
-        token = T_PINT32;
+         lf->pint32_val = scan_pint(lf, lf->str);
+         lf->pint32_val2 = lf->pint32_val;
+         token = T_PINT32;
       } else {
          char *p = strchr(lf->str, '-');
-        if (!p) {
-            scan_err2(lf, _("expected an integer or a range, got %s: %s"), 
-              lex_tok_to_str(token), lf->str);
-           token = T_ERROR;
-           break;
-        }
-        *p++ = 0;                       /* terminate first half of range */
-        lf->pint32_val  = scan_pint(lf, lf->str);
-        lf->pint32_val2 = scan_pint(lf, p);
-        token = T_PINT32_RANGE;
+         if (!p) {
+            scan_err2(lf, _("expected an integer or a range, got %s: %s"),
+               lex_tok_to_str(token), lf->str);
+            token = T_ERROR;
+            break;
+         }
+         *p++ = 0;                       /* terminate first half of range */
+         lf->pint32_val  = scan_pint(lf, lf->str);
+         lf->pint32_val2 = scan_pint(lf, p);
+         token = T_PINT32_RANGE;
       }
       break;
 
    case T_INT32:
       if (token != T_NUMBER || !is_a_number(lf->str)) {
          scan_err2(lf, _("expected an integer number, got %s: %s"),
-              lex_tok_to_str(token), lf->str);
-        token = T_ERROR;
-        break;
+               lex_tok_to_str(token), lf->str);
+         token = T_ERROR;
+         break;
       }
       errno = 0;
       lf->int32_val = (int32_t)str_to_int64(lf->str);
       if (errno != 0) {
          scan_err2(lf, _("expected an integer number, got %s: %s"),
-              lex_tok_to_str(token), lf->str);
-        token = T_ERROR;
+               lex_tok_to_str(token), lf->str);
+         token = T_ERROR;
       } else {
-        token = T_INT32;
+         token = T_INT32;
       }
       break;
 
    case T_INT64:
-      Dmsg2(2000, "int64=:%s: %f\n", lf->str, strtod(lf->str, NULL)); 
+      Dmsg2(2000, "int64=:%s: %f\n", lf->str, strtod(lf->str, NULL));
       if (token != T_NUMBER || !is_a_number(lf->str)) {
          scan_err2(lf, _("expected an integer number, got %s: %s"),
-              lex_tok_to_str(token), lf->str);
-        token = T_ERROR;
-        break;
+               lex_tok_to_str(token), lf->str);
+         token = T_ERROR;
+         break;
       }
       errno = 0;
       lf->int64_val = str_to_int64(lf->str);
       if (errno != 0) {
          scan_err2(lf, _("expected an integer number, got %s: %s"),
-              lex_tok_to_str(token), lf->str);
-        token = T_ERROR;
+               lex_tok_to_str(token), lf->str);
+         token = T_ERROR;
       } else {
-        token = T_INT64;
+         token = T_INT64;
       }
       break;
 
    case T_NAME:
       if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
          scan_err2(lf, _("expected a name, got %s: %s"),
-              lex_tok_to_str(token), lf->str);
-        token = T_ERROR;
+               lex_tok_to_str(token), lf->str);
+         token = T_ERROR;
       } else if (lf->str_len > MAX_RES_NAME_LENGTH) {
-         scan_err3(lf, _("name %s length %d too long, max is %d\n"), lf->str, 
-           lf->str_len, MAX_RES_NAME_LENGTH);
-        token = T_ERROR;
+         scan_err3(lf, _("name %s length %d too long, max is %d\n"), lf->str,
+            lf->str_len, MAX_RES_NAME_LENGTH);
+         token = T_ERROR;
       }
       break;
 
    case T_STRING:
       if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
          scan_err2(lf, _("expected a string, got %s: %s"),
-              lex_tok_to_str(token), lf->str);
-        token = T_ERROR;
+               lex_tok_to_str(token), lf->str);
+         token = T_ERROR;
       } else {
-        token = T_STRING;
+         token = T_STRING;
       }
       break;
 
 
    default:
-      break;                         /* no expectation given */
+      break;                          /* no expectation given */
    }
-   lf->token = token;                /* set possible new token */
+   lf->token = token;                 /* set possible new token */
    return token;
 }
index 49274ed93a0e01065700da2595f57b54aa936ca0..68113338fe7c6f3debcb5aae667bc9e0a96db190 100644 (file)
@@ -1,15 +1,15 @@
 /*
- *   lex.h  
+ *   lex.h
  *
  *    Lexical scanning of configuration files, used by parsers.
  *
- *   Kern Sibbald, MM  
+ *   Kern Sibbald, MM
  *
  *   Version $Id$
  *
  */
 /*
-   Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 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
@@ -36,7 +36,7 @@
 #define L_EOL                         (-2)
 
 /* Internal tokens */
-#define T_NONE                        100                              
+#define T_NONE                        100
 
 /* Tokens returned by get_token() */
 #define T_EOF                         101
@@ -53,7 +53,7 @@
 #define T_ERROR                       200
 /*
  * The following will be returned only if
- * the appropriate expect flag has been set   
+ * the appropriate expect flag has been set
  */
 #define T_SKIP_EOL                    113  /* scan through EOLs */
 #define T_PINT32                      114  /* positive integer */
@@ -79,6 +79,7 @@ enum lex_state {
 
 /* Lex scan options */
 #define LOPT_NO_IDENT            0x1  /* No Identifiers -- use string */
+#define LOPT_STRING              0x2  /* Force scan for string */
 
 /* Lexical context */
 typedef struct s_lex_context {
index 95d92d2f092212e201c9919bea07083d5dd95e20..91cd8c8bd53392739d3af0586b83205416c07ed6 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  *   Library includes for Bacula lib directory
  *
  *   This file contains an include for each library file
index f5a68abc1c781ec57004e5ba055f4c3aaa553ac5..9b788e8d7e88e04856eb9bd6dc26c795d71b5eda 100644 (file)
@@ -105,7 +105,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len)
 }
 
 /*
- * Final wrapup - pad to 64-byte boundary with the bit pattern 
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
  * 1 0* (64-bit count of bits processed, MSB-first)
  */
 void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
@@ -255,7 +255,7 @@ void MD5Transform(uint32_t buf[4], uint32_t in[16])
  * Reads a single ASCII file and prints the HEX md5 sum.
  */
 #include <stdio.h>
-int main(int argc, char *argv[]) 
+int main(int argc, char *argv[])
 {
    FILE *fd;
    MD5Context ctx;
index 15497c24a1522db9a17392b30e37d8a9fd5298a3..a62b6c50c6481f0d1ebe4fd3754fccd0a9656b9b 100644 (file)
@@ -1,10 +1,10 @@
 /*
- *  Bacula memory pool routines. 
+ *  Bacula memory pool routines.
  *
  *  The idea behind these routines is that there will be
  *  pools of memory that are pre-allocated for quick
  *  access. The pools will have a fixed memory size on allocation
- *  but if need be, the size can be increased. This is 
+ *  but if need be, the size can be increased. This is
  *  particularly useful for filename
  *  buffers where 256 bytes should be sufficient in 99.99%
  *  of the cases, but when it isn't we want to be able to
@@ -112,7 +112,7 @@ POOLMEM *sm_get_pool_memory(const char *fname, int lineno, int pool)
       sm_new_owner(fname, lineno, (char *)buf);
       return (POOLMEM *)((char *)buf+HEAD_SIZE);
    }
-      
+
    if ((buf = (struct abufhead *)sm_malloc(fname, lineno, pool_ctl[pool].size+HEAD_SIZE)) == NULL) {
       V(mutex);
       Emsg1(M_ABORT, 0, "Out of memory requesting %d bytes\n", pool_ctl[pool].size);
@@ -238,7 +238,7 @@ POOLMEM *get_pool_memory(int pool)
       V(mutex);
       return (POOLMEM *)((char *)buf+HEAD_SIZE);
    }
-      
+
    if ((buf=malloc(pool_ctl[pool].size+HEAD_SIZE)) == NULL) {
       V(mutex);
       Emsg1(M_ABORT, 0, "Out of memory requesting %d bytes\n", pool_ctl[pool].size);
@@ -390,9 +390,9 @@ static const char *pool_name(int pool)
    sprintf(buf, "%-6d", pool);
    return buf;
 }
-   
-/* Print staticstics on memory pool usage   
- */ 
+
+/* Print staticstics on memory pool usage
+ */
 void print_memory_pool_stats()
 {
    Dmsg0(-1, "Pool   Maxsize  Maxused  Inuse\n");
@@ -404,7 +404,7 @@ void print_memory_pool_stats()
 }
 
 #else
-void print_memory_pool_stats() {} 
+void print_memory_pool_stats() {}
 #endif /* DEBUG */
 
 
@@ -487,7 +487,7 @@ int pm_strcpy(POOLMEM *&pm, POOL_MEM &str)
 
 
 int pm_strcpy(POOL_MEM &pm, const char *str)
-{  
+{
    int len = strlen(str) + 1;
    pm.check_size(len);
    memcpy(pm.c_str(), str, len);
@@ -543,7 +543,7 @@ int POOL_MEM::strcat(const char *str)
 
 
 int POOL_MEM::strcpy(const char *str)
-{  
+{
    int len = strlen(str) + 1;
    check_size(len);
    memcpy(mem, str, len);
index 7d23bb20c873549127cbb4f0ae25f2c9f8f7eaf9..ee4dfbbbe61a4baa3e3d011d59cfa514d0bcc760 100644 (file)
@@ -46,8 +46,8 @@ extern POOLMEM  *sm_realloc_pool_memory(const char *fname, int line, POOLMEM *bu
 #define check_pool_memory_size(buf,size) sm_check_pool_memory_size(__FILE__, __LINE__, buf, size)
 extern POOLMEM  *sm_check_pool_memory_size(const char *fname, int line, POOLMEM *buf, int32_t size);
 
-#define free_pool_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x) 
-#define free_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x) 
+#define free_pool_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x)
+#define free_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x)
 extern void sm_free_pool_memory(const char *fname, int line, POOLMEM *buf);
 
 
@@ -62,11 +62,11 @@ extern POOLMEM  *check_pool_memory_size(POOLMEM *buf, int32_t size);
 extern void   free_pool_memory(POOLMEM *buf);
 
 #endif
+
 extern void  close_memory_pool();
 extern void  print_memory_pool_stats();
 
-   
+
 
 #define PM_NOPOOL  0                  /* nonpooled memory */
 #define PM_NAME    1                  /* Bacula name */
@@ -83,7 +83,7 @@ public:
    ~POOL_MEM() { free_pool_memory(mem); mem = NULL; }
    char *c_str() const { return mem; }
    int size() const { return sizeof_pool_memory(mem); }
-   char *check_size(int32_t size) { 
+   char *check_size(int32_t size) {
       mem = check_pool_memory_size(mem, size);
       return mem;
    }
index 0edf834f3a28dd3ae1be4b5ff80a6de06e712f0b..b1e653cce47b106611386ab9fb85254a2986a726 100755 (executable)
@@ -1,7 +1,7 @@
 /*
  * Bacula message handling routines
  *
- *   Kern Sibbald, April 2000 
+ *   Kern Sibbald, April 2000
  *
  *   Version $Id$
  *
@@ -39,7 +39,7 @@
 
 #define FULL_LOCATION 1              /* set for file:line in Debug messages */
 
-/* 
+/*
  *  This is where we define "Globals" because all the
  *    daemons include this file.
  */
@@ -61,7 +61,7 @@ char catalog_db[] = "PostgreSQL";
 #else
 #ifdef HAVE_MYSQL
 char catalog_db[] = "MySQL";
-#else 
+#else
 #ifdef HAVE_SQLITE
 char catalog_db[] = "SQLite";
 #else
@@ -94,7 +94,7 @@ static MSGS *daemon_msgs;            /* global messages */
 /* Define if e_msg must exit when M_ERROR_TERM is received */
 static int exit_on_error = 1;
 
-/* 
+/*
  * Set daemon name. Also, find canonical execution
  *  path.  Note, exepath has spare room for tacking on
  *  the exename so that we can reconstruct the full name.
@@ -115,7 +115,7 @@ void my_name_is(int argc, char *argv[], const char *name)
    if (argc>0 && argv && argv[0]) {
       /* strip trailing filename and save exepath */
       for (l=p=argv[0]; *p; p++) {
-         if (*p == '/') {
+        if (*p == '/') {
            l = p;                       /* set pos of last slash */
         }
       }
@@ -125,7 +125,7 @@ void my_name_is(int argc, char *argv[], const char *name)
         l = argv[0];
 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
         /* On Windows allow c: junk */
-         if (l[1] == ':') {
+        if (l[1] == ':') {
            l += 2;
         }
 #endif
@@ -156,11 +156,11 @@ void my_name_is(int argc, char *argv[], const char *name)
    }
 }
 
-/* 
+/*
  * Initialize message handler for a daemon or a Job
  *   We make a copy of the MSGS resource passed, so it belows
  *   to the job or daemon and thus can be modified.
- * 
+ *
  *   NULL for jcr -> initialize global messages for daemon
  *   non-NULL    -> initialize jcr using Message resource
  */
@@ -273,12 +273,12 @@ void init_console_msg(const char *wd)
    }
    if (rwl_init(&con_lock) != 0) {
       berrno be;
-      Emsg1(M_ERROR_TERM, 0, _("Could not get con mutex: ERR=%s\n"), 
+      Emsg1(M_ERROR_TERM, 0, _("Could not get con mutex: ERR=%s\n"),
         be.strerror());
    }
 }
 
-/* 
+/*
  * Called only during parsing of the config file.
  *
  * Add a message destination. I.e. associate a message type with
@@ -289,15 +289,15 @@ void init_console_msg(const char *wd)
  */
 void add_msg_dest(MSGS *msg, int dest_code, int msg_type, char *where, char *mail_cmd)
 {
-   DEST *d; 
+   DEST *d;
    /*
     * First search the existing chain and see if we
     * can simply add this msg_type to an existing entry.
     */
    for (d=msg->dest_chain; d; d=d->next) {
       if (dest_code == d->dest_code && ((where == NULL && d->where == NULL) ||
-                    (strcmp(where, d->where) == 0))) {  
-         Dmsg4(200, "Add to existing d=%x msgtype=%d destcode=%d where=%s\n", 
+                    (strcmp(where, d->where) == 0))) {
+        Dmsg4(200, "Add to existing d=%x msgtype=%d destcode=%d where=%s\n",
             d, msg_type, dest_code, NPRT(where));
         set_bit(msg_type, d->msg_types);
         set_bit(msg_type, msg->send_msg);  /* set msg_type bit in our local */
@@ -317,15 +317,15 @@ void add_msg_dest(MSGS *msg, int dest_code, int msg_type, char *where, char *mai
    if (mail_cmd) {
       d->mail_cmd = bstrdup(mail_cmd);
    }
-   Dmsg5(200, "add new d=%x msgtype=%d destcode=%d where=%s mailcmd=%s\n", 
+   Dmsg5(200, "add new d=%x msgtype=%d destcode=%d where=%s mailcmd=%s\n",
          d, msg_type, dest_code, NPRT(where), NPRT(d->mail_cmd));
    msg->dest_chain = d;
 }
 
-/* 
+/*
  * Called only during parsing of the config file.
  *
- * Remove a message destination   
+ * Remove a message destination
  */
 void rem_msg_dest(MSGS *msg, int dest_code, int msg_type, char *where)
 {
@@ -335,11 +335,11 @@ void rem_msg_dest(MSGS *msg, int dest_code, int msg_type, char *where)
       Dmsg2(200, "Remove_msg_dest d=%x where=%s\n", d, NPRT(d->where));
       if (bit_is_set(msg_type, d->msg_types) && (dest_code == d->dest_code) &&
          ((where == NULL && d->where == NULL) ||
-                    (strcmp(where, d->where) == 0))) {  
-         Dmsg3(200, "Found for remove d=%x msgtype=%d destcode=%d\n", 
+                    (strcmp(where, d->where) == 0))) {
+        Dmsg3(200, "Found for remove d=%x msgtype=%d destcode=%d\n",
               d, msg_type, dest_code);
         clear_bit(msg_type, d->msg_types);
-         Dmsg0(200, "Return rem_msg_dest\n");
+        Dmsg0(200, "Return rem_msg_dest\n");
         return;
       }
    }
@@ -367,7 +367,7 @@ static void make_unique_mail_filename(JCR *jcr, POOLMEM *&name, DEST *d)
 static BPIPE *open_mail_pipe(JCR *jcr, POOLMEM *&cmd, DEST *d)
 {
    BPIPE *bpipe;
-       
+
    if (d->mail_cmd) {
       cmd = edit_job_codes(jcr, cmd, d->mail_cmd, d->where);
    } else {
@@ -377,7 +377,7 @@ static BPIPE *open_mail_pipe(JCR *jcr, POOLMEM *&cmd, DEST *d)
 
    if (!(bpipe = open_bpipe(cmd, 120, "rw"))) {
       berrno be;
-      Jmsg(jcr, M_ERROR, 0, "open mail pipe %s failed: ERR=%s\n", 
+      Jmsg(jcr, M_ERROR, 0, "open mail pipe %s failed: ERR=%s\n",
         cmd, be.strerror());
    }
 
@@ -385,11 +385,11 @@ static BPIPE *open_mail_pipe(JCR *jcr, POOLMEM *&cmd, DEST *d)
    if (!d->mail_cmd) {
        fprintf(bpipe->wfd, "Subject: Bacula Message\r\n\r\n");
    }
-   
+
    return bpipe;
 }
 
-/* 
+/*
  * Close the messages for this Messages resource, which means to close
  *  any open files, and dispatch any pending email messages.
  */
@@ -400,7 +400,7 @@ void close_msg(JCR *jcr)
    BPIPE *bpipe;
    POOLMEM *cmd, *line;
    int len, stat;
-   
+
    Dmsg1(350, "Close_msg jcr=0x%x\n", jcr);
 
    if (jcr == NULL) {               /* NULL -> global chain */
@@ -426,7 +426,7 @@ void close_msg(JCR *jcr)
            break;
         case MD_MAIL:
         case MD_MAIL_ON_ERROR:
-            Dmsg0(350, "Got MD_MAIL or MD_MAIL_ON_ERROR\n");
+           Dmsg0(350, "Got MD_MAIL or MD_MAIL_ON_ERROR\n");
            if (!d->fd) {
               break;
            }
@@ -434,12 +434,12 @@ void close_msg(JCR *jcr)
                jcr->JobStatus == JS_Terminated) {
               goto rem_temp_file;
            }
-           
+
            if (!(bpipe=open_mail_pipe(jcr, cmd, d))) {
-               Pmsg0(000, "open mail pipe failed.\n");
+              Pmsg0(000, "open mail pipe failed.\n");
               goto rem_temp_file;
            }
-            Dmsg0(350, "Opened mail pipe\n");
+           Dmsg0(350, "Opened mail pipe\n");
            len = d->max_len+10;
            line = get_memory(len);
            rewind(d->fd);
@@ -448,18 +448,18 @@ void close_msg(JCR *jcr)
            }
            if (!close_wpipe(bpipe)) {       /* close write pipe sending mail */
               berrno be;
-               Pmsg1(000, "close error: ERR=%s\n", be.strerror());
+              Pmsg1(000, "close error: ERR=%s\n", be.strerror());
            }
 
            /*
-             * Since we are closing all messages, before "recursing"
+            * Since we are closing all messages, before "recursing"
             * make sure we are not closing the daemon messages, otherwise
             * kaboom.
             */
            if (msgs != daemon_msgs) {
               /* read what mail prog returned -- should be nothing */
               while (fgets(line, len, bpipe->rfd)) {
-                  Jmsg1(jcr, M_INFO, 0, _("Mail prog: %s"), line);
+                 Jmsg1(jcr, M_INFO, 0, _("Mail prog: %s"), line);
               }
            }
 
@@ -467,10 +467,10 @@ void close_msg(JCR *jcr)
            if (stat != 0 && msgs != daemon_msgs) {
               berrno be;
               be.set_errno(stat);
-               Dmsg1(350, "Calling emsg. CMD=%s\n", cmd);
-               Jmsg2(jcr, M_ERROR, 0, _("Mail program terminated in error.\n"
-                                        "CMD=%s\n"
-                                        "ERR=%s\n"), cmd, be.strerror());
+              Dmsg1(350, "Calling emsg. CMD=%s\n", cmd);
+              Jmsg2(jcr, M_ERROR, 0, _("Mail program terminated in error.\n"
+                                       "CMD=%s\n"
+                                       "ERR=%s\n"), cmd, be.strerror());
            }
            free_memory(line);
 rem_temp_file:
@@ -479,7 +479,7 @@ rem_temp_file:
            unlink(d->mail_filename);
            free_pool_memory(d->mail_filename);
            d->mail_filename = NULL;
-            Dmsg0(350, "end mail or mail on error\n");
+           Dmsg0(350, "end mail or mail on error\n");
            break;
         default:
            break;
@@ -500,7 +500,7 @@ rem_temp_file:
 }
 
 /*
- * Free memory associated with Messages resource  
+ * Free memory associated with Messages resource
  */
 void free_msgs_res(MSGS *msgs)
 {
@@ -523,10 +523,10 @@ void free_msgs_res(MSGS *msgs)
 }
 
 
-/* 
- * Terminate the message handler for good. 
+/*
+ * Terminate the message handler for good.
  * Release the global destination chain.
- * 
+ *
  * Also, clean up a few other items (cons, exepath). Note,
  *   these really should be done elsewhere.
  */
@@ -563,7 +563,7 @@ void term_msg()
  */
 void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
 {
-    DEST *d;   
+    DEST *d;
     char dt[MAX_TIME_LENGTH];
     POOLMEM *mcmd;
     int len, dtlen;
@@ -580,7 +580,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
      */
     if (mtime == 0) {
        mtime = time(NULL);
-    } 
+    }
     if (mtime == 1) {
        *dt = 0;
        dtlen = 0;
@@ -601,7 +601,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
        /* If we don't exit on error, error messages are parsed by UA */
        if (exit_on_error) {
-          MessageBox(NULL, msg, "Bacula", MB_OK);
+         MessageBox(NULL, msg, "Bacula", MB_OK);
        }
 #endif
 #endif
@@ -611,7 +611,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
     msgs = NULL;
     if (jcr) {
        msgs = jcr->jcr_msgs;
-    } 
+    }
     if (msgs == NULL) {
        msgs = daemon_msgs;
     }
@@ -619,10 +619,10 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
        if (bit_is_set(type, d->msg_types)) {
          switch (d->dest_code) {
             case MD_CONSOLE:
-                Dmsg1(800, "CONSOLE for following msg: %s", msg);
+               Dmsg1(800, "CONSOLE for following msg: %s", msg);
                if (!con_fd) {
-                   con_fd = fopen(con_fname, "a+");
-                   Dmsg0(800, "Console file not open.\n");
+                  con_fd = fopen(con_fname, "a+");
+                  Dmsg0(800, "Console file not open.\n");
                }
                if (con_fd) {
                   Pw(con_lock);      /* get write lock on console message file */
@@ -633,11 +633,11 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                   len = strlen(msg);
                   if (len > 0) {
                      fwrite(msg, len, 1, con_fd);
-                      if (msg[len-1] != '\n') {
-                         fwrite("\n", 2, 1, con_fd);
+                     if (msg[len-1] != '\n') {
+                        fwrite("\n", 2, 1, con_fd);
                      }
                   } else {
-                      fwrite("\n", 2, 1, con_fd);
+                     fwrite("\n", 2, 1, con_fd);
                   }
                   fflush(con_fd);
                   console_msg_pending = TRUE;
@@ -645,14 +645,14 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                }
                break;
             case MD_SYSLOG:
-                Dmsg1(800, "SYSLOG for collowing msg: %s\n", msg);
+               Dmsg1(800, "SYSLOG for collowing msg: %s\n", msg);
                /*
-                * We really should do an openlog() here.  
+                * We really should do an openlog() here.
                 */
-                syslog(LOG_DAEMON|LOG_ERR, "%s", msg);
+               syslog(LOG_DAEMON|LOG_ERR, "%s", msg);
                break;
             case MD_OPERATOR:
-                Dmsg1(800, "OPERATOR for following msg: %s\n", msg);
+               Dmsg1(800, "OPERATOR for following msg: %s\n", msg);
                mcmd = get_pool_memory(PM_MESSAGE);
                if ((bpipe=open_mail_pipe(jcr, mcmd, d))) {
                   int stat;
@@ -663,24 +663,24 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                   if (stat != 0) {
                      berrno be;
                      be.set_errno(stat);
-                      Qmsg2(jcr, M_ERROR, 0, _("Operator mail program terminated in error.\n"
-                            "CMD=%s\n"
-                            "ERR=%s\n"), mcmd, be.strerror());
+                     Qmsg2(jcr, M_ERROR, 0, _("Operator mail program terminated in error.\n"
+                           "CMD=%s\n"
+                           "ERR=%s\n"), mcmd, be.strerror());
                   }
                }
                free_pool_memory(mcmd);
                break;
             case MD_MAIL:
             case MD_MAIL_ON_ERROR:
-                Dmsg1(800, "MAIL for following msg: %s", msg);
+               Dmsg1(800, "MAIL for following msg: %s", msg);
                if (!d->fd) {
                   POOLMEM *name = get_pool_memory(PM_MESSAGE);
                   make_unique_mail_filename(jcr, name, d);
-                   d->fd = fopen(name, "w+");
+                  d->fd = fopen(name, "w+");
                   if (!d->fd) {
                      berrno be;
                      d->fd = stdout;
-                      Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", name, 
+                     Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", name,
                            be.strerror());
                      d->fd = NULL;
                      free_pool_memory(name);
@@ -696,13 +696,13 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                fputs(msg, d->fd);
                break;
             case MD_FILE:
-                Dmsg1(800, "FILE for following msg: %s", msg);
+               Dmsg1(800, "FILE for following msg: %s", msg);
                if (!d->fd) {
-                   d->fd = fopen(d->where, "w+");
+                  d->fd = fopen(d->where, "w+");
                   if (!d->fd) {
                      berrno be;
                      d->fd = stdout;
-                      Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, 
+                     Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where,
                            be.strerror());
                      d->fd = NULL;
                      break;
@@ -712,13 +712,13 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                fputs(msg, d->fd);
                break;
             case MD_APPEND:
-                Dmsg1(800, "APPEND for following msg: %s", msg);
+               Dmsg1(800, "APPEND for following msg: %s", msg);
                if (!d->fd) {
-                   d->fd = fopen(d->where, "a");
+                  d->fd = fopen(d->where, "a");
                   if (!d->fd) {
                      berrno be;
                      d->fd = stdout;
-                      Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, 
+                     Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where,
                            be.strerror());
                      d->fd = NULL;
                      break;
@@ -728,21 +728,21 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                fputs(msg, d->fd);
                break;
             case MD_DIRECTOR:
-                Dmsg1(800, "DIRECTOR for following msg: %s", msg);
+               Dmsg1(800, "DIRECTOR for following msg: %s", msg);
                if (jcr && jcr->dir_bsock && !jcr->dir_bsock->errors) {
-                   bnet_fsend(jcr->dir_bsock, "Jmsg Job=%s type=%d level=%d %s", 
+                  bnet_fsend(jcr->dir_bsock, "Jmsg Job=%s type=%d level=%d %s",
                      jcr->Job, type, mtime, msg);
                }
                break;
             case MD_STDOUT:
-                Dmsg1(800, "STDOUT for following msg: %s", msg);
+               Dmsg1(800, "STDOUT for following msg: %s", msg);
                if (type != M_ABORT && type != M_ERROR_TERM) { /* already printed */
                   fputs(dt, stdout);
                   fputs(msg, stdout);
                }
                break;
             case MD_STDERR:
-                Dmsg1(800, "STDERR for following msg: %s", msg);
+               Dmsg1(800, "STDERR for following msg: %s", msg);
                fputs(dt, stderr);
                fputs(msg, stderr);
                break;
@@ -760,11 +760,11 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
  *  is less than or equal the debug_level. File and line numbers
  *  are included for more detail if desired, but not currently
  *  printed.
- *  
+ *
  *  If the level is negative, the details of file and line number
  *  are not printed.
  */
-void 
+void
 d_msg(const char *file, int line, int level, const char *fmt,...)
 {
     char      buf[5000];
@@ -783,9 +783,9 @@ d_msg(const char *file, int line, int level, const char *fmt,...)
          /* visual studio passes the whole path to the file as well
           * which makes for very long lines
           */
-          const char *f = strrchr(file, '\\');
+         const char *f = strrchr(file, '\\');
          if (f) file = f + 1;
-          len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, file, line);
+         len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, file, line);
        } else {
          len = 0;
        }
@@ -796,14 +796,14 @@ d_msg(const char *file, int line, int level, const char *fmt,...)
        bvsnprintf(buf+len, sizeof(buf)-len, (char *)fmt, arg_ptr);
        va_end(arg_ptr);
 
-       /* 
-        * Used the "trace on" command in the console to turn on
-        *  output to the trace file.  "trace off" will close the file.
+       /*
+       * Used the "trace on" command in the console to turn on
+       *  output to the trace file.  "trace off" will close the file.
        */
        if (trace) {
          if (!trace_fd) {
-             bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory ? working_directory : ".");
-             trace_fd = fopen(buf, "a+");
+            bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory ? working_directory : ".");
+            trace_fd = fopen(buf, "a+");
          }
          if (trace_fd) {
             fputs(buf, trace_fd);
@@ -816,7 +816,7 @@ d_msg(const char *file, int line, int level, const char *fmt,...)
 }
 
 /*
- * Set trace flag on/off. If argument is negative, there is no change 
+ * Set trace flag on/off. If argument is negative, there is no change
  */
 void set_trace(int trace_flag)
 {
@@ -843,11 +843,11 @@ bool get_trace(void)
 /*********************************************************************
  *
  *  This subroutine prints a message regardless of the debug level
- *  
+ *
  *  If the level is negative, the details of file and line number
  *  are not printed.
  */
-void 
+void
 p_msg(const char *file, int line, int level, const char *fmt,...)
 {
     char      buf[5000];
@@ -876,11 +876,11 @@ p_msg(const char *file, int line, int level, const char *fmt,...)
  *  is less than or equal the debug_level. File and line numbers
  *  are included for more detail if desired, but not currently
  *  printed.
- *  
+ *
  *  If the level is negative, the details of file and line number
  *  are not printed.
  */
-void 
+void
 t_msg(const char *file, int line, int level, const char *fmt,...)
 {
     char      buf[5000];
@@ -895,13 +895,13 @@ t_msg(const char *file, int line, int level, const char *fmt,...)
 
     if (level <= debug_level) {
        if (!trace_fd) {
-          bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory);
-          trace_fd = fopen(buf, "a+");
+         bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory);
+         trace_fd = fopen(buf, "a+");
        }
-    
+
 #ifdef FULL_LOCATION
        if (details) {
-          len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, file, line);
+         len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, file, line);
        } else {
          len = 0;
        }
@@ -925,41 +925,41 @@ t_msg(const char *file, int line, int level, const char *fmt,...)
  * print an error message
  *
  */
-void 
+void
 e_msg(const char *file, int line, int type, int level, const char *fmt,...)
 {
     char     buf[5000];
     va_list   arg_ptr;
     int len;
 
-    /* 
-     * Check if we have a message destination defined. 
-     * We always report M_ABORT and M_ERROR_TERM 
+    /*
+     * Check if we have a message destination defined.
+     * We always report M_ABORT and M_ERROR_TERM
      */
-    if (!daemon_msgs || ((type != M_ABORT && type != M_ERROR_TERM) && 
+    if (!daemon_msgs || ((type != M_ABORT && type != M_ERROR_TERM) &&
                         !bit_is_set(type, daemon_msgs->send_msg))) {
        return;                       /* no destination */
     }
     switch (type) {
     case M_ABORT:
-       len = bsnprintf(buf, sizeof(buf), "%s: ABORTING due to ERROR in %s:%d\n", 
+       len = bsnprintf(buf, sizeof(buf), "%s: ABORTING due to ERROR in %s:%d\n",
               my_name, file, line);
        break;
     case M_ERROR_TERM:
-       len = bsnprintf(buf, sizeof(buf), "%s: ERROR TERMINATION at %s:%d\n", 
+       len = bsnprintf(buf, sizeof(buf), "%s: ERROR TERMINATION at %s:%d\n",
               my_name, file, line);
        break;
     case M_FATAL:
        if (level == -1)           /* skip details */
-          len = bsnprintf(buf, sizeof(buf), "%s: Fatal Error because: ", my_name);
+         len = bsnprintf(buf, sizeof(buf), "%s: Fatal Error because: ", my_name);
        else
-          len = bsnprintf(buf, sizeof(buf), "%s: Fatal Error at %s:%d because:\n", my_name, file, line);
+         len = bsnprintf(buf, sizeof(buf), "%s: Fatal Error at %s:%d because:\n", my_name, file, line);
        break;
     case M_ERROR:
        if (level == -1)           /* skip details */
-          len = bsnprintf(buf, sizeof(buf), "%s: ERROR: ", my_name);
+         len = bsnprintf(buf, sizeof(buf), "%s: ERROR: ", my_name);
        else
-          len = bsnprintf(buf, sizeof(buf), "%s: ERROR in %s:%d ", my_name, file, line);
+         len = bsnprintf(buf, sizeof(buf), "%s: ERROR in %s:%d ", my_name, file, line);
        break;
     case M_WARNING:
        len = bsnprintf(buf, sizeof(buf), "%s: Warning: ", my_name);
@@ -992,7 +992,7 @@ e_msg(const char *file, int line, int type, int level, const char *fmt,...)
  * Generate a Job message
  *
  */
-void 
+void
 Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
 {
     char     rbuf[5000];
@@ -1001,17 +1001,17 @@ Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
     MSGS *msgs;
     const char *job;
 
-    
+
     Dmsg1(800, "Enter Jmsg type=%d\n", type);
 
     /* Special case for the console, which has a dir_bsock and JobId==0,
      * in that case, we send the message directly back to the
-     * dir_bsock.  
+     * dir_bsock.
      */
     if (jcr && jcr->JobId == 0 && jcr->dir_bsock) {
        BSOCK *dir = jcr->dir_bsock;
        va_start(arg_ptr, fmt);
-       dir->msglen = bvsnprintf(dir->msg, sizeof_pool_memory(dir->msg), 
+       dir->msglen = bvsnprintf(dir->msg, sizeof_pool_memory(dir->msg),
                                fmt, arg_ptr);
        va_end(arg_ptr);
        bnet_send(jcr->dir_bsock);
@@ -1023,7 +1023,7 @@ Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
     if (jcr) {
        msgs = jcr->jcr_msgs;
        job = jcr->Job;
-    } 
+    }
     if (!msgs) {
        msgs = daemon_msgs;           /* if no jcr, we use daemon handler */
     }
@@ -1031,9 +1031,9 @@ Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
        job = "";                      /* Set null job name if none */
     }
 
-    /* 
-     * Check if we have a message destination defined. 
-     * We always report M_ABORT and M_ERROR_TERM 
+    /*
+     * Check if we have a message destination defined.
+     * We always report M_ABORT and M_ERROR_TERM
      */
     if (msgs && (type != M_ABORT && type != M_ERROR_TERM) &&
         !bit_is_set(type, msgs->send_msg)) {
@@ -1098,7 +1098,7 @@ void j_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const c
    i = Mmsg(pool_buf, "%s:%d ", file, line);
 
    for (;;) {
-      maxlen = sizeof_pool_memory(pool_buf) - i - 1; 
+      maxlen = sizeof_pool_memory(pool_buf) - i - 1;
       va_start(arg_ptr, fmt);
       len = bvsnprintf(pool_buf+i, maxlen, fmt, arg_ptr);
       va_end(arg_ptr);
@@ -1116,7 +1116,7 @@ void j_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const c
 
 /*
  * Edit a message into a Pool memory buffer, with file:lineno
- */                                                 
+ */
 int m_msg(const char *file, int line, POOLMEM **pool_buf, const char *fmt, ...)
 {
    va_list   arg_ptr;
@@ -1125,7 +1125,7 @@ int m_msg(const char *file, int line, POOLMEM **pool_buf, const char *fmt, ...)
    i = sprintf(*pool_buf, "%s:%d ", file, line);
 
    for (;;) {
-      maxlen = sizeof_pool_memory(*pool_buf) - i - 1; 
+      maxlen = sizeof_pool_memory(*pool_buf) - i - 1;
       va_start(arg_ptr, fmt);
       len = bvsnprintf(*pool_buf+i, maxlen, fmt, arg_ptr);
       va_end(arg_ptr);
@@ -1146,7 +1146,7 @@ int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...)
    i = sprintf(pool_buf, "%s:%d ", file, line);
 
    for (;;) {
-      maxlen = sizeof_pool_memory(pool_buf) - i - 1; 
+      maxlen = sizeof_pool_memory(pool_buf) - i - 1;
       va_start(arg_ptr, fmt);
       len = bvsnprintf(pool_buf+i, maxlen, fmt, arg_ptr);
       va_end(arg_ptr);
@@ -1170,7 +1170,7 @@ int Mmsg(POOLMEM **pool_buf, const char *fmt, ...)
    int len, maxlen;
 
    for (;;) {
-      maxlen = sizeof_pool_memory(*pool_buf) - 1; 
+      maxlen = sizeof_pool_memory(*pool_buf) - 1;
       va_start(arg_ptr, fmt);
       len = bvsnprintf(*pool_buf, maxlen, fmt, arg_ptr);
       va_end(arg_ptr);
@@ -1189,7 +1189,7 @@ int Mmsg(POOLMEM *&pool_buf, const char *fmt, ...)
    int len, maxlen;
 
    for (;;) {
-      maxlen = sizeof_pool_memory(pool_buf) - 1; 
+      maxlen = sizeof_pool_memory(pool_buf) - 1;
       va_start(arg_ptr, fmt);
       len = bvsnprintf(pool_buf, maxlen, fmt, arg_ptr);
       va_end(arg_ptr);
@@ -1208,7 +1208,7 @@ int Mmsg(POOL_MEM &pool_buf, const char *fmt, ...)
    int len, maxlen;
 
    for (;;) {
-      maxlen = pool_buf.max_size() - 1; 
+      maxlen = pool_buf.max_size() - 1;
       va_start(arg_ptr, fmt);
       len = bvsnprintf(pool_buf.c_str(), maxlen, fmt, arg_ptr);
       va_end(arg_ptr);
@@ -1227,7 +1227,7 @@ static pthread_mutex_t msg_queue_mutex = PTHREAD_MUTEX_INITIALIZER;
 /*
  * We queue messages rather than print them directly. This
  *  is generally used in low level routines (msg handler, bnet)
- *  to prevent recursion (i.e. if you are in the middle of 
+ *  to prevent recursion (i.e. if you are in the middle of
  *  sending a message, it is a bit messy to recursively call
  *  yourself when the bnet packet is not reentrant).
  */
@@ -1241,7 +1241,7 @@ void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
    pool_buf = get_pool_memory(PM_EMSG);
 
    for (;;) {
-      maxlen = sizeof_pool_memory(pool_buf) - 1; 
+      maxlen = sizeof_pool_memory(pool_buf) - 1;
       va_start(arg_ptr, fmt);
       len = bvsnprintf(pool_buf, maxlen, fmt, arg_ptr);
       va_end(arg_ptr);
@@ -1254,7 +1254,7 @@ void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
    item = (MQUEUE_ITEM *)malloc(sizeof(MQUEUE_ITEM) + strlen(pool_buf) + 1);
    item->type = type;
    item->mtime = time(NULL);
-   strcpy(item->msg, pool_buf);  
+   strcpy(item->msg, pool_buf);
    /* If no jcr or dequeuing send to daemon to avoid recursion */
    if (!jcr || jcr->dequeuing) {
       /* jcr==NULL => daemon message, safe to send now */
@@ -1271,7 +1271,7 @@ void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
 }
 
 /*
- * Dequeue messages 
+ * Dequeue messages
  */
 void dequeue_messages(JCR *jcr)
 {
@@ -1285,7 +1285,7 @@ void dequeue_messages(JCR *jcr)
    jcr->msg_queue->destroy();
    jcr->dequeuing = false;
    V(msg_queue_mutex);
-}                                                
+}
 
 
 /*
@@ -1302,7 +1302,7 @@ void q_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const c
    i = Mmsg(pool_buf, "%s:%d ", file, line);
 
    for (;;) {
-      maxlen = sizeof_pool_memory(pool_buf) - i - 1; 
+      maxlen = sizeof_pool_memory(pool_buf) - i - 1;
       va_start(arg_ptr, fmt);
       len = bvsnprintf(pool_buf+i, maxlen, fmt, arg_ptr);
       va_end(arg_ptr);
@@ -1317,7 +1317,7 @@ void q_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const c
    free_memory(pool_buf);
 }
 
-/* 
+/*
  * Define if e_msg must exit when M_ERROR_TERM is received
  */
 void set_exit_on_error(int value) {
index 969aafd94ac25b296cc9f9492d0cd532ba3748f3..677efbb9c2cf9039076abd937064dd1a05f173af 100644 (file)
@@ -40,7 +40,7 @@
 #undef  M_ALERT
 
 /*
- * Most of these message levels are more or less obvious. 
+ * Most of these message levels are more or less obvious.
  * They have evolved somewhat during the development of Bacula,
  * and here are some of the details of where I am trying to
  * head (in the process of changing the code) as of 15 June 2002.
@@ -57,7 +57,7 @@
  *  M_FATAL       Bacula detected a fatal Job error. The Job will be killed,
  *                  but Bacula continues running.
  *  M_ERROR       Bacula detected a Job error. The Job will continue running
- *                  but the termination status will be error. 
+ *                  but the termination status will be error.
  *  M_WARNING     Job warning message.
  *  M_INFO        Job information message.
  *
index 82e22502ee998d4b2b398dd1075ca0b093e11a15..f79e1b8fa21312b6e82598aba571d82cc1d7f7df 100755 (executable)
@@ -1,6 +1,6 @@
 /*
  *   Master Configuration routines.
- *  
+ *
  *   This file contains the common parts of the Bacula
  *   configuration routines.
  *
@@ -8,7 +8,7 @@
  *
  *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
  *
- *   2. The generic config  scanner in lib/parse_conf.c and 
+ *   2. The generic config  scanner in lib/parse_conf.c and
  *     lib/parse_conf.h.
  *     These files contain the parser code, some utility
  *     routines, and the common store routines (name, int,
@@ -58,7 +58,7 @@
 
 extern int debug_level;
 
-/* Each daemon has a slightly different set of 
+/* Each daemon has a slightly different set of
  * resources, so it will define the following
  * global values.
  */
@@ -95,7 +95,7 @@ RES_ITEM msgs_items[] = {
    {"description", store_str,     ITEM(res_msgs.hdr.desc),  0, 0, 0},
    {"mailcommand", store_str,     ITEM(res_msgs.mail_cmd),  0, 0, 0},
    {"operatorcommand", store_str, ITEM(res_msgs.operator_cmd), 0, 0, 0},
-   {"syslog",      store_msgs, ITEM(res_msgs), MD_SYSLOG,   0, 0}, 
+   {"syslog",      store_msgs, ITEM(res_msgs), MD_SYSLOG,   0, 0},
    {"mail",        store_msgs, ITEM(res_msgs), MD_MAIL,     0, 0},
    {"mailonerror", store_msgs, ITEM(res_msgs), MD_MAIL_ON_ERROR, 0, 0},
    {"file",        store_msgs, ITEM(res_msgs), MD_FILE,     0, 0},
@@ -103,14 +103,14 @@ RES_ITEM msgs_items[] = {
    {"stdout",      store_msgs, ITEM(res_msgs), MD_STDOUT,   0, 0},
    {"stderr",      store_msgs, ITEM(res_msgs), MD_STDERR,   0, 0},
    {"director",    store_msgs, ITEM(res_msgs), MD_DIRECTOR, 0, 0},
-   {"console",     store_msgs, ITEM(res_msgs), MD_CONSOLE,  0, 0},   
+   {"console",     store_msgs, ITEM(res_msgs), MD_CONSOLE,  0, 0},
    {"operator",    store_msgs, ITEM(res_msgs), MD_OPERATOR, 0, 0},
    {NULL, NULL,    NULL,       0,             0}
 };
 
-struct s_mtypes {      
+struct s_mtypes {
    const char *name;
-   int token;  
+   int token;
 };
 /* Various message types */
 static struct s_mtypes msg_types[] = {
@@ -153,7 +153,7 @@ const char *res_to_str(int rcode)
 }
 
 
-/* 
+/*
  * Initialize the static structure to zeros, then
  *  apply all the default values.
  */
@@ -165,7 +165,7 @@ void init_resource(int type, RES_ITEM *items, int pass)
    int errstat;
 
    if (first && (errstat=rwl_init(&res_lock)) != 0) {
-      Emsg1(M_ABORT, 0, _("Unable to initialize resource lock. ERR=%s\n"), 
+      Emsg1(M_ABORT, 0, _("Unable to initialize resource lock. ERR=%s\n"),
            strerror(errstat));
    }
    first = false;
@@ -176,12 +176,12 @@ void init_resource(int type, RES_ITEM *items, int pass)
 
    for (i=0; items[i].name; i++) {
       Dmsg3(900, "Item=%s def=%s defval=%d\n", items[i].name,
-            (items[i].flags & ITEM_DEFAULT) ? "yes" : "no",      
+           (items[i].flags & ITEM_DEFAULT) ? "yes" : "no",
            items[i].default_value);
       if (items[i].flags & ITEM_DEFAULT && items[i].default_value != 0) {
         if (items[i].handler == store_yesno) {
            *(int *)(items[i].value) |= items[i].code;
-        } else if (items[i].handler == store_pint || 
+        } else if (items[i].handler == store_pint ||
                    items[i].handler == store_int) {
            *(int *)(items[i].value) = items[i].default_value;
         } else if (items[i].handler == store_int64) {
@@ -196,7 +196,7 @@ void init_resource(int type, RES_ITEM *items, int pass)
       }
       /* If this triggers, take a look at lib/parse_conf.h */
       if (i >= MAX_RES_ITEMS) {
-         Emsg1(M_ERROR_TERM, 0, _("Too many items in %s resource\n"), resources[rindex]);
+        Emsg1(M_ERROR_TERM, 0, _("Too many items in %s resource\n"), resources[rindex]);
       }
    }
 }
@@ -208,7 +208,7 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
    int token;
    char *cmd;
    POOLMEM *dest;
-   int dest_len;    
+   int dest_len;
 
    Dmsg2(900, "store_msgs pass=%d code=%d\n", pass, item->code);
    if (pass == 1) {
@@ -236,25 +236,25 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
            token = lex_get_token(lc, T_NAME);   /* scan destination */
            dest = check_pool_memory_size(dest, dest_len + lc->str_len + 2);
            if (dest[0] != 0) {
-               pm_strcat(dest, " ");  /* separate multiple destinations with space */
+              pm_strcat(dest, " ");  /* separate multiple destinations with space */
               dest_len++;
            }
            pm_strcat(dest, lc->str);
            dest_len += lc->str_len;
-            Dmsg2(900, "store_msgs newdest=%s: dest=%s:\n", lc->str, NPRT(dest));
+           Dmsg2(900, "store_msgs newdest=%s: dest=%s:\n", lc->str, NPRT(dest));
            token = lex_get_token(lc, T_SKIP_EOL);
-           if (token == T_COMMA) { 
+           if (token == T_COMMA) {
               continue;           /* get another destination */
            }
            if (token != T_EQUALS) {
-               scan_err1(lc, _("expected an =, got: %s"), lc->str); 
+              scan_err1(lc, _("expected an =, got: %s"), lc->str);
            }
            break;
         }
-         Dmsg1(900, "mail_cmd=%s\n", NPRT(cmd));
+        Dmsg1(900, "mail_cmd=%s\n", NPRT(cmd));
         scan_types(lc, (MSGS *)(item->value), item->code, dest, cmd);
         free_pool_memory(dest);
-         Dmsg0(900, "done with dest codes\n");
+        Dmsg0(900, "done with dest codes\n");
         break;
       case MD_FILE:               /* file */
       case MD_APPEND:             /* append */
@@ -264,17 +264,17 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
         pm_strcpy(dest, lc->str);
         dest_len = lc->str_len;
         token = lex_get_token(lc, T_SKIP_EOL);
-         Dmsg1(900, "store_msgs dest=%s:\n", NPRT(dest));
+        Dmsg1(900, "store_msgs dest=%s:\n", NPRT(dest));
         if (token != T_EQUALS) {
-            scan_err1(lc, _("expected an =, got: %s"), lc->str); 
+           scan_err1(lc, _("expected an =, got: %s"), lc->str);
         }
         scan_types(lc, (MSGS *)(item->value), item->code, dest, NULL);
         free_pool_memory(dest);
-         Dmsg0(900, "done with dest codes\n");
+        Dmsg0(900, "done with dest codes\n");
         break;
 
       default:
-         scan_err1(lc, _("Unknown item code: %d\n"), item->code);
+        scan_err1(lc, _("Unknown item code: %d\n"), item->code);
         break;
       }
    }
@@ -283,7 +283,7 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
    Dmsg0(900, "Done store_msgs\n");
 }
 
-/* 
+/*
  * Scan for message types and add them to the message
  * destination. The basic job here is to connect message types
  *  (WARNING, ERROR, FATAL, INFO, ...) with an appropriate
@@ -296,7 +296,7 @@ static void scan_types(LEX *lc, MSGS *msg, int dest_code, char *where, char *cmd
    char *str;
 
    for (quit=0; !quit;) {
-      lex_get_token(lc, T_NAME);           /* expect at least one type */       
+      lex_get_token(lc, T_NAME);           /* expect at least one type */
       found = FALSE;
       if (lc->str[0] == '!') {
         is_not = TRUE;
@@ -313,7 +313,7 @@ static void scan_types(LEX *lc, MSGS *msg, int dest_code, char *where, char *cmd
         }
       }
       if (!found) {
-         scan_err1(lc, _("message type: %s not found"), str);
+        scan_err1(lc, _("message type: %s not found"), str);
         /* NOT REACHED */
       }
 
@@ -338,7 +338,7 @@ static void scan_types(LEX *lc, MSGS *msg, int dest_code, char *where, char *cmd
 }
 
 
-/* 
+/*
  * This routine is ONLY for resource names
  *  Store a name at specified address.
  */
@@ -352,7 +352,7 @@ void store_name(LEX *lc, RES_ITEM *item, int index, int pass)
    free_pool_memory(msg);
    /* Store the name both pass 1 and pass 2 */
    if (*(item->value)) {
-      scan_err2(lc, _("Attempt to redefine name \"%s\" to \"%s\"."), 
+      scan_err2(lc, _("Attempt to redefine name \"%s\" to \"%s\"."),
         *(item->value), lc->str);
    }
    *(item->value) = bstrdup(lc->str);
@@ -421,7 +421,7 @@ void store_password(LEX *lc, RES_ITEM *item, int index, int pass)
       MD5Update(&md5c, (unsigned char *) (lc->str), lc->str_len);
       MD5Final(signature, &md5c);
       for (i = j = 0; i < sizeof(signature); i++) {
-         sprintf(&sig[j], "%02x", signature[i]); 
+        sprintf(&sig[j], "%02x", signature[i]);
         j += 2;
       }
       *(item->value) = bstrdup(sig);
@@ -432,7 +432,7 @@ void store_password(LEX *lc, RES_ITEM *item, int index, int pass)
 
 
 /* Store a resource at specified address.
- * If we are in pass 2, do a lookup of the 
+ * If we are in pass 2, do a lookup of the
  * resource.
  */
 void store_res(LEX *lc, RES_ITEM *item, int index, int pass)
@@ -443,11 +443,11 @@ void store_res(LEX *lc, RES_ITEM *item, int index, int pass)
    if (pass == 2) {
       res = GetResWithName(item->code, lc->str);
       if (res == NULL) {
-         scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"), 
+        scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"),
            lc->str, lc->line_no, lc->line);
       }
       if (*(item->value)) {
-         scan_err3(lc, _("Attempt to redefine resource \"%s\" referenced on line %d : %s\n"), 
+        scan_err3(lc, _("Attempt to redefine resource \"%s\" referenced on line %d : %s\n"),
            item->name, lc->line_no, lc->line);
       }
       *(item->value) = (char *)res;
@@ -460,7 +460,7 @@ void store_res(LEX *lc, RES_ITEM *item, int index, int pass)
  * Store a resource in an alist. default_value indicates how many
  *   times this routine can be called -- i.e. how many alists
  *   there are.
- * If we are in pass 2, do a lookup of the 
+ * If we are in pass 2, do a lookup of the
  *   resource.
  */
 void store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass)
@@ -474,7 +474,7 @@ void store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass)
       /* Find empty place to store this directive */
       while ((item->value)[i] != NULL && i++ < count) { }
       if (i >= count) {
-         scan_err3(lc, _("Too many Storage directives. Max. is %d. line %d: %s\n"),
+        scan_err3(lc, _("Too many Storage directives. Max. is %d. line %d: %s\n"),
            count, lc->line_no, lc->line);
       }
       list = New(alist(10, not_owned_by_alist));
@@ -483,12 +483,12 @@ void store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass)
         lex_get_token(lc, T_NAME);   /* scan next item */
         res = GetResWithName(item->code, lc->str);
         if (res == NULL) {
-            scan_err3(lc, _("Could not find config Resource \"%s\" referenced on line %d : %s\n"), 
+           scan_err3(lc, _("Could not find config Resource \"%s\" referenced on line %d : %s\n"),
               lc->str, lc->line_no, lc->line);
         }
         list->append(res);
         (item->value)[i] = (char *)list;
-         if (lc->ch != ',') {         /* if no other item follows */
+        if (lc->ch != ',') {         /* if no other item follows */
            break;                    /* get out */
         }
         lex_get_token(lc, T_ALL);    /* eat comma */
@@ -501,7 +501,7 @@ void store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass)
 
 /*
  * Store default values for Resource from xxxDefs
- * If we are in pass 2, do a lookup of the 
+ * If we are in pass 2, do a lookup of the
  * resource and store everything not explicitly set
  * in main resource.
  *
@@ -517,16 +517,16 @@ void store_defs(LEX *lc, RES_ITEM *item, int index, int pass)
      Dmsg2(900, "Code=%d name=%s\n", item->code, lc->str);
      res = GetResWithName(item->code, lc->str);
      if (res == NULL) {
-        scan_err3(lc, _("Missing config Resource \"%s\" referenced on line %d : %s\n"), 
+       scan_err3(lc, _("Missing config Resource \"%s\" referenced on line %d : %s\n"),
           lc->str, lc->line_no, lc->line);
      }
      /* for each item not set, we copy the field from res */
 #ifdef xxx
      for (int i=0; item->name;; i++, item++) {
        if (bit_is_set(i, res->item_present)) {
-           Dmsg2(900, "Item %d is present in %s\n", i, res->name);
+          Dmsg2(900, "Item %d is present in %s\n", i, res->name);
        } else {
-           Dmsg2(900, "Item %d is not present in %s\n", i, res->name);
+          Dmsg2(900, "Item %d is not present in %s\n", i, res->name);
        }
      }
      /* ***FIXME **** add code */
@@ -579,7 +579,7 @@ void store_size(LEX *lc, RES_ITEM *item, int index, int pass)
    case T_IDENTIFIER:
    case T_UNQUOTED_STRING:
       if (!size_to_uint64(lc->str, lc->str_len, &uvalue)) {
-         scan_err1(lc, _("expected a size number, got: %s"), lc->str);
+        scan_err1(lc, _("expected a size number, got: %s"), lc->str);
       }
       *(uint64_t *)(item->value) = uvalue;
       break;
@@ -596,7 +596,7 @@ void store_size(LEX *lc, RES_ITEM *item, int index, int pass)
 /* Store a time period in seconds */
 void store_time(LEX *lc, RES_ITEM *item, int index, int pass)
 {
-   int token; 
+   int token;
    utime_t utime;
    char period[500];
 
@@ -617,7 +617,7 @@ void store_time(LEX *lc, RES_ITEM *item, int index, int pass)
         }
       }
       if (!duration_to_utime(period, &utime)) {
-         scan_err1(lc, _("expected a time period, got: %s"), period);
+        scan_err1(lc, _("expected a time period, got: %s"), period);
       }
       *(utime_t *)(item->value) = utime;
       break;
@@ -697,7 +697,7 @@ GetResWithName(int rcode, char *name)
    }
    UnlockRes();
    return res;
-   
+
 }
 
 /*
@@ -710,7 +710,7 @@ GetNextRes(int rcode, RES *res)
 {
    RES *nres;
    int rindex = rcode - r_first;
-       
+
 
    if (!res_locked) {
       Emsg0(M_ABORT, 0, "Resource chain not locked.\n");
@@ -733,10 +733,10 @@ enum parse_state {
 /*********************************************************************
  *
  *     Parse configuration file
- * 
+ *
  * Return 0 if reading failed, 1 otherwise
  */
-int 
+int
 parse_config(const char *cf, int exit_on_error)
 {
    set_exit_on_error(exit_on_error);
@@ -748,7 +748,7 @@ parse_config(const char *cf, int exit_on_error)
    int level = 0;
 
    /* Make two passes. The first builds the name symbol table,
-    * and the second picks up the items. 
+    * and the second picks up the items.
     */
    Dmsg0(900, "Enter parse_config()\n");
    for (pass=1; pass <= 2; pass++) {
@@ -758,14 +758,14 @@ parse_config(const char *cf, int exit_on_error)
         return 0;
       }
       while ((token=lex_get_token(lc, T_ALL)) != T_EOF) {
-         Dmsg1(900, "parse got token=%s\n", lex_tok_to_str(token));
+        Dmsg1(900, "parse got token=%s\n", lex_tok_to_str(token));
         switch (state) {
         case p_none:
            if (token == T_EOL) {
               break;
            }
            if (token != T_IDENTIFIER) {
-               scan_err1(lc, _("Expected a Resource name identifier, got: %s"), lc->str);
+              scan_err1(lc, _("Expected a Resource name identifier, got: %s"), lc->str);
               set_exit_on_error(1); /* Never reached if exit_on_error == 1 */
               return 0;
            }
@@ -778,7 +778,7 @@ parse_config(const char *cf, int exit_on_error)
                  break;
               }
            if (state == p_none) {
-               scan_err1(lc, _("expected resource name, got: %s"), lc->str);
+              scan_err1(lc, _("expected resource name, got: %s"), lc->str);
               set_exit_on_error(1); /* Never reached if exit_on_error == 1 */
               return 0;
            }
@@ -790,24 +790,24 @@ parse_config(const char *cf, int exit_on_error)
               break;
            case T_IDENTIFIER:
               if (level != 1) {
-                  scan_err1(lc, _("not in resource definition: %s"), lc->str);
+                 scan_err1(lc, _("not in resource definition: %s"), lc->str);
                  set_exit_on_error(1); /* Never reached if exit_on_error == 1 */
                  return 0;
               }
               for (i=0; items[i].name; i++) {
                  if (strcasecmp(items[i].name, lc->str) == 0) {
-                    /* If the ITEM_NO_EQUALS flag is set we do NOT              
+                    /* If the ITEM_NO_EQUALS flag is set we do NOT
                      *   scan for = after the keyword  */
                     if (!(items[i].flags & ITEM_NO_EQUALS)) {
                        token = lex_get_token(lc, T_SKIP_EOL);
-                        Dmsg1 (900, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
+                       Dmsg1 (900, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
                        if (token != T_EQUALS) {
-                           scan_err1(lc, _("expected an equals, got: %s"), lc->str);
+                          scan_err1(lc, _("expected an equals, got: %s"), lc->str);
                           set_exit_on_error(1); /* Never reached if exit_on_error == 1 */
                           return 0;
                        }
                     }
-                     Dmsg1(900, "calling handler for %s\n", items[i].name);
+                    Dmsg1(900, "calling handler for %s\n", items[i].name);
                     /* Call item handler */
                     items[i].handler(lc, &items[i], i, pass);
                     i = -1;
@@ -815,10 +815,10 @@ parse_config(const char *cf, int exit_on_error)
                  }
               }
               if (i >= 0) {
-                  Dmsg2(900, "level=%d id=%s\n", level, lc->str);
-                  Dmsg1(900, "Keyword = %s\n", lc->str);
-                  scan_err1(lc, _("Keyword \"%s\" not permitted in this resource.\n"
-                     "Perhaps you left the trailing brace off of the previous resource."), lc->str);
+                 Dmsg2(900, "level=%d id=%s\n", level, lc->str);
+                 Dmsg1(900, "Keyword = %s\n", lc->str);
+                 scan_err1(lc, _("Keyword \"%s\" not permitted in this resource.\n"
+                    "Perhaps you left the trailing brace off of the previous resource."), lc->str);
                  set_exit_on_error(1); /* Never reached if exit_on_error == 1 */
                  return 0;
               }
@@ -827,7 +827,7 @@ parse_config(const char *cf, int exit_on_error)
            case T_EOB:
               level--;
               state = p_none;
-               Dmsg0(900, "T_EOB => define new resource\n");
+              Dmsg0(900, "T_EOB => define new resource\n");
               save_resource(res_type, items, pass);  /* save resource */
               break;
 
@@ -835,20 +835,20 @@ parse_config(const char *cf, int exit_on_error)
               break;
 
            default:
-               scan_err2(lc, _("unexpected token %d %s in resource definition"),    
+              scan_err2(lc, _("unexpected token %d %s in resource definition"),
                  token, lex_tok_to_str(token));
               set_exit_on_error(1); /* Never reached if exit_on_error == 1 */
               return 0;
            }
            break;
         default:
-            scan_err1(lc, _("Unknown parser state %d\n"), state);
+           scan_err1(lc, _("Unknown parser state %d\n"), state);
            set_exit_on_error(1); /* Never reached if exit_on_error == 1 */
            return 0;
         }
       }
       if (state != p_none) {
-         scan_err0(lc, _("End of conf file reached with unclosed resource."));
+        scan_err0(lc, _("End of conf file reached with unclosed resource."));
         set_exit_on_error(1); /* Never reached if exit_on_error == 1 */
         return 0;
       }
@@ -878,7 +878,7 @@ void free_config_resources()
    }
 }
 
-RES **save_config_resources() 
+RES **save_config_resources()
 {
    int num = r_last - r_first + 1;
    RES **res = (RES **)malloc(num*sizeof(RES *));
index 1385e3e3bf165a40e26b3052b020be722bbdf99e..f28a411b3e3bce5e3ce47ddcf01e9e0aef6a9e97 100644 (file)
@@ -21,7 +21,7 @@
 
  */
 
-struct RES_ITEM;                   /* Declare forward referenced structure */ 
+struct RES_ITEM;                   /* Declare forward referenced structure */
 typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
 
 /* This is the structure that defines
@@ -57,12 +57,12 @@ struct RES {
 };
 
 
-/* 
+/*
  * Master Resource configuration structure definition
  * This is the structure that defines the
  * resources that are available to this daemon.
  */
-struct RES_TABLE {      
+struct RES_TABLE {
    const char *name;                 /* resource name */
    RES_ITEM *items;                  /* list of resource keywords */
    int rcode;                        /* code if needed */
@@ -115,11 +115,11 @@ const char *res_to_str(int rcode);
 
 /* Loop through each resource of type, returning in var */
 #define foreach_res(var, type) \
-    for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));) 
+    for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));)
 
 #ifdef the_old_way
 #define foreach_res(var, type) \
-       for((var)=NULL; (((void *)(var))=GetNextRes((type), (RES *)var));) 
+       for((var)=NULL; (((void *)(var))=GetNextRes((type), (RES *)var));)
 #endif
 
 
index ba5bad997b825556a8b16bd92c7c9f58e339cef1..199abd8f0369955dfd0453bd609d57e5311180e0 100644 (file)
@@ -73,11 +73,11 @@ bool       bnet_sig              (BSOCK *bs, int sig);
 int        bnet_ssl_server       (BSOCK *bsock, char *password, int ssl_need, int ssl_has);
 int        bnet_ssl_client       (BSOCK *bsock, char *password, int ssl_need);
 BSOCK *    bnet_connect            (JCR *jcr, int retry_interval,
-               int max_retry_time, const char *name, char *host, char *service, 
-               int port, int verbose);
+              int max_retry_time, const char *name, char *host, char *service,
+              int port, int verbose);
 void       bnet_close            (BSOCK *bsock);
-BSOCK *    init_bsock            (JCR *jcr, int sockfd, const char *who, const char *ip, 
-                                  int port, struct sockaddr *client_addr);
+BSOCK *    init_bsock            (JCR *jcr, int sockfd, const char *who, const char *ip,
+                                 int port, struct sockaddr *client_addr);
 BSOCK *    dup_bsock             (BSOCK *bsock);
 void       term_bsock            (BSOCK *bsock);
 const char *bnet_strerror         (BSOCK *bsock);
@@ -102,7 +102,7 @@ int              close_bpipe(BPIPE *bpipe);
 int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need);
 int cram_md5_auth(BSOCK *bs, char *password, int ssl_need);
 void hmac_md5(uint8_t* text, int text_len, uint8_t*  key,
-              int key_len, uint8_t *hmac);
+             int key_len, uint8_t *hmac);
 
 /* crc32.c */
 
@@ -159,8 +159,8 @@ void       set_trace             (int trace_flag);
 void       set_exit_on_error     (int value);
 
 /* bnet_server.c */
-void       bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq, 
-                   void *handle_client_request(void *bsock));
+void       bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq,
+                  void *handle_client_request(void *bsock));
 void       bnet_stop_thread_server(pthread_t tid);
 void             bnet_server             (int port, void handle_client_request(BSOCK *bsock));
 int              net_connect             (int port);
@@ -190,10 +190,10 @@ bool             skip_spaces             (char **msg);
 bool             skip_nonspaces          (char **msg);
 int              fstrsch                 (const char *a, const char *b);
 char            *next_arg(char **s);
-int              parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, 
-                        char **argk, char **argv, int max_args);
-void            split_path_and_filename(const char *fname, POOLMEM **path, 
-                        int *pnl, POOLMEM **file, int *fnl);
+int              parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
+                       char **argk, char **argv, int max_args);
+void            split_path_and_filename(const char *fname, POOLMEM **path,
+                       int *pnl, POOLMEM **file, int *fnl);
 int             bsscanf(const char *buf, const char *fmt, ...);
 
 
index 191ffd61e16a9fb5aa2ba0842f339902b3c5672b..aaf71faf8f38baee0a8566fdeb38eb30efe37f13 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 
+ *
  * Bacula common code library interface to Python
  *
  * Kern Sibbald, November MMIV
@@ -7,7 +7,7 @@
  *   Version $Id$
  *
  */
-   
+
 /*
    Copyright (C) 2004 Kern Sibbald
 
@@ -54,7 +54,7 @@ void init_python_interpreter(const char *progname, const char *scripts)
    PyEval_InitThreads();
    Py_InitModule("bacula", BaculaMethods);
    bsnprintf(buf, sizeof(buf), "import sys\n"
-            "sys.path.append('%s')\n", scripts);
+           "sys.path.append('%s')\n", scripts);
    PyRun_SimpleString(buf);
    PyEval_ReleaseLock();
    generate_event = _generate_event;
@@ -66,7 +66,7 @@ void term_python_interpreter()
 }
 
 
-/* 
+/*
  * Generate and process a Bacula event by importing a Python
  *  module and running it.
  *
@@ -102,7 +102,7 @@ int _generate_event(JCR *jcr, const char *event)
          if (!pValue) {
             Py_DECREF(pArgs);
             Py_DECREF(pModule);
-             Jmsg(jcr, M_ERROR, 0, "Could not convert JCR to Python CObject.\n");
+            Jmsg(jcr, M_ERROR, 0, "Could not convert JCR to Python CObject.\n");
             return -1;               /* Could not convert JCR to CObject */
          }
          /* pValue reference stolen here: */
@@ -116,7 +116,7 @@ int _generate_event(JCR *jcr, const char *event)
          } else {
             Py_DECREF(pModule);
             PyErr_Print();
-             Jmsg(jcr, M_ERROR, 0, "Error running Python module: %s\n", event);
+            Jmsg(jcr, M_ERROR, 0, "Error running Python module: %s\n", event);
             return 0;                /* error running function */
          }
          /* pDict and pFunc are borrowed and must not be Py_DECREF-ed */
@@ -124,8 +124,8 @@ int _generate_event(JCR *jcr, const char *event)
         if (PyErr_Occurred()) {
            PyErr_Print();
         }
-         Jmsg(jcr, M_ERROR, 0, "Python function \"%s\" not found in module.\n", event);
-        return -1;                   /* function not found */ 
+        Jmsg(jcr, M_ERROR, 0, "Python function \"%s\" not found in module.\n", event);
+        return -1;                   /* function not found */
       }
       Py_DECREF(pModule);
    } else {
index 19fd12599e6e664d7108b984be8d24a46243a9b0..1f3473bc76406d17e33a949a42ecdcc75b6dd760 100644 (file)
@@ -7,7 +7,7 @@
 
                  http://www.fourmilab.ch/smartall/
 
-  
+
        Version $Id$
 
 */
@@ -44,10 +44,10 @@ struct b_queue {
 };
 #endif
 
-/* 
+/*
  * To define a queue, use the following
  *
- *  static BQUEUE xyz = { &xyz, &xyz }; 
+ *  static BQUEUE xyz = { &xyz, &xyz };
  *
  *   Also, note, that the only real requirement is that
  *   the object that is passed to these routines contain
@@ -82,7 +82,7 @@ void qinsert(BQUEUE *qhead, BQUEUE *object)
 
 
 /*  QREMOVE  --  Remove next object from the queue given
-                the queue head (or any item). 
+                the queue head (or any item).
      Returns NULL if queue is empty  */
 
 BQUEUE *qremove(BQUEUE *qhead)
@@ -118,13 +118,13 @@ BQUEUE *qnext(BQUEUE *qhead, BQUEUE *qitem)
           qitem = qhead;
        ASSERT(qi->qprev->qnext == qi);
        ASSERT(qi->qnext->qprev == qi);
-       
+
        if ((object = qi->qnext) == qh)
           return NULL;
        return object;
 #undef qh
 #undef qi
-}         
+}
 
 
 /*  QDCHAIN  --  Dequeue an item from the middle of a queue.  Passed
index 4df665ec1da7066e86533a08a0663de93ce549ea..0b9b352f72bfafb17174f06b00e0754d5ca8f342 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "bacula.h"
 
-/*   
+/*
  * Initialize a read/write lock
  *
  *  Returns: 0 on success
@@ -43,7 +43,7 @@
 int rwl_init(brwlock_t *rwl)
 {
    int stat;
-                       
+
    rwl->r_active = rwl->w_active = 0;
    rwl->r_wait = rwl->w_wait = 0;
    if ((stat = pthread_mutex_init(&rwl->mutex, NULL)) != 0) {
@@ -79,7 +79,7 @@ int rwl_destroy(brwlock_t *rwl)
      return stat;
   }
 
-  /* 
+  /*
    * If any threads are active, report EBUSY
    */
   if (rwl->r_active > 0 || rwl->w_active) {
@@ -90,7 +90,7 @@ int rwl_destroy(brwlock_t *rwl)
   /*
    * If any threads are waiting, report EBUSY
    */
-  if (rwl->r_wait > 0 || rwl->w_wait > 0) { 
+  if (rwl->r_wait > 0 || rwl->w_wait > 0) {
      pthread_mutex_unlock(&rwl->mutex);
      return EBUSY;
   }
@@ -135,7 +135,7 @@ static void rwl_write_release(void *arg)
 int rwl_readlock(brwlock_t *rwl)
 {
    int stat;
-    
+
    if (rwl->valid != RWLOCK_VALID) {
       return EINVAL;
    }
@@ -161,13 +161,13 @@ int rwl_readlock(brwlock_t *rwl)
    return stat;
 }
 
-/* 
+/*
  * Attempt to lock for read access, don't wait
  */
 int rwl_readtrylock(brwlock_t *rwl)
 {
    int stat, stat2;
-    
+
    if (rwl->valid != RWLOCK_VALID) {
       return EINVAL;
    }
@@ -182,14 +182,14 @@ int rwl_readtrylock(brwlock_t *rwl)
    stat2 = pthread_mutex_unlock(&rwl->mutex);
    return (stat == 0 ? stat2 : stat);
 }
-   
-/* 
+
+/*
  * Unlock read lock
  */
 int rwl_readunlock(brwlock_t *rwl)
 {
    int stat, stat2;
-    
+
    if (rwl->valid != RWLOCK_VALID) {
       return EINVAL;
    }
@@ -212,7 +212,7 @@ int rwl_readunlock(brwlock_t *rwl)
 int rwl_writelock(brwlock_t *rwl)
 {
    int stat;
-    
+
    if (rwl->valid != RWLOCK_VALID) {
       return EINVAL;
    }
@@ -243,13 +243,13 @@ int rwl_writelock(brwlock_t *rwl)
    return stat;
 }
 
-/* 
+/*
  * Attempt to lock for write access, don't wait
  */
 int rwl_writetrylock(brwlock_t *rwl)
 {
    int stat, stat2;
-    
+
    if (rwl->valid != RWLOCK_VALID) {
       return EINVAL;
    }
@@ -270,15 +270,15 @@ int rwl_writetrylock(brwlock_t *rwl)
    stat2 = pthread_mutex_unlock(&rwl->mutex);
    return (stat == 0 ? stat2 : stat);
 }
-   
-/* 
+
+/*
  * Unlock write lock
  *  Start any waiting writers in preference to waiting readers
  */
 int rwl_writeunlock(brwlock_t *rwl)
 {
    int stat, stat2;
-    
+
    if (rwl->valid != RWLOCK_VALID) {
       return EINVAL;
    }
@@ -323,7 +323,7 @@ typedef struct thread_tag {
    int interval;
 } thread_t;
 
-/* 
+/*
  * Read/write lock and shared data.
  */
 typedef struct data_tag {
@@ -335,7 +335,7 @@ typedef struct data_tag {
 thread_t threads[THREADS];
 data_t data[DATASIZE];
 
-/* 
+/*
  * Thread start routine that uses read/write locks.
  */
 void *thread_routine(void *arg)
@@ -355,14 +355,14 @@ void *thread_routine(void *arg)
       if ((iteration % self->interval) == 0) {
         status = rwl_writelock(&data[element].lock);
         if (status != 0) {
-            Emsg1(M_ABORT, 0, "Write lock failed. ERR=%s\n", strerror(status));
+           Emsg1(M_ABORT, 0, "Write lock failed. ERR=%s\n", strerror(status));
         }
         data[element].data = self->thread_num;
         data[element].writes++;
         self->writes++;
         status = rwl_writeunlock(&data[element].lock);
         if (status != 0) {
-            Emsg1(M_ABORT, 0, "Write unlock failed. ERR=%s\n", strerror(status));
+           Emsg1(M_ABORT, 0, "Write unlock failed. ERR=%s\n", strerror(status));
         }
       } else {
         /*
@@ -372,14 +372,14 @@ void *thread_routine(void *arg)
          */
          status = rwl_readlock(&data[element].lock);
          if (status != 0) {
-             Emsg1(M_ABORT, 0, "Read lock failed. ERR=%s\n", strerror(status));
+            Emsg1(M_ABORT, 0, "Read lock failed. ERR=%s\n", strerror(status));
          }
          self->reads++;
          if (data[element].data == self->thread_num)
             repeats++;
          status = rwl_readunlock(&data[element].lock);
          if (status != 0) {
-             Emsg1(M_ABORT, 0, "Read unlock failed. ERR=%s\n", strerror(status));
+            Emsg1(M_ABORT, 0, "Read unlock failed. ERR=%s\n", strerror(status));
          }
       }
       element++;
@@ -420,7 +420,7 @@ int main (int argc, char *argv[])
        data[data_count].writes = 0;
        status = rwl_init (&data[data_count].lock);
        if (status != 0) {
-           Emsg1(M_ABORT, 0, "Init rwlock failed. ERR=%s\n", strerror(status));
+          Emsg1(M_ABORT, 0, "Init rwlock failed. ERR=%s\n", strerror(status));
        }
     }
 
@@ -435,7 +435,7 @@ int main (int argc, char *argv[])
        status = pthread_create (&threads[count].thread_id,
            NULL, thread_routine, (void*)&threads[count]);
        if (status != 0) {
-           Emsg1(M_ABORT, 0, "Create thread failed. ERR=%s\n", strerror(status));
+          Emsg1(M_ABORT, 0, "Create thread failed. ERR=%s\n", strerror(status));
        }
     }
 
@@ -446,10 +446,10 @@ int main (int argc, char *argv[])
     for (count = 0; count < THREADS; count++) {
        status = pthread_join (threads[count].thread_id, NULL);
        if (status != 0) {
-           Emsg1(M_ABORT, 0, "Join thread failed. ERR=%s\n", strerror(status));
+          Emsg1(M_ABORT, 0, "Join thread failed. ERR=%s\n", strerror(status));
        }
        thread_writes += threads[count].writes;
-        printf ("%02d: interval %d, writes %d, reads %d\n",
+       printf ("%02d: interval %d, writes %d, reads %d\n",
            count, threads[count].interval,
            threads[count].writes, threads[count].reads);
     }
@@ -459,7 +459,7 @@ int main (int argc, char *argv[])
      */
     for (data_count = 0; data_count < DATASIZE; data_count++) {
        data_writes += data[data_count].writes;
-        printf ("data %02d: value %d, %d writes\n",
+       printf ("data %02d: value %d, %d writes\n",
            data_count, data[data_count].data, data[data_count].writes);
        rwl_destroy (&data[data_count].lock);
     }
@@ -536,16 +536,16 @@ void *thread_routine (void *arg)
                self->updates++;
                rwl_writeunlock (&data[element].lock);
            } else
-                err_abort (status, "Try write lock");
+               err_abort (status, "Try write lock");
        } else {
            status = rwl_readtrylock (&data[element].lock);
            if (status == EBUSY)
                self->r_collisions++;
            else if (status != 0) {
-                err_abort (status, "Try read lock");
+               err_abort (status, "Try read lock");
            } else {
                if (data[element].data != data[element].updates)
-                    printf ("%d: data[%d] %d != %d\n",
+                   printf ("%d: data[%d] %d != %d\n",
                        self->thread_num, element,
                        data[element].data, data[element].updates);
                rwl_readunlock (&data[element].lock);
@@ -597,7 +597,7 @@ int main (int argc, char *argv[])
        status = pthread_create (&threads[count].thread_id,
            NULL, thread_routine, (void*)&threads[count]);
        if (status != 0)
-            err_abort (status, "Create thread");
+           err_abort (status, "Create thread");
     }
 
     /*
@@ -607,10 +607,10 @@ int main (int argc, char *argv[])
     for (count = 0; count < THREADS; count++) {
        status = pthread_join (threads[count].thread_id, NULL);
        if (status != 0)
-            err_abort (status, "Join thread");
+           err_abort (status, "Join thread");
        thread_updates += threads[count].updates;
-        printf ("%02d: interval %d, updates %d, "
-                "r_collisions %d, w_collisions %d\n",
+       printf ("%02d: interval %d, updates %d, "
+               "r_collisions %d, w_collisions %d\n",
            count, threads[count].interval,
            threads[count].updates,
            threads[count].r_collisions, threads[count].w_collisions);
@@ -621,7 +621,7 @@ int main (int argc, char *argv[])
      */
     for (data_count = 0; data_count < DATASIZE; data_count++) {
        data_updates += data[data_count].updates;
-        printf ("data %02d: value %d, %d updates\n",
+       printf ("data %02d: value %d, %d updates\n",
            data_count, data[data_count].data, data[data_count].updates);
        rwl_destroy (&data[data_count].lock);
     }
index d310e1b3daec9f081ed34f5f5e911f43882e5be9..8abd1b8311ea7b100c97debf610094b5cb774779 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Bacula Thread Read/Write locking code. It permits
- *  multiple readers but only one writer.                 
+ *  multiple readers but only one writer.
  *
  *  Kern Sibbald, January MMI
  *
@@ -30,7 +30,7 @@
 
  */
 
-#ifndef __RWLOCK_H 
+#ifndef __RWLOCK_H
 #define __RWLOCK_H 1
 
 typedef struct s_rwlock_tag {
@@ -57,7 +57,7 @@ typedef struct s_rwsteal_tag {
    {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, \
     PTHREAD_COND_INITIALIZER, RWLOCK_VALID, 0, 0, 0, 0}
 
-/* 
+/*
  * read/write lock prototypes
  */
 extern int rwl_init(brwlock_t *wrlock);
index ef338a9a1bbee88ee07bc313232cfee4960b4d33..70d567fc33fc691c7086253fb5f008fa17f0e893 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *   scan.c -- scanning routines for Bacula
- * 
+ *
  *    Kern Sibbald, MM separated from util.c MMIII
  *
  *   Version $Id$
@@ -55,9 +55,9 @@ void strip_trailing_slashes(char *dir)
 
 /*
  * Skip spaces
- *  Returns: 0 on failure (EOF)            
+ *  Returns: 0 on failure (EOF)
  *          1 on success
- *          new address in passed parameter 
+ *          new address in passed parameter
  */
 bool skip_spaces(char **msg)
 {
@@ -74,9 +74,9 @@ bool skip_spaces(char **msg)
 
 /*
  * Skip nonspaces
- *  Returns: 0 on failure (EOF)            
+ *  Returns: 0 on failure (EOF)
  *          1 on success
- *          new address in passed parameter 
+ *          new address in passed parameter
  */
 bool skip_nonspaces(char **msg)
 {
@@ -122,7 +122,7 @@ fstrsch(const char *a, const char *b)       /* folded case search */
 }
 
 
-/* 
+/*
  * Return next argument from command line.  Note, this
  * routine is destructive.
  */
@@ -134,7 +134,7 @@ char *next_arg(char **s)
    /* skip past spaces to next arg */
    for (p=*s; *p && B_ISSPACE(*p); ) {
       p++;
-   }   
+   }
    Dmsg1(400, "Next arg=%s\n", p);
    for (n = q = p; *p ; ) {
       if (*p == '\\') {
@@ -166,13 +166,13 @@ char *next_arg(char **s)
    *s = p;
    Dmsg2(400, "End arg=%s next=%s\n", n, p);
    return n;
-}   
+}
 
 /*
  * This routine parses the input command line.
  * It makes a copy in args, then builds an
  *  argc, argv like list where
- *    
+ *
  *  argc = count of arguments
  *  argk[i] = argument keyword (part preceding =)
  *  argv[i] = argument value (part after =)
@@ -185,11 +185,11 @@ char *next_arg(char **s)
  *  argk[1] = arg2
  *  argv[1] = abc
  *  argk[2] = arg3
- *  argv[2] = 
+ *  argv[2] =
  */
 
-int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, 
-              char **argk, char **argv, int max_args) 
+int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
+              char **argk, char **argv, int max_args)
 {
    char *p, *q, *n;
 
@@ -199,7 +199,7 @@ int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
    *argc = 0;
    /* Pick up all arguments */
    while (*argc < max_args) {
-      n = next_arg(&p);   
+      n = next_arg(&p);
       if (*n) {
         argk[*argc] = n;
         argv[(*argc)++] = NULL;
@@ -213,9 +213,9 @@ int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
       if (p) {
         *p++ = 0;                    /* terminate keyword and point to value */
         /* Unquote quoted values */
-         if (*p == '"') {
-            for (n = q = ++p; *p && *p != '"'; ) {
-               if (*p == '\\') {
+        if (*p == '"') {
+           for (n = q = ++p; *p && *p != '"'; ) {
+              if (*p == '\\') {
                  p++;
               }
               *q++ = *p++;
@@ -250,7 +250,7 @@ void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl,
    int len = slen = strlen(fname);
 
    /*
-    * Find path without the filename.  
+    * Find path without the filename.
     * I.e. everything after the last / is a "filename".
     * OK, maybe it is a directory name, but we treat it like
     * a filename. If we don't find a / then the whole name
@@ -292,7 +292,7 @@ void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl,
 }
 
 /*
- * Extremely simple sscanf. Handles only %(u,d,ld,lu,lld,llu,c,nns) 
+ * Extremely simple sscanf. Handles only %(u,d,ld,lu,lld,llu,c,nns)
  */
 const int BIG = 1000;
 int bsscanf(const char *buf, const char *fmt, ...)
@@ -314,11 +314,11 @@ int bsscanf(const char *buf, const char *fmt, ...)
 //       Dmsg1(000, "Got %% nxt=%c\n", *fmt);
 switch_top:
         switch (*fmt++) {
-         case 'u':
-         case 'd':
+        case 'u':
+        case 'd':
            value = 0;
            while (B_ISDIGIT(*buf)) {
-               value = B_TIMES10(value) + *buf++ - '0';
+              value = B_TIMES10(value) + *buf++ - '0';
            }
            vp = (void *)va_arg(ap, void *);
 //          Dmsg2(000, "val=%lld at 0x%lx\n", value, (long unsigned)vp);
@@ -332,28 +332,28 @@ switch_top:
            count++;
            l = 0;
            break;
-         case 'l':
+        case 'l':
 //          Dmsg0(000, "got l\n");
            l = 1;
-            if (*fmt == 'l') {
+           if (*fmt == 'l') {
               l++;
               fmt++;
            }
-            if (*fmt == 'd' || *fmt == 'u') {
+           if (*fmt == 'd' || *fmt == 'u') {
               goto switch_top;
            }
 //          Dmsg1(000, "fmt=%c !=d,u\n", *fmt);
            error = true;
            break;
-         case 'q':
+        case 'q':
            l = 2;
-            if (*fmt == 'd' || *fmt == 'u') {
+           if (*fmt == 'd' || *fmt == 'u') {
               goto switch_top;
            }
 //          Dmsg1(000, "fmt=%c !=d,u\n", *fmt);
            error = true;
            break;
-         case 's':
+        case 's':
 //          Dmsg1(000, "Store string max_len=%d\n", max_len);
            cp = (char *)va_arg(ap, char *);
            while (*buf && !B_ISSPACE(*buf) && max_len-- > 0) {
@@ -363,13 +363,13 @@ switch_top:
            count++;
            max_len = BIG;
            break;
-         case 'c':
+        case 'c':
            cp = (char *)va_arg(ap, char *);
            *cp = *buf++;
            count++;
            break;
-         case '%':
-            if (*buf++ != '%') {
+        case '%':
+           if (*buf++ != '%') {
               error = true;
            }
            break;
@@ -377,10 +377,10 @@ switch_top:
            fmt--;
            max_len = 0;
            while (B_ISDIGIT(*fmt)) {
-               max_len = B_TIMES10(max_len) + *fmt++ - '0';
+              max_len = B_TIMES10(max_len) + *fmt++ - '0';
            }
 //          Dmsg1(000, "Default max_len=%d\n", max_len);
-            if (*fmt == 's') {
+           if (*fmt == 's') {
               goto switch_top;
            }
 //          Dmsg1(000, "Default c=%c\n", *fmt);
@@ -420,7 +420,7 @@ int main(int argc, char *argv[])
    int cnt;
    char *helloreq= "Hello *UserAgent* calling\n";
    char *hello = "Hello %127s calling\n";
-   char *catreq = 
+   char *catreq =
 "CatReq Job=NightlySave.2004-06-11_19.11.32 CreateJobMedia FirstIndex=1 LastIndex=114 StartFile=0 EndFile=0 StartBlock=208 EndBlock=2903248";
 static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia "
   "FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u "
@@ -454,7 +454,7 @@ struct VOLUME_CAT_INFO {
    uint64_t VolWriteTime;            /* time spent writing this Volume */
    char VolCatStatus[20];            /* Volume status */
    char VolCatName[MAX_NAME_LENGTH];  /* Desired volume to mount */
-};               
+};
    struct VOLUME_CAT_INFO vol;
 
 #ifdef xxx
index 78ea114bbbcd1e40c3b2f17e56cd9ca454944c61..e20d77f5341a754938d7b6fee30bd623a84df423 100644 (file)
@@ -2,7 +2,7 @@
  * Bacula Semaphore code. This code permits setting up
  *  a semaphore that lets through a specified number
  *  of callers simultaneously. Once the number of callers
- *  exceed the limit, they block.      
+ *  exceed the limit, they block.
  *
  *  Kern Sibbald, March MMIII
  *
@@ -34,7 +34,7 @@
 
 #include "bacula.h"
 
-/*   
+/*
  * Initialize a semaphore
  *
  *  Returns: 0 on success
@@ -43,7 +43,7 @@
 int sem_init(semlock_t *sem, int max_active)
 {
    int stat;
-                       
+
    sem->active = sem->waiting = 0;
    sem->max_active = max_active;
    if ((stat = pthread_mutex_init(&sem->mutex, NULL)) != 0) {
@@ -65,7 +65,7 @@ int sem_init(semlock_t *sem, int max_active)
  */
 int sem_destroy(semlock_t *sem)
 {
-   int stat, stat1;      
+   int stat, stat1;
 
   if (sem->valid != SEMLOCK_VALID) {
      return EINVAL;
@@ -74,7 +74,7 @@ int sem_destroy(semlock_t *sem)
      return stat;
   }
 
-  /* 
+  /*
    * If any threads are active, report EBUSY
    */
   if (sem->active > 0) {
@@ -118,7 +118,7 @@ static void sem_release(void *arg)
 int sem_lock(semlock_t *sem)
 {
    int stat;
-    
+
    if (sem->valid != SEMLOCK_VALID) {
       return EINVAL;
    }
@@ -143,13 +143,13 @@ int sem_lock(semlock_t *sem)
    return stat;
 }
 
-/* 
+/*
  * Attempt to lock semaphore, don't wait
  */
 int sem_trylock(semlock_t *sem)
 {
    int stat, stat1;
-    
+
    if (sem->valid != SEMLOCK_VALID) {
       return EINVAL;
    }
@@ -165,15 +165,15 @@ int sem_trylock(semlock_t *sem)
    stat1 = pthread_mutex_unlock(&sem->mutex);
    return (stat == 0 ? stat1 : stat);
 }
-   
-/* 
+
+/*
  * Unlock semaphore
  *  Start any waiting callers
  */
 int sem_unlock(semlock_t *sem)
 {
    int stat, stat1;
-    
+
    if (sem->valid != SEMLOCK_VALID) {
       return EINVAL;
    }
@@ -213,7 +213,7 @@ typedef struct thread_tag {
    int interval;
 } thread_t;
 
-/* 
+/*
  * Semaphore lock and shared data.
  */
 typedef struct data_tag {
@@ -225,7 +225,7 @@ typedef struct data_tag {
 thread_t threads[THREADS];
 data_t data[DATASIZE];
 
-/* 
+/*
  * Thread start routine that uses semaphores locks.
  */
 void *thread_routine(void *arg)
@@ -245,14 +245,14 @@ void *thread_routine(void *arg)
       if ((iteration % self->interval) == 0) {
         status = sem_writelock(&data[element].lock);
         if (status != 0) {
-            Emsg1(M_ABORT, 0, "Write lock failed. ERR=%s\n", strerror(status));
+           Emsg1(M_ABORT, 0, "Write lock failed. ERR=%s\n", strerror(status));
         }
         data[element].data = self->thread_num;
         data[element].writes++;
         self->writes++;
         status = sem_writeunlock(&data[element].lock);
         if (status != 0) {
-            Emsg1(M_ABORT, 0, "Write unlock failed. ERR=%s\n", strerror(status));
+           Emsg1(M_ABORT, 0, "Write unlock failed. ERR=%s\n", strerror(status));
         }
       } else {
         /*
@@ -262,14 +262,14 @@ void *thread_routine(void *arg)
          */
          status = sem_readlock(&data[element].lock);
          if (status != 0) {
-             Emsg1(M_ABORT, 0, "Read lock failed. ERR=%s\n", strerror(status));
+            Emsg1(M_ABORT, 0, "Read lock failed. ERR=%s\n", strerror(status));
          }
          self->reads++;
          if (data[element].data == self->thread_num)
             repeats++;
          status = sem_readunlock(&data[element].lock);
          if (status != 0) {
-             Emsg1(M_ABORT, 0, "Read unlock failed. ERR=%s\n", strerror(status));
+            Emsg1(M_ABORT, 0, "Read unlock failed. ERR=%s\n", strerror(status));
          }
       }
       element++;
@@ -310,7 +310,7 @@ int main (int argc, char *argv[])
        data[data_count].writes = 0;
        status = sem_init (&data[data_count].lock);
        if (status != 0) {
-           Emsg1(M_ABORT, 0, "Init rwlock failed. ERR=%s\n", strerror(status));
+          Emsg1(M_ABORT, 0, "Init rwlock failed. ERR=%s\n", strerror(status));
        }
     }
 
@@ -325,7 +325,7 @@ int main (int argc, char *argv[])
        status = pthread_create(&threads[count].thread_id,
            NULL, thread_routine, (void*)&threads[count]);
        if (status != 0) {
-           Emsg1(M_ABORT, 0, "Create thread failed. ERR=%s\n", strerror(status));
+          Emsg1(M_ABORT, 0, "Create thread failed. ERR=%s\n", strerror(status));
        }
     }
 
@@ -336,10 +336,10 @@ int main (int argc, char *argv[])
     for (count = 0; count < THREADS; count++) {
        status = pthread_join (threads[count].thread_id, NULL);
        if (status != 0) {
-           Emsg1(M_ABORT, 0, "Join thread failed. ERR=%s\n", strerror(status));
+          Emsg1(M_ABORT, 0, "Join thread failed. ERR=%s\n", strerror(status));
        }
        thread_writes += threads[count].writes;
-        printf ("%02d: interval %d, writes %d, reads %d\n",
+       printf ("%02d: interval %d, writes %d, reads %d\n",
            count, threads[count].interval,
            threads[count].writes, threads[count].reads);
     }
@@ -349,7 +349,7 @@ int main (int argc, char *argv[])
      */
     for (data_count = 0; data_count < DATASIZE; data_count++) {
        data_writes += data[data_count].writes;
-        printf ("data %02d: value %d, %d writes\n",
+       printf ("data %02d: value %d, %d writes\n",
            data_count, data[data_count].data, data[data_count].writes);
        sem_destroy (&data[data_count].lock);
     }
@@ -426,16 +426,16 @@ void *thread_routine (void *arg)
                self->updates++;
                sem_writeunlock (&data[element].lock);
            } else
-                err_abort (status, "Try write lock");
+               err_abort (status, "Try write lock");
        } else {
            status = sem_readtrylock (&data[element].lock);
            if (status == EBUSY)
                self->r_collisions++;
            else if (status != 0) {
-                err_abort (status, "Try read lock");
+               err_abort (status, "Try read lock");
            } else {
                if (data[element].data != data[element].updates)
-                    printf ("%d: data[%d] %d != %d\n",
+                   printf ("%d: data[%d] %d != %d\n",
                        self->thread_num, element,
                        data[element].data, data[element].updates);
                sem_readunlock (&data[element].lock);
@@ -487,7 +487,7 @@ int main (int argc, char *argv[])
        status = pthread_create (&threads[count].thread_id,
            NULL, thread_routine, (void*)&threads[count]);
        if (status != 0)
-            err_abort (status, "Create thread");
+           err_abort (status, "Create thread");
     }
 
     /*
@@ -497,10 +497,10 @@ int main (int argc, char *argv[])
     for (count = 0; count < THREADS; count++) {
        status = pthread_join(threads[count].thread_id, NULL);
        if (status != 0)
-            err_abort(status, "Join thread");
+           err_abort(status, "Join thread");
        thread_updates += threads[count].updates;
-        printf ("%02d: interval %d, updates %d, "
-                "r_collisions %d, w_collisions %d\n",
+       printf ("%02d: interval %d, updates %d, "
+               "r_collisions %d, w_collisions %d\n",
            count, threads[count].interval,
            threads[count].updates,
            threads[count].r_collisions, threads[count].w_collisions);
@@ -511,7 +511,7 @@ int main (int argc, char *argv[])
      */
     for (data_count = 0; data_count < DATASIZE; data_count++) {
        data_updates += data[data_count].updates;
-        printf ("data %02d: value %d, %d updates\n",
+       printf ("data %02d: value %d, %d updates\n",
            data_count, data[data_count].data, data[data_count].updates);
        sem_destroy(&data[data_count].lock);
     }
index 83c19c809262086038e631fbb28901709c6f7d44..6051341dcd3fcbd07c903cf61dc7c2206ce30da6 100644 (file)
@@ -2,7 +2,7 @@
  * Bacula Semaphore code. This code permits setting up
  *  a semaphore that lets through a specified number
  *  of callers simultaneously. Once the number of callers
- *  exceed the limit, they block.      
+ *  exceed the limit, they block.
  *
  *  Kern Sibbald, March MMIII
  *
@@ -31,7 +31,7 @@
 
  */
 
-#ifndef __SEMLOCK_H 
+#ifndef __SEMLOCK_H
 #define __SEMLOCK_H 1
 
 typedef struct s_semlock_tag {
@@ -49,7 +49,7 @@ typedef struct s_semlock_tag {
    {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, \
     PTHREAD_COND_INITIALIZER, SEMLOCK_VALID, 0, 0, 0, 0}
 
-/* 
+/*
  * semaphore lock prototypes
  */
 extern int sem_init(semlock_t *sem, int max_active);
index 46e0390a7d669cb6315ec40e5d800bc5d9103c61..a042324108f5dedd4346330c71e5d6ba756c847a 100644 (file)
@@ -3,7 +3,7 @@
                   Serialisation Support Functions
                          John Walker
 
-  
+
      Version $Id$
 */
 /*
@@ -168,7 +168,7 @@ void serial_float64(uint8_t * * const ptr, const float64_t v)
 void serial_string(uint8_t * * const ptr, const char * const str)
 {
    int len = strlen(str) + 1;
-   
+
    memcpy(*ptr, str, len);
    *ptr += len;
 }
index e1c835ccfaf55301aefd419d45dc91abfd1adf8f..528819739e1962f336c17fe0bc481d0e12cacdfc 100644 (file)
@@ -47,7 +47,7 @@ extern void unserial_string(uint8_t * * const ptr, char * const str);
 
 /*
 
-                         Serialisation Macros
+                        Serialisation Macros
 
     These macros use a uint8_t pointer, ser_ptr, which must be
     defined by the code which uses them.
@@ -66,7 +66,7 @@ extern void unserial_string(uint8_t * * const ptr, char * const str);
 #define unser_begin(x, s) ser_ptr = ((uint8_t *)(x))
 
 /*  ser_length  --  Determine length in bytes of serialised into a
-                    buffer x.  */
+                   buffer x.  */
 #define ser_length(x)  (ser_ptr - (uint8_t *)(x))
 #define unser_length(x)  (ser_ptr - (uint8_t *)(x))
 
@@ -75,7 +75,7 @@ extern void unserial_string(uint8_t * * const ptr, char * const str);
 #define unser_end(x, s)   ASSERT(ser_length(x) <= (s))
 
 /*  ser_check(x, s)  --  Verify length of serialised data in buffer x is
-                         expected length s.  */
+                        expected length s.  */
 #define ser_check(x, s) ASSERT(ser_length(x) == (s))
 
 /*                          Serialisation                   */
index 1d4ed9c95d7de0aa09bc0540f38e6e7b8e1821d7..136d8a7f17b429568398b63b125abbf4b0b772fe 100644 (file)
@@ -424,14 +424,14 @@ int main()
      * Perform SHA-1 tests
      */
     for(j = 0; j < 4; ++j) {
-        printf( "\nTest %d: %d, '%s'\n",
+       printf( "\nTest %d: %d, '%s'\n",
                j+1,
                repeatcount[j],
                testarray[j]);
 
        err = SHA1Init(&sha);
        if (err) {
-            fprintf(stderr, "SHA1Reset Error %d.\n", err );
+           fprintf(stderr, "SHA1Reset Error %d.\n", err );
            break;    /* out of for j loop */
        }
 
@@ -441,7 +441,7 @@ int main()
                  (const unsigned char *) testarray[j],
                  strlen(testarray[j]));
            if (err) {
-                fprintf(stderr, "SHA1Input Error %d.\n", err );
+               fprintf(stderr, "SHA1Input Error %d.\n", err );
                break;    /* out of for i loop */
            }
        }
@@ -449,19 +449,19 @@ int main()
        err = SHA1Final(&sha, Message_Digest);
        if (err) {
            fprintf(stderr,
-            "SHA1Result Error %d, could not compute message digest.\n",
+           "SHA1Result Error %d, could not compute message digest.\n",
            err );
        }
        else
        {
-            printf("\t");
+           printf("\t");
            for(i = 0; i < 20 ; ++i) {
-                printf("%02X ", Message_Digest[i]);
+               printf("%02X ", Message_Digest[i]);
            }
-            printf("\n");
+           printf("\n");
        }
-        printf("Should match:\n");
-        printf("\t%s\n", resultarray[j]);
+       printf("Should match:\n");
+       printf("\t%s\n", resultarray[j]);
     }
 
     /* Test some error returns */
@@ -479,7 +479,7 @@ int main()
  * Reads a single ASCII file and prints the HEX sha1 sum.
  */
 #include <stdio.h>
-int main(int argc, char *argv[]) 
+int main(int argc, char *argv[])
 {
    FILE *fd;
    SHA1Context ctx;
index 4bcf470d286c8d40afd8b6c1a48e693da92ba2e2..437fe19c1bc3d8b175e02d2e8645f2dcbcaa8b13 100644 (file)
@@ -85,7 +85,7 @@ typedef struct SHA1Context
     uint32_t Length_Low;            /* Message length in bits      */
     uint32_t Length_High;           /* Message length in bits      */
 
-                               /* Index into message block array   */
+                              /* Index into message block array   */
     int32_t Message_Block_Index;
     uint8_t Message_Block[64];      /* 512-bit message blocks      */
 
@@ -99,9 +99,9 @@ typedef struct SHA1Context
 
 int SHA1Init(SHA1Context *);
 int SHA1Update(SHA1Context *,
-               const uint8_t *,
-               unsigned int);
+              const uint8_t *,
+              unsigned int);
 int SHA1Final(SHA1Context *,
-               uint8_t Message_Digest[SHA1HashSize]);
+              uint8_t Message_Digest[SHA1HashSize]);
 
 #endif
index 27932e7e097422434a89e59a4a929723acef7d6b..7d03d2b85ef233109b3259a6d4c5769ef5564564 100644 (file)
@@ -4,11 +4,11 @@
  *   Kern Sibbald, April 2000
  *
  *   Version $Id$
- * 
+ *
  * Note, we probably should do a core dump for the serious
- * signals such as SIGBUS, SIGPFE, ... 
- * Also, for SIGHUP and SIGUSR1, we should re-read the 
- * configuration file.  However, since this is a "general"  
+ * signals such as SIGBUS, SIGPFE, ...
+ * Also, for SIGHUP and SIGUSR1, we should re-read the
+ * configuration file.  However, since this is a "general"
  * routine, we leave it to the individual daemons to
  * tweek their signals after calling this routine.
  *
@@ -64,7 +64,7 @@ const char *get_signal_name(int sig)
    }
 }
 
-/* 
+/*
  * Handle signals here
  */
 extern "C" void signal_handler(int sig)
@@ -97,21 +97,21 @@ extern "C" void signal_handler(int sig)
       pid_t pid;
       int exelen = strlen(exepath);
 
-      fprintf(stderr, "Kaboom! %s, %s got signal %d. Attempting traceback.\n", 
+      fprintf(stderr, "Kaboom! %s, %s got signal %d. Attempting traceback.\n",
              exename, my_name, sig);
       fprintf(stderr, "Kaboom! exepath=%s\n", exepath);
 
       if (exelen + 12 > (int)sizeof(btpath)) {
-         bstrncpy(btpath, "btraceback", sizeof(btpath));
+        bstrncpy(btpath, "btraceback", sizeof(btpath));
       } else {
         bstrncpy(btpath, exepath, sizeof(btpath));
-         if (btpath[exelen-1] == '/') {
+        if (btpath[exelen-1] == '/') {
            btpath[exelen-1] = 0;
         }
-         bstrncat(btpath, "/btraceback", sizeof(btpath));
+        bstrncat(btpath, "/btraceback", sizeof(btpath));
       }
       if (exepath[exelen-1] != '/') {
-         strcat(exepath, "/");
+        strcat(exepath, "/");
       }
       strcat(exepath, exename);
       if (!working_directory) {
@@ -119,12 +119,12 @@ extern "C" void signal_handler(int sig)
         *buf = 0;
       }
       if (*working_directory == 0) {
-         strcpy((char *)working_directory, "/tmp/");
+        strcpy((char *)working_directory, "/tmp/");
       }
       if (chdir(working_directory) != 0) {  /* dump in working directory */
         berrno be;
-         Pmsg2(000, "chdir to %s failed. ERR=%s\n", working_directory,  be.strerror());
-         strcpy((char *)working_directory, "/tmp/");
+        Pmsg2(000, "chdir to %s failed. ERR=%s\n", working_directory,  be.strerror());
+        strcpy((char *)working_directory, "/tmp/");
       }
       unlink("./core");               /* get rid of any old core file */
       sprintf(pid_buf, "%d", (int)main_pid);
@@ -133,16 +133,16 @@ extern "C" void signal_handler(int sig)
       Dmsg1(300, "exepath=%s\n", exepath);
       switch (pid = fork()) {
       case -1:                       /* error */
-         fprintf(stderr, "Fork error: ERR=%s\n", strerror(errno));
+        fprintf(stderr, "Fork error: ERR=%s\n", strerror(errno));
         break;
       case 0:                        /* child */
         argv[0] = btpath;            /* path to btraceback */
         argv[1] = exepath;           /* path to exe */
         argv[2] = pid_buf;
         argv[3] = (char *)NULL;
-         fprintf(stderr, "Calling: %s %s %s\n", btpath, exepath, pid_buf);
+        fprintf(stderr, "Calling: %s %s %s\n", btpath, exepath, pid_buf);
         if (execv(btpath, argv) != 0) {
-            printf("execv: %s failed: ERR=%s\n", btpath, strerror(errno));
+           printf("execv: %s failed: ERR=%s\n", btpath, strerror(errno));
         }
         exit(-1);
       default:                       /* parent */
@@ -155,14 +155,14 @@ extern "C" void signal_handler(int sig)
 
       sigaction(sig,  &sigdefault, NULL);
       if (pid > 0) {
-         Dmsg0(500, "Doing waitpid\n");
+        Dmsg0(500, "Doing waitpid\n");
         waitpid(pid, NULL, 0);       /* wait for child to produce dump */
-         fprintf(stderr, "Traceback complete, attempting cleanup ...\n");
-         Dmsg0(500, "Done waitpid\n");
+        fprintf(stderr, "Traceback complete, attempting cleanup ...\n");
+        Dmsg0(500, "Done waitpid\n");
         exit_handler(sig);           /* clean up if possible */
-         Dmsg0(500, "Done exit_handler\n");
+        Dmsg0(500, "Done exit_handler\n");
       } else {
-         Dmsg0(500, "Doing sleep\n");
+        Dmsg0(500, "Doing sleep\n");
         bmicrosleep(30, 0);
       }
       fprintf(stderr, "It looks like the traceback worked ...\n");
@@ -267,7 +267,7 @@ void init_signals(void terminate(int sig))
    sighandle.sa_handler = signal_handler;
    sigfillset(&sighandle.sa_mask);
    sigignore.sa_flags = 0;
-   sigignore.sa_handler = SIG_IGN;      
+   sigignore.sa_handler = SIG_IGN;
    sigfillset(&sigignore.sa_mask);
    sigdefault.sa_flags = 0;
    sigdefault.sa_handler = SIG_DFL;
@@ -279,16 +279,16 @@ void init_signals(void terminate(int sig))
    sigaction(SIGCONT,  &sigignore, NULL);
    sigaction(SIGPROF,  &sigignore, NULL);
    sigaction(SIGWINCH, &sigignore, NULL);
-   sigaction(SIGIO,    &sighandle, NULL);     
+   sigaction(SIGIO,    &sighandle, NULL);
 
-   sigaction(SIGINT,   &sigdefault, NULL);    
+   sigaction(SIGINT,   &sigdefault, NULL);
    sigaction(SIGXCPU,  &sigdefault, NULL);
    sigaction(SIGXFSZ,  &sigdefault, NULL);
 
    sigaction(SIGHUP,   &sigignore, NULL);
-   sigaction(SIGQUIT,  &sighandle, NULL);   
-   sigaction(SIGILL,   &sighandle, NULL);    
-   sigaction(SIGTRAP,  &sighandle, NULL);   
+   sigaction(SIGQUIT,  &sighandle, NULL);
+   sigaction(SIGILL,   &sighandle, NULL);
+   sigaction(SIGTRAP,  &sighandle, NULL);
 /* sigaction(SIGABRT,  &sighandle, NULL);   */
 #ifdef SIGEMT
    sigaction(SIGEMT,   &sighandle, NULL);
@@ -296,25 +296,25 @@ void init_signals(void terminate(int sig))
 #ifdef SIGIOT
 /* sigaction(SIGIOT,   &sighandle, NULL);  used by debugger */
 #endif
-   sigaction(SIGBUS,   &sighandle, NULL);    
-   sigaction(SIGFPE,   &sighandle, NULL);    
-   sigaction(SIGKILL,  &sighandle, NULL);   
-   sigaction(SIGUSR1,  &sighandle, NULL);   
-   sigaction(SIGSEGV,  &sighandle, NULL);   
+   sigaction(SIGBUS,   &sighandle, NULL);
+   sigaction(SIGFPE,   &sighandle, NULL);
+   sigaction(SIGKILL,  &sighandle, NULL);
+   sigaction(SIGUSR1,  &sighandle, NULL);
+   sigaction(SIGSEGV,  &sighandle, NULL);
    sigaction(SIGUSR2,  &sighandle, NULL);
-   sigaction(SIGALRM,  &sighandle, NULL);   
-   sigaction(SIGTERM,  &sighandle, NULL);   
+   sigaction(SIGALRM,  &sighandle, NULL);
+   sigaction(SIGTERM,  &sighandle, NULL);
 #ifdef SIGSTKFLT
-   sigaction(SIGSTKFLT, &sighandle, NULL); 
+   sigaction(SIGSTKFLT, &sighandle, NULL);
 #endif
-   sigaction(SIGSTOP,  &sighandle, NULL);   
-   sigaction(SIGTSTP,  &sighandle, NULL);   
-   sigaction(SIGTTIN,  &sighandle, NULL);   
-   sigaction(SIGTTOU,  &sighandle, NULL);   
-   sigaction(SIGURG,   &sighandle, NULL);    
-   sigaction(SIGVTALRM, &sighandle, NULL); 
+   sigaction(SIGSTOP,  &sighandle, NULL);
+   sigaction(SIGTSTP,  &sighandle, NULL);
+   sigaction(SIGTTIN,  &sighandle, NULL);
+   sigaction(SIGTTOU,  &sighandle, NULL);
+   sigaction(SIGURG,   &sighandle, NULL);
+   sigaction(SIGVTALRM, &sighandle, NULL);
 #ifdef SIGPWR
-   sigaction(SIGPWR,   &sighandle, NULL);    
+   sigaction(SIGPWR,   &sighandle, NULL);
 #endif
 #ifdef SIGWAITING
    sigaction(SIGWAITING,&sighandle, NULL);
index 0d75ffebef443734c8479e706f54f53fb7428b3a..a6873dc53bdd89f34455b852d5b9b5b98deae680 100644 (file)
@@ -13,7 +13,7 @@
 
                  http://www.fourmilab.ch/smartall/
 
-  
+
         Version $Id$
 
 */
@@ -46,7 +46,7 @@
 #undef free
 
 /* We normally turn off debugging here.
- *  If you want it, simply #ifdef all the 
+ *  If you want it, simply #ifdef all the
  *  following off.
  */
 #undef Dmsg1
@@ -57,7 +57,7 @@
 #define Dmsg2(l,f,a1,a2)
 #define Dmsg3(l,f,a1,a2,a3)
 #define Dmsg4(l,f,a1,a2,a3,a4)
-      
+
 
 uint64_t sm_max_bytes = 0;
 uint64_t sm_bytes = 0;
@@ -83,7 +83,7 @@ struct abufhead {
    struct b_queue abq;        /* Links on allocated queue */
    unsigned ablen;            /* Buffer length in bytes */
    const char *abfname;        /* File name pointer */
-   sm_ushort ablineno;        /* Line number of allocation */ 
+   sm_ushort ablineno;        /* Line number of allocation */
 };
 
 static struct b_queue abqueue = {    /* Allocated buffer queue */
@@ -170,8 +170,8 @@ void sm_free(const char *file, int line, void *fp)
    struct abufhead *head = (struct abufhead *)cp;
 
    P(mutex);
-   Dmsg4(1150, "sm_free %d at %x from %s:%d\n", 
-        head->ablen, fp, 
+   Dmsg4(1150, "sm_free %d at %x from %s:%d\n",
+        head->ablen, fp,
         head->abfname, head->ablineno);
 
    /* The following assertions will catch virtually every release
@@ -221,7 +221,7 @@ void *sm_malloc(const char *fname, int lineno, unsigned int nbytes)
 
       /* To catch sloppy code that assumes  buffers  obtained  from
         malloc()  are  zeroed,  we  preset  the buffer contents to
-         "designer garbage" consisting of alternating bits.  */
+        "designer garbage" consisting of alternating bits.  */
 
       memset(buf, 0x55, (int) nbytes);
    } else {
@@ -246,7 +246,7 @@ void *sm_calloc(const char *fname, int lineno,
 }
 
 /*  SM_REALLOC --  Adjust the size of a  previously  allocated  buffer.
-                    Note  that  the trick of "resurrecting" a previously
+                   Note  that  the trick of "resurrecting" a previously
                    freed buffer with realloc() is NOT supported by this
                    function.   Further, because of the need to maintain
                    our control storage, SM_REALLOC must always allocate
@@ -294,7 +294,7 @@ void *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size)
    if ((buf = smalloc(fname, lineno, size)) != NULL) {
       memcpy(buf, ptr, (int) sm_min(size, osize));
       /* If the new buffer is larger than the old, fill the balance
-         of it with "designer garbage". */
+        of it with "designer garbage". */
       if (size > osize) {
         memset(((char *) buf) + osize, 0x55, (int) (size - osize));
       }
@@ -362,14 +362,14 @@ void sm_dump(bool bufdump)
    while (ap != (struct abufhead *) &abqueue) {
 
       if ((ap == NULL) ||
-         (ap->abq.qnext->qprev != (struct b_queue *) ap) || 
+         (ap->abq.qnext->qprev != (struct b_queue *) ap) ||
          (ap->abq.qprev->qnext != (struct b_queue *) ap)) {
         fprintf(stderr,
-            "\nOrphaned buffers exist.  Dump terminated following\n");
+           "\nOrphaned buffers exist.  Dump terminated following\n");
         fprintf(stderr,
-            "  discovery of bad links in chain of orphaned buffers.\n");
+           "  discovery of bad links in chain of orphaned buffers.\n");
         fprintf(stderr,
-            "  Buffer address with bad links: %lx\n", (long) ap);
+           "  Buffer address with bad links: %lx\n", (long) ap);
         break;
       }
 
@@ -378,10 +378,10 @@ void sm_dump(bool bufdump)
         char errmsg[500];
 
         bsnprintf(errmsg, sizeof(errmsg),
-           "Orphaned buffer:  %6u bytes allocated at line %d of %s %s\n",
+          "Orphaned buffer:  %6u bytes allocated at line %d of %s %s\n",
            memsize, ap->ablineno, my_name, ap->abfname
         );
-         fprintf(stderr, "%s", errmsg);
+        fprintf(stderr, "%s", errmsg);
         if (bufdump) {
            char buf[20];
            unsigned llen = 0;
@@ -390,18 +390,18 @@ void sm_dump(bool bufdump)
            errmsg[0] = EOS;
            while (memsize) {
               if (llen >= 16) {
-                  bstrncat(errmsg, "\n", sizeof(errmsg));
+                 bstrncat(errmsg, "\n", sizeof(errmsg));
                  llen = 0;
-                  fprintf(stderr, "%s", errmsg);
+                 fprintf(stderr, "%s", errmsg);
                  errmsg[0] = EOS;
               }
-               bsnprintf(buf, sizeof(buf), " %02X",
+              bsnprintf(buf, sizeof(buf), " %02X",
                  (*cp++) & 0xFF);
               bstrncat(errmsg, buf, sizeof(errmsg));
               llen++;
               memsize--;
            }
-            fprintf(stderr, "%s\n", errmsg);
+           fprintf(stderr, "%s\n", errmsg);
         }
       }
       ap = (struct abufhead *) ap->abq.qnext;
@@ -414,7 +414,7 @@ void sm_dump(bool bufdump)
 void sm_check(const char *fname, int lineno, bool bufdump)
 {
        if (!sm_check_rtn(fname, lineno, bufdump)) {
-           Emsg2(M_ABORT, 0, "Damaged buffer found. Called from %s:%d\n",
+          Emsg2(M_ABORT, 0, "Damaged buffer found. Called from %s:%d\n",
              fname, lineno);
        }
 }
@@ -434,7 +434,7 @@ int sm_check_rtn(const char *fname, int lineno, bool bufdump)
          (ap->abq.qnext->qprev != (struct b_queue *) ap)) {
         bad = 0x1;
       }
-      if (ap->abq.qprev->qnext != (struct b_queue *) ap) { 
+      if (ap->abq.qprev->qnext != (struct b_queue *) ap) {
         bad |= 0x2;
       }
       if (((unsigned char *) ap)[((struct abufhead *) ap)->ablen - 1] !=
@@ -444,26 +444,26 @@ int sm_check_rtn(const char *fname, int lineno, bool bufdump)
       badbuf |= bad;
       if (bad) {
         fprintf(stderr,
-            "\nDamaged buffers found at %s:%d\n", fname, lineno);
+           "\nDamaged buffers found at %s:%d\n", fname, lineno);
 
         if (bad & 0x1) {
-            fprintf(stderr, "  discovery of bad prev link.\n");
+           fprintf(stderr, "  discovery of bad prev link.\n");
         }
         if (bad & 0x2) {
-            fprintf(stderr, "  discovery of bad next link.\n");
+           fprintf(stderr, "  discovery of bad next link.\n");
         }
         if (bad & 0x4) {
-            fprintf(stderr, "  discovery of data overrun.\n");
+           fprintf(stderr, "  discovery of data overrun.\n");
         }
 
-         fprintf(stderr, "  Buffer address: %lx\n", (long) ap);
+        fprintf(stderr, "  Buffer address: %lx\n", (long) ap);
 
         if (ap->abfname != NULL) {
            unsigned memsize = ap->ablen - (HEAD_SIZE + 1);
            char errmsg[80];
 
            fprintf(stderr,
-              "Damaged buffer:  %6u bytes allocated at line %d of %s %s\n",
+             "Damaged buffer:  %6u bytes allocated at line %d of %s %s\n",
               memsize, ap->ablineno, my_name, ap->abfname
            );
            if (bufdump) {
@@ -473,22 +473,22 @@ int sm_check_rtn(const char *fname, int lineno, bool bufdump)
               errmsg[0] = EOS;
               while (memsize) {
                  if (llen >= 16) {
-                     strcat(errmsg, "\n");
+                    strcat(errmsg, "\n");
                     llen = 0;
-                     fprintf(stderr, "%s", errmsg);
+                    fprintf(stderr, "%s", errmsg);
                     errmsg[0] = EOS;
                  }
                  if (*cp < 0x20) {
-                     sprintf(errmsg + strlen(errmsg), " %02X",
+                    sprintf(errmsg + strlen(errmsg), " %02X",
                        (*cp++) & 0xFF);
                  } else {
-                     sprintf(errmsg + strlen(errmsg), " %c ",
+                    sprintf(errmsg + strlen(errmsg), " %c ",
                        (*cp++) & 0xFF);
                  }
                  llen++;
                  memsize--;
               }
-               fprintf(stderr, "%s\n", errmsg);
+              fprintf(stderr, "%s\n", errmsg);
            }
         }
       }
@@ -511,7 +511,7 @@ void sm_static(int mode)
    bufimode = (bool) (mode != 0);
 }
 
-/* 
+/*
  * Here we overload C++'s global new and delete operators
  *  so that the memory is allocated through smartalloc.
  */
index 3f202974b6c4f97b8bcb7cee1086f86cb549fe1e..98305061d5d0c34b181b60d444a90ba85570ac5a 100644 (file)
@@ -1,7 +1,7 @@
 /*
 
-        Definitions for the smart memory allocator
-  
+       Definitions for the smart memory allocator
+
      Version $Id$
 
 */
@@ -37,15 +37,15 @@ extern uint32_t sm_buffers;
 
 
 extern void *sm_malloc(const char *fname, int lineno, unsigned int nbytes),
-            *sm_calloc(const char *fname, int lineno,
-                unsigned int nelem, unsigned int elsize),
-            *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size),
-            *actuallymalloc(unsigned int size),
-            *actuallycalloc(unsigned int nelem, unsigned int elsize),
-            *actuallyrealloc(void *ptr, unsigned int size);
+           *sm_calloc(const char *fname, int lineno,
+               unsigned int nelem, unsigned int elsize),
+           *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size),
+           *actuallymalloc(unsigned int size),
+           *actuallycalloc(unsigned int nelem, unsigned int elsize),
+           *actuallyrealloc(void *ptr, unsigned int size);
 extern void sm_free(const char *fname, int lineno, void *fp);
 extern void actuallyfree(void *cp),
-            sm_dump(bool bufdump), sm_static(int mode);
+           sm_dump(bool bufdump), sm_static(int mode);
 extern void sm_new_owner(const char *fname, int lineno, char *buf);
 
 #ifdef SMCHECK
@@ -84,7 +84,7 @@ extern int sm_check_rtn(const char *fname, int lineno, bool bufdump);
 #define sm_check_rtn(f, l, fl) 1
 
 extern void *b_malloc();
-#define malloc(x) b_malloc(__FILE__, __LINE__, (x))                  
+#define malloc(x) b_malloc(__FILE__, __LINE__, (x))
 
 
 #endif
@@ -121,7 +121,7 @@ void  operator delete(void *ptr, const char *fname, int line)
 {
    free(ptr);
 }
-void  operator delete[](void *ptr, size_t i, const char *fname, int line) 
+void  operator delete[](void *ptr, size_t i, const char *fname, int line)
 {
    free(ptr);
 }
@@ -131,7 +131,7 @@ private:
 void *operator new(size_t s) throw() { return 0; }
 void *operator new[](size_t s) throw() { return 0; }
 };
+
 
 #else
 
@@ -142,19 +142,19 @@ class SMARTALLOC
    public:
       void *operator new(size_t s)
       {
-          return malloc(s);
+         return malloc(s);
       }
       void *operator new[](size_t s)
       {
-          return malloc(s);
+         return malloc(s);
       }
       void  operator delete(void *ptr)
       {
-          free(ptr);
+         free(ptr);
       }
       void  operator delete[](void *ptr, size_t i)
       {
-          free(ptr);
+         free(ptr);
       }
 };
 #endif
index d9f49ec36e2076689d3e3b5afe3341f168f17f5d..b8a9ee6434618086d2096b37dcf997c7a7ef6bb2 100644 (file)
@@ -1,12 +1,12 @@
  /*
   * @(#) tcpd.h 1.5 96/03/19 16:22:24
-  * 
+  *
   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
   */
 
-/* 
- * This version of the file has been hacked over by 
- *   Kern Sibbald to make it compatible with C++ for 
+/*
+ * This version of the file has been hacked over by
+ *   Kern Sibbald to make it compatible with C++ for
  *   the few functions that Bacula uses.  19 April 2002
  *  It now compiles with C++ but remains untested.
  *  A correct fix would require significantly more work.
@@ -140,11 +140,11 @@ extern char *eval_server();             /* whatever is available */
 
 /* Socket-specific methods, including DNS hostname lookups. */
 
-extern void sock_host(struct request_info *); 
+extern void sock_host(struct request_info *);
 extern void sock_hostname();            /* translate address to hostname */
 extern void sock_hostaddr();            /* address to printable address */
 #define sock_methods(r) \
-        { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; }
+       { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; }
 
 /* The System V Transport-Level Interface (TLI) interface. */
 
index e6ef465eb199b273711383aa951be35aa7923486..c84f4cbbb0b3941aa11d9f49afb346cd20ab3ed1 100755 (executable)
@@ -1,6 +1,6 @@
 /*
  * Directory tree build/traverse routines
- * 
+ *
  *    Kern Sibbald, June MMII
  *
 */
 
 #include "bacula.h"
 #include "findlib/find.h"
-            
+
 
 /* Forward referenced subroutines */
-static TREE_NODE *search_and_insert_tree_node(char *fname, int type, 
+static TREE_NODE *search_and_insert_tree_node(char *fname, int type,
               TREE_ROOT *root, TREE_NODE *parent);
 static char *tree_alloc(TREE_ROOT *root, int size);
 
@@ -94,7 +94,7 @@ TREE_ROOT *new_tree(int count)
    return root;
 }
 
-/* 
+/*
  * Create a new tree node.
  */
 static TREE_NODE *new_tree_node(TREE_ROOT *root)
@@ -108,7 +108,7 @@ static TREE_NODE *new_tree_node(TREE_ROOT *root)
 
 #ifdef USE_DLIST
 /*
- * This routine can be called to release the 
+ * This routine can be called to release the
  *  previously allocated tree node.
  */
 static void free_tree_node(TREE_ROOT *root)
@@ -167,7 +167,7 @@ void free_tree(TREE_ROOT *root)
 }
 
 
-/* 
+/*
  * Insert a node in the tree. This is the main subroutine
  *   called when building a tree.
  *
@@ -205,7 +205,7 @@ TREE_NODE *insert_tree_node(char *path, char *fname, int type,
    }
    if (*fname) {
       if (!parent) {                 /* if no parent, we need to make one */
-         Dmsg1(100, "make_tree_path for %s\n", path);
+        Dmsg1(100, "make_tree_path for %s\n", path);
         path_len = strlen(path);     /* get new length */
         if (path_len == root->cached_path_len &&
             strcmp(path, root->cached_path) == 0) {
@@ -214,9 +214,9 @@ TREE_NODE *insert_tree_node(char *path, char *fname, int type,
            root->cached_path_len = path_len;
            pm_strcpy(&root->cached_path, path);
            parent = make_tree_path(path, root);
-           root->cached_parent = parent; 
+           root->cached_parent = parent;
         }
-         Dmsg1(100, "parent=%s\n", parent->fname);
+        Dmsg1(100, "parent=%s\n", parent->fname);
       }
    } else {
       fname = path;
@@ -265,7 +265,7 @@ TREE_NODE *make_tree_path(char *path, TREE_ROOT *root)
    }
    node = search_and_insert_tree_node(fname, type, root, parent);
    return node;
-}  
+}
 
 #ifdef USE_DLIST
 static int node_compare(void *item1, void *item2)
@@ -284,7 +284,7 @@ static int node_compare(void *item1, void *item2)
 /*
  *  See if the fname already exists. If not insert a new node for it.
  */
-static TREE_NODE *search_and_insert_tree_node(char *fname, int type, 
+static TREE_NODE *search_and_insert_tree_node(char *fname, int type,
               TREE_ROOT *root, TREE_NODE *parent)
 {
 #ifdef USE_DLIST
@@ -321,7 +321,7 @@ static TREE_NODE *search_and_insert_tree_node(char *fname, int type,
    int cmp;
 
    /* Is it already a sibling? */
-   foreach_child(sibling, parent) {    
+   foreach_child(sibling, parent) {
       Dmsg2(000, "sibling->fname=%s fname=%s\n", sibling->fname, fname);
       if (fname[0] > sibling->fname[0] || (cmp=strcmp(fname, sibling->fname)) > 0) {
         last_sibling = sibling;
@@ -336,7 +336,7 @@ static TREE_NODE *search_and_insert_tree_node(char *fname, int type,
         if (sibling == first_child(parent)) { /* if sibling was at head of list */
            parent->child_ = NULL;        /* force parent to be updated below */
         }
-         Dmsg2(000, "insert before sibling->fname=%s fname=%s\n", sibling->fname, fname);
+        Dmsg2(000, "insert before sibling->fname=%s fname=%s\n", sibling->fname, fname);
         break;
       }
       /* Found it */
@@ -345,8 +345,8 @@ static TREE_NODE *search_and_insert_tree_node(char *fname, int type,
    }
 
 
-   /* 
-    * At this point, the fname is not found. We must add it 
+   /*
+    * At this point, the fname is not found. We must add it
     */
    if (!node) {
       node = new_tree_node(root);
@@ -398,13 +398,13 @@ int tree_getpath(TREE_NODE *node, char *buf, int buf_size)
       return 1;
    }
    tree_getpath(node->parent, buf, buf_size);
-   /* 
-    * Fixup for Win32. If we have a Win32 directory and 
+   /*
+    * Fixup for Win32. If we have a Win32 directory and
     *   there is only a / in the buffer, remove it since
     *    win32 names don't generally start with /
     */
    if (node->type == TN_DIR_NLS && buf[0] == '/' && buf[1] == 0) {
-      buf[0] = 0;   
+      buf[0] = 0;
    }
    bstrncat(buf, node->fname, buf_size);
    /* Add a slash for all directories unless we are at the root,
@@ -418,7 +418,7 @@ int tree_getpath(TREE_NODE *node, char *buf, int buf_size)
    return 1;
 }
 
-/* 
+/*
  * Change to specified directory
  */
 TREE_NODE *tree_cwd(char *path, TREE_ROOT *root, TREE_NODE *node)
@@ -464,7 +464,7 @@ TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node)
    Dmsg2(100, "tree_relcwd: len=%d path=%s\n", len, path);
    foreach_child(cd, node) {
       Dmsg1(100, "tree_relcwd: test cd=%s\n", cd->fname);
-      if (cd->fname[0] == path[0] && len == (int)strlen(cd->fname)    
+      if (cd->fname[0] == path[0] && len == (int)strlen(cd->fname)
          && strncmp(cd->fname, path, len) == 0) {
         break;
       }
@@ -542,7 +542,7 @@ void FillDirectoryTree(char *path, TREE_ROOT *root, TREE_NODE *parent)
    char file[MAXPATHLEN];
    int type;
    int i;
-   
+
    Dmsg1(100, "FillDirectoryTree: %s\n", path);
    dp = opendir(path);
    if (!dp) {
@@ -555,7 +555,7 @@ void FillDirectoryTree(char *path, TREE_ROOT *root, TREE_NODE *parent)
       bstrncpy(file, dir->d_name, sizeof(file));
       snprintf(pathbuf, MAXPATHLEN-1, "%s/%s", path, file);
       if (lstat(pathbuf, &statbuf) < 0) {
-         printf("lstat() failed. ERR=%s\n", strerror(errno));
+        printf("lstat() failed. ERR=%s\n", strerror(errno));
         continue;
       }
 //      printf("got file=%s, pathbuf=%s\n", file, pathbuf);
@@ -576,7 +576,7 @@ void FillDirectoryTree(char *path, TREE_ROOT *root, TREE_NODE *parent)
         type = TN_FILE; /* sock */
       else {
         type = TN_FILE;
-         printf("Unknown file type: 0x%x\n", statbuf.st_mode);
+        printf("Unknown file type: 0x%x\n", statbuf.st_mode);
       }
 
       Dmsg2(100, "Doing: %d %s\n", type, pathbuf);
@@ -584,7 +584,7 @@ void FillDirectoryTree(char *path, TREE_ROOT *root, TREE_NODE *parent)
       node->FileIndex = ++FileIndex;
       parent = insert_tree_node(pathbuf, node, root, parent);
       if (S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) {
-         Dmsg2(100, "calling fill. pathbuf=%s, file=%s\n", pathbuf, file);
+        Dmsg2(100, "calling fill. pathbuf=%s, file=%s\n", pathbuf, file);
         FillDirectoryTree(pathbuf, root, node);
       }
    }
@@ -606,7 +606,7 @@ void print_tree(char *path, TREE_NODE *tree)
    switch (tree->type) {
    case TN_DIR_NLS:
    case TN_DIR:
-   case TN_NEWDIR:  
+   case TN_NEWDIR:
       termchr = "/";
       break;
    case TN_ROOT:
index 4c48f3a423b04918bb69c62a7a62ffd71c87a94e..5c7f39e9783677ef678c10e9532b5c7544a76d9a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Directory tree build/traverse routines
- * 
+ *
  *    Kern Sibbald, June MMII
  *
 */
@@ -60,7 +60,7 @@ struct s_tree_node {
    unsigned int extract: 1;          /* extract item */
    unsigned int extract_dir: 1;       /* extract dir entry only */
    unsigned int hard_link: 1;        /* set if have hard link */
-   unsigned int soft_link: 1;        /* set if is soft link */  
+   unsigned int soft_link: 1;        /* set if is soft link */
    unsigned int inserted: 1;         /* set when newly inserted */
    struct s_tree_node *parent;
    struct s_tree_node *next;         /* next hash of FileIndex */
@@ -120,7 +120,7 @@ struct s_tree_node {
    unsigned int extract: 1;          /* extract item */
    unsigned int extract_dir: 1;       /* extract dir entry only */
    unsigned int hard_link: 1;        /* set if have hard link */
-   unsigned int soft_link: 1;        /* set if is soft link */  
+   unsigned int soft_link: 1;        /* set if is soft link */
    unsigned int inserted: 1;         /* set when newly inserted */
    struct s_tree_node *parent;
    struct s_tree_node *sibling_;
@@ -177,7 +177,7 @@ int tree_getpath(TREE_NODE *node, char *buf, int buf_size);
 /*
  * Use the following for traversing the whole tree. It will be
  *   traversed in the order the entries were inserted into the
- *   tree.       
+ *   tree.
  */
 #ifdef SLOW_WAY
 TREE_NODE *first_tree_node(TREE_ROOT *root);
index b2c499aadb9aade883ce364288dca6ac5a509060..a7c634b55b68e6302f57a77022e1a3dda6ad7018 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *   util.c  miscellaneous utility subroutines for Bacula
- * 
+ *
  *    Kern Sibbald, MM
  *
  *   Version $Id$
@@ -75,7 +75,7 @@ void lcase(char *str)
    }
 }
 
-/* Convert spaces to non-space character. 
+/* Convert spaces to non-space character.
  * This makes scanf of fields containing spaces easier.
  */
 void
@@ -88,7 +88,7 @@ bash_spaces(char *str)
    }
 }
 
-/* Convert spaces to non-space character. 
+/* Convert spaces to non-space character.
  * This makes scanf of fields containing spaces easier.
  */
 void
@@ -109,7 +109,7 @@ unbash_spaces(char *str)
 {
    while (*str) {
      if (*str == 0x1)
-        *str = ' ';
+       *str = ' ';
      str++;
    }
 }
@@ -121,7 +121,7 @@ unbash_spaces(POOL_MEM &pm)
    char *str = pm.c_str();
    while (*str) {
      if (*str == 0x1)
-        *str = ' ';
+       *str = ' ';
      str++;
    }
 }
@@ -240,7 +240,7 @@ void jobstatus_to_ascii(int JobStatus, char *msg, int maxlen)
       if (JobStatus == 0) {
         buf[0] = 0;
       } else {
-         bsnprintf(buf, sizeof(buf), _("Unknown Job termination status=%d"), JobStatus);
+        bsnprintf(buf, sizeof(buf), _("Unknown Job termination status=%d"), JobStatus);
       }
       jobstat = buf;
       break;
@@ -251,7 +251,7 @@ void jobstatus_to_ascii(int JobStatus, char *msg, int maxlen)
 /*
  * Convert Job Termination Status into a string
  */
-const char *job_status_to_str(int stat) 
+const char *job_status_to_str(int stat)
 {
    const char *str;
 
@@ -283,7 +283,7 @@ const char *job_status_to_str(int stat)
 /*
  * Convert Job Type into a string
  */
-const char *job_type_to_str(int type) 
+const char *job_type_to_str(int type)
 {
    const char *str;
 
@@ -310,7 +310,7 @@ const char *job_type_to_str(int type)
 /*
  * Convert Job Level into a string
  */
-const char *job_level_to_str(int level) 
+const char *job_level_to_str(int level)
 {
    const char *str;
 
@@ -361,25 +361,25 @@ const char *job_level_to_str(int level)
 
 char *encode_mode(mode_t mode, char *buf)
 {
-  char *cp = buf;  
+  char *cp = buf;
 
   *cp++ = S_ISDIR(mode) ? 'd' : S_ISBLK(mode)  ? 'b' : S_ISCHR(mode)  ? 'c' :
-          S_ISLNK(mode) ? 'l' : S_ISFIFO(mode) ? 'f' : S_ISSOCK(mode) ? 's' : '-';
+         S_ISLNK(mode) ? 'l' : S_ISFIFO(mode) ? 'f' : S_ISSOCK(mode) ? 's' : '-';
   *cp++ = mode & S_IRUSR ? 'r' : '-';
   *cp++ = mode & S_IWUSR ? 'w' : '-';
   *cp++ = (mode & S_ISUID
-               ? (mode & S_IXUSR ? 's' : 'S')
-               : (mode & S_IXUSR ? 'x' : '-'));
+              ? (mode & S_IXUSR ? 's' : 'S')
+              : (mode & S_IXUSR ? 'x' : '-'));
   *cp++ = mode & S_IRGRP ? 'r' : '-';
   *cp++ = mode & S_IWGRP ? 'w' : '-';
   *cp++ = (mode & S_ISGID
-               ? (mode & S_IXGRP ? 's' : 'S')
-               : (mode & S_IXGRP ? 'x' : '-'));
+              ? (mode & S_IXGRP ? 's' : 'S')
+              : (mode & S_IXGRP ? 'x' : '-'));
   *cp++ = mode & S_IROTH ? 'r' : '-';
   *cp++ = mode & S_IWOTH ? 'w' : '-';
   *cp++ = (mode & S_ISVTX
-               ? (mode & S_IXOTH ? 't' : 'T')
-               : (mode & S_IXOTH ? 'x' : '-'));
+              ? (mode & S_IXOTH ? 't' : 'T')
+              : (mode & S_IXOTH ? 'x' : '-'));
   *cp = '\0';
   return cp;
 }
@@ -407,7 +407,7 @@ int do_shell_expansion(char *name, int name_len)
       cmd =  get_pool_memory(PM_FNAME);
       /* look for shell */
       if ((shellcmd = getenv("SHELL")) == NULL) {
-         shellcmd = "/bin/sh";
+        shellcmd = "/bin/sh";
       }
       pm_strcpy(&cmd, shellcmd);
       pm_strcat(&cmd, " -c \"echo ");
@@ -419,7 +419,7 @@ int do_shell_expansion(char *name, int name_len)
         fgets(line, sizeof(line), bpipe->rfd);
         strip_trailing_junk(line);
         stat = close_bpipe(bpipe);
-         Dmsg2(400, "stat=%d got: %s\n", stat, line);
+        Dmsg2(400, "stat=%d got: %s\n", stat, line);
       } else {
         stat = 1;                    /* error */
       }
@@ -454,7 +454,7 @@ void make_session_key(char *key, char *seed, int mode)
      /* The following creates a seed for the session key generator
        based on a collection of volatile and environment-specific
        information unlikely to be vulnerable (as a whole) to an
-        exhaustive search attack.  If one of these items isn't
+       exhaustive search attack.  If one of these items isn't
        available on your machine, replace it with something
        equivalent or, if you like, just delete it. */
 
@@ -492,7 +492,7 @@ void make_session_key(char *key, char *seed, int mode)
           key[k++] = Rad16(rb & 0xF);
 #undef Rad16
           if (j & 1) {
-              key[k++] = '-';
+             key[k++] = '-';
           }
        }
        key[--k] = 0;
@@ -522,10 +522,10 @@ void make_session_key(char *key, char *seed, int mode)
  *
  *  omsg = edited output message
  *  imsg = input string containing edit codes (%x)
- *  to = recepients list 
+ *  to = recepients list
  *
  */
-POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to)   
+POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to)
 {
    char *p, *q;
    const char *str;
@@ -538,85 +538,85 @@ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to)
    for (p=imsg; *p; p++) {
       if (*p == '%') {
         switch (*++p) {
-         case '%':
-            str = "%";
+        case '%':
+           str = "%";
            break;
-         case 'c':
+        case 'c':
            if (jcr) {
               str = jcr->client_name;
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
-         case 'd':
-            str = my_name;            /* Director's name */
+        case 'd':
+           str = my_name;            /* Director's name */
            break;
-         case 'e':
+        case 'e':
            if (jcr) {
-              str = job_status_to_str(jcr->JobStatus); 
-           } else { 
-               str = "*none*";
+              str = job_status_to_str(jcr->JobStatus);
+           } else {
+              str = "*none*";
            }
            break;
-         case 'i':
+        case 'i':
            if (jcr) {
-               bsnprintf(add, sizeof(add), "%d", jcr->JobId);
+              bsnprintf(add, sizeof(add), "%d", jcr->JobId);
               str = add;
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
-         case 'j':                    /* Job name */
+        case 'j':                    /* Job name */
            if (jcr) {
               str = jcr->Job;
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
-         case 'l':
+        case 'l':
            if (jcr) {
               str = job_level_to_str(jcr->JobLevel);
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
-         case 'n':
+        case 'n':
             if (jcr) {
                bstrncpy(name, jcr->Job, sizeof(name));
                /* There are three periods after the Job name */
                for (i=0; i<3; i++) {
-                   if ((q=strrchr(name, '.')) != NULL) {
+                  if ((q=strrchr(name, '.')) != NULL) {
                       *q = 0;
                   }
                }
                str = name;
             } else {
-                str = "*none*";
+               str = "*none*";
             }
             break;
-         case 'r':
+        case 'r':
            str = to;
            break;
-         case 't':
+        case 't':
            if (jcr) {
               str = job_type_to_str(jcr->JobType);
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
-         case 'v':
+        case 'v':
            if (jcr) {
               if (jcr->VolumeName && jcr->VolumeName[0]) {
                  str = jcr->VolumeName;
               } else {
-                  str = "";
+                 str = "";
               }
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
         default:
-            add[0] = '%';
+           add[0] = '%';
            add[1] = *p;
            add[2] = 0;
            str = add;
@@ -636,7 +636,7 @@ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to)
 
 void set_working_directory(char *wd)
 {
-   struct stat stat_buf; 
+   struct stat stat_buf;
 
    if (wd == NULL) {
       Emsg0(M_ERROR_TERM, 0, _("Working directory not defined. Cannot continue.\n"));
index eb33b0eade932415056be62af313d15c4cdf6bce..d9b58d74971d4c3ed64b3147f55d2420cbb6d1bc 100644 (file)
@@ -107,13 +107,13 @@ static const var_syntax_t var_syntax_default = {
 */
 
 /* minimal output-independent vprintf(3) variant which supports %{c,s,d,%} only */
-static int 
+static int
 var_mvxprintf(
-    int (*output)(void *ctx, const char *buffer, int bufsize), void *ctx, 
+    int (*output)(void *ctx, const char *buffer, int bufsize), void *ctx,
     const char *format, va_list ap)
 {
     /* sufficient integer buffer: <available-bits> x log_10(2) + safety */
-    char ibuf[((sizeof(int)*8)/3)+10]; 
+    char ibuf[((sizeof(int)*8)/3)+10];
     const char *cp;
     char c;
     int d;
@@ -124,34 +124,34 @@ var_mvxprintf(
        return -1;
     bytes = 0;
     while (*format != '\0') {
-        if (*format == '%') {
+       if (*format == '%') {
            c = *(format+1);
-            if (c == '%') {
-                /* expand "%%" */
+           if (c == '%') {
+               /* expand "%%" */
                cp = &c;
                n = sizeof(char);
            }
-            else if (c == 'c') {
-                /* expand "%c" */
+           else if (c == 'c') {
+               /* expand "%c" */
                c = (char)va_arg(ap, int);
                cp = &c;
                n = sizeof(char);
            }
-            else if (c == 's') {
-                /* expand "%s" */
+           else if (c == 's') {
+               /* expand "%s" */
                if ((cp = (char *)va_arg(ap, char *)) == NULL)
-                    cp = "(null)";
+                   cp = "(null)";
                n = strlen(cp);
            }
-            else if (c == 'd') {
-                /* expand "%d" */
+           else if (c == 'd') {
+               /* expand "%d" */
                d = (int)va_arg(ap, int);
-                bsnprintf(ibuf, sizeof(ibuf), "%d", d); /* explicitly secure */
+               bsnprintf(ibuf, sizeof(ibuf), "%d", d); /* explicitly secure */
                cp = ibuf;
                n = strlen(cp);
            }
            else {
-                /* any other "%X" */
+               /* any other "%X" */
                cp = (char *)format;
                n  = 2;
            }
@@ -160,8 +160,8 @@ var_mvxprintf(
        else {
            /* plain text */
            cp = (char *)format;
-            if ((format = strchr(cp, '%')) == NULL)
-                format = strchr(cp, '\0');
+           if ((format = strchr(cp, '%')) == NULL)
+               format = strchr(cp, '\0');
            n = format - cp;
        }
        /* perform output operation */
@@ -180,9 +180,9 @@ typedef struct {
 } var_mvsnprintf_cb_t;
 
 /* output callback function for var_mvsnprintf() */
-static int 
+static int
 var_mvsnprintf_cb(
-    void *_ctx, 
+    void *_ctx,
     const char *buffer, int bufsize)
 {
     var_mvsnprintf_cb_t *ctx = (var_mvsnprintf_cb_t *)_ctx;
@@ -196,9 +196,9 @@ var_mvsnprintf_cb(
 }
 
 /* minimal vsnprintf(3) variant which supports %{c,s,d} only */
-static int 
+static int
 var_mvsnprintf(
-    char *buffer, int bufsize, 
+    char *buffer, int bufsize,
     const char *format, va_list ap)
 {
     int n;
@@ -208,7 +208,7 @@ var_mvsnprintf(
        return -1;
     if (buffer != NULL && bufsize == 0)
        return -1;
-    if (buffer == NULL) 
+    if (buffer == NULL)
        /* just determine output length */
        n = var_mvxprintf(NULL, NULL, format, ap);
     else {
@@ -219,7 +219,7 @@ var_mvsnprintf(
        if (n != -1 && ctx.buflen == 0)
            n = -1;
        if (n != -1)
-            *(ctx.bufptr) = '\0';
+           *(ctx.bufptr) = '\0';
     }
     return n;
 }
@@ -264,7 +264,7 @@ typedef struct {
     int buffer_size;
 } tokenbuf_t;
 
-static void 
+static void
 tokenbuf_init(
     tokenbuf_t *buf)
 {
@@ -274,7 +274,7 @@ tokenbuf_init(
     return;
 }
 
-static int 
+static int
 tokenbuf_isundef(
     tokenbuf_t *buf)
 {
@@ -283,7 +283,7 @@ tokenbuf_isundef(
     return 0;
 }
 
-static int 
+static int
 tokenbuf_isempty(
     tokenbuf_t *buf)
 {
@@ -292,7 +292,7 @@ tokenbuf_isempty(
     return 0;
 }
 
-static void 
+static void
 tokenbuf_set(
     tokenbuf_t *buf, const char *begin, const char *end, int buffer_size)
 {
@@ -302,7 +302,7 @@ tokenbuf_set(
     return;
 }
 
-static void 
+static void
 tokenbuf_move(
     tokenbuf_t *src, tokenbuf_t *dst)
 {
@@ -313,7 +313,7 @@ tokenbuf_move(
     return;
 }
 
-static int 
+static int
 tokenbuf_assign(
     tokenbuf_t *buf, const char *data, int len)
 {
@@ -329,7 +329,7 @@ tokenbuf_assign(
     return 1;
 }
 
-static int 
+static int
 tokenbuf_append(
     tokenbuf_t *output, const char *data, int len)
 {
@@ -386,14 +386,14 @@ tokenbuf_append(
     return 1;
 }
 
-static int 
+static int
 tokenbuf_merge(
     tokenbuf_t *output, tokenbuf_t *input)
 {
     return tokenbuf_append(output, input->begin, input->end - input->begin);
 }
 
-static void 
+static void
 tokenbuf_free(
     tokenbuf_t *buf)
 {
@@ -410,7 +410,7 @@ tokenbuf_free(
 **
 */
 
-static void 
+static void
 expand_range(char a, char b, char_class_t chrclass)
 {
     do {
@@ -419,7 +419,7 @@ expand_range(char a, char b, char_class_t chrclass)
     return;
 }
 
-static var_rc_t 
+static var_rc_t
 expand_character_class(const char *desc, char_class_t chrclass)
 {
     int i;
@@ -430,7 +430,7 @@ expand_character_class(const char *desc, char_class_t chrclass)
 
     /* walk through class description and set appropriate entries in array */
     while (*desc != EOS) {
-        if (desc[1] == '-' && desc[2] != EOS) {
+       if (desc[1] == '-' && desc[2] != EOS) {
            if (desc[0] > desc[2])
                return VAR_ERR_INCORRECT_CLASS_SPEC;
            expand_range(desc[0], desc[2], chrclass);
@@ -449,7 +449,7 @@ expand_character_class(const char *desc, char_class_t chrclass)
 **
 */
 
-static int 
+static int
 expand_isoct(
     int c)
 {
@@ -459,7 +459,7 @@ expand_isoct(
        return 0;
 }
 
-static var_rc_t 
+static var_rc_t
 expand_octal(
     const char **src, char **dst, const char *end)
 {
@@ -467,8 +467,8 @@ expand_octal(
 
     if (end - *src < 3)
        return VAR_ERR_INCOMPLETE_OCTAL;
-    if (   !expand_isoct(**src) 
-       || !expand_isoct((*src)[1]) 
+    if (   !expand_isoct(**src)
+       || !expand_isoct((*src)[1])
        || !expand_isoct((*src)[2]))
        return VAR_ERR_INVALID_OCTAL;
 
@@ -489,18 +489,18 @@ expand_octal(
     return VAR_OK;
 }
 
-static int 
+static int
 expand_ishex(
     int c)
 {
     if ((c >= '0' && c <= '9') ||
-        (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
+       (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
        return 1;
     else
        return 0;
 }
 
-static var_rc_t 
+static var_rc_t
 expand_simple_hex(
     const char **src, char **dst, const char *end)
 {
@@ -508,33 +508,33 @@ expand_simple_hex(
 
     if (end - *src < 2)
        return VAR_ERR_INCOMPLETE_HEX;
-    if (   !expand_ishex(**src) 
+    if (   !expand_ishex(**src)
        || !expand_ishex((*src)[1]))
        return VAR_ERR_INVALID_HEX;
 
     if (**src >= '0' && **src <= '9')
-        c = **src - '0';
+       c = **src - '0';
     else if (**src >= 'a' && **src <= 'f')
-        c = **src - 'a' + 10;
+       c = **src - 'a' + 10;
     else if (**src >= 'A' && **src <= 'F')
-        c = **src - 'A' + 10;
+       c = **src - 'A' + 10;
 
     c = c << 4;
     (*src)++;
 
     if (**src >= '0' && **src <= '9')
-        c += **src - '0';
+       c += **src - '0';
     else if (**src >= 'a' && **src <= 'f')
-        c += **src - 'a' + 10;
+       c += **src - 'a' + 10;
     else if (**src >= 'A' && **src <= 'F')
-        c += **src - 'A' + 10;
+       c += **src - 'A' + 10;
 
     **dst = (char)c;
     (*dst)++;
     return VAR_OK;
 }
 
-static var_rc_t 
+static var_rc_t
 expand_grouped_hex(
     const char **src, char **dst, const char *end)
 {
@@ -551,7 +551,7 @@ expand_grouped_hex(
     return VAR_OK;
 }
 
-static var_rc_t 
+static var_rc_t
 expand_hex(
     const char **src, char **dst, const char *end)
 {
@@ -564,7 +564,7 @@ expand_hex(
        return expand_simple_hex(src, dst, end);
 }
 
-/* 
+/*
 **
 **  ==== RECURSIVE-DESCEND VARIABLE EXPANSION PARSER ====
 **
@@ -576,7 +576,7 @@ static int parse_numexp (var_t *var, var_parse_t *ctx, const char *begin, const
 static int parse_name  (var_t *var, var_parse_t *ctx, const char *begin, const char *end);
 
 /* parse pattern text */
-static int 
+static int
 parse_pattern(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end)
@@ -595,7 +595,7 @@ parse_pattern(
 }
 
 /* parse substitution text */
-static int 
+static int
 parse_substext(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end)
@@ -614,7 +614,7 @@ parse_substext(
 }
 
 /* parse expression text */
-static int 
+static int
 parse_exptext(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end)
@@ -625,7 +625,7 @@ parse_exptext(
     for (p = begin;    p != end
                    && *p != var->syntax.delim_init
                    && *p != var->syntax.delim_close
-                    && *p != ':'; p++) {
+                   && *p != ':'; p++) {
        if (*p == var->syntax.escape) {
            if (p + 1 == end)
                return VAR_ERR_INCOMPLETE_QUOTED_PAIR;
@@ -636,7 +636,7 @@ parse_exptext(
 }
 
 /* parse opertion argument text */
-static int 
+static int
 parse_opargtext(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end)
@@ -654,7 +654,7 @@ parse_opargtext(
     return (p - begin);
 }
 
-static int 
+static int
 parse_opargtext_or_variable(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end,
@@ -702,7 +702,7 @@ error_return:
 }
 
 /* parse expression or variable */
-static int 
+static int
 parse_exptext_or_variable(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end,
@@ -753,7 +753,7 @@ error_return:
 }
 
 /* parse substitution text or variable */
-static int 
+static int
 parse_substext_or_variable(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end,
@@ -804,17 +804,17 @@ error_return:
 }
 
 /* parse class description */
-static int 
+static int
 parse_class_description(
     var_t *var, var_parse_t *ctx,
     tokenbuf_t *src, tokenbuf_t *dst)
 {
     unsigned char c, d;
-    const char *p; 
+    const char *p;
 
     p = src->begin;
     while (p != src->end) {
-        if ((src->end - p) >= 3 && p[1] == '-') {
+       if ((src->end - p) >= 3 && p[1] == '-') {
            if (*p > p[2])
                return VAR_ERR_INCORRECT_TRANSPOSE_CLASS_SPEC;
            for (c = *p, d = p[2]; c <= d; ++c) {
@@ -832,12 +832,12 @@ parse_class_description(
 }
 
 /* parse regex replace part */
-static int 
+static int
 parse_regex_replace(
     var_t *var, var_parse_t *ctx,
-    const char *data, 
+    const char *data,
     tokenbuf_t *orig,
-    regmatch_t *pmatch, 
+    regmatch_t *pmatch,
     tokenbuf_t *expanded)
 {
     const char *p;
@@ -847,13 +847,13 @@ parse_regex_replace(
     tokenbuf_init(expanded);
 
     while (p != orig->end) {
-        if (*p == '\\') {
+       if (*p == '\\') {
            if (orig->end - p <= 1) {
                tokenbuf_free(expanded);
                return VAR_ERR_INCOMPLETE_QUOTED_PAIR;
            }
            p++;
-            if (*p == '\\') {
+           if (*p == '\\') {
                if (!tokenbuf_append(expanded, p, 1)) {
                    tokenbuf_free(expanded);
                    return VAR_ERR_OUT_OF_MEMORY;
@@ -865,7 +865,7 @@ parse_regex_replace(
                tokenbuf_free(expanded);
                return VAR_ERR_UNKNOWN_QUOTED_PAIR_IN_REPLACE;
            }
-            i = (*p - '0');
+           i = (*p - '0');
            p++;
            if (pmatch[i].rm_so == -1 || pmatch[i].rm_eo == -1) {
                tokenbuf_free(expanded);
@@ -889,10 +889,10 @@ parse_regex_replace(
 }
 
 /* operation: transpose */
-static int 
+static int
 op_transpose(
     var_t *var, var_parse_t *ctx,
-    tokenbuf_t *data, 
+    tokenbuf_t *data,
     tokenbuf_t *search,
     tokenbuf_t *replace)
 {
@@ -944,12 +944,12 @@ error_return:
 }
 
 /* operation: search & replace */
-static int 
+static int
 op_search_and_replace(
     var_t *var, var_parse_t *ctx,
-    tokenbuf_t *data, 
+    tokenbuf_t *data,
     tokenbuf_t *search,
-    tokenbuf_t *replace, 
+    tokenbuf_t *replace,
     tokenbuf_t *flags)
 {
     tokenbuf_t tmp;
@@ -965,16 +965,16 @@ op_search_and_replace(
 
     for (p = flags->begin; p != flags->end; p++) {
        switch (tolower(*p)) {
-            case 'm':
+           case 'm':
                multiline = 1;
                break;
-            case 'i':
+           case 'i':
                case_insensitive = 1;
                break;
-            case 'g':
+           case 'g':
                global = 1;
                break;
-            case 't':
+           case 't':
                no_regex = 1;
                break;
            default:
@@ -1030,7 +1030,7 @@ op_search_and_replace(
        }
 
        /* compile the pattern. */
-       rc = regcomp(&preg, tmp.begin, 
+       rc = regcomp(&preg, tmp.begin,
                     (  REG_EXTENDED
                      | (multiline ? REG_NEWLINE : 0)
                      | (case_insensitive ? REG_ICASE : 0)));
@@ -1041,9 +1041,9 @@ op_search_and_replace(
        }
 
        /* match the pattern and create the result string in the tmp buffer */
-        tokenbuf_append(&tmp, "", 0);
+       tokenbuf_append(&tmp, "", 0);
        for (p = mydata.begin; p < mydata.end; ) {
-            if (p == mydata.begin || p[-1] == '\n')
+           if (p == mydata.begin || p[-1] == '\n')
                regexec_flag = 0;
            else
                regexec_flag = REG_NOTBOL;
@@ -1053,8 +1053,8 @@ op_search_and_replace(
                tokenbuf_append(&tmp, p, mydata.end - p);
                break;
            }
-           else if (   multiline 
-                    && (p + pmatch[0].rm_so) == mydata.end 
+           else if (   multiline
+                    && (p + pmatch[0].rm_so) == mydata.end
                     && (pmatch[0].rm_eo - pmatch[0].rm_so) == 0) {
                /* special case: found empty pattern (usually /^/ or /$/ only)
                   in multi-line at end of data (after the last newline) */
@@ -1103,7 +1103,7 @@ op_search_and_replace(
                    }
                    p++;
                }
-               /* append prolog string and stop processing if we 
+               /* append prolog string and stop processing if we
                   do not perform the search & replace globally */
                if (!global) {
                    if (!tokenbuf_append(&tmp, p, mydata.end - p)) {
@@ -1126,12 +1126,12 @@ op_search_and_replace(
 }
 
 /* operation: offset substring */
-static int 
+static int
 op_offset(
     var_t *var, var_parse_t *ctx,
-    tokenbuf_t *data, 
+    tokenbuf_t *data,
     int num1,
-    int num2, 
+    int num2,
     int isrange)
 {
     tokenbuf_t res;
@@ -1168,11 +1168,11 @@ op_offset(
 }
 
 /* operation: padding */
-static int 
+static int
 op_padding(
     var_t *var, var_parse_t *ctx,
-    tokenbuf_t *data, 
-    int width, 
+    tokenbuf_t *data,
+    int width,
     tokenbuf_t *fill,
     char position)
 {
@@ -1269,7 +1269,7 @@ op_padding(
 }
 
 /* parse an integer number ("123") */
-static int 
+static int
 parse_integer(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end,
@@ -1282,7 +1282,7 @@ parse_integer(
     num = 0;
     while (isdigit(*p) && p != end) {
        num *= 10;
-        num += (*p - '0');
+       num += (*p - '0');
        p++;
     }
     if (result != NULL)
@@ -1291,7 +1291,7 @@ parse_integer(
 }
 
 /* parse an operation (":x...") */
-static int 
+static int
 parse_operation(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end,
@@ -1319,7 +1319,7 @@ parse_operation(
 
     /* dispatch through the first operation character */
     switch (tolower(*p)) {
-        case 'l': {
+       case 'l': {
            /* turn value to lowercase. */
            if (data->begin != NULL) {
                /* if the buffer does not live in an allocated buffer,
@@ -1337,7 +1337,7 @@ parse_operation(
            p++;
            break;
        }
-        case 'u': {
+       case 'u': {
            /* turn value to uppercase. */
            if (data->begin != NULL) {
                /* if the buffer does not live in an allocated buffer,
@@ -1355,7 +1355,7 @@ parse_operation(
            p++;
            break;
        }
-        case 'o': {
+       case 'o': {
            /* cut out substring of value. */
            p++;
            rc = parse_integer(var, ctx, p, end, &num1);
@@ -1366,10 +1366,10 @@ parse_operation(
            else if (rc < 0)
                goto error_return;
            p += rc;
-            if (*p == ',') {
+           if (*p == ',') {
                isrange = 0;
                p++;
-            } else if (*p == '-') {
+           } else if (*p == '-') {
                isrange = 1;
                p++;
            } else {
@@ -1385,11 +1385,11 @@ parse_operation(
            }
            break;
        }
-        case '#': {
+       case '#': {
            /* determine length of the value */
            if (data->begin != NULL) {
                char buf[((sizeof(int)*8)/3)+10]; /* sufficient size: <#bits> x log_10(2) + safety */
-                sprintf(buf, "%d", (int)(data->end - data->begin));
+               sprintf(buf, "%d", (int)(data->end - data->begin));
                tokenbuf_free(data);
                if (!tokenbuf_assign(data, buf, strlen(buf))) {
                    rc = VAR_ERR_OUT_OF_MEMORY;
@@ -1399,7 +1399,7 @@ parse_operation(
            p++;
            break;
        }
-        case '-': {
+       case '-': {
            /* substitute parameter if data is empty */
            p++;
            rc = parse_exptext_or_variable(var, ctx, p, end, &tmptokbuf);
@@ -1418,7 +1418,7 @@ parse_operation(
            }
            break;
        }
-        case '*': {
+       case '*': {
            /* substitute empty string if data is not empty, parameter otherwise. */
            p++;
            rc = parse_exptext_or_variable(var, ctx, p, end, &tmptokbuf);
@@ -1435,13 +1435,13 @@ parse_operation(
                    tokenbuf_move(&tmptokbuf, data);
                } else {
                    tokenbuf_free(data);
-                    data->begin = data->end = "";
+                   data->begin = data->end = "";
                    data->buffer_size = 0;
                }
            }
            break;
        }
-        case '+': {
+       case '+': {
            /* substitute parameter if data is not empty. */
            p++;
            rc = parse_exptext_or_variable(var, ctx, p, end, &tmptokbuf);
@@ -1458,10 +1458,10 @@ parse_operation(
            }
            break;
        }
-        case 's': {
+       case 's': {
            /* search and replace. */
            p++;
-            if (*p != '/')
+           if (*p != '/')
                return VAR_ERR_MALFORMATTED_REPLACE;
            p++;
            rc = parse_pattern(var, ctx, p, end);
@@ -1469,7 +1469,7 @@ parse_operation(
                goto error_return;
            tokenbuf_set(&search, p, p + rc, 0);
            p += rc;
-            if (*p != '/') {
+           if (*p != '/') {
                rc = VAR_ERR_MALFORMATTED_REPLACE;
                goto error_return;
            }
@@ -1478,7 +1478,7 @@ parse_operation(
            if (rc < 0)
                goto error_return;
            p += rc;
-            if (*p != '/') {
+           if (*p != '/') {
                rc = VAR_ERR_MALFORMATTED_REPLACE;
                goto error_return;
            }
@@ -1495,17 +1495,17 @@ parse_operation(
            }
            break;
        }
-        case 'y': {
+       case 'y': {
            /* transpose characters from class A to class B. */
            p++;
-            if (*p != '/')
+           if (*p != '/')
                return VAR_ERR_MALFORMATTED_TRANSPOSE;
            p++;
            rc = parse_substext_or_variable(var, ctx, p, end, &search);
            if (rc < 0)
                goto error_return;
            p += rc;
-            if (*p != '/') {
+           if (*p != '/') {
                rc = VAR_ERR_MALFORMATTED_TRANSPOSE;
                goto error_return;
            }
@@ -1514,7 +1514,7 @@ parse_operation(
            if (rc < 0)
                goto error_return;
            p += rc;
-            if (*p != '/') {
+           if (*p != '/') {
                rc = VAR_ERR_MALFORMATTED_TRANSPOSE;
                goto error_return;
            } else
@@ -1526,10 +1526,10 @@ parse_operation(
            }
            break;
        }
-        case 'p': {
+       case 'p': {
            /* padding. */
            p++;
-            if (*p != '/')
+           if (*p != '/')
                return VAR_ERR_MALFORMATTED_PADDING;
            p++;
            rc = parse_integer(var, ctx, p, end, &num1);
@@ -1538,7 +1538,7 @@ parse_operation(
                goto error_return;
            }
            p += rc;
-            if (*p != '/') {
+           if (*p != '/') {
                rc = VAR_ERR_MALFORMATTED_PADDING;
                goto error_return;
            }
@@ -1547,12 +1547,12 @@ parse_operation(
            if (rc < 0)
                goto error_return;
            p += rc;
-            if (*p != '/') {
+           if (*p != '/') {
                rc = VAR_ERR_MALFORMATTED_PADDING;
                goto error_return;
            }
            p++;
-            if (*p != 'l' && *p != 'c' && *p != 'r') {
+           if (*p != 'l' && *p != 'c' && *p != 'r') {
                rc = VAR_ERR_MALFORMATTED_PADDING;
                goto error_return;
            }
@@ -1564,7 +1564,7 @@ parse_operation(
            }
            break;
        }
-        case '%': {
+       case '%': {
            /* operation callback function */
            const char *op_ptr;
            int op_len;
@@ -1573,7 +1573,7 @@ parse_operation(
            const char *val_ptr;
            int val_len;
            const char *out_ptr;
-           int out_len; 
+           int out_len;
            int out_size;
            tokenbuf_t args;
 
@@ -1584,7 +1584,7 @@ parse_operation(
            op_ptr = p;
            op_len = rc;
            p += rc;
-            if (*p == '(') {
+           if (*p == '(') {
                p++;
                tokenbuf_init(&args);
                rc = parse_opargtext_or_variable(var, ctx, p, end, &args);
@@ -1593,7 +1593,7 @@ parse_operation(
                p += rc;
                arg_ptr = args.begin;
                arg_len = args.end - args.begin;
-                if (*p != ')') {
+               if (*p != ')') {
                    rc = VAR_ERR_MALFORMED_OPERATION_ARGUMENTS;
                    goto error_return;
                }
@@ -1651,10 +1651,10 @@ error_return:
 }
 
 /* parse numerical expression operand */
-static int 
+static int
 parse_numexp_operand(
     var_t *var, var_parse_t *ctx,
-    const char *begin, const char *end, 
+    const char *begin, const char *end,
     int *result, int *failed)
 {
     const char *p;
@@ -1678,7 +1678,7 @@ parse_numexp_operand(
        if (p == end)
            return VAR_ERR_INCOMPLETE_INDEX_SPEC;
        /* parse closing parenthesis */
-        if (*p != ')')
+       if (*p != ')')
            return VAR_ERR_UNCLOSED_BRACKET_IN_INDEX;
        p++;
     }
@@ -1714,7 +1714,7 @@ parse_numexp_operand(
        }
     }
     /* parse relative index mark ("#") */
-    else if (  var->syntax.index_mark != EOS 
+    else if (  var->syntax.index_mark != EOS
             && *p == var->syntax.index_mark) {
        p++;
        *result = ctx->index_this;
@@ -1755,10 +1755,10 @@ parse_numexp_operand(
 }
 
 /* parse numerical expression ("x+y") */
-static int 
+static int
 parse_numexp(
     var_t *var, var_parse_t *ctx,
-    const char *begin, const char *end, 
+    const char *begin, const char *end,
     int *result, int *failed)
 {
     const char *p;
@@ -1779,28 +1779,28 @@ parse_numexp(
 
     /* parse numerical operator */
     while (p != end) {
-        if (*p == '+' || *p == '-') {
+       if (*p == '+' || *p == '-') {
            op = *p++;
            /* recursively parse right operand (light binding) */
            rc = parse_numexp(var, ctx, p, end, &right, failed);
            if (rc < 0)
                return rc;
            p += rc;
-            if (op == '+')
+           if (op == '+')
                *result = (*result + right);
            else
                *result = (*result - right);
        }
-        else if (*p == '*' || *p == '/' || *p == '%') {
+       else if (*p == '*' || *p == '/' || *p == '%') {
            op = *p++;
            /* recursively parse right operand (string binding) */
            rc = parse_numexp_operand(var, ctx, p, end, &right, failed);
            if (rc < 0)
                return rc;
            p += rc;
-            if (op == '*')
+           if (op == '*')
                *result = (*result * right);
-            else if (op == '/') {
+           else if (op == '/') {
                if (right == 0) {
                    if (*failed)
                        *result = 0;
@@ -1810,7 +1810,7 @@ parse_numexp(
                else
                    *result = (*result / right);
            }
-            else if (op == '%') {
+           else if (op == '%') {
                if (right == 0) {
                    if (*failed)
                        *result = 0;
@@ -1830,7 +1830,7 @@ parse_numexp(
 }
 
 /* parse variable name ("abc") */
-static int 
+static int
 parse_name(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end)
@@ -1844,7 +1844,7 @@ parse_name(
 }
 
 /* lookup a variable value through the callback function */
-static int 
+static int
 lookup_value(
     var_t *var, var_parse_t *ctx,
     const char *var_ptr, int  var_len, int var_inc, int var_idx,
@@ -1855,13 +1855,13 @@ lookup_value(
 
     /* pass through to original callback */
     rc = (*var->cb_value_fct)(var, var->cb_value_ctx,
-                             var_ptr, var_len, var_inc, var_idx, 
+                             var_ptr, var_len, var_inc, var_idx,
                              val_ptr, val_len, val_size);
 
     /* convert undefined variable into empty variable if relative
        lookups are counted. This is the case inside an active loop
        construct if no limits are given. There the parse_input()
-       has to proceed until all variables have undefined values. 
+       has to proceed until all variables have undefined values.
        This trick here allows it to determine this case. */
     if (ctx->rel_lookup_flag && rc == VAR_ERR_UNDEFINED_VARIABLE) {
        ctx->rel_lookup_cnt--;
@@ -1876,7 +1876,7 @@ lookup_value(
 }
 
 /* parse complex variable construct ("${name...}") */
-static int 
+static int
 parse_variable_complex(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end,
@@ -1888,7 +1888,7 @@ parse_variable_complex(
     int failed = 0;
     int rc;
     int idx = 0;
-    int inc;   
+    int inc;
     tokenbuf_t name;
     tokenbuf_t tmp;
 
@@ -1935,7 +1935,7 @@ parse_variable_complex(
        tokenbuf_free(&tmp);          /* KES 11/9/2003 */
     } while (rc > 0);
 
-    /* we must have the complete expanded variable name now, 
+    /* we must have the complete expanded variable name now,
        so make sure we really do. */
     if (name.begin == name.end) {
        if (ctx->force_expand) {
@@ -1944,7 +1944,7 @@ parse_variable_complex(
        }
        else {
            /* If no force_expand is requested, we have to back-off.
-               We're not sure whether our approach here is 100% correct,
+              We're not sure whether our approach here is 100% correct,
               because it _could_ have side-effects according to Peter
               Simons, but as far as we know and tried it, it is
               correct. But be warned -- RSE */
@@ -2008,7 +2008,7 @@ goahead:
        tokenbuf_free(&tmp);
        tokenbuf_init(&tmp);
        p--;
-        while (p != end && *p == ':') {
+       while (p != end && *p == ':') {
            p++;
            if (!failed)
                rc = parse_operation(var, ctx, p, end, result);
@@ -2055,7 +2055,7 @@ error_return:
 }
 
 /* parse variable construct ("$name" or "${name...}") */
-static int 
+static int
 parse_variable(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end,
@@ -2078,13 +2078,13 @@ parse_variable(
     if (p == end)
        return VAR_ERR_INCOMPLETE_VARIABLE_SPEC;
 
-    /* parse a simple variable name. 
+    /* parse a simple variable name.
        (if this fails, we're try to parse a complex variable construct) */
     rc = parse_name(var, ctx, p, end);
     if (rc < 0)
        return rc;
     if (rc > 0) {
-        inc = (p[rc] == '+');
+       inc = (p[rc] == '+');
        rc2 = lookup_value(var, ctx, p, rc, inc, 0, &data, &len, &buffer_size);
        if (rc2 == VAR_ERR_UNDEFINED_VARIABLE && !ctx->force_expand) {
            tokenbuf_set(result, begin, begin + 1 + rc, 0);
@@ -2104,7 +2104,7 @@ parse_variable(
 }
 
 /* parse loop construct limits ("[...]{b,s,e}") */
-static var_rc_t 
+static var_rc_t
 parse_looplimits(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end,
@@ -2201,14 +2201,14 @@ parse_looplimits(
 }
 
 /* parse plain text */
-static int 
+static int
 parse_text(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end)
 {
     const char *p;
 
-    /* parse until delim_init (variable construct) 
+    /* parse until delim_init (variable construct)
        or index_open (loop construct) is found */
     for (p = begin; p != end; p++) {
        if (*p == var->syntax.escape) {
@@ -2219,7 +2219,7 @@ parse_text(
        else if (*p == var->syntax.delim_init)
            break;
        else if (   var->syntax.index_open != EOS
-                && (   *p == var->syntax.index_open 
+                && (   *p == var->syntax.index_open
                     || *p == var->syntax.index_close))
            break;
     }
@@ -2227,7 +2227,7 @@ parse_text(
 }
 
 /* expand input in general */
-static var_rc_t 
+static var_rc_t
 parse_input(
     var_t *var, var_parse_t *ctx,
     const char *begin, const char *end,
@@ -2248,8 +2248,8 @@ parse_input(
 
     do {
        /* try to parse a loop construct */
-       if (   p != end 
-           && var->syntax.index_open != EOS 
+       if (   p != end
+           && var->syntax.index_open != EOS
            && *p == var->syntax.index_open) {
            p++;
 
@@ -2269,24 +2269,24 @@ parse_input(
               or there is a stop limit known and it is still not reached */
            re_loop:
            for (i = start;
-                (   (   open_stop 
-                     && (   loop_limit_length < 0 
-                         || rel_lookup_cnt > ctx->rel_lookup_cnt)) 
-                 || (   !open_stop 
+                (   (   open_stop
+                     && (   loop_limit_length < 0
+                         || rel_lookup_cnt > ctx->rel_lookup_cnt))
+                 || (   !open_stop
                      && i <= stop)                                );
                 i += step) {
 
                /* remember current output end for restoring */
                output_backup = (output->end - output->begin);
 
-               /* open temporary context for recursion */ 
+               /* open temporary context for recursion */
                ctx = var_parse_push(ctx, &myctx);
                ctx->force_expand    = 1;
                ctx->rel_lookup_flag = 1;
                ctx->index_this      = i;
 
                /* recursive parse input through ourself */
-               rc = parse_input(var, ctx, p, end, 
+               rc = parse_input(var, ctx, p, end,
                                 output, recursion_level+1);
 
                /* retrieve info and close temporary context */
@@ -2305,7 +2305,7 @@ parse_input(
 
                /* try to parse loop construct limit specification */
                if (loop_limit_length < 0) {
-                   rc2 = parse_looplimits(var, ctx, p+rc+1, end, 
+                   rc2 = parse_looplimits(var, ctx, p+rc+1, end,
                                           &start, &step, &stop, &open_stop);
                    if (rc2 < 0)
                        goto error_return;
@@ -2358,7 +2358,7 @@ parse_input(
            tokenbuf_free(&result);
            p += rc;
            continue;
-       }    
+       }
        tokenbuf_free(&result);
        if (rc < 0)
            goto error_return;
@@ -2388,14 +2388,14 @@ parse_input(
     return (var_rc_t)rc;
 }
 
-/* 
+/*
 **
 **  ==== APPLICATION PROGRAMMING INTERFACE (API) ====
 **
 */
 
 /* create variable expansion context */
-var_rc_t 
+var_rc_t
 var_create(
     var_t **pvar)
 {
@@ -2412,7 +2412,7 @@ var_create(
 }
 
 /* destroy variable expansion context */
-var_rc_t 
+var_rc_t
 var_destroy(
     var_t *var)
 {
@@ -2423,10 +2423,10 @@ var_destroy(
 }
 
 /* configure variable expansion context */
-var_rc_t 
+var_rc_t
 var_config(
-    var_t *var, 
-    var_config_t mode, 
+    var_t *var,
+    var_config_t mode,
     ...)
 {
     va_list ap;
@@ -2451,7 +2451,7 @@ var_config(
            var->syntax.name_chars  = NULL; /* unused internally */
            if ((rc = expand_character_class(s->name_chars, var->syntax_nameclass)) != VAR_OK)
                return VAR_RC(rc);
-           if (   var->syntax_nameclass[(int)var->syntax.delim_init] 
+           if (   var->syntax_nameclass[(int)var->syntax.delim_init]
                || var->syntax_nameclass[(int)var->syntax.delim_open]
                || var->syntax_nameclass[(int)var->syntax.delim_close]
                || var->syntax_nameclass[(int)var->syntax.escape])
@@ -2484,11 +2484,11 @@ var_config(
 }
 
 /* perform unescape operation on a buffer */
-var_rc_t 
+var_rc_t
 var_unescape(
-    var_t *var, 
-    const char *src, int srclen, 
-    char *dst, int dstlen, 
+    var_t *var,
+    const char *src, int srclen,
+    char *dst, int dstlen,
     int all)
 {
     const char *end;
@@ -2498,34 +2498,34 @@ var_unescape(
        return VAR_RC(VAR_ERR_INVALID_ARGUMENT);
     end = src + srclen;
     while (src < end) {
-        if (*src == '\\') {
+       if (*src == '\\') {
            if (++src == end)
                return VAR_RC(VAR_ERR_INCOMPLETE_NAMED_CHARACTER);
            switch (*src) {
-                case '\\':
+               case '\\':
                    if (!all) {
-                        *dst++ = '\\';
+                       *dst++ = '\\';
                    }
-                    *dst++ = '\\';
+                   *dst++ = '\\';
                    break;
-                case 'n':
-                    *dst++ = '\n';
+               case 'n':
+                   *dst++ = '\n';
                    break;
-                case 't':
-                    *dst++ = '\t';
+               case 't':
+                   *dst++ = '\t';
                    break;
-                case 'r':
-                    *dst++ = '\r';
+               case 'r':
+                   *dst++ = '\r';
                    break;
-                case 'x':
+               case 'x':
                    ++src;
                    if ((rc = expand_hex(&src, &dst, end)) != VAR_OK)
                        return VAR_RC(rc);
                    break;
-                case '0': case '1': case '2': case '3': case '4':
-                case '5': case '6': case '7': case '8': case '9':
-                   if (   end - src >= 3 
-                       && isdigit((int)src[1]) 
+               case '0': case '1': case '2': case '3': case '4':
+               case '5': case '6': case '7': case '8': case '9':
+                   if (   end - src >= 3
+                       && isdigit((int)src[1])
                        && isdigit((int)src[2])) {
                        if ((rc = expand_octal(&src, &dst, end)) != 0)
                            return VAR_RC(rc);
@@ -2533,7 +2533,7 @@ var_unescape(
                    }
                default:
                    if (!all) {
-                        *dst++ = '\\';
+                       *dst++ = '\\';
                    }
                    *dst++ = *src;
            }
@@ -2546,11 +2546,11 @@ var_unescape(
 }
 
 /* perform expand operation on a buffer */
-var_rc_t 
+var_rc_t
 var_expand(
-    var_t *var, 
-    const char *src_ptr, int src_len, 
-    char **dst_ptr, int *dst_len, 
+    var_t *var,
+    const char *src_ptr, int src_len,
+    char **dst_ptr, int *dst_len,
     int force_expand)
 {
     var_parse_t ctx;
@@ -2574,9 +2574,9 @@ var_expand(
 
     /* post-processing */
     if (rc >= 0) {
-       /* always EOS-terminate output for convinience reasons 
+       /* always EOS-terminate output for convinience reasons
           but do not count the EOS-terminator in the length */
-        if (!tokenbuf_append(&output, "\0", 1)) {
+       if (!tokenbuf_append(&output, "\0", 1)) {
            tokenbuf_free(&output);
            return VAR_RC(VAR_ERR_OUT_OF_MEMORY);
        }
@@ -2598,10 +2598,10 @@ var_expand(
 }
 
 /* format and expand a string */
-var_rc_t 
+var_rc_t
 var_formatv(
-    var_t *var, 
-    char **dst_ptr, int force_expand, 
+    var_t *var,
+    char **dst_ptr, int force_expand,
     const char *fmt, va_list ap)
 {
     var_rc_t rc;
@@ -2634,10 +2634,10 @@ var_formatv(
 }
 
 /* format and expand a string */
-var_rc_t 
+var_rc_t
 var_format(
-    var_t *var, 
-    char **dst_ptr, int force_expand, 
+    var_t *var,
+    char **dst_ptr, int force_expand,
     const char *fmt, ...)
 {
     var_rc_t rc;
@@ -2710,7 +2710,7 @@ const char *var_strerror(var_t *var, var_rc_t rc)
     const char *str;
     rc = (var_rc_t)(0 - rc);
     if (rc < 0 || rc >= (int)sizeof(var_errors) / (int)sizeof(char *)) {
-        str = "unknown error";
+       str = "unknown error";
     } else {
        str = (char *)var_errors[rc];
     }
index 4931075663c76e20a100119fc0880c705ac5a614..45da4b00ace1d9efc7276dd136df5d12a1a5b453 100644 (file)
@@ -135,6 +135,6 @@ var_rc_t  var_unescape  (var_t  *var, const char *src_ptr, int src_len, char  *d
 var_rc_t  var_expand    (var_t  *var, const char *src_ptr, int src_len, char **dst_ptr, int *dst_len, int force_expand);
 var_rc_t  var_formatv   (var_t  *var, char **dst_ptr, int force_expand, const char *fmt, va_list ap);
 var_rc_t  var_format    (var_t  *var, char **dst_ptr, int force_expand, const char *fmt, ...);
-const char *var_strerror  (var_t  *var, var_rc_t rc);            
+const char *var_strerror  (var_t  *var, var_rc_t rc);
 
 #endif /* __VAR_H__ */
index 0691f455df64993b250fced6348a2d107c08132c..ec0c8d85607a37b420506ce1020f0a614c9c5159 100644 (file)
 
  */
 
-#ifndef __WAITQ_H 
+#ifndef __WAITQ_H
 #define __WAITQ_H 1
 
-/* 
+/*
  * Structure to keep track of wait queue request
  */
 typedef struct waitq_ele_tag {
@@ -43,7 +43,7 @@ typedef struct waitq_ele_tag {
    void            *msg;             /* message to be passed */
 } waitq_ele_t;
 
-/* 
+/*
  * Structure describing a wait queue
  */
 typedef struct workq_tag {
index e33bb1ca219b5fffd6eb94fa6351039713a2e194..ec6bc848a5ea8c25491470774f80ea3554afdc36 100755 (executable)
@@ -53,7 +53,7 @@ static pthread_t wd_tid;
 static dlist *wd_queue;
 static dlist *wd_inactive;
 
-/*   
+/*
  * Start watchdog thread
  *
  *  Returns: 0 on success
@@ -72,7 +72,7 @@ int start_watchdog(void)
    watchdog_time = time(NULL);
 
    if ((errstat=rwl_init(&lock)) != 0) {
-      Emsg1(M_ABORT, 0, _("Unable to initialize watchdog lock. ERR=%s\n"), 
+      Emsg1(M_ABORT, 0, _("Unable to initialize watchdog lock. ERR=%s\n"),
            strerror(errstat));
    }
    wd_queue = New(dlist(dummy, &dummy->link));
@@ -105,7 +105,7 @@ static void ping_watchdog()
 int stop_watchdog(void)
 {
    int stat;
-   watchdog_t *p;    
+   watchdog_t *p;
 
    if (!wd_is_init) {
       return 0;
@@ -181,7 +181,7 @@ bool register_watchdog(watchdog_t *wd)
    wd->next_fire = watchdog_time + wd->interval;
    wd_queue->append(wd);
    Dmsg3(400, "Registered watchdog %p, interval %d%s\n",
-         wd, wd->interval, wd->one_shot ? " one shot" : "");
+        wd, wd->interval, wd->one_shot ? " one shot" : "");
    wd_unlock();
    ping_watchdog();
 
@@ -201,7 +201,7 @@ bool unregister_watchdog(watchdog_t *wd)
    foreach_dlist(p, wd_queue) {
       if (wd == p) {
         wd_queue->remove(wd);
-         Dmsg1(400, "Unregistered watchdog %p\n", wd);
+        Dmsg1(400, "Unregistered watchdog %p\n", wd);
         ok = true;
         goto get_out;
       }
@@ -210,7 +210,7 @@ bool unregister_watchdog(watchdog_t *wd)
    foreach_dlist(p, wd_inactive) {
       if (wd == p) {
         wd_inactive->remove(wd);
-         Dmsg1(400, "Unregistered inactive watchdog %p\n", wd);
+        Dmsg1(400, "Unregistered inactive watchdog %p\n", wd);
         ok = true;
         goto get_out;
       }
@@ -234,9 +234,9 @@ extern "C" void *watchdog_thread(void *arg)
    Dmsg0(400, "NicB-reworked watchdog thread entered\n");
 
    while (!quit) {
-      watchdog_t *p;   
+      watchdog_t *p;
 
-      /* 
+      /*
        * We lock the jcr chain here because a good number of the
        *   callback routines lock the jcr chain. We need to lock
        *   it here *before* the watchdog lock because the SD message
@@ -256,7 +256,7 @@ walk_list:
            /* Run the callback */
            p->callback(p);
 
-            /* Reschedule (or move to inactive list if it's a one-shot timer) */
+           /* Reschedule (or move to inactive list if it's a one-shot timer) */
            if (p->one_shot) {
               wd_queue->remove(p);
               wd_inactive->append(p);
@@ -264,7 +264,7 @@ walk_list:
            } else {
               p->next_fire = watchdog_time + p->interval;
            }
-        } 
+        }
         if (p->next_fire < next_time) {
            next_time = p->next_fire;
         }
@@ -272,8 +272,8 @@ walk_list:
       wd_unlock();
       unlock_jcr_chain();
 
-      /*                  
-       * Wait sleep time or until someone wakes us 
+      /*
+       * Wait sleep time or until someone wakes us
        */
       gettimeofday(&tv, &tz);
       timeout.tv_nsec = tv.tv_usec * 1000;
@@ -306,7 +306,7 @@ static void wd_lock()
       Emsg1(M_ABORT, 0, "rwl_writelock failure. ERR=%s\n",
           strerror(errstat));
    }
-}    
+}
 
 /*
  * Unlock the watchdog. This can be called multiple times by the
@@ -320,4 +320,4 @@ static void wd_unlock()
       Emsg1(M_ABORT, 0, "rwl_writeunlock failure. ERR=%s\n",
           strerror(errstat));
    }
-}    
+}
index 04725cf0189a509bf716cbe37d8850cf342f3c39..c8e1cebb582297dedf58a3d713a6f78867206543 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Watchdog timer routines
- * 
+ *
  *    Kern Sibbald, December MMII
  *
 */
 
 enum {
    TYPE_CHILD = 1,
-   TYPE_PTHREAD, 
-   TYPE_BSOCK 
+   TYPE_PTHREAD,
+   TYPE_BSOCK
 };
 
 #define TIMEOUT_SIGNAL SIGUSR2
 
 struct s_watchdog_t {
-        bool one_shot;
-        time_t interval;
-        void (*callback)(struct s_watchdog_t *wd);
-        void (*destructor)(struct s_watchdog_t *wd);
-        void *data;
-        /* Private data below - don't touch outside of watchdog.c */
-        dlink link;
-        time_t next_fire;
+       bool one_shot;
+       time_t interval;
+       void (*callback)(struct s_watchdog_t *wd);
+       void (*destructor)(struct s_watchdog_t *wd);
+       void *data;
+       /* Private data below - don't touch outside of watchdog.c */
+       dlink link;
+       time_t next_fire;
 };
 typedef struct s_watchdog_t watchdog_t;
index efc41bbe8b141c408d212a8a1d4d293bbdece434..4611e6ce541de672eef30fa63ccafa2a589c5230 100755 (executable)
@@ -52,7 +52,7 @@
 /* Forward referenced functions */
 extern "C" void *workq_server(void *arg);
 
-/*   
+/*
  * Initialize a work queue
  *
  *  Returns: 0 on success
@@ -61,7 +61,7 @@ extern "C" void *workq_server(void *arg);
 int workq_init(workq_t *wq, int threads, void *(*engine)(void *arg))
 {
    int stat;
-                       
+
    if ((stat = pthread_attr_init(&wq->attr)) != 0) {
       return stat;
    }
@@ -84,7 +84,7 @@ int workq_init(workq_t *wq, int threads, void *(*engine)(void *arg))
    wq->num_workers = 0;              /* no threads yet */
    wq->idle_workers = 0;             /* no idle threads */
    wq->engine = engine;              /* routine to run */
-   wq->valid = WORKQ_VALID; 
+   wq->valid = WORKQ_VALID;
    return 0;
 }
 
@@ -106,8 +106,8 @@ int workq_destroy(workq_t *wq)
   }
   wq->valid = 0;                     /* prevent any more operations */
 
-  /* 
-   * If any threads are active, wake them 
+  /*
+   * If any threads are active, wake them
    */
   if (wq->num_workers > 0) {
      wq->quit = 1;
@@ -137,7 +137,7 @@ int workq_destroy(workq_t *wq)
 /*
  *  Add work to a queue
  *    wq is a queue that was created with workq_init
- *    element is a user unique item that will be passed to the 
+ *    element is a user unique item that will be passed to the
  *       processing routine
  *    work_item will get internal work queue item -- if it is not NULL
  *    priority if non-zero will cause the item to be placed on the
@@ -148,7 +148,7 @@ int workq_add(workq_t *wq, void *element, workq_ele_t **work_item, int priority)
    int stat;
    workq_ele_t *item;
    pthread_t id;
-    
+
    Dmsg0(400, "workq_add\n");
    if (wq->valid != WORKQ_VALID) {
       return EINVAL;
@@ -224,7 +224,7 @@ int workq_remove(workq_t *wq, workq_ele_t *work_item)
    int stat, found = 0;
    pthread_t id;
    workq_ele_t *item, *prev;
-    
+
    Dmsg0(400, "workq_remove\n");
    if (wq->valid != WORKQ_VALID) {
       return EINVAL;
@@ -244,10 +244,10 @@ int workq_remove(workq_t *wq, workq_ele_t *work_item)
    if (!found) {
       return EINVAL;
    }
-   
+
    /* Move item to be first on list */
    if (wq->first != work_item) {
-      prev->next = work_item->next;   
+      prev->next = work_item->next;
       if (wq->last == work_item) {
         wq->last = prev;
       }
@@ -278,7 +278,7 @@ int workq_remove(workq_t *wq, workq_ele_t *work_item)
 }
 
 
-/* 
+/*
  * This is the worker thread that serves the work queue.
  * In due course, it will call the user's engine.
  */
@@ -310,7 +310,7 @@ void *workq_server(void *arg)
         /*
          * Wait 2 seconds, then if no more work, exit
          */
-         Dmsg0(400, "pthread_cond_timedwait()\n");
+        Dmsg0(400, "pthread_cond_timedwait()\n");
 #ifdef xxxxxxxxxxxxxxxx_was_HAVE_CYGWIN
         /* CYGWIN dies with a page fault the second
          * time that pthread_cond_timedwait() is called
@@ -321,18 +321,18 @@ void *workq_server(void *arg)
 #else
         stat = pthread_cond_timedwait(&wq->work, &wq->mutex, &timeout);
 #endif
-         Dmsg1(400, "timedwait=%d\n", stat);
+        Dmsg1(400, "timedwait=%d\n", stat);
         if (stat == ETIMEDOUT) {
            timedout = 1;
            break;
         } else if (stat != 0) {
-            /* This shouldn't happen */
-            Dmsg0(400, "This shouldn't happen\n");
+           /* This shouldn't happen */
+           Dmsg0(400, "This shouldn't happen\n");
            wq->num_workers--;
            pthread_mutex_unlock(&wq->mutex);
            return NULL;
         }
-      } 
+      }
       we = wq->first;
       if (we != NULL) {
         wq->first = we->next;
@@ -342,16 +342,16 @@ void *workq_server(void *arg)
         if ((stat = pthread_mutex_unlock(&wq->mutex)) != 0) {
            return NULL;
         }
-         /* Call user's routine here */
-         Dmsg0(400, "Calling user engine.\n");
+        /* Call user's routine here */
+        Dmsg0(400, "Calling user engine.\n");
         wq->engine(we->data);
-         Dmsg0(400, "Back from user engine.\n");
+        Dmsg0(400, "Back from user engine.\n");
         free(we);                    /* release work entry */
-         Dmsg0(400, "relock mutex\n"); 
+        Dmsg0(400, "relock mutex\n");
         if ((stat = pthread_mutex_lock(&wq->mutex)) != 0) {
            return NULL;
         }
-         Dmsg0(400, "Done lock mutex\n");
+        Dmsg0(400, "Done lock mutex\n");
       }
       /*
        * If no more work request, and we are asked to quit, then do it
@@ -359,23 +359,23 @@ void *workq_server(void *arg)
       if (wq->first == NULL && wq->quit) {
         wq->num_workers--;
         if (wq->num_workers == 0) {
-            Dmsg0(400, "Wake up destroy routine\n");
+           Dmsg0(400, "Wake up destroy routine\n");
            /* Wake up destroy routine if he is waiting */
            pthread_cond_broadcast(&wq->work);
         }
-         Dmsg0(400, "Unlock mutex\n");
+        Dmsg0(400, "Unlock mutex\n");
         pthread_mutex_unlock(&wq->mutex);
-         Dmsg0(400, "Return from workq_server\n");
+        Dmsg0(400, "Return from workq_server\n");
         return NULL;
       }
       Dmsg0(400, "Check for work request\n");
-      /* 
+      /*
        * If no more work requests, and we waited long enough, quit
        */
       Dmsg1(400, "wq->first==NULL = %d\n", wq->first==NULL);
       Dmsg1(400, "timedout=%d\n", timedout);
       if (wq->first == NULL && timedout) {
-         Dmsg0(400, "break big loop\n");
+        Dmsg0(400, "break big loop\n");
         wq->num_workers--;
         break;
       }
index d0a8443482384450ff9c1d6cc0ab55e864b16c23..2c4c11d27e0f689aaa9e9998466b13d13a2b8f8a 100644 (file)
 
  */
 
-#ifndef __WORKQ_H 
+#ifndef __WORKQ_H
 #define __WORKQ_H 1
 
-/* 
+/*
  * Structure to keep track of work queue request
  */
 typedef struct workq_ele_tag {
@@ -40,7 +40,7 @@ typedef struct workq_ele_tag {
    void                 *data;
 } workq_ele_t;
 
-/* 
+/*
  * Structure describing a work queue
  */
 typedef struct workq_tag {
@@ -59,10 +59,10 @@ typedef struct workq_tag {
 #define WORKQ_VALID  0xdec1992
 
 extern int workq_init(
-              workq_t *wq,
-              int     threads,        /* maximum threads */
-              void   *(*engine)(void *)   /* engine routine */
-                    );
+             workq_t *wq,
+             int     threads,        /* maximum threads */
+             void   *(*engine)(void *)   /* engine routine */
+                   );
 extern int workq_destroy(workq_t *wq);
 extern int workq_add(workq_t *wq, void *element, workq_ele_t **work_item, int priority);
 extern int workq_remove(workq_t *wq, workq_ele_t *work_item);
index ab909549d46ff3f708c233e46641190dde8ec0d0..cd6e846d1717073bc4ed17ebb50c9dfd1e1c0af0 100644 (file)
@@ -2,7 +2,7 @@
  *  Routines to acquire and release a device for read/write
  *
  *   Kern Sibbald, August MMII
- *                           
+ *
  *   Version $Id$
  */
 /*
@@ -75,7 +75,7 @@ void free_dcr(DCR *dcr)
 }
 
 
-/********************************************************************* 
+/*********************************************************************
  * Acquire device for reading. We permit (for the moment)
  *  only one reader.  We read the Volume label from the block and
  *  leave the block pointers just after the label.
@@ -93,7 +93,7 @@ DCR *acquire_device_for_read(JCR *jcr)
    int i;
    DCR *dcr = jcr->dcr;
    DEVICE *dev;
-   
+
    /* Called for each volume */
    if (!dcr) {
       dcr = new_dcr(jcr, jcr->device->dev);
@@ -109,12 +109,12 @@ DCR *acquire_device_for_read(JCR *jcr)
 
    init_dev_wait_timers(dev);
    if (dev_state(dev, ST_READ) || dev->num_writers > 0) {
-      Jmsg2(jcr, M_FATAL, 0, _("Device %s is busy. Job %d canceled.\n"), 
+      Jmsg2(jcr, M_FATAL, 0, _("Device %s is busy. Job %d canceled.\n"),
            dev_name(dev), jcr->JobId);
       goto get_out;
    }
 
-   tape_previously_mounted = dev_state(dev, ST_READ) || 
+   tape_previously_mounted = dev_state(dev, ST_READ) ||
                             dev_state(dev, ST_APPEND) ||
                             dev_state(dev, ST_LABEL);
    tape_initially_mounted = tape_previously_mounted;
@@ -134,25 +134,25 @@ DCR *acquire_device_for_read(JCR *jcr)
    for (i=0; i<5; i++) {
       dcr->dev->state &= ~ST_LABEL;          /* force reread of label */
       if (job_canceled(jcr)) {
-         Mmsg1(dev->errmsg, _("Job %d canceled.\n"), jcr->JobId);
+        Mmsg1(dev->errmsg, _("Job %d canceled.\n"), jcr->JobId);
         goto get_out;                /* error return */
       }
       /*
        * This code ensures that the device is ready for
        * reading. If it is a file, it opens it.
-       * If it is a tape, it checks the volume name 
+       * If it is a tape, it checks the volume name
        */
       for ( ; !(dev->state & ST_OPENED); ) {
-         Dmsg1(120, "bstored: open vol=%s\n", dcr->VolumeName);
+        Dmsg1(120, "bstored: open vol=%s\n", dcr->VolumeName);
         if (open_dev(dev, dcr->VolumeName, OPEN_READ_ONLY) < 0) {
            if (dev->dev_errno == EIO) {   /* no tape loaded */
               goto default_path;
            }
-            Jmsg(jcr, M_FATAL, 0, _("Open device %s volume %s failed, ERR=%s\n"), 
+           Jmsg(jcr, M_FATAL, 0, _("Open device %s volume %s failed, ERR=%s\n"),
                dev_name(dev), dcr->VolumeName, strerror_dev(dev));
            goto get_out;
         }
-         Dmsg1(129, "open_dev %s OK\n", dev_name(dev));
+        Dmsg1(129, "open_dev %s OK\n", dev_name(dev));
       }
       /****FIXME***** do not reread label if ioctl() says we are
        *  correctly possitioned.  Possibly have way user can turn
@@ -171,7 +171,7 @@ DCR *acquire_device_for_read(JCR *jcr)
          *  error messages when nothing is mounted.
          */
         if (tape_previously_mounted) {
-            Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);                         
+           Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
         }
         goto default_path;
       case VOL_NAME_ERROR:
@@ -181,18 +181,18 @@ DCR *acquire_device_for_read(JCR *jcr)
         }
         /* Fall through */
       default:
-         Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
+        Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
 default_path:
         tape_previously_mounted = true;
-         Dmsg0(200, "dir_get_volume_info\n");
-        if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_READ)) { 
-            Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg);
+        Dmsg0(200, "dir_get_volume_info\n");
+        if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_READ)) {
+           Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg);
         }
         /* Call autochanger only once unless ask_sysop called */
         if (try_autochanger) {
            int stat;
-            Dmsg2(200, "calling autoload Vol=%s Slot=%d\n",
-              dcr->VolumeName, dcr->VolCatInfo.Slot);                         
+           Dmsg2(200, "calling autoload Vol=%s Slot=%d\n",
+              dcr->VolumeName, dcr->VolCatInfo.Slot);
            stat = autoload_device(dcr, 0, NULL);
            if (stat > 0) {
               try_autochanger = false;
@@ -200,7 +200,7 @@ default_path:
            }
         }
         /* Mount a specific volume and no other */
-         Dmsg0(200, "calling dir_ask_sysop\n");
+        Dmsg0(200, "calling dir_ask_sysop\n");
         if (!dir_ask_sysop_to_mount_volume(dcr)) {
            goto get_out;             /* error return */
         }
@@ -223,7 +223,7 @@ default_path:
       dcr->VolumeName, dev_name(dev));
 
 get_out:
-   P(dev->mutex); 
+   P(dev->mutex);
    unblock_device(dev);
    V(dev->mutex);
    if (!vol_ok) {
@@ -240,7 +240,7 @@ get_out:
  *  Returns: NULL if failed for any reason
  *          dev if successful (may change if new dev opened)
  *  This routine must be single threaded because we may create
- *   multiple devices (for files), thus we have our own mutex 
+ *   multiple devices (for files), thus we have our own mutex
  *   on top of the device mutex.
  */
 DCR *acquire_device_for_append(JCR *jcr)
@@ -261,13 +261,13 @@ DCR *acquire_device_for_append(JCR *jcr)
    unlock_device(dev);
    P(mutex);                        /* lock all devices */
    Dmsg1(190, "acquire_append device is %s\n", dev_is_tape(dev)?"tape":"disk");
-            
+
    if (dev_state(dev, ST_APPEND)) {
       Dmsg0(190, "device already in append.\n");
-      /* 
-       * Device already in append mode  
+      /*
+       * Device already in append mode
        *
-       * Check if we have the right Volume mounted   
+       * Check if we have the right Volume mounted
        *   OK if current volume info OK
        *   OK if next volume matches current volume
        *   otherwise mount desired volume obtained from
@@ -277,7 +277,7 @@ DCR *acquire_device_for_append(JCR *jcr)
       if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE) &&
          !(dir_find_next_appendable_volume(dcr) &&
            strcmp(dev->VolHdr.VolName, dcr->VolumeName) == 0)) { /* wrong tape mounted */
-         Dmsg0(190, "Wrong tape mounted.\n");
+        Dmsg0(190, "Wrong tape mounted.\n");
         if (dev->num_writers != 0) {
            DEVICE *d = ((DEVRES *)dev->device)->dev;
            uint32_t open_vols = 0;
@@ -290,7 +290,7 @@ DCR *acquire_device_for_append(JCR *jcr)
               d->next = dev->next;
               dev->next = d;
               /* Release old device */
-              P(dev->mutex); 
+              P(dev->mutex);
               unblock_device(dev);
               V(dev->mutex);
               free_dcr(dcr);         /* release dcr pointing to old dev */
@@ -301,38 +301,38 @@ DCR *acquire_device_for_append(JCR *jcr)
               block_device(dev, BST_DOING_ACQUIRE);
               unlock_device(dev);
            } else {
-               Jmsg(jcr, M_FATAL, 0, _("Device %s is busy writing on another Volume.\n"), dev_name(dev));
+              Jmsg(jcr, M_FATAL, 0, _("Device %s is busy writing on another Volume.\n"), dev_name(dev));
               goto get_out;
            }
         }
         /* Wrong tape mounted, release it, then fall through to get correct one */
-         Dmsg0(190, "Wrong tape mounted, release and try mount.\n");
+        Dmsg0(190, "Wrong tape mounted, release and try mount.\n");
         release = true;
         do_mount = true;
       } else {
-        /*       
-         * At this point, the correct tape is already mounted, so 
+        /*
+         * At this point, the correct tape is already mounted, so
          *   we do not need to do mount_next_write_volume(), unless
          *   we need to recycle the tape.
          */
-          recycle = strcmp(dcr->VolCatInfo.VolCatStatus, "Recycle") == 0;
-          Dmsg1(190, "Correct tape mounted. recycle=%d\n", recycle);
+         recycle = strcmp(dcr->VolCatInfo.VolCatStatus, "Recycle") == 0;
+         Dmsg1(190, "Correct tape mounted. recycle=%d\n", recycle);
          if (recycle && dev->num_writers != 0) {
-             Jmsg(jcr, M_FATAL, 0, _("Cannot recycle volume \"%s\""
-                  " because it is in use by another job.\n"));
+            Jmsg(jcr, M_FATAL, 0, _("Cannot recycle volume \"%s\""
+                 " because it is in use by another job.\n"));
             goto get_out;
          }
          if (dev->num_writers == 0) {
             memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
          }
        }
-   } else { 
+   } else {
       /* Not already in append mode, so mount the device */
       Dmsg0(190, "Not in append mode, try mount.\n");
       if (dev_state(dev, ST_READ)) {
-         Jmsg(jcr, M_FATAL, 0, _("Device %s is busy reading.\n"), dev_name(dev));
+        Jmsg(jcr, M_FATAL, 0, _("Device %s is busy reading.\n"), dev_name(dev));
         goto get_out;
-      } 
+      }
       ASSERT(dev->num_writers == 0);
       do_mount = true;
    }
@@ -344,8 +344,8 @@ DCR *acquire_device_for_append(JCR *jcr)
       P(mutex);                      /* re-lock */
       if (!mounted) {
         if (!job_canceled(jcr)) {
-            /* Reduce "noise" -- don't print if job canceled */
-            Jmsg(jcr, M_FATAL, 0, _("Could not ready device \"%s\" for append.\n"),
+           /* Reduce "noise" -- don't print if job canceled */
+           Jmsg(jcr, M_FATAL, 0, _("Could not ready device \"%s\" for append.\n"),
               dev_name(dev));
         }
         goto get_out;
@@ -368,7 +368,7 @@ get_out:
    free_dcr(dcr);
    dcr = NULL;
 ok_out:
-   P(dev->mutex); 
+   P(dev->mutex);
    unblock_device(dev);
    V(dev->mutex);
    V(mutex);                         /* unlock other threads */
@@ -383,7 +383,7 @@ ok_out:
 bool release_device(JCR *jcr)
 {
    DCR *dcr = jcr->dcr;
-   DEVICE *dev = dcr->dev;   
+   DEVICE *dev = dcr->dev;
    lock_device(dev);
    Dmsg1(100, "release_device device is %s\n", dev_is_tape(dev)?"tape":"disk");
    if (dev_state(dev, ST_READ)) {
@@ -398,9 +398,9 @@ bool release_device(JCR *jcr)
       dev->num_writers--;
       Dmsg1(100, "There are %d writers in release_device\n", dev->num_writers);
       if (dev_state(dev, ST_LABEL)) {
-         Dmsg0(100, "dir_create_jobmedia_record. Release\n");
+        Dmsg0(100, "dir_create_jobmedia_record. Release\n");
         if (!dir_create_jobmedia_record(dcr)) {
-            Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
+           Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
               dcr->VolCatInfo.VolCatName, jcr->Job);
         }
         /* If no more writers, write an EOF */
@@ -410,7 +410,7 @@ bool release_device(JCR *jcr)
         dev->VolCatInfo.VolCatFiles = dev->file;   /* set number of files */
         dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs */
         /* Note! do volume update before close, which zaps VolCatInfo */
-         Dmsg0(100, "dir_update_vol_info. Release0\n");
+        Dmsg0(100, "dir_update_vol_info. Release0\n");
         dir_update_volume_info(dcr, false); /* send Volume info to Director */
       }
 
@@ -419,7 +419,7 @@ bool release_device(JCR *jcr)
         close_dev(dev);
       }
    } else {
-      Jmsg2(jcr, M_FATAL, 0, _("BAD ERROR: release_device %s, Volume \"%s\" not in use.\n"), 
+      Jmsg2(jcr, M_FATAL, 0, _("BAD ERROR: release_device %s, Volume \"%s\" not in use.\n"),
            dev_name(dev), NPRT(dcr->VolumeName));
       Jmsg2(jcr, M_ERROR, 0, _("num_writers=%d state=%x\n"), dev->num_writers, dev->state);
    }
@@ -435,7 +435,7 @@ bool release_device(JCR *jcr)
       bpipe = open_bpipe(alert, 0, "r");
       if (bpipe) {
         while (fgets(line, sizeof(line), bpipe->rfd)) {
-            Jmsg(jcr, M_ALERT, 0, _("Alert: %s"), line);
+           Jmsg(jcr, M_ALERT, 0, _("Alert: %s"), line);
         }
         status = close_bpipe(bpipe);
       } else {
@@ -443,7 +443,7 @@ bool release_device(JCR *jcr)
       }
       if (status != 0) {
         berrno be;
-         Jmsg(jcr, M_ALERT, 0, _("3997 Bad alert command: %s: ERR=%s.\n"),
+        Jmsg(jcr, M_ALERT, 0, _("3997 Bad alert command: %s: ERR=%s.\n"),
              alert, be.strerror(status));
       }
 
index 648d44cab08fb8a5c2520d63e6d37d180efad404..97edb1b97c92edac712c91f56934af0f1f57705e 100644 (file)
@@ -33,11 +33,11 @@ static char OK_data[]    = "3000 OK data\n";
 
 /* Forward referenced functions */
 
-/* 
- *  Append Data sent from File daemon  
+/*
+ *  Append Data sent from File daemon
  *
  */
-bool do_append_data(JCR *jcr) 
+bool do_append_data(JCR *jcr)
 {
    int32_t n;
    int32_t file_index, stream, last_file_index;
@@ -47,7 +47,7 @@ bool do_append_data(JCR *jcr)
    DEVICE *dev;
    DEV_RECORD rec;
    DCR *dcr;
-   
+
    Dmsg0(10, "Start append data.\n");
 
    ds = fd_sock;
@@ -58,7 +58,7 @@ bool do_append_data(JCR *jcr)
       return false;
    }
 
-   /* 
+   /*
     * Acquire output device for writing.  Note, after acquiring a
     *  device, we MUST release it, which is done at the end of this
     *  subroutine.
@@ -104,9 +104,9 @@ bool do_append_data(JCR *jcr)
       ok = false;
    }
 
-   /* 
+   /*
     * Get Data from File daemon, write to device.  To clarify what is
-    *  going on here.  We expect:        
+    *  going on here.  We expect:
     *    - A stream header
     *    - Multiple records of data
     *    - EOD record
@@ -115,10 +115,10 @@ bool do_append_data(JCR *jcr)
     *   none of the stream header is written to tape.
     *   The Multiple records of data, contain first the Attributes,
     *   then after another stream header, the file data, then
-    *   after another stream header, the MD5 data if any.  
+    *   after another stream header, the MD5 data if any.
     *
     *  So we get the (stream header, data, EOD) three time for each
-    *  file. 1. for the Attributes, 2. for the file data if any, 
+    *  file. 1. for the Attributes, 2. for the file data if any,
     *  and 3. for the MD5 if any.
     */
    dcr->VolFirstIndex = dcr->VolLastIndex = 0;
@@ -136,16 +136,16 @@ bool do_append_data(JCR *jcr)
         if (n == BNET_SIGNAL && ds->msglen == BNET_EOD) {
            break;                    /* end of data */
         }
-         Jmsg1(jcr, M_FATAL, 0, _("Error reading data header from FD. ERR=%s\n"),
+        Jmsg1(jcr, M_FATAL, 0, _("Error reading data header from FD. ERR=%s\n"),
               bnet_strerror(ds));
         ok = false;
         break;
       }
-       
-      /* 
+
+      /*
        * This hand scanning is a bit more complicated than a simple
        *   sscanf, but it allows us to handle any size integer up to
-       *   int64_t without worrying about whether %d, %ld, %lld, or %q 
+       *   int64_t without worrying about whether %d, %ld, %lld, or %q
        *   is the correct format for each different architecture.
        * It is a real pity that sscanf() is not portable.
        */
@@ -158,7 +158,7 @@ bool do_append_data(JCR *jcr)
         p++;
       }
       if (!B_ISSPACE(*p) || !B_ISDIGIT(*(p+1))) {
-         Jmsg1(jcr, M_FATAL, 0, _("Malformed data header from FD: %s\n"), ds->msg);
+        Jmsg1(jcr, M_FATAL, 0, _("Malformed data header from FD: %s\n"), ds->msg);
         ok = false;
         break;
       }
@@ -168,7 +168,7 @@ bool do_append_data(JCR *jcr)
 
       if (!(file_index > 0 && (file_index == last_file_index ||
          file_index == last_file_index + 1))) {
-         Jmsg0(jcr, M_FATAL, 0, _("File index from FD not positive or sequential\n"));
+        Jmsg0(jcr, M_FATAL, 0, _("File index from FD not positive or sequential\n"));
         ok = false;
         break;
       }
@@ -176,7 +176,7 @@ bool do_append_data(JCR *jcr)
         jcr->JobFiles = file_index;
         last_file_index = file_index;
       }
-      
+
       /* Read data stream from the File daemon.
        *  The data stream is just raw bytes
        */
@@ -188,42 +188,42 @@ bool do_append_data(JCR *jcr)
         rec.data_len = ds->msglen;
         rec.data = ds->msg;            /* use message buffer */
 
-         Dmsg4(850, "before writ_rec FI=%d SessId=%d Strm=%s len=%d\n",
-           rec.FileIndex, rec.VolSessionId, stream_to_ascii(rec.Stream,rec.FileIndex), 
+        Dmsg4(850, "before writ_rec FI=%d SessId=%d Strm=%s len=%d\n",
+           rec.FileIndex, rec.VolSessionId, stream_to_ascii(rec.Stream,rec.FileIndex),
            rec.data_len);
-         
+
         while (!write_record_to_block(dcr->block, &rec)) {
-            Dmsg2(850, "!write_record_to_block data_len=%d rem=%d\n", rec.data_len,
+           Dmsg2(850, "!write_record_to_block data_len=%d rem=%d\n", rec.data_len,
                       rec.remainder);
            if (!write_block_to_device(dcr)) {
-               Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
+              Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
                  dev_name(dev), strerror_dev(dev));
-               Jmsg(jcr, M_FATAL, 0, _("Fatal device error: ERR=%s\n"),
+              Jmsg(jcr, M_FATAL, 0, _("Fatal device error: ERR=%s\n"),
                     strerror_dev(dev));
               ok = false;
               break;
            }
         }
         if (!ok) {
-            Dmsg0(400, "Not OK\n");
+           Dmsg0(400, "Not OK\n");
            break;
         }
         jcr->JobBytes += rec.data_len;   /* increment bytes this job */
-         Dmsg4(850, "write_record FI=%s SessId=%d Strm=%s len=%d\n",
-           FI_to_ascii(rec.FileIndex), rec.VolSessionId, 
+        Dmsg4(850, "write_record FI=%s SessId=%d Strm=%s len=%d\n",
+           FI_to_ascii(rec.FileIndex), rec.VolSessionId,
            stream_to_ascii(rec.Stream, rec.FileIndex), rec.data_len);
 
         /* Send attributes and MD5 to Director for Catalog */
         if (stream == STREAM_UNIX_ATTRIBUTES    || stream == STREAM_MD5_SIGNATURE ||
-            stream == STREAM_UNIX_ATTRIBUTES_EX || stream == STREAM_SHA1_SIGNATURE) { 
+            stream == STREAM_UNIX_ATTRIBUTES_EX || stream == STREAM_SHA1_SIGNATURE) {
            if (!jcr->no_attributes) {
               if (are_attributes_spooled(jcr)) {
                  jcr->dir_bsock->spool = true;
               }
-               Dmsg0(850, "Send attributes to dir.\n");
+              Dmsg0(850, "Send attributes to dir.\n");
               if (!dir_update_file_attributes(dcr, &rec)) {
                  jcr->dir_bsock->spool = false;
-                  Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"),
+                 Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"),
                     bnet_strerror(jcr->dir_bsock));
                  ok = false;
                  break;
@@ -231,12 +231,12 @@ bool do_append_data(JCR *jcr)
               jcr->dir_bsock->spool = false;
            }
         }
-         Dmsg0(350, "Enter bnet_get\n");
+        Dmsg0(350, "Enter bnet_get\n");
       }
       Dmsg1(350, "End read loop with FD. Stat=%d\n", n);
       if (is_bnet_error(ds)) {
-         Dmsg1(350, "Network read error from FD. ERR=%s\n", bnet_strerror(ds));
-         Jmsg1(jcr, M_FATAL, 0, _("Network error on data channel. ERR=%s\n"),
+        Dmsg1(350, "Network read error from FD. ERR=%s\n", bnet_strerror(ds));
+        Jmsg1(jcr, M_FATAL, 0, _("Network error on data channel. ERR=%s\n"),
               bnet_strerror(ds));
         ok = false;
         break;
@@ -257,18 +257,18 @@ bool do_append_data(JCR *jcr)
     */
    if (ok || dev_can_write(dev)) {
       if (!write_session_label(dcr, EOS_LABEL)) {
-         Jmsg1(jcr, M_FATAL, 0, _("Error writting end session label. ERR=%s\n"),
+        Jmsg1(jcr, M_FATAL, 0, _("Error writting end session label. ERR=%s\n"),
               strerror_dev(dev));
         set_jcr_job_status(jcr, JS_ErrorTerminated);
         ok = false;
       }
       if (dev->VolCatInfo.VolCatName[0] == 0) {
-         Dmsg0(000, "NULL Volume name. This shouldn't happen!!!\n");
+        Dmsg0(000, "NULL Volume name. This shouldn't happen!!!\n");
       }
       Dmsg0(90, "back from write_end_session_label()\n");
       /* Flush out final partial block of this session */
       if (!write_block_to_device(dcr)) {
-         Dmsg0(100, _("Set ok=FALSE after write_block_to_device.\n"));
+        Dmsg0(100, _("Set ok=FALSE after write_block_to_device.\n"));
         set_jcr_job_status(jcr, JS_ErrorTerminated);
         ok = false;
       }
index ca19abed6123e91b6f1129bd6c1258d034831c33..b77c5e1e25b9d10205fefe4386041a4573b22e1f 100644 (file)
@@ -36,8 +36,8 @@ static char Update_media[] = "CatReq Job=%s UpdateMedia VolName=%s"
    " VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%s VolMounts=%u"
    " VolErrors=%u VolWrites=%u MaxVolBytes=%s EndTime=%d VolStatus=%s"
    " Slot=%d relabel=%d InChanger=%d VolReadTime=%s VolWriteTime=%s\n";
-static char Create_job_media[] = "CatReq Job=%s CreateJobMedia" 
-   " FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u" 
+static char Create_job_media[] = "CatReq Job=%s CreateJobMedia"
+   " FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u"
    " StartBlock=%u EndBlock=%u\n";
 static char FileAttributes[] = "UpdCat Job=%s FileAttributes ";
 static char Job_status[]     = "3012 Job %s jobstatus %d\n";
@@ -69,7 +69,7 @@ bool dir_send_job_status(JCR *jcr)
  *   dir_get_volume_info()
  * and
  *   dir_find_next_appendable_volume()
- * 
+ *
  *  Returns: true  on success and vol info in dcr->VolCatInfo
  *          false on failure
  */
@@ -89,7 +89,7 @@ static bool do_get_volume_info(DCR *dcr)
     }
     memset(&vol, 0, sizeof(vol));
     Dmsg1(300, "Get vol info=%s", dir->msg);
-    n = sscanf(dir->msg, OK_media, vol.VolCatName, 
+    n = sscanf(dir->msg, OK_media, vol.VolCatName,
               &vol.VolCatJobs, &vol.VolCatFiles,
               &vol.VolCatBlocks, &vol.VolCatBytes,
               &vol.VolCatMounts, &vol.VolCatErrors,
@@ -107,8 +107,8 @@ static bool do_get_volume_info(DCR *dcr)
     unbash_spaces(vol.VolCatName);
     bstrncpy(dcr->VolumeName, vol.VolCatName, sizeof(dcr->VolumeName));
     memcpy(&dcr->VolCatInfo, &vol, sizeof(dcr->VolCatInfo));
-    
-    Dmsg2(300, "do_reqest_vol_info got slot=%d Volume=%s\n", 
+
+    Dmsg2(300, "do_reqest_vol_info got slot=%d Volume=%s\n",
          vol.Slot, vol.VolCatName);
     return true;
 }
@@ -132,7 +132,7 @@ bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing)
     bstrncpy(dcr->VolCatInfo.VolCatName, dcr->VolumeName, sizeof(dcr->VolCatInfo.VolCatName));
     Dmsg1(300, "dir_get_volume_info=%s\n", dcr->VolCatInfo.VolCatName);
     bash_spaces(dcr->VolCatInfo.VolCatName);
-    bnet_fsend(dir, Get_Vol_Info, jcr->Job, dcr->VolCatInfo.VolCatName, 
+    bnet_fsend(dir, Get_Vol_Info, jcr->Job, dcr->VolCatInfo.VolCatName,
        writing==GET_VOL_INFO_FOR_WRITE?1:0);
     return do_get_volume_info(dcr);
 }
@@ -162,12 +162,12 @@ bool dir_find_next_appendable_volume(DCR *dcr)
     for (int vol_index=1;  vol_index < 3; vol_index++) {
        bnet_fsend(dir, Find_media, jcr->Job, vol_index);
        if (do_get_volume_info(dcr)) {
-          Dmsg2(300, "JobId=%d got possible Vol=%s\n", jcr->JobId, dcr->VolumeName);
+         Dmsg2(300, "JobId=%d got possible Vol=%s\n", jcr->JobId, dcr->VolumeName);
          bool found = false;
-         /* 
-          * Walk through all jobs and see if the volume is   
+         /*
+          * Walk through all jobs and see if the volume is
           *  already mounted. If so, try a different one.
-          * This would be better done by walking through  
+          * This would be better done by walking through
           *  all the devices.
           */
          lock_jcr_chain();
@@ -176,10 +176,10 @@ bool dir_find_next_appendable_volume(DCR *dcr)
                free_locked_jcr(njcr);
                continue;             /* us */
             }
-             Dmsg2(300, "Compare to JobId=%d using Vol=%s\n", njcr->JobId, njcr->dcr->VolumeName);
+            Dmsg2(300, "Compare to JobId=%d using Vol=%s\n", njcr->JobId, njcr->dcr->VolumeName);
             if (njcr->dcr && strcmp(dcr->VolumeName, njcr->dcr->VolumeName) == 0) {
                found = true;
-                Dmsg1(400, "Vol in use by JobId=%u\n", njcr->JobId);
+               Dmsg1(400, "Vol in use by JobId=%u\n", njcr->JobId);
                free_locked_jcr(njcr);
                break;
             }
@@ -187,23 +187,23 @@ bool dir_find_next_appendable_volume(DCR *dcr)
          }
          unlock_jcr_chain();
          if (!found) {
-             Dmsg0(400, "dir_find_next_appendable_volume return true\n");
+            Dmsg0(400, "dir_find_next_appendable_volume return true\n");
             return true;             /* Got good Volume */
          }
        } else {
-          Dmsg0(200, "No volume info, return false\n");
+         Dmsg0(200, "No volume info, return false\n");
          return false;
        }
     }
     Dmsg0(400, "dir_find_next_appendable_volume return true\n");
-    return true; 
+    return true;
 }
 
-    
+
 /*
  * After writing a Volume, send the updated statistics
  * back to the director. The information comes from the
- * dev record.    
+ * dev record.
  */
 bool dir_update_volume_info(DCR *dcr, bool label)
 {
@@ -234,14 +234,14 @@ bool dir_update_volume_info(DCR *dcr, bool label)
    }
    bash_spaces(vol->VolCatName);
    InChanger = vol->InChanger;
-   bnet_fsend(dir, Update_media, jcr->Job, 
+   bnet_fsend(dir, Update_media, jcr->Job,
       vol->VolCatName, vol->VolCatJobs, vol->VolCatFiles,
       vol->VolCatBlocks, edit_uint64(vol->VolCatBytes, ed1),
       vol->VolCatMounts, vol->VolCatErrors,
-      vol->VolCatWrites, edit_uint64(vol->VolCatMaxBytes, ed2), 
+      vol->VolCatWrites, edit_uint64(vol->VolCatMaxBytes, ed2),
       LastWritten, vol->VolCatStatus, vol->Slot, label,
       InChanger,                     /* bool in structure */
-      edit_uint64(vol->VolReadTime, ed3), 
+      edit_uint64(vol->VolReadTime, ed3),
       edit_uint64(vol->VolWriteTime, ed4) );
 
    Dmsg1(300, "update_volume_info(): %s", dir->msg);
@@ -271,14 +271,14 @@ bool dir_create_jobmedia_record(DCR *dcr)
    }
 
    dcr->WroteVol = false;
-   bnet_fsend(dir, Create_job_media, jcr->Job, 
+   bnet_fsend(dir, Create_job_media, jcr->Job,
       dcr->VolFirstIndex, dcr->VolLastIndex,
       dcr->StartFile, dcr->EndFile,
       dcr->StartBlock, dcr->EndBlock);
    Dmsg1(400, "create_jobmedia(): %s", dir->msg);
    if (bnet_recv(dir) <= 0) {
       Dmsg0(190, "create_jobmedia error bnet_recv\n");
-      Jmsg(jcr, M_FATAL, 0, _("Error creating JobMedia record: ERR=%s\n"), 
+      Jmsg(jcr, M_FATAL, 0, _("Error creating JobMedia record: ERR=%s\n"),
           bnet_strerror(dir));
       return false;
    }
@@ -292,7 +292,7 @@ bool dir_create_jobmedia_record(DCR *dcr)
 }
 
 
-/* 
+/*
  * Update File Attribute data
  */
 bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec)
@@ -302,7 +302,7 @@ bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec)
    ser_declare;
 
    dir->msglen = sprintf(dir->msg, FileAttributes, jcr->Job);
-   dir->msg = check_pool_memory_size(dir->msg, dir->msglen + 
+   dir->msg = check_pool_memory_size(dir->msg, dir->msglen +
                sizeof(DEV_RECORD) + rec->data_len);
    ser_begin(dir->msg + dir->msglen, 0);
    ser_uint32(rec->VolSessionId);
@@ -347,9 +347,9 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr)
    for ( ;; ) {
       if (job_canceled(jcr)) {
         Mmsg(dev->errmsg,
-              _("Job %s canceled while waiting for mount on Storage Device \"%s\".\n"), 
+             _("Job %s canceled while waiting for mount on Storage Device \"%s\".\n"),
              jcr->Job, dcr->dev_name);
-         Jmsg(jcr, M_INFO, 0, "%s", dev->errmsg);
+        Jmsg(jcr, M_INFO, 0, "%s", dev->errmsg);
         return false;
       }
       /* First pass, we *know* there are no appendable volumes, so no need to call */
@@ -362,10 +362,10 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr)
          *   Slot for an autochanger, otherwise wait
          *   for the operator to mount the media.
          */
-        if (!unmounted && ((dcr->VolumeName[0] && !dev_cap(dev, CAP_REM) && 
+        if (!unmounted && ((dcr->VolumeName[0] && !dev_cap(dev, CAP_REM) &&
                dev_cap(dev, CAP_LABEL)) ||
                 (dcr->VolumeName[0] && dcr->VolCatInfo.Slot))) {
-            Dmsg0(400, "Return 1 from mount without wait.\n");
+           Dmsg0(400, "Return 1 from mount without wait.\n");
            return true;
         }
         jstat = JS_WaitMount;
@@ -374,20 +374,20 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr)
 "Please mount Volume \"%s\" on Storage Device \"%s\" for Job %s\n"
 "Use \"mount\" command to release Job.\n"),
              dcr->VolumeName, dcr->dev_name, jcr->Job);
-            Dmsg3(400, "Mount %s on %s for Job %s\n",
+           Dmsg3(400, "Mount %s on %s for Job %s\n",
                  dcr->VolumeName, dcr->dev_name, jcr->Job);
         }
       } else {
         jstat = JS_WaitMedia;
         if (!dev->poll) {
            Jmsg(jcr, M_MOUNT, 0, _(
-"Job %s waiting. Cannot find any appendable volumes.\n\
-Please use the \"label\"  command to create a new Volume for:\n\
-    Storage:      %s\n\
-    Media type:   %s\n\
-    Pool:         %s\n"),
-              jcr->Job, 
-              dcr->dev_name, 
+"Job %s waiting. Cannot find any appendable volumes.\n"
+"Please use the \"label\"  command to create a new Volume for:\n"
+"    Storage:      %s\n"
+"    Media type:   %s\n"
+"    Pool:         %s\n"),
+              jcr->Job,
+              dcr->dev_name,
               dcr->media_type,
               dcr->pool_name);
         }
@@ -399,30 +399,30 @@ Please use the \"label\"  command to create a new Volume for:\n\
 
       stat = wait_for_sysop(dcr);
       if (dev->poll) {
-         Dmsg1(400, "Poll timeout in create append vol on device %s\n", dev_name(dev));
+        Dmsg1(400, "Poll timeout in create append vol on device %s\n", dev_name(dev));
         continue;
       }
 
       if (stat == ETIMEDOUT) {
         if (!double_dev_wait_time(dev)) {
-            Mmsg(dev->errmsg, _("Max time exceeded waiting to mount Storage Device \"%s\" for Job %s\n"), 
+           Mmsg(dev->errmsg, _("Max time exceeded waiting to mount Storage Device \"%s\" for Job %s\n"),
               dev_name(dev), jcr->Job);
-            Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
-            Dmsg1(400, "Gave up waiting on device %s\n", dev_name(dev));
+           Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
+           Dmsg1(400, "Gave up waiting on device %s\n", dev_name(dev));
            return false;             /* exceeded maximum waits */
         }
         continue;
       }
       if (stat == EINVAL) {
         berrno be;
-         Mmsg2(dev->errmsg, _("pthread error in mount_next_volume stat=%d ERR=%s\n"),
+        Mmsg2(dev->errmsg, _("pthread error in mount_next_volume stat=%d ERR=%s\n"),
               stat, be.strerror(stat));
-         Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
+        Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
         return false;
       }
       if (stat != 0) {
         berrno be;
-         Jmsg(jcr, M_WARNING, 0, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), stat,
+        Jmsg(jcr, M_WARNING, 0, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), stat,
            be.strerror(stat));
       }
       Dmsg1(400, "Someone woke me for device %s\n", dev_name(dev));
@@ -431,12 +431,12 @@ Please use the \"label\"  command to create a new Volume for:\n\
       if (dcr->VolumeName[0] == 0 && !job_canceled(jcr) &&
          !dir_find_next_appendable_volume(dcr)) {
         Jmsg(jcr, M_MOUNT, 0, _(
-"Someone woke me up, but I cannot find any appendable\n\
-volumes for Job=%s.\n"), jcr->Job);
+"Someone woke me up, but I cannot find any appendable\n"
+"volumes for Job=%s.\n"), jcr->Job);
         /* Restart wait counters after user interaction */
         init_dev_wait_timers(dev);
         continue;
-      }       
+      }
       unmounted = (dev->dev_blocked == BST_UNMOUNTED) ||
                  (dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP);
       if (unmounted) {
@@ -444,7 +444,7 @@ volumes for Job=%s.\n"), jcr->Job);
       }
 
       /*
-       * Device mounted, we have a volume, break and return   
+       * Device mounted, we have a volume, break and return
        */
       break;
    }
@@ -481,16 +481,16 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
    ASSERT(dev->dev_blocked);
    for ( ;; ) {
       if (job_canceled(jcr)) {
-         Mmsg(dev->errmsg, _("Job %s canceled while waiting for mount on Storage Device \"%s\".\n"), 
+        Mmsg(dev->errmsg, _("Job %s canceled while waiting for mount on Storage Device \"%s\".\n"),
              jcr->Job, dcr->dev_name);
         return false;
       }
 
       if (!dev->poll) {
-         msg = _("Please mount");
-         Jmsg(jcr, M_MOUNT, 0, _("%s Volume \"%s\" on Storage Device \"%s\" for Job %s\n"),
+        msg = _("Please mount");
+        Jmsg(jcr, M_MOUNT, 0, _("%s Volume \"%s\" on Storage Device \"%s\" for Job %s\n"),
              msg, dcr->VolumeName, dcr->dev_name, jcr->Job);
-         Dmsg3(400, "Mount \"%s\" on device \"%s\" for Job %s\n",
+        Dmsg3(400, "Mount \"%s\" on device \"%s\" for Job %s\n",
               dcr->VolumeName, dcr->dev_name, jcr->Job);
       }
 
@@ -499,31 +499,31 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
 
       stat = wait_for_sysop(dcr);    ;    /* wait on device */
       if (dev->poll) {
-         Dmsg1(400, "Poll timeout in mount vol on device %s\n", dev_name(dev));
-         Dmsg1(400, "Blocked=%s\n", edit_blocked_reason(dev));
+        Dmsg1(400, "Poll timeout in mount vol on device %s\n", dev_name(dev));
+        Dmsg1(400, "Blocked=%s\n", edit_blocked_reason(dev));
         return true;
       }
 
       if (stat == ETIMEDOUT) {
         if (!double_dev_wait_time(dev)) {
-            Mmsg(dev->errmsg, _("Max time exceeded waiting to mount Storage Device \"%s\" for Job %s\n"), 
+           Mmsg(dev->errmsg, _("Max time exceeded waiting to mount Storage Device \"%s\" for Job %s\n"),
               dev_name(dev), jcr->Job);
-            Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
-            Dmsg1(400, "Gave up waiting on device %s\n", dev_name(dev));
+           Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
+           Dmsg1(400, "Gave up waiting on device %s\n", dev_name(dev));
            return false;             /* exceeded maximum waits */
         }
         continue;
       }
       if (stat == EINVAL) {
         berrno be;
-         Mmsg2(dev->errmsg, _("pthread error in mount_volume stat=%d ERR=%s\n"),
+        Mmsg2(dev->errmsg, _("pthread error in mount_volume stat=%d ERR=%s\n"),
               stat, be.strerror(stat));
-         Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
+        Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
         return false;
       }
       if (stat != 0) {
         berrno be;
-         Jmsg(jcr, M_FATAL, 0, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), stat,
+        Jmsg(jcr, M_FATAL, 0, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), stat,
            be.strerror(stat));
       }
       Dmsg1(400, "Someone woke me for device %s\n", dev_name(dev));
@@ -550,7 +550,7 @@ static int wait_for_sysop(DCR *dcr)
    bool unmounted;
    DEVICE *dev = dcr->dev;
    JCR *jcr = dcr->jcr;
-   
+
    P(dev->mutex);
    unmounted = (dev->dev_blocked == BST_UNMOUNTED) ||
                (dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP);
@@ -567,7 +567,7 @@ static int wait_for_sysop(DCR *dcr)
       add_wait = me->heartbeat_interval;
    }
    /* If the user did not unmount the tape and we are polling, ensure
-    *  that we poll at the correct interval. 
+    *  that we poll at the correct interval.
     */
    if (!unmounted && dev->vol_poll_interval && add_wait > dev->vol_poll_interval) {
       add_wait = dev->vol_poll_interval;
@@ -600,7 +600,7 @@ static int wait_for_sysop(DCR *dcr)
            /* send heartbeats */
            if (jcr->file_bsock) {
               bnet_sig(jcr->file_bsock, BNET_HEARTBEAT);
-               Dmsg0(400, "Send heartbeat to FD.\n");
+              Dmsg0(400, "Send heartbeat to FD.\n");
            }
            if (jcr->dir_bsock) {
               bnet_sig(jcr->dir_bsock, BNET_HEARTBEAT);
@@ -619,13 +619,13 @@ static int wait_for_sysop(DCR *dcr)
         break;                    /* on error return */
       }
       if (dev->rem_wait_sec <= 0) {  /* on exceeding wait time return */
-         Dmsg0(400, "Exceed wait time.\n");
+        Dmsg0(400, "Exceed wait time.\n");
         break;
       }
-      
-      if (!unmounted && dev->vol_poll_interval &&      
+
+      if (!unmounted && dev->vol_poll_interval &&
          (now - first_start >= dev->vol_poll_interval)) {
-         Dmsg1(400, "In wait blocked=%s\n", edit_blocked_reason(dev));
+        Dmsg1(400, "In wait blocked=%s\n", edit_blocked_reason(dev));
         dev->poll = true;            /* returning a poll event */
         break;
       }
index 2216a6ba30256a34b3f4dae9155829209634ac31..6754738888fa1cd91deea9528ff9f1b83226d7bf 100644 (file)
@@ -4,7 +4,7 @@
  *   Kern Sibbald, October 2000
  *
  *   Version $Id$
- * 
+ *
  */
 /*
    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
@@ -25,7 +25,7 @@
    MA 02111-1307, USA.
 
  */
-  
+
 #include "bacula.h"
 #include "stored.h"
 
@@ -33,7 +33,7 @@ static char Dir_sorry[] = "3999 No go\n";
 static char OK_hello[]  = "3000 OK Hello\n";
 
 
-/********************************************************************* 
+/*********************************************************************
  *
  *
  */
@@ -50,9 +50,9 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
       return 0;
    }
    if (bs->msglen < 25 || bs->msglen > 200) {
-      Dmsg2(50, _("Bad Hello command from Director at %s. Len=%d.\n"), 
+      Dmsg2(50, _("Bad Hello command from Director at %s. Len=%d.\n"),
            bs->who, bs->msglen);
-      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s. Len=%d.\n"), 
+      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s. Len=%d.\n"),
            bs->who, bs->msglen);
       return 0;
    }
@@ -61,9 +61,9 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
 
    if (sscanf(bs->msg, "Hello Director %127s calling\n", dirname) != 1) {
       bs->msg[100] = 0;
-      Dmsg2(50, _("Bad Hello command from Director at %s: %s\n"), 
+      Dmsg2(50, _("Bad Hello command from Director at %s: %s\n"),
            bs->who, bs->msg);
-      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"), 
+      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"),
            bs->who, bs->msg);
       return 0;
    }
@@ -76,10 +76,10 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    }
    UnlockRes();
    if (!director) {
-      Dmsg2(50, _("Connection from unknown Director %s at %s rejected.\n"), 
+      Dmsg2(50, _("Connection from unknown Director %s at %s rejected.\n"),
            dirname, bs->who);
-      Emsg2(M_FATAL, 0, _("Connection from unknown Director %s at %s rejected.\n"   
-       "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"), 
+      Emsg2(M_FATAL, 0, _("Connection from unknown Director %s at %s rejected.\n"
+       "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"),
            dirname, bs->who);
       free_pool_memory(dirname);
       return 0;
@@ -91,14 +91,14 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    if (auth) {
       get_auth = cram_md5_get_auth(bs, director->password, ssl_need);
       if (!get_auth) {
-         Dmsg1(50, "cram_get_auth failed with %s\n", bs->who);
+        Dmsg1(50, "cram_get_auth failed with %s\n", bs->who);
       }
    } else {
       Dmsg1(50, "cram_auth failed with %s\n", bs->who);
    }
    if (!auth || !get_auth) {
       stop_bsock_timer(tid);
-      Emsg0(M_FATAL, 0, _("Incorrect password given by Director.\n"   
+      Emsg0(M_FATAL, 0, _("Incorrect password given by Director.\n"
        "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"));
       free_pool_memory(dirname);
       return 0;
@@ -112,7 +112,7 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
 /*
  * Inititiate the message channel with the Director.
  * He has made a connection to our server.
- * 
+ *
  * Basic tasks done here:
  *   Assume the Hello message is already in the input
  *     buffer. We then authenticate him.
@@ -147,7 +147,7 @@ int authenticate_filed(JCR *jcr)
    if (auth) {
        get_auth = cram_md5_get_auth(fd, jcr->sd_auth_key, ssl_need);
        if (!get_auth) {
-          Dmsg1(50, "cram-get-auth failed with %s\n", fd->who);
+         Dmsg1(50, "cram-get-auth failed with %s\n", fd->who);
        }
    } else {
       Dmsg1(50, "cram-auth failed with %s\n", fd->who);
index a9811c43e81d96c5c4f4f7485d81999269a6a740..9eee899b6c566b7ae706f38c8218c5a078b7b2af 100644 (file)
@@ -40,12 +40,12 @@ static int get_autochanger_loaded_slot(JCR *jcr);
  *  On success this routine loads the indicated tape, but the
  *  label is not read, so it must be verified.
  *
- *  Note if dir is not NULL, it is the console requesting the 
+ *  Note if dir is not NULL, it is the console requesting the
  *   autoload for labeling, so we respond directly to the
  *   dir bsock.
  *
  *  Returns: 1 on success
- *          0 on failure (no changer available) 
+ *          0 on failure (no changer available)
  *         -1 on error on autochanger
  */
 int autoload_device(DCR *dcr, int writing, BSOCK *dir)
@@ -55,7 +55,7 @@ int autoload_device(DCR *dcr, int writing, BSOCK *dir)
    int slot;
    int drive = jcr->device->drive_index;
    int rtn_stat = -1;                /* error status */
-     
+
    slot = dcr->VolCatInfo.InChanger ? dcr->VolCatInfo.Slot : 0;
    /*
     * Handle autoloaders here. If we cannot autoload it, we
@@ -76,57 +76,57 @@ int autoload_device(DCR *dcr, int writing, BSOCK *dir)
    if (slot > 0 && jcr->device->changer_name && jcr->device->changer_command) {
       uint32_t timeout = jcr->device->max_changer_wait;
       POOLMEM *changer;
-      int loaded, status;     
+      int loaded, status;
 
       changer = get_pool_memory(PM_FNAME);
 
       loaded = get_autochanger_loaded_slot(jcr);
 
       /* If tape we want is not loaded, load it. */
-      if (loaded != slot) { 
+      if (loaded != slot) {
         offline_or_rewind_dev(dev);
         /* We are going to load a new tape, so close the device */
         force_close_dev(dev);
         if (loaded != 0 && loaded != -1) {        /* must unload drive */
-            Dmsg0(400, "Doing changer unload.\n");
-           Jmsg(jcr, M_INFO, 0, 
-                 _("3303 Issuing autochanger \"unload slot %d, drive %d\" command.\n"),
+           Dmsg0(400, "Doing changer unload.\n");
+           Jmsg(jcr, M_INFO, 0,
+                _("3303 Issuing autochanger \"unload slot %d, drive %d\" command.\n"),
                 loaded, drive);
            dcr->VolCatInfo.Slot = loaded;   /* slot to be unloaded */
-           changer = edit_device_codes(jcr, changer, 
-                        jcr->device->changer_command, "unload");
+           changer = edit_device_codes(jcr, changer,
+                       jcr->device->changer_command, "unload");
            status = run_program(changer, timeout, NULL);
            if (status != 0) {
               berrno be;
               be.set_errno(status);
-               Jmsg(jcr, M_INFO, 0, _("3992 Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n"),
+              Jmsg(jcr, M_INFO, 0, _("3992 Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n"),
                    slot, drive, be.strerror());
            }
 
-            Dmsg1(400, "unload status=%d\n", status);
+           Dmsg1(400, "unload status=%d\n", status);
         }
         /*
-         * Load the desired cassette    
+         * Load the desired cassette
          */
-         Dmsg1(400, "Doing changer load slot %d\n", slot);
-        Jmsg(jcr, M_INFO, 0, 
-              _("3304 Issuing autochanger \"load slot %d, drive %d\" command.\n"), 
+        Dmsg1(400, "Doing changer load slot %d\n", slot);
+        Jmsg(jcr, M_INFO, 0,
+             _("3304 Issuing autochanger \"load slot %d, drive %d\" command.\n"),
              slot, drive);
         dcr->VolCatInfo.Slot = slot;    /* slot to be loaded */
-        changer = edit_device_codes(jcr, changer, 
-                      jcr->device->changer_command, "load");
+        changer = edit_device_codes(jcr, changer,
+                     jcr->device->changer_command, "load");
         status = run_program(changer, timeout, NULL);
         if (status == 0) {
-            Jmsg(jcr, M_INFO, 0, _("3305 Autochanger \"load slot %d, drive %d\", status is OK.\n"),
+           Jmsg(jcr, M_INFO, 0, _("3305 Autochanger \"load slot %d, drive %d\", status is OK.\n"),
                    slot, drive);
         } else {
           berrno be;
           be.set_errno(status);
-            Jmsg(jcr, M_INFO, 0, _("3992 Bad autochanger \"load slot %d, drive %d\": ERR=%s.\n"),
+           Jmsg(jcr, M_INFO, 0, _("3992 Bad autochanger \"load slot %d, drive %d\": ERR=%s.\n"),
                    slot, drive, be.strerror());
         }
-         Dmsg2(400, "load slot %d status=%d\n", slot, status);
-      } else { 
+        Dmsg2(400, "load slot %d status=%d\n", slot, status);
+      } else {
         status = 0;                  /* we got what we want */
       }
       free_pool_memory(changer);
@@ -153,7 +153,7 @@ static int get_autochanger_loaded_slot(JCR *jcr)
    /* Find out what is loaded, zero means device is unloaded */
    Jmsg(jcr, M_INFO, 0, _("3301 Issuing autochanger \"loaded drive %d\" command.\n"),
        drive);
-   changer = edit_device_codes(jcr, changer, jcr->device->changer_command, 
+   changer = edit_device_codes(jcr, changer, jcr->device->changer_command,
                 "loaded");
    status = run_program(changer, timeout, results);
    Dmsg3(50, "run_prog: %s stat=%d result=%s\n", changer, status, results);
@@ -169,7 +169,7 @@ static int get_autochanger_loaded_slot(JCR *jcr)
    } else {
       berrno be;
       be.set_errno(status);
-      Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"loaded drive %d\" command: ERR=%s.\n"), 
+      Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"loaded drive %d\" command: ERR=%s.\n"),
           drive, be.strerror());
       loaded = -1;             /* force unload */
    }
@@ -179,7 +179,7 @@ static int get_autochanger_loaded_slot(JCR *jcr)
 }
 
 /*
- * The Volume is not in the correct slot, so mark this 
+ * The Volume is not in the correct slot, so mark this
  *   Volume as not being in the Changer.
  */
 void invalid_slot_in_catalog(DCR *dcr)
@@ -225,14 +225,14 @@ bool autochanger_list(DCR *dcr, BSOCK *dir)
    loaded = get_autochanger_loaded_slot(jcr);
    if (loaded > 0) {
       bnet_fsend(dir, _("3305 Issuing autochanger \"unload slot %d\" command.\n"), loaded);
-      slot = dcr->VolCatInfo.Slot; 
+      slot = dcr->VolCatInfo.Slot;
       dcr->VolCatInfo.Slot = loaded;
       changer = edit_device_codes(jcr, changer, jcr->device->changer_command, "unload");
       int stat = run_program(changer, timeout, NULL);
       if (stat != 0) {
         berrno be;
         be.set_errno(stat);
-         Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d\" command: ERR=%s.\n"), 
+        Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d\" command: ERR=%s.\n"),
              loaded, be.strerror());
       }
       dcr->VolCatInfo.Slot = slot;
@@ -248,7 +248,7 @@ bool autochanger_list(DCR *dcr, BSOCK *dir)
       return false;
    }
    /* Get output from changer */
-   while (fgets(dir->msg, len, bpipe->rfd)) { 
+   while (fgets(dir->msg, len, bpipe->rfd)) {
       dir->msglen = strlen(dir->msg);
       bnet_send(dir);
    }
@@ -270,7 +270,7 @@ bool autochanger_list(DCR *dcr, BSOCK *dir)
  *  %% = %
  *  %a = archive device name
  *  %c = changer device name
- *  %d = changer drive index       
+ *  %d = changer drive index
  *  %f = Client's name
  *  %j = Job name
  *  %o = command
@@ -281,10 +281,10 @@ bool autochanger_list(DCR *dcr, BSOCK *dir)
  *
  *  omsg = edited output message
  *  imsg = input string containing edit codes (%x)
- *  cmd = command string (load, unload, ...) 
+ *  cmd = command string (load, unload, ...)
  *
  */
-char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd) 
+char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd)
 {
    const char *p;
    const char *str;
@@ -295,42 +295,42 @@ char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd)
    for (p=imsg; *p; p++) {
       if (*p == '%') {
         switch (*++p) {
-         case '%':
-            str = "%";
+        case '%':
+           str = "%";
            break;
-         case 'a':
+        case 'a':
            str = dev_name(jcr->device->dev);
            break;
-         case 'c':
+        case 'c':
            str = NPRT(jcr->device->changer_name);
            break;
-         case 'd':
-            sprintf(add, "%d", jcr->device->dev->drive_index);
+        case 'd':
+           sprintf(add, "%d", jcr->device->dev->drive_index);
            str = add;
            break;
-         case 'o':
+        case 'o':
            str = NPRT(cmd);
            break;
-         case 's':
-            sprintf(add, "%d", jcr->dcr->VolCatInfo.Slot - 1);
+        case 's':
+           sprintf(add, "%d", jcr->dcr->VolCatInfo.Slot - 1);
            str = add;
            break;
-         case 'S':
-            sprintf(add, "%d", jcr->dcr->VolCatInfo.Slot);
+        case 'S':
+           sprintf(add, "%d", jcr->dcr->VolCatInfo.Slot);
            str = add;
            break;
-         case 'j':                    /* Job name */
+        case 'j':                    /* Job name */
            str = jcr->Job;
            break;
-         case 'v':
+        case 'v':
            str = NPRT(jcr->dcr->VolumeName);
            break;
-         case 'f':
+        case 'f':
            str = NPRT(jcr->client_name);
            break;
 
         default:
-            add[0] = '%';
+           add[0] = '%';
            add[1] = *p;
            add[2] = 0;
            str = add;
index 430ade486db28825bdcddeec368cb7e32dbfbac0..9b51f9f3690ff9db4132a69fbf0e489381c425e9 100644 (file)
@@ -95,7 +95,7 @@ int main (int argc, char *argv[])
       case 'd':                    /* debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0)
-           debug_level = 1; 
+           debug_level = 1;
         break;
 
       case 'i':                    /* input Volume name */
@@ -110,7 +110,7 @@ int main (int argc, char *argv[])
         ignore_label_errors = true;
         forge_on = true;
         break;
-  
+
       case 'v':
         verbose++;
         break;
@@ -123,7 +123,7 @@ int main (int argc, char *argv[])
       default:
         usage();
 
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -148,7 +148,7 @@ int main (int argc, char *argv[])
    }
    in_jcr->ignore_label_errors = ignore_label_errors;
    in_dev = in_jcr->dcr->dev;
-   if (!in_dev) { 
+   if (!in_dev) {
       exit(1);
    }
 
@@ -158,8 +158,8 @@ int main (int argc, char *argv[])
       exit(1);
    }
    out_dev = out_jcr->dcr->dev;
-   if (!out_dev) { 
-      exit(1);     
+   if (!out_dev) {
+      exit(1);
    }
    /* For we must now acquire the device for writing */
    lock_device(out_dev);
@@ -189,7 +189,7 @@ int main (int argc, char *argv[])
    term_dev(out_dev);
    return 0;
 }
-  
+
 
 /*
  * read_records() calls back here for each record it gets
@@ -198,11 +198,11 @@ static bool record_cb(DCR *in_dcr, DEV_RECORD *rec)
 {
    if (list_records) {
       Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
-           rec->VolSessionId, rec->VolSessionTime, rec->FileIndex, 
+           rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
            rec->Stream, rec->data_len);
    }
-   /* 
-    * Check for Start or End of Session Record 
+   /*
+    * Check for Start or End of Session Record
     *
     */
    if (rec->FileIndex < 0) {
@@ -212,37 +212,37 @@ static bool record_cb(DCR *in_dcr, DEV_RECORD *rec)
       }
       switch (rec->FileIndex) {
       case PRE_LABEL:
-         Pmsg0(000, "Volume is prelabeled. This volume cannot be copied.\n");
+        Pmsg0(000, "Volume is prelabeled. This volume cannot be copied.\n");
         return false;
       case VOL_LABEL:
-         Pmsg0(000, "Volume label not copied.\n");
+        Pmsg0(000, "Volume label not copied.\n");
         return true;
       case SOS_LABEL:
         jobs++;
         break;
       case EOS_LABEL:
         while (!write_record_to_block(out_block, rec)) {
-            Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
+           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)) {
-               Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
+              Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
                  dev_name(out_dev), strerror_dev(out_dev));
-               Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
+              Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
                     strerror_dev(out_dev));
            }
         }
         if (!write_block_to_device(out_jcr->dcr)) {
-            Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
+           Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
               dev_name(out_dev), strerror_dev(out_dev));
-            Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
+           Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
                  strerror_dev(out_dev));
         }
         break;
       case EOM_LABEL:
-         Pmsg0(000, "EOM label not copied.\n");
+        Pmsg0(000, "EOM label not copied.\n");
         return true;
       case EOT_LABEL:             /* end of all tapes */
-         Pmsg0(000, "EOT label not copied.\n");
+        Pmsg0(000, "EOT label not copied.\n");
         return true;
       default:
         break;
@@ -255,9 +255,9 @@ static bool record_cb(DCR *in_dcr, DEV_RECORD *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)) {
-         Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
+        Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
            dev_name(out_dev), strerror_dev(out_dev));
-         Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
+        Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
               strerror_dev(out_dev));
         break;
       }
@@ -281,6 +281,6 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
    DEVICE *dev = dcr->dev;
    fprintf(stderr, "Mount Volume \"%s\" on device %s and press return when ready: ",
       dcr->VolumeName, dev_name(dev));
-   getchar();  
+   getchar();
    return true;
 }
index fb67da69ae724324b30a3474c2b9b3ef6c1e6100..8747e02e9131064e78688bea7e53ad18fb8a0c96 100644 (file)
@@ -88,7 +88,7 @@ static void usage()
 
 int main (int argc, char *argv[])
 {
-   int ch;   
+   int ch;
    FILE *fd;
    char line[1000];
    int got_inc = FALSE;
@@ -118,34 +118,34 @@ int main (int argc, char *argv[])
       case 'd':                    /* debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0)
-           debug_level = 1; 
+           debug_level = 1;
         break;
 
       case 'e':                    /* exclude list */
-         if ((fd = fopen(optarg, "r")) == NULL) {
+        if ((fd = fopen(optarg, "r")) == NULL) {
            berrno be;
-            Pmsg2(0, "Could not open exclude file: %s, ERR=%s\n",
+           Pmsg2(0, "Could not open exclude file: %s, ERR=%s\n",
               optarg, be.strerror());
            exit(1);
         }
         while (fgets(line, sizeof(line), fd) != NULL) {
            strip_trailing_junk(line);
-            Dmsg1(900, "add_exclude %s\n", line);
+           Dmsg1(900, "add_exclude %s\n", line);
            add_fname_to_exclude_list(ff, line);
         }
         fclose(fd);
         break;
 
       case 'i':                    /* include list */
-         if ((fd = fopen(optarg, "r")) == NULL) {
+        if ((fd = fopen(optarg, "r")) == NULL) {
            berrno be;
-            Pmsg2(0, "Could not open include file: %s, ERR=%s\n",
+           Pmsg2(0, "Could not open include file: %s, ERR=%s\n",
               optarg, be.strerror());
            exit(1);
         }
         while (fgets(line, sizeof(line), fd) != NULL) {
            strip_trailing_junk(line);
-            Dmsg1(900, "add_include %s\n", line);
+           Dmsg1(900, "add_include %s\n", line);
            add_fname_to_include_list(ff, 0, line);
         }
         fclose(fd);
@@ -236,7 +236,7 @@ static void do_extract(char *devname)
 
    read_records(dcr, record_cb, mount_next_read_volume);
    /* If output file is still open, it was the last one in the
-    * archive since we just hit an end of file, so close the file. 
+    * archive since we just hit an end of file, so close the file.
     */
    if (is_bopen(&bfd)) {
       set_attributes(jcr, attr, &bfd);
@@ -266,34 +266,34 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
 
    switch (rec->Stream) {
    case STREAM_UNIX_ATTRIBUTES:
-   case STREAM_UNIX_ATTRIBUTES_EX:  
+   case STREAM_UNIX_ATTRIBUTES_EX:
 
       /* If extracting, it was from previous stream, so
        * close the output file.
        */
       if (extract) {
         if (!is_bopen(&bfd)) {
-            Emsg0(M_ERROR, 0, _("Logic error output file should be open but is not.\n"));
+           Emsg0(M_ERROR, 0, _("Logic error output file should be open but is not.\n"));
         }
         set_attributes(jcr, attr, &bfd);
         extract = false;
       }
 
       if (!unpack_attributes_record(jcr, rec->Stream, rec->data, attr)) {
-         Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
+        Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
       }
 
       if (attr->file_index != rec->FileIndex) {
-         Emsg2(M_ERROR_TERM, 0, _("Record header file index %ld not equal record index %ld\n"),
+        Emsg2(M_ERROR_TERM, 0, _("Record header file index %ld not equal record index %ld\n"),
            rec->FileIndex, attr->file_index);
       }
-        
+
       if (file_is_included(ff, attr->fname) && !file_is_excluded(ff, attr->fname)) {
 
         attr->data_stream = decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
         if (!is_stream_supported(attr->data_stream)) {
            if (!non_support_data++) {
-               Jmsg(jcr, M_ERROR, 0, _("%s stream not supported on this Client.\n"),
+              Jmsg(jcr, M_ERROR, 0, _("%s stream not supported on this Client.\n"),
                  stream_to_ascii(attr->data_stream));
            }
            extract = false;
@@ -304,7 +304,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
         build_attr_output_fnames(jcr, attr);
 
         extract = false;
-        stat = create_file(jcr, attr, &bfd, REPLACE_ALWAYS);   
+        stat = create_file(jcr, attr, &bfd, REPLACE_ALWAYS);
         switch (stat) {
         case CF_ERROR:
         case CF_SKIP:
@@ -321,14 +321,14 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
            num_files++;
            fileAddr = 0;
            break;
-        }  
+        }
       }
       break;
 
    /* Data stream and extracting */
    case STREAM_FILE_DATA:
    case STREAM_SPARSE_DATA:
-   case STREAM_WIN32_DATA:  
+   case STREAM_WIN32_DATA:
 
       if (extract) {
         if (rec->Stream == STREAM_SPARSE_DATA) {
@@ -342,7 +342,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
               fileAddr = faddr;
               if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) {
                  berrno be;
-                  Emsg2(M_ERROR_TERM, 0, _("Seek error on %s: %s\n"), 
+                 Emsg2(M_ERROR_TERM, 0, _("Seek error on %s: %s\n"),
                     attr->ofname, be.strerror());
               }
            }
@@ -351,10 +351,10 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
            wsize = rec->data_len;
         }
         total += wsize;
-         Dmsg2(8, "Write %u bytes, total=%u\n", wsize, total);
+        Dmsg2(8, "Write %u bytes, total=%u\n", wsize, total);
         if ((uint32_t)bwrite(&bfd, wbuf, wsize) != wsize) {
            berrno be;
-            Emsg2(M_ERROR_TERM, 0, _("Write error on %s: %s\n"), 
+           Emsg2(M_ERROR_TERM, 0, _("Write error on %s: %s\n"),
               attr->ofname, be.strerror());
         }
         fileAddr += wsize;
@@ -363,8 +363,8 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
 
    /* GZIP data stream */
    case STREAM_GZIP_DATA:
-   case STREAM_SPARSE_GZIP_DATA: 
-   case STREAM_WIN32_GZIP_DATA:  
+   case STREAM_SPARSE_GZIP_DATA:
+   case STREAM_WIN32_GZIP_DATA:
 #ifdef HAVE_LIBZ
       if (extract) {
         uLong compress_len;
@@ -382,7 +382,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
               fileAddr = faddr;
               if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) {
                  berrno be;
-                  Emsg3(M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"), 
+                 Emsg3(M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
                     edit_uint64(fileAddr, ec1), attr->ofname, be.strerror());
                  extract = false;
                  return true;
@@ -393,30 +393,30 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
            wsize = rec->data_len;
         }
         compress_len = compress_buf_size;
-        if ((stat=uncompress((Bytef *)compress_buf, &compress_len, 
+        if ((stat=uncompress((Bytef *)compress_buf, &compress_len,
               (const Bytef *)wbuf, (uLong)wsize) != Z_OK)) {
-            Emsg1(M_ERROR, 0, _("Uncompression error. ERR=%d\n"), stat);
+           Emsg1(M_ERROR, 0, _("Uncompression error. ERR=%d\n"), stat);
            extract = false;
            return true;
         }
 
-         Dmsg2(100, "Write uncompressed %d bytes, total before write=%d\n", compress_len, total);
+        Dmsg2(100, "Write uncompressed %d bytes, total before write=%d\n", compress_len, total);
         if ((uLongf)bwrite(&bfd, compress_buf, (size_t)compress_len) != compress_len) {
            berrno be;
-            Pmsg0(0, "===Write error===\n");
-            Emsg2(M_ERROR, 0, _("Write error on %s: %s\n"), 
+           Pmsg0(0, "===Write error===\n");
+           Emsg2(M_ERROR, 0, _("Write error on %s: %s\n"),
               attr->ofname, be.strerror());
            extract = false;
            return true;
         }
         total += compress_len;
         fileAddr += compress_len;
-         Dmsg2(100, "Compress len=%d uncompressed=%d\n", rec->data_len,
+        Dmsg2(100, "Compress len=%d uncompressed=%d\n", rec->data_len,
            compress_len);
       }
 #else
       if (extract) {
-         Emsg0(M_ERROR, 0, "GZIP data stream found, but GZIP not configured!\n");
+        Emsg0(M_ERROR, 0, "GZIP data stream found, but GZIP not configured!\n");
         extract = false;
         return true;
       }
@@ -430,7 +430,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
    case STREAM_PROGRAM_NAMES:
    case STREAM_PROGRAM_DATA:
       if (!prog_name_msg) {
-         Pmsg0(000, "Got Program Name or Data Stream. Ignored.\n");
+        Pmsg0(000, "Got Program Name or Data Stream. Ignored.\n");
         prog_name_msg++;
       }
       break;
@@ -439,15 +439,15 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       /* If extracting, wierd stream (not 1 or 2), close output file anyway */
       if (extract) {
         if (!is_bopen(&bfd)) {
-            Emsg0(M_ERROR, 0, "Logic error output file should be open but is not.\n");
+           Emsg0(M_ERROR, 0, "Logic error output file should be open but is not.\n");
         }
         set_attributes(jcr, attr, &bfd);
         extract = false;
       }
-      Jmsg(jcr, M_ERROR, 0, _("Unknown stream=%d ignored. This shouldn't happen!\n"), 
+      Jmsg(jcr, M_ERROR, 0, _("Unknown stream=%d ignored. This shouldn't happen!\n"),
         rec->Stream);
       break;
-      
+
    } /* end switch */
    return true;
 }
@@ -467,6 +467,6 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
    DEVICE *dev = dcr->dev;
    fprintf(stderr, "Mount Volume \"%s\" on device %s and press return when ready: ",
       dcr->VolumeName, dev_name(dev));
-   getchar();  
+   getchar();
    return true;
 }
index d7288b0126852f522acde0fe15bae0b4fda5e2f6..4ad745f3fa10517843944826f72c7d4bff245c2b 100644 (file)
@@ -77,11 +77,11 @@ void dump_block(DEV_BLOCK *b, const char *msg)
 
    BlockCheckSum = bcrc32((uint8_t *)b->buf+BLKHDR_CS_LENGTH,
                         block_len-BLKHDR_CS_LENGTH);
-   Pmsg6(000, "Dump block %s %x: size=%d BlkNum=%d\n\
-               Hdrcksum=%x cksum=%x\n",
+   Pmsg6(000, "Dump block %s %x: size=%d BlkNum=%d\n"
+"               Hdrcksum=%x cksum=%x\n",
       msg, b, block_len, BlockNumber, CheckSum, BlockCheckSum);
    p = b->buf + bhl;
-   while (p < (b->buf + block_len+WRITE_RECHDR_LENGTH)) { 
+   while (p < (b->buf + block_len+WRITE_RECHDR_LENGTH)) {
       unser_begin(p, WRITE_RECHDR_LENGTH);
       if (rhl == RECHDR1_LENGTH) {
         unser_uint32(VolSessionId);
@@ -91,14 +91,14 @@ void dump_block(DEV_BLOCK *b, const char *msg)
       unser_int32(Stream);
       unser_uint32(data_len);
       Pmsg6(000, "   Rec: VId=%u VT=%u FI=%s Strm=%s len=%d p=%x\n",
-          VolSessionId, VolSessionTime, FI_to_ascii(FileIndex), 
+          VolSessionId, VolSessionTime, FI_to_ascii(FileIndex),
           stream_to_ascii(Stream, FileIndex), data_len, p);
       p += data_len + rhl;
   }
 }
-    
+
 /*
- * Create a new block structure.                          
+ * Create a new block structure.
  * We pass device so that the block can inherit the
  * min and max block sizes.
  */
@@ -116,7 +116,7 @@ DEV_BLOCK *new_block(DEVICE *dev)
    }
    block->dev = dev;
    block->block_len = block->buf_len;  /* default block size */
-   block->buf = get_memory(block->buf_len); 
+   block->buf = get_memory(block->buf_len);
    empty_block(block);
    block->BlockVer = BLOCK_VER;       /* default write version */
    Dmsg1(350, "Returning new block=%x\n", block);
@@ -139,7 +139,7 @@ DEV_BLOCK *dup_block(DEV_BLOCK *eblock)
 }
 
 
-/* 
+/*
  * Only the first block checksum error was reported.
  *   If there are more, report it now.
  */
@@ -152,7 +152,7 @@ void print_block_read_errors(JCR *jcr, DEV_BLOCK *block)
 }
 
 /*
- * Free block 
+ * Free block
  */
 void free_block(DEV_BLOCK *block)
 {
@@ -183,7 +183,7 @@ void ser_block_header(DEV_BLOCK *block)
    ser_declare;
    uint32_t CheckSum = 0;
    uint32_t block_len = block->binbuf;
-   
+
    Dmsg1(390, "ser_block_header: block_len=%d\n", block_len);
    ser_begin(block->buf, BLKHDR2_LENGTH);
    ser_uint32(CheckSum);
@@ -196,7 +196,7 @@ void ser_block_header(DEV_BLOCK *block)
    }
 
    /* Checksum whole block except for the checksum */
-   CheckSum = bcrc32((uint8_t *)block->buf+BLKHDR_CS_LENGTH, 
+   CheckSum = bcrc32((uint8_t *)block->buf+BLKHDR_CS_LENGTH,
                 block_len-BLKHDR_CS_LENGTH);
    Dmsg1(390, "ser_bloc_header: checksum=%x\n", CheckSum);
    ser_begin(block->buf, BLKHDR2_LENGTH);
@@ -234,10 +234,10 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       block->bufp = block->buf + bhl;
       if (strncmp(Id, BLKHDR1_ID, BLKHDR_ID_LENGTH) != 0) {
         dev->dev_errno = EIO;
-         Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"),
+        Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"),
            dev->file, dev->block_num, BLKHDR1_ID, Id);
         if (block->read_errors == 0 || verbose >= 2) {
-            Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
+           Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
         }
         block->read_errors++;
         return false;
@@ -250,10 +250,10 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       block->bufp = block->buf + bhl;
       if (strncmp(Id, BLKHDR2_ID, BLKHDR_ID_LENGTH) != 0) {
         dev->dev_errno = EIO;
-         Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"),
+        Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"),
            dev->file, dev->block_num, BLKHDR2_ID, Id);
         if (block->read_errors == 0 || verbose >= 2) {
-            Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
+           Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
         }
         block->read_errors++;
         return false;
@@ -263,7 +263,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"),
          dev->file, dev->block_num, BLKHDR2_ID, Id);
       if (block->read_errors == 0 || verbose >= 2) {
-         Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
+        Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
       }
       block->read_errors++;
       unser_uint32(block->VolSessionId);
@@ -277,7 +277,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       Mmsg3(dev->errmsg,  _("Volume data error at %u:%u! Block length %u is insane (too large), probably due to a bad archive.\n"),
         dev->file, dev->block_num, block_len);
       if (block->read_errors == 0 || verbose >= 2) {
-         Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
+        Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
       }
       block->read_errors++;
       return false;
@@ -300,10 +300,10 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
                         block_len-BLKHDR_CS_LENGTH);
       if (BlockCheckSum != CheckSum) {
         dev->dev_errno = EIO;
-         Mmsg5(dev->errmsg, _("Volume data error at %u:%u! Block checksum mismatch in block %u: calc=%x blk=%x\n"), 
+        Mmsg5(dev->errmsg, _("Volume data error at %u:%u! Block checksum mismatch in block %u: calc=%x blk=%x\n"),
            dev->file, dev->block_num, (unsigned)BlockNumber, BlockCheckSum, CheckSum);
         if (block->read_errors == 0 || verbose >= 2) {
-            Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
+           Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
         }
         block->read_errors++;
         if (!forge_on) {
@@ -314,7 +314,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    return true;
 }
 
-/*  
+/*
  * Write a block to the device, with locking and unlocking
  *
  * Returns: true  on success
@@ -339,7 +339,7 @@ bool write_block_to_device(DCR *dcr)
    /*
     * If a new volume has been mounted since our last write
     *  Create a JobMedia record for the previous volume written,
-    *  and set new parameters to write this volume   
+    *  and set new parameters to write this volume
     * The same applies for if we are in a new file.
     */
    if (dcr->NewVol || dcr->NewFile) {
@@ -350,7 +350,7 @@ bool write_block_to_device(DCR *dcr)
       /* Create a jobmedia record for this job */
       if (!dir_create_jobmedia_record(dcr)) {
         dev->dev_errno = EIO;
-         Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
+        Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
            dcr->VolCatInfo.VolCatName, jcr->Job);
         set_new_volume_parameters(dcr);
         stat = false;
@@ -381,7 +381,7 @@ bail_out:
 }
 
 /*
- * Write a block to the device 
+ * Write a block to the device
  *
  *  Returns: true  on success or EOT
  *          false on hard error
@@ -419,7 +419,7 @@ bool write_block_to_dev(DCR *dcr)
       Dmsg0(100, "return write_block_to_dev no data to write\n");
       return true;
    }
-   /* 
+   /*
     * Clear to the end of the buffer if it is not full,
     *  and on tape devices, apply min and fixed blocking.
     */
@@ -445,7 +445,7 @@ bool write_block_to_dev(DCR *dcr)
       if (wlen-blen > 0) {
         memset(block->bufp, 0, wlen-blen); /* clear garbage */
       }
-   }  
+   }
 
    ser_block_header(block);
 
@@ -454,7 +454,7 @@ bool write_block_to_dev(DCR *dcr)
        ((dev->VolCatInfo.VolCatBytes + block->binbuf)) >= dev->max_volume_size;
    hit_max2 = (dev->VolCatInfo.VolCatMaxBytes > 0) &&
        ((dev->VolCatInfo.VolCatBytes + block->binbuf)) >= dev->VolCatInfo.VolCatMaxBytes;
-   if (hit_max1 || hit_max2) {  
+   if (hit_max1 || hit_max2) {
       char ed1[50];
       uint64_t max_cap;
       Dmsg0(10, "==== Output bytes Triggered medium max capacity.\n");
@@ -471,12 +471,12 @@ bool write_block_to_dev(DCR *dcr)
    }
 
    /* Limit maximum File size on volume to user specified value */
-   if ((dev->max_file_size > 0) && 
+   if ((dev->max_file_size > 0) &&
        (dev->file_size+block->binbuf) >= dev->max_file_size) {
       dev->file_size = 0;            /* reset file size */
 
       if (dev_state(dev, ST_TAPE) && weof_dev(dev, 1) != 0) {           /* write eof */
-         Dmsg0(190, "WEOF error in max file size.\n");
+        Dmsg0(190, "WEOF error in max file size.\n");
         terminate_writing_volume(dcr);
         dev->dev_errno = ENOSPC;
         return false;
@@ -484,9 +484,9 @@ bool write_block_to_dev(DCR *dcr)
 
       /* Create a JobMedia record so restore can seek */
       if (!dir_create_jobmedia_record(dcr)) {
-         Dmsg0(190, "Error from create_job_media.\n");
+        Dmsg0(190, "Error from create_job_media.\n");
         dev->dev_errno = EIO;
-          Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
+         Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
               dcr->VolCatInfo.VolCatName, jcr->Job);
          terminate_writing_volume(dcr);
          dev->dev_errno = EIO;
@@ -494,7 +494,7 @@ bool write_block_to_dev(DCR *dcr)
       }
       dev->VolCatInfo.VolCatFiles = dev->file;
       if (!dir_update_volume_info(dcr, false)) {
-         Dmsg0(190, "Error from update_vol_info.\n");
+        Dmsg0(190, "Error from update_vol_info.\n");
         terminate_writing_volume(dcr);
         dev->dev_errno = EIO;
         return false;
@@ -518,7 +518,7 @@ bool write_block_to_dev(DCR *dcr)
    }
 
    dev->VolCatInfo.VolCatWrites++;
-   Dmsg1(300, "Write block of %u bytes\n", wlen);      
+   Dmsg1(300, "Write block of %u bytes\n", wlen);
 #ifdef DEBUG_BLOCK_ZEROING
    uint32_t *bp = (uint32_t *)block->buf;
    if (bp[0] == 0 && bp[1] == 0 && bp[2] == 0 && block->buf[12] == 0) {
@@ -548,18 +548,18 @@ bool write_block_to_dev(DCR *dcr)
            dev->dev_errno = ENOSPC;        /* out of space */
         }
         if (dev->dev_errno != ENOSPC) {
-            Jmsg4(jcr, M_ERROR, 0, _("Write error at %u:%u on device %s. ERR=%s.\n"), 
+           Jmsg4(jcr, M_ERROR, 0, _("Write error at %u:%u on device %s. ERR=%s.\n"),
               dev->file, dev->block_num, dev->dev_name, be.strerror());
         }
       } else {
        dev->dev_errno = ENOSPC;            /* out of space */
-      }  
+      }
       if (dev->dev_errno == ENOSPC) {
-         Jmsg(jcr, M_INFO, 0, _("End of Volume \"%s\" at %u:%u on device %s. Write of %u bytes got %d.\n"), 
+        Jmsg(jcr, M_INFO, 0, _("End of Volume \"%s\" at %u:%u on device %s. Write of %u bytes got %d.\n"),
            dev->VolCatInfo.VolCatName,
            dev->file, dev->block_num, dev->dev_name, wlen, stat);
       }
-      Dmsg6(100, "=== Write error. size=%u rtn=%d dev_blk=%d blk_blk=%d errno=%d: ERR=%s\n", 
+      Dmsg6(100, "=== Write error. size=%u rtn=%d dev_blk=%d blk_blk=%d errno=%d: ERR=%s\n",
         wlen, stat, dev->block_num, block->BlockNumber, dev->dev_errno, strerror(dev->dev_errno));
 
       ok = terminate_writing_volume(dcr);
@@ -569,9 +569,9 @@ bool write_block_to_dev(DCR *dcr)
 
 #define CHECK_LAST_BLOCK
 #ifdef CHECK_LAST_BLOCK
-      /* 
+      /*
        * If the device is a tape and it supports backspace record,
-       *   we backspace over one or two eof marks depending on 
+       *   we backspace over one or two eof marks depending on
        *   how many we just wrote, then over the last record,
        *   then re-read it and verify that the block number is
        *   correct.
@@ -580,19 +580,19 @@ bool write_block_to_dev(DCR *dcr)
         /* Now back up over what we wrote and read the last block */
         if (!bsf_dev(dev, 1)) {
            ok = false;
-            Jmsg(jcr, M_ERROR, 0, _("Backspace file at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
+           Jmsg(jcr, M_ERROR, 0, _("Backspace file at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
         }
         if (ok && dev_cap(dev, CAP_TWOEOF) && !bsf_dev(dev, 1)) {
            ok = false;
-            Jmsg(jcr, M_ERROR, 0, _("Backspace file at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
+           Jmsg(jcr, M_ERROR, 0, _("Backspace file at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
         }
         /* Backspace over record */
         if (ok && !bsr_dev(dev, 1)) {
            ok = false;
-            Jmsg(jcr, M_ERROR, 0, _("Backspace record at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
+           Jmsg(jcr, M_ERROR, 0, _("Backspace record at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
            /*
             *  On FreeBSD systems, if the user got here, it is likely that his/her
-             *    tape drive is "frozen".  The correct thing to do is a 
+            *    tape drive is "frozen".  The correct thing to do is a
             *    rewind(), but if we do that, higher levels in cleaning up, will
             *    most likely write the EOS record over the beginning of the
             *    tape.  The rewind *is* done later in mount.c when another
@@ -605,10 +605,10 @@ bool write_block_to_dev(DCR *dcr)
            /* Note, this can destroy dev->errmsg */
            dcr->block = lblock;
            if (!read_block_from_dev(dcr, NO_BLOCK_NUMBER_CHECK)) {
-               Jmsg(jcr, M_ERROR, 0, _("Re-read last block at EOT failed. ERR=%s"), dev->errmsg);
+              Jmsg(jcr, M_ERROR, 0, _("Re-read last block at EOT failed. ERR=%s"), dev->errmsg);
            } else {
               if (lblock->BlockNumber+1 == block->BlockNumber) {
-                  Jmsg(jcr, M_INFO, 0, _("Re-read of last block succeeded.\n"));
+                 Jmsg(jcr, M_INFO, 0, _("Re-read of last block succeeded.\n"));
               } else {
                  Jmsg(jcr, M_ERROR, 0, _(
 "Re-read of last block failed. Last block=%u Current block=%u.\n"),
@@ -626,7 +626,7 @@ bool write_block_to_dev(DCR *dcr)
    /* We successfully wrote the block, now do housekeeping */
 
    dev->VolCatInfo.VolCatBytes += block->binbuf;
-   dev->VolCatInfo.VolCatBlocks++;   
+   dev->VolCatInfo.VolCatBlocks++;
    dev->EndBlock = dev->block_num;
    dev->EndFile  = dev->file;
    dev->block_num++;
@@ -675,7 +675,7 @@ static bool terminate_writing_volume(DCR *dcr)
    if (weof_dev(dev, 1) != 0) {        /* end the tape */
       dev->VolCatInfo.VolCatErrors++;
       Jmsg(dcr->jcr, M_ERROR, 0, "Error writing final EOF to tape. This tape may not be readable.\n"
-           "%s", dev->errmsg);
+          "%s", dev->errmsg);
       ok = false;
       Dmsg0(100, "WEOF error.\n");
    }
@@ -713,7 +713,7 @@ bail_out:
 }
 
 
-/*  
+/*
  * Read block with locking
  *
  */
@@ -770,7 +770,7 @@ reread:
 //     block->buf[12],block->buf[13],block->buf[14],block->buf[15]);
 
       if (retry == 1) {
-        dev->VolCatInfo.VolCatErrors++;   
+        dev->VolCatInfo.VolCatErrors++;
       }
    } while (stat == -1 && (errno == EINTR || errno == EIO) && retry++ < 11);
    if (stat < 0) {
@@ -778,7 +778,7 @@ reread:
       clrerror_dev(dev, -1);
       Dmsg1(200, "Read device got: ERR=%s\n", be.strerror());
       block->read_len = 0;
-      Mmsg4(dev->errmsg, _("Read error at file:blk %u:%u on device %s. ERR=%s.\n"), 
+      Mmsg4(dev->errmsg, _("Read error at file:blk %u:%u on device %s. ERR=%s.\n"),
         dev->file, dev->block_num, dev->dev_name, be.strerror());
       Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
       if (dev->state & ST_EOF) {  /* EOF just seen? */
@@ -789,7 +789,7 @@ reread:
    Dmsg1(200, "Read device got %d bytes\n", stat);
    if (stat == 0) {            /* Got EOF ! */
       dev->block_num = block->read_len = 0;
-      Mmsg3(dev->errmsg, _("Read zero bytes at %u:%u on device %s.\n"), 
+      Mmsg3(dev->errmsg, _("Read zero bytes at %u:%u on device %s.\n"),
         dev->file, dev->block_num, dev->dev_name);
       if (dev->state & ST_EOF) { /* EOF already read? */
         dev->state |= ST_EOT;  /* yes, 2 EOFs => EOT */
@@ -805,13 +805,13 @@ reread:
    block->read_len = stat;     /* save length read */
    if (block->read_len < BLKHDR2_LENGTH) {
       dev->dev_errno = EIO;
-      Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Very short block of %d bytes on device %s discarded.\n"), 
+      Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Very short block of %d bytes on device %s discarded.\n"),
         dev->file, dev->block_num, block->read_len, dev->dev_name);
       Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
       dev->state |= ST_SHORT;  /* set short block */
       block->read_len = block->binbuf = 0;
       return false;            /* return error */
-   }  
+   }
 
    BlockNumber = block->BlockNumber + 1;
    if (!unser_block_header(jcr, dev, block)) {
@@ -836,17 +836,17 @@ reread:
       Pmsg1(000, "%s", dev->errmsg);
       /* Attempt to reposition to re-read the block */
       if (dev->state & ST_TAPE) {
-         Dmsg0(200, "BSR for reread; block too big for buffer.\n");
+        Dmsg0(200, "BSR for reread; block too big for buffer.\n");
         if (!bsr_dev(dev, 1)) {
-            Jmsg(jcr, M_ERROR, 0, "%s", strerror_dev(dev));
+           Jmsg(jcr, M_ERROR, 0, "%s", strerror_dev(dev));
            block->read_len = 0;
            return false;
         }
       } else {
-         Dmsg0(200, "Seek to beginning of block for reread.\n");
+        Dmsg0(200, "Seek to beginning of block for reread.\n");
         off_t pos = lseek(dev->fd, (off_t)0, SEEK_CUR); /* get curr pos */
         pos -= block->read_len;
-        lseek(dev->fd, pos, SEEK_SET);   
+        lseek(dev->fd, pos, SEEK_SET);
         dev->file_addr = pos;
       }
       Mmsg1(dev->errmsg, _("Setting block buffer size to %u bytes.\n"), block->block_len);
@@ -864,20 +864,20 @@ reread:
 
    if (block->block_len > block->read_len) {
       dev->dev_errno = EIO;
-      Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Short block of %d bytes on device %s discarded.\n"), 
+      Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Short block of %d bytes on device %s discarded.\n"),
         dev->file, dev->block_num, block->read_len, dev->dev_name);
       Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
       dev->state |= ST_SHORT;  /* set short block */
       block->read_len = block->binbuf = 0;
       return false;            /* return error */
-   }  
+   }
 
    dev->state &= ~(ST_EOF|ST_SHORT); /* clear EOF and short block */
-   dev->VolCatInfo.VolCatReads++;   
+   dev->VolCatInfo.VolCatReads++;
    dev->VolCatInfo.VolCatRBytes += block->read_len;
 
    dev->VolCatInfo.VolCatBytes += block->block_len;
-   dev->VolCatInfo.VolCatBlocks++;   
+   dev->VolCatInfo.VolCatBlocks++;
    dev->EndBlock = dev->block_num;
    dev->EndFile  = dev->file;
    dev->block_num++;
@@ -912,7 +912,7 @@ reread:
    if (block->read_len > block->block_len && !(dev->state & ST_TAPE)) {
       off_t pos = lseek(dev->fd, (off_t)0, SEEK_CUR); /* get curr pos */
       pos -= (block->read_len - block->block_len);
-      lseek(dev->fd, pos, SEEK_SET);   
+      lseek(dev->fd, pos, SEEK_SET);
       Dmsg2(200, "Did lseek blk_size=%d rdlen=%d\n", block->block_len,
            block->read_len);
       dev->file_addr = pos;
index 6a35c81fd2120ebbaaa21ceefafe62a4122cb989..4df807342a2029fe65759f9e000196efa6281b9f 100644 (file)
@@ -63,7 +63,7 @@
  *  Note, when written, it is serialized.
 
    uint32_t CheckSum;
-   uint32_t block_len; 
+   uint32_t block_len;
    uint32_t BlockNumber;
    char     Id[BLKHDR_ID_LENGTH];
 
index df7e674867fe181d13454777efc4484eaf4fc54b..2563751ae6917a2b2a18da528ad9f5b3750e1423 100644 (file)
@@ -117,32 +117,32 @@ int main (int argc, char *argv[])
       case 'd':                    /* debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0)
-           debug_level = 1; 
+           debug_level = 1;
         break;
 
       case 'e':                    /* exclude list */
-         if ((fd = fopen(optarg, "r")) == NULL) {
-            Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"),
+        if ((fd = fopen(optarg, "r")) == NULL) {
+           Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"),
               optarg, strerror(errno));
            exit(1);
         }
         while (fgets(line, sizeof(line), fd) != NULL) {
            strip_trailing_junk(line);
-            Dmsg1(100, "add_exclude %s\n", line);
+           Dmsg1(100, "add_exclude %s\n", line);
            add_fname_to_exclude_list(&ff, line);
         }
         fclose(fd);
         break;
 
       case 'i':                    /* include list */
-         if ((fd = fopen(optarg, "r")) == NULL) {
-            Pmsg2(0, "Could not open include file: %s, ERR=%s\n",
+        if ((fd = fopen(optarg, "r")) == NULL) {
+           Pmsg2(0, "Could not open include file: %s, ERR=%s\n",
               optarg, strerror(errno));
            exit(1);
         }
         while (fgets(line, sizeof(line), fd) != NULL) {
            strip_trailing_junk(line);
-            Dmsg1(100, "add_include %s\n", line);
+           Dmsg1(100, "add_include %s\n", line);
            add_fname_to_include_list(&ff, 0, line);
         }
         fclose(fd);
@@ -201,7 +201,7 @@ int main (int argc, char *argv[])
       if (bsrName) {
         bsr = parse_bsr(NULL, bsrName);
       }
-      jcr = setup_jcr("bls", argv[i], bsr, VolumeName, 1); /* acquire for read */ 
+      jcr = setup_jcr("bls", argv[i], bsr, VolumeName, 1); /* acquire for read */
       if (!jcr) {
         exit(1);
       }
@@ -216,11 +216,11 @@ int main (int argc, char *argv[])
       attr = new_attr();
       /*
        * Assume that we have already read the volume label.
-       * If on second or subsequent volume, adjust buffer pointer 
+       * If on second or subsequent volume, adjust buffer pointer
        */
       if (dev->VolHdr.PrevVolName[0] != 0) { /* second volume */
-         Pmsg1(0, "\n\
-Warning, this Volume is a continuation of Volume %s\n",
+        Pmsg1(0, "\n"
+"Warning, this Volume is a continuation of Volume %s\n",
                dev->VolHdr.PrevVolName);
       }
 
@@ -260,10 +260,10 @@ static void do_blocks(char *infname)
    }
    for ( ;; ) {
       if (!read_block_from_device(dcr, NO_BLOCK_NUMBER_CHECK)) {
-         Dmsg1(100, "!read_block(): ERR=%s\n", strerror_dev(dev));
+        Dmsg1(100, "!read_block(): ERR=%s\n", strerror_dev(dev));
         if (dev->state & ST_EOT) {
            if (!mount_next_read_volume(dcr)) {
-               Jmsg(jcr, M_INFO, 0, _("Got EOM at file %u on device %s, Volume \"%s\"\n"), 
+              Jmsg(jcr, M_INFO, 0, _("Got EOM at file %u on device %s, Volume \"%s\"\n"),
                  dev->file, dev_name(dev), dcr->VolumeName);
               break;
            }
@@ -274,15 +274,15 @@ static void do_blocks(char *infname)
            read_record_from_block(block, record);
            get_session_record(dev, record, &sessrec);
            free_record(record);
-            Jmsg(jcr, M_INFO, 0, _("Mounted Volume \"%s\".\n"), dcr->VolumeName);
-           
+           Jmsg(jcr, M_INFO, 0, _("Mounted Volume \"%s\".\n"), dcr->VolumeName);
+
         } else if (dev->state & ST_EOF) {
-            Jmsg(jcr, M_INFO, 0, _("Got EOF at file %u on device %s, Volume \"%s\"\n"), 
+           Jmsg(jcr, M_INFO, 0, _("Got EOF at file %u on device %s, Volume \"%s\"\n"),
               dev->file, dev_name(dev), dcr->VolumeName);
-            Dmsg0(20, "read_record got eof. try again\n");
+           Dmsg0(20, "read_record got eof. try again\n");
            continue;
         } else if (dev->state & ST_SHORT) {
-            Jmsg(jcr, M_INFO, 0, "%s", dev->errmsg);
+           Jmsg(jcr, M_INFO, 0, "%s", dev->errmsg);
            continue;
         } else {
            /* I/O error */
@@ -291,7 +291,7 @@ static void do_blocks(char *infname)
         }
       }
       if (!match_bsr_block(bsr, block)) {
-         Dmsg5(100, "reject Blk=%u blen=%u bVer=%d SessId=%u SessTim=%u\n",
+        Dmsg5(100, "reject Blk=%u blen=%u bVer=%d SessId=%u SessTim=%u\n",
            block->BlockNumber, block->block_len, block->BlockVer,
            block->VolSessionId, block->VolSessionTime);
         continue;
@@ -301,16 +301,16 @@ static void do_blocks(char *infname)
        block->VolSessionId, block->VolSessionTime);
       if (verbose == 1) {
         read_record_from_block(block, rec);
-         Pmsg9(-1, "File:blk=%u:%u blk_num=%u blen=%u First rec FI=%s SessId=%u SessTim=%u Strm=%s rlen=%d\n",
+        Pmsg9(-1, "File:blk=%u:%u blk_num=%u blen=%u First rec FI=%s SessId=%u SessTim=%u Strm=%s rlen=%d\n",
              dev->file, dev->block_num,
              block->BlockNumber, block->block_len,
              FI_to_ascii(rec->FileIndex), rec->VolSessionId, rec->VolSessionTime,
              stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len);
         rec->remainder = 0;
       } else if (verbose > 1) {
-         dump_block(block, "");
+        dump_block(block, "");
       } else {
-         printf("Block: %d size=%d\n", block->BlockNumber, block->block_len);
+        printf("Block: %d size=%d\n", block->BlockNumber, block->block_len);
       }
 
    }
@@ -356,24 +356,24 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       return true;
    }
    /* File Attributes stream */
-   if (rec->Stream == STREAM_UNIX_ATTRIBUTES || 
+   if (rec->Stream == STREAM_UNIX_ATTRIBUTES ||
        rec->Stream == STREAM_UNIX_ATTRIBUTES_EX) {
 
       if (verbose > 1) {
-         const char *rtype = "Attributes";
-         Pmsg5(-1, "%s Record: VolSessionId=%d VolSessionTime=%d JobId=%d DataLen=%d\n",
+        const char *rtype = "Attributes";
+        Pmsg5(-1, "%s Record: VolSessionId=%d VolSessionTime=%d JobId=%d DataLen=%d\n",
               rtype, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
       }
       if (!unpack_attributes_record(jcr, rec->Stream, rec->data, attr)) {
         if (!forge_on) {
-            Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
+           Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
         }
         num_files++;
         return true;
       }
 
       if (attr->file_index != rec->FileIndex) {
-         Emsg2(forge_on?M_WARNING:M_ERROR_TERM, 0, _("Record header file index %ld not equal record index %ld\n"),
+        Emsg2(forge_on?M_WARNING:M_ERROR_TERM, 0, _("Record header file index %ld not equal record index %ld\n"),
               rec->FileIndex, attr->file_index);
       }
 
@@ -395,7 +395,7 @@ static void get_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *sess
    memset(sessrec, 0, sizeof(sessrec));
    switch (rec->FileIndex) {
    case PRE_LABEL:
-      rtype = "Fresh Volume Label";   
+      rtype = "Fresh Volume Label";
       break;
    case VOL_LABEL:
       rtype = "Volume Label";
@@ -439,6 +439,6 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
    DEVICE *dev = dcr->dev;
    fprintf(stderr, "Mount Volume \"%s\" on device %s and press return when ready: ",
       dcr->VolumeName, dev_name(dev));
-   getchar();  
+   getchar();
    return true;
 }
index 3a78a0ed2307c3a19a3f03bdeec1a92b913826c3..5c95a3d69b6bf9967e9d215f1ffafaf242e19e4a 100644 (file)
 /* Forward referenced functions */
 static void do_scan(void);
 static bool record_cb(DCR *dcr, DEV_RECORD *rec);
-static int  create_file_attributes_record(B_DB *db, JCR *mjcr, 
+static int  create_file_attributes_record(B_DB *db, JCR *mjcr,
                               char *fname, char *lname, int type,
                               char *ap, DEV_RECORD *rec);
 static int  create_media_record(B_DB *db, MEDIA_DBR *mr, VOLUME_LABEL *vl);
 static bool update_media_record(B_DB *db, MEDIA_DBR *mr);
 static int  create_pool_record(B_DB *db, POOL_DBR *pr);
 static JCR *create_job_record(B_DB *db, JOB_DBR *mr, SESSION_LABEL *label, DEV_RECORD *rec);
-static int  update_job_record(B_DB *db, JOB_DBR *mr, SESSION_LABEL *elabel, 
+static int  update_job_record(B_DB *db, JOB_DBR *mr, SESSION_LABEL *elabel,
                              DEV_RECORD *rec);
 static int  create_client_record(B_DB *db, CLIENT_DBR *cr);
 static int  create_fileset_record(B_DB *db, FILESET_DBR *fsr);
@@ -156,7 +156,7 @@ int main (int argc, char *argv[])
       case 'd':                    /* debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0)
-           debug_level = 1; 
+           debug_level = 1;
         break;
 
       case 'h':
@@ -207,7 +207,7 @@ int main (int argc, char *argv[])
       default:
         usage();
 
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -226,12 +226,12 @@ int main (int argc, char *argv[])
    me = (STORES *)GetNextRes(R_STORAGE, NULL);
    if (!me) {
       UnlockRes();
-      Emsg1(M_ERROR_TERM, 0, _("No Storage resource defined in %s. Cannot continue.\n"), 
+      Emsg1(M_ERROR_TERM, 0, _("No Storage resource defined in %s. Cannot continue.\n"),
         configfile);
    }
    UnlockRes();
    /* Check if -w option given, otherwise use resource for working directory */
-   if (wd) { 
+   if (wd) {
       working_directory = wd;
    } else if (!me->working_directory) {
       Emsg1(M_ERROR_TERM, 0, _("No Working Directory defined in %s. Cannot continue.\n"),
@@ -251,7 +251,7 @@ int main (int argc, char *argv[])
    }
 
    bjcr = setup_jcr("bscan", argv[0], bsr, VolumeName, 1); /* read device */
-   if (!bjcr) { 
+   if (!bjcr) {
       exit(1);
    }
    dev = bjcr->dcr->dev;
@@ -262,7 +262,7 @@ int main (int argc, char *argv[])
       Pmsg1(000, _("Current Volume Size = %" llu "\n"), currentVolumeSize);
    }
 
-   if ((db=db_init_database(NULL, db_name, db_user, db_password, 
+   if ((db=db_init_database(NULL, db_name, db_user, db_password,
        db_host, 0, NULL, 0)) == NULL) {
       Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n"));
    }
@@ -283,8 +283,8 @@ int main (int argc, char *argv[])
    term_dev(dev);
    return 0;
 }
-  
-/*  
+
+/*
  * We are at the end of reading a tape. Now, we simulate handling
  *   the end of writing a tape by wiffling through the attached
  *   jcrs creating jobmedia records.
@@ -300,7 +300,7 @@ static bool bscan_mount_next_read_volume(DCR *dcr)
         continue;
       }
       if (verbose) {
-         Pmsg1(000, _("Create JobMedia for Job %s\n"), mjcr->Job);
+        Pmsg1(000, _("Create JobMedia for Job %s\n"), mjcr->Job);
       }
       if (dev->state & ST_TAPE) {
         mdcr->EndBlock = dev->EndBlock;
@@ -310,10 +310,10 @@ static bool bscan_mount_next_read_volume(DCR *dcr)
         mdcr->EndFile = (uint32_t)(dev->file_addr >> 32);
       }
       if (!create_jobmedia_record(db, mjcr)) {
-         Pmsg2(000, _("Could not create JobMedia record for Volume=%s Job=%s\n"),
+        Pmsg2(000, _("Could not create JobMedia record for Volume=%s Job=%s\n"),
            dev->VolCatInfo.VolCatName, mjcr->Job);
       }
-   }  
+   }
    /* Now let common read routine get up next tape. Note,
     * we call mount_next... with bscan's jcr because that is where we
     * have the Volume list, but we get attached.
@@ -329,7 +329,7 @@ static bool bscan_mount_next_read_volume(DCR *dcr)
    return stat;
 }
 
-static void do_scan()            
+static void do_scan()
 {
    attr = new_attr();
 
@@ -364,20 +364,20 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       if (showProgress) {
         int64_t pct = (mr.VolBytes * 100) / currentVolumeSize;
         if (pct != last_pct) {
-            fprintf(stdout, "done: %" lld "\n", pct);
+           fprintf(stdout, "done: %" lld "\n", pct);
            fflush(stdout);
            last_pct = pct;
         }
       }
    }
-   
+
    if (list_records) {
       Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
-           rec->VolSessionId, rec->VolSessionTime, rec->FileIndex, 
+           rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
            rec->Stream, rec->data_len);
    }
-   /* 
-    * Check for Start or End of Session Record 
+   /*
+    * Check for Start or End of Session Record
     *
     */
    if (rec->FileIndex < 0) {
@@ -388,7 +388,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       }
       switch (rec->FileIndex) {
       case PRE_LABEL:
-         Pmsg0(000, _("Volume is prelabeled. This tape cannot be scanned.\n"));
+        Pmsg0(000, _("Volume is prelabeled. This tape cannot be scanned.\n"));
         return false;
         break;
 
@@ -400,21 +400,21 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
         num_pools++;
         if (db_get_pool_record(bjcr, db, &pr)) {
            if (verbose) {
-               Pmsg1(000, _("Pool record for %s found in DB.\n"), pr.Name);
+              Pmsg1(000, _("Pool record for %s found in DB.\n"), pr.Name);
            }
         } else {
            if (!update_db) {
-               Pmsg1(000, _("VOL_LABEL: Pool record not found for Pool: %s\n"),
+              Pmsg1(000, _("VOL_LABEL: Pool record not found for Pool: %s\n"),
                  pr.Name);
            }
            create_pool_record(db, &pr);
         }
         if (strcmp(pr.PoolType, dev->VolHdr.PoolType) != 0) {
-            Pmsg2(000, _("VOL_LABEL: PoolType mismatch. DB=%s Vol=%s\n"),
+           Pmsg2(000, _("VOL_LABEL: PoolType mismatch. DB=%s Vol=%s\n"),
               pr.PoolType, dev->VolHdr.PoolType);
            return true;
         } else if (verbose) {
-            Pmsg1(000, _("Pool type \"%s\" is OK.\n"), pr.PoolType);
+           Pmsg1(000, _("Pool type \"%s\" is OK.\n"), pr.PoolType);
         }
 
         /* Check Media Info */
@@ -424,25 +424,25 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
         num_media++;
         if (db_get_media_record(bjcr, db, &mr)) {
            if (verbose) {
-               Pmsg1(000, _("Media record for %s found in DB.\n"), mr.VolumeName);
+              Pmsg1(000, _("Media record for %s found in DB.\n"), mr.VolumeName);
            }
            /* Clear out some volume statistics that will be updated */
            mr.VolJobs = mr.VolFiles = mr.VolBlocks = 0;
            mr.VolBytes = rec->data_len + 20;
         } else {
            if (!update_db) {
-               Pmsg1(000, _("VOL_LABEL: Media record not found for Volume: %s\n"),
+              Pmsg1(000, _("VOL_LABEL: Media record not found for Volume: %s\n"),
                  mr.VolumeName);
            }
            bstrncpy(mr.MediaType, dev->VolHdr.MediaType, sizeof(mr.MediaType));
            create_media_record(db, &mr, &dev->VolHdr);
         }
         if (strcmp(mr.MediaType, dev->VolHdr.MediaType) != 0) {
-            Pmsg2(000, _("VOL_LABEL: MediaType mismatch. DB=%s Vol=%s\n"),
+           Pmsg2(000, _("VOL_LABEL: MediaType mismatch. DB=%s Vol=%s\n"),
               mr.MediaType, dev->VolHdr.MediaType);
            return true;              /* ignore error */
         } else if (verbose) {
-            Pmsg1(000, _("Media type \"%s\" is OK.\n"), mr.MediaType);
+           Pmsg1(000, _("Media type \"%s\" is OK.\n"), mr.MediaType);
         }
         /* Reset some JCR variables */
         foreach_dlist(dcr, dev->attached_dcrs) {
@@ -451,14 +451,14 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
            dcr->StartFile = dcr->EndFile = 0;
         }
 
-         Pmsg1(000, _("VOL_LABEL: OK for Volume: %s\n"), mr.VolumeName);
+        Pmsg1(000, _("VOL_LABEL: OK for Volume: %s\n"), mr.VolumeName);
         break;
 
       case SOS_LABEL:
         mr.VolJobs++;
         num_jobs++;
         if (ignored_msgs > 0) {
-            Pmsg1(000, _("%d \"errors\" ignored before first Start of Session record.\n"), 
+           Pmsg1(000, _("%d \"errors\" ignored before first Start of Session record.\n"),
                  ignored_msgs);
            ignored_msgs = 0;
         }
@@ -467,14 +467,14 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
         bstrncpy(jr.Job, label.Job, sizeof(jr.Job));
         if (db_get_job_record(bjcr, db, &jr)) {
            /* Job record already exists in DB */
-            update_db = false;  /* don't change db in create_job_record */
+           update_db = false;  /* don't change db in create_job_record */
            if (verbose) {
-               Pmsg1(000, _("SOS_LABEL: Found Job record for JobId: %d\n"), jr.JobId);
+              Pmsg1(000, _("SOS_LABEL: Found Job record for JobId: %d\n"), jr.JobId);
            }
         } else {
            /* Must create a Job record in DB */
            if (!update_db) {
-               Pmsg1(000, _("SOS_LABEL: Job record not found for JobId: %d\n"),
+              Pmsg1(000, _("SOS_LABEL: Job record not found for JobId: %d\n"),
                  jr.JobId);
            }
         }
@@ -483,7 +483,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
            create_client_record(db, &cr);
            jr.ClientId = cr.ClientId;
 
-         /* process label, if Job record exists don't update db */
+        /* process label, if Job record exists don't update db */
         mjcr = create_job_record(db, &jr, &label, rec);
         dcr = mjcr->dcr;
         update_db = save_update_db;
@@ -493,8 +493,8 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
         if (dev->state & ST_TAPE) {
            /*
             * Note, we have already advanced past current block,
-            *  so the correct number is block_num - 1 
-            */ 
+            *  so the correct number is block_num - 1
+            */
            dcr->StartBlock = dev->block_num - 1;
            dcr->StartFile = dev->file;
         } else {
@@ -512,19 +512,19 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
         bstrncpy(dcr->pool_name, label.PoolName, sizeof(dcr->pool_name));
 
         if (rec->VolSessionId != jr.VolSessionId) {
-            Pmsg3(000, _("SOS_LABEL: VolSessId mismatch for JobId=%u. DB=%d Vol=%d\n"),
+           Pmsg3(000, _("SOS_LABEL: VolSessId mismatch for JobId=%u. DB=%d Vol=%d\n"),
               jr.JobId,
               jr.VolSessionId, rec->VolSessionId);
            return true;              /* ignore error */
         }
         if (rec->VolSessionTime != jr.VolSessionTime) {
-            Pmsg3(000, _("SOS_LABEL: VolSessTime mismatch for JobId=%u. DB=%d Vol=%d\n"),
+           Pmsg3(000, _("SOS_LABEL: VolSessTime mismatch for JobId=%u. DB=%d Vol=%d\n"),
               jr.JobId,
               jr.VolSessionTime, rec->VolSessionTime);
            return true;              /* ignore error */
         }
         if (jr.PoolId != pr.PoolId) {
-            Pmsg3(000, _("SOS_LABEL: PoolId mismatch for JobId=%u. DB=%d Vol=%d\n"),
+           Pmsg3(000, _("SOS_LABEL: PoolId mismatch for JobId=%u. DB=%d Vol=%d\n"),
               jr.JobId,
               jr.PoolId, pr.PoolId);
            return true;              /* ignore error */
@@ -542,7 +542,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
 
         mjcr = get_jcr_by_session(rec->VolSessionId, rec->VolSessionTime);
         if (!mjcr) {
-            Pmsg2(000, _("Could not find SessId=%d SessTime=%d for EOS record.\n"),
+           Pmsg2(000, _("Could not find SessId=%d SessTime=%d for EOS record.\n"),
                  rec->VolSessionId, rec->VolSessionTime);
            break;
         }
@@ -564,7 +564,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
         break;
 
       case EOT_LABEL:             /* end of all tapes */
-        /* 
+        /*
          * Wiffle through all jobs still open and close
          *   them.
          */
@@ -585,7 +585,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
               jr.JobTDate = (utime_t)mjcr->start_time;
               jr.ClientId = mjcr->ClientId;
               if (!db_update_job_end_record(bjcr, db, &jr)) {
-                  Pmsg1(0, _("Could not update job record. ERR=%s\n"), db_strerror(db));
+                 Pmsg1(0, _("Could not update job record. ERR=%s\n"), db_strerror(db));
               }
               mjcr->dcr = NULL;
               free_jcr(mjcr);
@@ -596,7 +596,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
         mr.VolBytes += mr.VolBlocks * WRITE_BLKHDR_LENGTH; /* approx. */
         mr.VolMounts++;
         update_media_record(db, &mr);
-         Pmsg3(0, _("End of all Volumes. VolFiles=%u VolBlocks=%u VolBytes=%s\n"), mr.VolFiles,
+        Pmsg3(0, _("End of all Volumes. VolFiles=%u VolBlocks=%u VolBytes=%s\n"), mr.VolFiles,
                    mr.VolBlocks, edit_uint64_with_commas(mr.VolBytes, ec1));
         break;
       default:
@@ -608,7 +608,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
    mjcr = get_jcr_by_session(rec->VolSessionId, rec->VolSessionTime);
    if (!mjcr) {
       if (mr.VolJobs > 0) {
-         Pmsg2(000, _("Could not find Job for SessId=%d SessTime=%d record.\n"),
+        Pmsg2(000, _("Could not find Job for SessId=%d SessTime=%d record.\n"),
                      rec->VolSessionId, rec->VolSessionTime);
       } else {
         ignored_msgs++;
@@ -622,18 +622,18 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
 
    /* File Attributes stream */
    switch (rec->Stream) {
-   case STREAM_UNIX_ATTRIBUTES:   
-   case STREAM_UNIX_ATTRIBUTES_EX:  
+   case STREAM_UNIX_ATTRIBUTES:
+   case STREAM_UNIX_ATTRIBUTES_EX:
 
       if (!unpack_attributes_record(bjcr, rec->Stream, rec->data, attr)) {
-         Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
+        Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
       }
 
       if (attr->file_index != rec->FileIndex) {
-         Emsg2(M_ERROR_TERM, 0, _("Record header file index %ld not equal record index %ld\n"),
+        Emsg2(M_ERROR_TERM, 0, _("Record header file index %ld not equal record index %ld\n"),
            rec->FileIndex, attr->file_index);
       }
-       
+
       if (verbose > 1) {
         decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
         build_attr_output_fnames(bjcr, attr);
@@ -644,13 +644,13 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       num_files++;
       if (verbose && (num_files & 0x7FFF) == 0) {
         char ed1[30], ed2[30], ed3[30], ed4[30];
-         Pmsg4(000, _("%s file records. At file:blk=%s:%s bytes=%s\n"),
+        Pmsg4(000, _("%s file records. At file:blk=%s:%s bytes=%s\n"),
                     edit_uint64_with_commas(num_files, ed1),
                     edit_uint64_with_commas(rec->File, ed2),
                     edit_uint64_with_commas(rec->Block, ed3),
                     edit_uint64_with_commas(mr.VolBytes, ed4));
-      } 
-      create_file_attributes_record(db, mjcr, attr->fname, attr->lname, 
+      }
+      create_file_attributes_record(db, mjcr, attr->fname, attr->lname,
            attr->type, attr->attr, rec);
       free_jcr(mjcr);
       break;
@@ -663,7 +663,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       if (rec->Stream == STREAM_SPARSE_DATA) {
         mjcr->JobBytes -= sizeof(uint64_t);
       }
-        
+
       free_jcr(mjcr);                /* done using JCR */
       break;
 
@@ -687,7 +687,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       char MD5buf[50];
       bin_to_base64(MD5buf, (char *)rec->data, 16); /* encode 16 bytes */
       if (verbose > 1) {
-         Pmsg1(000, _("Got MD5 record: %s\n"), MD5buf);
+        Pmsg1(000, _("Got MD5 record: %s\n"), MD5buf);
       }
       update_SIG_record(db, MD5buf, rec, MD5_SIG);
       break;
@@ -696,7 +696,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       char SIGbuf[50];
       bin_to_base64(SIGbuf, (char *)rec->data, 20); /* encode 20 bytes */
       if (verbose > 1) {
-         Pmsg1(000, _("Got SHA1 record: %s\n"), SIGbuf);
+        Pmsg1(000, _("Got SHA1 record: %s\n"), SIGbuf);
       }
       update_SIG_record(db, SIGbuf, rec, SHA1_SIG);
       break;
@@ -704,13 +704,13 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
 
    case STREAM_PROGRAM_NAMES:
       if (verbose) {
-         Pmsg1(000, _("Got Prog Names Stream: %s\n"), rec->data);
+        Pmsg1(000, _("Got Prog Names Stream: %s\n"), rec->data);
       }
       break;
 
    case STREAM_PROGRAM_DATA:
       if (verbose > 1) {
-         Pmsg0(000, _("Got Prog Data Stream record.\n"));
+        Pmsg0(000, _("Got Prog Data Stream record.\n"));
       }
       break;
    default:
@@ -780,7 +780,7 @@ static int create_file_attributes_record(B_DB *db, JCR *mjcr,
    mjcr->FileId = ar.FileId;
 
    if (verbose > 1) {
-      Pmsg1(000, _("Created File record: %s\n"), fname);   
+      Pmsg1(000, _("Created File record: %s\n"), fname);
    }
    return 1;
 }
@@ -875,7 +875,7 @@ static int create_pool_record(B_DB *db, POOL_DBR *pr)
 
 
 /*
- * Called from SOS to create a client for the current Job 
+ * Called from SOS to create a client for the current Job
  */
 static int create_client_record(B_DB *db, CLIENT_DBR *cr)
 {
@@ -904,16 +904,16 @@ static int create_fileset_record(B_DB *db, FILESET_DBR *fsr)
    }
    if (db_get_fileset_record(bjcr, db, fsr)) {
       if (verbose) {
-         Pmsg1(000, _("Fileset \"%s\" already exists.\n"), fsr->FileSet);
+        Pmsg1(000, _("Fileset \"%s\" already exists.\n"), fsr->FileSet);
       }
    } else {
       if (!db_create_fileset_record(bjcr, db, fsr)) {
-         Pmsg2(0, _("Could not create FileSet record \"%s\". ERR=%s\n"), 
+        Pmsg2(0, _("Could not create FileSet record \"%s\". ERR=%s\n"),
            fsr->FileSet, db_strerror(db));
         return 0;
       }
       if (verbose) {
-         Pmsg1(000, _("Created FileSet record \"%s\"\n"), fsr->FileSet);
+        Pmsg1(000, _("Created FileSet record \"%s\"\n"), fsr->FileSet);
       }
    }
    return 1;
@@ -924,7 +924,7 @@ static int create_fileset_record(B_DB *db, FILESET_DBR *fsr)
  *  the Job record and to update it when the Job actually
  *  begins running.
  */
-static JCR *create_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *label, 
+static JCR *create_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *label,
                             DEV_RECORD *rec)
 {
    JCR *mjcr;
@@ -969,14 +969,14 @@ static JCR *create_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *label,
       Pmsg1(0, _("Could not update job start record. ERR=%s\n"), db_strerror(db));
       return mjcr;
    }
-   Pmsg2(000, _("Created new JobId=%u record for original JobId=%u\n"), jr->JobId, 
+   Pmsg2(000, _("Created new JobId=%u record for original JobId=%u\n"), jr->JobId,
         label->JobId);
    mjcr->JobId = jr->JobId;          /* set new JobId */
    return mjcr;
 }
 
-/* 
- * Simulate the database call that updates the Job 
+/*
+ * Simulate the database call that updates the Job
  *  at Job termination time.
  */
 static int update_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *elabel,
@@ -1017,7 +1017,7 @@ static int update_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *elabel,
       free_jcr(mjcr);
       return 1;
    }
-   
+
    if (!db_update_job_end_record(bjcr, db, jr)) {
       Pmsg2(0, _("Could not update JobId=%u record. ERR=%s\n"), jr->JobId,  db_strerror(db));
       free_jcr(mjcr);
@@ -1035,36 +1035,36 @@ static int update_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *elabel,
 
       switch (mjcr->JobStatus) {
       case JS_Terminated:
-         term_msg = _("Backup OK");
+        term_msg = _("Backup OK");
         break;
       case JS_FatalError:
       case JS_ErrorTerminated:
-         term_msg = _("*** Backup Error ***");
+        term_msg = _("*** Backup Error ***");
         break;
       case JS_Canceled:
-         term_msg = _("Backup Canceled");
+        term_msg = _("Backup Canceled");
         break;
       default:
         term_msg = term_code;
-         sprintf(term_code, _("Job Termination code: %d"), mjcr->JobStatus);
+        sprintf(term_code, _("Job Termination code: %d"), mjcr->JobStatus);
         break;
       }
       bstrftime(sdt, sizeof(sdt), mjcr->start_time);
       bstrftime(edt, sizeof(edt), mjcr->end_time);
-      Pmsg14(000,  _("%s\n\
-JobId:                  %d\n\
-Job:                    %s\n\
-FileSet:                %s\n\
-Backup Level:           %s\n\
-Client:                 %s\n\
-Start time:             %s\n\
-End time:               %s\n\
-Files Written:          %s\n\
-Bytes Written:          %s\n\
-Volume Session Id:      %d\n\
-Volume Session Time:    %d\n\
-Last Volume Bytes:      %s\n\
-Termination:            %s\n\n"),
+      Pmsg14(000,  _("%s\n"
+"JobId:                  %d\n"
+"Job:                    %s\n"
+"FileSet:                %s\n"
+"Backup Level:           %s\n"
+"Client:                 %s\n"
+"Start time:             %s\n"
+"End time:               %s\n"
+"Files Written:          %s\n"
+"Bytes Written:          %s\n"
+"Volume Session Id:      %d\n"
+"Volume Session Time:    %d\n"
+"Last Volume Bytes:      %s\n"
+"Termination:            %s\n\n"),
        edt,
        mjcr->JobId,
        mjcr->Job,
@@ -1117,13 +1117,13 @@ static int create_jobmedia_record(B_DB *db, JCR *mjcr)
       return 0;
    }
    if (verbose) {
-      Pmsg2(000, _("Created JobMedia record JobId %d, MediaId %d\n"), 
+      Pmsg2(000, _("Created JobMedia record JobId %d, MediaId %d\n"),
                jmr.JobId, jmr.MediaId);
    }
    return 1;
 }
 
-/* 
+/*
  * Simulate the database call that updates the MD5/SHA1 record
  */
 static int update_SIG_record(B_DB *db, char *SIGbuf, DEV_RECORD *rec, int type)
@@ -1133,7 +1133,7 @@ static int update_SIG_record(B_DB *db, char *SIGbuf, DEV_RECORD *rec, int type)
    mjcr = get_jcr_by_session(rec->VolSessionId, rec->VolSessionTime);
    if (!mjcr) {
       if (mr.VolJobs > 0) {
-         Pmsg2(000, _("Could not find SessId=%d SessTime=%d for MD5/SHA1 record.\n"),
+        Pmsg2(000, _("Could not find SessId=%d SessTime=%d for MD5/SHA1 record.\n"),
                      rec->VolSessionId, rec->VolSessionTime);
       } else {
         ignored_msgs++;
@@ -1145,7 +1145,7 @@ static int update_SIG_record(B_DB *db, char *SIGbuf, DEV_RECORD *rec, int type)
       free_jcr(mjcr);
       return 1;
    }
-   
+
    if (!db_add_SIG_to_file_record(bjcr, db, mjcr->FileId, SIGbuf, type)) {
       Pmsg1(0, _("Could not add MD5/SHA1 to File record. ERR=%s\n"), db_strerror(db));
       free_jcr(mjcr);
@@ -1159,7 +1159,7 @@ static int update_SIG_record(B_DB *db, char *SIGbuf, DEV_RECORD *rec, int type)
 }
 
 
-/* 
+/*
  * Create a JCR as if we are really starting the job
  */
 static JCR *create_jcr(JOB_DBR *jr, DEV_RECORD *rec, uint32_t JobId)
@@ -1206,6 +1206,6 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
    force_close_dev(dev);
    fprintf(stderr, "Mount Volume \"%s\" on device %s and press return when ready: ",
         dcr->VolumeName, dev_name(dev));
-   getchar();  
+   getchar();
    return true;
 }
index c44643baf1d0b2083158452e40428d4047b59fcc..dfafe13b917e31b1d06e5f580ce0302ed4141c25 100644 (file)
 
 /*
  * List of Volume names to be read by Storage daemon.
- *  Formed by Storage daemon from BSR  
+ *  Formed by Storage daemon from BSR
  */
 struct VOL_LIST {
    VOL_LIST *next;
    char VolumeName[MAX_NAME_LENGTH];
-   int Slot; 
+   int Slot;
    uint32_t start_file;
 };
 
@@ -54,12 +54,12 @@ struct VOL_LIST {
 struct BSR_VOLUME {
    BSR_VOLUME *next;
    char VolumeName[MAX_NAME_LENGTH];
-};           
+};
 
 struct BSR_CLIENT {
    BSR_CLIENT *next;
    char ClientName[MAX_NAME_LENGTH];
-};           
+};
 
 struct BSR_SESSID {
    BSR_SESSID *next;
@@ -71,7 +71,7 @@ struct BSR_SESSTIME {
    BSR_SESSTIME *next;
    uint32_t sesstime;
    bool done;                         /* local done */
-};             
+};
 
 struct BSR_VOLFILE {
    BSR_VOLFILE *next;
@@ -85,7 +85,7 @@ struct BSR_VOLBLOCK {
    uint32_t sblock;                   /* start block */
    uint32_t eblock;                   /* end block */
    bool done;                         /* local done */
-};             
+};
 
 
 struct BSR_FINDEX {
@@ -93,23 +93,23 @@ struct BSR_FINDEX {
    int32_t findex;                    /* start file index */
    int32_t findex2;                   /* end file index */
    bool done;                         /* local done */
-};           
+};
 
 struct BSR_JOBID {
    BSR_JOBID *next;
    uint32_t JobId;
    uint32_t JobId2;
-};          
+};
 
 struct BSR_JOBTYPE {
    BSR_JOBTYPE *next;
    uint32_t JobType;
-};            
+};
 
 struct BSR_JOBLEVEL {
    BSR_JOBLEVEL *next;
    uint32_t JobLevel;
-};             
+};
 
 struct BSR_JOB {
    BSR_JOB *next;
@@ -120,7 +120,7 @@ struct BSR_JOB {
 struct BSR_STREAM {
    BSR_STREAM *next;
    int32_t stream;                    /* stream desired */
-};           
+};
 
 struct BSR {
    BSR          *next;                /* pointer to next one */
index 50a8bf52e2bef27a7a509b8e651446bdc08debb6..a661374c2facc9c786ab00cb1786aece886bffcb 100644 (file)
@@ -48,16 +48,16 @@ char VolName[MAX_NAME_LENGTH];
 bool forge_on = false;
 
 /*
- * If you change the format of the state file, 
+ * If you change the format of the state file,
  *  increment this value
- */ 
+ */
 static uint32_t btape_state_level = 2;
 
 DEVICE *dev = NULL;
 DCR *dcr;
 DEVRES *device = NULL;
 
-           
+
 /* Forward referenced subroutines */
 static void do_tape_cmds();
 static void helpcmd();
@@ -123,7 +123,7 @@ static uint32_t last_block_num1 = 0;
 static uint32_t last_block_num2 = 0;
 static uint32_t last_block_num = 0;
 static uint32_t BlockNumber = 0;
-static bool simple = true; 
+static bool simple = true;
 
 static const char *VolumeName = NULL;
 static int vol_num = 0;
@@ -200,7 +200,7 @@ int main(int margc, char *margv[])
       case 'd':                    /* set debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0) {
-           debug_level = 1; 
+           debug_level = 1;
         }
         break;
 
@@ -221,14 +221,14 @@ int main(int margc, char *margv[])
         helpcmd();
         exit(0);
 
-      }  
+      }
    }
    margc -= optind;
    margv += optind;
 
    cmd = get_pool_memory(PM_FNAME);
    args = get_pool_memory(PM_FNAME);
-   
+
    if (signals) {
       init_signals(terminate_btape);
    }
@@ -268,7 +268,7 @@ int main(int margc, char *margv[])
 
    Dmsg0(200, "Do tape commands\n");
    do_tape_cmds();
-  
+
 terminate:
    terminate_btape(0);
    return 0;
@@ -303,7 +303,7 @@ static void terminate_btape(int stat)
    }
 
    if (debug_level > 10)
-      print_memory_pool_stats(); 
+      print_memory_pool_stats();
 
    if (this_block) {
       free_block(this_block);
@@ -320,13 +320,13 @@ static void terminate_btape(int stat)
 static bool open_the_device()
 {
    DEV_BLOCK *block;
-   
+
    block = new_block(dev);
    lock_device(dev);
    if (!(dev->state & ST_OPENED)) {
       Dmsg1(200, "Opening device %s\n", dcr->VolumeName);
       if (open_dev(dev, dcr->VolumeName, OPEN_READ_WRITE) < 0) {
-         Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
+        Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
         unlock_device(dev);
         free_block(block);
         return false;
@@ -346,7 +346,7 @@ void quitcmd()
 }
 
 /*
- * Write a label to the tape   
+ * Write a label to the tape
  */
 static void labelcmd()
 {
@@ -357,10 +357,10 @@ static void labelcmd()
         return;
       }
    }
-        
+
    if (!(dev->state & ST_OPENED)) {
       if (!first_open_device(dev)) {
-         Pmsg1(0, "Device open failed. ERR=%s\n", strerror_dev(dev));
+        Pmsg1(0, "Device open failed. ERR=%s\n", strerror_dev(dev));
       }
    }
    rewind_dev(dev);
@@ -369,7 +369,7 @@ static void labelcmd()
 }
 
 /*
- * Read the tape label  
+ * Read the tape label
  */
 static void readlabelcmd()
 {
@@ -405,7 +405,7 @@ static void readlabelcmd()
    }
 
    debug_level = 20;
-   dump_volume_label(dev); 
+   dump_volume_label(dev);
    debug_level = save_debug_level;
 }
 
@@ -424,7 +424,7 @@ static void loadcmd()
 }
 
 /*
- * Rewind the tape.   
+ * Rewind the tape.
  */
 static void rewindcmd()
 {
@@ -437,7 +437,7 @@ static void rewindcmd()
 }
 
 /*
- * Clear any tape error   
+ * Clear any tape error
  */
 static void clearcmd()
 {
@@ -445,7 +445,7 @@ static void clearcmd()
 }
 
 /*
- * Write and end of file on the tape   
+ * Write and end of file on the tape
  */
 static void weofcmd()
 {
@@ -467,7 +467,7 @@ static void weofcmd()
 }
 
 
-/* Go to the end of the medium -- raw command  
+/* Go to the end of the medium -- raw command
  * The idea was orginally that the end of the Bacula
  * medium would be flagged differently. This is not
  * currently the case. So, this is identical to the
@@ -493,7 +493,7 @@ static void eodcmd()
 }
 
 /*
- * Backspace file   
+ * Backspace file
  */
 static void bsfcmd()
 {
@@ -513,7 +513,7 @@ static void bsfcmd()
 }
 
 /*
- * Backspace record   
+ * Backspace record
  */
 static void bsrcmd()
 {
@@ -532,7 +532,7 @@ static void bsrcmd()
 }
 
 /*
- * List device capabilities as defined in the 
+ * List device capabilities as defined in the
  *  stored.conf file.
  */
 static void capcmd()
@@ -580,7 +580,7 @@ static void capcmd()
 }
 
 /*
- * Test writting larger and larger records.  
+ * Test writting larger and larger records.
  * This is a torture test for records.
  */
 static void rectestcmd()
@@ -613,7 +613,7 @@ static void rectestcmd()
       if (write_record_to_block(block, rec)) {
         empty_block(block);
         blkno++;
-         Pmsg2(0, "Block %d i=%d\n", blkno, i);
+        Pmsg2(0, "Block %d i=%d\n", blkno, i);
       } else {
         break;
       }
@@ -645,10 +645,10 @@ static int re_read_block_test()
 
    Pmsg0(-1, _("\n=== Write, backup, and re-read test ===\n\n"
       "I'm going to write three records and an EOF\n"
-      "then backup over the EOF and re-read the last record.\n"     
+      "then backup over the EOF and re-read the last record.\n"
       "Bacula does this after writing the last block on the\n"
       "tape to verify that the block was written correctly.\n\n"
-      "This is not an *essential* feature ...\n\n")); 
+      "This is not an *essential* feature ...\n\n"));
    rewindcmd();
    empty_block(block);
    rec = new_record();
@@ -656,33 +656,33 @@ static int re_read_block_test()
    len = rec->data_len = block->buf_len-100;
    memset(rec->data, 1, rec->data_len);
    if (!write_record_to_block(block, rec)) {
-      Pmsg0(0, _("Error writing record to block.\n")); 
+      Pmsg0(0, _("Error writing record to block.\n"));
       goto bail_out;
    }
    if (!write_block_to_dev(dcr)) {
-      Pmsg0(0, _("Error writing block to device.\n")); 
+      Pmsg0(0, _("Error writing block to device.\n"));
       goto bail_out;
    } else {
       Pmsg1(0, _("Wrote first record of %d bytes.\n"), rec->data_len);
    }
    memset(rec->data, 2, rec->data_len);
    if (!write_record_to_block(block, rec)) {
-      Pmsg0(0, _("Error writing record to block.\n")); 
+      Pmsg0(0, _("Error writing record to block.\n"));
       goto bail_out;
    }
    if (!write_block_to_dev(dcr)) {
-      Pmsg0(0, _("Error writing block to device.\n")); 
+      Pmsg0(0, _("Error writing block to device.\n"));
       goto bail_out;
    } else {
       Pmsg1(0, _("Wrote second record of %d bytes.\n"), rec->data_len);
    }
    memset(rec->data, 3, rec->data_len);
    if (!write_record_to_block(block, rec)) {
-      Pmsg0(0, _("Error writing record to block.\n")); 
+      Pmsg0(0, _("Error writing record to block.\n"));
       goto bail_out;
    }
    if (!write_block_to_dev(dcr)) {
-      Pmsg0(0, _("Error writing block to device.\n")); 
+      Pmsg0(0, _("Error writing block to device.\n"));
       goto bail_out;
    } else {
       Pmsg1(0, _("Wrote third record of %d bytes.\n"), rec->data_len);
@@ -697,7 +697,7 @@ static int re_read_block_test()
    }
    if (dev_cap(dev, CAP_TWOEOF)) {
       if (!bsf_dev(dev, 1)) {
-         Pmsg1(0, _("Backspace file failed! ERR=%s\n"), strerror_dev(dev));
+        Pmsg1(0, _("Backspace file failed! ERR=%s\n"), strerror_dev(dev));
         goto bail_out;
       }
    }
@@ -720,7 +720,7 @@ static int re_read_block_test()
    }
    for (int i=0; i<len; i++) {
       if (rec->data[i] != 3) {
-         Pmsg0(0, _("Bad data in record. Test failed!\n"));
+        Pmsg0(0, _("Bad data in record. Test failed!\n"));
         goto bail_out;
       }
    }
@@ -733,12 +733,12 @@ bail_out:
    free_record(rec);
    if (stat == 0) {
       Pmsg0(0, _("This is not terribly serious since Bacula only uses\n"
-                 "this function to verify the last block written to the\n"
-                 "tape. Bacula will skip the last block verification\n"
-                 "if you add:\n\n"
-                  "Backward Space Record = No\n\n"
-                  "to your Storage daemon's Device resource definition.\n"));
-   }   
+                "this function to verify the last block written to the\n"
+                "tape. Bacula will skip the last block verification\n"
+                "if you add:\n\n"
+                 "Backward Space Record = No\n\n"
+                 "to your Storage daemon's Device resource definition.\n"));
+   }
    return stat;
 }
 
@@ -758,9 +758,9 @@ static int write_read_test()
 
    Pmsg0(-1, _("\n=== Write, rewind, and re-read test ===\n\n"
       "I'm going to write 1000 records and an EOF\n"
-      "then write 1000 records and an EOF, then rewind,\n"     
+      "then write 1000 records and an EOF, then rewind,\n"
       "and re-read the data to verify that it is correct.\n\n"
-      "This is an *essential* feature ...\n\n")); 
+      "This is an *essential* feature ...\n\n"));
    block = dcr->block;
    rec = new_record();
    if (!rewind_dev(dev)) {
@@ -776,11 +776,11 @@ static int write_read_test()
         *p++ = i;
       }
       if (!write_record_to_block(block, rec)) {
-         Pmsg0(0, _("Error writing record to block.\n")); 
+        Pmsg0(0, _("Error writing record to block.\n"));
         goto bail_out;
       }
       if (!write_block_to_dev(dcr)) {
-         Pmsg0(0, _("Error writing block to device.\n")); 
+        Pmsg0(0, _("Error writing block to device.\n"));
         goto bail_out;
       }
    }
@@ -792,11 +792,11 @@ static int write_read_test()
         *p++ = i;
       }
       if (!write_record_to_block(block, rec)) {
-         Pmsg0(0, _("Error writing record to block.\n")); 
+        Pmsg0(0, _("Error writing record to block.\n"));
         goto bail_out;
       }
       if (!write_block_to_dev(dcr)) {
-         Pmsg0(0, _("Error writing block to device.\n")); 
+        Pmsg0(0, _("Error writing block to device.\n"));
         goto bail_out;
       }
    }
@@ -816,31 +816,31 @@ read_again:
       if (!read_block_from_dev(dcr, NO_BLOCK_NUMBER_CHECK)) {
         berrno be;
         if (dev_state(dev, ST_EOF)) {
-            Pmsg0(-1, _("Got EOF on tape.\n"));
+           Pmsg0(-1, _("Got EOF on tape.\n"));
            if (i == 1001) {
               goto read_again;
            }
         }
-         Pmsg2(0, _("Read block %d failed! ERR=%s\n"), i, be.strerror(dev->dev_errno));
+        Pmsg2(0, _("Read block %d failed! ERR=%s\n"), i, be.strerror(dev->dev_errno));
         goto bail_out;
       }
       memset(rec->data, 0, rec->data_len);
       if (!read_record_from_block(block, rec)) {
         berrno be;
-         Pmsg2(0, _("Read record failed. Block %d! ERR=%s\n"), i, be.strerror(dev->dev_errno));
+        Pmsg2(0, _("Read record failed. Block %d! ERR=%s\n"), i, be.strerror(dev->dev_errno));
         goto bail_out;
       }
       p = (int *)rec->data;
       for (j=0; j<len; j++) {
         if (*p != i) {
-            Pmsg3(0, _("Bad data in record. Expected %d, got %d at byte %d. Test failed!\n"),
+           Pmsg3(0, _("Bad data in record. Expected %d, got %d at byte %d. Test failed!\n"),
               i, *p, j);
            goto bail_out;
         }
         p++;
       }
       if (i == 1000 || i == 2000) {
-         Pmsg0(-1, _("1000 blocks re-read correctly.\n"));
+        Pmsg0(-1, _("1000 blocks re-read correctly.\n"));
       }
    }
    Pmsg0(-1, _("=== Test Succeeded. End Write, rewind, and re-read test ===\n\n"));
@@ -870,9 +870,9 @@ static int position_test()
 
    Pmsg0(-1, _("\n=== Write, rewind, and position test ===\n\n"
       "I'm going to write 1000 records and an EOF\n"
-      "then write 1000 records and an EOF, then rewind,\n"     
+      "then write 1000 records and an EOF, then rewind,\n"
       "and position to a few blocks and verify that it is correct.\n\n"
-      "This is an *essential* feature ...\n\n")); 
+      "This is an *essential* feature ...\n\n"));
    empty_block(block);
    rec = new_record();
    if (!rewind_dev(dev)) {
@@ -888,11 +888,11 @@ static int position_test()
         *p++ = i;
       }
       if (!write_record_to_block(block, rec)) {
-         Pmsg0(0, _("Error writing record to block.\n")); 
+        Pmsg0(0, _("Error writing record to block.\n"));
         goto bail_out;
       }
       if (!write_block_to_dev(dcr)) {
-         Pmsg0(0, _("Error writing block to device.\n")); 
+        Pmsg0(0, _("Error writing block to device.\n"));
         goto bail_out;
       }
    }
@@ -904,11 +904,11 @@ static int position_test()
         *p++ = i;
       }
       if (!write_record_to_block(block, rec)) {
-         Pmsg0(0, _("Error writing record to block.\n")); 
+        Pmsg0(0, _("Error writing record to block.\n"));
         goto bail_out;
       }
       if (!write_block_to_dev(dcr)) {
-         Pmsg0(0, _("Error writing block to device.\n")); 
+        Pmsg0(0, _("Error writing block to device.\n"));
         goto bail_out;
       }
    }
@@ -963,44 +963,44 @@ static int position_test()
       }
       Pmsg2(-1, "Reposition to file:block %d:%d\n", file, blk);
       if (!reposition_dev(dev, file, blk)) {
-         Pmsg0(0, "Reposition error.\n");
+        Pmsg0(0, "Reposition error.\n");
         goto bail_out;
       }
 read_again:
       if (!read_block_from_dev(dcr, NO_BLOCK_NUMBER_CHECK)) {
         berrno be;
         if (dev_state(dev, ST_EOF)) {
-            Pmsg0(-1, _("Got EOF on tape.\n"));
+           Pmsg0(-1, _("Got EOF on tape.\n"));
            if (!got_eof) {
               got_eof = true;
               goto read_again;
            }
         }
-         Pmsg4(0, _("Read block %d failed! file=%d blk=%d. ERR=%s\n\n"), 
+        Pmsg4(0, _("Read block %d failed! file=%d blk=%d. ERR=%s\n\n"),
            recno, file, blk, be.strerror(dev->dev_errno));
-         Pmsg0(0, _("This may be because the tape drive block size is not\n"
-                    " set to variable blocking as normally used by Bacula.\n"
-                    " Please see the Tape Testing chapter in the manual and \n"
-                    " look for using mt with defblksize and setoptions\n"
-                    "If your tape drive block size is correct, then perhaps\n"
-                    " your SCSI driver is *really* stupid and does not\n"
-                    " correctly report the file:block after a FSF. In this\n"
-                    " case try setting:\n"
-                    "    Fast Forward Space File = no\n"
-                    " in your Device resource.\n"));
+        Pmsg0(0, _("This may be because the tape drive block size is not\n"
+                   " set to variable blocking as normally used by Bacula.\n"
+                   " Please see the Tape Testing chapter in the manual and \n"
+                   " look for using mt with defblksize and setoptions\n"
+                   "If your tape drive block size is correct, then perhaps\n"
+                   " your SCSI driver is *really* stupid and does not\n"
+                   " correctly report the file:block after a FSF. In this\n"
+                   " case try setting:\n"
+                   "    Fast Forward Space File = no\n"
+                   " in your Device resource.\n"));
 
         goto bail_out;
       }
       memset(rec->data, 0, rec->data_len);
       if (!read_record_from_block(block, rec)) {
         berrno be;
-         Pmsg1(0, _("Read record failed! ERR=%s\n"), be.strerror(dev->dev_errno));
+        Pmsg1(0, _("Read record failed! ERR=%s\n"), be.strerror(dev->dev_errno));
         goto bail_out;
       }
       p = (int *)rec->data;
       for (j=0; j<len; j++) {
         if (p[j] != recno) {
-            Pmsg3(0, _("Bad data in record. Expected %d, got %d at byte %d. Test failed!\n"),
+           Pmsg3(0, _("Bad data in record. Expected %d, got %d at byte %d. Test failed!\n"),
               recno, p[j], j);
            goto bail_out;
         }
@@ -1027,7 +1027,7 @@ bail_out:
 static int append_test()
 {
    Pmsg0(-1, _("\n\n=== Append files test ===\n\n"
-               "This test is essential to Bacula.\n\n"
+              "This test is essential to Bacula.\n\n"
 "I'm going to write one record  in file 0,\n"
 "                   two records in file 1,\n"
 "             and three records in file 2\n\n"));
@@ -1052,7 +1052,7 @@ static int append_test()
    rewindcmd();
    Pmsg0(0, _("Now moving to end of medium.\n"));
    eodcmd();
-   Pmsg2(-1, _("We should be in file 3. I am at file %d. This is %s\n"), 
+   Pmsg2(-1, _("We should be in file 3. I am at file %d. This is %s\n"),
       dev->file, dev->file == 3 ? "correct!" : "NOT correct!!!!");
 
    if (dev->file != 3) {
@@ -1060,7 +1060,7 @@ static int append_test()
    }
 
    Pmsg0(-1, _("\nNow the important part, I am going to attempt to append to the tape.\n\n"));
-   wrcmd(); 
+   wrcmd();
    weofcmd();
    if (dev_cap(dev, CAP_TWOEOF)) {
       weofcmd();
@@ -1070,7 +1070,7 @@ static int append_test()
    Pmsg0(-1, "Doing Bacula scan of blocks:\n");
    scan_blocks();
    Pmsg0(-1, _("End scanning the tape.\n"));
-   Pmsg2(-1, _("We should be in file 4. I am at file %d. This is %s\n"), 
+   Pmsg2(-1, _("We should be in file 4. I am at file %d. This is %s\n"),
       dev->file, dev->file == 4 ? "correct!" : "NOT correct!!!!");
 
    if (dev->file != 4) {
@@ -1100,8 +1100,8 @@ static int autochanger_test()
    }
 
    Pmsg0(-1, "\nAh, I see you have an autochanger configured.\n"
-             "To test the autochanger you must have a blank tape\n"
-             " that I can write on in Slot 1.\n");
+            "To test the autochanger you must have a blank tape\n"
+            " that I can write on in Slot 1.\n");
    if (!get_cmd("\nDo you wish to continue with the Autochanger test? (y/n): ")) {
       return 0;
    }
@@ -1119,8 +1119,8 @@ try_again:
    dcr->VolCatInfo.Slot = slot;
    /* Find out what is loaded, zero means device is unloaded */
    Pmsg0(-1, _("3301 Issuing autochanger \"loaded\" command.\n"));
-   changer = edit_device_codes(jcr, changer, jcr->device->changer_command, 
-                "loaded");
+   changer = edit_device_codes(jcr, changer, jcr->device->changer_command,
+               "loaded");
    status = run_program(changer, timeout, results);
    Dmsg3(100, "run_prog: %s stat=%d result=\"%s\"\n", changer, status, results);
    if (status == 0) {
@@ -1144,24 +1144,24 @@ try_again:
       force_close_dev(dev);
       Pmsg2(-1, _("3302 Issuing autochanger \"unload %d %d\" command.\n"),
         loaded, dev->drive_index);
-      changer = edit_device_codes(jcr, changer, 
-                     jcr->device->changer_command, "unload");
+      changer = edit_device_codes(jcr, changer,
+                    jcr->device->changer_command, "unload");
       status = run_program(changer, timeout, results);
       Pmsg2(-1, "unload status=%s %d\n", status==0?"OK":"Bad", status);
       if (status != 0) {
         berrno be;
-         Pmsg1(-1, _("3992 Bad autochanger command: %s\n"), changer);
-         Pmsg2(-1, _("3992 result=\"%s\": ERR=%s\n"), results, be.strerror(status));
+        Pmsg1(-1, _("3992 Bad autochanger command: %s\n"), changer);
+        Pmsg2(-1, _("3992 result=\"%s\": ERR=%s\n"), results, be.strerror(status));
       }
    }
 
    /*
     * Load the Slot 1
     */
-   
+
    slot = 1;
    dcr->VolCatInfo.Slot = slot;
-   Pmsg2(-1, _("3303 Issuing autochanger \"load slot %d %d\" command.\n"), 
+   Pmsg2(-1, _("3303 Issuing autochanger \"load slot %d %d\" command.\n"),
       slot, dev->drive_index);
    changer = edit_device_codes(jcr, changer, jcr->device->changer_command, "load");
    Dmsg1(100, "Changer=%s\n", changer);
@@ -1180,7 +1180,7 @@ try_again:
    if (!open_the_device()) {
       goto bail_out;
    }
-   /*  
+   /*
     * Start with sleep_time 0 then increment by 30 seconds if we get
     * a failure.
     */
@@ -1189,14 +1189,14 @@ try_again:
       Pmsg1(0, "Bad status from rewind. ERR=%s\n", strerror_dev(dev));
       clrerror_dev(dev, -1);
       Pmsg0(-1, "\nThe test failed, probably because you need to put\n"
-                "a longer sleep time in the mtx-script in the load) case.\n" 
-                "Adding a 30 second sleep and trying again ...\n");
+               "a longer sleep time in the mtx-script in the load) case.\n"
+               "Adding a 30 second sleep and trying again ...\n");
       sleep_time += 30;
       goto try_again;
    } else {
       Pmsg1(0, "Rewound %s\n", dev_name(dev));
    }
-      
+
    if ((status = weof_dev(dev, 1)) < 0) {
       Pmsg2(0, "Bad status from weof %d. ERR=%s\n", status, strerror_dev(dev));
       goto bail_out;
@@ -1206,8 +1206,8 @@ try_again:
 
    if (sleep_time) {
       Pmsg1(-1, "\nThe test worked this time. Please add:\n\n"
-                "   sleep %d\n\n"
-                "to your mtx-changer script in the load) case.\n\n",
+               "   sleep %d\n\n"
+               "to your mtx-changer script in the load) case.\n\n",
                sleep_time);
    } else {
       Pmsg0(-1, "\nThe test autochanger worked!!\n\n");
@@ -1238,10 +1238,10 @@ static void autochangercmd()
 static int fsf_test()
 {
    bool set_off = false;
-   
+
    Pmsg0(-1, _("\n\n=== Forward space files test ===\n\n"
-               "This test is essential to Bacula.\n\n"
-               "I'm going to write five files then test forward spacing\n\n"));
+              "This test is essential to Bacula.\n\n"
+              "I'm going to write five files then test forward spacing\n\n"));
    argc = 1;
    rewindcmd();
    wrcmd();
@@ -1269,7 +1269,7 @@ test_again:
       Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev));
       goto bail_out;
    }
-   Pmsg2(-1, _("We should be in file 1. I am at file %d. This is %s\n"), 
+   Pmsg2(-1, _("We should be in file 1. I am at file %d. This is %s\n"),
       dev->file, dev->file == 1 ? "correct!" : "NOT correct!!!!");
 
    if (dev->file != 1) {
@@ -1281,7 +1281,7 @@ test_again:
       Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev));
       goto bail_out;
    }
-   Pmsg2(-1, _("We should be in file 3. I am at file %d. This is %s\n"), 
+   Pmsg2(-1, _("We should be in file 3. I am at file %d. This is %s\n"),
       dev->file, dev->file == 3 ? "correct!" : "NOT correct!!!!");
 
    if (dev->file != 3) {
@@ -1294,7 +1294,7 @@ test_again:
       Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev));
       goto bail_out;
    }
-   Pmsg2(-1, _("We should be in file 4. I am at file %d. This is %s\n"), 
+   Pmsg2(-1, _("We should be in file 4. I am at file %d. This is %s\n"),
       dev->file, dev->file == 4 ? "correct!" : "NOT correct!!!!");
 
    if (dev->file != 4) {
@@ -1302,8 +1302,8 @@ test_again:
    }
    if (set_off) {
       Pmsg0(-1, "The test worked this time. Please add:\n\n"
-                "   Fast Forward Space File = no\n\n"
-                "to your Device resource for this drive.\n");
+               "   Fast Forward Space File = no\n\n"
+               "to your Device resource for this drive.\n");
    }
 
    Pmsg0(-1, "\n");
@@ -1311,7 +1311,7 @@ test_again:
    if (!fsf_dev(dev, 1)) {
       Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev));
    }
-   Pmsg2(-1, _("We should be in file 5. I am at file %d. This is %s\n"), 
+   Pmsg2(-1, _("We should be in file 5. I am at file %d. This is %s\n"),
       dev->file, dev->file == 5 ? "correct!" : "NOT correct!!!!");
    if (dev->file != 5) {
       goto bail_out;
@@ -1323,15 +1323,15 @@ bail_out:
    Pmsg0(-1, _("\nThe forward space file test failed.\n"));
    if (dev_cap(dev, CAP_FASTFSF)) {
       Pmsg0(-1, "You have Fast Forward Space File enabled.\n"
-              "I am turning it off then retrying the test.\n");
+             "I am turning it off then retrying the test.\n");
       dev->capabilities &= ~CAP_FASTFSF;
       set_off = true;
       goto test_again;
    }
    Pmsg0(-1, "You must correct this error or Bacula will not work.\n"
-            "Some systems, e.g. OpenBSD, require you to set\n"
-            "   Use MTIOCGET= no\n"
-            "in your device resource. Use with caution.\n");
+           "Some systems, e.g. OpenBSD, require you to set\n"
+           "   Use MTIOCGET= no\n"
+           "in your device resource. Use with caution.\n");
    return -2;
 }
 
@@ -1339,7 +1339,7 @@ bail_out:
 
 
 
-/* 
+/*
  * This is a general test of Bacula's functions
  *   needed to read and write the tape.
  */
@@ -1360,36 +1360,36 @@ static void testcmd()
    }
    if (stat == -1) {                 /* first test failed */
       if (dev_cap(dev, CAP_EOM) || dev_cap(dev, CAP_FASTFSF)) {
-         Pmsg0(-1, "\nAppend test failed. Attempting again.\n"
-                   "Setting \"Hardware End of Medium = no\n"
-                   "    and \"Fast Forward Space File = no\n"
-                   "and retrying append test.\n\n");
+        Pmsg0(-1, "\nAppend test failed. Attempting again.\n"
+                  "Setting \"Hardware End of Medium = no\n"
+                  "    and \"Fast Forward Space File = no\n"
+                  "and retrying append test.\n\n");
         dev->capabilities &= ~CAP_EOM; /* turn off eom */
         dev->capabilities &= ~CAP_FASTFSF; /* turn off fast fsf */
         stat = append_test();
         if (stat == 1) {
-            Pmsg0(-1, "\n\nIt looks like the test worked this time, please add:\n\n"
-                     "    Hardware End of Medium = No\n\n"
-                     "    Fast Forward Space File = No\n"
-                     "to your Device resource in the Storage conf file.\n");
+           Pmsg0(-1, "\n\nIt looks like the test worked this time, please add:\n\n"
+                    "    Hardware End of Medium = No\n\n"
+                    "    Fast Forward Space File = No\n"
+                    "to your Device resource in the Storage conf file.\n");
            goto all_done;
         }
         if (stat == -1) {
-            Pmsg0(-1, "\n\nThat appears *NOT* to have corrected the problem.\n");
+           Pmsg0(-1, "\n\nThat appears *NOT* to have corrected the problem.\n");
            goto failed;
         }
         /* Wrong count after append */
         if (stat == -2) {
-            Pmsg0(-1, "\n\nIt looks like the append failed. Attempting again.\n"
-                     "Setting \"BSF at EOM = yes\" and retrying append test.\n");
+           Pmsg0(-1, "\n\nIt looks like the append failed. Attempting again.\n"
+                    "Setting \"BSF at EOM = yes\" and retrying append test.\n");
            dev->capabilities |= CAP_BSFATEOM; /* backspace on eom */
            stat = append_test();
            if (stat == 1) {
-               Pmsg0(-1, "\n\nIt looks like the test worked this time, please add:\n\n"
-                     "    Hardware End of Medium = No\n"
-                     "    Fast Forward Space File = No\n"
-                     "    BSF at EOM = yes\n\n"
-                     "to your Device resource in the Storage conf file.\n");
+              Pmsg0(-1, "\n\nIt looks like the test worked this time, please add:\n\n"
+                    "    Hardware End of Medium = No\n"
+                    "    Fast Forward Space File = No\n"
+                    "    BSF at EOM = yes\n\n"
+                    "to your Device resource in the Storage conf file.\n");
               goto all_done;
            }
         }
@@ -1398,43 +1398,43 @@ static void testcmd()
 failed:
       Pmsg0(-1, "\nAppend test failed.\n\n");
       Pmsg0(-1, "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
-            "Unable to correct the problem. You MUST fix this\n"
-             "problem before Bacula can use your tape drive correctly\n");
+           "Unable to correct the problem. You MUST fix this\n"
+            "problem before Bacula can use your tape drive correctly\n");
       Pmsg0(-1, "\nPerhaps running Bacula in fixed block mode will work.\n"
-            "Do so by setting:\n\n"
-            "Minimum Block Size = nnn\n"
-            "Maximum Block Size = nnn\n\n"
-            "in your Storage daemon's Device definition.\n"
-            "nnn must match your tape driver's block size, which\n"
-            "can be determined by reading your tape manufacturers\n"
-            "information, and the information on your kernel dirver.\n"
-            "Fixed block sizes, however, are not normally an ideal solution.\n"
-            "\n"
-            "Some systems, e.g. OpenBSD, require you to set\n"
-            "   Use MTIOCGET= no\n"
-            "in your device resource. Use with caution.\n");
+           "Do so by setting:\n\n"
+           "Minimum Block Size = nnn\n"
+           "Maximum Block Size = nnn\n\n"
+           "in your Storage daemon's Device definition.\n"
+           "nnn must match your tape driver's block size, which\n"
+           "can be determined by reading your tape manufacturers\n"
+           "information, and the information on your kernel dirver.\n"
+           "Fixed block sizes, however, are not normally an ideal solution.\n"
+           "\n"
+           "Some systems, e.g. OpenBSD, require you to set\n"
+           "   Use MTIOCGET= no\n"
+           "in your device resource. Use with caution.\n");
        return;
    }
 
 all_done:
    Pmsg0(-1, _("\nThe above Bacula scan should have output identical to what follows.\n"
-        "Please double check it ...\n"
-        "=== Sample correct output ===\n"
-        "1 block of 64448 bytes in file 1\n"
-        "End of File mark.\n"
-        "2 blocks of 64448 bytes in file 2\n"
-        "End of File mark.\n"
-        "3 blocks of 64448 bytes in file 3\n"
-        "End of File mark.\n"
-        "1 block of 64448 bytes in file 4\n" 
-        "End of File mark.\n"
-        "Total files=4, blocks=7, bytes = 451,136\n"
-        "=== End sample correct output ===\n\n"));
+       "Please double check it ...\n"
+       "=== Sample correct output ===\n"
+       "1 block of 64448 bytes in file 1\n"
+       "End of File mark.\n"
+       "2 blocks of 64448 bytes in file 2\n"
+       "End of File mark.\n"
+       "3 blocks of 64448 bytes in file 3\n"
+       "End of File mark.\n"
+       "1 block of 64448 bytes in file 4\n"
+       "End of File mark.\n"
+       "Total files=4, blocks=7, bytes = 451,136\n"
+       "=== End sample correct output ===\n\n"));
 
    Pmsg0(-1, _("If the above scan output is not identical to the\n"
-               "sample output, you MUST correct the problem\n"
-               "or Bacula will not be able to write multiple Jobs to \n"
-               "the tape.\n\n"));
+              "sample output, you MUST correct the problem\n"
+              "or Bacula will not be able to write multiple Jobs to \n"
+              "the tape.\n\n"));
 
    if (stat == 1) {
       re_read_block_test();
@@ -1443,7 +1443,7 @@ all_done:
    fsf_test();                       /* do fast forward space file test */
 
    autochanger_test();               /* do autochanger test */
-   
+
 }
 
 /* Forward space a file */
@@ -1503,11 +1503,11 @@ static void wrcmd()
    rec->data_len = i;
    sm_check(__FILE__, __LINE__, false);
    if (!write_record_to_block(block, rec)) {
-      Pmsg0(0, _("Error writing record to block.\n")); 
+      Pmsg0(0, _("Error writing record to block.\n"));
       goto bail_out;
    }
    if (!write_block_to_dev(dcr)) {
-      Pmsg0(0, _("Error writing block to device.\n")); 
+      Pmsg0(0, _("Error writing block to device.\n"));
       goto bail_out;
    } else {
       Pmsg1(0, _("Wrote one record of %d bytes.\n"), i);
@@ -1519,7 +1519,7 @@ bail_out:
    sm_check(__FILE__, __LINE__, false);
 }
 
-/* 
+/*
  * Read a record from the tape
  */
 static void rrcmd()
@@ -1565,7 +1565,7 @@ static void scancmd()
    bytes = 0;
    if (dev->state & ST_EOT) {
       Pmsg0(0, "End of tape\n");
-      return; 
+      return;
    }
    update_pos_dev(dev);
    tot_files = dev->file;
@@ -1574,12 +1574,12 @@ static void scancmd()
       if ((stat = read(dev->fd, buf, sizeof(buf))) < 0) {
         berrno be;
         clrerror_dev(dev, -1);
-         Mmsg2(dev->errmsg, "read error on %s. ERR=%s.\n",
+        Mmsg2(dev->errmsg, "read error on %s. ERR=%s.\n",
            dev->dev_name, be.strerror());
-         Pmsg2(0, "Bad status from read %d. ERR=%s\n", stat, strerror_dev(dev));
+        Pmsg2(0, "Bad status from read %d. ERR=%s\n", stat, strerror_dev(dev));
         if (blocks > 0)
-            printf("%d block%s of %d bytes in file %d\n",        
-                    blocks, blocks>1?"s":"", block_size, dev->file);
+           printf("%d block%s of %d bytes in file %d\n",
+                   blocks, blocks>1?"s":"", block_size, dev->file);
         return;
       }
       Dmsg1(200, "read status = %d\n", stat);
@@ -1587,15 +1587,15 @@ static void scancmd()
       if (stat != block_size) {
         update_pos_dev(dev);
         if (blocks > 0) {
-            printf("%d block%s of %d bytes in file %d\n", 
-                 blocks, blocks>1?"s":"", block_size, dev->file);
+           printf("%d block%s of %d bytes in file %d\n",
+                blocks, blocks>1?"s":"", block_size, dev->file);
            blocks = 0;
         }
         block_size = stat;
       }
       if (stat == 0) {               /* EOF */
         update_pos_dev(dev);
-         printf("End of File mark.\n");
+        printf("End of File mark.\n");
         /* Two reads of zero means end of tape */
         if (dev->state & ST_EOF)
            dev->state |= ST_EOT;
@@ -1604,7 +1604,7 @@ static void scancmd()
            dev->file++;
         }
         if (dev->state & ST_EOT) {
-            printf("End of tape\n");
+           printf("End of tape\n");
            break;
         }
       } else {                       /* Got data */
@@ -1616,7 +1616,7 @@ static void scancmd()
    }
    update_pos_dev(dev);
    tot_files = dev->file - tot_files;
-   printf("Total files=%d, blocks=%d, bytes = %s\n", tot_files, tot_blocks, 
+   printf("Total files=%d, blocks=%d, bytes = %s\n", tot_files, tot_blocks,
       edit_uint64_with_commas(bytes, ec1));
 }
 
@@ -1643,40 +1643,40 @@ static void scan_blocks()
    tot_files = dev->file;
    for (;;) {
       if (!read_block_from_device(dcr, NO_BLOCK_NUMBER_CHECK)) {
-         Dmsg1(100, "!read_block(): ERR=%s\n", strerror_dev(dev));
+        Dmsg1(100, "!read_block(): ERR=%s\n", strerror_dev(dev));
         if (dev->state & ST_EOT) {
            if (blocks > 0) {
-               printf("%d block%s of %d bytes in file %d\n", 
-                    blocks, blocks>1?"s":"", block_size, dev->file);
+              printf("%d block%s of %d bytes in file %d\n",
+                   blocks, blocks>1?"s":"", block_size, dev->file);
               blocks = 0;
            }
            goto bail_out;
         }
         if (dev->state & ST_EOF) {
            if (blocks > 0) {
-               printf("%d block%s of %d bytes in file %d\n",        
-                       blocks, blocks>1?"s":"", block_size, dev->file);
+              printf("%d block%s of %d bytes in file %d\n",
+                      blocks, blocks>1?"s":"", block_size, dev->file);
               blocks = 0;
            }
-            printf(_("End of File mark.\n"));
+           printf(_("End of File mark.\n"));
            continue;
         }
         if (dev->state & ST_SHORT) {
            if (blocks > 0) {
-               printf("%d block%s of %d bytes in file %d\n",        
-                       blocks, blocks>1?"s":"", block_size, dev->file);
+              printf("%d block%s of %d bytes in file %d\n",
+                      blocks, blocks>1?"s":"", block_size, dev->file);
               blocks = 0;
            }
-            printf(_("Short block read.\n"));
+           printf(_("Short block read.\n"));
            continue;
         }
-         printf(_("Error reading block. ERR=%s\n"), strerror_dev(dev));
+        printf(_("Error reading block. ERR=%s\n"), strerror_dev(dev));
         goto bail_out;
       }
       if (block->block_len != block_size) {
         if (blocks > 0) {
-            printf("%d block%s of %d bytes in file %d\n",        
-                    blocks, blocks>1?"s":"", block_size, dev->file);
+           printf("%d block%s of %d bytes in file %d\n",
+                   blocks, blocks>1?"s":"", block_size, dev->file);
            blocks = 0;
         }
         block_size = block->block_len;
@@ -1690,20 +1690,20 @@ static void scan_blocks()
       if (verbose == 1) {
         DEV_RECORD *rec = new_record();
         read_record_from_block(block, rec);
-         Pmsg8(-1, "Blk_block: %u dev_blk=%u blen=%u First rec FI=%s SessId=%u SessTim=%u Strm=%s rlen=%d\n",
+        Pmsg8(-1, "Blk_block: %u dev_blk=%u blen=%u First rec FI=%s SessId=%u SessTim=%u Strm=%s rlen=%d\n",
              block->BlockNumber, dev->block_num, block->block_len,
              FI_to_ascii(rec->FileIndex), rec->VolSessionId, rec->VolSessionTime,
              stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len);
         rec->remainder = 0;
         free_record(rec);
       } else if (verbose > 1) {
-         dump_block(block, "");
+        dump_block(block, "");
       }
 
    }
 bail_out:
    tot_files = dev->file - tot_files;
-   printf("Total files=%d, blocks=%d, bytes = %s\n", tot_files, tot_blocks, 
+   printf("Total files=%d, blocks=%d, bytes = %s\n", tot_files, tot_blocks,
       edit_uint64_with_commas(bytes, ec1));
 }
 
@@ -1720,10 +1720,10 @@ static void statcmd()
 }
 
 
-/* 
+/*
  * First we label the tape, then we fill
  *  it with data get a new tape and write a few blocks.
- */                           
+ */
 static void fillcmd()
 {
    DEV_RECORD rec;
@@ -1740,30 +1740,30 @@ static void fillcmd()
    last_block_num = 0;
    BlockNumber = 0;
 
-   Pmsg0(-1, "\n\
-This command simulates Bacula writing to a tape.\n\
-It requires either one or two blank tapes, which it\n\
-will label and write.\n\n\
-If you have an autochanger configured, it will use\n\
-the tapes that are in slots 1 and 2, otherwise, you will\n\
-be prompted to insert the tapes when necessary.\n\n\
-It will print a status approximately\n\
-every 322 MB, and write an EOF every 3.2 GB.  If you have\n\
-selected the simple test option, after writing the first tape\n\
-it will rewind it and re-read the last block written.\n\n\
-If you have selected the multiple tape test, when the first tape\n\
-fills, it will ask for a second, and after writing a few more \n\
-blocks, it will stop.  Then it will begin re-reading the\n\
-two tapes.\n\n\
-This may take a long time -- hours! ...\n\n");
+   Pmsg0(-1, "\n"
+"This command simulates Bacula writing to a tape.\n"
+"It requires either one or two blank tapes, which it\n"
+"will label and write.\n\n"
+"If you have an autochanger configured, it will use\n"
+"the tapes that are in slots 1 and 2, otherwise, you will\n"
+"be prompted to insert the tapes when necessary.\n\n"
+"It will print a status approximately\n"
+"every 322 MB, and write an EOF every 3.2 GB.  If you have\n"
+"selected the simple test option, after writing the first tape\n"
+"it will rewind it and re-read the last block written.\n\n"
+"If you have selected the multiple tape test, when the first tape\n"
+"fills, it will ask for a second, and after writing a few more \n"
+"blocks, it will stop.  Then it will begin re-reading the\n"
+"two tapes.\n\n"
+"This may take a long time -- hours! ...\n\n");
 
    get_cmd("Do you want to run the simplified test (s) with one tape\n"
-           "or the complete multiple tape (m) test: (s/m) ");
+          "or the complete multiple tape (m) test: (s/m) ");
    if (cmd[0] == 's') {
       Pmsg0(-1, "Simple test (single tape) selected.\n");
       simple = true;
    } else if (cmd[0] == 'm') {
-      Pmsg0(-1, "Multiple tape test selected.\n"); 
+      Pmsg0(-1, "Multiple tape test selected.\n");
       simple = false;
    } else {
       Pmsg0(000, "Command aborted.\n");
@@ -1783,7 +1783,7 @@ This may take a long time -- hours! ...\n\n");
    labelcmd();
    dev->state &= ~ST_APPEND;         /* force volume to be relabeled */
 
-   /* 
+   /*
     * Acquire output device for writing.  Note, after acquiring a
     *  device, we MUST release it, which is done at the end of this
     *  subroutine.
@@ -1813,7 +1813,7 @@ This may take a long time -- hours! ...\n\n");
 #define REC_SIZE 32768
    rec.data_len = REC_SIZE;
 
-   /* 
+   /*
     * Put some random data in the record
     */
    fd = open("/dev/urandom", O_RDONLY);
@@ -1828,8 +1828,8 @@ This may take a long time -- hours! ...\n\n");
       }
    }
 
-   /* 
-    * Generate data as if from File daemon, write to device   
+   /*
+    * Generate data as if from File daemon, write to device
     */
    jcr->dcr->VolFirstIndex = 0;
    time(&jcr->run_time);             /* start counting time for rates */
@@ -1852,14 +1852,14 @@ This may take a long time -- hours! ...\n\n");
       }
 
       Dmsg4(250, "before write_rec FI=%d SessId=%d Strm=%s len=%d\n",
-        rec.FileIndex, rec.VolSessionId, stream_to_ascii(rec.Stream, rec.FileIndex), 
+        rec.FileIndex, rec.VolSessionId, stream_to_ascii(rec.Stream, rec.FileIndex),
         rec.data_len);
-       
+
       while (!write_record_to_block(block, &rec)) {
         /*
          * When we get here we have just filled a block
          */
-         Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec.data_len,
+        Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec.data_len,
                    rec.remainder);
 
         /* Write block to tape */
@@ -1876,36 +1876,36 @@ This may take a long time -- hours! ...\n\n");
               now = 1;          /* prevent divide error */
            }
            kbs = (double)dev->VolCatInfo.VolCatBytes / (1000.0 * (double)now);
-            Pmsg4(-1, "Wrote blk_block=%u, dev_blk_num=%u VolBytes=%s rate=%.1f KB/s\n", 
+           Pmsg4(-1, "Wrote blk_block=%u, dev_blk_num=%u VolBytes=%s rate=%.1f KB/s\n",
               block->BlockNumber, dev->block_num,
               edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, ec1), (float)kbs);
         }
         /* Every 15000 blocks (approx 1GB) write an EOF.
          */
         if ((block->BlockNumber % 15000) == 0) {
-            Pmsg0(-1, "Flush block, write EOF\n");
+           Pmsg0(-1, "Flush block, write EOF\n");
            flush_block(block, 0);
            weof_dev(dev, 1);
         }
 
         /* Get out after writing 10 blocks to the second tape */
         if (++BlockNumber > 10 && stop != 0) {      /* get out */
-           break;    
+           break;
         }
       }
       if (!ok) {
-         Pmsg0(000, _("Not OK\n"));
+        Pmsg0(000, _("Not OK\n"));
         break;
       }
       jcr->JobBytes += rec.data_len;   /* increment bytes this job */
       Dmsg4(190, "write_record FI=%s SessId=%d Strm=%s len=%d\n",
-        FI_to_ascii(rec.FileIndex), rec.VolSessionId, 
+        FI_to_ascii(rec.FileIndex), rec.VolSessionId,
         stream_to_ascii(rec.Stream, rec.FileIndex), rec.data_len);
 
       /* Get out after writing 10 blocks to the second tape */
       if (BlockNumber > 10 && stop != 0) {     /* get out */
-         Pmsg0(-1, "Done writing ...\n");
-        break;    
+        Pmsg0(-1, "Done writing ...\n");
+        break;
       }
    }
    if (vol_num > 1) {
@@ -1917,12 +1917,12 @@ This may take a long time -- hours! ...\n\n");
         set_jcr_job_status(jcr, JS_ErrorTerminated);
       }
       if (!write_session_label(dcr, EOS_LABEL)) {
-         Pmsg1(000, _("Error writting end session label. ERR=%s\n"), strerror_dev(dev));
+        Pmsg1(000, _("Error writting end session label. ERR=%s\n"), strerror_dev(dev));
         ok = false;
       }
       /* Write out final block of this session */
       if (!write_block_to_device(dcr)) {
-         Pmsg0(-1, _("Set ok=false after write_block_to_device.\n"));
+        Pmsg0(-1, _("Set ok=false after write_block_to_device.\n"));
         ok = false;
       }
       Pmsg0(-1, _("Wrote End of Session label.\n"));
@@ -1989,7 +1989,7 @@ static void unfillcmd()
    sprintf(buf, "%s/btape.state", working_directory);
    fd = open(buf, O_RDONLY);
    if (fd >= 0) {
-      uint32_t state_level;             
+      uint32_t state_level;
       read(fd, &state_level, sizeof(btape_state_level));
       read(fd, &simple, sizeof(simple));
       read(fd, &last_block_num1, sizeof(last_block_num1));
@@ -2001,14 +2001,14 @@ static void unfillcmd()
       read(fd, first_block->buf, first_block->buf_len);
       close(fd);
       if (state_level != btape_state_level) {
-          Pmsg0(-1, "\nThe state file level has changed. You must redo\n"
-                  "the fill command.\n");
+         Pmsg0(-1, "\nThe state file level has changed. You must redo\n"
+                 "the fill command.\n");
          return;
        }
    } else {
       berrno be;
       Pmsg2(-1, "\nCould not find the state file: %s ERR=%s\n"
-             "You must redo the fill command.\n", buf, be.strerror());
+            "You must redo the fill command.\n", buf, be.strerror());
       return;
    }
    do_unfill();
@@ -2049,7 +2049,7 @@ static void do_unfill()
       autochanger = autoload_device(dcr, 1, NULL);
       if (!autochanger) {
         force_close_dev(dev);
-         get_cmd(_("Mount first tape. Press enter when ready: ")); 
+        get_cmd(_("Mount first tape. Press enter when ready: "));
       }
       free_vol_list(jcr);
       jcr->dcr = new_dcr(jcr, dev);
@@ -2060,13 +2060,13 @@ static void do_unfill()
       dev->state &= ~(ST_READ|ST_APPEND);
       dev->num_writers = 0;
       if (!acquire_device_for_read(jcr)) {
-         Pmsg1(-1, "%s", dev->errmsg);
+        Pmsg1(-1, "%s", dev->errmsg);
         goto bail_out;
       }
    }
    /*
     * We now have the first tape mounted.
-    * Note, re-reading last block may have caused us to 
+    * Note, re-reading last block may have caused us to
     *  loose track of where we are (block number unknown).
     */
    if (!rewind_dev(dev)) {               /* get to a known place on tape */
@@ -2089,9 +2089,9 @@ static void do_unfill()
    }
    if (compare_blocks(last_block, block)) {
       if (simple) {
-         Pmsg0(-1, _("\nThe last block on the tape matches. Test succeeded.\n\n"));
+        Pmsg0(-1, _("\nThe last block on the tape matches. Test succeeded.\n\n"));
       } else {
-         Pmsg0(-1, _("\nThe last block of the first tape matches.\n\n"));
+        Pmsg0(-1, _("\nThe last block of the first tape matches.\n\n"));
       }
    }
    if (simple) {
@@ -2116,7 +2116,7 @@ static void do_unfill()
    autochanger = autoload_device(dcr, 1, NULL);
    if (!autochanger) {
       force_close_dev(dev);
-      get_cmd(_("Mount second tape. Press enter when ready: ")); 
+      get_cmd(_("Mount second tape. Press enter when ready: "));
    }
 
    dev->state &= ~ST_READ;
@@ -2180,13 +2180,13 @@ static bool quickie_cb(DCR *dcr, DEV_RECORD *rec)
    return quickie_count < 1000;
 }
 
-static bool compare_blocks(DEV_BLOCK *last_block, DEV_BLOCK *block) 
+static bool compare_blocks(DEV_BLOCK *last_block, DEV_BLOCK *block)
 {
    char *p, *q;
    uint32_t CheckSum, block_len;
    ser_declare;
 
-   p = last_block->buf;      
+   p = last_block->buf;
    q = block->buf;
    unser_begin(q, BLKHDR2_LENGTH);
    unser_uint32(CheckSum);
@@ -2203,9 +2203,9 @@ static bool compare_blocks(DEV_BLOCK *last_block, DEV_BLOCK *block)
       dump_block(block, _("Block read back"));
       Pmsg1(-1, "\n\nThe blocks differ at byte %u\n", p - last_block->buf);
       Pmsg0(-1, "\n\n!!!! The last block written and the block\n"
-                "that was read back differ. The test FAILED !!!!\n"
-                "This must be corrected before you use Bacula\n"
-                "to write multi-tape Volumes.!!!!\n");
+               "that was read back differ. The test FAILED !!!!\n"
+               "This must be corrected before you use Bacula\n"
+               "to write multi-tape Volumes.!!!!\n");
       return false;
    }
    if (verbose) {
@@ -2241,12 +2241,12 @@ static int flush_block(DEV_BLOCK *block, int dump)
    this_file = dev->file;
    this_block_num = dev->block_num;
    if (!write_block_to_dev(dcr)) {
-      Pmsg3(000, "Last block at: %u:%u this_dev_block_num=%d\n", 
+      Pmsg3(000, "Last block at: %u:%u this_dev_block_num=%d\n",
                  last_file, last_block_num, this_block_num);
       if (vol_num == 1) {
-        /* 
+        /*
          * This is 1st tape, so save first tape info separate
-         *  from second tape info 
+         *  from second tape info
          */
         last_block_num1 = last_block_num;
         last_file1 = last_file;
@@ -2255,11 +2255,11 @@ static int flush_block(DEV_BLOCK *block, int dump)
         first_block = dup_block(block); /* first block second tape */
       }
       if (verbose) {
-         Pmsg3(000, "Block not written: FileIndex=%u blk_block=%u Size=%u\n", 
+        Pmsg3(000, "Block not written: FileIndex=%u blk_block=%u Size=%u\n",
            (unsigned)file_index, block->BlockNumber, block->block_len);
-         dump_block(last_block, "Last block written");
-         Pmsg0(-1, "\n");
-         dump_block(block, "Block not written");
+        dump_block(last_block, "Last block written");
+        Pmsg0(-1, "\n");
+        dump_block(block, "Block not written");
       }
       if (stop == 0) {
         eot_block = block->BlockNumber;
@@ -2270,11 +2270,11 @@ static int flush_block(DEV_BLOCK *block, int dump)
       now = time(NULL);
       now -= jcr->run_time;
       if (now <= 0) {
-         now = 1;                     /* don't divide by zero */
+        now = 1;                     /* don't divide by zero */
       }
       kbs = (double)dev->VolCatInfo.VolCatBytes / (1000 * now);
       vol_size = dev->VolCatInfo.VolCatBytes;
-      Pmsg4(000, "End of tape %d:%d. VolumeCapacity=%s. Write rate = %.1f KB/s\n", 
+      Pmsg4(000, "End of tape %d:%d. VolumeCapacity=%s. Write rate = %.1f KB/s\n",
         dev->file, dev->block_num,
         edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, ec1), kbs);
 
@@ -2283,7 +2283,7 @@ static int flush_block(DEV_BLOCK *block, int dump)
       } else {
         /* Full test in progress */
         if (!fixup_device_block_write_error(jcr->dcr)) {
-            Pmsg1(000, _("Cannot fixup device error. %s\n"), strerror_dev(dev));
+           Pmsg1(000, _("Cannot fixup device error. %s\n"), strerror_dev(dev));
            ok = false;
            unlock_device(dev);
            return 0;
@@ -2301,10 +2301,10 @@ static int flush_block(DEV_BLOCK *block, int dump)
     * Note, we always read/write to block, but we toggle
     *  copying it to one or another of two allocated blocks.
     * Switch blocks so that the block just successfully written is
-    *  always in last_block. 
+    *  always in last_block.
     */
    tblock = last_block;
-   last_block = this_block; 
+   last_block = this_block;
    this_block = tblock;
    last_file = this_file;
    last_block_num = this_block_num;
@@ -2314,10 +2314,10 @@ static int flush_block(DEV_BLOCK *block, int dump)
 }
 
 
-/* 
+/*
  * First we label the tape, then we fill
  *  it with data get a new tape and write a few blocks.
- */                           
+ */
 static void qfillcmd()
 {
    DEV_BLOCK *block = dcr->block;
@@ -2344,15 +2344,15 @@ static void qfillcmd()
    Pmsg1(0, "Begin writing %d Bacula blocks to tape ...\n", count);
    for (i=0; i < count; i++) {
       if (i % 100 == 0) {
-         printf("+");
+        printf("+");
         fflush(stdout);
       }
       if (!write_record_to_block(block, rec)) {
-         Pmsg0(0, _("Error writing record to block.\n")); 
+        Pmsg0(0, _("Error writing record to block.\n"));
         goto bail_out;
       }
       if (!write_block_to_dev(dcr)) {
-         Pmsg0(0, _("Error writing block to device.\n")); 
+        Pmsg0(0, _("Error writing block to device.\n"));
         goto bail_out;
       }
    }
@@ -2399,7 +2399,7 @@ static void rawfill_cmd()
       stat = write(dev->fd, block->buf, block->buf_len);
       if (stat == (int)block->buf_len) {
         if ((block_num++ % 100) == 0) {
-            printf("+");
+           printf("+");
            fflush(stdout);
         }
         p[0] += p[13];
@@ -2428,7 +2428,7 @@ static void bfill_cmd()
    uint32_t block_num = 0;
    uint32_t *p;
    int my_errno;
-   int fd;   
+   int fd;
    uint32_t i;
 
    fd = open("/dev/urandom", O_RDONLY);
@@ -2452,7 +2452,7 @@ static void bfill_cmd()
         break;
       }
       if ((block_num++ % 100) == 0) {
-         printf("+");
+        printf("+");
         fflush(stdout);
       }
       p[0] += p[13];
@@ -2462,12 +2462,12 @@ static void bfill_cmd()
    }
    my_errno = errno;
    printf("\n");
-   printf("Write failed at block %u.\n", block_num);     
+   printf("Write failed at block %u.\n", block_num);
    weofcmd();
 }
 
 
-struct cmdstruct { const char *key; void (*func)(); const char *help; }; 
+struct cmdstruct { const char *key; void (*func)(); const char *help; };
 static struct cmdstruct commands[] = {
  {"autochanger", autochangercmd, "test autochanger"},
  {"bsf",        bsfcmd,       "backspace file"},
@@ -2484,17 +2484,17 @@ static struct cmdstruct commands[] = {
  {"help",       helpcmd,      "print this command"},
  {"label",      labelcmd,     "write a Bacula label to the tape"},
  {"load",       loadcmd,      "load a tape"},
- {"quit",       quitcmd,      "quit btape"},   
+ {"quit",       quitcmd,      "quit btape"},
  {"rawfill",    rawfill_cmd,  "use write() to fill tape"},
  {"readlabel",  readlabelcmd, "read and print the Bacula tape label"},
  {"rectest",    rectestcmd,   "test record handling functions"},
  {"rewind",     rewindcmd,    "rewind the tape"},
- {"scan",       scancmd,      "read() tape block by block to EOT and report"}, 
+ {"scan",       scancmd,      "read() tape block by block to EOT and report"},
  {"scanblocks", scan_blocks,  "Bacula read block by block to EOT and report"},
  {"status",     statcmd,      "print tape status"},
  {"test",       testcmd,      "General test Bacula tape functions"},
  {"weof",       weofcmd,      "write an EOF on the tape"},
- {"wr",         wrcmd,        "write a single Bacula block"}, 
+ {"wr",         wrcmd,        "write a single Bacula block"},
  {"rr",         rrcmd,        "read a single record"},
  {"qfill",      qfillcmd,     "quick fill command"},
             };
@@ -2517,7 +2517,7 @@ do_tape_cmds()
            break;
         }
       if (!found)
-         Pmsg1(0, _("%s is an illegal command\n"), cmd);
+        Pmsg1(0, _("%s is an illegal command\n"), cmd);
       if (quit)
         break;
    }
@@ -2546,17 +2546,17 @@ static void usage()
 "       -p          proceed inspite of I/O errors\n"
 "       -s          turn off signals\n"
 "       -v          be verbose\n"
-"       -?          print this message.\n"  
+"       -?          print this message.\n"
 "\n"));
 
 }
 
-/*     
+/*
  * Get next input command from terminal.  This
  * routine is REALLY primitive, and should be enhanced
  * to have correct backspacing, etc.
  */
-int 
+int
 get_cmd(const char *prompt)
 {
    int i = 0;
@@ -2567,7 +2567,7 @@ get_cmd(const char *prompt)
     * up a bit.
     */
    cmd[i] = 0;
-   while ((ch = fgetc(stdin)) != EOF) { 
+   while ((ch = fgetc(stdin)) != EOF) {
       if (ch == '\n') {
         strip_trailing_junk(cmd);
         return 1;
@@ -2575,8 +2575,8 @@ get_cmd(const char *prompt)
         if (i > 0)
            cmd[--i] = 0;
         continue;
-      } 
-        
+      }
+
       cmd[i++] = ch;
       cmd[i] = 0;
    }
@@ -2588,13 +2588,13 @@ get_cmd(const char *prompt)
 bool   dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
 bool   dir_send_job_status(JCR *jcr) {return 1;}
 
-bool dir_update_volume_info(DCR *dcr, bool relabel) 
-{ 
+bool dir_update_volume_info(DCR *dcr, bool relabel)
+{
    return 1;
 }
 
 
-bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw  writing)            
+bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw  writing)
 {
    Dmsg0(20, "Enter dir_get_volume_info\n");
    bstrncpy(dcr->VolCatInfo.VolCatName, dcr->VolumeName, sizeof(dcr->VolCatInfo.VolCatName));
@@ -2608,8 +2608,8 @@ bool dir_create_jobmedia_record(DCR *dcr)
 }
 
 
-bool dir_find_next_appendable_volume(DCR *dcr) 
-{ 
+bool dir_find_next_appendable_volume(DCR *dcr)
+{
    Dmsg1(20, "Enter dir_find_next_appendable_volume. stop=%d\n", stop);
    return dcr->VolumeName[0] != 0;
 }
@@ -2634,7 +2634,7 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr)
       fprintf(stderr, "Mount Volume \"%s\" on device %s and press return when ready: ",
         dcr->VolumeName, dev_name(dev));
    }
-   getchar();  
+   getchar();
    return true;
 }
 
@@ -2657,7 +2657,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr)
       force_close_dev(dev);
       fprintf(stderr, "Mount blank Volume on device %s and press return when ready: ",
         dev_name(dev));
-      getchar();   
+      getchar();
    }
    open_device(dcr);
    labelcmd();
@@ -2698,7 +2698,7 @@ static bool my_mount_next_read_volume(DCR *dcr)
    jcr->bsr = NULL;
    create_vol_list(jcr);
    close_dev(dev);
-   dev->state &= ~ST_READ; 
+   dev->state &= ~ST_READ;
    if (!acquire_device_for_read(jcr)) {
       Pmsg2(0, "Cannot open Dev=%s, Vol=%s\n", dev_name(dev), dcr->VolumeName);
       return false;
@@ -2706,7 +2706,7 @@ static bool my_mount_next_read_volume(DCR *dcr)
    return true;                   /* next volume mounted */
 }
 
-static void set_volume_name(const char *VolName, int volnum) 
+static void set_volume_name(const char *VolName, int volnum)
 {
    DCR *dcr = jcr->dcr;
    VolumeName = VolName;
index 654a4cd9c0341761e5436d9eb12fd511f5cd9f0a..2fae0494d3cae600f6d184821c7472c2e473d9f5 100644 (file)
@@ -4,8 +4,8 @@
  *    bextract, ...  Some routines also used by Bacula.
  *
  *    Kern Sibbald, MM
- * 
- *  Normally nothing in this file is called by the Storage   
+ *
+ *  Normally nothing in this file is called by the Storage
  *    daemon because we interact more directly with the user
  *    i.e. printf, ...
  *
@@ -45,7 +45,7 @@ extern char *configfile;
 #ifdef DEBUG
 char *rec_state_to_str(DEV_RECORD *rec)
 {
-   static char buf[200]; 
+   static char buf[200];
    buf[0] = 0;
    if (rec->state & REC_NO_HEADER) {
       strcat(buf, "Nohdr,");
@@ -124,7 +124,7 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name, const char *VolumeN
 
    /*
     * If no volume name already given and no bsr, and it is a file,
-    * try getting name from Filename  
+    * try getting name from Filename
     */
    if (VolumeName) {
       bstrncpy(VolName, VolumeName, sizeof(VolName));
@@ -136,9 +136,9 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name, const char *VolumeN
         /* Try stripping file part */
         p = dev_name + strlen(dev_name);
 
-         while (p >= dev_name && *p != '/')
+        while (p >= dev_name && *p != '/')
            p--;
-         if (*p == '/') {
+        if (*p == '/') {
            bstrncpy(VolName, p+1, sizeof(VolName));
            *p = 0;
         }
@@ -146,19 +146,19 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name, const char *VolumeN
    }
 
    if ((device=find_device_res(dev_name, mode)) == NULL) {
-      Jmsg2(jcr, M_FATAL, 0, _("Cannot find device \"%s\" in config file %s.\n"), 
+      Jmsg2(jcr, M_FATAL, 0, _("Cannot find device \"%s\" in config file %s.\n"),
           dev_name, configfile);
       return NULL;
    }
    jcr->device = device;
-   
+
    dev = init_dev(NULL, device);
    if (!dev) {
       Jmsg1(jcr, M_FATAL, 0, _("Cannot init device %s\n"), dev_name);
       return NULL;
    }
    device->dev = dev;
-   dcr = new_dcr(jcr, dev);       
+   dcr = new_dcr(jcr, dev);
    if (VolName[0]) {
       bstrncpy(dcr->VolumeName, VolName, sizeof(dcr->VolumeName));
    }
@@ -181,7 +181,7 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name, const char *VolumeN
 
 
 /*
- * Called here when freeing JCR so that we can get rid 
+ * Called here when freeing JCR so that we can get rid
  *  of "daemon" specific memory allocated.
  */
 static void my_free_jcr(JCR *jcr)
@@ -204,7 +204,7 @@ static void my_free_jcr(JCR *jcr)
    }
    if (jcr->VolList) {
       free_vol_list(jcr);
-   }  
+   }
    if (jcr->dcr) {
       free_dcr(jcr->dcr);
       jcr->dcr = NULL;
@@ -214,9 +214,9 @@ static void my_free_jcr(JCR *jcr)
 
 
 /*
- * Search for device resource that corresponds to 
+ * Search for device resource that corresponds to
  * device name on command line (or default).
- *      
+ *
  * Returns: NULL on failure
  *         Device resource pointer on success
  */
@@ -231,14 +231,14 @@ static DEVRES *find_device_res(char *device_name, int read_access)
         found = true;
         break;
       }
-   } 
+   }
    if (!found) {
       /* Search for name of Device resource rather than archive name */
       if (device_name[0] == '"') {
         strcpy(device_name, device_name+1);
         int len = strlen(device_name);
         if (len > 0) {
-            device_name[len-1] = 0;   /* zap trailing " */
+           device_name[len-1] = 0;   /* zap trailing " */
         }
       }
       foreach_res(device, R_DEVICE) {
@@ -246,7 +246,7 @@ static DEVRES *find_device_res(char *device_name, int read_access)
            found = true;
            break;
         }
-      } 
+      }
    }
    UnlockRes();
    if (!found) {
@@ -255,7 +255,7 @@ static DEVRES *find_device_res(char *device_name, int read_access)
       return NULL;
    }
    Pmsg2(0, _("Using device: \"%s\" for %s.\n"), device_name,
-             read_access?"reading":"writing");
+            read_access?"reading":"writing");
    return device;
 }
 
index baf1e2085baade5d3e98bd8e88292b6dc1ae50d6..b8967bfb292ff6d8a6324cfea5a472c4761d9b2b 100644 (file)
@@ -2,20 +2,20 @@
  *
  *   dev.c  -- low level operations on device (storage device)
  *
- *             Kern Sibbald, MM 
+ *             Kern Sibbald, MM
  *
  *     NOTE!!!! None of these routines are reentrant. You must
  *       use lock_device() and unlock_device() at a higher level,
  *       or use the xxx_device() equivalents.  By moving the
  *       thread synchronization to a higher level, we permit
- *        the higher level routines to "seize" the device and 
+ *        the higher level routines to "seize" the device and
  *       to carry out operations without worrying about who
  *       set what lock (i.e. race conditions).
  *
  *     Note, this is the device dependent code, and my have
  *          to be modified for each system, but is meant to
  *           be as "generic" as possible.
- * 
+ *
  *     The purpose of this code is to develop a SIMPLE Storage
  *     daemon. More complicated coding (double buffering, writer
  *     thread, ...) is left for a later version.
  * be able to read and write the tape (he sort of tunnels through
  * the locking mechanism -- see lock_dev() for details).
  *
- * Now presumably somewhere higher in the chain of command 
- * (device.c), someone will notice the EOT condition and 
- * get a new tape up, get the tape label read, and mark 
- * the label for rewriting. Then this higher level routine 
+ * Now presumably somewhere higher in the chain of command
+ * (device.c), someone will notice the EOT condition and
+ * get a new tape up, get the tape label read, and mark
+ * the label for rewriting. Then this higher level routine
  * will write the unwritten buffer to the new volume.
  * Finally, he will release
  * any blocked threads by doing a broadcast on the condition
- * variable.  At that point, we should be totally back in 
+ * variable.  At that point, we should be totally back in
  * business with no lost data.
  */
 
@@ -83,7 +83,7 @@
 /* Forward referenced functions */
 void set_os_device_parameters(DEVICE *dev);
 
-/* 
+/*
  * Allocate and initialize the DEVICE structure
  * Note, if dev is non-NULL, it is already allocated,
  * thus we neither allocate it nor free it. This allows
@@ -107,8 +107,8 @@ init_dev(DEVICE *dev, DEVRES *device)
       berrno be;
       if (dev) {
         dev->dev_errno = errno;
-      } 
-      Emsg2(M_FATAL, 0, "Unable to stat device %s : %s\n", device->device_name, 
+      }
+      Emsg2(M_FATAL, 0, "Unable to stat device %s : %s\n", device->device_name,
            be.strerror());
       return NULL;
    }
@@ -167,15 +167,15 @@ init_dev(DEVICE *dev, DEVRES *device)
    }
 
    if (dev->max_block_size > 1000000) {
-      Emsg3(M_ERROR, 0, _("Block size %u on device %s is too large, using default %u\n"), 
+      Emsg3(M_ERROR, 0, _("Block size %u on device %s is too large, using default %u\n"),
         dev->max_block_size, dev->dev_name, DEFAULT_BLOCK_SIZE);
       dev->max_block_size = 0;
    }
    if (dev->max_block_size % TAPE_BSIZE != 0) {
       Emsg2(M_WARNING, 0, _("Max block size %u not multiple of device %s block size.\n"),
         dev->max_block_size, dev->dev_name);
-   }   
-        
+   }
+
    dev->errmsg = get_pool_memory(PM_EMSG);
    *dev->errmsg = 0;
 
@@ -242,7 +242,7 @@ open_dev(DEVICE *dev, char *VolName, int mode)
         return -1;
       }
       dev->use_count++;
-      Mmsg2(&dev->errmsg, _("WARNING!!!! device %s opened %d times!!!\n"), 
+      Mmsg2(&dev->errmsg, _("WARNING!!!! device %s opened %d times!!!\n"),
            dev->dev_name, dev->use_count);
       Emsg1(M_WARNING, 0, "%s", dev->errmsg);
       return dev->fd;
@@ -251,7 +251,7 @@ open_dev(DEVICE *dev, char *VolName, int mode)
       bstrncpy(dev->VolCatInfo.VolCatName, VolName, sizeof(dev->VolCatInfo.VolCatName));
    }
 
-   Dmsg3(29, "open_dev: tape=%d dev_name=%s vol=%s\n", dev_is_tape(dev), 
+   Dmsg3(29, "open_dev: tape=%d dev_name=%s vol=%s\n", dev_is_tape(dev),
         dev->dev_name, dev->VolCatInfo.VolCatName);
    dev->state &= ~(ST_LABEL|ST_APPEND|ST_READ|ST_EOT|ST_WEOT|ST_EOF);
    dev->file_size = 0;
@@ -265,7 +265,7 @@ open_dev(DEVICE *dev, char *VolName, int mode)
       } else if (mode == OPEN_WRITE_ONLY) {
         dev->mode = O_WRONLY | O_BINARY;
       } else {
-         Emsg0(M_ABORT, 0, _("Illegal mode given to open_dev.\n")); 
+        Emsg0(M_ABORT, 0, _("Illegal mode given to open_dev.\n"));
       }
       timeout = dev->max_open_wait;
       errno = 0;
@@ -280,12 +280,12 @@ open_dev(DEVICE *dev, char *VolName, int mode)
            continue;
         }
         if (errno == EBUSY && timeout-- > 0) {
-            Dmsg2(100, "Device %s busy. ERR=%s\n", dev->dev_name, be.strerror());
+           Dmsg2(100, "Device %s busy. ERR=%s\n", dev->dev_name, be.strerror());
            bmicrosleep(1, 0);
            continue;
         }
         dev->dev_errno = errno;
-         Mmsg2(&dev->errmsg, _("stored: unable to open device %s: ERR=%s\n"), 
+        Mmsg2(&dev->errmsg, _("stored: unable to open device %s: ERR=%s\n"),
               dev->dev_name, be.strerror());
         /* Stop any open timer we set */
         if (dev->tid) {
@@ -313,14 +313,14 @@ open_dev(DEVICE *dev, char *VolName, int mode)
        * Handle opening of File Archive (not a tape)
        */
       if (VolName == NULL || *VolName == 0) {
-         Mmsg(dev->errmsg, _("Could not open file device %s. No Volume name given.\n"),
+        Mmsg(dev->errmsg, _("Could not open file device %s. No Volume name given.\n"),
            dev->dev_name);
         return -1;
       }
       archive_name = get_pool_memory(PM_FNAME);
       pm_strcpy(archive_name, dev->dev_name);
       if (archive_name[strlen(archive_name)] != '/') {
-         pm_strcat(archive_name, "/");
+        pm_strcat(archive_name, "/");
       }
       pm_strcat(archive_name, VolName);
       Dmsg1(29, "open_dev: device is disk %s\n", archive_name);
@@ -331,13 +331,13 @@ open_dev(DEVICE *dev, char *VolName, int mode)
       } else if (mode == OPEN_WRITE_ONLY) {
         dev->mode = O_WRONLY | O_BINARY;
       } else {
-         Emsg0(M_ABORT, 0, _("Illegal mode given to open_dev.\n")); 
+        Emsg0(M_ABORT, 0, _("Illegal mode given to open_dev.\n"));
       }
       /* If creating file, give 0640 permissions */
       if ((dev->fd = open(archive_name, dev->mode, 0640)) < 0) {
         berrno be;
         dev->dev_errno = errno;
-         Mmsg2(&dev->errmsg, _("Could not open: %s, ERR=%s\n"), archive_name, be.strerror());
+        Mmsg2(&dev->errmsg, _("Could not open: %s, ERR=%s\n"), archive_name, be.strerror());
         Emsg0(M_FATAL, 0, dev->errmsg);
       } else {
         dev->dev_errno = 0;
@@ -395,14 +395,14 @@ bool rewind_dev(DEVICE *dev)
            berrno be;
            clrerror_dev(dev, MTREW);
            if (i == dev->max_rewind_wait) {
-               Dmsg1(200, "Rewind error, %s. retrying ...\n", be.strerror());
+              Dmsg1(200, "Rewind error, %s. retrying ...\n", be.strerror());
            }
            if (dev->dev_errno == EIO && i > 0) {
-               Dmsg0(200, "Sleeping 5 seconds.\n");
+              Dmsg0(200, "Sleeping 5 seconds.\n");
               bmicrosleep(5, 0);
               continue;
            }
-            Mmsg2(&dev->errmsg, _("Rewind error on %s. ERR=%s.\n"),
+           Mmsg2(&dev->errmsg, _("Rewind error on %s. ERR=%s.\n"),
               dev->dev_name, be.strerror());
            return false;
         }
@@ -412,7 +412,7 @@ bool rewind_dev(DEVICE *dev)
       if (lseek(dev->fd, (off_t)0, SEEK_SET) < 0) {
         berrno be;
         dev->dev_errno = errno;
-         Mmsg2(&dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
+        Mmsg2(&dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
            dev->dev_name, be.strerror());
         return false;
       }
@@ -420,12 +420,12 @@ bool rewind_dev(DEVICE *dev)
    return true;
 }
 
-/* 
+/*
  * Position device to end of medium (end of data)
  *  Returns: 1 on succes
  *          0 on error
  */
-int 
+int
 eod_dev(DEVICE *dev)
 {
    struct mtop mt_com;
@@ -481,7 +481,7 @@ eod_dev(DEVICE *dev)
 
    if (dev_cap(dev, CAP_MTIOCGET) && (dev_cap(dev, CAP_FASTFSF) || dev_cap(dev, CAP_EOM))) {
       if (dev_cap(dev, CAP_EOM)) {
-         Dmsg0(100,"Using EOM for EOM\n");
+        Dmsg0(100,"Using EOM for EOM\n");
         mt_com.mt_op = MTEOM;
         mt_com.mt_count = 1;
       }
@@ -489,9 +489,9 @@ eod_dev(DEVICE *dev)
       if ((stat=ioctl(dev->fd, MTIOCTOP, (char *)&mt_com)) < 0) {
         berrno be;
         clrerror_dev(dev, mt_com.mt_op);
-         Dmsg1(50, "ioctl error: %s\n", be.strerror());
+        Dmsg1(50, "ioctl error: %s\n", be.strerror());
         update_pos_dev(dev);
-         Mmsg2(&dev->errmsg, _("ioctl MTEOM error on %s. ERR=%s.\n"),
+        Mmsg2(&dev->errmsg, _("ioctl MTEOM error on %s. ERR=%s.\n"),
            dev->dev_name, be.strerror());
         return 0;
       }
@@ -499,7 +499,7 @@ eod_dev(DEVICE *dev)
       if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) < 0) {
         berrno be;
         clrerror_dev(dev, -1);
-         Mmsg2(&dev->errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
+        Mmsg2(&dev->errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
            dev->dev_name, be.strerror());
         return 0;
       }
@@ -516,14 +516,14 @@ eod_dev(DEVICE *dev)
       if (!rewind_dev(dev)) {
         return 0;
       }
-      /* 
+      /*
        * Move file by file to the end of the tape
        */
       int file_num;
       for (file_num=dev->file; !(dev->state & ST_EOT); file_num++) {
-         Dmsg0(200, "eod_dev: doing fsf 1\n");
+        Dmsg0(200, "eod_dev: doing fsf 1\n");
         if (!fsf_dev(dev, 1)) {
-            Dmsg0(200, "fsf_dev error.\n");
+           Dmsg0(200, "fsf_dev error.\n");
            return 0;
         }
         /*
@@ -532,10 +532,10 @@ eod_dev(DEVICE *dev)
          */
         if (file_num == (int)dev->file) {
            struct mtget mt_stat;
-            Dmsg1(100, "fsf_dev did not advance from file %d\n", file_num);
-           if (dev_cap(dev, CAP_MTIOCGET) && ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 && 
+           Dmsg1(100, "fsf_dev did not advance from file %d\n", file_num);
+           if (dev_cap(dev, CAP_MTIOCGET) && ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 &&
                      mt_stat.mt_fileno >= 0) {
-               Dmsg2(100, "Adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno);
+              Dmsg2(100, "Adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno);
               dev->file = mt_stat.mt_fileno;
            }
            stat = 0;
@@ -554,7 +554,7 @@ eod_dev(DEVICE *dev)
       stat = bsf_dev(dev, 1);
       /* If BSF worked and fileno is known (not -1), set file */
       if (dev_cap(dev, CAP_MTIOCGET) && ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 && mt_stat.mt_fileno >= 0) {
-         Dmsg2(100, "BSFATEOF adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno);
+        Dmsg2(100, "BSFATEOF adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno);
         dev->file = mt_stat.mt_fileno;
       } else {
         dev->file++;                 /* wing it -- not correct on all OSes */
@@ -593,8 +593,8 @@ bool update_pos_dev(DEVICE *dev)
       if (pos < 0) {
         berrno be;
         dev->dev_errno = errno;
-         Pmsg1(000, "Seek error: ERR=%s\n", be.strerror());
-         Mmsg2(&dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
+        Pmsg1(000, "Seek error: ERR=%s\n", be.strerror());
+        Mmsg2(&dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
            dev->dev_name, be.strerror());
         ok = false;
       } else {
@@ -605,7 +605,7 @@ bool update_pos_dev(DEVICE *dev)
 }
 
 
-/* 
+/*
  * Return the status of the device.  This was meant
  * to be a generic routine. Unfortunately, it doesn't
  * seem possible (at least I do not know how to do it
@@ -634,7 +634,7 @@ uint32_t status_dev(DEVICE *dev)
       if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) < 0) {
         berrno be;
         dev->dev_errno = errno;
-         Mmsg2(&dev->errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
+        Mmsg2(&dev->errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
            dev->dev_name, be.strerror());
         return 0;
       }
@@ -643,45 +643,45 @@ uint32_t status_dev(DEVICE *dev)
 #if defined(HAVE_LINUX_OS)
       if (GMT_EOF(mt_stat.mt_gstat)) {
         stat |= BMT_EOF;
-         Dmsg0(-20, " EOF");
+        Dmsg0(-20, " EOF");
       }
       if (GMT_BOT(mt_stat.mt_gstat)) {
         stat |= BMT_BOT;
-         Dmsg0(-20, " BOT");
+        Dmsg0(-20, " BOT");
       }
       if (GMT_EOT(mt_stat.mt_gstat)) {
         stat |= BMT_EOT;
-         Dmsg0(-20, " EOT");
+        Dmsg0(-20, " EOT");
       }
       if (GMT_SM(mt_stat.mt_gstat)) {
         stat |= BMT_SM;
-         Dmsg0(-20, " SM");
+        Dmsg0(-20, " SM");
       }
       if (GMT_EOD(mt_stat.mt_gstat)) {
         stat |= BMT_EOD;
-         Dmsg0(-20, " EOD");
+        Dmsg0(-20, " EOD");
       }
       if (GMT_WR_PROT(mt_stat.mt_gstat)) {
         stat |= BMT_WR_PROT;
-         Dmsg0(-20, " WR_PROT");
+        Dmsg0(-20, " WR_PROT");
       }
       if (GMT_ONLINE(mt_stat.mt_gstat)) {
         stat |= BMT_ONLINE;
-         Dmsg0(-20, " ONLINE");
+        Dmsg0(-20, " ONLINE");
       }
       if (GMT_DR_OPEN(mt_stat.mt_gstat)) {
         stat |= BMT_DR_OPEN;
-         Dmsg0(-20, " DR_OPEN");       
+        Dmsg0(-20, " DR_OPEN");
       }
       if (GMT_IM_REP_EN(mt_stat.mt_gstat)) {
         stat |= BMT_IM_REP_EN;
-         Dmsg0(-20, " IM_REP_EN");
+        Dmsg0(-20, " IM_REP_EN");
       }
 #endif /* !SunOS && !OSF */
       if (dev_cap(dev, CAP_MTIOCGET)) {
-         Dmsg2(-20, " file=%d block=%d\n", mt_stat.mt_fileno, mt_stat.mt_blkno);
+        Dmsg2(-20, " file=%d block=%d\n", mt_stat.mt_fileno, mt_stat.mt_blkno);
       } else {
-         Dmsg2(-20, " file=%d block=%d\n", -1, -1);
+        Dmsg2(-20, " file=%d block=%d\n", -1, -1);
       }
    } else {
       stat |= BMT_ONLINE | BMT_BOT;
@@ -784,7 +784,7 @@ bool offline_or_rewind_dev(DEVICE *dev)
    if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
       return offline_dev(dev);
    } else {
-   /*           
+   /*
     * Note, this rewind probably should not be here (it wasn't
     *  in prior versions of Bacula), but on FreeBSD, this is
     *  needed in the case the tape was "frozen" due to an error
@@ -796,14 +796,14 @@ bool offline_or_rewind_dev(DEVICE *dev)
    }
 }
 
-/* 
- * Foward space a file 
+/*
+ * Foward space a file
  *   Returns: true  on success
  *           false on failure
  */
 bool
 fsf_dev(DEVICE *dev, int num)
-{ 
+{
    struct mtget mt_stat;
    struct mtop mt_com;
    int stat = 0;
@@ -826,13 +826,13 @@ fsf_dev(DEVICE *dev, int num)
    if (dev->state & ST_EOF) {
       Dmsg0(200, "ST_EOF set on entry to FSF\n");
    }
-      
+
    Dmsg0(100, "fsf_dev\n");
    dev->block_num = 0;
    /*
     * If Fast forward space file is set, then we
     *  use MTFSF to forward space and MTIOCGET
-    *  to get the file position. We assume that 
+    *  to get the file position. We assume that
     *  the SCSI driver will ensure that we do not
     *  forward space past the end of the medium.
     */
@@ -843,11 +843,11 @@ fsf_dev(DEVICE *dev, int num)
       if (stat < 0 || ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) < 0) {
         berrno be;
         dev->state |= ST_EOT;
-         Dmsg0(200, "Set ST_EOT\n");
+        Dmsg0(200, "Set ST_EOT\n");
         clrerror_dev(dev, MTFSF);
-         Mmsg2(dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
+        Mmsg2(dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
            dev->dev_name, be.strerror());
-         Dmsg1(200, "%s", dev->errmsg);
+        Dmsg1(200, "%s", dev->errmsg);
         return false;
       }
       Dmsg2(200, "fsf file=%d block=%d\n", mt_stat.mt_fileno, mt_stat.mt_blkno);
@@ -857,7 +857,7 @@ fsf_dev(DEVICE *dev, int num)
       dev->file_size = 0;
       return true;
 
-   /* 
+   /*
     * Here if CAP_FSF is set, and virtually all drives
     *  these days support it, we read a record, then forward
     *  space one file. Using this procedure, which is slow,
@@ -877,7 +877,7 @@ fsf_dev(DEVICE *dev, int num)
       mt_com.mt_op = MTFSF;
       mt_com.mt_count = 1;
       while (num-- && !(dev->state & ST_EOT)) {
-         Dmsg0(100, "Doing read before fsf\n");
+        Dmsg0(100, "Doing read before fsf\n");
         if ((stat = read(dev->fd, (char *)rbuf, rbuf_len)) < 0) {
            if (errno == ENOMEM) {     /* tape record exceeds buf len */
               stat = rbuf_len;        /* This is OK */
@@ -885,21 +885,21 @@ fsf_dev(DEVICE *dev, int num)
               berrno be;
               dev->state |= ST_EOT;
               clrerror_dev(dev, -1);
-               Dmsg2(100, "Set ST_EOT read errno=%d. ERR=%s\n", dev->dev_errno,
+              Dmsg2(100, "Set ST_EOT read errno=%d. ERR=%s\n", dev->dev_errno,
                  be.strerror());
-               Mmsg2(dev->errmsg, _("read error on %s. ERR=%s.\n"),
+              Mmsg2(dev->errmsg, _("read error on %s. ERR=%s.\n"),
                  dev->dev_name, be.strerror());
-               Dmsg1(100, "%s", dev->errmsg);
+              Dmsg1(100, "%s", dev->errmsg);
               break;
            }
         }
         if (stat == 0) {                /* EOF */
            update_pos_dev(dev);
-            Dmsg1(100, "End of File mark from read. File=%d\n", dev->file+1);
+           Dmsg1(100, "End of File mark from read. File=%d\n", dev->file+1);
            /* Two reads of zero means end of tape */
            if (dev->state & ST_EOF) {
               dev->state |= ST_EOT;
-               Dmsg0(100, "Set ST_EOT\n");
+              Dmsg0(100, "Set ST_EOT\n");
               break;
            } else {
               dev->state |= ST_EOF;
@@ -912,26 +912,26 @@ fsf_dev(DEVICE *dev, int num)
            dev->state &= ~(ST_EOF|ST_EOT);
         }
 
-         Dmsg0(100, "Doing MTFSF\n");
+        Dmsg0(100, "Doing MTFSF\n");
         stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
         if (stat < 0) {                 /* error => EOT */
            berrno be;
            dev->state |= ST_EOT;
-            Dmsg0(100, "Set ST_EOT\n");
+           Dmsg0(100, "Set ST_EOT\n");
            clrerror_dev(dev, MTFSF);
-            Mmsg2(&dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
+           Mmsg2(&dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
               dev->dev_name, be.strerror());
-            Dmsg0(100, "Got < 0 for MTFSF\n");
-            Dmsg1(100, "%s", dev->errmsg);
+           Dmsg0(100, "Got < 0 for MTFSF\n");
+           Dmsg1(100, "%s", dev->errmsg);
         } else {
            dev->state |= ST_EOF;     /* just read EOF */
            dev->file++;
            dev->file_addr = 0;
            dev->file_size = 0;
-        }   
+        }
       }
       free_memory(rbuf);
-   
+
    /*
     * No FSF, so use FSR to simulate it
     */
@@ -942,7 +942,7 @@ fsf_dev(DEVICE *dev, int num)
       }
       if (dev->state & ST_EOT) {
         dev->dev_errno = 0;
-         Mmsg1(dev->errmsg, _("Device %s at End of Tape.\n"), dev->dev_name);
+        Mmsg1(dev->errmsg, _("Device %s at End of Tape.\n"), dev->dev_name);
         stat = -1;
       } else {
         stat = 0;
@@ -958,14 +958,14 @@ fsf_dev(DEVICE *dev, int num)
    return stat == 0;
 }
 
-/* 
- * Backward space a file  
+/*
+ * Backward space a file
  *  Returns: false on failure
  *          true  on success
  */
 bool
 bsf_dev(DEVICE *dev, int num)
-{ 
+{
    struct mtop mt_com;
    int stat;
 
@@ -1000,14 +1000,14 @@ bsf_dev(DEVICE *dev, int num)
 }
 
 
-/* 
+/*
  * Foward space a record
  *  Returns: false on failure
  *          true  on success
  */
 bool
 fsr_dev(DEVICE *dev, int num)
-{ 
+{
    struct mtop mt_com;
    int stat;
 
@@ -1039,7 +1039,7 @@ fsr_dev(DEVICE *dev, int num)
       clrerror_dev(dev, MTFSR);
       Dmsg1(100, "FSF fail: ERR=%s\n", be.strerror());
       if (dev_cap(dev, CAP_MTIOCGET) && ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 && mt_stat.mt_fileno >= 0) {
-         Dmsg4(100, "Adjust from %d:%d to %d:%d\n", dev->file, 
+        Dmsg4(100, "Adjust from %d:%d to %d:%d\n", dev->file,
            dev->block_num, mt_stat.mt_fileno, mt_stat.mt_blkno);
         dev->file = mt_stat.mt_fileno;
         dev->block_num = mt_stat.mt_blkno;
@@ -1061,14 +1061,14 @@ fsr_dev(DEVICE *dev, int num)
    return stat == 0;
 }
 
-/* 
+/*
  * Backward space a record
  *   Returns:  false on failure
  *            true  on success
  */
 bool
 bsr_dev(DEVICE *dev, int num)
-{ 
+{
    struct mtop mt_com;
    int stat;
 
@@ -1104,14 +1104,14 @@ bsr_dev(DEVICE *dev, int num)
    return stat == 0;
 }
 
-/* 
+/*
  * Reposition the device to file, block
  * Returns: false on failure
  *         true  on success
  */
 bool
 reposition_dev(DEVICE *dev, uint32_t file, uint32_t block)
-{ 
+{
    if (dev->fd < 0) {
       dev->dev_errno = EBADF;
       Mmsg0(dev->errmsg, _("Bad call to reposition_dev. Archive not open\n"));
@@ -1125,7 +1125,7 @@ reposition_dev(DEVICE *dev, uint32_t file, uint32_t block)
       if (lseek(dev->fd, pos, SEEK_SET) == (off_t)-1) {
         berrno be;
         dev->dev_errno = errno;
-         Mmsg2(dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
+        Mmsg2(dev->errmsg, _("lseek error on %s. ERR=%s.\n"),
            dev->dev_name, be.strerror());
         return false;
       }
@@ -1134,7 +1134,7 @@ reposition_dev(DEVICE *dev, uint32_t file, uint32_t block)
       dev->file_addr = pos;
       return true;
    }
-   Dmsg4(100, "reposition_dev from %u:%u to %u:%u\n", 
+   Dmsg4(100, "reposition_dev from %u:%u to %u:%u\n",
       dev->file, dev->block_num, file, block);
    if (file < dev->file) {
       Dmsg0(100, "Rewind_dev\n");
@@ -1145,7 +1145,7 @@ reposition_dev(DEVICE *dev, uint32_t file, uint32_t block)
    if (file > dev->file) {
       Dmsg1(100, "fsf %d\n", file-dev->file);
       if (!fsf_dev(dev, file-dev->file)) {
-         Dmsg1(100, "fsf failed! ERR=%s\n", strerror_dev(dev));
+        Dmsg1(100, "fsf failed! ERR=%s\n", strerror_dev(dev));
         return false;
       }
       Dmsg2(100, "wanted_file=%d at_file=%d\n", file, dev->file);
@@ -1173,9 +1173,9 @@ reposition_dev(DEVICE *dev, uint32_t file, uint32_t block)
  *   Returns: 0 on success
  *           non-zero on failure
  */
-int 
+int
 weof_dev(DEVICE *dev, int num)
-{ 
+{
    struct mtop mt_com;
    int stat;
 
@@ -1203,7 +1203,7 @@ weof_dev(DEVICE *dev, int num)
       berrno be;
       clrerror_dev(dev, MTWEOF);
       if (stat == -1) {
-         Mmsg2(dev->errmsg, _("ioctl MTWEOF error on %s. ERR=%s.\n"),
+        Mmsg2(dev->errmsg, _("ioctl MTWEOF error on %s. ERR=%s.\n"),
            dev->dev_name, be.strerror());
        }
    }
@@ -1244,46 +1244,46 @@ clrerror_dev(DEVICE *dev, int func)
    if (errno == ENOTTY || errno == ENOSYS) { /* Function not implemented */
       switch (func) {
       case -1:
-         Emsg0(M_ABORT, 0, "Got ENOTTY on read/write!\n");
+        Emsg0(M_ABORT, 0, "Got ENOTTY on read/write!\n");
         break;
       case MTWEOF:
-         msg = "WTWEOF";
+        msg = "WTWEOF";
         dev->capabilities &= ~CAP_EOF; /* turn off feature */
         break;
 #ifdef MTEOM
       case MTEOM:
-         msg = "WTEOM";
+        msg = "WTEOM";
         dev->capabilities &= ~CAP_EOM; /* turn off feature */
         break;
-#endif 
+#endif
       case MTFSF:
-         msg = "MTFSF";
+        msg = "MTFSF";
         dev->capabilities &= ~CAP_FSF; /* turn off feature */
         break;
       case MTBSF:
-         msg = "MTBSF";
+        msg = "MTBSF";
         dev->capabilities &= ~CAP_BSF; /* turn off feature */
         break;
       case MTFSR:
-         msg = "MTFSR";
+        msg = "MTFSR";
         dev->capabilities &= ~CAP_FSR; /* turn off feature */
         break;
       case MTBSR:
-         msg = "MTBSR";
+        msg = "MTBSR";
         dev->capabilities &= ~CAP_BSR; /* turn off feature */
         break;
       default:
-         msg = "Unknown";
+        msg = "Unknown";
         break;
       }
       if (msg != NULL) {
         dev->dev_errno = ENOSYS;
-         Mmsg1(&dev->errmsg, _("This device does not support %s.\n"), msg);
+        Mmsg1(&dev->errmsg, _("This device does not support %s.\n"), msg);
         Emsg0(M_ERROR, 0, dev->errmsg);
       }
    }
    /* On some systems such as NetBSD, this clears all errors */
-   ioctl(dev->fd, MTIOCGET, (char *)&mt_stat);     
+   ioctl(dev->fd, MTIOCGET, (char *)&mt_stat);
 
 /* Found on Linux */
 #ifdef MTIOCLRERR
@@ -1353,7 +1353,7 @@ static void do_close(DEVICE *dev)
    dev->use_count = 0;
 }
 
-/* 
+/*
  * Close the device
  */
 void
@@ -1369,7 +1369,7 @@ close_dev(DEVICE *dev)
    } else if (dev->use_count > 0) {
       dev->use_count--;
    }
-          
+
 #ifdef FULL_DEBUG
    ASSERT(dev->use_count >= 0);
 #endif
@@ -1409,7 +1409,7 @@ bool truncate_dev(DEVICE *dev)
 
 bool
 dev_is_tape(DEVICE *dev)
-{  
+{
    return (dev->state & ST_TAPE) ? true : false;
 }
 
@@ -1455,7 +1455,7 @@ uint32_t dev_file(DEVICE *dev)
    return dev->file;
 }
 
-/* 
+/*
  * Free memory allocated for the device
  */
 void
index c6871518dc57b6925e91a494b03b0bf0bf260fca..bca2c42694286937403fcd49642e67dd706f3a93 100644 (file)
@@ -35,7 +35,7 @@
 
 /* #define NEW_LOCK 1 */
 
-#define new_lock_device(dev)             _new_lock_device(__FILE__, __LINE__, (dev)) 
+#define new_lock_device(dev)             _new_lock_device(__FILE__, __LINE__, (dev))
 #define new_lock_device_state(dev,state) _new_lock_device(__FILE__, __LINE__, (dev), (state))
 #define new_unlock_device(dev)           _new_unlock_device(__FILE__, __LINE__, (dev))
 
@@ -50,7 +50,7 @@
 enum {
    OPEN_READ_WRITE = 0,
    OPEN_READ_ONLY,
-   OPEN_WRITE_ONLY   
+   OPEN_WRITE_ONLY
 };
 
 /* Generic status bits returned from status_dev() */
@@ -97,7 +97,7 @@ enum {
 
 /* Device state bits */
 #define ST_OPENED          (1<<0)     /* set when device opened */
-#define ST_TAPE            (1<<1)     /* is a tape device */  
+#define ST_TAPE            (1<<1)     /* is a tape device */
 #define ST_FILE            (1<<2)     /* is a file device */
 #define ST_FIFO            (1<<3)     /* is a fifo device */
 #define ST_PROG            (1<<4)     /* is a program device */
@@ -117,7 +117,7 @@ enum {
    BST_UNMOUNTED,                     /* User unmounted device */
    BST_WAITING_FOR_SYSOP,             /* Waiting for operator to mount tape */
    BST_DOING_ACQUIRE,                 /* Opening/validating/moving tape */
-   BST_WRITING_LABEL,                  /* Labeling a tape */  
+   BST_WRITING_LABEL,                  /* Labeling a tape */
    BST_UNMOUNTED_WAITING_FOR_SYSOP,    /* Closed by user during mount request */
    BST_MOUNT                           /* Mount request */
 };
@@ -147,7 +147,7 @@ struct VOLUME_CAT_INFO {
    uint64_t VolWriteTime;             /* time spent writing this Volume */
    char VolCatStatus[20];             /* Volume status */
    char VolCatName[MAX_NAME_LENGTH];  /* Desired volume to mount */
-};                
+};
 
 
 typedef struct s_steal_lock {
@@ -160,7 +160,7 @@ struct DEVRES;                        /* Device resource defined in stored_conf.
 
 /*
  * Device structure definition. There is one of these for
- *  each physical device. Everything here is "global" to 
+ *  each physical device. Everything here is "global" to
  *  that device and effects all jobs using the device.
  */
 struct DEVICE {
@@ -213,7 +213,7 @@ public:
 
    VOLUME_CAT_INFO VolCatInfo;        /* Volume Catalog Information */
    VOLUME_LABEL VolHdr;               /* Actual volume label */
-   
+
    /* Device wait times ***FIXME*** look at durations */
    char BadVolName[MAX_NAME_LENGTH];  /* Last wrong Volume mounted */
    bool poll;                         /* set to poll Volume */
@@ -226,8 +226,8 @@ public:
 };
 
 /*
- * Device Context (or Control) Record.  
- *  There is one of these records for each Job that is using    
+ * Device Context (or Control) Record.
+ *  There is one of these records for each Job that is using
  *  the device. Items in this record are "local" to the Job and
  *  do not affect other Jobs.
  */
index 73dd46ba0b7ab500a7df912f634d3cde9b68b8b3..b14f64c125e279ca68ba70d9e193cf1918c91c88 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *
- *  Higher Level Device routines. 
- *  Knows about Bacula tape labels and such  
+ *  Higher Level Device routines.
+ *  Knows about Bacula tape labels and such
  *
  *  NOTE! In general, subroutines that have the word
  *        "device" in the name do locking.  Subroutines
  *       yyy_dev(), all is OK, but if xxx_device()
  *       calls yyy_device(), everything will hang.
  *       Obviously, no zzz_dev() is allowed to call
- *       a www_device() or everything falls apart. 
+ *       a www_device() or everything falls apart.
  *
  * Concerning the routines lock_device() and block_device()
  *  see the end of this module for details.  In general,
  *  blocking a device leaves it in a state where all threads
- *  other than the current thread block when they attempt to 
+ *  other than the current thread block when they attempt to
  *  lock the device. They remain suspended (blocked) until the device
  *  is unblocked. So, a device is blocked during an operation
  *  that takes a long time (initialization, mounting a new
  *  volume, ...) locking a device is done for an operation
- *  that takes a short time such as writing data to the   
+ *  that takes a short time such as writing data to the
  *  device.
  *
  *
  *   Kern Sibbald, MM, MMI
- *                           
+ *
  *   Version $Id$
  */
 /*
@@ -64,11 +64,11 @@ extern int debug_level;
  * Here are a few things to know:
  *  dcr->VolCatInfo contains the info on the "current" tape for this job.
  *  dev->VolCatInfo contains the info on the tape in the drive.
- *    The tape in the drive could have changed several times since 
+ *    The tape in the drive could have changed several times since
  *    the last time the job used it (jcr->VolCatInfo).
  *  dcr->VolumeName is the name of the current/desired tape in the drive.
  *
- * We enter with device locked, and 
+ * We enter with device locked, and
  *     exit with device locked.
  *
  * Note, we are called only from one place in block.c
@@ -101,7 +101,7 @@ bool fixup_device_block_write_error(DCR *dcr)
    unlock_device(dev);
 
    bstrncpy(dev->VolCatInfo.VolCatStatus, "Full", sizeof(dev->VolCatInfo.VolCatStatus));
-   Dmsg2(100, "Call update_vol_info Stat=%s Vol=%s\n", 
+   Dmsg2(100, "Call update_vol_info Stat=%s Vol=%s\n",
       dev->VolCatInfo.VolCatStatus, dev->VolCatInfo.VolCatName);
    dev->VolCatInfo.VolCatFiles = dev->file;   /* set number of files */
    dev->VolCatInfo.VolCatJobs++;             /* increment number of jobs */
@@ -119,7 +119,7 @@ bool fixup_device_block_write_error(DCR *dcr)
    dcr->block = label_blk;
 
    /* Inform User about end of medium */
-   Jmsg(jcr, M_INFO, 0, _("End of medium on Volume \"%s\" Bytes=%s Blocks=%s at %s.\n"), 
+   Jmsg(jcr, M_INFO, 0, _("End of medium on Volume \"%s\" Bytes=%s Blocks=%s at %s.\n"),
        PrevVolName, edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
        edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
        bstrftime(dt, sizeof(dt), time(NULL)));
@@ -136,7 +136,7 @@ bool fixup_device_block_write_error(DCR *dcr)
    Jmsg(jcr, M_INFO, 0, _("New volume \"%s\" mounted on device %s at %s.\n"),
       dcr->VolumeName, dev_name(dev), bstrftime(dt, sizeof(dt), time(NULL)));
 
-   /* 
+   /*
     * If this is a new tape, the label_blk will contain the
     *  label, so write it now. If this is a previously
     *  used tape, mount_next_write_volume() will return an
@@ -155,8 +155,8 @@ bool fixup_device_block_write_error(DCR *dcr)
    free_block(label_blk);
    dcr->block = block;
 
-   /* 
-    * Walk through all attached jcrs indicating the volume has changed  
+   /*
+    * Walk through all attached jcrs indicating the volume has changed
     */
    Dmsg1(100, "Walk attached jcrs. Volume=%s\n", dev->VolCatInfo.VolCatName);
 // for (JCR *mjcr=NULL; (mjcr=next_attached_jcr(dev, mjcr)); ) {
@@ -228,7 +228,7 @@ void set_new_volume_parameters(DCR *dcr)
 void set_new_file_parameters(DCR *dcr)
 {
    DEVICE *dev = dcr->dev;
-    
+
    /* Set new start/end positions */
    if (dev_state(dev, ST_TAPE)) {
       dcr->StartBlock = dev->block_num;
@@ -247,15 +247,15 @@ void set_new_file_parameters(DCR *dcr)
 
 
 /*
- *   First Open of the device. Expect dev to already be initialized.  
+ *   First Open of the device. Expect dev to already be initialized.
  *
- *   This routine is used only when the Storage daemon starts 
+ *   This routine is used only when the Storage daemon starts
  *   and always_open is set, and in the stand-alone utility
  *   routines such as bextract.
  *
  *   Note, opening of a normal file is deferred to later so
  *    that we can get the filename; the device_name for
- *    a file is the directory only. 
+ *    a file is the directory only.
  *
  *   Returns: false on failure
  *           true  on success
@@ -285,7 +285,7 @@ bool first_open_device(DEVICE *dev)
        }
       Dmsg0(129, "Opening device.\n");
       if (open_dev(dev, NULL, mode) < 0) {
-         Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
+        Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
         unlock_device(dev);
         return false;
       }
@@ -296,8 +296,8 @@ bool first_open_device(DEVICE *dev)
    return true;
 }
 
-/* 
- * Make sure device is open, if not do so 
+/*
+ * Make sure device is open, if not do so
  */
 bool open_device(DCR *dcr)
 {
@@ -313,7 +313,7 @@ bool open_device(DCR *dcr)
        if (open_dev(dev, dcr->VolCatInfo.VolCatName, mode) < 0) {
          /* If polling, ignore the error */
          if (!dev->poll) {
-             Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open device %s. ERR=%s\n"), 
+            Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open device %s. ERR=%s\n"),
                dev_name(dev), strerror_dev(dev));
          }
          return false;
@@ -338,7 +338,7 @@ void dev_unlock(DEVICE *dev)
    }
 }
 
-/* 
+/*
  * When dev_blocked is set, all threads EXCEPT thread with id no_wait_id
  * must wait. The no_wait_id thread is out obtaining a new volume
  * and preparing the label.
@@ -353,7 +353,7 @@ void _lock_device(const char *file, int line, DEVICE *dev)
       while (dev->dev_blocked) {
         if ((stat = pthread_cond_wait(&dev->wait, &dev->mutex)) != 0) {
            V(dev->mutex);
-            Emsg1(M_ABORT, 0, _("pthread_cond_wait failure. ERR=%s\n"),
+           Emsg1(M_ABORT, 0, _("pthread_cond_wait failure. ERR=%s\n"),
               strerror(stat));
         }
       }
@@ -381,7 +381,7 @@ const char *edit_blocked_reason(DEVICE *dev)
    case BST_UNMOUNTED:
       return "user unmounted device";
    case BST_WAITING_FOR_SYSOP:
-      return "waiting for operator action";      
+      return "waiting for operator action";
    case BST_DOING_ACQUIRE:
       return "opening, validating, or positioning tape";
    case BST_WRITING_LABEL:
@@ -395,13 +395,13 @@ const char *edit_blocked_reason(DEVICE *dev)
    }
 }
 
-void _unlock_device(const char *file, int line, DEVICE *dev) 
+void _unlock_device(const char *file, int line, DEVICE *dev)
 {
    Dmsg2(500, "unlock from %s:%d\n", file, line);
    V(dev->mutex);
 }
 
-/* 
+/*
  * Block all other threads from using the device
  *  Device must already be locked.  After this call,
  *  the device is blocked to any thread calling lock_device(),
@@ -451,11 +451,11 @@ void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *
 
 /*
  * Enter with device blocked by us but not locked
- * Exit with device locked, and blocked by previous owner 
+ * Exit with device locked, and blocked by previous owner
  */
-void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold)            
+void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold)
 {
-   Dmsg4(500, "return lock. old=%d new=%d from %s:%d\n", 
+   Dmsg4(500, "return lock. old=%d new=%d from %s:%d\n",
       dev->dev_blocked, hold->dev_blocked, file, line);
    P(dev->mutex);
    dev->dev_blocked = hold->dev_blocked;
index 523d42baeb82fc1d4a583cee88818e67885de2c3..de9904b31a5acde469c93fb319171cd696839c09 100644 (file)
@@ -1,10 +1,10 @@
 /*
  *  This file handles accepting Director Commands
  *
- *    Most Director commands are handled here, with the 
- *    exception of the Job command command and subsequent 
+ *    Most Director commands are handled here, with the
+ *    exception of the Job command command and subsequent
  *    subcommands that are handled
- *    in job.c.  
+ *    in job.c.
  *
  *    N.B. in this file, in general we must use P(dev->mutex) rather
  *     than lock_device(dev) so that we can examine the blocked
@@ -16,7 +16,7 @@
  *     Kern Sibbald, May MMI
  *
  *   Version $Id$
- *  
+ *
  */
 /*
    Copyright (C) 2001-2004 Kern Sibbald and John Walker
@@ -76,7 +76,7 @@ static bool do_label(JCR *jcr, int relabel);
 static DEVICE *find_device(JCR *jcr, POOL_MEM &dname);
 static void read_volume_label(JCR *jcr, DEVICE *dev, int Slot);
 static void label_volume_if_ok(JCR *jcr, DEVICE *dev, char *oldname,
-                              char *newname, char *poolname, 
+                              char *newname, char *poolname,
                               int Slot, int relabel);
 static bool try_autoload_device(JCR *jcr, int slot, const char *VolName);
 
@@ -86,8 +86,8 @@ struct s_cmds {
    int monitoraccess; /* specify if monitors have access to this function */
 };
 
-/*  
- * The following are the recognized commands from the Director. 
+/*
+ * The following are the recognized commands from the Director.
  */
 static struct s_cmds cmds[] = {
    {"JobId=",      job_cmd,         0},     /* start Job */
@@ -107,15 +107,15 @@ static struct s_cmds cmds[] = {
 };
 
 
-/* 
- * Connection request. We accept connections either from the 
+/*
+ * Connection request. We accept connections either from the
  *  Director or a Client (File daemon).
- * 
+ *
  * Note, we are running as a seperate thread of the Storage daemon.
  *  and it is because a Director has made a connection with
- *  us on the "Message" channel.    
+ *  us on the "Message" channel.
  *
- * Basic tasks done here:  
+ * Basic tasks done here:
  *  - Create a JCR record
  *  - If it was from the FD, call handle_filed_connection()
  *  - Authenticate the Director
@@ -138,7 +138,7 @@ void *handle_connection_request(void *arg)
       return NULL;
    }
 
-   /* 
+   /*
     * Do a sanity check on the message received
     */
    if (bs->msglen < 25 || bs->msglen > (int)sizeof(name)-25) {
@@ -146,7 +146,7 @@ void *handle_connection_request(void *arg)
       bnet_close(bs);
       return NULL;
    }
-   /* 
+   /*
     * See if this is a File daemon connection. If so
     *  call FD handler.
     */
@@ -155,7 +155,7 @@ void *handle_connection_request(void *arg)
       handle_filed_connection(bs, name);
       return NULL;
    }
-   
+
    Dmsg0(110, "Start Dir Job\n");
    jcr = new_jcr(sizeof(JCR), stored_free_jcr); /* create Job Control Record */
    jcr->dir_bsock = bs;              /* save Director bsock */
@@ -188,14 +188,14 @@ void *handle_connection_request(void *arg)
       for (i=0; cmds[i].cmd; i++) {
        if (strncmp(cmds[i].cmd, bs->msg, strlen(cmds[i].cmd)) == 0) {
           if ((!cmds[i].monitoraccess) && (jcr->director->monitor)) {
-              Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd);
+             Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd);
              bnet_fsend(bs, illegal_cmd);
              bnet_sig(bs, BNET_EOD);
              break;
           }
           if (!cmds[i].func(jcr)) { /* do command */
              quit = true; /* error, get out */
-              Dmsg1(190, "Command %s requsts quit\n", cmds[i].cmd);
+             Dmsg1(190, "Command %s requsts quit\n", cmds[i].cmd);
           }
           found = true;             /* indicate command found */
           break;
@@ -245,7 +245,7 @@ static bool cancel_cmd(JCR *cjcr)
 
    if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) {
       if (!(jcr=get_jcr_by_full_name(Job))) {
-         bnet_fsend(dir, _("3992 Job %s not found.\n"), Job);
+        bnet_fsend(dir, _("3992 Job %s not found.\n"), Job);
       } else {
         P(jcr->mutex);
         oldStatus = jcr->JobStatus;
@@ -264,7 +264,7 @@ static bool cancel_cmd(JCR *cjcr)
               jcr->dcr->dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP)) {
             pthread_cond_signal(&jcr->dcr->dev->wait_next_vol);
         }
-         bnet_fsend(dir, _("3000 Job %s marked to be canceled.\n"), jcr->Job);
+        bnet_fsend(dir, _("3000 Job %s marked to be canceled.\n"), jcr->Job);
         free_jcr(jcr);
       }
    } else {
@@ -278,24 +278,24 @@ static bool cancel_cmd(JCR *cjcr)
  * Label a tape
  *
  */
-static bool label_cmd(JCR *jcr) 
+static bool label_cmd(JCR *jcr)
 {
    return do_label(jcr, 0);
 }
 
-static bool relabel_cmd(JCR *jcr) 
+static bool relabel_cmd(JCR *jcr)
 {
    return do_label(jcr, 1);
 }
 
-static bool do_label(JCR *jcr, int relabel)  
+static bool do_label(JCR *jcr, int relabel)
 {
    POOLMEM *newname, *oldname, *poolname, *mtype;
    POOL_MEM dname;
    BSOCK *dir = jcr->dir_bsock;
    DEVICE *dev;
    bool ok = false;
-   int slot;   
+   int slot;
 
    newname = get_memory(dir->msglen+1);
    oldname = get_memory(dir->msglen+1);
@@ -325,18 +325,18 @@ static bool do_label(JCR *jcr, int relabel)
         if (!(dev->state & ST_OPENED)) {
            label_volume_if_ok(jcr, dev, oldname, newname, poolname, slot, relabel);
            force_close_dev(dev);
-         /* Under certain "safe" conditions, we can steal the lock */
-        } else if (dev->dev_blocked && 
+        /* Under certain "safe" conditions, we can steal the lock */
+        } else if (dev->dev_blocked &&
                    (dev->dev_blocked == BST_UNMOUNTED ||
                     dev->dev_blocked == BST_WAITING_FOR_SYSOP ||
                     dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP)) {
            label_volume_if_ok(jcr, dev, oldname, newname, poolname, slot, relabel);
         } else if (dev_state(dev, ST_READ) || dev->num_writers) {
            if (dev_state(dev, ST_READ)) {
-                bnet_fsend(dir, _("3911 Device %s is busy with 1 reader.\n"),
+               bnet_fsend(dir, _("3911 Device %s is busy with 1 reader.\n"),
                   dev_name(dev));
            } else {
-                bnet_fsend(dir, _("3912 Device %s is busy with %d writer(s).\n"),
+               bnet_fsend(dir, _("3912 Device %s is busy with %d writer(s).\n"),
                   dev_name(dev), dev->num_writers);
            }
         } else {                     /* device not being used */
@@ -344,7 +344,7 @@ static bool do_label(JCR *jcr, int relabel)
         }
         V(dev->mutex);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
+        bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
       }
    } else {
       /* NB dir->msg gets clobbered in bnet_fsend, so save command */
@@ -359,13 +359,13 @@ static bool do_label(JCR *jcr, int relabel)
    return true;
 }
 
-/* 
+/*
  * Read the tape label and determine if we can safely
  * label the tape (not a Bacula volume), then label it.
  *
  *  Enter with the mutex set
  */
-static void label_volume_if_ok(JCR *jcr, DEVICE *dev, char *oldname, 
+static void label_volume_if_ok(JCR *jcr, DEVICE *dev, char *oldname,
                               char *newname, char *poolname,
                               int slot, int relabel)
 {
@@ -373,16 +373,16 @@ static void label_volume_if_ok(JCR *jcr, DEVICE *dev, char *oldname,
    bsteal_lock_t hold;
    DCR *dcr = jcr->dcr;
    int label_status;
-   
+
    dcr->dev = dev;
    steal_device_lock(dev, &hold, BST_WRITING_LABEL);
-   
+
    if (!try_autoload_device(jcr, slot, newname)) {
       goto bail_out;                 /* error */
    }
 
    /* See what we have for a Volume */
-   label_status = read_dev_volume_label(dcr);                 
+   label_status = read_dev_volume_label(dcr);
    switch(label_status) {
    case VOL_NAME_ERROR:
    case VOL_VERSION_ERROR:
@@ -390,33 +390,33 @@ static void label_volume_if_ok(JCR *jcr, DEVICE *dev, char *oldname,
    case VOL_OK:
       if (!relabel) {
         bnet_fsend(dir, _(
-            "3911 Cannot label Volume because it is already labeled: \"%s\"\n"), 
+           "3911 Cannot label Volume because it is already labeled: \"%s\"\n"),
             dev->VolHdr.VolName);
         break;
       }
       /* Relabel request. If oldname matches, continue */
       if (strcmp(oldname, dev->VolHdr.VolName) != 0) {
-         bnet_fsend(dir, _("Wrong volume mounted.\n"));
+        bnet_fsend(dir, _("Wrong volume mounted.\n"));
         break;
       }
       /* Fall through wanted! */
    case VOL_IO_ERROR:
    case VOL_NO_LABEL:
       if (!write_new_volume_label_to_dev(dcr, newname, poolname)) {
-         bnet_fsend(dir, _("3912 Failed to label Volume: ERR=%s\n"), strerror_dev(dev));
+        bnet_fsend(dir, _("3912 Failed to label Volume: ERR=%s\n"), strerror_dev(dev));
         break;
       }
       bstrncpy(dcr->VolumeName, newname, sizeof(dcr->VolumeName));
       /* The following 3000 OK label. string is scanned in ua_label.c */
-      bnet_fsend(dir, "3000 OK label. Volume=%s Device=%s\n", 
+      bnet_fsend(dir, "3000 OK label. Volume=%s Device=%s\n",
         newname, dev_name(dev));
       break;
    case VOL_NO_MEDIA:
       bnet_fsend(dir, _("3912 Failed to label Volume: ERR=%s\n"), strerror_dev(dev));
       break;
    default:
-      bnet_fsend(dir, _("3913 Cannot label Volume. \
-Unknown status %d from read_volume_label()\n"), label_status);
+      bnet_fsend(dir, _("3913 Cannot label Volume. "
+"Unknown status %d from read_volume_label()\n"), label_status);
       break;
    }
 
@@ -426,7 +426,7 @@ bail_out:
 }
 
 
-/* 
+/*
  * Read the tape label
  *
  *  Enter with the mutex set
@@ -438,12 +438,12 @@ static bool read_label(DCR *dcr)
    BSOCK *dir = jcr->dir_bsock;
    bsteal_lock_t hold;
    DEVICE *dev = dcr->dev;
-   
+
    steal_device_lock(dev, &hold, BST_DOING_ACQUIRE);
-   
+
    dcr->VolumeName[0] = 0;
    dev->state &= ~ST_LABEL;          /* force read of label */
-   switch (read_dev_volume_label(dcr)) {               
+   switch (read_dev_volume_label(dcr)) {
    case VOL_OK:
       bnet_fsend(dir, _("3001 Mounted Volume: %s\n"), dev->VolHdr.VolName);
       ok = true;
@@ -468,7 +468,7 @@ static DEVICE *find_device(JCR *jcr, POOL_MEM &dname)
    foreach_res(device, R_DEVICE) {
       /* Find resource, and make sure we were able to open it */
       if (strcmp(device->hdr.name, dname.c_str()) == 0 && device->dev) {
-         Dmsg1(20, "Found device %s\n", device->hdr.name);
+        Dmsg1(20, "Found device %s\n", device->hdr.name);
         jcr->device = device;
         found = true;
         break;
@@ -506,9 +506,9 @@ static bool mount_cmd(JCR *jcr)
         switch (dev->dev_blocked) {         /* device blocked? */
         case BST_WAITING_FOR_SYSOP:
            /* Someone is waiting, wake him */
-            Dmsg0(100, "Waiting for mount. Attempting to wake thread\n");
+           Dmsg0(100, "Waiting for mount. Attempting to wake thread\n");
            dev->dev_blocked = BST_MOUNT;
-            bnet_fsend(dir, "3001 OK mount. Device=%s\n", dev_name(dev));
+           bnet_fsend(dir, "3001 OK mount. Device=%s\n", dev_name(dev));
            pthread_cond_signal(&dev->wait_next_vol);
            break;
 
@@ -517,79 +517,79 @@ static bool mount_cmd(JCR *jcr)
         case BST_UNMOUNTED:
            /* We freed the device, so reopen it and wake any waiting threads */
            if (open_dev(dev, NULL, OPEN_READ_WRITE) < 0) {
-               bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"), 
+              bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"),
                  strerror_dev(dev));
               break;
            }
            read_dev_volume_label(dcr);
            if (dev->dev_blocked == BST_UNMOUNTED) {
               /* We blocked the device, so unblock it */
-               Dmsg0(100, "Unmounted. Unblocking device\n");
+              Dmsg0(100, "Unmounted. Unblocking device\n");
               read_label(dcr);       /* this should not be necessary */
               unblock_device(dev);
            } else {
-               Dmsg0(100, "Unmounted waiting for mount. Attempting to wake thread\n");
+              Dmsg0(100, "Unmounted waiting for mount. Attempting to wake thread\n");
               dev->dev_blocked = BST_MOUNT;
            }
            if (dev_state(dev, ST_LABEL)) {
-               bnet_fsend(dir, _("3001 Device %s is mounted with Volume \"%s\"\n"), 
+              bnet_fsend(dir, _("3001 Device %s is mounted with Volume \"%s\"\n"),
                  dev_name(dev), dev->VolHdr.VolName);
            } else {
-               bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
-                                 "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
+              bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+                                "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
                          dev_name(dev));
            }
            pthread_cond_signal(&dev->wait_next_vol);
            break;
 
         case BST_DOING_ACQUIRE:
-            bnet_fsend(dir, _("3001 Device %s is mounted; doing acquire.\n"), 
+           bnet_fsend(dir, _("3001 Device %s is mounted; doing acquire.\n"),
                       dev_name(dev));
            break;
 
         case BST_WRITING_LABEL:
-            bnet_fsend(dir, _("3903 Device %s is being labeled.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3903 Device %s is being labeled.\n"), dev_name(dev));
            break;
 
         case BST_NOT_BLOCKED:
            if (dev_state(dev, ST_OPENED)) {
               if (dev_state(dev, ST_LABEL)) {
-                  bnet_fsend(dir, _("3001 Device %s is mounted with Volume \"%s\"\n"),
+                 bnet_fsend(dir, _("3001 Device %s is mounted with Volume \"%s\"\n"),
                     dev_name(dev), dev->VolHdr.VolName);
               } else {
-                  bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"   
-                                 "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
+                 bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+                                "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
                             dev_name(dev));
               }
            } else {
               if (!dev_is_tape(dev)) {
-                  bnet_fsend(dir, _("3906 cannot mount non-tape.\n"));
+                 bnet_fsend(dir, _("3906 cannot mount non-tape.\n"));
                  break;
               }
               if (open_dev(dev, NULL, OPEN_READ_WRITE) < 0) {
-                  bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"), 
+                 bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"),
                     strerror_dev(dev));
                  break;
               }
               read_label(dcr);
               if (dev_state(dev, ST_LABEL)) {
-                  bnet_fsend(dir, _("3001 Device %s is already mounted with Volume \"%s\"\n"), 
+                 bnet_fsend(dir, _("3001 Device %s is already mounted with Volume \"%s\"\n"),
                     dev_name(dev), dev->VolHdr.VolName);
               } else {
-                  bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
-                                    "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
+                 bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+                                   "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
                             dev_name(dev));
               }
            }
            break;
 
         default:
-            bnet_fsend(dir, _("3905 Bizarre wait state %d\n"), dev->dev_blocked);
+           bnet_fsend(dir, _("3905 Bizarre wait state %d\n"), dev->dev_blocked);
            break;
         }
         V(dev->mutex);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
+        bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
       }
    } else {
       pm_strcpy(jcr->errmsg, dir->msg);
@@ -613,36 +613,36 @@ static bool unmount_cmd(JCR *jcr)
       if (dev) {
         P(dev->mutex);               /* Use P to avoid indefinite block */
         if (!(dev->state & ST_OPENED)) {
-            Dmsg0(90, "Device already unmounted\n");
-            bnet_fsend(dir, _("3901 Device \"%s\" is already unmounted.\n"), dev_name(dev));
+           Dmsg0(90, "Device already unmounted\n");
+           bnet_fsend(dir, _("3901 Device \"%s\" is already unmounted.\n"), dev_name(dev));
 
         } else if (dev->dev_blocked == BST_WAITING_FOR_SYSOP) {
-            Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
+           Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
               dev->dev_blocked);
            open_dev(dev, NULL, 0);     /* fake open for close */
            offline_or_rewind_dev(dev);
            force_close_dev(dev);
            dev->dev_blocked = BST_UNMOUNTED_WAITING_FOR_SYSOP;
-            bnet_fsend(dir, _("3001 Device \"%s\" unmounted.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3001 Device \"%s\" unmounted.\n"), dev_name(dev));
 
         } else if (dev->dev_blocked == BST_DOING_ACQUIRE) {
-            bnet_fsend(dir, _("3902 Device \"%s\" is busy in acquire.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3902 Device \"%s\" is busy in acquire.\n"), dev_name(dev));
 
         } else if (dev->dev_blocked == BST_WRITING_LABEL) {
-            bnet_fsend(dir, _("3903 Device \"%s\" is being labeled.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3903 Device \"%s\" is being labeled.\n"), dev_name(dev));
 
         } else if (dev_state(dev, ST_READ) || dev->num_writers) {
            if (dev_state(dev, ST_READ)) {
-                Dmsg0(90, "Device in read mode\n");
-                bnet_fsend(dir, _("3904 Device \"%s\" is busy reading.\n"), dev_name(dev));
+               Dmsg0(90, "Device in read mode\n");
+               bnet_fsend(dir, _("3904 Device \"%s\" is busy reading.\n"), dev_name(dev));
            } else {
-                Dmsg1(90, "Device busy with %d writers\n", dev->num_writers);
-                bnet_fsend(dir, _("3905 Device %s is busy with %d writer(s).\n"),
+               Dmsg1(90, "Device busy with %d writers\n", dev->num_writers);
+               bnet_fsend(dir, _("3905 Device %s is busy with %d writer(s).\n"),
                   dev_name(dev), dev->num_writers);
            }
 
         } else {                     /* device not being used */
-            Dmsg0(90, "Device not in use, unmounting\n");
+           Dmsg0(90, "Device not in use, unmounting\n");
            /* On FreeBSD, I am having ASSERT() failures in block_device()
             * and I can only imagine that the thread id that we are
             * leaving in no_wait_id is being re-used. So here,
@@ -654,11 +654,11 @@ static bool unmount_cmd(JCR *jcr)
            open_dev(dev, NULL, 0);     /* fake open for close */
            offline_or_rewind_dev(dev);
            force_close_dev(dev);
-            bnet_fsend(dir, _("3002 Device %s unmounted.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3002 Device %s unmounted.\n"), dev_name(dev));
         }
         V(dev->mutex);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
+        bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
       }
    } else {
       /* NB dir->msg gets clobbered in bnet_fsend, so save command */
@@ -687,39 +687,39 @@ static bool release_cmd(JCR *jcr)
       if (dev) {
         P(dev->mutex);               /* Use P to avoid indefinite block */
         if (!(dev->state & ST_OPENED)) {
-            Dmsg0(90, "Device already released\n");
-            bnet_fsend(dir, _("3911 Device %s already released.\n"), dev_name(dev));
+           Dmsg0(90, "Device already released\n");
+           bnet_fsend(dir, _("3911 Device %s already released.\n"), dev_name(dev));
 
         } else if (dev->dev_blocked == BST_WAITING_FOR_SYSOP ||
                    dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP) {
-            Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
+           Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
               dev->dev_blocked);
-            bnet_fsend(dir, _("3912 Device %s waiting for mount.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3912 Device %s waiting for mount.\n"), dev_name(dev));
 
         } else if (dev->dev_blocked == BST_DOING_ACQUIRE) {
-            bnet_fsend(dir, _("3913 Device %s is busy in acquire.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3913 Device %s is busy in acquire.\n"), dev_name(dev));
 
         } else if (dev->dev_blocked == BST_WRITING_LABEL) {
-            bnet_fsend(dir, _("3914 Device %s is being labeled.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3914 Device %s is being labeled.\n"), dev_name(dev));
 
         } else if (dev_state(dev, ST_READ) || dev->num_writers) {
            if (dev_state(dev, ST_READ)) {
-                Dmsg0(90, "Device in read mode\n");
-                bnet_fsend(dir, _("3915 Device %s is busy with 1 reader.\n"), dev_name(dev));
+               Dmsg0(90, "Device in read mode\n");
+               bnet_fsend(dir, _("3915 Device %s is busy with 1 reader.\n"), dev_name(dev));
            } else {
-                Dmsg1(90, "Device busy with %d writers\n", dev->num_writers);
-                bnet_fsend(dir, _("3916 Device %s is busy with %d writer(s).\n"),
+               Dmsg1(90, "Device busy with %d writers\n", dev->num_writers);
+               bnet_fsend(dir, _("3916 Device %s is busy with %d writer(s).\n"),
                   dev_name(dev), dev->num_writers);
            }
 
         } else {                     /* device not being used */
-            Dmsg0(90, "Device not in use, unmounting\n");
+           Dmsg0(90, "Device not in use, unmounting\n");
            release_volume(jcr->dcr);
-            bnet_fsend(dir, _("3012 Device %s released.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3012 Device %s released.\n"), dev_name(dev));
         }
         V(dev->mutex);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
+        bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
       }
    } else {
       /* NB dir->msg gets clobbered in bnet_fsend, so save command */
@@ -748,20 +748,20 @@ static bool autochanger_cmd(JCR *jcr)
       if (dev) {
         P(dev->mutex);               /* Use P to avoid indefinite block */
         if (!dev_is_tape(dev)) {
-            bnet_fsend(dir, _("3995 Device %s is not an autochanger.\n"), dev_name(dev));
+           bnet_fsend(dir, _("3995 Device %s is not an autochanger.\n"), dev_name(dev));
         } else if (!(dev->state & ST_OPENED)) {
            autochanger_list(dcr, dir);
-         /* Under certain "safe" conditions, we can steal the lock */
-        } else if (dev->dev_blocked && 
+        /* Under certain "safe" conditions, we can steal the lock */
+        } else if (dev->dev_blocked &&
                    (dev->dev_blocked == BST_UNMOUNTED ||
                     dev->dev_blocked == BST_WAITING_FOR_SYSOP ||
                     dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP)) {
            autochanger_list(dcr, dir);
         } else if (dev_state(dev, ST_READ) || dev->num_writers) {
            if (dev_state(dev, ST_READ)) {
-                bnet_fsend(dir, _("3901 Device %s is busy with 1 reader.\n"), dev_name(dev));
+               bnet_fsend(dir, _("3901 Device %s is busy with 1 reader.\n"), dev_name(dev));
            } else {
-                bnet_fsend(dir, _("3902 Device %s is busy with %d writer(s).\n"),
+               bnet_fsend(dir, _("3902 Device %s is busy with %d writer(s).\n"),
                   dev_name(dev), dev->num_writers);
            }
         } else {                     /* device not being used */
@@ -769,7 +769,7 @@ static bool autochanger_cmd(JCR *jcr)
         }
         V(dev->mutex);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
+        bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
       }
    } else {  /* error on scanf */
       pm_strcpy(jcr->errmsg, dir->msg);
@@ -797,18 +797,18 @@ static bool readlabel_cmd(JCR *jcr)
         if (!dev_state(dev, ST_OPENED)) {
            read_volume_label(jcr, dev, Slot);
            force_close_dev(dev);
-         /* Under certain "safe" conditions, we can steal the lock */
-        } else if (dev->dev_blocked && 
+        /* Under certain "safe" conditions, we can steal the lock */
+        } else if (dev->dev_blocked &&
                    (dev->dev_blocked == BST_UNMOUNTED ||
                     dev->dev_blocked == BST_WAITING_FOR_SYSOP ||
                     dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP)) {
            read_volume_label(jcr, dev, Slot);
         } else if (dev_state(dev, ST_READ) || dev->num_writers) {
            if (dev_state(dev, ST_READ)) {
-                bnet_fsend(dir, _("3911 Device %s is busy with 1 reader.\n"),
+               bnet_fsend(dir, _("3911 Device %s is busy with 1 reader.\n"),
                            dev_name(dev));
            } else {
-                bnet_fsend(dir, _("3912 Device %s is busy with %d writer(s).\n"),
+               bnet_fsend(dir, _("3912 Device %s is busy with %d writer(s).\n"),
                   dev_name(dev), dev->num_writers);
            }
         } else {                     /* device not being used */
@@ -816,7 +816,7 @@ static bool readlabel_cmd(JCR *jcr)
         }
         V(dev->mutex);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
+        bnet_fsend(dir, _("3999 Device \"%s\" not found\n"), dname.c_str());
       }
    } else {
       pm_strcpy(jcr->errmsg, dir->msg);
@@ -826,7 +826,7 @@ static bool readlabel_cmd(JCR *jcr)
    return true;
 }
 
-/* 
+/*
  * Read the tape label
  *
  *  Enter with the mutex set
@@ -839,13 +839,13 @@ static void read_volume_label(JCR *jcr, DEVICE *dev, int Slot)
 
    dcr->dev = dev;
    steal_device_lock(dev, &hold, BST_WRITING_LABEL);
-   
+
    if (!try_autoload_device(jcr, Slot, "")) {
       goto bail_out;                 /* error */
    }
 
    dev->state &= ~ST_LABEL;          /* force read of label */
-   switch (read_dev_volume_label(dcr)) {               
+   switch (read_dev_volume_label(dcr)) {
    case VOL_OK:
       /* DO NOT add quotes around the Volume name. It is scanned in the DIR */
       bnet_fsend(dir, _("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolName, Slot);
@@ -872,13 +872,13 @@ static bool try_autoload_device(JCR *jcr, int slot, const char *VolName)
    dcr->VolCatInfo.Slot = slot;
    dcr->VolCatInfo.InChanger = slot > 0;
    if (autoload_device(dcr, 0, dir) < 0) {    /* autoload if possible */
-      return false; 
+      return false;
    }
 
    /* Ensure that the device is open -- autoload_device() closes it */
    for ( ; !(dev->state & ST_OPENED); ) {
       if (open_dev(dev, dcr->VolumeName, OPEN_READ_WRITE) < 0) {
-         bnet_fsend(dir, _("3910 Unable to open device %s. ERR=%s\n"), 
+        bnet_fsend(dir, _("3910 Unable to open device %s. ERR=%s\n"),
            dev_name(dev), strerror_dev(dev));
         return false;
       }
index 482cc68b47f38e4943b539d691e7990d4ddac373..122dca6da03a89029f651dad348678af192699eb 100644 (file)
@@ -6,11 +6,11 @@
  * We get here because the Director has initiated a Job with
  *  the Storage daemon, then done the same with the File daemon,
  *  then when the Storage daemon receives a proper connection from
- *  the File daemon, control is passed here to handle the 
+ *  the File daemon, control is passed here to handle the
  *  subsequent File daemon commands.
  *
  *   Version $Id$
- * 
+ *
  */
 /*
    Copyright (C) 2000-2004 Kern Sibbald and John Walker
@@ -62,7 +62,7 @@ struct s_cmds {
    bool (*func)(JCR *jcr);
 };
 
-/*  
+/*
  * The following are the recognized commands from the File daemon
  */
 static struct s_cmds fd_cmds[] = {
@@ -93,7 +93,7 @@ static char ERROR_bootstrap[] = "3904 Error bootstrap\n";
 
 /* Information sent to the Director */
 static char Job_start[] = "3010 Job %s start\n";
-static char Job_end[]  = 
+static char Job_end[]  =
    "3099 Job %s end JobStatus=%d JobFiles=%d JobBytes=%s\n";
 
 /*
@@ -116,7 +116,7 @@ void run_job(JCR *jcr)
    fd->jcr = jcr;
    dir->jcr = jcr;
    Dmsg1(120, "Start run Job=%s\n", jcr->Job);
-   bnet_fsend(dir, Job_start, jcr->Job); 
+   bnet_fsend(dir, Job_start, jcr->Job);
    jcr->start_time = time(NULL);
    jcr->run_time = jcr->start_time;
    set_jcr_job_status(jcr, JS_Running);
@@ -145,7 +145,7 @@ void run_job(JCR *jcr)
         }
       }
       if (!found) {                  /* command not found */
-         Dmsg1(110, "<filed: Command not found: %s\n", fd->msg);
+        Dmsg1(110, "<filed: Command not found: %s\n", fd->msg);
         bnet_fsend(fd, ferrmsg);
         break;
       }
@@ -160,7 +160,7 @@ void run_job(JCR *jcr)
    return;
 }
 
-       
+
 /*
  *   Append Data command
  *     Open Data Channel and receive Data for archiving
@@ -200,7 +200,7 @@ static bool append_end_session(JCR *jcr)
 }
 
 
-/* 
+/*
  * Append Open session command
  *
  */
@@ -226,7 +226,7 @@ static bool append_open_session(JCR *jcr)
 
 /*
  *   Append Close session command
- *     Close the append session and send back Statistics     
+ *     Close the append session and send back Statistics
  *        (need to fix statistics)
  */
 static bool append_close_session(JCR *jcr)
@@ -243,7 +243,7 @@ static bool append_close_session(JCR *jcr)
    Dmsg1(120, ">filed: %s", fd->msg);
 
    bnet_sig(fd, BNET_EOD);           /* send EOD to File daemon */
-       
+
    Dmsg1(110, "Append close session: %s\n", dev_name(jcr->device->dev));
 
    jcr->session_opened = false;
@@ -252,7 +252,7 @@ static bool append_close_session(JCR *jcr)
 
 /*
  *   Read Data command
- *     Open Data Channel, read the data from  
+ *     Open Data Channel, read the data from
  *     the archive device and send to File
  *     daemon.
  */
@@ -270,7 +270,7 @@ static bool read_data_cmd(JCR *jcr)
    }
 }
 
-/* 
+/*
  * Read Open session command
  *
  *  We need to scan for the parameters of the job
@@ -294,7 +294,7 @@ static bool read_open_session(JCR *jcr)
         return false;
       }
       Dmsg4(100, "read_open_session got: JobId=%d Vol=%s VolSessId=%ld VolSessT=%ld\n",
-        jcr->JobId, jcr->dcr->VolumeName, jcr->read_VolSessionId, 
+        jcr->JobId, jcr->dcr->VolumeName, jcr->read_VolSessionId,
         jcr->read_VolSessionTime);
       Dmsg4(100, "  StartF=%ld EndF=%ld StartB=%ld EndB=%ld\n",
         jcr->read_StartFile, jcr->read_EndFile, jcr->read_StartBlock,
@@ -379,7 +379,7 @@ static bool read_close_session(JCR *jcr)
    Dmsg1(160, ">filed: %s\n", fd->msg);
 
    bnet_sig(fd, BNET_EOD);         /* send EOD to File daemon */
-       
+
    jcr->session_opened = FALSE;
    return true;
 }
index d1ca3002a8eaef886815bde588cbc4c62a63a8f4..4381db297d69e6105fba7738ad59c2fa439b0d6b 100644 (file)
@@ -40,8 +40,8 @@ static bool use_device_cmd(JCR *jcr);
 
 /* Requests from the Director daemon */
 static char jobcmd[] = "JobId=%d job=%127s job_name=%127s client_name=%127s "
-         "type=%d level=%d FileSet=%127s NoAttr=%d SpoolAttr=%d FileSetMD5=%127s "
-         "SpoolData=%d";
+        "type=%d level=%d FileSet=%127s NoAttr=%d SpoolAttr=%d FileSetMD5=%127s "
+        "SpoolData=%d";
 static char use_device[]  = "use device=%127s media_type=%127s pool_name=%127s pool_type=%127s\n";
 static char use_devices[] = "use devices=%127s media_type=%127s pool_name=%127s pool_type=%127s\n";
 
@@ -78,7 +78,7 @@ bool job_cmd(JCR *jcr)
     * Get JobId and permissions from Director
     */
    Dmsg1(100, "Job_cmd: %s\n", dir->msg);
-   if (sscanf(dir->msg, jobcmd, &JobId, job.c_str(), job_name.c_str(), 
+   if (sscanf(dir->msg, jobcmd, &JobId, job.c_str(), job_name.c_str(),
              client_name.c_str(),
              &JobType, &level, fileset_name.c_str(), &no_attributes,
              &spool_attributes, fileset_md5.c_str(), &spool_data) != 11) {
@@ -88,7 +88,7 @@ bool job_cmd(JCR *jcr)
       set_jcr_job_status(jcr, JS_ErrorTerminated);
       return false;
    }
-   /*        
+   /*
     * Since this job could be rescheduled, we
     *  check to see if we have it already. If so
     *  free the old jcr and use the new one.
@@ -128,7 +128,7 @@ bool job_cmd(JCR *jcr)
    bnet_fsend(dir, OKjob, jcr->VolSessionId, jcr->VolSessionTime, auth_key);
    Dmsg1(110, ">dird: %s", dir->msg);
    jcr->sd_auth_key = bstrdup(auth_key);
-   memset(auth_key, 0, sizeof(auth_key));    
+   memset(auth_key, 0, sizeof(auth_key));
 
    /*
     * Wait for the device, media, and pool information
@@ -153,7 +153,7 @@ bool job_cmd(JCR *jcr)
    dir_send_job_status(jcr);
 
    gettimeofday(&tv, &tz);
-   timeout.tv_nsec = tv.tv_usec * 1000; 
+   timeout.tv_nsec = tv.tv_usec * 1000;
    timeout.tv_sec = tv.tv_sec + 30 * 60;       /* wait 30 minutes */
 
    Dmsg1(100, "%s waiting on FD to contact SD\n", jcr->Job);
@@ -183,7 +183,7 @@ bool job_cmd(JCR *jcr)
 /*
  * After receiving a connection (in job.c) if it is
  *   from the File daemon, this routine is called.
- */  
+ */
 void handle_filed_connection(BSOCK *fd, char *job_name)
 {
    JCR *jcr;
@@ -201,12 +201,12 @@ void handle_filed_connection(BSOCK *fd, char *job_name)
    Dmsg1(110, "Found Job %s\n", job_name);
 
    if (jcr->authenticated) {
-      Jmsg2(jcr, M_FATAL, 0, "Hey!!!! JobId %u Job %s already authenticated.\n", 
+      Jmsg2(jcr, M_FATAL, 0, "Hey!!!! JobId %u Job %s already authenticated.\n",
         jcr->JobId, jcr->Job);
       free_jcr(jcr);
       return;
    }
-  
+
    /*
     * Authenticate the File daemon
     */
@@ -229,9 +229,9 @@ void handle_filed_connection(BSOCK *fd, char *job_name)
 }
 
 
-/*  
+/*
  *   Use Device command from Director
- *   He tells is what Device Name to use, the Media Type, 
+ *   He tells is what Device Name to use, the Media Type,
  *     the Pool Name, and the Pool Type.
  *
  *    Ensure that the device exists and is opened, then store
@@ -243,27 +243,27 @@ static bool use_device_cmd(JCR *jcr)
    BSOCK *dir = jcr->dir_bsock;
    DEVRES *device;
    bool quit = false;
-   
+
    while (!quit) {
       bool ok;
       if (bnet_recv(dir) <= 0) {
-         Jmsg0(jcr, M_FATAL, 0, _("No Device from Director\n"));
+        Jmsg0(jcr, M_FATAL, 0, _("No Device from Director\n"));
         return false;
       }
-   
+
       Dmsg1(120, "Use device: %s", dir->msg);
-      /* 
-       * If there are multiple devices, the director sends us 
+      /*
+       * If there are multiple devices, the director sends us
        *   use_devices (note plurel) until the last one, at which
        *   time, it sends us a use_device command (note singlular)
        *   so we stop looking after getting the use_device.
        */
-      ok = sscanf(dir->msg, use_device, dev_name.c_str(), media_type.c_str(), 
+      ok = sscanf(dir->msg, use_device, dev_name.c_str(), media_type.c_str(),
                  pool_name.c_str(), pool_type.c_str()) == 4;
       if (ok) {
         quit = true;                 /* got last device */
       } else {
-        ok = sscanf(dir->msg, use_devices, dev_name.c_str(), media_type.c_str(), 
+        ok = sscanf(dir->msg, use_devices, dev_name.c_str(), media_type.c_str(),
                     pool_name.c_str(), pool_type.c_str()) == 4;
       }
       if (ok) {
@@ -274,7 +274,7 @@ static bool use_device_cmd(JCR *jcr)
         LockRes();
         foreach_res(device, R_DEVICE) {
            /* Find resource, and make sure we were able to open it */
-           if (fnmatch(dev_name.c_str(), device->hdr.name, 0) == 0 && 
+           if (fnmatch(dev_name.c_str(), device->hdr.name, 0) == 0 &&
                device->dev && strcmp(device->media_type, media_type.c_str()) == 0) {
               const int name_len = MAX_NAME_LENGTH;
               DCR *dcr;
@@ -283,13 +283,13 @@ static bool use_device_cmd(JCR *jcr)
               if (!dcr) {
                  return false;
               }
-               Dmsg1(120, "Found device %s\n", device->hdr.name);
+              Dmsg1(120, "Found device %s\n", device->hdr.name);
               bstrncpy(dcr->pool_name, pool_name, name_len);
               bstrncpy(dcr->pool_type, pool_type, name_len);
               bstrncpy(dcr->media_type, media_type, name_len);
               bstrncpy(dcr->dev_name, dev_name, name_len);
               jcr->device = device;
-               Dmsg1(220, "Got: %s", dir->msg);
+              Dmsg1(220, "Got: %s", dir->msg);
               return bnet_fsend(dir, OK_device);
            }
         }
@@ -297,19 +297,19 @@ static bool use_device_cmd(JCR *jcr)
         if (verbose) {
            unbash_spaces(dir->msg);
            pm_strcpy(jcr->errmsg, dir->msg);
-            Jmsg(jcr, M_INFO, 0, _("Failed command: %s\n"), jcr->errmsg);
+           Jmsg(jcr, M_INFO, 0, _("Failed command: %s\n"), jcr->errmsg);
         }
-         Jmsg(jcr, M_FATAL, 0, _("\n"
-            "     Device \"%s\" with MediaType \"%s\" requested by Dir not found in SD Device resources.\n"),
+        Jmsg(jcr, M_FATAL, 0, _("\n"
+           "     Device \"%s\" with MediaType \"%s\" requested by Dir not found in SD Device resources.\n"),
              dev_name.c_str(), media_type.c_str());
         bnet_fsend(dir, NO_device, dev_name.c_str());
       } else {
         unbash_spaces(dir->msg);
         pm_strcpy(jcr->errmsg, dir->msg);
         if (verbose) {
-            Jmsg(jcr, M_INFO, 0, _("Failed command: %s\n"), jcr->errmsg);
+           Jmsg(jcr, M_INFO, 0, _("Failed command: %s\n"), jcr->errmsg);
         }
-         Jmsg(jcr, M_FATAL, 0, _("Bad Use Device command: %s\n"), jcr->errmsg);
+        Jmsg(jcr, M_FATAL, 0, _("Bad Use Device command: %s\n"), jcr->errmsg);
         bnet_fsend(dir, BAD_use, jcr->errmsg);
       }
    }
@@ -317,11 +317,11 @@ static bool use_device_cmd(JCR *jcr)
    return false;                     /* ERROR return */
 }
 
-/* 
+/*
  * Destroy the Job Control Record and associated
  * resources (sockets).
  */
-void stored_free_jcr(JCR *jcr) 
+void stored_free_jcr(JCR *jcr)
 {
    if (jcr->file_bsock) {
       bnet_close(jcr->file_bsock);
index 1b9caa213b3334f0dfed08549ed5e0ce40750d1b..d822b6b4fd96f4ca9340914487f4523ddedc689f 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *
- *  label.c  Bacula routines to handle labels 
+ *  label.c  Bacula routines to handle labels
  *
  *   Kern Sibbald, MM
- *                           
+ *
  *
  *   Version $Id$
  */
@@ -43,7 +43,7 @@ extern int debug_level;
  *  If dcr->VolumeName[0] == 0, we accept any Bacula Volume
  *  otherwise dcr->VolumeName must match the Volume.
  *
- *  If VolName given, ensure that it matches   
+ *  If VolName given, ensure that it matches
  *
  *  Returns VOL_  code as defined in record.h
  *    VOL_NOT_READ
@@ -55,7 +55,7 @@ extern int debug_level;
  *    VOL_VERSION_ERROR
  *    VOL_LABEL_ERROR
  *    VOL_NO_MEDIA
- */  
+ */
 int read_dev_volume_label(DCR *dcr)
 {
    JCR *jcr = dcr->jcr;
@@ -65,20 +65,20 @@ int read_dev_volume_label(DCR *dcr)
    bool ok = false;
    DEV_BLOCK *block = dcr->block;
 
-   Dmsg3(100, "Enter read_volume_label device=%s vol=%s dev_Vol=%s\n", 
+   Dmsg3(100, "Enter read_volume_label device=%s vol=%s dev_Vol=%s\n",
       dev_name(dev), VolName, dev->VolHdr.VolName);
 
    if (dev_state(dev, ST_LABEL)) {      /* did we already read label? */
       /* Compare Volume Names allow special wild card */
       if (VolName && *VolName && *VolName != '*' && strcmp(dev->VolHdr.VolName, VolName) != 0) {
-         Mmsg(jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"),
+        Mmsg(jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"),
            dev_name(dev), VolName, dev->VolHdr.VolName);
         /*
          * Cancel Job if too many label errors
          *  => we are in a loop
          */
         if (!dev->poll && jcr->label_errors++ > 100) {
-            Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg);
+           Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg);
         }
         return VOL_NAME_ERROR;
       }
@@ -100,9 +100,9 @@ int read_dev_volume_label(DCR *dcr)
    record = new_record();
    empty_block(block);
    Dmsg0(90, "Big if statement in read_volume_label\n");
-   if (!read_block_from_dev(dcr, NO_BLOCK_NUMBER_CHECK)) { 
+   if (!read_block_from_dev(dcr, NO_BLOCK_NUMBER_CHECK)) {
       Mmsg(jcr->errmsg, _("Requested Volume \"%s\" on %s is not a Bacula "
-           "labeled Volume, because: ERR=%s"), NPRT(VolName), dev_name(dev), 
+          "labeled Volume, because: ERR=%s"), NPRT(VolName), dev_name(dev),
           strerror_dev(dev));
       Dmsg1(30, "%s", jcr->errmsg);
    } else if (!read_record_from_block(block, record)) {
@@ -112,7 +112,7 @@ int read_dev_volume_label(DCR *dcr)
       Mmsg(jcr->errmsg, _("Could not unserialize Volume label: ERR=%s\n"),
         strerror_dev(dev));
       Dmsg1(30, "%s", jcr->errmsg);
-   } else if (strcmp(dev->VolHdr.Id, BaculaId) != 0 && 
+   } else if (strcmp(dev->VolHdr.Id, BaculaId) != 0 &&
              strcmp(dev->VolHdr.Id, OldBaculaId) != 0) {
       Mmsg(jcr->errmsg, _("Volume Header Id bad: %s\n"), dev->VolHdr.Id);
       Dmsg1(30, "%s", jcr->errmsg);
@@ -123,7 +123,7 @@ int read_dev_volume_label(DCR *dcr)
       free_record(record);
       if (forge_on || jcr->ignore_label_errors) {
         dev->state |= ST_LABEL;      /* set has Bacula label */
-         Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
+        Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
         return VOL_OK;
       }
       empty_block(block);
@@ -138,8 +138,8 @@ int read_dev_volume_label(DCR *dcr)
       rewind_dev(dev);
    }
 
-   if (dev->VolHdr.VerNum != BaculaTapeVersion && 
-       dev->VolHdr.VerNum != OldCompatibleBaculaTapeVersion1 &&  
+   if (dev->VolHdr.VerNum != BaculaTapeVersion &&
+       dev->VolHdr.VerNum != OldCompatibleBaculaTapeVersion1 &&
        dev->VolHdr.VerNum != OldCompatibleBaculaTapeVersion2) {
       Mmsg(jcr->errmsg, _("Volume on %s has wrong Bacula version. Wanted %d got %d\n"),
         dev_name(dev), BaculaTapeVersion, dev->VolHdr.VerNum);
@@ -151,7 +151,7 @@ int read_dev_volume_label(DCR *dcr)
     * a Bacula volume label (VOL_LABEL)
     */
    if (dev->VolHdr.LabelType != PRE_LABEL && dev->VolHdr.LabelType != VOL_LABEL) {
-      Mmsg(jcr->errmsg, _("Volume on %s has bad Bacula label type: %x\n"), 
+      Mmsg(jcr->errmsg, _("Volume on %s has bad Bacula label type: %x\n"),
          dev_name(dev), dev->VolHdr.LabelType);
       Dmsg1(30, "%s", jcr->errmsg);
       return VOL_LABEL_ERROR;
@@ -170,7 +170,7 @@ int read_dev_volume_label(DCR *dcr)
        *  => we are in a loop
        */
       if (!dev->poll && jcr->label_errors++ > 100) {
-         Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg);
+        Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg);
       }
       return VOL_NAME_ERROR;
    }
@@ -183,8 +183,8 @@ int read_dev_volume_label(DCR *dcr)
    return VOL_OK;
 }
 
-/*  unser_volume_label 
- *  
+/*  unser_volume_label
+ *
  * Unserialize the Volume label into the device Volume_Label
  * structure.
  *
@@ -199,8 +199,8 @@ bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec)
    ser_declare;
 
    if (rec->FileIndex != VOL_LABEL && rec->FileIndex != PRE_LABEL) {
-      Mmsg3(dev->errmsg, _("Expecting Volume Label, got FI=%s Stream=%s len=%d\n"), 
-             FI_to_ascii(rec->FileIndex), 
+      Mmsg3(dev->errmsg, _("Expecting Volume Label, got FI=%s Stream=%s len=%d\n"),
+             FI_to_ascii(rec->FileIndex),
              stream_to_ascii(rec->Stream, rec->FileIndex),
              rec->data_len);
       if (!forge_on) {
@@ -221,7 +221,7 @@ bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec)
    if (dev->VolHdr.VerNum >= 11) {
       unser_btime(dev->VolHdr.label_btime);
       unser_btime(dev->VolHdr.write_btime);
-   } else { /* old way */ 
+   } else { /* old way */
       unser_float64(dev->VolHdr.label_date);
       unser_float64(dev->VolHdr.label_time);
    }
@@ -242,7 +242,7 @@ bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec)
    ser_end(rec->data, SER_LENGTH_Volume_Label);
    Dmsg0(90, "ser_read_vol\n");
    if (debug_level >= 90) {
-      dump_volume_label(dev);     
+      dump_volume_label(dev);
    }
    return true;
 }
@@ -280,10 +280,10 @@ bool write_volume_label_to_block(DCR *dcr)
    return true;
 }
 
-/* 
+/*
  *  create_volume_label_record
  *   Serialize label (from dev->VolHdr structure) into device record.
- *   Assumes that the dev->VolHdr structure is properly 
+ *   Assumes that the dev->VolHdr structure is properly
  *   initialized.
 */
 static void create_volume_label_record(DCR *dcr, DEV_RECORD *rec)
@@ -337,7 +337,7 @@ static void create_volume_label_record(DCR *dcr, DEV_RECORD *rec)
    rec->Stream = jcr->NumVolumes;
    Dmsg2(100, "Created Vol label rec: FI=%s len=%d\n", FI_to_ascii(rec->FileIndex),
       rec->data_len);
-}     
+}
 
 
 /*
@@ -384,7 +384,7 @@ void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName)
  *           a fresh volume label.  Any data
  *           after the label will be destroyed,
  *           in fact, we write the label 5 times !!!!
- * 
+ *
  *  This routine expects that open_device() was previously called.
  *
  *  This routine should be used only when labeling a blank tape.
@@ -397,7 +397,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *Po
 
    Dmsg0(99, "write_volume_label()\n");
    empty_block(dcr->block);
-   /* Create PRE_LABEL */      
+   /* Create PRE_LABEL */
    create_volume_label(dev, VolName, PoolName);
 
    if (!rewind_dev(dev)) {
@@ -420,7 +420,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *Po
    } else {
       Dmsg2(30, "Wrote label of %d bytes to %s\n", dcr->rec->data_len, dev_name(dev));
    }
-      
+
    Dmsg0(99, "Call write_block_to_dev()\n");
    if (!write_block_to_dev(dcr)) {
       memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
@@ -428,7 +428,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *Po
       goto bail_out;
    }
    Dmsg0(99, " Wrote block to device\n");
-     
+
    if (weof_dev(dev, 1) == 0) {
       dev->state |= ST_LABEL;
       ok = true;
@@ -441,7 +441,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *Po
 bail_out:
    dev->state &= ~ST_APPEND;         /* remove append since this is PRE_LABEL */
    return ok;
-}     
+}
 
 
 /*
@@ -499,7 +499,7 @@ void create_session_label(DCR *dcr, DEV_RECORD *rec, int label)
 
 /* Write session label
  *  Returns: false on failure
- *          true  on success 
+ *          true  on success
  */
 bool write_session_label(DCR *dcr, int label)
 {
@@ -536,7 +536,7 @@ bool write_session_label(DCR *dcr, int label)
    create_session_label(dcr, rec, label);
    rec->FileIndex = label;
 
-   /* 
+   /*
     * We guarantee that the session record can totally fit
     *  into a block. If not, write the block, and put it in
     *  the next block. Having the sesssion record totally in
@@ -546,29 +546,29 @@ bool write_session_label(DCR *dcr, int label)
    if (!can_write_record_to_block(block, rec)) {
       Dmsg0(100, "Cannot write session label to block.\n");
       if (!write_block_to_device(dcr)) {
-         Dmsg0(90, "Got session label write_block_to_dev error.\n");
+        Dmsg0(90, "Got session label write_block_to_dev error.\n");
         /* ****FIXME***** errno is not set here */
-         Jmsg(jcr, M_FATAL, 0, _("Error writing Session label to %s: %s\n"), 
+        Jmsg(jcr, M_FATAL, 0, _("Error writing Session label to %s: %s\n"),
                           dev_vol_name(dev), strerror(errno));
         free_record(rec);
         return false;
       }
    }
    if (!write_record_to_block(block, rec)) {
-      Jmsg(jcr, M_FATAL, 0, _("Error writing Session label to %s: %s\n"), 
+      Jmsg(jcr, M_FATAL, 0, _("Error writing Session label to %s: %s\n"),
                        dev_vol_name(dev), strerror(errno));
       free_record(rec);
       return false;
    }
 
-   Dmsg6(20, "Write sesson_label record JobId=%d FI=%s SessId=%d Strm=%s len=%d " 
-             "remainder=%d\n", jcr->JobId,
-      FI_to_ascii(rec->FileIndex), rec->VolSessionId, 
+   Dmsg6(20, "Write sesson_label record JobId=%d FI=%s SessId=%d Strm=%s len=%d "
+            "remainder=%d\n", jcr->JobId,
+      FI_to_ascii(rec->FileIndex), rec->VolSessionId,
       stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len,
       rec->remainder);
 
    free_record(rec);
-   Dmsg2(20, "Leave write_session_label Block=%d File=%d\n", 
+   Dmsg2(20, "Leave write_session_label Block=%d File=%d\n",
       dev->block_num, dev->file);
    return true;
 }
@@ -586,46 +586,46 @@ void dump_volume_label(DEVICE *dev)
    File = dev->file;
    switch (dev->VolHdr.LabelType) {
       case PRE_LABEL:
-         LabelType = "PRE_LABEL";
+        LabelType = "PRE_LABEL";
         break;
       case VOL_LABEL:
-         LabelType = "VOL_LABEL";
+        LabelType = "VOL_LABEL";
         break;
       case EOM_LABEL:
-         LabelType = "EOM_LABEL";
+        LabelType = "EOM_LABEL";
         break;
       case SOS_LABEL:
-         LabelType = "SOS_LABEL";
+        LabelType = "SOS_LABEL";
         break;
       case EOS_LABEL:
-         LabelType = "EOS_LABEL";
+        LabelType = "EOS_LABEL";
         break;
       case EOT_LABEL:
         goto bail_out;
       default:
         LabelType = buf;
-         sprintf(buf, "Unknown %d", dev->VolHdr.LabelType);
+        sprintf(buf, "Unknown %d", dev->VolHdr.LabelType);
         break;
    }
-             
-   
-   Pmsg11(-1, "\nVolume Label:\n\
-Id                : %s\
-VerNo             : %d\n\
-VolName           : %s\n\
-PrevVolName       : %s\n\
-VolFile           : %d\n\
-LabelType         : %s\n\
-LabelSize         : %d\n\
-PoolName          : %s\n\
-MediaType         : %s\n\
-PoolType          : %s\n\
-HostName          : %s\n\
-",
+
+
+   Pmsg11(-1, "\nVolume Label:\n"
+"Id                : %s"
+"VerNo             : %d\n"
+"VolName           : %s\n"
+"PrevVolName       : %s\n"
+"VolFile           : %d\n"
+"LabelType         : %s\n"
+"LabelSize         : %d\n"
+"PoolName          : %s\n"
+"MediaType         : %s\n"
+"PoolType          : %s\n"
+"HostName          : %s\n"
+"",
             dev->VolHdr.Id, dev->VolHdr.VerNum,
             dev->VolHdr.VolName, dev->VolHdr.PrevVolName,
-            File, LabelType, dev->VolHdr.LabelSize, 
-            dev->VolHdr.PoolName, dev->VolHdr.MediaType, 
+            File, LabelType, dev->VolHdr.LabelSize,
+            dev->VolHdr.PoolName, dev->VolHdr.MediaType,
             dev->VolHdr.PoolType, dev->VolHdr.HostName);
 
    if (dev->VolHdr.VerNum >= 11) {
@@ -636,8 +636,8 @@ HostName          : %s\n\
    dt.julian_day_number   = dev->VolHdr.label_date;
    dt.julian_day_fraction = dev->VolHdr.label_time;
    tm_decode(&dt, &tm);
-   Pmsg5(-1, "\
-Date label written: %04d-%02d-%02d at %02d:%02d\n", 
+   Pmsg5(-1,
+"Date label written: %04d-%02d-%02d at %02d:%02d\n",
       tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min);
    }
 
@@ -645,7 +645,7 @@ bail_out:
    debug_level = dbl;
 }
 
-bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec) 
+bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec)
 {
    ser_declare;
 
@@ -688,7 +688,7 @@ bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec)
       } else {
         label->JobStatus = JS_Terminated; /* kludge */
       }
-   }     
+   }
    return true;
 }
 
@@ -704,44 +704,44 @@ static void dump_session_label(DEV_RECORD *rec, const char *type)
    unser_session_label(&label, rec);
    dbl = debug_level;
    debug_level = 1;
-   Pmsg7(-1, "\n%s Record:\n\
-JobId             : %d\n\
-VerNum            : %d\n\
-PoolName          : %s\n\
-PoolType          : %s\n\
-JobName           : %s\n\
-ClientName        : %s\n\
-",    type, label.JobId, label.VerNum,
+   Pmsg7(-1, "\n%s Record:\n"
+"JobId             : %d\n"
+"VerNum            : %d\n"
+"PoolName          : %s\n"
+"PoolType          : %s\n"
+"JobName           : %s\n"
+"ClientName        : %s\n"
+"",    type, label.JobId, label.VerNum,
       label.PoolName, label.PoolType,
       label.JobName, label.ClientName);
 
    if (label.VerNum >= 10) {
-      Pmsg4(-1, "\
-Job (unique name) : %s\n\
-FileSet           : %s\n\
-JobType           : %c\n\
-JobLevel          : %c\n\
-", label.Job, label.FileSetName, label.JobType, label.JobLevel);
+      Pmsg4(-1, ""
+"Job (unique name) : %s\n"
+"FileSet           : %s\n"
+"JobType           : %c\n"
+"JobLevel          : %c\n"
+"", label.Job, label.FileSetName, label.JobType, label.JobLevel);
    }
 
    if (rec->FileIndex == EOS_LABEL) {
-      Pmsg8(-1, "\
-JobFiles          : %s\n\
-JobBytes          : %s\n\
-StartBlock        : %s\n\
-EndBlock          : %s\n\
-StartFile         : %s\n\
-EndFile           : %s\n\
-JobErrors         : %s\n\
-JobStatus         : %c\n\
-",
+      Pmsg8(-1, ""
+"JobFiles          : %s\n"
+"JobBytes          : %s\n"
+"StartBlock        : %s\n"
+"EndBlock          : %s\n"
+"StartFile         : %s\n"
+"EndFile           : %s\n"
+"JobErrors         : %s\n"
+"JobStatus         : %c\n"
+"",
         edit_uint64_with_commas(label.JobFiles, ec1),
         edit_uint64_with_commas(label.JobBytes, ec2),
         edit_uint64_with_commas(label.StartBlock, ec3),
         edit_uint64_with_commas(label.EndBlock, ec4),
         edit_uint64_with_commas(label.StartFile, ec5),
         edit_uint64_with_commas(label.EndFile, ec6),
-        edit_uint64_with_commas(label.JobErrors, ec7), 
+        edit_uint64_with_commas(label.JobErrors, ec7),
         label.JobStatus);
    }
    if (label.VerNum >= 11) {
@@ -752,8 +752,8 @@ JobStatus         : %c\n\
       dt.julian_day_number   = label.write_date;
       dt.julian_day_fraction = label.write_time;
       tm_decode(&dt, &tm);
-      Pmsg5(-1, _("\
-Date written      : %04d-%02d-%02d at %02d:%02d\n"),
+      Pmsg5(-1, _(""
+"Date written      : %04d-%02d-%02d at %02d:%02d\n"),
       tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min);
    }
 
@@ -769,7 +769,7 @@ void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose)
    debug_level = 1;
    switch (rec->FileIndex) {
    case PRE_LABEL:
-      type = _("Fresh Volume");   
+      type = _("Fresh Volume");
       break;
    case VOL_LABEL:
       type = _("Volume");
@@ -804,14 +804,14 @@ void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose)
         dump_session_label(rec, type);
         break;
       case EOM_LABEL:
-         Pmsg5(-1, "%s Record: SessId=%d SessTime=%d JobId=%d DataLen=%d\n",
+        Pmsg5(-1, "%s Record: SessId=%d SessTime=%d JobId=%d DataLen=%d\n",
            type, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
         break;
       case EOT_LABEL:
-         Pmsg0(-1, _("End of physical tape.\n"));
+        Pmsg0(-1, _("End of physical tape.\n"));
         break;
       default:
-         Pmsg5(-1, "%s Record: SessId=%d SessTime=%d JobId=%d DataLen=%d\n",
+        Pmsg5(-1, "%s Record: SessId=%d SessTime=%d JobId=%d DataLen=%d\n",
            type, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
         break;
       }
@@ -820,17 +820,17 @@ void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose)
       switch (rec->FileIndex) {
       case SOS_LABEL:
         unser_session_label(&label, rec);
-         Pmsg6(-1, "%s Record: SessId=%d SessTime=%d JobId=%d Level=%c Type=%c\n",
-           type, rec->VolSessionId, rec->VolSessionTime, rec->Stream, 
+        Pmsg6(-1, "%s Record: SessId=%d SessTime=%d JobId=%d Level=%c Type=%c\n",
+           type, rec->VolSessionId, rec->VolSessionTime, rec->Stream,
            label.JobLevel, label.JobType);
         break;
       case EOS_LABEL:
         char ed1[30], ed2[30];
         unser_session_label(&label, rec);
-         Pmsg6(-1, "%s Record: SessId=%d SessTime=%d JobId=%d Level=%c Type=%c\n",
-           type, rec->VolSessionId, rec->VolSessionTime, rec->Stream, 
+        Pmsg6(-1, "%s Record: SessId=%d SessTime=%d JobId=%d Level=%c Type=%c\n",
+           type, rec->VolSessionId, rec->VolSessionTime, rec->Stream,
            label.JobLevel, label.JobType);
-         Pmsg4(-1, "   Files=%s Bytes=%s Errors=%d Status=%c\n",
+        Pmsg4(-1, "   Files=%s Bytes=%s Errors=%d Status=%c\n",
            edit_uint64_with_commas(label.JobFiles, ed1),
            edit_uint64_with_commas(label.JobBytes, ed2),
            label.JobErrors, (char)label.JobStatus);
@@ -839,7 +839,7 @@ void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose)
       case PRE_LABEL:
       case VOL_LABEL:
       default:
-         Pmsg5(-1, "%s Record: SessId=%d SessTime=%d JobId=%d DataLen=%d\n",
+        Pmsg5(-1, "%s Record: SessId=%d SessTime=%d JobId=%d DataLen=%d\n",
       type, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
         break;
       case EOT_LABEL:
index 75faad0cbcc7a4affe5b4a5e1633b5ab6c2fdd60..d25dc016b82772ab929987f0ff618083d135a9b2 100755 (executable)
@@ -1,7 +1,7 @@
-/*     
+/*
  *   Match Bootstrap Records (used for restores) against
  *     Volume Records
- *  
+ *
  *     Kern Sibbald, June MMII
  *
  *   Version $Id$
@@ -65,7 +65,7 @@ void position_bsr_block(BSR *bsr, DEV_BLOCK *block)
 
 /*********************************************************************
  *
- *  Do fast block rejection based on bootstrap records. 
+ *  Do fast block rejection based on bootstrap records.
  *    use_fast_rejection will be set if we have VolSessionId and VolSessTime
  *    in each record. When BlockVer is >= 2, we have those in the block header
  *    so can do fast rejection.
@@ -142,7 +142,7 @@ int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *se
    if (bsr) {
       bsr->reposition = false;
       stat = match_all(bsr, rec, volrec, sessrec, true);
-      /* 
+      /*
        * Note, bsr->reposition is set by match_all when
        *  a bsr is done. We turn it off if a match was
        *  found or if we cannot use positioning
@@ -165,7 +165,7 @@ BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev)
    BSR *bsr;
    BSR *found_bsr = NULL;
 
-   if (!root_bsr || !root_bsr->use_positioning || 
+   if (!root_bsr || !root_bsr->use_positioning ||
        !root_bsr->reposition || !dev_is_tape(dev)) {
       Dmsg2(100, "No nxt_bsr use_pos=%d repos=%d\n", root_bsr->use_positioning, root_bsr->reposition);
       return NULL;
@@ -241,12 +241,12 @@ static BSR *find_smallest_volfile(BSR *found_bsr, BSR *bsr)
    return return_bsr;
 }
 
-/* 
+/*
  * Called to tell the matcher that the end of
  *   the current file has been reached.
  *  The bsr argument is not used, but is included
  *    for consistency with the other match calls.
- * 
+ *
  * Returns: true if we should reposition
  *       : false otherwise.
  */
@@ -269,13 +269,13 @@ bool match_set_eof(BSR *bsr, DEV_RECORD *rec)
    return false;
 }
 
-/* 
+/*
  * Match all the components of current record
  *   returns  1 on match
  *   returns  0 no match
  *   returns -1 no additional matches possible
  */
-static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, 
+static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
                     SESSION_LABEL *sessrec, bool done)
 {
    if (bsr->done) {
@@ -328,7 +328,7 @@ static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
     */
    if (!match_jobid(bsr, bsr->JobId, sessrec, 1)) {
       goto no_match;
-       
+
    }
    if (!match_job(bsr, bsr->job, sessrec, 1)) {
       goto no_match;
@@ -357,7 +357,7 @@ no_match:
    return 0;
 }
 
-static int match_volume(BSR *bsr, BSR_VOLUME *volume, VOLUME_LABEL *volrec, bool done) 
+static int match_volume(BSR *bsr, BSR_VOLUME *volume, VOLUME_LABEL *volrec, bool done)
 {
    if (!volume) {
       return 0;                      /* Volume must match */
@@ -467,7 +467,7 @@ static int match_volfile(BSR *bsr, BSR_VOLFILE *volfile, DEV_RECORD *rec, bool d
    if (volfile->done && done) {
       bsr->done = true;
       bsr->root->reposition = true;
-      Dmsg2(100, "bsr done from volfile rec=%d volefile=%d\n", 
+      Dmsg2(100, "bsr done from volfile rec=%d volefile=%d\n",
         rec->File, volfile->efile);
    }
    return 0;
index 66a040329237edc0e0852b4da45a4785049521aa..1b0cd6b52dc27cdcf8261c6ad3a128adacf7a28f 100644 (file)
@@ -4,7 +4,7 @@
  *    writing.
  *
  *   Kern Sibbald, August MMII
- *                           
+ *
  *   Version $Id$
  */
 /*
@@ -34,8 +34,8 @@ static bool rewrite_volume_label(DCR *dcr, bool recycle);
 
 
 /*
- * If release is set, we rewind the current volume, 
- * which we no longer want, and ask the user (console) 
+ * If release is set, we rewind the current volume,
+ * which we no longer want, and ask the user (console)
  * to mount the next volume.
  *
  *  Continue trying until we get it, and then ensure
@@ -58,7 +58,7 @@ bool mount_next_write_volume(DCR *dcr, bool release)
 
    init_dev_wait_timers(dev);
 
-   /* 
+   /*
     * Attempt to mount the next volume. If something non-fatal goes
     *  wrong, we come back here to re-try (new op messages, re-read
     *  Volume, ...)
@@ -69,7 +69,7 @@ mount_next_vol:
       /* Last ditch effort before giving up, force operator to respond */
       dcr->VolCatInfo.Slot = 0;
       if (!dir_ask_sysop_to_mount_volume(dcr)) {
-         Jmsg(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"), 
+        Jmsg(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"),
              dev_name(dev));
         return false;
       }
@@ -85,8 +85,8 @@ mount_next_vol:
       ask = true;                    /* ask operator to mount tape */
    }
 
-   /* 
-    * Get Director's idea of what tape we should have mounted. 
+   /*
+    * Get Director's idea of what tape we should have mounted.
     *   in dcr->VolCatInfo
     */
    Dmsg0(200, "Before dir_find_next_appendable_volume.\n");
@@ -103,11 +103,11 @@ mount_next_vol:
    Dmsg2(100, "After find_next_append. Vol=%s Slot=%d\n",
         dcr->VolCatInfo.VolCatName, dcr->VolCatInfo.Slot);
 
-   /* 
+   /*
     * Get next volume and ready it for append
     * This code ensures that the device is ready for
     * writing. We start from the assumption that there
-    * may not be a tape mounted. 
+    * may not be a tape mounted.
     *
     * If the device is a file, we create the output
     * file. If it is a tape, we check the volume name
@@ -126,7 +126,7 @@ mount_next_vol:
    Dmsg1(100, "autoload_dev returns %d\n", autochanger);
    /*
     * If we autochanged to correct Volume or (we have not just
-    *  released the Volume AND we can automount) we go ahead 
+    *  released the Volume AND we can automount) we go ahead
     *  and read the label. If there is no tape in the drive,
     *  we will err, recurse and ask the operator the next time.
     */
@@ -166,7 +166,7 @@ mount_next_vol:
     * Now make sure we have the right tape mounted
     */
 read_volume:
-   /* 
+   /*
     * If we are writing to a stream device, ASSUME the volume label
     *  is correct.
     */
@@ -198,21 +198,21 @@ read_volume:
 
       /* If not removable, Volume is broken */
       if (!dev_cap(dev, CAP_REM)) {
-         Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s.\n"),
+        Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s.\n"),
            dcr->VolumeName, dev_name(dev));
         mark_volume_in_error(dcr);
         goto mount_next_vol;
       }
-        
+
       Dmsg1(100, "Vol NAME Error Name=%s\n", dcr->VolumeName);
       /* If polling and got a previous bad name, ignore it */
       if (dev->poll && strcmp(dev->BadVolName, dev->VolHdr.VolName) == 0) {
         ask = true;
-         Dmsg1(200, "Vol Name error supress due to poll. Name=%s\n", 
+        Dmsg1(200, "Vol Name error supress due to poll. Name=%s\n",
            dcr->VolumeName);
         goto mount_next_vol;
       }
-      /* 
+      /*
        * OK, we got a different volume mounted. First save the
        *  requested Volume info (jcr) structure, then query if
        *  this volume is really OK. If not, put back the desired
@@ -223,9 +223,9 @@ read_volume:
       bstrncpy(dcr->VolumeName, dev->VolHdr.VolName, sizeof(dcr->VolumeName));
       if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE)) {
         bstrncpy(dev->BadVolName, dev->VolHdr.VolName, sizeof(dev->BadVolName));
-         Jmsg(jcr, M_WARNING, 0, _("Director wanted Volume \"%s\".\n"
-              "    Current Volume \"%s\" not acceptable because:\n"
-              "    %s"),
+        Jmsg(jcr, M_WARNING, 0, _("Director wanted Volume \"%s\".\n"
+             "    Current Volume \"%s\" not acceptable because:\n"
+             "    %s"),
             VolCatInfo.VolCatName, dev->VolHdr.VolName,
             jcr->dir_bsock->msg);
         /* Restore desired volume name, note device info out of sync */
@@ -242,9 +242,9 @@ read_volume:
     */
    case VOL_NO_LABEL:
    case VOL_IO_ERROR:
-      /* 
+      /*
        * If permitted, we label the device, make sure we can do
-       *   it by checking that the VolCatBytes is zero => not labeled, 
+       *   it by checking that the VolCatBytes is zero => not labeled,
        *   once the Volume is labeled we don't want to label another
        *   blank tape with the same name.  For disk, we go ahead and
        *   label it anyway, because the OS insures that there is only
@@ -254,28 +254,28 @@ read_volume:
        *   previous tape (or nothing).
        */
       if (dev_cap(dev, CAP_LABEL) && (dcr->VolCatInfo.VolCatBytes == 0 ||
-           (!dev_is_tape(dev) && strcmp(dcr->VolCatInfo.VolCatStatus, 
-                                   "Recycle") == 0))) {
-         Dmsg0(100, "Create volume label\n");
+           (!dev_is_tape(dev) && strcmp(dcr->VolCatInfo.VolCatStatus,
+                                  "Recycle") == 0))) {
+        Dmsg0(100, "Create volume label\n");
         /* Create a new Volume label and write it to the device */
         if (!write_new_volume_label_to_dev(dcr, dcr->VolumeName,
                dcr->pool_name)) {
-            Dmsg0(100, "!write_vol_label\n");
+           Dmsg0(100, "!write_vol_label\n");
            goto mount_next_vol;
         }
-         Dmsg0(100, "dir_update_vol_info. Set Append\n");
-         /* Copy Director's info into the device info */
+        Dmsg0(100, "dir_update_vol_info. Set Append\n");
+        /* Copy Director's info into the device info */
         memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
         if (!dir_update_volume_info(dcr, true)) {  /* indicate tape labeled */
            return false;
         }
-         Jmsg(jcr, M_INFO, 0, _("Labeled new Volume \"%s\" on device %s.\n"),
+        Jmsg(jcr, M_INFO, 0, _("Labeled new Volume \"%s\" on device %s.\n"),
            dcr->VolumeName, dev_name(dev));
         goto read_volume;      /* read label we just wrote */
-      } 
+      }
       /* If not removable, Volume is broken */
       if (!dev_cap(dev, CAP_REM)) {
-         Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s.\n"),
+        Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s.\n"),
            dcr->VolumeName, dev_name(dev));
         mark_volume_in_error(dcr);
         goto mount_next_vol;
@@ -285,15 +285,15 @@ read_volume:
    default:
       /* Send error message */
       if (!dev->poll) {
-         Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);                         
+        Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
       } else {
-         Dmsg1(200, "Msg suppressed by poll: %s\n", jcr->errmsg);
+        Dmsg1(200, "Msg suppressed by poll: %s\n", jcr->errmsg);
       }
       ask = true;
       goto mount_next_vol;
    }
 
-   /* 
+   /*
     * See if we have a fresh tape or a tape with data.
     *
     * Note, if the LabelType is PRE_LABEL, it was labeled
@@ -320,7 +320,7 @@ read_volume:
       Jmsg(jcr, M_INFO, 0, _("Volume \"%s\" previously written, moving to end of data.\n"),
         dcr->VolumeName);
       if (!eod_dev(dev)) {
-         Jmsg(jcr, M_ERROR, 0, _("Unable to position to end of data on device \"%s\". ERR=%s\n"),
+        Jmsg(jcr, M_ERROR, 0, _("Unable to position to end of data on device \"%s\". ERR=%s\n"),
            dev_name(dev), strerror_dev(dev));
         mark_volume_in_error(dcr);
         goto mount_next_vol;
@@ -332,11 +332,11 @@ read_volume:
          * that the database says we should be.
          */
         if (dev->VolCatInfo.VolCatFiles == dev_file(dev)) {
-            Jmsg(jcr, M_INFO, 0, _("Ready to append to end of Volume \"%s\" at file=%d.\n"), 
+           Jmsg(jcr, M_INFO, 0, _("Ready to append to end of Volume \"%s\" at file=%d.\n"),
                 dcr->VolumeName, dev_file(dev));
         } else {
-            Jmsg(jcr, M_ERROR, 0, _("I canot write on Volume \"%s\" because:\n\
-The number of files mismatch! Volume=%u Catalog=%u\n"), 
+           Jmsg(jcr, M_ERROR, 0, _("I canot write on Volume \"%s\" because:\n"
+"The number of files mismatch! Volume=%u Catalog=%u\n"),
                 dcr->VolumeName, dev_file(dev), dev->VolCatInfo.VolCatFiles);
            mark_volume_in_error(dcr);
            goto mount_next_vol;
@@ -356,7 +356,7 @@ The number of files mismatch! Volume=%u Catalog=%u\n"),
 }
 
 /*
- * Write a volume label. 
+ * Write a volume label.
  *  Returns: true if OK
  *          false if unable to write it
  */
@@ -379,21 +379,21 @@ static bool rewrite_volume_label(DCR *dcr, bool recycle)
     */
    if (!dev_cap(dev, CAP_STREAM)) {
       if (!rewind_dev(dev)) {
-         Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device \"%s\". ERR=%s\n"), 
+        Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device \"%s\". ERR=%s\n"),
               dev_name(dev), strerror_dev(dev));
       }
       if (recycle) {
         if (!truncate_dev(dev)) {
-            Jmsg2(jcr, M_WARNING, 0, _("Truncate error on device \"%s\". ERR=%s\n"), 
+           Jmsg2(jcr, M_WARNING, 0, _("Truncate error on device \"%s\". ERR=%s\n"),
                  dev_name(dev), strerror_dev(dev));
         }
       }
       /* Attempt write to check write permission */
       Dmsg0(200, "Attempt to write to device.\n");
       if (!write_block_to_dev(dcr)) {
-         Jmsg2(jcr, M_ERROR, 0, _("Unable to write device \"%s\". ERR=%s\n"),
+        Jmsg2(jcr, M_ERROR, 0, _("Unable to write device \"%s\". ERR=%s\n"),
            dev_name(dev), strerror_dev(dev));
-         Dmsg0(200, "===ERROR write block to dev\n");
+        Dmsg0(200, "===ERROR write block to dev\n");
         return false;
       }
    }
@@ -405,7 +405,7 @@ static bool rewrite_volume_label(DCR *dcr, bool recycle)
    dev->VolCatInfo.VolCatBlocks = 0;
    dev->VolCatInfo.VolCatRBytes = 0;
    if (recycle) {
-      dev->VolCatInfo.VolCatMounts++;  
+      dev->VolCatInfo.VolCatMounts++;
       dev->VolCatInfo.VolCatRecycles++;
    } else {
       dev->VolCatInfo.VolCatMounts = 1;
@@ -435,7 +435,7 @@ static bool rewrite_volume_label(DCR *dcr, bool recycle)
 
 
 /*
- * Mark volume in error in catalog 
+ * Mark volume in error in catalog
  */
 void mark_volume_in_error(DCR *dcr)
 {
@@ -447,7 +447,7 @@ void mark_volume_in_error(DCR *dcr)
    dir_update_volume_info(dcr, false);
 }
 
-/* 
+/*
  * If we are reading, we come here at the end of the tape
  *  and see if there are more volumes to be mounted.
  */
@@ -461,9 +461,9 @@ bool mount_next_read_volume(DCR *dcr)
     */
    if (jcr->NumVolumes > 1 && jcr->CurVolume < jcr->NumVolumes) {
       close_dev(dev);
-      dev->state &= ~ST_READ; 
+      dev->state &= ~ST_READ;
       if (!acquire_device_for_read(jcr)) {
-         Jmsg2(jcr, M_FATAL, 0, "Cannot open Dev=%s, Vol=%s\n", dev_name(dev),
+        Jmsg2(jcr, M_FATAL, 0, "Cannot open Dev=%s, Vol=%s\n", dev_name(dev),
               dcr->VolumeName);
         return false;
       }
@@ -485,8 +485,8 @@ void release_volume(DCR *dcr)
       Jmsg0(jcr, M_ERROR, 0, "Hey!!!!! WroteVol non-zero !!!!!\n");
       Dmsg0(190, "Hey!!!!! WroteVol non-zero !!!!!\n");
    }
-   /* 
-    * First erase all memory of the current volume   
+   /*
+    * First erase all memory of the current volume
     */
    dev->block_num = dev->file = 0;
    dev->EndBlock = dev->EndFile = 0;
@@ -497,7 +497,7 @@ void release_volume(DCR *dcr)
    dev->state &= ~(ST_LABEL|ST_READ|ST_APPEND);
    dcr->VolumeName[0] = 0;
 
-   if ((dev->state & ST_OPENED) && 
+   if ((dev->state & ST_OPENED) &&
        (!dev_is_tape(dev) || !dev_cap(dev, CAP_ALWAYSOPEN))) {
       offline_or_rewind_dev(dev);
       close_dev(dev);
index 4ff019b30c51ef272ebfef784fd06f822c736c10..b9a2e0e44b6769a1e904dc791984a978a5ca79fc 100755 (executable)
@@ -1,6 +1,6 @@
-/*     
- *   Parse a Bootstrap Records (used for restores) 
- *  
+/*
+ *   Parse a Bootstrap Records (used for restores)
+ *
  *     Kern Sibbald, June MMII
  *
  *   Version $Id$
@@ -79,7 +79,7 @@ struct kw_items items[] = {
 
 };
 
-/* 
+/*
  * Create a BSR record
  */
 static BSR *new_bsr()
@@ -90,7 +90,7 @@ static BSR *new_bsr()
 }
 
 /*
- * Format a scanner error message 
+ * Format a scanner error message
  */
 static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
 {
@@ -101,14 +101,14 @@ static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
    va_start(arg_ptr, msg);
    bvsnprintf(buf, sizeof(buf), msg, arg_ptr);
    va_end(arg_ptr);
-     
+
    if (jcr) {
-      Jmsg(jcr, M_FATAL, 0, _("Bootstrap file error: %s\n\
-            : Line %d, col %d of file %s\n%s\n"),
+      Jmsg(jcr, M_FATAL, 0, _("Bootstrap file error: %s\n"
+"            : Line %d, col %d of file %s\n%s\n"),
         buf, lc->line_no, lc->col_no, lc->fname, lc->line);
    } else {
-      e_msg(file, line, M_FATAL, 0, _("Bootstrap file error: %s\n\
-            : Line %d, col %d of file %s\n%s\n"),
+      e_msg(file, line, M_FATAL, 0, _("Bootstrap file error: %s\n"
+"            : Line %d, col %d of file %s\n%s\n"),
         buf, lc->line_no, lc->col_no, lc->fname, lc->line);
    }
 }
@@ -125,7 +125,7 @@ BSR *parse_bsr(JCR *jcr, char *fname)
    int token, i;
    BSR *root_bsr = new_bsr();
    BSR *bsr = root_bsr;
-     
+
    Dmsg1(200, "Enter parse_bsf %s\n", fname);
    lc = lex_open_file(lc, fname, s_err);
    lc->caller_ctx = (void *)jcr;
@@ -137,13 +137,13 @@ BSR *parse_bsr(JCR *jcr, char *fname)
       for (i=0; items[i].name; i++) {
         if (strcasecmp(items[i].name, lc->str) == 0) {
            token = lex_get_token(lc, T_ALL);
-            Dmsg1 (200, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
+           Dmsg1 (200, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
            if (token != T_EQUALS) {
-               scan_err1(lc, "expected an equals, got: %s", lc->str);
+              scan_err1(lc, "expected an equals, got: %s", lc->str);
               bsr = NULL;
               break;
            }
-            Dmsg1(200, "calling handler for %s\n", items[i].name);
+           Dmsg1(200, "calling handler for %s\n", items[i].name);
            /* Call item handler */
            bsr = items[i].handler(lc, bsr);
            i = -1;
@@ -151,8 +151,8 @@ BSR *parse_bsr(JCR *jcr, char *fname)
         }
       }
       if (i >= 0) {
-         Dmsg1(200, "Keyword = %s\n", lc->str);
-         scan_err1(lc, "Keyword %s not found", lc->str);
+        Dmsg1(200, "Keyword = %s\n", lc->str);
+        scan_err1(lc, "Keyword %s not found", lc->str);
         bsr = NULL;
         break;
       }
@@ -213,7 +213,7 @@ static BSR *store_vol(LEX *lc, BSR *bsr)
    int token;
    BSR_VOLUME *volume;
    char *p, *n;
-    
+
    token = lex_get_token(lc, T_STRING);
    if (token == T_ERROR) {
       return NULL;
@@ -222,7 +222,7 @@ static BSR *store_vol(LEX *lc, BSR *bsr)
       bsr->next = new_bsr();
       bsr = bsr->next;
    }
-   /* This may actually be more than one volume separated by a |  
+   /* This may actually be more than one volume separated by a |
     * If so, separate them.
     */
    for (p=lc->str; p && *p; ) {
@@ -238,7 +238,7 @@ static BSR *store_vol(LEX *lc, BSR *bsr)
         bsr->volume = volume;
       } else {
         BSR_VOLUME *bc = bsr->volume;
-        for ( ;bc->next; bc=bc->next)  
+        for ( ;bc->next; bc=bc->next)
            { }
         bc->next = volume;
       }
@@ -251,7 +251,7 @@ static BSR *store_client(LEX *lc, BSR *bsr)
 {
    int token;
    BSR_CLIENT *client;
-    
+
    for (;;) {
       token = lex_get_token(lc, T_NAME);
       if (token == T_ERROR) {
@@ -265,7 +265,7 @@ static BSR *store_client(LEX *lc, BSR *bsr)
         bsr->client = client;
       } else {
         BSR_CLIENT *bc = bsr->client;
-        for ( ;bc->next; bc=bc->next)  
+        for ( ;bc->next; bc=bc->next)
            { }
         bc->next = client;
       }
@@ -281,7 +281,7 @@ static BSR *store_job(LEX *lc, BSR *bsr)
 {
    int token;
    BSR_JOB *job;
-    
+
    for (;;) {
       token = lex_get_token(lc, T_NAME);
       if (token == T_ERROR) {
@@ -407,7 +407,7 @@ static BSR *store_joblevel(LEX *lc, BSR *bsr)
 
 
 /*
- * Routine to handle Volume start/end file   
+ * Routine to handle Volume start/end file
  */
 static BSR *store_volfile(LEX *lc, BSR *bsr)
 {
@@ -443,7 +443,7 @@ static BSR *store_volfile(LEX *lc, BSR *bsr)
 
 
 /*
- * Routine to handle Volume start/end Block  
+ * Routine to handle Volume start/end Block
  */
 static BSR *store_volblock(LEX *lc, BSR *bsr)
 {
@@ -619,9 +619,9 @@ void dump_findex(BSR_FINDEX *FileIndex)
 {
    if (FileIndex) {
       if (FileIndex->findex == FileIndex->findex2) {
-         Dmsg1(-1, "FileIndex   : %u\n", FileIndex->findex);
+        Dmsg1(-1, "FileIndex   : %u\n", FileIndex->findex);
       } else {
-         Dmsg2(-1, "FileIndex   : %u-%u\n", FileIndex->findex, FileIndex->findex2);
+        Dmsg2(-1, "FileIndex   : %u-%u\n", FileIndex->findex, FileIndex->findex2);
       }
       dump_findex(FileIndex->next);
    }
@@ -631,9 +631,9 @@ void dump_jobid(BSR_JOBID *jobid)
 {
    if (jobid) {
       if (jobid->JobId == jobid->JobId2) {
-         Dmsg1(-1, "JobId       : %u\n", jobid->JobId);
+        Dmsg1(-1, "JobId       : %u\n", jobid->JobId);
       } else {
-         Dmsg2(-1, "JobId       : %u-%u\n", jobid->JobId, jobid->JobId2);
+        Dmsg2(-1, "JobId       : %u-%u\n", jobid->JobId, jobid->JobId2);
       }
       dump_jobid(jobid->next);
    }
@@ -643,9 +643,9 @@ void dump_sessid(BSR_SESSID *sessid)
 {
    if (sessid) {
       if (sessid->sessid == sessid->sessid2) {
-         Dmsg1(-1, "SessId      : %u\n", sessid->sessid);
+        Dmsg1(-1, "SessId      : %u\n", sessid->sessid);
       } else {
-         Dmsg2(-1, "SessId      : %u-%u\n", sessid->sessid, sessid->sessid2);
+        Dmsg2(-1, "SessId      : %u-%u\n", sessid->sessid, sessid->sessid2);
       }
       dump_sessid(sessid->next);
    }
@@ -762,7 +762,7 @@ void free_bsr(BSR *bsr)
 }
 
 /*****************************************************************
- * Routines for handling volumes     
+ * Routines for handling volumes
  */
 VOL_LIST *new_vol()
 {
@@ -772,7 +772,7 @@ VOL_LIST *new_vol()
    return vol;
 }
 
-/* 
+/*
  * Add current volume to end of list, only if the Volume
  * is not already in the list.
  *
@@ -827,7 +827,7 @@ void create_vol_list(JCR *jcr)
    char *p, *n;
    VOL_LIST *vol;
 
-   /* 
+   /*
     * Build a list of volumes to be processed
     */
    jcr->NumVolumes = 0;
@@ -855,18 +855,18 @@ void create_vol_list(JCR *jcr)
            vol->start_file = sfile;
            if (add_vol(jcr, vol)) {
               jcr->NumVolumes++;
-               Dmsg1(400, "Added volume %s\n", vol->VolumeName);
+              Dmsg1(400, "Added volume %s\n", vol->VolumeName);
            } else {
-               Dmsg1(400, "Duplicate volume %s\n", vol->VolumeName);
+              Dmsg1(400, "Duplicate volume %s\n", vol->VolumeName);
               free((char *)vol);
            }
            sfile = 0;                /* start at beginning of second volume */
         }
       }
    } else {
-      /* This is the old way -- deprecated */ 
+      /* This is the old way -- deprecated */
       for (p = jcr->dcr->VolumeName; p && *p; ) {
-         n = strchr(p, '|');             /* volume name separator */
+        n = strchr(p, '|');             /* volume name separator */
         if (n) {
            *n++ = 0;                    /* Terminate name */
         }
index 38633dc1c8c22c9add4dab230acb91f432fa60dd..29cb0491585bdd41b43239bacb0bf0f95ad580ac 100644 (file)
@@ -23,7 +23,7 @@
    MA 02111-1307, USA.
 
  */
-   
+
 /* From stored.c */
 uint32_t new_VolSessionId();
 
@@ -139,7 +139,7 @@ void         dev_unlock(DEVICE *dev);
 const char *edit_blocked_reason(DEVICE *dev);
 
 /* From dircmd.c */
-void    *handle_connection_request(void *arg); 
+void    *handle_connection_request(void *arg);
 
 
 /* From fd_cmds.c */
@@ -148,7 +148,7 @@ bool         bootstrap_cmd(JCR *jcr);
 
 /* From job.c */
 void    stored_free_jcr(JCR *jcr);
-void    connection_from_filed(void *arg);     
+void    connection_from_filed(void *arg);
 void    handle_filed_connection(BSOCK *fd, char *job_name);
 
 /* From label.c */
@@ -164,7 +164,7 @@ bool         unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
 bool    unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
 
 /* From match_bsr.c */
-int     match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, 
+int     match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
              SESSION_LABEL *sesrec);
 int     match_bsr_block(BSR *bsr, DEV_BLOCK *block);
 void    position_bsr_block(BSR *bsr, DEV_BLOCK *block);
@@ -191,7 +191,7 @@ const char *FI_to_ascii(int fi);
 const char *stream_to_ascii(int stream, int fi);
 bool       write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
 bool       can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
-bool       read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec); 
+bool       read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
 DEV_RECORD *new_record();
 void       free_record(DEV_RECORD *rec);
 void       empty_record(DEV_RECORD *rec);
index 937ae4ba2d26f5b278c084449fcd4824328dfd84..c91aca91205707c660aefe7291e679842208f22a 100644 (file)
@@ -37,17 +37,17 @@ static char OK_data[]    = "3000 OK data\n";
 static char FD_error[]   = "3000 error\n";
 static char rec_header[] = "rechdr %ld %ld %ld %ld %ld";
 
-/* 
+/*
  *  Read Data and send to File Daemon
  *   Returns: false on failure
  *           true  on success
  */
-bool do_read_data(JCR *jcr) 
+bool do_read_data(JCR *jcr)
 {
    BSOCK *fd = jcr->file_bsock;
    bool ok = true;
    DCR *dcr;
-   
+
    Dmsg0(20, "Start read data.\n");
 
    if (!bnet_set_buffer_size(fd, jcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) {
@@ -63,10 +63,10 @@ bool do_read_data(JCR *jcr)
       return false;
    }
 
-   Dmsg2(200, "Found %d volumes names to restore. First=%s\n", jcr->NumVolumes, 
+   Dmsg2(200, "Found %d volumes names to restore. First=%s\n", jcr->NumVolumes,
       jcr->VolList->VolumeName);
 
-   /* 
+   /*
     * Ready device for reading, and read records
     */
    if (!(dcr=acquire_device_for_read(jcr))) {
@@ -84,7 +84,7 @@ bool do_read_data(JCR *jcr)
    if (!release_device(jcr)) {
       ok = false;
    }
-   
+
    free_vol_list(jcr);
    Dmsg0(30, "Done reading.\n");
    return ok;
index 827d9e44aa71d5c3722874503d71c7806b5bbda5..6a6c6db381cc5d605fb9c2e78c1f91a0de469fff 100644 (file)
@@ -67,10 +67,10 @@ bool read_records(DCR *dcr,
         if (dev_state(dev, ST_EOT)) {
            DEV_RECORD *trec = new_record();
 
-            Jmsg(jcr, M_INFO, 0, "End of Volume at file %u on device %s, Volume \"%s\"\n", 
+           Jmsg(jcr, M_INFO, 0, "End of Volume at file %u on device %s, Volume \"%s\"\n",
                 dev->file, dev_name(dev), dcr->VolumeName);
            if (!mount_cb(dcr)) {
-               Jmsg(jcr, M_INFO, 0, "End of all volumes.\n");
+              Jmsg(jcr, M_INFO, 0, "End of all volumes.\n");
               ok = false;
               /*
                * Create EOT Label so that Media record may
@@ -99,21 +99,21 @@ bool read_records(DCR *dcr,
 
         } else if (dev_state(dev, ST_EOF)) {
            if (verbose) {
-               Jmsg(jcr, M_INFO, 0, "Got EOF at file %u  on device %s, Volume \"%s\"\n", 
+              Jmsg(jcr, M_INFO, 0, "Got EOF at file %u  on device %s, Volume \"%s\"\n",
                  dev->file, dev_name(dev), dcr->VolumeName);
            }
-            Dmsg3(200, "Got EOF at file %u  on device %s, Volume \"%s\"\n", 
+           Dmsg3(200, "Got EOF at file %u  on device %s, Volume \"%s\"\n",
                  dev->file, dev_name(dev), dcr->VolumeName);
            continue;
         } else if (dev_state(dev, ST_SHORT)) {
-            Jmsg1(jcr, M_ERROR, 0, "%s", dev->errmsg);
+           Jmsg1(jcr, M_ERROR, 0, "%s", dev->errmsg);
            continue;
         } else {
            /* I/O error or strange end of tape */
            display_tape_error_status(jcr, dev);
            if (forge_on || jcr->ignore_label_errors) {
               fsr_dev(dev, 1);       /* try skipping bad record */
-               Dmsg0(000, "Did fsr\n");
+              Dmsg0(000, "Did fsr\n");
               continue;              /* try to continue */
            }
            ok = false;
@@ -133,7 +133,7 @@ bool read_records(DCR *dcr,
 
       /*
        * Get a new record for each Job as defined by
-       *   VolSessionId and VolSessionTime 
+       *   VolSessionId and VolSessionTime
        */
       bool found = false;
       foreach_dlist(rec, recs) {
@@ -146,28 +146,28 @@ bool read_records(DCR *dcr,
       if (!found) {
         rec = new_record();
         recs->prepend(rec);
-         Dmsg2(300, "New record for SI=%d ST=%d\n",
+        Dmsg2(300, "New record for SI=%d ST=%d\n",
             block->VolSessionId, block->VolSessionTime);
       } else {
 #ifdef xxx
         if (rec->Block != 0 && (rec->Block+1) != block->BlockNumber) {
-            Jmsg(jcr, M_ERROR, 0, _("Invalid block number. Expected %u, got %u\n"),
+           Jmsg(jcr, M_ERROR, 0, _("Invalid block number. Expected %u, got %u\n"),
                 rec->Block+1, block->BlockNumber);
         }
-#endif 
+#endif
       }
-      Dmsg3(300, "After mount next vol. stat=%s blk=%d rem=%d\n", rec_state_to_str(rec), 
+      Dmsg3(300, "After mount next vol. stat=%s blk=%d rem=%d\n", rec_state_to_str(rec),
            block->BlockNumber, rec->remainder);
       record = 0;
       rec->state = 0;
       Dmsg1(300, "Block empty %d\n", is_block_empty(rec));
       for (rec->state=0; !is_block_empty(rec); ) {
         if (!read_record_from_block(block, rec)) {
-            Dmsg3(400, "!read-break. state=%s blk=%d rem=%d\n", rec_state_to_str(rec), 
+           Dmsg3(400, "!read-break. state=%s blk=%d rem=%d\n", rec_state_to_str(rec),
                  block->BlockNumber, rec->remainder);
            break;
         }
-         Dmsg5(300, "read-OK. state=%s blk=%d rem=%d file:block=%d:%d\n", 
+        Dmsg5(300, "read-OK. state=%s blk=%d rem=%d file:block=%d:%d\n",
                 rec_state_to_str(rec), block->BlockNumber, rec->remainder,
                 dev->file, dev->block_num);
         /*
@@ -177,21 +177,21 @@ bool read_records(DCR *dcr,
          *  get all the data.
          */
         record++;
-         Dmsg6(300, "recno=%d state=%s blk=%d SI=%d ST=%d FI=%d\n", record,
+        Dmsg6(300, "recno=%d state=%s blk=%d SI=%d ST=%d FI=%d\n", record,
            rec_state_to_str(rec), block->BlockNumber,
            rec->VolSessionId, rec->VolSessionTime, rec->FileIndex);
 
         if (rec->FileIndex == EOM_LABEL) { /* end of tape? */
-            Dmsg0(40, "Get EOM LABEL\n");
+           Dmsg0(40, "Get EOM LABEL\n");
            break;                         /* yes, get out */
         }
 
-        /* Some sort of label? */ 
+        /* Some sort of label? */
         if (rec->FileIndex < 0) {
            handle_session_record(dev, rec, &sessrec);
            ok = record_cb(dcr, rec);
            if (rec->FileIndex == EOS_LABEL) {
-               Dmsg2(300, "Remove rec. SI=%d ST=%d\n", rec->VolSessionId,
+              Dmsg2(300, "Remove rec. SI=%d ST=%d\n", rec->VolSessionId,
                  rec->VolSessionTime);
               recs->remove(rec);
               free_record(rec);
@@ -199,42 +199,42 @@ bool read_records(DCR *dcr,
            continue;
         } /* end if label record */
 
-        /* 
+        /*
          * Apply BSR filter
          */
         if (jcr->bsr) {
            int stat = match_bsr(jcr->bsr, rec, &dev->VolHdr, &sessrec);
            if (stat == -1) { /* no more possible matches */
               done = true;   /* all items found, stop */
-               Dmsg2(300, "All done=(file:block) %d:%d\n", dev->file, dev->block_num);
+              Dmsg2(300, "All done=(file:block) %d:%d\n", dev->file, dev->block_num);
               break;
            } else if (stat == 0) {  /* no match */
-               Dmsg4(300, "Clear rem=%d FI=%d before set_eof pos %d:%d\n", 
+              Dmsg4(300, "Clear rem=%d FI=%d before set_eof pos %d:%d\n",
                  rec->remainder, rec->FileIndex, dev->file, dev->block_num);
               rec->remainder = 0;
               rec->state &= ~REC_PARTIAL_RECORD;
               if (try_repositioning(jcr, rec, dev)) {
                  break;
               }
-               continue;              /* we don't want record, read next one */
+              continue;              /* we don't want record, read next one */
            }
         }
         if (is_partial_record(rec)) {
-            Dmsg6(300, "Partial, break. recno=%d state=%s blk=%d SI=%d ST=%d FI=%d\n", record,
+           Dmsg6(300, "Partial, break. recno=%d state=%s blk=%d SI=%d ST=%d FI=%d\n", record,
               rec_state_to_str(rec), block->BlockNumber,
               rec->VolSessionId, rec->VolSessionTime, rec->FileIndex);
            break;                    /* read second part of record */
         }
         ok = record_cb(dcr, rec);
         if (rec->Stream == STREAM_MD5_SIGNATURE || rec->Stream == STREAM_SHA1_SIGNATURE) {
-            Dmsg3(300, "Done FI=%d before set_eof pos %d:%d\n", rec->FileIndex,
+           Dmsg3(300, "Done FI=%d before set_eof pos %d:%d\n", rec->FileIndex,
                  dev->file, dev->block_num);
            if (match_set_eof(jcr->bsr, rec) && try_repositioning(jcr, rec, dev)) {
-               Dmsg2(300, "Break after match_set_eof pos %d:%d\n",
+              Dmsg2(300, "Break after match_set_eof pos %d:%d\n",
                     dev->file, dev->block_num);
               break;
            }
-            Dmsg2(300, "After set_eof pos %d:%d\n", dev->file, dev->block_num);
+           Dmsg2(300, "After set_eof pos %d:%d\n", dev->file, dev->block_num);
         }
       } /* end for loop over records */
       Dmsg2(300, "After end records position=(file:block) %d:%d\n", dev->file, dev->block_num);
@@ -269,10 +269,10 @@ static int try_repositioning(JCR *jcr, DEV_RECORD *rec, DEVICE *dev)
       dev->state |= ST_EOT;
       rec->Block = 0;
       return 1;
-   }    
+   }
    if (bsr) {
       if (verbose) {
-         Jmsg(jcr, M_INFO, 0, "Reposition from (file:block) %d:%d to %d:%d\n",
+        Jmsg(jcr, M_INFO, 0, "Reposition from (file:block) %d:%d to %d:%d\n",
            dev->file, dev->block_num, bsr->volfile->sfile,
            bsr->volblock->sblock);
       }
@@ -292,16 +292,16 @@ static BSR *position_to_first_file(JCR *jcr, DEVICE *dev)
 {
    BSR *bsr = NULL;
    /*
-    * Now find and position to first file and block 
+    * Now find and position to first file and block
     *  on this tape.
     */
    if (jcr->bsr) {
       jcr->bsr->reposition = true;    /* force repositioning */
       bsr = find_next_bsr(jcr->bsr, dev);
       if (bsr && (bsr->volfile->sfile != 0 || bsr->volblock->sblock != 0)) {
-         Jmsg(jcr, M_INFO, 0, _("Forward spacing to file:block %u:%u.\n"), 
+        Jmsg(jcr, M_INFO, 0, _("Forward spacing to file:block %u:%u.\n"),
            bsr->volfile->sfile, bsr->volblock->sblock);
-         Dmsg2(300, "Forward spacing to file:block %u:%u.\n", 
+        Dmsg2(300, "Forward spacing to file:block %u:%u.\n",
            bsr->volfile->sfile, bsr->volblock->sblock);
         reposition_dev(dev, bsr->volfile->sfile, bsr->volblock->sblock);
       }
@@ -314,11 +314,11 @@ static void handle_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *s
 {
    const char *rtype;
    char buf[100];
-   
+
    memset(sessrec, 0, sizeof(sessrec));
    switch (rec->FileIndex) {
    case PRE_LABEL:
-      rtype = "Fresh Volume Label";   
+      rtype = "Fresh Volume Label";
       break;
    case VOL_LABEL:
       rtype = "Volume Label";
@@ -346,7 +346,7 @@ static void handle_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *s
 #ifdef DEBUG
 static char *rec_state_to_str(DEV_RECORD *rec)
 {
-   static char buf[200]; 
+   static char buf[200];
    buf[0] = 0;
    if (rec->state & REC_NO_HEADER) {
       bstrncat(buf, "Nohdr,", sizeof(buf));
index 3275c91452f049b3bcaeece8e1da5341c4d0f902..dce3c1c9c57c23b7f861bb85365f5372623e45b1 100644 (file)
@@ -69,7 +69,7 @@ const char *FI_to_ascii(int fi)
 }
 
 
-/* 
+/*
  * Convert a Stream ID into a printable
  * ASCII string.  Not reentrant.
 
@@ -85,7 +85,7 @@ const char *stream_to_ascii(int stream, int fi)
     static char buf[20];
     if (fi < 0) {
        sprintf(buf, "%d", stream);
-       return buf;     
+       return buf;
     }
     switch (stream) {
     case STREAM_UNIX_ATTRIBUTES:
@@ -146,11 +146,11 @@ const char *stream_to_ascii(int stream, int fi)
        return "contHFSPLUS-ATTR";
     default:
        sprintf(buf, "%d", stream);
-       return buf;     
+       return buf;
     }
 }
 
-/* 
+/*
  * Return a new record entity
  */
 DEV_RECORD *new_record(void)
@@ -173,10 +173,10 @@ void empty_record(DEV_RECORD *rec)
 }
 
 /*
- * Free the record entity 
+ * Free the record entity
  *
  */
-void free_record(DEV_RECORD *rec) 
+void free_record(DEV_RECORD *rec)
 {
    Dmsg0(350, "Enter free_record.\n");
    if (rec->data) {
@@ -185,7 +185,7 @@ void free_record(DEV_RECORD *rec)
    Dmsg0(350, "Data buf is freed.\n");
    free_pool_memory((POOLMEM *)rec);
    Dmsg0(350, "Leave free_record.\n");
-} 
+}
 
 
 /*
@@ -212,9 +212,9 @@ bool write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec)
    ASSERT(block->binbuf == (uint32_t) (block->bufp - block->buf));
    ASSERT(block->buf_len >= block->binbuf);
 
-   Dmsg6(890, "write_record_to_block() FI=%s SessId=%d Strm=%s len=%d\n\
-rem=%d remainder=%d\n",
-      FI_to_ascii(rec->FileIndex), rec->VolSessionId, 
+   Dmsg6(890, "write_record_to_block() FI=%s SessId=%d Strm=%s len=%d\n"
+"rem=%d remainder=%d\n",
+      FI_to_ascii(rec->FileIndex), rec->VolSessionId,
       stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len,
       remlen, rec->remainder);
 
@@ -254,15 +254,15 @@ rem=%d remainder=%d\n",
         return false;
       }
    } else {
-      /* 
+      /*
        * We are here to write unwritten bytes from a previous
-       * time. Presumably we have a new buffer (possibly 
-       * containing a volume label), so the new header 
+       * time. Presumably we have a new buffer (possibly
+       * containing a volume label), so the new header
        * should be able to fit in the block -- otherwise we have
        * an error.  Note, we have to continue splitting the
        * data record if it is longer than the block.
-       * 
-       * First, write the header, then write as much as 
+       *
+       * First, write the header, then write as much as
        * possible of the data record.
        *
        * Every time we write a header and it is a continuation
@@ -307,7 +307,7 @@ rem=%d remainder=%d\n",
 
    /*
     * Now deal with data record.
-    * Part of it may have already been transferred, and we 
+    * Part of it may have already been transferred, and we
     * may not have enough room to transfer the whole this time.
     */
    if (rec->remainder > 0) {
@@ -318,23 +318,23 @@ rem=%d remainder=%d\n",
         block->bufp += rec->remainder;
         block->binbuf += rec->remainder;
       } else {
-        memcpy(block->bufp, rec->data+rec->data_len-rec->remainder, 
+        memcpy(block->bufp, rec->data+rec->data_len-rec->remainder,
                remlen);
 #ifdef xxxxxSMCHECK
         if (!sm_check_rtn(__FILE__, __LINE__, False)) {
            /* We damaged a buffer */
-            Dmsg6(0, "Damaged block FI=%s SessId=%d Strm=%s len=%d\n\
-rem=%d remainder=%d\n",
-              FI_to_ascii(rec->FileIndex), rec->VolSessionId, 
+           Dmsg6(0, "Damaged block FI=%s SessId=%d Strm=%s len=%d\n"
+"rem=%d remainder=%d\n",
+              FI_to_ascii(rec->FileIndex), rec->VolSessionId,
               stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len,
               remlen, rec->remainder);
-            Dmsg5(0, "Damaged block: bufp=%x binbuf=%d buf_len=%d rem=%d moved=%d\n",
+           Dmsg5(0, "Damaged block: bufp=%x binbuf=%d buf_len=%d rem=%d moved=%d\n",
               block->bufp, block->binbuf, block->buf_len, block->buf_len-block->binbuf,
               remlen);
-            Dmsg2(0, "Damaged block: buf=%x binbuffrombuf=%d \n",
+           Dmsg2(0, "Damaged block: buf=%x binbuffrombuf=%d \n",
               block->buf, block->bufp-block->buf);
 
-               Emsg0(M_ABORT, 0, "Damaged buffer\n");
+              Emsg0(M_ABORT, 0, "Damaged buffer\n");
         }
 #endif
 
@@ -352,7 +352,7 @@ rem=%d remainder=%d\n",
 /*
  * Test if we can write whole record to the block
  *
- *  Returns: false on failure 
+ *  Returns: false on failure
  *          true  on success (all bytes can be written)
  */
 bool can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec)
@@ -381,7 +381,7 @@ bool can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec)
  * Read a Record from the block
  *  Returns: false if nothing read or if the continuation record does not match.
  *                In both of these cases, a block read must be done.
- *          true  if at least the record header was read, this 
+ *          true  if at least the record header was read, this
  *                routine may have to be called again with a new
  *                block if the entire record was not read.
  */
@@ -400,14 +400,14 @@ bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
    rec->Block = block->BlockNumber;
    rec->File = ((DEVICE *)block->dev)->file;
 
-   /* Clear state flags */      
+   /* Clear state flags */
    rec->state = 0;
    if (((DEVICE *)block->dev)->state & ST_TAPE) {
       rec->state |= REC_ISTAPE;
    }
 
 
-   /* 
+   /*
     * Get the header. There is always a full header,
     * otherwise we find it in the next block.
     */
@@ -419,7 +419,7 @@ bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
       rhl = RECHDR2_LENGTH;
    }
    if (remlen >= rhl) {
-      Dmsg4(450, "Enter read_record_block: remlen=%d data_len=%d rem=%d blkver=%d\n", 
+      Dmsg4(450, "Enter read_record_block: remlen=%d data_len=%d rem=%d blkver=%d\n",
            remlen, rec->data_len, rec->remainder, block->BlockVer);
 
       unser_begin(block->bufp, WRITE_RECHDR_LENGTH);
@@ -441,10 +441,10 @@ bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
       /* If we are looking for more (remainder!=0), we reject anything
        *  where the VolSessionId and VolSessionTime don't agree
        */
-      if (rec->remainder && (rec->VolSessionId != VolSessionId || 
+      if (rec->remainder && (rec->VolSessionId != VolSessionId ||
                             rec->VolSessionTime != VolSessionTime)) {
         rec->state |= REC_NO_MATCH;
-         Dmsg0(450, "remainder and VolSession doesn't match\n");
+        Dmsg0(450, "remainder and VolSession doesn't match\n");
         return false;             /* This is from some other Session */
       }
 
@@ -452,10 +452,10 @@ bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
        * of a previous partially written record.
        */
       if (Stream < 0) {              /* continuation record? */
-         Dmsg1(500, "Got negative Stream => continuation. remainder=%d\n", 
+        Dmsg1(500, "Got negative Stream => continuation. remainder=%d\n",
            rec->remainder);
         rec->state |= REC_CONTINUATION;
-         if (!rec->remainder) {       /* if we didn't read previously */
+        if (!rec->remainder) {       /* if we didn't read previously */
            rec->data_len = 0;        /* return data as if no continuation */
         } else if (rec->Stream != -Stream) {
            rec->state |= REC_NO_MATCH;
@@ -477,14 +477,14 @@ bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
       }
 
       Dmsg6(450, "rd_rec_blk() got FI=%s SessId=%d Strm=%s len=%u\n"
-                 "remlen=%d data_len=%d\n",
-        FI_to_ascii(rec->FileIndex), rec->VolSessionId, 
-        stream_to_ascii(rec->Stream, rec->FileIndex), data_bytes, remlen, 
+                "remlen=%d data_len=%d\n",
+        FI_to_ascii(rec->FileIndex), rec->VolSessionId,
+        stream_to_ascii(rec->Stream, rec->FileIndex), data_bytes, remlen,
         rec->data_len);
    } else {
-      /*    
-       * No more records in this block because the number   
-       * of remaining bytes are less than a record header 
+      /*
+       * No more records in this block because the number
+       * of remaining bytes are less than a record header
        * length, so return empty handed, but indicate that
        * he must read again. By returning, we allow the
        * higher level routine to fetch the next block and
@@ -505,10 +505,10 @@ bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
    ASSERT(data_bytes < MAX_BLOCK_LENGTH);      /* temp sanity check */
 
    rec->data = check_pool_memory_size(rec->data, rec->data_len+data_bytes);
-   
+
    /*
     * At this point, we have read the header, now we
-    * must transfer as much of the data record as 
+    * must transfer as much of the data record as
     * possible taking into account: 1. A partial
     * data record may have previously been transferred,
     * 2. The current block may not contain the whole data
@@ -533,7 +533,7 @@ bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec)
    }
    rec->remainder = 0;
    Dmsg4(450, "Rtn full rd_rec_blk FI=%s SessId=%d Strm=%s len=%d\n",
-      FI_to_ascii(rec->FileIndex), rec->VolSessionId, 
+      FI_to_ascii(rec->FileIndex), rec->VolSessionId,
       stream_to_ascii(rec->Stream, rec->FileIndex), rec->data_len);
    return true;                      /* transferred full record */
 }
index 2267d8a4733579c802fd7f2bad7ce3a5c963a738..2d6f5a4dc59cf188f6e23d3b1d2fd8dfce00b343 100644 (file)
@@ -76,7 +76,7 @@
 /*
  * DEV_RECORD for reading and writing records.
  * It consists of a Record Header, and the Record Data
- * 
+ *
  *  This is the memory structure for the record header.
  */
 struct BSR;                           /* satisfy forward reference */
@@ -97,7 +97,7 @@ struct DEV_RECORD {
    BSR *bsr;                          /* pointer to bsr that matched */
    uint8_t  ser_buf[WRITE_RECHDR_LENGTH];   /* serialized record header goes here */
    POOLMEM *data;                     /* Record data. This MUST be a memory pool item */
-};           
+};
 
 
 /*
@@ -107,20 +107,20 @@ struct DEV_RECORD {
  */
 #define PRE_LABEL   -1                /* Vol label on unwritten tape */
 #define VOL_LABEL   -2                /* Volume label first file */
-#define EOM_LABEL   -3                /* Writen at end of tape */        
+#define EOM_LABEL   -3                /* Writen at end of tape */
 #define SOS_LABEL   -4                /* Start of Session */
 #define EOS_LABEL   -5                /* End of Session */
 #define EOT_LABEL   -6                /* End of physical tape (2 eofs) */
 
-/* 
+/*
  *   Volume Label Record.  This is the in-memory definition. The
  *     tape definition is defined in the serialization code itself
  *     ser_volume_label() and unser_volume_label() and is slightly different.
  */
 
+
 struct Volume_Label {
-  /*  
+  /*
    * The first items in this structure are saved
    * in the DEVICE buffer, but are not actually written
    * to the tape.
@@ -128,7 +128,7 @@ struct Volume_Label {
   int32_t LabelType;                  /* This is written in header only */
   uint32_t LabelSize;                 /* length of serialized label */
   /*
-   * The items below this line are stored on 
+   * The items below this line are stored on
    * the tape
    */
   char Id[32];                        /* Bacula Immortal ... */
index 5e05173f5a646024043233030b603c7237cbbe61..89a774f64cdd70c335416723f70cad157a521ac0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Spooling code 
+ *  Spooling code
  *
  *     Kern Sibbald, March 2004
  *
@@ -41,7 +41,7 @@ static bool write_spool_data(DCR *dcr);
 
 struct spool_stats_t {
    uint32_t data_jobs;               /* current jobs spooling data */
-   uint32_t attr_jobs;               
+   uint32_t attr_jobs;
    uint32_t total_data_jobs;         /* total jobs to have spooled data */
    uint32_t total_attr_jobs;
    int64_t max_data_size;            /* max data size */
@@ -53,7 +53,7 @@ struct spool_stats_t {
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 spool_stats_t spool_stats;
 
-/* 
+/*
  * Header for data spool record */
 struct spool_hdr {
    int32_t  FirstIndex;              /* FirstIndex for buffer */
@@ -73,13 +73,13 @@ void list_spool_stats(BSOCK *bs)
    if (spool_stats.data_jobs || spool_stats.max_data_size) {
       bnet_fsend(bs, "Data spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes/job.\n",
         spool_stats.data_jobs, edit_uint64_with_commas(spool_stats.data_size, ed1),
-        spool_stats.total_data_jobs, 
+        spool_stats.total_data_jobs,
         edit_uint64_with_commas(spool_stats.max_data_size, ed2));
    }
    if (spool_stats.attr_jobs || spool_stats.max_attr_size) {
       bnet_fsend(bs, "Attr spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes.\n",
-        spool_stats.attr_jobs, edit_uint64_with_commas(spool_stats.attr_size, ed1), 
-        spool_stats.total_attr_jobs, 
+        spool_stats.attr_jobs, edit_uint64_with_commas(spool_stats.attr_size, ed1),
+        spool_stats.total_attr_jobs,
         edit_uint64_with_commas(spool_stats.max_attr_size, ed2));
    }
 }
@@ -93,7 +93,7 @@ bool begin_data_spool(JCR *jcr)
       stat = open_data_spool_file(jcr);
       if (stat) {
         jcr->dcr->spooling = true;
-         Jmsg(jcr, M_INFO, 0, _("Spooling data ...\n"));
+        Jmsg(jcr, M_INFO, 0, _("Spooling data ...\n"));
         P(mutex);
         spool_stats.data_jobs++;
         V(mutex);
@@ -119,7 +119,7 @@ bool commit_data_spool(JCR *jcr)
       Dmsg0(100, "Committing spooled data\n");
       stat = despool_data(jcr->dcr, true /*commit*/);
       if (!stat) {
-         Pmsg1(000, "Bad return from despool WroteVol=%d\n", jcr->dcr->WroteVol);
+        Pmsg1(000, "Bad return from despool WroteVol=%d\n", jcr->dcr->WroteVol);
         close_data_spool_file(jcr);
         return false;
       }
@@ -130,7 +130,7 @@ bool commit_data_spool(JCR *jcr)
 
 static void make_unique_data_spool_filename(JCR *jcr, POOLMEM **name)
 {
-   const char *dir;  
+   const char *dir;
    if (jcr->dcr->dev->device->spool_directory) {
       dir = jcr->dcr->dev->device->spool_directory;
    } else {
@@ -188,7 +188,7 @@ static bool close_data_spool_file(JCR *jcr)
 
 static const char *spool_name = "*spool*";
 
-static bool despool_data(DCR *dcr, bool commit) 
+static bool despool_data(DCR *dcr, bool commit)
 {
    DEVICE *rdev;
    DCR *rdcr;
@@ -204,11 +204,11 @@ static bool despool_data(DCR *dcr, bool commit)
        edit_uint64_with_commas(jcr->dcr->spool_size, ec1));
    dcr->spooling = false;
    lock_device(dcr->dev);
-   dcr->dev_locked = true; 
+   dcr->dev_locked = true;
 
-   /* 
+   /*
     * This is really quite kludgy and should be fixed some time.
-    * We create a dev structure to read from the spool file 
+    * We create a dev structure to read from the spool file
     * in rdev and rdcr.
     */
    rdev = (DEVICE *)malloc(sizeof(DEVICE));
@@ -221,7 +221,7 @@ static bool despool_data(DCR *dcr, bool commit)
    rdev->min_block_size = dcr->dev->min_block_size;
    rdev->device = dcr->dev->device;
    rdcr = new_dcr(NULL, rdev);
-   rdcr->spool_fd = dcr->spool_fd; 
+   rdcr->spool_fd = dcr->spool_fd;
    rdcr->jcr = jcr;                  /* set a valid jcr */
    block = dcr->block;               /* save block */
    dcr->block = rdcr->block;         /* make read and write block the same */
@@ -249,7 +249,7 @@ static bool despool_data(DCR *dcr, bool commit)
    lseek(rdcr->spool_fd, 0, SEEK_SET); /* rewind */
    if (ftruncate(rdcr->spool_fd, 0) != 0) {
       berrno be;
-      Jmsg(dcr->jcr, M_ERROR, 0, _("Ftruncate spool file failed: ERR=%s\n"), 
+      Jmsg(dcr->jcr, M_ERROR, 0, _("Ftruncate spool file failed: ERR=%s\n"),
         be.strerror());
       Pmsg1(000, "Bad return from ftruncate. ERR=%s\n", be.strerror());
       ok = false;
@@ -280,7 +280,7 @@ static bool despool_data(DCR *dcr, bool commit)
 
 /*
  * Read a block from the spool file
- * 
+ *
  *  Returns RB_OK on success
  *         RB_EOT when file done
  *         RB_ERROR on error
@@ -300,11 +300,11 @@ static int read_block_from_spool_file(DCR *dcr)
    } else if (stat != (ssize_t)rlen) {
       if (stat == -1) {
         berrno be;
-         Jmsg(dcr->jcr, M_FATAL, 0, _("Spool header read error. ERR=%s\n"), 
+        Jmsg(dcr->jcr, M_FATAL, 0, _("Spool header read error. ERR=%s\n"),
              be.strerror());
       } else {
-         Pmsg2(000, "Spool read error. Wanted %u bytes, got %u\n", rlen, stat);
-         Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool header read error. Wanted %u bytes, got %u\n"), rlen, stat);
+        Pmsg2(000, "Spool read error. Wanted %u bytes, got %u\n", rlen, stat);
+        Jmsg2(dcr->jcr, M_FATAL, 0, _("Spool header read error. Wanted %u bytes, got %u\n"), rlen, stat);
       }
       return RB_ERROR;
    }
@@ -365,10 +365,10 @@ bool write_block_to_spool_file(DCR *dcr)
    }
    V(mutex);
    if (despool) {
-#ifdef xDEBUG 
+#ifdef xDEBUG
       char ec1[30], ec2[30], ec3[30], ec4[30];
       Dmsg4(100, "Despool in write_block_to_spool_file max_size=%s size=%s "
-            "max_job_size=%s job_size=%s\n", 
+           "max_job_size=%s job_size=%s\n",
            edit_uint64_with_commas(dcr->max_spool_size, ec1),
            edit_uint64_with_commas(dcr->spool_size, ec2),
            edit_uint64_with_commas(dcr->dev->max_spool_size, ec3),
@@ -376,7 +376,7 @@ bool write_block_to_spool_file(DCR *dcr)
 #endif
       Jmsg(dcr->jcr, M_INFO, 0, _("User specified spool size reached.\n"));
       if (!despool_data(dcr, false)) {
-         Pmsg0(000, "Bad return from despool in write_block.\n");
+        Pmsg0(000, "Bad return from despool in write_block.\n");
         return false;
       }
       /* Despooling cleared these variables so reset them */
@@ -385,7 +385,7 @@ bool write_block_to_spool_file(DCR *dcr)
       dcr->dev->spool_size += hlen + wlen;
       V(dcr->dev->spool_mutex);
       Jmsg(dcr->jcr, M_INFO, 0, _("Spooling data again ...\n"));
-   }  
+   }
 
 
    if (!write_spool_header(dcr)) {
@@ -402,7 +402,7 @@ bool write_block_to_spool_file(DCR *dcr)
 
 static bool write_spool_header(DCR *dcr)
 {
-   spool_hdr hdr;   
+   spool_hdr hdr;
    ssize_t stat;
    DEV_BLOCK *block = dcr->block;
 
@@ -415,7 +415,7 @@ static bool write_spool_header(DCR *dcr)
       stat = write(dcr->spool_fd, (char*)&hdr, sizeof(hdr));
       if (stat == -1) {
         berrno be;
-         Jmsg(dcr->jcr, M_FATAL, 0, _("Error writing header to spool file. ERR=%s\n"), 
+        Jmsg(dcr->jcr, M_FATAL, 0, _("Error writing header to spool file. ERR=%s\n"),
              be.strerror());
       }
       if (stat != (ssize_t)sizeof(hdr)) {
@@ -423,13 +423,13 @@ static bool write_spool_header(DCR *dcr)
         if (stat != -1) {
            if (ftruncate(dcr->spool_fd, lseek(dcr->spool_fd, (off_t)0, SEEK_CUR) - stat) != 0) {
               berrno be;
-               Jmsg(dcr->jcr, M_FATAL, 0, _("Ftruncate spool file failed: ERR=%s\n"), 
+              Jmsg(dcr->jcr, M_FATAL, 0, _("Ftruncate spool file failed: ERR=%s\n"),
                  be.strerror());
               return false;
            }
         }
         if (!despool_data(dcr, false)) {
-            Jmsg(dcr->jcr, M_FATAL, 0, _("Fatal despooling error."));
+           Jmsg(dcr->jcr, M_FATAL, 0, _("Fatal despooling error."));
            return false;
         }
         continue;                    /* try again */
@@ -450,24 +450,24 @@ static bool write_spool_data(DCR *dcr)
       stat = write(dcr->spool_fd, block->buf, (size_t)block->binbuf);
       if (stat == -1) {
         berrno be;
-         Jmsg(dcr->jcr, M_FATAL, 0, _("Error writing data to spool file. ERR=%s\n"),
+        Jmsg(dcr->jcr, M_FATAL, 0, _("Error writing data to spool file. ERR=%s\n"),
              be.strerror());
       }
       if (stat != (ssize_t)block->binbuf) {
-        /* 
+        /*
          * If we wrote something, truncate it and the header, then despool
          */
         if (stat != -1) {
            if (ftruncate(dcr->spool_fd, lseek(dcr->spool_fd, (off_t)0, SEEK_CUR)
                      - stat - sizeof(spool_hdr)) != 0) {
               berrno be;
-               Jmsg(dcr->jcr, M_FATAL, 0, _("Ftruncate spool file failed: ERR=%s\n"), 
+              Jmsg(dcr->jcr, M_FATAL, 0, _("Ftruncate spool file failed: ERR=%s\n"),
                  be.strerror());
               return false;
            }
         }
         if (!despool_data(dcr, false)) {
-            Jmsg(dcr->jcr, M_FATAL, 0, _("Fatal despooling error."));
+           Jmsg(dcr->jcr, M_FATAL, 0, _("Fatal despooling error."));
            return false;
         }
         if (!write_spool_header(dcr)) {
@@ -488,7 +488,7 @@ bool are_attributes_spooled(JCR *jcr)
    return jcr->spool_attributes && jcr->dir_bsock->spool_fd;
 }
 
-/* 
+/*
  * Create spool file for attributes.
  *  This is done by "attaching" to the bsock, and when
  *  it is called, the output is written to a file.
@@ -532,7 +532,7 @@ bool commit_attribute_spool(JCR *jcr)
    if (are_attributes_spooled(jcr)) {
       if (fseek(jcr->dir_bsock->spool_fd, 0, SEEK_END) != 0) {
         berrno be;
-         Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"),
+        Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"),
              be.strerror());
       }
       size = ftell(jcr->dir_bsock->spool_fd);
@@ -540,7 +540,7 @@ bool commit_attribute_spool(JCR *jcr)
       if (size > 0) {
        if (spool_stats.attr_size + size > spool_stats.max_attr_size) {
           spool_stats.max_attr_size = spool_stats.attr_size + size;
-       } 
+       }
       }
       spool_stats.attr_size += size;
       V(mutex);
@@ -582,7 +582,7 @@ bool open_attr_spool_file(JCR *jcr, BSOCK *bs)
 bool close_attr_spool_file(JCR *jcr, BSOCK *bs)
 {
    POOLMEM *name;
-    
+
    if (!bs->spool_fd) {
       return true;
    }
index cf73279d1901ee22c498ff137bc71b6279b64302..878376b79cecf17400f9db924edc9bb1135d825a 100644 (file)
@@ -4,7 +4,7 @@
  *     Kern Sibbald, May MMIII
  *
  *   Version $Id$
- *  
+ *
  */
 /*
    Copyright (C) 2000-2004 Kern Sibbald and John Walker
@@ -71,7 +71,7 @@ bool status_cmd(JCR *jcr)
              HOST_OS, DISTNAME, DISTVER);
    bstrftime_nc(dt, sizeof(dt), daemon_start_time);
    bnet_fsend(user, _("Daemon started %s, %d Job%s run since started.\n"), dt, num_jobs_run,
-        num_jobs_run == 1 ? "" : "s");
+       num_jobs_run == 1 ? "" : "s");
    if (debug_level > 0) {
       char b1[35], b2[35], b3[35], b4[35];
       bnet_fsend(user, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"),
@@ -100,10 +100,10 @@ bool status_cmd(JCR *jcr)
       for (dev=device->dev; dev; dev=dev->next) {
         if (dev_state(dev, ST_OPENED)) {
            if (dev_state(dev, ST_LABEL)) {
-               bnet_fsend(user, _("Device \"%s\" is mounted with Volume \"%s\"\n"), 
+              bnet_fsend(user, _("Device \"%s\" is mounted with Volume \"%s\"\n"),
                  dev_name(dev), dev->VolHdr.VolName);
            } else {
-               bnet_fsend(user, _("Device \"%s\" open but no Bacula volume is mounted.\n"), dev_name(dev));
+              bnet_fsend(user, _("Device \"%s\" open but no Bacula volume is mounted.\n"), dev_name(dev));
            }
            send_blocked_status(jcr, dev);
            if (dev_state(dev, ST_APPEND)) {
@@ -112,9 +112,9 @@ bool status_cmd(JCR *jcr)
                  bpb = 1;
               }
               bpb = dev->VolCatInfo.VolCatBytes / bpb;
-               bnet_fsend(user, _("    Total Bytes=%s Blocks=%s Bytes/block=%s\n"),
+              bnet_fsend(user, _("    Total Bytes=%s Blocks=%s Bytes/block=%s\n"),
                  edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
-                 edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2), 
+                 edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
                  edit_uint64_with_commas(bpb, b3));
            } else {  /* reading */
               bpb = dev->VolCatInfo.VolCatReads;
@@ -126,17 +126,17 @@ bool status_cmd(JCR *jcr)
               } else {
                  bpb = 0;
               }
-               bnet_fsend(user, _("    Total Bytes Read=%s Blocks Read=%s Bytes/block=%s\n"),
+              bnet_fsend(user, _("    Total Bytes Read=%s Blocks Read=%s Bytes/block=%s\n"),
                  edit_uint64_with_commas(dev->VolCatInfo.VolCatRBytes, b1),
-                 edit_uint64_with_commas(dev->VolCatInfo.VolCatReads, b2), 
+                 edit_uint64_with_commas(dev->VolCatInfo.VolCatReads, b2),
                  edit_uint64_with_commas(bpb, b3));
            }
-            bnet_fsend(user, _("    Positioned at File=%s Block=%s\n"), 
+           bnet_fsend(user, _("    Positioned at File=%s Block=%s\n"),
               edit_uint64_with_commas(dev->file, b1),
               edit_uint64_with_commas(dev->block_num, b2));
 
         } else {
-            bnet_fsend(user, _("Device \"%s\" is not open.\n"), dev_name(dev));
+           bnet_fsend(user, _("Device \"%s\" is not open.\n"), dev_name(dev));
            send_blocked_status(jcr, dev);
         }
       }
@@ -156,7 +156,7 @@ bool status_cmd(JCR *jcr)
    return true;
 }
 
-static void send_blocked_status(JCR *jcr, DEVICE *dev) 
+static void send_blocked_status(JCR *jcr, DEVICE *dev)
 {
    BSOCK *user = jcr->dir_bsock;
    DCR *dcr = jcr->dcr;
@@ -170,10 +170,10 @@ static void send_blocked_status(JCR *jcr, DEVICE *dev)
       break;
    case BST_WAITING_FOR_SYSOP:
       if (jcr->JobStatus == JS_WaitMount) {
-         bnet_fsend(user, _("    Device is BLOCKED waiting for mount of volume \"%s\".\n"),
+        bnet_fsend(user, _("    Device is BLOCKED waiting for mount of volume \"%s\".\n"),
            dcr->VolumeName);
       } else {
-         bnet_fsend(user, _("    Device is BLOCKED waiting for appendable media.\n"));
+        bnet_fsend(user, _("    Device is BLOCKED waiting for appendable media.\n"));
       }
       break;
    case BST_DOING_ACQUIRE:
@@ -230,12 +230,12 @@ static void list_running_jobs(BSOCK *user)
    JCR *jcr;
    char JobName[MAX_NAME_LENGTH];
    char b1[30], b2[30], b3[30];
-   
+
    bnet_fsend(user, _("\nRunning Jobs:\n"));
    lock_jcr_chain();
    foreach_jcr(jcr) {
       if (jcr->JobStatus == JS_WaitFD) {
-         bnet_fsend(user, _("%s Job %s waiting for Client connection.\n"),
+        bnet_fsend(user, _("%s Job %s waiting for Client connection.\n"),
            job_type_to_str(jcr->JobType), jcr->Job);
       }
       if (jcr->device) {
@@ -243,35 +243,35 @@ static void list_running_jobs(BSOCK *user)
         /* There are three periods after the Job name */
         char *p;
         for (int i=0; i<3; i++) {
-            if ((p=strrchr(JobName, '.')) != NULL) {
+           if ((p=strrchr(JobName, '.')) != NULL) {
               *p = 0;
            }
         }
-         bnet_fsend(user, _("%s %s job %s JobId=%d Volume=\"%s\" device=\"%s\"\n"), 
+        bnet_fsend(user, _("%s %s job %s JobId=%d Volume=\"%s\" device=\"%s\"\n"),
                   job_level_to_str(jcr->JobLevel),
                   job_type_to_str(jcr->JobType),
                   JobName,
                   jcr->JobId,
-                   jcr->dcr?jcr->dcr->VolumeName:"*none*",
-                   jcr->device?jcr->device->device_name:"none");
+                  jcr->dcr?jcr->dcr->VolumeName:"*none*",
+                  jcr->device?jcr->device->device_name:"none");
         sec = time(NULL) - jcr->run_time;
         if (sec <= 0) {
            sec = 1;
         }
         bps = jcr->JobBytes / sec;
-         bnet_fsend(user, _("    Files=%s Bytes=%s Bytes/sec=%s\n"), 
+        bnet_fsend(user, _("    Files=%s Bytes=%s Bytes/sec=%s\n"),
            edit_uint64_with_commas(jcr->JobFiles, b1),
            edit_uint64_with_commas(jcr->JobBytes, b2),
            edit_uint64_with_commas(bps, b3));
         found = true;
 #ifdef DEBUG
         if (jcr->file_bsock) {
-            bnet_fsend(user, "    FDReadSeqNo=%s in_msg=%u out_msg=%d fd=%d\n", 
+           bnet_fsend(user, "    FDReadSeqNo=%s in_msg=%u out_msg=%d fd=%d\n",
               edit_uint64_with_commas(jcr->file_bsock->read_seqno, b1),
               jcr->file_bsock->in_msg_no, jcr->file_bsock->out_msg_no,
               jcr->file_bsock->fd);
         } else {
-            bnet_fsend(user, "    FDSocket closed\n");
+           bnet_fsend(user, "    FDSocket closed\n");
         }
 #endif
       }
@@ -292,16 +292,16 @@ static void list_terminated_jobs(void *arg)
    const char *msg;
 
    if (last_jobs->size() == 0) {
-      msg = _("No Terminated Jobs.\n"); 
+      msg = _("No Terminated Jobs.\n");
       sendit(msg, strlen(msg), arg);
       return;
    }
    lock_last_jobs_list();
-   msg =  _("\nTerminated Jobs:\n"); 
+   msg =  _("\nTerminated Jobs:\n");
    sendit(msg, strlen(msg), arg);
    msg =  _(" JobId  Level   Files          Bytes Status   Finished        Name \n");
    sendit(msg, strlen(msg), arg);
-   msg = _("======================================================================\n"); 
+   msg = _("======================================================================\n");
    sendit(msg, strlen(msg), arg);
    foreach_dlist(je, last_jobs) {
       char JobName[MAX_NAME_LENGTH];
@@ -312,7 +312,7 @@ static void list_terminated_jobs(void *arg)
       switch (je->JobType) {
       case JT_ADMIN:
       case JT_RESTORE:
-         bstrncpy(level, "    ", sizeof(level));
+        bstrncpy(level, "    ", sizeof(level));
         break;
       default:
         bstrncpy(level, level_to_str(je->JobLevel), sizeof(level));
@@ -321,38 +321,38 @@ static void list_terminated_jobs(void *arg)
       }
       switch (je->JobStatus) {
       case JS_Created:
-         termstat = "Created";
+        termstat = "Created";
         break;
       case JS_FatalError:
       case JS_ErrorTerminated:
-         termstat = "Error";
+        termstat = "Error";
         break;
       case JS_Differences:
-         termstat = "Diffs";
+        termstat = "Diffs";
         break;
       case JS_Canceled:
-         termstat = "Cancel";
+        termstat = "Cancel";
         break;
       case JS_Terminated:
-         termstat = "OK";
+        termstat = "OK";
         break;
       default:
-         termstat = "Other";
+        termstat = "Other";
         break;
       }
       bstrncpy(JobName, je->Job, sizeof(JobName));
       /* There are three periods after the Job name */
       char *p;
       for (int i=0; i<3; i++) {
-         if ((p=strrchr(JobName, '.')) != NULL) {
+        if ((p=strrchr(JobName, '.')) != NULL) {
            *p = 0;
         }
       }
-      bsnprintf(buf, sizeof(buf), _("%6d  %-6s %8s %14s %-7s  %-8s %s\n"), 
+      bsnprintf(buf, sizeof(buf), _("%6d  %-6s %8s %14s %-7s  %-8s %s\n"),
         je->JobId,
-        level, 
+        level,
         edit_uint64_with_commas(je->JobFiles, b1),
-        edit_uint64_with_commas(je->JobBytes, b2), 
+        edit_uint64_with_commas(je->JobBytes, b2),
         termstat,
         dt, JobName);
       sendit(buf, strlen(buf), arg);
@@ -364,7 +364,7 @@ static void list_terminated_jobs(void *arg)
 /*
  * Convert Job Level into a string
  */
-static const char *level_to_str(int level) 
+static const char *level_to_str(int level)
 {
    const char *str;
 
@@ -409,7 +409,7 @@ static const char *level_to_str(int level)
 }
 
 /*
- * Send to Director 
+ * Send to Director
  */
 static void sendit(const char *msg, int len, void *arg)
 {
@@ -438,7 +438,7 @@ bool qstatus_cmd(JCR *jcr)
       return false;
    }
    unbash_spaces(time);
-   
+
    if (strcmp(time.c_str(), "current") == 0) {
       bnet_fsend(dir, OKqstatus, time.c_str());
       lock_jcr_chain();
index 27fe7618cc511962ab615a6482da027c0a61e4ed..017fa608e3e13839a054a08f2e6740ec2d59c443 100644 (file)
@@ -4,10 +4,10 @@
  * It accepts a number of simple commands from the File daemon
  * and acts on them. When a request to append data is made,
  * it opens a data channel and accepts data from the
- * File daemon. 
+ * File daemon.
  *
  *   Version $Id$
- * 
+ *
  */
 /*
    Copyright (C) 2000-2004 Kern Sibbald and John Walker
@@ -82,14 +82,14 @@ static void usage()
    exit(1);
 }
 
-/********************************************************************* 
+/*********************************************************************
  *
  *  Main Bacula Unix Storage Daemon
  *
  */
 int main (int argc, char *argv[])
 {
-   int ch;   
+   int ch;
    int no_signals = FALSE;
    int test_config = FALSE;
    pthread_t thid;
@@ -123,7 +123,7 @@ int main (int argc, char *argv[])
       case 'd':                    /* debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0) {
-           debug_level = 1; 
+           debug_level = 1;
         }
         break;
 
@@ -159,7 +159,7 @@ int main (int argc, char *argv[])
       default:
         usage();
         break;
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -169,7 +169,7 @@ int main (int argc, char *argv[])
         free(configfile);
       }
       configfile = bstrdup(*argv);
-      argc--; 
+      argc--;
       argv++;
    }
    if (argc)
@@ -223,12 +223,12 @@ int main (int argc, char *argv[])
 
    init_jcr_subsystem();             /* start JCR watchdogs etc. */
 
-   /* 
+   /*
     * Sleep a bit to give device thread a chance to lock the resource
     * chain before we start the server.
     */
    bmicrosleep(1, 0);
-                                
+
    /* Single server used for Director and File daemon */
    bnet_thread_server(me->sdaddrs, me->max_concurrent_jobs * 2 + 1,
                      &dird_workq, handle_connection_request);
@@ -262,7 +262,7 @@ static void check_config()
 
    if (GetNextRes(R_STORAGE, (RES *)me) != NULL) {
       UnlockRes();
-      Emsg1(M_ERROR_TERM, 0, _("Only one Storage resource permitted in %s\n"), 
+      Emsg1(M_ERROR_TERM, 0, _("Only one Storage resource permitted in %s\n"),
         configfile);
    }
    if (GetNextRes(R_DIRECTOR, NULL) == NULL) {
@@ -278,7 +278,7 @@ static void check_config()
    if (!me->messages) {
       me->messages = (MSGS *)GetNextRes(R_MSGS, NULL);
       if (!me->messages) {
-         Emsg1(M_ERROR_TERM, 0, _("No Messages resource defined in %s. Cannot continue.\n"),
+        Emsg1(M_ERROR_TERM, 0, _("No Messages resource defined in %s. Cannot continue.\n"),
            configfile);
       }
    }
@@ -291,7 +291,7 @@ static void check_config()
       Emsg1(M_ERROR_TERM, 0, _("No Working Directory defined in %s. Cannot continue.\n"),
         configfile);
    }
-   
+
    set_working_directory(me->working_directory);
 }
 
@@ -312,17 +312,17 @@ void *device_allocation(void *arg)
       device->dev = init_dev(NULL, device);
       Dmsg1(10, "SD init done %s\n", device->device_name);
       if (!device->dev) {
-         Emsg1(M_ERROR, 0, _("Could not initialize %s\n"), device->device_name);
+        Emsg1(M_ERROR, 0, _("Could not initialize %s\n"), device->device_name);
         continue;
       }
 
       if (device->cap_bits & CAP_ALWAYSOPEN) {
-         Dmsg1(20, "calling first_open_device %s\n", device->device_name);
+        Dmsg1(20, "calling first_open_device %s\n", device->device_name);
         if (!first_open_device(device->dev)) {
-            Emsg1(M_ERROR, 0, _("Could not open device %s\n"), device->device_name);
+           Emsg1(M_ERROR, 0, _("Could not open device %s\n"), device->device_name);
         }
       }
-      if (device->cap_bits & CAP_AUTOMOUNT && device->dev && 
+      if (device->cap_bits & CAP_AUTOMOUNT && device->dev &&
          device->dev->state & ST_OPENED) {
         JCR *jcr;
         DCR *dcr;
@@ -331,7 +331,7 @@ void *device_allocation(void *arg)
         /* Initialize FD start condition variable */
         int errstat = pthread_cond_init(&jcr->job_start_wait, NULL);
         if (errstat != 0) {
-            Jmsg1(jcr, M_ABORT, 0, _("Unable to init job cond variable: ERR=%s\n"), strerror(errstat));
+           Jmsg1(jcr, M_ABORT, 0, _("Unable to init job cond variable: ERR=%s\n"), strerror(errstat));
         }
         jcr->device = device;
         dcr = new_dcr(jcr, device->dev);
@@ -340,12 +340,12 @@ void *device_allocation(void *arg)
               memcpy(&dcr->dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dcr->dev->VolCatInfo));
               break;
            default:
-               Emsg1(M_WARNING, 0, _("Could not mount device %s\n"), device->device_name);
+              Emsg1(M_WARNING, 0, _("Could not mount device %s\n"), device->device_name);
               break;
         }
         free_jcr(jcr);
       }
-   } 
+   }
    UnlockRes();
    return NULL;
 }
@@ -378,10 +378,10 @@ void terminate_stored(int sig)
            continue;                 /* ignore console */
         }
         set_jcr_job_status(jcr, JS_Canceled);
-        fd = jcr->file_bsock;  
+        fd = jcr->file_bsock;
         if (fd) {
            fd->timed_out = true;
-            Dmsg1(100, "term_stored killing JobId=%d\n", jcr->JobId);
+           Dmsg1(100, "term_stored killing JobId=%d\n", jcr->JobId);
            pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
            if (jcr->device && jcr->device->dev && jcr->device->dev->dev_blocked) {
               pthread_cond_signal(&jcr->device->dev->wait_next_vol);
@@ -403,7 +403,7 @@ void terminate_stored(int sig)
       if (device->dev) {
         term_dev(device->dev);
       }
-   } 
+   }
    UnlockRes();
 
    if (configfile)
index 22f071c22c8656ffab2594b3180319e7ad02d9fc..9f8edaa23d93fd4d6ce1ea55bca7483634518b6d 100644 (file)
@@ -47,9 +47,9 @@ URES res_all;
 int res_all_size = sizeof(res_all);
 
 /* Definition of records permitted within each
- * resource with the routine to process the record 
+ * resource with the routine to process the record
  * information.
- */ 
+ */
 
 /* Globals for the Storage daemon. */
 static RES_ITEM store_items[] = {
@@ -65,7 +65,7 @@ static RES_ITEM store_items[] = {
    {"requiressl",            store_yesno,ITEM(res_store.require_ssl), 1, ITEM_DEFAULT, 0},
    {"maximumconcurrentjobs", store_pint, ITEM(res_store.max_concurrent_jobs), 0, ITEM_DEFAULT, 10},
    {"heartbeatinterval",     store_time, ITEM(res_store.heartbeat_interval), 0, ITEM_DEFAULT, 0},
-   {NULL, NULL, 0, 0, 0, 0} 
+   {NULL, NULL, 0, 0, 0, 0}
 };
 
 
@@ -76,7 +76,7 @@ static RES_ITEM dir_items[] = {
    {"password",    store_password, ITEM(res_dir.password),   0, ITEM_REQUIRED, 0},
    {"enablessl",   store_yesno,    ITEM(res_dir.enable_ssl), 1, ITEM_DEFAULT, 0},
    {"monitor",     store_yesno,    ITEM(res_dir.monitor),   1, ITEM_DEFAULT, 0},
-   {NULL, NULL, 0, 0, 0, 0} 
+   {NULL, NULL, 0, 0, 0, 0}
 };
 
 /* Device definition */
@@ -122,7 +122,7 @@ static RES_ITEM dev_items[] = {
    {"maximumspoolsize",      store_size,   ITEM(res_dev.max_spool_size), 0, 0, 0},
    {"maximumjobspoolsize",   store_size,   ITEM(res_dev.max_job_spool_size), 0, 0, 0},
    {"driveindex",            store_pint,   ITEM(res_dev.drive_index), 0, 0, 0},
-   {NULL, NULL, 0, 0, 0, 0} 
+   {NULL, NULL, 0, 0, 0, 0}
 };
 
 // {"mountanonymousvolumes", store_yesno,  ITEM(res_dev.cap_bits), CAP_ANONVOLS,   ITEM_DEFAULT, 0},
@@ -166,17 +166,17 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
       break;
    case R_STORAGE:
       sendit(sock, "Storage: name=%s SDaddr=%s SDport=%d SDDport=%d HB=%s\n",
-          res->res_store.hdr.name, 
+          res->res_store.hdr.name,
           NPRT(get_first_address(res->res_store.sdaddrs, buf, sizeof(buf))),
-          get_first_port_host_order(res->res_store.sdaddrs), 
+          get_first_port_host_order(res->res_store.sdaddrs),
           get_first_port_host_order(res->res_store.sddaddrs),
           edit_utime(res->res_store.heartbeat_interval, buf, sizeof(buf)));
          foreach_dlist(p, res->res_store.sdaddrs) {
-                sendit(sock, "        SDaddr=%s SDport=%d\n", 
+               sendit(sock, "        SDaddr=%s SDport=%d\n",
                             p->get_address(buf, sizeof(buf)), p->get_port_host_order());
          }
          foreach_dlist(p, res->res_store.sddaddrs) {
-                sendit(sock, "        SDDaddr=%s SDDport=%d\n", 
+               sendit(sock, "        SDDaddr=%s SDDport=%d\n",
                             p->get_address(buf, sizeof(buf)), p->get_port_host_order());
          }
       break;
@@ -185,7 +185,7 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
         res->res_dev.hdr.name,
         res->res_dev.media_type, res->res_dev.device_name);
       sendit(sock, "        rew_wait=%d min_bs=%d max_bs=%d\n",
-        res->res_dev.max_rewind_wait, res->res_dev.min_block_size, 
+        res->res_dev.max_rewind_wait, res->res_dev.min_block_size,
         res->res_dev.max_block_size);
       sendit(sock, "        max_jobs=%d max_files=%" lld " max_size=%" lld "\n",
         res->res_dev.max_volume_jobs, res->res_dev.max_volume_files,
@@ -197,50 +197,50 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
         res->res_dev.max_spool_size, res->res_dev.max_job_spool_size);
       strcpy(buf, "        ");
       if (res->res_dev.cap_bits & CAP_EOF) {
-         bstrncat(buf, "CAP_EOF ", sizeof(buf));
+        bstrncat(buf, "CAP_EOF ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_BSR) {
-         bstrncat(buf, "CAP_BSR ", sizeof(buf));
+        bstrncat(buf, "CAP_BSR ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_BSF) {
-         bstrncat(buf, "CAP_BSF ", sizeof(buf));
+        bstrncat(buf, "CAP_BSF ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_FSR) {
-         bstrncat(buf, "CAP_FSR ", sizeof(buf));
+        bstrncat(buf, "CAP_FSR ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_FSF) {
-         bstrncat(buf, "CAP_FSF ", sizeof(buf));
+        bstrncat(buf, "CAP_FSF ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_EOM) {
-         bstrncat(buf, "CAP_EOM ", sizeof(buf));
+        bstrncat(buf, "CAP_EOM ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_REM) {
-         bstrncat(buf, "CAP_REM ", sizeof(buf));
+        bstrncat(buf, "CAP_REM ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_RACCESS) {
-         bstrncat(buf, "CAP_RACCESS ", sizeof(buf));
+        bstrncat(buf, "CAP_RACCESS ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_AUTOMOUNT) {
-         bstrncat(buf, "CAP_AUTOMOUNT ", sizeof(buf));
+        bstrncat(buf, "CAP_AUTOMOUNT ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_LABEL) {
-         bstrncat(buf, "CAP_LABEL ", sizeof(buf));
+        bstrncat(buf, "CAP_LABEL ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_ANONVOLS) {
-         bstrncat(buf, "CAP_ANONVOLS ", sizeof(buf));
+        bstrncat(buf, "CAP_ANONVOLS ", sizeof(buf));
       }
       if (res->res_dev.cap_bits & CAP_ALWAYSOPEN) {
-         bstrncat(buf, "CAP_ALWAYSOPEN ", sizeof(buf));
+        bstrncat(buf, "CAP_ALWAYSOPEN ", sizeof(buf));
       }
       bstrncat(buf, "\n", sizeof(buf));
       sendit(sock, buf);
       break;
    case R_MSGS:
       sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name);
-      if (res->res_msgs.mail_cmd) 
-         sendit(sock, "      mailcmd=%s\n", res->res_msgs.mail_cmd);
-      if (res->res_msgs.operator_cmd) 
-         sendit(sock, "      opcmd=%s\n", res->res_msgs.operator_cmd);
+      if (res->res_msgs.mail_cmd)
+        sendit(sock, "      mailcmd=%s\n", res->res_msgs.mail_cmd);
+      if (res->res_msgs.operator_cmd)
+        sendit(sock, "      opcmd=%s\n", res->res_msgs.operator_cmd);
       break;
    default:
       sendit(sock, _("Warning: unknown resource type %d\n"), type);
@@ -250,10 +250,10 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
       dump_resource(type, (RES *)res->res_dir.hdr.next, sendit, sock);
 }
 
-/* 
- * Free memory of resource.  
+/*
+ * 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 
+ * to other resources as they will be freed when that
  * resource chain is traversed.  Mainly we worry about freeing
  * allocated strings (names).
  */
@@ -332,7 +332,7 @@ void free_resource(RES *sres, int type)
         res = NULL;
         break;
       default:
-         Dmsg1(0, "Unknown resource type %d\n", type);
+        Dmsg1(0, "Unknown resource type %d\n", type);
         break;
    }
    /* Common stuff again -- free the resource, recurse to next one */
@@ -355,19 +355,19 @@ void save_resource(int type, RES_ITEM *items, int pass)
    int i, size;
    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.res_dir.hdr.item_present)) {  
-            Emsg2(M_ERROR_TERM, 0, _("\"%s\" item is required in \"%s\" resource, but not found.\n"),
+        if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
+           Emsg2(M_ERROR_TERM, 0, _("\"%s\" item is required in \"%s\" resource, but not found.\n"),
              items[i].name, resources[rindex]);
          }
       }
       /* If this triggers, take a look at lib/parse_conf.h */
       if (i >= MAX_RES_ITEMS) {
-         Emsg1(M_ERROR_TERM, 0, _("Too many items in \"%s\" resource\n"), resources[rindex]);
+        Emsg1(M_ERROR_TERM, 0, _("Too many items in \"%s\" resource\n"), resources[rindex]);
       }
    }
 
@@ -387,12 +387,12 @@ void save_resource(int type, RES_ITEM *items, int pass)
         /* Resources containing a resource */
         case R_STORAGE:
            if ((res = (URES *)GetResWithName(R_STORAGE, res_all.res_dir.hdr.name)) == NULL) {
-               Emsg1(M_ERROR_TERM, 0, "Cannot find Storage resource \"%s\"\n", res_all.res_dir.hdr.name);
+              Emsg1(M_ERROR_TERM, 0, "Cannot find Storage resource \"%s\"\n", res_all.res_dir.hdr.name);
            }
            res->res_store.messages = res_all.res_store.messages;
            break;
         default:
-            printf("Unknown resource type %d\n", type);
+           printf("Unknown resource type %d\n", type);
            error = 1;
            break;
       }
@@ -421,10 +421,10 @@ void save_resource(int type, RES_ITEM *items, int pass)
         size = sizeof(DEVRES);
         break;
       case R_MSGS:
-        size = sizeof(MSGS);   
+        size = sizeof(MSGS);
         break;
       default:
-         printf("Unknown resource type %d\n", type);
+        printf("Unknown resource type %d\n", type);
         error = 1;
         size = 1;
         break;
@@ -441,12 +441,12 @@ void save_resource(int type, RES_ITEM *items, int pass)
         for (next=res_head[rindex]; next->next; next=next->next) {
            if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
               Emsg2(M_ERROR_TERM, 0,
-                  _("Attempt to define second \"%s\" resource named \"%s\" is not permitted.\n"),
+                 _("Attempt to define second \"%s\" resource named \"%s\" is not permitted.\n"),
                  resources[rindex].name, res->res_dir.hdr.name);
            }
         }
         next->next = (RES *)res;
-         Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type),
+        Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type),
               res->res_dir.hdr.name);
       }
    }
index 2c4bc74bc756c4e8511880f9955c40148c9e69ae..7274d34787d8c337f5c9ec3ff0c69e616acfc6d1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Resource codes -- they must be sequential for indexing   
+ * Resource codes -- they must be sequential for indexing
  *
  *   Version $Id$
  */
index d51c57b37b37aec5a641d701e2df44930e94b791..929bed296890c23ed9084aa4a7409b550c924eb8 100644 (file)
@@ -28,9 +28,9 @@
        www.engelschall.com
 
    Kern Sibbald, July 2001
-  
+
    Version $Id$
-    
+
  */
 
 #ifdef APCUPSD
@@ -70,7 +70,7 @@ static char my_hostname[MAXSTRING];
 
 
 /*
- *  examine message from server 
+ *  examine message from server
  */
 static void get_response(void)
 {
@@ -83,12 +83,12 @@ static void get_response(void)
        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);
+       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] != '-') {
+       if (buf[3] != '-') {
            break;
        }
     }
@@ -105,11 +105,11 @@ static void chat(const char *fmt, ...)
     va_start(ap, fmt);
     vfprintf(sfp, fmt, ap);
     if (debug_level >= 10) {
-       fprintf(stdout, "%s --> ", my_hostname); 
+       fprintf(stdout, "%s --> ", my_hostname);
        vfprintf(stdout, fmt, ap);
     }
     va_end(ap);
-  
+
     fflush(sfp);
     if (debug_level >= 10) {
        fflush(stdout);
@@ -128,7 +128,7 @@ static void usage()
 "       -f          set the From: field\n"
 "       -h          use mailhost:port as the SMTP server\n"
 "       -s          set the Subject: field\n"
-"       -?          print this message.\n"  
+"       -?          print this message.\n"
 "\n", MY_NAME);
 
    exit(1);
@@ -154,17 +154,17 @@ int main (int argc, char *argv[])
 
    while ((ch = getopt(argc, argv, "c:d:f:h:r:s:?")) != -1) {
       switch (ch) {
-      case 'c':                    
-         Dmsg1(20, "cc=%s\n", optarg);
+      case 'c':
+        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; 
+           debug_level = 1;
         }
-         Dmsg1(20, "Debug level = %d\n", debug_level);
+        Dmsg1(20, "Debug level = %d\n", debug_level);
         break;
 
       case 'f':                    /* from */
@@ -172,8 +172,8 @@ int main (int argc, char *argv[])
         break;
 
       case 'h':                    /* smtp host */
-         Dmsg1(20, "host=%s\n", optarg);
-         p = strchr(optarg, ':');
+        Dmsg1(20, "host=%s\n", optarg);
+        p = strchr(optarg, ':');
         if (p) {
            *p++ = 0;
            mailport = atoi(p);
@@ -182,7 +182,7 @@ int main (int argc, char *argv[])
         break;
 
       case 's':                    /* subject */
-         Dmsg1(20, "subject=%s\n", optarg);
+        Dmsg1(20, "subject=%s\n", optarg);
         subject = optarg;
         break;
 
@@ -194,7 +194,7 @@ int main (int argc, char *argv[])
       default:
         usage();
 
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -212,12 +212,12 @@ int main (int argc, char *argv[])
       if ((cp = getenv("SMTPSERVER")) != NULL) {
         mailhost = cp;
       } else {
-         mailhost = "localhost";
+        mailhost = "localhost";
       }
    }
 
    /*
-    *  Find out my own host name for HELO; 
+    *  Find out my own host name for HELO;
     *  if possible, get the fully qualified domain name
     */
    if (gethostname(my_hostname, sizeof(my_hostname) - 1) < 0) {
@@ -237,9 +237,9 @@ int main (int argc, char *argv[])
     */
    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);
    }
@@ -253,8 +253,8 @@ hp:
       Pmsg2(0, "Error unknown mail host \"%s\": ERR=%s\n", mailhost,
         strerror(errno));
       if (strcasecmp(mailhost, "localhost") != 0) {
-         Pmsg0(0, "Retrying connection using \"localhost\".\n");
-         mailhost = "localhost";
+        Pmsg0(0, "Retrying connection using \"localhost\".\n");
+        mailhost = "localhost";
         goto hp;
       }
       exit(1);
@@ -290,7 +290,7 @@ hp:
       exit(1);
    }
 
-   /* 
+   /*
     *  Send SMTP headers
     */
    get_response(); /* banner */
@@ -308,7 +308,7 @@ hp:
    Dmsg0(20, "Data\n");
    chat("data\r\n");
 
-   /* 
+   /*
     *  Send message header
     */
    fprintf(sfp, "From: %s\r\n", from_addr);
@@ -344,25 +344,25 @@ hp:
 
    fprintf(sfp, "\r\n");
 
-   /* 
-    *  Send message body 
+   /*
+    *  Send message body
     */
    while (fgets(buf, sizeof(buf), stdin)) {
       buf[strlen(buf)-1] = 0;
       if (strcmp(buf, ".") == 0) { /* quote lone dots */
-         fprintf(sfp, "..\r\n");
+        fprintf(sfp, "..\r\n");
       } else {                    /* pass body through unchanged */
-         fprintf(sfp, "%s\r\n", buf);
+        fprintf(sfp, "%s\r\n", buf);
       }
    }
 
-   /* 
+   /*
     *  Send SMTP quit command
     */
    chat(".\r\n");
    chat("quit\r\n");
 
-   /* 
+   /*
     *  Go away gracefully ...
     */
    exit(0);
index 3dba7d8f5f9325bc9c6ae6f1b516a4c36aabe0c0..b6a74617f67b60852866c03194362d3cc0e6b89b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *
  *  Program to check a Bacula database for consistency and to
- *   make repairs 
+ *   make repairs
  *
  *   Kern E. Sibbald, August 2002
  *
@@ -129,7 +129,7 @@ int main (int argc, char *argv[])
       case 'd':                    /* debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0)
-           debug_level = 1; 
+           debug_level = 1;
         break;
 
       case 'f':                    /* fix inconsistencies */
@@ -143,7 +143,7 @@ int main (int argc, char *argv[])
       case '?':
       default:
         usage();
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -152,12 +152,12 @@ int main (int argc, char *argv[])
       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)) { 
+        if (catalogname && !strcmp(catalog->hdr.name, catalogname)) {
            ++found;
            break;
         } else if (!catalogname) { // stop on first if no catalogname is given
@@ -168,9 +168,9 @@ int main (int argc, char *argv[])
       UnlockRes();
       if (!found) {
         if (catalogname) {
-            Pmsg2(0, "Error can not find the Catalog name[%s] in the given config file [%s]\n", catalogname, configfile);
+           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);
+           Pmsg1(0, "Error there is no Catalog section in the given config file [%s]\n", configfile);
         }
         exit(1);
       } else {
@@ -179,7 +179,7 @@ int main (int argc, char *argv[])
         director = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
         UnlockRes();
         if (!director) {
-            Pmsg0(0, "Error no Director resource defined.\n");
+           Pmsg0(0, "Error no Director resource defined.\n");
            exit(1);
         }
         set_working_directory(director->working_directory);
@@ -193,12 +193,12 @@ int main (int argc, char *argv[])
       }
    } else {
       if (argc > 5) {
-         Pmsg0(0, _("Wrong number of arguments.\n"));
+        Pmsg0(0, _("Wrong number of arguments.\n"));
         usage();
       }
 
       if (argc < 1) {
-         Pmsg0(0, _("Working directory not supplied.\n"));
+        Pmsg0(0, _("Working directory not supplied.\n"));
         usage();
       }
 
@@ -263,50 +263,50 @@ static void do_interactive_mode()
    bool quit = false;
    const char *cmd;
 
-   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");
+   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");
 
    while (!quit) {
       if (fix) {
-         printf(_("\n\
-     1) Toggle modify database flag\n\
-     2) Toggle verbose flag\n\
-     3) Repair bad Filename records\n\
-     4) Repair bad Path records\n\
-     5) Eliminate duplicate Filename records\n\
-     6) Eliminate duplicate Path records\n\
-     7) Eliminate orphaned Jobmedia records\n\
-     8) Eliminate orphaned File records\n\
-     9) Eliminate orphaned Path records\n\
-    10) Eliminate orphaned Filename records\n\
-    11) Eliminate orphaned FileSet records\n\
-    12) Eliminate orphaned Client records\n\
-    13) Eliminate orphaned Job records\n\
-    14) Eliminate all Admin records\n\
-    15) Eliminate all Restore records\n\
-    16) All (3-15)\n\
-    17) Quit\n"));
+        printf(_("\n"
+"     1) Toggle modify database flag\n"
+"     2) Toggle verbose flag\n"
+"     3) Repair bad Filename records\n"
+"     4) Repair bad Path records\n"
+"     5) Eliminate duplicate Filename records\n"
+"     6) Eliminate duplicate Path records\n"
+"     7) Eliminate orphaned Jobmedia records\n"
+"     8) Eliminate orphaned File records\n"
+"     9) Eliminate orphaned Path records\n"
+"    10) Eliminate orphaned Filename records\n"
+"    11) Eliminate orphaned FileSet records\n"
+"    12) Eliminate orphaned Client records\n"
+"    13) Eliminate orphaned Job records\n"
+"    14) Eliminate all Admin records\n"
+"    15) Eliminate all Restore records\n"
+"    16) All (3-15)\n"
+"    17) Quit\n"));
        } else {
-         printf(_("\n\
-     1) Toggle modify database flag\n\
-     2) Toggle verbose flag\n\
-     3) Check for bad Filename records\n\
-     4) Check for bad Path records\n\
-     5) Check for duplicate Filename records\n\
-     6) Check for duplicate Path records\n\
-     7) Check for orphaned Jobmedia records\n\
-     8) Check for orphaned File records\n\
-     9) Check for orphaned Path records\n\
-    10) Check for orphaned Filename records\n\
-    11) Check for orphaned FileSet records\n\
-    12) Check for orphaned Client records\n\
-    13) Check for orphaned Job records\n\
-    14) Check for all Admin records\n\
-    15) Check for all Restore records\n\
-    16) All (3-15)\n\
-    17) Quit\n"));
+        printf(_("\n"
+"     1) Toggle modify database flag\n"
+"     2) Toggle verbose flag\n"
+"     3) Check for bad Filename records\n"
+"     4) Check for bad Path records\n"
+"     5) Check for duplicate Filename records\n"
+"     6) Check for duplicate Path records\n"
+"     7) Check for orphaned Jobmedia records\n"
+"     8) Check for orphaned File records\n"
+"     9) Check for orphaned Path records\n"
+"    10) Check for orphaned Filename records\n"
+"    11) Check for orphaned FileSet records\n"
+"    12) Check for orphaned Client records\n"
+"    13) Check for orphaned Job records\n"
+"    14) Check for all Admin records\n"
+"    15) Check for all Restore records\n"
+"    16) All (3-15)\n"
+"    17) Quit\n"));
        }
 
       cmd = get_cmd(_("Select function number: "));
@@ -315,11 +315,11 @@ Please select the fuction you want to perform.\n",
         switch (item) {
         case 1:
            fix = !fix;
-            printf(_("Database will %sbe modified.\n"), fix?"":_("NOT "));
+           printf(_("Database will %sbe modified.\n"), fix?"":_("NOT "));
            break;
         case 2:
            verbose = verbose?0:1;
-            printf(_("Verbose is %s\n"), verbose?_("On"):_("Off"));
+           printf(_("Verbose is %s\n"), verbose?_("On"):_("Off"));
            break;
         case 3:
            repair_bad_filenames();
@@ -402,7 +402,7 @@ static int get_name_handler(void *ctx, int num_fields, char **row)
 
 static int print_job_handler(void *ctx, int num_fields, char **row)
 {
-   printf(_("JobId=%s Name=\"%s\" StartTime=%s\n"), 
+   printf(_("JobId=%s Name=\"%s\" StartTime=%s\n"),
              NPRT(row[0]), NPRT(row[1]), NPRT(row[2]));
    return 0;
 }
@@ -410,33 +410,33 @@ static int print_job_handler(void *ctx, int num_fields, char **row)
 
 static int print_jobmedia_handler(void *ctx, int num_fields, char **row)
 {
-   printf(_("Orphaned JobMediaId=%s JobId=%s Volume=\"%s\"\n"), 
+   printf(_("Orphaned JobMediaId=%s JobId=%s Volume=\"%s\"\n"),
              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"), 
+   printf(_("Orphaned FileId=%s JobId=%s Volume=\"%s\"\n"),
              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"), 
+   printf(_("Orphaned FileSetId=%s FileSet=\"%s\" MD5=%s\n"),
              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"), 
+   printf(_("Orphaned ClientId=%s Name=\"%s\"\n"),
              NPRT(row[0]), NPRT(row[1]));
    return 0;
 }
 
-  
+
 /*
  * Called here with each id to be added to the list
  */
@@ -444,7 +444,7 @@ static int id_list_handler(void *ctx, int num_fields, char **row)
 {
    ID_LIST *lst = (ID_LIST *)ctx;
 
-   if (lst->num_ids == MAX_ID_LIST_LEN) {  
+   if (lst->num_ids == MAX_ID_LIST_LEN) {
       return 1;
    }
    if (lst->num_ids == lst->max_ids) {
@@ -477,14 +477,14 @@ static int make_id_list(const char *query, ID_LIST *id_list)
 }
 
 /*
- * Delete all entries in the list 
+ * Delete all entries in the list
  */
 static int delete_id_list(const char *query, ID_LIST *id_list)
-{ 
+{
    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);
    }
@@ -498,7 +498,7 @@ static int name_list_handler(void *ctx, int num_fields, char **row)
 {
    NAME_LIST *name = (NAME_LIST *)ctx;
 
-   if (name->num_ids == MAX_ID_LIST_LEN) {  
+   if (name->num_ids == MAX_ID_LIST_LEN) {
       return 1;
    }
    if (name->num_ids == name->max_ids) {
@@ -535,7 +535,7 @@ static int make_name_list(const char *query, NAME_LIST *name_list)
  * Print names in the list
  */
 static void print_name_list(NAME_LIST *name_list)
-{ 
+{
    for (int i=0; i < name_list->num_ids; i++) {
       printf("%s\n", name_list->name[i]);
    }
@@ -546,7 +546,7 @@ static void print_name_list(NAME_LIST *name_list)
  * Free names in the list
  */
 static void free_name_list(NAME_LIST *name_list)
-{ 
+{
    for (int i=0; i < name_list->num_ids; i++) {
       free(name_list->name[i]);
    }
@@ -559,10 +559,10 @@ static void eliminate_duplicate_filenames()
    char esc_name[5000];
 
    printf("Checking for duplicate Filename entries.\n");
-   
+
    /* 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);
@@ -576,28 +576,28 @@ static void eliminate_duplicate_filenames()
       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);
+        bsnprintf(buf, sizeof(buf), "SELECT FilenameId FROM Filename WHERE Name='%s'", esc_name);
         if (verbose > 1) {
-            printf("%s\n", buf);
+           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]);
+           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", 
+           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);
+              printf("%s\n", buf);
            }
            db_sql_query(db, buf, NULL, NULL);
-            bsnprintf(buf, sizeof(buf), "DELETE FROM Filename WHERE FilenameId=%u", 
+           bsnprintf(buf, sizeof(buf), "DELETE FROM Filename WHERE FilenameId=%u",
               id_list.Id[j]);
            if (verbose > 2) {
-               printf("%s\n", buf);
+              printf("%s\n", buf);
            }
            db_sql_query(db, buf, NULL, NULL);
         }
@@ -612,11 +612,11 @@ static void eliminate_duplicate_paths()
    char esc_name[5000];
 
    printf(_("Checking for duplicate Path entries.\n"));
-   
+
    /* 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);
@@ -630,28 +630,28 @@ static void eliminate_duplicate_paths()
       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);
+        bsnprintf(buf, sizeof(buf), "SELECT PathId FROM Path WHERE Path='%s'", esc_name);
         if (verbose > 1) {
-            printf("%s\n", buf);
+           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]);
+           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", 
+           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);
+              printf("%s\n", buf);
            }
            db_sql_query(db, buf, NULL, NULL);
-            bsnprintf(buf, sizeof(buf), "DELETE FROM Path WHERE PathId=%u", 
+           bsnprintf(buf, sizeof(buf), "DELETE FROM Path WHERE PathId=%u",
               id_list.Id[j]);
            if (verbose > 2) {
-               printf("%s\n", buf);
+              printf("%s\n", buf);
            }
            db_sql_query(db, buf, NULL, NULL);
         }
@@ -666,23 +666,23 @@ static void eliminate_orphaned_jobmedia_records()
 
    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));
+           printf("%s\n", db_strerror(db));
         }
       }
    }
-   
+
    if (fix && id_list.num_ids > 0) {
       printf("Deleting %d orphaned JobMedia records.\n", id_list.num_ids);
       delete_id_list("DELETE FROM JobMedia WHERE JobMediaId=%u", &id_list);
@@ -695,8 +695,8 @@ static void eliminate_orphaned_file_records()
 
    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);
    }
@@ -710,11 +710,11 @@ static void eliminate_orphaned_file_records()
 "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));
+           printf("%s\n", db_strerror(db));
         }
       }
    }
-      
+
    if (fix && id_list.num_ids > 0) {
       printf("Deleting %d orphaned File records.\n", id_list.num_ids);
       delete_id_list("DELETE FROM File WHERE FileId=%u", &id_list);
@@ -727,8 +727,8 @@ static void eliminate_orphaned_path_records()
 
    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);
    }
@@ -738,11 +738,11 @@ static void eliminate_orphaned_path_records()
    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]);
+        bsnprintf(buf, sizeof(buf), "SELECT Path FROM Path WHERE PathId=%u", id_list.Id[i]);
         db_sql_query(db, buf, print_name_handler, NULL);
       }
    }
-   
+
    if (fix && id_list.num_ids > 0) {
       printf("Deleting %d orphaned Path records.\n", id_list.num_ids);
       delete_id_list("DELETE FROM Path WHERE PathId=%u", &id_list);
@@ -755,8 +755,8 @@ static void eliminate_orphaned_filename_records()
 
    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);
    }
@@ -766,11 +766,11 @@ static void eliminate_orphaned_filename_records()
    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]);
+        bsnprintf(buf, sizeof(buf), "SELECT Name FROM Filename WHERE FilenameId=%u", id_list.Id[i]);
         db_sql_query(db, buf, print_name_handler, NULL);
       }
    }
-   
+
    if (fix && id_list.num_ids > 0) {
       printf("Deleting %d orphaned Filename records.\n", id_list.num_ids);
       delete_id_list("DELETE FROM Filename WHERE FilenameId=%u", &id_list);
@@ -783,8 +783,8 @@ static void eliminate_orphaned_fileset_records()
 
    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);
    }
@@ -794,14 +794,14 @@ static void eliminate_orphaned_fileset_records()
    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]);
+        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("%s\n", db_strerror(db));
         }
       }
    }
-   
+
    if (fix && id_list.num_ids > 0) {
       printf("Deleting %d orphaned FileSet records.\n", id_list.num_ids);
       delete_id_list("DELETE FROM FileSet WHERE FileSetId=%u", &id_list);
@@ -821,8 +821,8 @@ static void eliminate_orphaned_client_records()
     *  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);
    }
@@ -832,14 +832,14 @@ static void eliminate_orphaned_client_records()
    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]);
+        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("%s\n", db_strerror(db));
         }
       }
    }
-   
+
    if (fix && id_list.num_ids > 0) {
       printf("Deleting %d orphaned Client records.\n", id_list.num_ids);
       delete_id_list("DELETE FROM Client WHERE ClientId=%u", &id_list);
@@ -859,8 +859,8 @@ static void eliminate_orphaned_job_records()
     *  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);
    }
@@ -870,14 +870,14 @@ static void eliminate_orphaned_job_records()
    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]);
+        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("%s\n", db_strerror(db));
         }
       }
    }
-   
+
    if (fix && id_list.num_ids > 0) {
       printf("Deleting %d orphaned Job records.\n", id_list.num_ids);
       delete_id_list("DELETE FROM Job WHERE JobId=%u", &id_list);
@@ -891,7 +891,7 @@ static void eliminate_admin_records()
 
    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);
    }
@@ -901,14 +901,14 @@ static void eliminate_admin_records()
    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]);
+        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("%s\n", db_strerror(db));
         }
       }
    }
-   
+
    if (fix && id_list.num_ids > 0) {
       printf("Deleting %d Admin Job records.\n", id_list.num_ids);
       delete_id_list("DELETE FROM Job WHERE JobId=%u", &id_list);
@@ -921,7 +921,7 @@ static void eliminate_restore_records()
 
    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);
    }
@@ -931,14 +931,14 @@ static void eliminate_restore_records()
    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]);
+        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("%s\n", db_strerror(db));
         }
       }
    }
-   
+
    if (fix && id_list.num_ids > 0) {
       printf("Deleting %d Restore Job records.\n", id_list.num_ids);
       delete_id_list("DELETE FROM Job WHERE JobId=%u", &id_list);
@@ -955,7 +955,7 @@ static void repair_bad_filenames()
 
    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);
    }
@@ -965,41 +965,41 @@ static void repair_bad_filenames()
    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]);
+        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));
+           printf("%s\n", db_strerror(db));
         }
       }
    }
-      
+
    if (fix && id_list.num_ids > 0) {
       POOLMEM *name = get_pool_memory(PM_FNAME);
       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]);
+        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));
+           printf("%s\n", db_strerror(db));
         }
         /* Strip trailing slash(es) */
-         for (len=strlen(name); len > 0 && name[len-1]=='/'; len--)
+        for (len=strlen(name); len > 0 && name[len-1]=='/'; len--)
            {  }
         if (len == 0) {
            len = 1;
-            esc_name[0] = ' ';
+           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", 
+        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);
+           printf("%s\n", buf);
         }
         db_sql_query(db, buf, NULL, NULL);
       }
@@ -1013,7 +1013,7 @@ static void repair_bad_paths()
 
    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);
    }
@@ -1023,36 +1023,36 @@ static void repair_bad_paths()
    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]);
+        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));
+           printf("%s\n", db_strerror(db));
         }
       }
    }
-      
+
    if (fix && id_list.num_ids > 0) {
       POOLMEM *name = get_pool_memory(PM_FNAME);
       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]);
+        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));
+           printf("%s\n", db_strerror(db));
         }
         /* Strip trailing blanks */
-         for (len=strlen(name); len > 0 && name[len-1]==' '; len--) {
+        for (len=strlen(name); len > 0 && name[len-1]==' '; len--) {
            name[len-1] = 0;
         }
         /* Add trailing slash */
-         len = pm_strcat(&name, "/");
+        len = pm_strcat(&name, "/");
         db_escape_string(esc_name, name, len);
-         bsnprintf(buf, sizeof(buf), "UPDATE Path SET Path='%s' WHERE PathId=%u", 
+        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);
+           printf("%s\n", buf);
         }
         db_sql_query(db, buf, NULL, NULL);
       }
@@ -1079,7 +1079,7 @@ static char *get_cmd(const char *prompt)
 
 static int yes_no(const char *prompt)
 {
-   char *cmd;  
+   char *cmd;
    cmd = get_cmd(prompt);
    return strcasecmp(cmd, "yes") == 0;
 }
index c34fe519632f0e20753ec7a387046e1f3e0e0b63..458f776767992b12f137a902ff512b6f2b65db81 100644 (file)
@@ -1,14 +1,14 @@
-/*  
+/*
  * Program for determining file system type
  *
  *   Written by Preben 'Peppe' Guldberg, December MMIV
- * 
+ *
  *   Version $Id$
- *   
+ *
  */
 
 /*
-   Copyright (C) 2004 Kern Sibbald               
+   Copyright (C) 2004 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
@@ -57,14 +57,14 @@ main (int argc, char *const *argv)
 
    while ((ch = getopt(argc, argv, "v?")) != -1) {
       switch (ch) {
-         case 'v':
+        case 'v':
            verbose = 1;
            break;
-         case '?':
+        case '?':
         default:
            usage();
 
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -76,13 +76,13 @@ main (int argc, char *const *argv)
    for (i = 0; i < argc; --argc, ++argv) {
       if ((fs = fstype(*argv)) != NULL) {
         if (verbose) {
-            printf("%s: %s\n", *argv, fs);
+           printf("%s: %s\n", *argv, fs);
         } else {
            puts(fs);
         }
         free(fs);
       } else {
-         fprintf(stderr, "%s: unknown\n", *argv);
+        fprintf(stderr, "%s: unknown\n", *argv);
         status = 1;
       }
    }
index 3630884ead9a5b91f4caf14a3a5b1cb79d1b5b4a..e72fb045ab2a3dd64493fb63612dc5e7acb33dde 100644 (file)
@@ -1,4 +1,4 @@
-/*  
+/*
  * Test program for find files
  */
 
@@ -82,30 +82,30 @@ main (int argc, char *const *argv)
 
    while ((ch = getopt(argc, argv, "ad:e:i:?")) != -1) {
       switch (ch) {
-         case 'a':                    /* print extended attributes *debug* */
+        case 'a':                    /* print extended attributes *debug* */
            attrs = 1;
            break;
 
-         case 'd':                    /* set debug level */
+        case 'd':                    /* set debug level */
            debug_level = atoi(optarg);
            if (debug_level <= 0) {
-              debug_level = 1; 
+              debug_level = 1;
            }
            break;
 
-         case 'e':                    /* exclude patterns */
+        case 'e':                    /* exclude patterns */
            exc = optarg;
            break;
 
-         case 'i':                    /* include patterns */
+        case 'i':                    /* include patterns */
            inc = optarg;
            break;
 
-         case '?':
+        case '?':
         default:
            usage();
 
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -115,22 +115,22 @@ main (int argc, char *const *argv)
    ff = init_find_files();
    if (argc == 0 && !inc) {
       add_fname_to_include_list(ff, 0, "/"); /* default to / */
-   } else {   
+   } else {
       for (i=0; i < argc; i++) {
-         if (strcmp(argv[i], "-") == 0) {
+        if (strcmp(argv[i], "-") == 0) {
             while (fgets(name, sizeof(name)-1, stdin)) {
                strip_trailing_junk(name);
-               add_fname_to_include_list(ff, 0, name); 
+               add_fname_to_include_list(ff, 0, name);
              }
              continue;
         }
-        add_fname_to_include_list(ff, 0, argv[i]); 
+        add_fname_to_include_list(ff, 0, argv[i]);
       }
    }
    if (inc) {
       fd = fopen(inc, "r");
       if (!fd) {
-         printf("Could not open include file: %s\n", inc);
+        printf("Could not open include file: %s\n", inc);
         exit(1);
       }
       while (fgets(name, sizeof(name)-1, fd)) {
@@ -143,7 +143,7 @@ main (int argc, char *const *argv)
    if (exc) {
       fd = fopen(exc, "r");
       if (!fd) {
-         printf("Could not open exclude file: %s\n", exc);
+        printf("Could not open exclude file: %s\n", exc);
         exit(1);
       }
       while (fgets(name, sizeof(name)-1, fd)) {
@@ -154,17 +154,17 @@ main (int argc, char *const *argv)
    }
    find_files(jcr, ff, print_file, NULL);
    hard_links = term_find_files(ff);
-  
-   printf(_("\
-Total files    : %d\n\
-Max file length: %d\n\
-Max path length: %d\n\
-Files truncated: %d\n\
-Paths truncated: %d\n\
-Hard links     : %d\n"),
+
+   printf(_(""
+"Total files    : %d\n"
+"Max file length: %d\n"
+"Max path length: %d\n"
+"Files truncated: %d\n"
+"Paths truncated: %d\n"
+"Hard links     : %d\n"),
      num_files, max_file_len, max_path_len,
      trunc_fname, trunc_path, hard_links);
-  
+
   free_jcr(jcr);
   close_memory_pool();
   sm_dump(false);
@@ -177,32 +177,32 @@ static int print_file(FF_PKT *ff, void *pkt)
    switch (ff->type) {
    case FT_LNKSAVED:
       if (debug_level == 1) {
-         printf("%s\n", ff->fname);
+        printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-         printf("Lnka: %s -> %s\n", ff->fname, ff->link);
+        printf("Lnka: %s -> %s\n", ff->fname, ff->link);
       }
       break;
    case FT_REGE:
       if (debug_level == 1) {
-         printf("%s\n", ff->fname);
+        printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-         printf("Empty: %s\n", ff->fname);
+        printf("Empty: %s\n", ff->fname);
       }
       count_files(ff);
-      break; 
+      break;
    case FT_REG:
       if (debug_level == 1) {
-         printf("%s\n", ff->fname);
+        printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-         printf("Reg: %s\n", ff->fname);
+        printf("Reg: %s\n", ff->fname);
       }
       count_files(ff);
       break;
    case FT_LNK:
       if (debug_level == 1) {
-         printf("%s\n", ff->fname);
+        printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-         printf("Lnk: %s -> %s\n", ff->fname, ff->link);
+        printf("Lnk: %s -> %s\n", ff->fname, ff->link);
       }
       count_files(ff);
       break;
@@ -228,9 +228,9 @@ static int print_file(FF_PKT *ff, void *pkt)
       break;
    case FT_SPEC:
       if (debug_level == 1) {
-         printf("%s\n", ff->fname);
+        printf("%s\n", ff->fname);
       } else if (debug_level > 1) {
-         printf("Spec: %s\n", ff->fname);
+        printf("Spec: %s\n", ff->fname);
       }
       count_files(ff);
       break;
@@ -260,14 +260,14 @@ static int print_file(FF_PKT *ff, void *pkt)
       char attr[200];
       encode_attribsEx(NULL, attr, ff);
       if (*attr != 0) {
-         printf("AttrEx=%s\n", attr);
+        printf("AttrEx=%s\n", attr);
       }
 //    set_attribsEx(NULL, ff->fname, NULL, NULL, ff->type, attr);
    }
    return 1;
 }
 
-static void count_files(FF_PKT *ar) 
+static void count_files(FF_PKT *ar)
 {
    int fnl, pnl;
    char *l, *p;
@@ -276,7 +276,7 @@ static void count_files(FF_PKT *ar)
 
    num_files++;
 
-   /* Find path without the filename.  
+   /* Find path without the filename.
     * I.e. everything after the last / is a "filename".
     * OK, maybe it is a directory name, but we treat it like
     * a filename. If we don't find a / then the whole name
@@ -294,7 +294,7 @@ static void count_files(FF_PKT *ar)
    }
 
    /* If filename doesn't exist (i.e. root directory), we
-    * simply create a blank name consisting of a single 
+    * simply create a blank name consisting of a single
     * space. This makes handling zero length filenames
     * easier.
     */
@@ -315,7 +315,7 @@ static void count_files(FF_PKT *ar)
       file[1] = 0;
    }
 
-   pnl = l - ar->fname;    
+   pnl = l - ar->fname;
    if (pnl > max_path_len) {
       max_path_len = pnl;
    }
index 667ab80088eda0a9fdce6a3b65d91a0fd626365c..f10ee60b4e970b2e654fd48d8b9293caab5a7a15 100755 (executable)
@@ -1,4 +1,4 @@
-/*  
+/*
  * Test program for listing files during regression testing
  */
 
@@ -84,7 +84,7 @@ main (int argc, char *const *argv)
       case 'd':                       /* set debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0) {
-           debug_level = 1; 
+           debug_level = 1;
         }
         break;
 
@@ -100,7 +100,7 @@ main (int argc, char *const *argv)
       default:
         usage();
 
-      }  
+      }
    }
    argc -= optind;
    argv += optind;
@@ -110,22 +110,22 @@ main (int argc, char *const *argv)
    ff = init_find_files();
    if (argc == 0 && !inc) {
       add_fname_to_include_list(ff, 0, "/"); /* default to / */
-   } else {   
+   } else {
       for (i=0; i < argc; i++) {
-         if (strcmp(argv[i], "-") == 0) {
+        if (strcmp(argv[i], "-") == 0) {
             while (fgets(name, sizeof(name)-1, stdin)) {
                strip_trailing_junk(name);
-               add_fname_to_include_list(ff, 0, name); 
+               add_fname_to_include_list(ff, 0, name);
              }
              continue;
         }
-        add_fname_to_include_list(ff, 0, argv[i]); 
+        add_fname_to_include_list(ff, 0, argv[i]);
       }
    }
    if (inc) {
       fd = fopen(inc, "r");
       if (!fd) {
-         printf("Could not open include file: %s\n", inc);
+        printf("Could not open include file: %s\n", inc);
         exit(1);
       }
       while (fgets(name, sizeof(name)-1, fd)) {
@@ -138,7 +138,7 @@ main (int argc, char *const *argv)
    if (exc) {
       fd = fopen(exc, "r");
       if (!fd) {
-         printf("Could not open exclude file: %s\n", exc);
+        printf("Could not open exclude file: %s\n", exc);
         exit(1);
       }
       while (fgets(name, sizeof(name)-1, fd)) {
@@ -149,7 +149,7 @@ main (int argc, char *const *argv)
    }
    find_files(jcr, ff, print_file, NULL);
    hard_links = term_find_files(ff);
-  
+
    free_jcr(jcr);
    close_memory_pool();
    sm_dump(false);
@@ -203,7 +203,7 @@ static int print_file(FF_PKT *ff, void *pkt)
 
 static void print_ls_output(char *fname, char *link, int type, struct stat *statp)
 {
-   char buf[1000]; 
+   char buf[1000];
    char ec1[30];
    char *p, *f;
    int n;
@@ -221,7 +221,7 @@ static void print_ls_output(char *fname, char *link, int type, struct stat *stat
    p += n;
    if (S_ISCHR(statp->st_mode) || S_ISBLK(statp->st_mode)) {
       n = sprintf(p, "%4x ", (int)statp->st_rdev);
-   } else { 
+   } else {
       n = sprintf(p, "     ");
    }
    p += n;
index 1ca320b5f4f406d16f7abb0de7e588f490d99687..f68f5e76dfef081810c8ca89590b0f96548921f4 100644 (file)
@@ -8,8 +8,8 @@
 #undef  DEBUG
 #define DEBUG 1
 #define TRACEBACK 1
-#define SMCHECK     
-#define TRACE_FILE 1  
+#define SMCHECK
+#define TRACE_FILE 1
 
 /* If this is set stdout will not be closed on startup */
 #define DEVELOPER 1