]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Fix tray-monitor by not requiring a timer interval in bnet_connect()
authorKern Sibbald <kern@sibbald.com>
Sun, 20 May 2007 11:12:13 +0000 (11:12 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 20 May 2007 11:12:13 +0000 (11:12 +0000)
kes  Complete change of berrno strerror() method to bstrerror()

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

25 files changed:
bacula/src/cats/sql.c
bacula/src/lib/base64.c
bacula/src/lib/berrno.c
bacula/src/lib/berrno.h
bacula/src/lib/bnet.c
bacula/src/lib/bnet_server.c
bacula/src/lib/bpipe.c
bacula/src/lib/bsock.c
bacula/src/lib/bsys.c
bacula/src/lib/daemon.c
bacula/src/lib/jcr.c
bacula/src/lib/lex.c
bacula/src/lib/message.c
bacula/src/lib/openssl.c
bacula/src/lib/parse_conf.c
bacula/src/lib/pythonlib.c
bacula/src/lib/runscript.c
bacula/src/lib/rwlock.c
bacula/src/lib/sha1.c
bacula/src/lib/signal.c
bacula/src/lib/tree.c
bacula/src/lib/watchdog.c
bacula/src/lib/workq.c
bacula/src/version.h
bacula/technotes-2.1

index fef68b35f65b1127e8147b9bdab4593017f247d8..908a70a394c154dfa00760f22d2488c84a231627 100644 (file)
@@ -266,7 +266,7 @@ void _db_lock(const char *file, int line, B_DB *mdb)
    if ((errstat=rwl_writelock(&mdb->lock)) != 0) {
       berrno be;
       e_msg(file, line, M_FATAL, 0, "rwl_writelock failure. stat=%d: ERR=%s\n",
-           errstat, be.strerror(errstat));
+           errstat, be.bstrerror(errstat));
    }
 }
 
@@ -281,7 +281,7 @@ void _db_unlock(const char *file, int line, B_DB *mdb)
    if ((errstat=rwl_writeunlock(&mdb->lock)) != 0) {
       berrno be;
       e_msg(file, line, M_FATAL, 0, "rwl_writeunlock failure. stat=%d: ERR=%s\n",
-           errstat, be.strerror(errstat));
+           errstat, be.bstrerror(errstat));
    }
 }
 
index 55ce65392cc9dc27fc525944a6c1e7b939427d88..bad70c1750d3ac1d93706e43a75555cb732acff8 100644 (file)
@@ -247,7 +247,8 @@ 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));
+         berrno be;
+         printf("Cannot stat %s: %s\n", fname, be.bstrerror(errno));
          continue;
       }
       encode_stat(where, &statp);
index 47c1ad82d443e1cb02ca31651cfd2af874699e26..673e21c7fc42984dd746b9a5ca538933c887eb55 100644 (file)
@@ -50,49 +50,49 @@ extern int execvp_errors[];
 const char *berrno::bstrerror()
 {
 #ifdef HAVE_WIN32
-   if (berrno_ & b_errno_win32) {
-      return (const char *)buf_;
+   if (m_berrno & b_errno_win32) {
+      return (const char *)m_buf;
    }
 #else
    int stat = 0;
 
-   if (berrno_ & b_errno_exit) {
-      stat = (berrno_ & ~b_errno_exit);       /* remove bit */
+   if (m_berrno & b_errno_exit) {
+      stat = (m_berrno & ~b_errno_exit);       /* remove bit */
       if (stat == 0) {
          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];
+               m_berrno = execvp_errors[stat - 200];
             } else {
                return _("Unknown error during program execvp");
             }
          } else {
-            Mmsg(buf_, _("Child exited with code %d"), stat);
-            return buf_;
+            Mmsg(m_buf, _("Child exited with code %d"), stat);
+            return m_buf;
          }
-         /* If we drop out here, berrno_ is set to an execvp errno */
+         /* If we drop out here, m_berrno is set to an execvp errno */
       }
    }
-   if (berrno_ & b_errno_signal) {
-      stat = (berrno_ & ~b_errno_signal);        /* remove bit */
-      Mmsg(buf_, _("Child died from signal %d: %s"), stat, get_signal_name(stat));
-      return buf_;
+   if (m_berrno & b_errno_signal) {
+      stat = (m_berrno & ~b_errno_signal);        /* remove bit */
+      Mmsg(m_buf, _("Child died from signal %d: %s"), stat, get_signal_name(stat));
+      return m_buf;
    }
 #endif
    /* Normal errno */
-   if (b_strerror(berrno_, buf_, 1024) < 0) {
+   if (b_strerror(m_berrno, m_buf, 1024) < 0) {
       return _("Invalid errno. No error message possible.");
    }
-   return buf_;
+   return m_buf;
 }
 
 void berrno::format_win32_message()
 {
 #ifdef HAVE_WIN32
    LPVOID msg;
-   if (berrno_ & b_errno_win32) {
+   if (m_berrno & b_errno_win32) {
       FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
           FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
           NULL,
@@ -102,7 +102,7 @@ void berrno::format_win32_message()
           0,
           NULL);
 
-      pm_strcpy(&buf_, (const char *)msg);
+      pm_strcpy(&m_buf, (const char *)msg);
       LocalFree(msg);
    }
 #endif
index 13750cdd3563060ccb4511c7bd288ad3c45f1282..9ba879616080e9a05378a3370abb03ec765c1583 100644 (file)
  *  for editing the message. strerror() does the actual editing, and
  *  it is thread safe.
  *
- * If bit 29 in berrno_ is set then it is a Win32 error, and we
+ * If bit 29 in m_berrno is set then it is a Win32 error, and we
  *  must do a GetLastError() to get the error code for formatting.
- * If bit 29 in berrno_ is not set, then it is a Unix errno.
+ * If bit 29 in m_berrno is not set, then it is a Unix errno.
  *
  */
 class berrno : public SMARTALLOC {
-   POOLMEM *buf_;
-   int berrno_;
+   POOLMEM *m_buf;
+   int m_berrno;
    void format_win32_message();
 public:
    berrno(int pool=PM_EMSG);
    ~berrno();
-   const char *strerror() { return bstrerror(); };
    const char *bstrerror();
-   const char *strerror(int errnum) { return bstrerror(errnum); };
    const char *bstrerror(int errnum);
    void set_errno(int errnum);
-   int code() { return berrno_ & ~(b_errno_exit|b_errno_signal); }
+   int code() { return m_berrno & ~(b_errno_exit|b_errno_signal); }
    int code(int stat) { return stat & ~(b_errno_exit|b_errno_signal); }
 };
 
 /* Constructor */
 inline berrno::berrno(int pool)
 {
-   berrno_ = errno;
-   buf_ = get_pool_memory(pool);
+   m_berrno = errno;
+   m_buf = get_pool_memory(pool);
 #ifdef HAVE_WIN32
    format_win32_message();
 #endif
@@ -84,17 +82,17 @@ inline berrno::berrno(int pool)
 
 inline berrno::~berrno()
 {
-   free_pool_memory(buf_);
+   free_pool_memory(m_buf);
 }
 
 inline const char *berrno::bstrerror(int errnum)
 {
-   berrno_ = errnum;
+   m_berrno = errnum;
    return berrno::bstrerror();
 }
 
 
 inline void berrno::set_errno(int errnum)
 {
-   berrno_ = errnum;
+   m_berrno = errnum;
 }
index 43b71c8136b0c2f837761aa387e96d81bead914a..b2d0fcdd0564e8c3658d4929fd47870524b0c25e 100644 (file)
@@ -116,7 +116,7 @@ int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes)
          berrno be;
          bsock->b_errno = errno;
          Qmsg1(bsock->jcr(), M_FATAL, 0, _("Attr spool write error. ERR=%s\n"),
-               be.strerror());
+               be.bstrerror());
          Dmsg2(400, "nwritten=%d nbytes=%d.\n", nwritten, nbytes);
          errno = bsock->b_errno;
          return -1;
@@ -419,7 +419,7 @@ static const char *gethost_strerror()
    berrno be;
    switch (h_errno) {
    case NETDB_INTERNAL:
-      msg = be.strerror();
+      msg = be.bstrerror();
       break;
    case NETDB_SUCCESS:
       msg = _("No problem.");
@@ -593,7 +593,7 @@ static BSOCK *bnet_open(JCR *jcr, const char *name, char *host, char *service,
          save_errno = errno;
          *fatal = 1;
          Pmsg3(000, _("Socket open error. proto=%d port=%d. ERR=%s\n"),
-            ipaddr->get_family(), ipaddr->get_port_host_order(), be.strerror());
+            ipaddr->get_family(), ipaddr->get_port_host_order(), be.bstrerror());
          continue;
       }
       /*
@@ -602,7 +602,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"),
-               be.strerror());
+               be.bstrerror());
       }
 #if defined(TCP_KEEPIDLE)
       if (heart_beat) {
@@ -610,7 +610,7 @@ static BSOCK *bnet_open(JCR *jcr, const char *name, char *host, char *service,
          if (setsockopt(sockfd, IPPROTO_IP, TCP_KEEPIDLE, (sockopt_val_t)&opt, sizeof(opt)) < 0) {
             berrno be;
             Qmsg1(jcr, M_WARNING, 0, _("Cannot set SO_KEEPIDLE on socket: %s\n"),
-                  be.strerror());
+                  be.bstrerror());
          }
       }
 #endif
@@ -638,7 +638,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"),
-            be.strerror());
+            be.bstrerror());
    }
    BSOCK* ret =  init_bsock(jcr, sockfd, name, host, port, ipaddr->get_sockaddr());
    free_addresses(addr_list);
@@ -661,7 +661,9 @@ BSOCK *bnet_connect(JCR * jcr, int retry_interval, utime_t max_retry_time,
    btimer_t *tid = NULL;
 
    /* Try to trap out of OS call when time expires */
-   tid = start_thread_timer(pthread_self(), (uint32_t)max_retry_time);
+   if (max_retry_time) {
+      tid = start_thread_timer(pthread_self(), (uint32_t)max_retry_time);
+   }
    
    for (i = 0; (bsock = bnet_open(jcr, name, host, service, port, heart_beat, &fatal)) == NULL;
         i -= retry_interval) {
@@ -671,19 +673,19 @@ BSOCK *bnet_connect(JCR * jcr, int retry_interval, utime_t max_retry_time,
          goto bail_out;
       }
       Dmsg4(100, "Unable to connect to %s on %s:%d. ERR=%s\n",
-            name, host, port, be.strerror());
+            name, host, port, be.bstrerror());
       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());
+               "Retrying ...\n"), name, host, port, be.bstrerror());
       }
       bmicrosleep(retry_interval, 0);
       now = time(NULL);
       if (begin_time + max_retry_time <= now) {
          Qmsg4(jcr, M_FATAL, 0, _("Unable to connect to %s on %s:%d. ERR=%s\n"),
-               name, host, port, be.strerror());
+               name, host, port, be.bstrerror());
          bsock = NULL;
          goto bail_out;
       }
@@ -707,7 +709,7 @@ const char *bnet_strerror(BSOCK * bsock)
    if (bsock->errmsg == NULL) {
       bsock->errmsg = get_pool_memory(PM_MESSAGE);
    }
-   pm_strcpy(bsock->errmsg, be.strerror(bsock->b_errno));
+   pm_strcpy(bsock->errmsg, be.bstrerror(bsock->b_errno));
    return bsock->errmsg;
 }
 
@@ -788,7 +790,7 @@ bool bnet_set_buffer_size(BSOCK * bs, uint32_t size, int rw)
       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.bstrerror());
          dbuf_size -= TAPE_BSIZE;
       }
       Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
@@ -812,7 +814,7 @@ bool bnet_set_buffer_size(BSOCK * bs, uint32_t size, int rw)
       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.bstrerror());
          dbuf_size -= TAPE_BSIZE;
       }
       Dmsg1(900, "set network buffer size=%d\n", dbuf_size);
@@ -842,13 +844,13 @@ int bnet_set_nonblocking (BSOCK *bsock) {
    /* Get current flags */
    if ((oflags = fcntl(bsock->fd, F_GETFL, 0)) < 0) {
       berrno be;
-      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.strerror());
+      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror());
    }
 
    /* Set O_NONBLOCK flag */
    if ((fcntl(bsock->fd, F_SETFL, oflags|O_NONBLOCK)) < 0) {
       berrno be;
-      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.strerror());
+      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror());
    }
 
    bsock->blocking = 0;
@@ -876,13 +878,13 @@ int bnet_set_blocking (BSOCK *bsock)
    /* Get current flags */
    if ((oflags = fcntl(bsock->fd, F_GETFL, 0)) < 0) {
       berrno be;
-      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.strerror());
+      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror());
    }
 
    /* Set O_NONBLOCK flag */
    if ((fcntl(bsock->fd, F_SETFL, oflags & ~O_NONBLOCK)) < 0) {
       berrno be;
-      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.strerror());
+      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror());
    }
 
    bsock->blocking = 1;
@@ -907,7 +909,7 @@ void bnet_restore_blocking (BSOCK *bsock, int flags)
 #ifndef HAVE_WIN32
    if ((fcntl(bsock->fd, F_SETFL, flags)) < 0) {
       berrno be;
-      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.strerror());
+      Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror());
    }
 
    bsock->blocking = (flags & O_NONBLOCK);
index d7ade4a9cd87fadcffe9adbeb4c6c91f7b822e94..b30d17e14f525a74ef37112c5cd1e8aa28d6124f 100644 (file)
@@ -1,14 +1,7 @@
- /*
-  * Originally written by Kern Sibbald for inclusion in apcupsd,
-  *  but heavily modified for Bacula
-  *
-  *   Version $Id$
-  */
-
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
-
+ /*
+  * Originally written by Kern Sibbald for inclusion in apcupsd,
+  *  but heavily modified for Bacula
+  *
+  *   Version $Id$
+  */
 
 #include "bacula.h"
 #include <netinet/in.h>
@@ -109,7 +107,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
             berrno be;
             char curbuf[256];
             Emsg3(M_ABORT, 0, _("Cannot open stream socket. ERR=%s. Current %s All %s\n"),
-                       be.strerror(),
+                       be.bstrerror(),
                        p->build_address_str(curbuf, sizeof(curbuf)),
                        build_addresses_str(addrs, allbuf, sizeof(allbuf)));
          }
@@ -122,7 +120,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
            sizeof(turnon)) < 0) {
          berrno be;
          Emsg1(M_WARNING, 0, _("Cannot set SO_REUSEADDR on socket: %s\n"),
-               be.strerror());
+               be.bstrerror());
       }
 
       int tmax = 30 * (60 / 5);    /* wait 30 minutes max */
@@ -131,12 +129,12 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
          if (tlog <= 0) {
             tlog = 2 * 60;         /* Complain every 2 minutes */
             Emsg2(M_WARNING, 0, _("Cannot bind port %d: ERR=%s: Retrying ...\n"),
-                  ntohs(fd_ptr->port), be.strerror());
+                  ntohs(fd_ptr->port), be.bstrerror());
          }
          bmicrosleep(5, 0);
          if (--tmax <= 0) {
             Emsg2(M_ABORT, 0, _("Cannot bind port %d: ERR=%s.\n"), ntohs(fd_ptr->port),
-                  be.strerror());
+                  be.bstrerror());
          }
       }
       listen(fd_ptr->fd, 5);       /* tell system we are ready */
@@ -146,7 +144,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
    if ((stat = workq_init(client_wq, max_clients, handle_client_request)) != 0) {
       berrno be;
       be.set_errno(stat);
-      Emsg1(M_ABORT, 0, _("Could not init client queue: ERR=%s\n"), be.strerror());
+      Emsg1(M_ABORT, 0, _("Could not init client queue: ERR=%s\n"), be.bstrerror());
    }
    /*
     * Wait for a connection from the client process.
@@ -169,7 +167,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
          foreach_dlist(fd_ptr, &sockfds) {
             close(fd_ptr->fd);
          }
-         Emsg1(M_FATAL, 0, _("Error in select: %s\n"), be.strerror());
+         Emsg1(M_FATAL, 0, _("Error in select: %s\n"), be.bstrerror());
          break;
       }
 
@@ -206,7 +204,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
                  sizeof(turnon)) < 0) {
                berrno be;
                Emsg1(M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"),
-                     be.strerror());
+                     be.bstrerror());
             }
 
             /* see who client is. i.e. who connected to us. */
@@ -224,7 +222,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
                berrno be;
                be.set_errno(stat);
                Jmsg1(NULL, M_ABORT, 0, _("Could not add job to client queue: ERR=%s\n"),
-                     be.strerror());
+                     be.bstrerror());
             }
          }
       }
@@ -235,7 +233,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq,
       berrno be;
       be.set_errno(stat);
       Emsg1(M_FATAL, 0, _("Could not destroy client queue: ERR=%s\n"),
-            be.strerror());
+            be.bstrerror());
    }
 }
 
@@ -256,12 +254,13 @@ BSOCK *bnet_bind(int port)
     * Open a TCP socket
     */
    for (tlog = 0; (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0; tlog -= 10) {
+      berrno be;
       if (errno == EINTR || errno == EAGAIN) {
          continue;
       }
       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"), be.bstrerror());
       }
       bmicrosleep(60, 0);
    }
@@ -270,8 +269,9 @@ BSOCK *bnet_bind(int port)
     * Reuse old sockets
     */
    if (setsockopt(sockfd, 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"),
-            strerror(errno));
+            be.bstrerror());
    }
 
    /*
@@ -291,7 +291,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,
-               be.strerror());
+               be.bstrerror());
       }
       bmicrosleep(5, 0);
    }
@@ -328,11 +328,12 @@ BSOCK *bnet_accept(BSOCK * bsock, char *who)
        */
       ready = sockset;
       if ((stat = select(bsock->fd + 1, &ready, NULL, NULL, NULL)) < 0) {
+         berrno be;
          if (errno == EINTR || errno = EAGAIN) {
             errno = 0;
             continue;
          }
-         Emsg1(M_FATAL, 0, _("Error in select: %s\n"), strerror(errno));
+         Emsg1(M_FATAL, 0, _("Error in select: %s\n"), be.bstrerror());
          newsockfd = -1;
          break;
       }
@@ -363,8 +364,9 @@ BSOCK *bnet_accept(BSOCK * bsock, char *who)
     * Receive notification when connection dies.
     */
    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"),
-            strerror(errno));
+            be.bstrerror());
    }
 
    /* see who client is. I.e. who connected to us.
@@ -378,8 +380,9 @@ BSOCK *bnet_accept(BSOCK * bsock, char *who)
    bsock->msglen = strlen(bsock->msg);
 
    if (newsockfd < 0) {
+      berrno be;
       Emsg2(M_FATAL, 0, _("Socket accept error for %s. ERR=%s\n"), who,
-            strerror(errno));
+            be.bstrerror());
       return NULL;
    } else {
       if (caller == NULL) {
index f2de9b683532a3f9fcad1f3a0de7f7c6774072ae..71c9c1d42a5ff915b2e5d06145951347daf4f3ef 100644 (file)
@@ -222,9 +222,10 @@ int close_bpipe(BPIPE *bpipe)
          wpid = waitpid(bpipe->worker_pid, &chldstatus, wait_option);
       } while (wpid == -1 && (errno == EINTR || errno == EAGAIN));
       if (wpid == bpipe->worker_pid || wpid == -1) {
+         berrno be;
          stat = errno;
          Dmsg3(800, "Got break wpid=%d status=%d ERR=%s\n", wpid, chldstatus,
-            wpid==-1?strerror(errno):"none");
+            wpid==-1?be.bstrerror():"none");
          break;
       }
       Dmsg3(800, "Got wpid=%d status=%d ERR=%s\n", wpid, chldstatus,
@@ -347,7 +348,8 @@ int run_program(char *prog, int wait, POOLMEM *results)
          stat1 = ferror(bpipe->rfd);
       }
       if (stat1 < 0) {
-         Dmsg2(150, "Run program fgets stat=%d ERR=%s\n", stat1, strerror(errno));
+         berrno be;
+         Dmsg2(150, "Run program fgets stat=%d ERR=%s\n", stat1, be.bstrerror(errno));
       } else if (stat1 != 0) {
          Dmsg1(150, "Run program fgets stat=%d\n", stat1);
          if (bpipe->timer_id) {
@@ -429,7 +431,7 @@ int run_program_full_output(char *prog, int wait, POOLMEM *results)
       }
       if (stat1 < 0) {
          berrno be;
-         Dmsg2(200, "Run program fgets stat=%d ERR=%s\n", stat1, be.strerror());
+         Dmsg2(200, "Run program fgets stat=%d ERR=%s\n", stat1, be.bstrerror());
          break;
       } else if (stat1 != 0) {
          Dmsg1(900, "Run program fgets stat=%d\n", stat1);
index 4677cea2ec9837b4f4b70fd91cbdf0bd610b9fea..d9a0592a1b7c58f2cbe5c7bd80a8dd53fa6c291b 100644 (file)
@@ -304,7 +304,7 @@ bool BSOCK::despool(void update_attr_spool_size(ssize_t size), ssize_t tsize)
             berrno be;
             Dmsg2(400, "nbytes=%d msglen=%d\n", nbytes, msglen);
             Qmsg1(jcr(), M_FATAL, 0, _("fread attr spool error. ERR=%s\n"),
-                  be.strerror());
+                  be.bstrerror());
             update_attr_spool_size(tsize - last);
             return false;
          }
@@ -320,7 +320,7 @@ bool BSOCK::despool(void update_attr_spool_size(ssize_t size), ssize_t tsize)
    if (ferror(spool_fd)) {
       berrno be;
       Qmsg1(jcr(), M_FATAL, 0, _("fread attr spool error. ERR=%s\n"),
-            be.strerror());
+            be.bstrerror());
       return false;
    }
    return true;
index 3a7899d581090ab66586bb0ce7bc97ceb48263e1..0c741c4b0bb1661314453fcfa9a3ca903c8288bb 100644 (file)
@@ -86,7 +86,7 @@ int bmicrosleep(time_t sec, long usec)
    if (stat != 0) {
       berrno be;
       Dmsg2(200, "pthread_cond_timedwait stat=%d ERR=%s\n", stat,
-         be.strerror(stat));
+         be.bstrerror(stat));
    }
    V(timer_mutex);
    return stat;
@@ -200,7 +200,7 @@ void *bmalloc(size_t size)
 #endif
   if (buf == NULL) {
      berrno be;
-     Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.strerror());
+     Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.bstrerror());
   }
   return buf;
 }
@@ -217,7 +217,7 @@ void *b_malloc(const char *file, int line, size_t size)
 #endif
   if (buf == NULL) {
      berrno be;
-     e_msg(file, line, M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.strerror());
+     e_msg(file, line, M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.bstrerror());
   }
   return buf;
 }
@@ -237,7 +237,7 @@ void *brealloc (void *buf, size_t size)
    buf = realloc(buf, size);
    if (buf == NULL) {
       berrno be;
-      Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.strerror());
+      Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.bstrerror());
    }
    return buf;
 }
@@ -250,7 +250,7 @@ void *bcalloc (size_t size1, size_t size2)
    buf = calloc(size1, size2);
    if (buf == NULL) {
       berrno be;
-      Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.strerror());
+      Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.bstrerror());
    }
    return buf;
 }
@@ -380,7 +380,7 @@ void _p(char *file, int line, pthread_mutex_t *m)
       if ((errstat=pthread_mutex_lock(m))) {
          berrno be;
          e_msg(file, line, M_ABORT, 0, _("Mutex lock failure. ERR=%s\n"),
-               be.strerror(errstat));
+               be.bstrerror(errstat));
       } else {
          e_msg(file, line, M_ERROR, 0, _("Possible mutex deadlock resolved.\n"));
       }
@@ -396,12 +396,12 @@ void _v(char *file, int line, pthread_mutex_t *m)
    if ((errstat=pthread_mutex_trylock(m)) == 0) {
       berrno be;
       e_msg(file, line, M_ERROR, 0, _("Mutex unlock not locked. ERR=%s\n"),
-           be.strerror(errstat));
+           be.bstrerror(errstat));
     }
     if ((errstat=pthread_mutex_unlock(m))) {
        berrno be;
        e_msg(file, line, M_ABORT, 0, _("Mutex unlock failure. ERR=%s\n"),
-              be.strerror(errstat));
+              be.bstrerror(errstat));
     }
 }
 
@@ -413,7 +413,7 @@ void _p(pthread_mutex_t *m)
    if ((errstat=pthread_mutex_lock(m))) {
       berrno be;
       e_msg(__FILE__, __LINE__, M_ABORT, 0, _("Mutex lock failure. ERR=%s\n"),
-            be.strerror(errstat));
+            be.bstrerror(errstat));
    }
 }
 
@@ -423,7 +423,7 @@ void _v(pthread_mutex_t *m)
    if ((errstat=pthread_mutex_unlock(m))) {
       berrno be;
       e_msg(__FILE__, __LINE__, M_ABORT, 0, _("Mutex unlock failure. ERR=%s\n"),
-            be.strerror(errstat));
+            be.bstrerror(errstat));
    }
 }
 
@@ -596,13 +596,13 @@ void write_state_file(char *dir, const char *progname, int port)
    unlink(fname);
    if ((sfd = open(fname, O_CREAT|O_WRONLY|O_BINARY, 0640)) < 0) {
       berrno be;
-      Dmsg2(000, "Could not create state file. %s ERR=%s\n", fname, be.strerror());
-      Emsg2(M_ERROR, 0, _("Could not create state file. %s ERR=%s\n"), fname, be.strerror());
+      Dmsg2(000, "Could not create state file. %s ERR=%s\n", fname, be.bstrerror());
+      Emsg2(M_ERROR, 0, _("Could not create state file. %s ERR=%s\n"), fname, be.bstrerror());
       goto bail_out;
    }
    if (write(sfd, &state_hdr, sizeof(state_hdr)) != sizeof(state_hdr)) {
       berrno be;
-      Dmsg1(000, "Write hdr error: ERR=%s\n", be.strerror());
+      Dmsg1(000, "Write hdr error: ERR=%s\n", be.bstrerror());
       goto bail_out;
    }
 // Dmsg1(010, "Wrote header of %d bytes\n", sizeof(state_hdr));
@@ -611,12 +611,12 @@ void write_state_file(char *dir, const char *progname, int port)
 // Dmsg1(010, "write last job end = %d\n", (int)state_hdr.reserved[0]);
    if (lseek(sfd, 0, SEEK_SET) < 0) {
       berrno be;
-      Dmsg1(000, "lseek error: ERR=%s\n", be.strerror());
+      Dmsg1(000, "lseek error: ERR=%s\n", be.bstrerror());
       goto bail_out;
    }
    if (write(sfd, &state_hdr, sizeof(state_hdr)) != sizeof(state_hdr)) {
       berrno be;
-      Pmsg1(000, _("Write final hdr error: ERR=%s\n"), be.strerror());
+      Pmsg1(000, _("Write final hdr error: ERR=%s\n"), be.bstrerror());
       goto bail_out;
    }
    ok = true;
@@ -653,13 +653,13 @@ void drop(char *uname, char *gname)
       if ((passw = getpwnam(uname)) == NULL) {
          berrno be;
          Emsg2(M_ERROR_TERM, 0, _("Could not find userid=%s: ERR=%s\n"), uname,
-            be.strerror());
+            be.bstrerror());
       }
    } else {
       if ((passw = getpwuid(getuid())) == NULL) {
          berrno be;
          Emsg1(M_ERROR_TERM, 0, _("Could not find password entry. ERR=%s\n"),
-            be.strerror());
+            be.bstrerror());
       } else {
          uname = passw->pw_name;
       }
@@ -672,7 +672,7 @@ void drop(char *uname, char *gname)
       if ((group = getgrnam(gname)) == NULL) {
          berrno be;
          Emsg2(M_ERROR_TERM, 0, _("Could not find group=%s: ERR=%s\n"), gname,
-            be.strerror());
+            be.bstrerror());
       }
       gid = group->gr_gid;
    }
@@ -680,17 +680,17 @@ void drop(char *uname, char *gname)
       berrno be;
       if (gname) {
          Emsg3(M_ERROR_TERM, 0, _("Could not initgroups for group=%s, userid=%s: ERR=%s\n"),         
-            gname, username, be.strerror());
+            gname, username, be.bstrerror());
       } else {
          Emsg2(M_ERROR_TERM, 0, _("Could not initgroups for userid=%s: ERR=%s\n"),         
-            username, be.strerror());
+            username, be.bstrerror());
       }
    }
    if (gname) {
       if (setgid(gid)) {
          berrno be;
          Emsg2(M_ERROR_TERM, 0, _("Could not set group=%s: ERR=%s\n"), gname,
-            be.strerror());
+            be.bstrerror());
       }
    }
    if (setuid(uid)) {
index 9deea049f0181d883ad80a2258d6f78bfba8d047..32252b47c388e8bf87f680b7c5f4026108b36854 100644 (file)
@@ -1,21 +1,7 @@
-/*
- *  daemon.c by Kern Sibbald
- *
- *   Version $Id$
- *
- *   this code is inspired by the Prentice Hall book
- *   "Unix Network Programming" by W. Richard Stevens
- *   and later updated from his book "Advanced Programming
- *   in the UNIX Environment"
- *
- * Initialize a daemon process completely detaching us from
- * any terminal processes.
- *
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *  daemon.c by Kern Sibbald
+ *
+ *   Version $Id$
+ *
+ *   this code is inspired by the Prentice Hall book
+ *   "Unix Network Programming" by W. Richard Stevens
+ *   and later updated from his book "Advanced Programming
+ *   in the UNIX Environment"
+ *
+ * Initialize a daemon process completely detaching us from
+ * any terminal processes.
+ *
+ */
 
 
 #include "bacula.h"
@@ -63,7 +63,7 @@ daemon_start()
    Dmsg0(900, "Enter daemon_start\n");
    if ( (cpid = fork() ) < 0) {
       berrno be;
-      Emsg1(M_ABORT, 0, _("Cannot fork to become daemon: %s\n"), be.strerror());
+      Emsg1(M_ABORT, 0, _("Cannot fork to become daemon: %s\n"), be.bstrerror());
    } else if (cpid > 0) {
       exit(0);              /* parent exits */
    }
index 925227a6b66ff45c621f1290da2c207ced19b792..b477230baad2668198319626a4b593d6037c178c 100644 (file)
@@ -142,7 +142,8 @@ bool 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));
+         berrno be;
+         Pmsg1(000, "Read job entry. ERR=%s\n", be.bstrerror());
          return false;
       }
       if (job.JobId > 0) {
@@ -175,12 +176,14 @@ 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));
+         berrno be;
+         Pmsg1(000, "Error writing num_items: ERR=%s\n", be.bstrerror());
          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));
+            berrno be;
+            Pmsg1(000, "Error writing job: ERR=%s\n", be.bstrerror());
             return 0;
          }
       }
@@ -576,8 +579,7 @@ static void lock_jcr_chain()
 #endif
 {
 #ifdef TRACE_JCR_CHAIN
-   Dmsg3(3400, "Lock jcr chain %d from %s:%d\n", ++lock_count,
-      fname, line);
+   Dmsg3(3400, "Lock jcr chain %d from %s:%d\n", ++lock_count, fname, line);
 #endif
    P(jcr_lock);
 }
@@ -592,8 +594,7 @@ static void unlock_jcr_chain()
 #endif
 {
 #ifdef TRACE_JCR_CHAIN
-   Dmsg3(3400, "Unlock jcr chain %d from %s:%d\n", lock_count--,
-      fname, line);
+   Dmsg3(3400, "Unlock jcr chain %d from %s:%d\n", lock_count--, fname, line);
 #endif
    V(jcr_lock);
 }
@@ -622,8 +623,7 @@ JCR *jcr_walk_start()
    jcr = (JCR *)jcrs->first();
    if (jcr) {
       jcr->inc_use_count();
-      Dmsg3(3400, "Inc jcr_walk_start 0x%x job=%d use_count=%d\n", jcr, 
-            jcr->JobId, jcr->use_count());
+      Dmsg3(3400, "Inc jcr_walk_start 0x%x job=%d use_count=%d\n", jcr, jcr->JobId, jcr->use_count());
    }
    unlock_jcr_chain();
    return jcr;
@@ -640,8 +640,7 @@ JCR *jcr_walk_next(JCR *prev_jcr)
    jcr = (JCR *)jcrs->next(prev_jcr);
    if (jcr) {
       jcr->inc_use_count();
-      Dmsg3(3400, "Inc jcr_walk_next 0x%x job=%d use_count=%d\n", jcr, 
-         jcr->JobId, jcr->use_count());
+      Dmsg3(3400, "Inc jcr_walk_next 0x%x job=%d use_count=%d\n", jcr, jcr->JobId, jcr->use_count());
    }
    unlock_jcr_chain();
    if (prev_jcr) {
index f5f098f68b5463c4d58c407c7580f9020f7e8cd8..049f75e60a0086318314a47bf6eeedc9d89eced0 100644 (file)
@@ -556,7 +556,7 @@ lex_get_token(LEX *lf, int expect)
             if (lf == NULL) {
                berrno be;
                scan_err2(lfori, _("Cannot open included config file %s: %s\n"),
-                  lfori->str, be.strerror());
+                  lfori->str, be.bstrerror());
                return T_ERROR;
             }
             break;
index da28cee39f789abb50d4509f241d70015103508b..d846f426146501702ab62583a2673f59729d4269 100644 (file)
@@ -261,7 +261,7 @@ void init_console_msg(const char *wd)
    if (fd == -1) {
       berrno be;
       Emsg2(M_ERROR_TERM, 0, _("Could not open console message file %s: ERR=%s\n"),
-          con_fname, be.strerror());
+          con_fname, be.bstrerror());
    }
    if (lseek(fd, 0, SEEK_END) > 0) {
       console_msg_pending = 1;
@@ -271,12 +271,12 @@ void init_console_msg(const char *wd)
    if (!con_fd) {
       berrno be;
       Emsg2(M_ERROR, 0, _("Could not open console message file %s: ERR=%s\n"),
-          con_fname, be.strerror());
+          con_fname, be.bstrerror());
    }
    if (rwl_init(&con_lock) != 0) {
       berrno be;
       Emsg1(M_ERROR_TERM, 0, _("Could not get con mutex: ERR=%s\n"),
-         be.strerror());
+         be.bstrerror());
    }
 }
 
@@ -380,7 +380,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"),
-         cmd, be.strerror());
+         cmd, be.bstrerror());
    }
 
    /* If we had to use sendmail, add subject */
@@ -457,7 +457,7 @@ 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.bstrerror());
             }
 
             /*
@@ -479,7 +479,7 @@ void close_msg(JCR *jcr)
                Dmsg1(850, "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());
+                                        "ERR=%s\n"), cmd, be.bstrerror());
             }
             free_memory(line);
 rem_temp_file:
@@ -577,7 +577,7 @@ static bool open_dest_file(JCR *jcr, DEST *d, const char *mode)
       berrno be;
       d->fd = stdout;
       Qmsg2(jcr, M_ERROR, 0, _("fopen %s failed: ERR=%s\n"), d->where,
-            be.strerror());
+            be.bstrerror());
       d->fd = NULL;
       return false;
    }
@@ -704,7 +704,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                       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());
+                            "ERR=%s\n"), mcmd, be.bstrerror());
                    }
                 }
                 free_pool_memory(mcmd);
@@ -721,7 +721,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                       berrno be;
                       d->fd = stdout;
                       Qmsg2(jcr, M_ERROR, 0, _("fopen %s failed: ERR=%s\n"), name,
-                            be.strerror());
+                            be.bstrerror());
                       d->fd = NULL;
                       free_pool_memory(name);
                       break;
index 3626d6bc1f13119d46a7ac213de7b9c3ebb3861d..beacf41bbd929ed9c521439fa661d60d78ddfca5 100644 (file)
@@ -103,7 +103,8 @@ static struct CRYPTO_dynlock_value *openssl_create_dynamic_mutex (const char *fi
    dynlock = (struct CRYPTO_dynlock_value *) malloc(sizeof(struct CRYPTO_dynlock_value));
 
    if ((stat = pthread_mutex_init(&dynlock->mutex, NULL)) != 0) {
-      Emsg1(M_ABORT, 0, _("Unable to init mutex: ERR=%s\n"), strerror(stat));
+      berrno be;
+      Emsg1(M_ABORT, 0, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(stat));
    }
 
    return dynlock;
@@ -123,7 +124,8 @@ static void openssl_destroy_dynamic_mutex (struct CRYPTO_dynlock_value *dynlock,
    int stat;
 
    if ((stat = pthread_mutex_destroy(&dynlock->mutex)) != 0) {
-      Emsg1(M_ABORT, 0, _("Unable to destroy mutex: ERR=%s\n"), strerror(stat));
+      berrno be;
+      Emsg1(M_ABORT, 0, _("Unable to destroy mutex: ERR=%s\n"), be.bstrerror(stat));
    }
 
    free(dynlock);
@@ -160,7 +162,8 @@ int openssl_init_threads (void)
    mutexes = (pthread_mutex_t *) malloc(numlocks * sizeof(pthread_mutex_t));
    for (i = 0; i < numlocks; i++) {
       if ((stat = pthread_mutex_init(&mutexes[i], NULL)) != 0) {
-         Emsg1(M_ERROR, 0, _("Unable to init mutex: ERR=%s\n"), strerror(stat));
+         berrno be;
+         Emsg1(M_ERROR, 0, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(stat));
          return stat;
       }
    }
@@ -179,7 +182,7 @@ int openssl_init_threads (void)
 /*
  * Clean up OpenSSL threading support
  */
-void openssl_cleanup_threads (void)
+void openssl_cleanup_threads(void)
 {
    int i, numlocks;
    int stat;
@@ -191,8 +194,9 @@ void openssl_cleanup_threads (void)
    numlocks = CRYPTO_num_locks();
    for (i = 0; i < numlocks; i++) {
       if ((stat = pthread_mutex_destroy(&mutexes[i])) != 0) {
+         berrno be;
          /* We don't halt execution, reporting the error should be sufficient */
-         Emsg1(M_ERROR, 0, _("Unable to destroy mutex: ERR=%s\n"), strerror(stat));
+         Emsg1(M_ERROR, 0, _("Unable to destroy mutex: ERR=%s\n"), be.bstrerror(stat));
       }
    }
 
index cacb71d6c2919d3a681c00c1df544f60ffc7e81d..96f6d8adc9c1a4c4c3db730437c7d6a7ba2d0a87 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-20076 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -196,8 +196,9 @@ void init_resource(int type, RES_ITEM *items, int pass)
    int errstat;
 
    if (first && (errstat=rwl_init(&res_lock)) != 0) {
+      berrno be;
       Emsg1(M_ABORT, 0, _("Unable to initialize resource lock. ERR=%s\n"),
-            strerror(errstat));
+            be.bstrerror(errstat));
    }
    first = false;
 
@@ -816,7 +817,7 @@ parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type)
          bstrncpy(lc->str, cf, sizeof(lc->str));
          lc->fname = lc->str;
          scan_err2(lc, _("Cannot open config file \"%s\": %s\n"),
-            lc->str, be.strerror());
+            lc->str, be.bstrerror());
          free(lc);
          return 0;
       }
index c2a458a5c7b6854b58cf7ef64d5835f6628c3cf2..199a514fd067964b6771ee8f4b92a8da0336f303 100644 (file)
@@ -1,16 +1,7 @@
-/*
- *
- * Bacula common code library interface to Python
- *
- * Kern Sibbald, November MMIV
- *
- *   Version $Id$
- *
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2004-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *
+ * Bacula common code library interface to Python
+ *
+ * Kern Sibbald, November MMIV
+ *
+ *   Version $Id$
+ *
+ */
 
 #include "bacula.h"
 #include "jcr.h"
@@ -327,7 +327,7 @@ static void init_python_lock()
    if ((errstat=rwl_init(&python_rwlock)) != 0) {
       berrno be;
       Emsg1(M_ABORT, 0, _("Unable to initialize the Python lock. ERR=%s\n"),
-            be.strerror(errstat));
+            be.bstrerror(errstat));
    }
 
 }
@@ -344,7 +344,7 @@ void lock_python()
    if ((errstat=rwl_writelock(&python_rwlock)) != 0) {
       berrno be;
       Emsg2(M_ABORT, 0, "Python rwl_writelock failure. stat=%d: ERR=%s\n",
-           errstat, be.strerror(errstat));
+           errstat, be.bstrerror(errstat));
    }
 }
 
@@ -354,7 +354,7 @@ void unlock_python()
    if ((errstat=rwl_writeunlock(&python_rwlock)) != 0) {
       berrno be;
       Emsg2(M_ABORT, 0, "Python rwl_writeunlock failure. stat=%d: ERR=%s\n",
-           errstat, be.strerror(errstat));
+           errstat, be.bstrerror(errstat));
    }
 }
 
index 871de9ebbf92529926843dafda9851efe23b9370..300b8a7b68f1d6394a92c7aede8bfee8fc358a1b 100644 (file)
@@ -1,15 +1,7 @@
-/*
- * Manipulation routines for RunScript list
- *
- *  Eric Bollengier, May 2006
- *
- *  Version $Id$
- *
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2006-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * Manipulation routines for RunScript list
+ *
+ *  Eric Bollengier, May 2006
+ *
+ *  Version $Id$
+ *
+ */
 
 
 #include "bacula.h"
@@ -123,32 +123,32 @@ int run_scripts(JCR *jcr, alist *runscripts, const char *label)
       runit=false;
 
       if ((script->when & SCRIPT_Before) && (when & SCRIPT_Before)) {
-        if (  (script->on_success && (jcr->JobStatus == JS_Running || jcr->JobStatus == JS_Created))
-              ||
-              (script->on_failure && job_canceled(jcr))
-           )
-        {
-           Dmsg4(200, "runscript: Run it because SCRIPT_Before (%s,%i,%i,%c)\n", script->command,
+         if (  (script->on_success && (jcr->JobStatus == JS_Running || jcr->JobStatus == JS_Created))
+               ||
+               (script->on_failure && job_canceled(jcr))
+            )
+         {
+            Dmsg4(200, "runscript: Run it because SCRIPT_Before (%s,%i,%i,%c)\n", script->command,
                                                                                   script->on_success,
                                                                                   script->on_failure,
                                                                                   jcr->JobStatus );
 
-           runit = true;
-        }
+            runit = true;
+         }
       }
 
       if ((script->when & SCRIPT_After) && (when & SCRIPT_After)) {
-        if (  (script->on_success && (jcr->JobStatus == JS_Terminated))
-              ||
-              (script->on_failure && job_canceled(jcr))
-           )
-        {
-           Dmsg4(200, "runscript: Run it because SCRIPT_After (%s,%i,%i,%c)\n", script->command,
+         if (  (script->on_success && (jcr->JobStatus == JS_Terminated))
+               ||
+               (script->on_failure && job_canceled(jcr))
+            )
+         {
+            Dmsg4(200, "runscript: Run it because SCRIPT_After (%s,%i,%i,%c)\n", script->command,
                                                                                  script->on_success,
                                                                                  script->on_failure,
                                                                                  jcr->JobStatus );
-           runit = true;
-        }
+            runit = true;
+         }
       }
 
       if (!script->is_local()) {
@@ -230,7 +230,7 @@ int RUNSCRIPT::run(JCR *jcr, const char *name)
    if (bpipe == NULL) {
       berrno be;
       Jmsg(jcr, M_ERROR, 0, _("Runscript: %s could not execute. ERR=%s\n"), name,
-         be.strerror());
+         be.bstrerror());
       return false;
    }
    while (fgets(line, sizeof(line), bpipe->rfd)) {
@@ -244,7 +244,7 @@ int RUNSCRIPT::run(JCR *jcr, const char *name)
    if (status != 0) {
       berrno be;
       Jmsg(jcr, M_ERROR, 0, _("Runscript: %s returned non-zero status=%d. ERR=%s\n"), name,
-         be.code(status), be.strerror(status));
+         be.code(status), be.bstrerror(status));
       return false;
    }
    return true;
index c2cd3e5c69085090402974891ea3093322a33b6b..3654708d80812e14c0b361da8006982e7c7c1785 100644 (file)
@@ -1,21 +1,7 @@
-/*
- * Bacula Thread Read/Write locking code. It permits
- *  multiple readers but only one writer.  Note, however,
- *  that the writer thread is permitted to make multiple
- *  nested write lock calls.
- *
- *  Kern Sibbald, January MMI
- *
- *   Version $Id$
- *
- *  This code adapted from "Programming with POSIX Threads", by
- *    David R. Butenhof
- *
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * Bacula Thread Read/Write locking code. It permits
+ *  multiple readers but only one writer.  Note, however,
+ *  that the writer thread is permitted to make multiple
+ *  nested write lock calls.
+ *
+ *  Kern Sibbald, January MMI
+ *
+ *   Version $Id$
+ *
+ *  This code adapted from "Programming with POSIX Threads", by
+ *    David R. Butenhof
+ *
+ */
 
 #include "bacula.h"
 
@@ -363,14 +363,16 @@ 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));
+            berrno be;
+            Emsg1(M_ABORT, 0, _("Write lock failed. ERR=%s\n"), be.bstrerror(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));
+            berrno be;
+            Emsg1(M_ABORT, 0, _("Write unlock failed. ERR=%s\n"), be.bstrerror(status));
          }
       } else {
          /*
@@ -380,14 +382,16 @@ 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));
+             berrno be;
+             Emsg1(M_ABORT, 0, _("Read lock failed. ERR=%s\n"), be.bstrerror(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));
+             berrno be;
+             Emsg1(M_ABORT, 0, _("Read unlock failed. ERR=%s\n"), be.bstrerror(status));
           }
       }
       element++;
@@ -428,7 +432,8 @@ 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));
+           berrno be;
+           Emsg1(M_ABORT, 0, _("Init rwlock failed. ERR=%s\n"), be.bstrerror(status));
         }
     }
 
@@ -443,7 +448,8 @@ 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));
+           berrno be;
+           Emsg1(M_ABORT, 0, _("Create thread failed. ERR=%s\n"), be.bstrerror(status));
         }
     }
 
@@ -454,7 +460,8 @@ 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));
+           berrno be;
+           Emsg1(M_ABORT, 0, _("Join thread failed. ERR=%s\n"), be.bstrerror(status));
         }
         thread_writes += threads[count].writes;
         printf (_("%02d: interval %d, writes %d, reads %d\n"),
index 063fad0e9436f5c18fc843dbc28668ed11045595..9fd9e40e2b150e42f73c2ec04695efacf85f746a 100644 (file)
@@ -2,30 +2,30 @@
  *  sha1.c
  *
  *  Description:
- *     This file implements the Secure Hashing Algorithm 1 as
- *     defined in FIPS PUB 180-1 published April 17, 1995.
+ *      This file implements the Secure Hashing Algorithm 1 as
+ *      defined in FIPS PUB 180-1 published April 17, 1995.
  *
- *     The SHA-1, produces a 160-bit message digest for a given
- *     data stream.  It should take about 2**n steps to find a
- *     message with the same digest as a given message and
- *     2**(n/2) to find any two messages with the same digest,
- *     when n is the digest size in bits.  Therefore, this
- *     algorithm can serve as a means of providing a
+ *      The SHA-1, produces a 160-bit message digest for a given
+ *      data stream.  It should take about 2**n steps to find a
+ *      message with the same digest as a given message and
+ *      2**(n/2) to find any two messages with the same digest,
+ *      when n is the digest size in bits.  Therefore, this
+ *      algorithm can serve as a means of providing a
  *      "fingerprint" for a message.
  *
  *  Portability Issues:
  *      SHA-1 is defined in terms of 32-bit "words".  This code
  *      uses <stdint.h> (included via "sha1.h" to define 32 and 8
- *     bit unsigned integer types.  If your C compiler does not
- *     support 32 bit unsigned integers, this code is not
- *     appropriate.
+ *      bit unsigned integer types.  If your C compiler does not
+ *      support 32 bit unsigned integers, this code is not
+ *      appropriate.
  *
  *  Caveats:
- *     SHA-1 is designed to work with messages less than 2^64 bits
- *     long.  Although SHA-1 allows a message digest to be generated
- *     for messages of any number of bits less than 2^64, this
- *     implementation only works with messages with a length that is
- *     a multiple of the size of an 8-bit character.
+ *      SHA-1 is designed to work with messages less than 2^64 bits
+ *      long.  Although SHA-1 allows a message digest to be generated
+ *      for messages of any number of bits less than 2^64, this
+ *      implementation only works with messages with a length that is
+ *      a multiple of the size of an 8-bit character.
  *
  *  See sha1.h for copyright
  */
@@ -36,7 +36,7 @@
  *  Define the SHA1 circular left shift macro
  */
 #define SHA1CircularShift(bits,word) \
-               (((word) << (bits)) | ((word) >> (32-(bits))))
+                (((word) << (bits)) | ((word) >> (32-(bits))))
 
 /* Local Function Prototyptes */
 static void SHA1PadMessage(SHA1Context *);
@@ -46,26 +46,26 @@ static void SHA1ProcessMessageBlock(SHA1Context *);
  *  SHA1Init
  *
  *  Description:
- *     This function will initialize the SHA1Context in preparation
- *     for computing a new SHA1 message digest.
+ *      This function will initialize the SHA1Context in preparation
+ *      for computing a new SHA1 message digest.
  *
  *  Parameters:
- *     context: [in/out]
- *         The context to reset.
+ *      context: [in/out]
+ *          The context to reset.
  *
  *  Returns:
- *     sha Error Code.
+ *      sha Error Code.
  *
  */
 int SHA1Init(SHA1Context *context)
 {
     if (!context)
     {
-       return shaNull;
+        return shaNull;
     }
 
-    context->Length_Low            = 0;
-    context->Length_High           = 0;
+    context->Length_Low             = 0;
+    context->Length_High            = 0;
     context->Message_Block_Index    = 0;
 
     context->Intermediate_Hash[0]   = 0x67452301;
@@ -74,8 +74,8 @@ int SHA1Init(SHA1Context *context)
     context->Intermediate_Hash[3]   = 0x10325476;
     context->Intermediate_Hash[4]   = 0xC3D2E1F0;
 
-    context->Computed  = 0;
-    context->Corrupted = 0;
+    context->Computed   = 0;
+    context->Corrupted  = 0;
 
     return shaSuccess;
 }
@@ -84,49 +84,49 @@ int SHA1Init(SHA1Context *context)
  *  SHA1Final
  *
  *  Description:
- *     This function will return the 160-bit message digest into the
- *     Message_Digest array  provided by the caller.
- *     NOTE: The first octet of hash is stored in the 0th element,
- *           the last octet of hash in the 19th element.
+ *      This function will return the 160-bit message digest into the
+ *      Message_Digest array  provided by the caller.
+ *      NOTE: The first octet of hash is stored in the 0th element,
+ *            the last octet of hash in the 19th element.
  *
  *  Parameters:
- *     context: [in/out]
- *         The context to use to calculate the SHA-1 hash.
- *     Message_Digest: [out]
- *         Where the digest is returned.
+ *      context: [in/out]
+ *          The context to use to calculate the SHA-1 hash.
+ *      Message_Digest: [out]
+ *          Where the digest is returned.
  *
  *  Returns:
- *     sha Error Code.
+ *      sha Error Code.
  *
  */
 int SHA1Final(SHA1Context *context,
-             uint8_t Message_Digest[SHA1HashSize])
+              uint8_t Message_Digest[SHA1HashSize])
 {
     int i;
 
     if (!context || !Message_Digest) {
-       return shaNull;
+        return shaNull;
     }
 
     if (context->Corrupted) {
-       return context->Corrupted;
+        return context->Corrupted;
     }
 
     if (!context->Computed) {
-       SHA1PadMessage(context);
-       for(i=0; i<64; ++i) {
-           /* message may be sensitive, clear it out */
-           context->Message_Block[i] = 0;
-       }
-       context->Length_Low = 0;    /* and clear length */
-       context->Length_High = 0;
-       context->Computed = 1;
+        SHA1PadMessage(context);
+        for(i=0; i<64; ++i) {
+            /* message may be sensitive, clear it out */
+            context->Message_Block[i] = 0;
+        }
+        context->Length_Low = 0;    /* and clear length */
+        context->Length_High = 0;
+        context->Computed = 1;
 
     }
 
     for(i = 0; i < SHA1HashSize; ++i) {
-       Message_Digest[i] = context->Intermediate_Hash[i>>2]
-                           >> 8 * ( 3 - ( i & 0x03 ) );
+        Message_Digest[i] = context->Intermediate_Hash[i>>2]
+                            >> 8 * ( 3 - ( i & 0x03 ) );
     }
 
     return shaSuccess;
@@ -136,58 +136,58 @@ int SHA1Final(SHA1Context *context,
  *  SHA1Update
  *
  *  Description:
- *     This function accepts an array of octets as the next portion
- *     of the message.
+ *      This function accepts an array of octets as the next portion
+ *      of the message.
  *
  *  Parameters:
- *     context: [in/out]
- *         The SHA context to update
- *     message_array: [in]
- *         An array of characters representing the next portion of
- *         the message.
- *     length: [in]
- *         The length of the message in message_array
+ *      context: [in/out]
+ *          The SHA context to update
+ *      message_array: [in]
+ *          An array of characters representing the next portion of
+ *          the message.
+ *      length: [in]
+ *          The length of the message in message_array
  *
  *  Returns:
- *     sha Error Code.
+ *      sha Error Code.
  *
  */
 int SHA1Update(SHA1Context    *context,
-              const uint8_t  *message_array,
-              unsigned       length)
+               const uint8_t  *message_array,
+               unsigned       length)
 {
     if (!length) {
-       return shaSuccess;
+        return shaSuccess;
     }
 
     if (!context || !message_array) {
-       return shaNull;
+        return shaNull;
     }
 
     if (context->Computed) {
-       context->Corrupted = shaStateError;
+        context->Corrupted = shaStateError;
 
-       return shaStateError;
+        return shaStateError;
     }
 
     if (context->Corrupted) {
-        return context->Corrupted;
+         return context->Corrupted;
     }
     while(length-- && !context->Corrupted) {
        context->Message_Block[context->Message_Block_Index++] =
-                   (*message_array & 0xFF);
+                    (*message_array & 0xFF);
 
        context->Length_Low += 8;
        if (context->Length_Low == 0) {
-          context->Length_High++;
-          if (context->Length_High == 0) {
-              /* Message is too long */
-              context->Corrupted = 1;
-          }
+           context->Length_High++;
+           if (context->Length_High == 0) {
+               /* Message is too long */
+               context->Corrupted = 1;
+           }
        }
 
        if (context->Message_Block_Index == 64) {
-          SHA1ProcessMessageBlock(context);
+           SHA1ProcessMessageBlock(context);
        }
 
        message_array++;
@@ -200,44 +200,44 @@ int SHA1Update(SHA1Context    *context,
  *  SHA1ProcessMessageBlock
  *
  *  Description:
- *     This function will process the next 512 bits of the message
- *     stored in the Message_Block array.
+ *      This function will process the next 512 bits of the message
+ *      stored in the Message_Block array.
  *
  *  Parameters:
- *     None.
+ *      None.
  *
  *  Returns:
- *     Nothing.
+ *      Nothing.
  *
  *  Comments:
 
- *     Many of the variable names in this code, especially the
- *     single character names, were used because those were the
- *     names used in the publication.
+ *      Many of the variable names in this code, especially the
+ *      single character names, were used because those were the
+ *      names used in the publication.
  *
  *
  */
 static void SHA1ProcessMessageBlock(SHA1Context *context)
 {
-    const uint32_t K[] =    {      /* Constants defined in SHA-1   */
-                           0x5A827999,
-                           0x6ED9EBA1,
-                           0x8F1BBCDC,
-                           0xCA62C1D6
-                           };
-    int          t;                 /* Loop counter                */
-    uint32_t     temp;              /* Temporary word value        */
-    uint32_t     W[80];             /* Word sequence               */
-    uint32_t     A, B, C, D, E;     /* Word buffers                */
+    const uint32_t K[] =    {       /* Constants defined in SHA-1   */
+                            0x5A827999,
+                            0x6ED9EBA1,
+                            0x8F1BBCDC,
+                            0xCA62C1D6
+                            };
+    int           t;                 /* Loop counter                */
+    uint32_t      temp;              /* Temporary word value        */
+    uint32_t      W[80];             /* Word sequence               */
+    uint32_t      A, B, C, D, E;     /* Word buffers                */
 
     /*
-     * Initialize the first 16 words in the array W
+     *  Initialize the first 16 words in the array W
      */
     for(t = 0; t < 16; t++) {
-       W[t] = context->Message_Block[t * 4] << 24;
-       W[t] |= context->Message_Block[t * 4 + 1] << 16;
-       W[t] |= context->Message_Block[t * 4 + 2] << 8;
-       W[t] |= context->Message_Block[t * 4 + 3];
+        W[t] = context->Message_Block[t * 4] << 24;
+        W[t] |= context->Message_Block[t * 4 + 1] << 16;
+        W[t] |= context->Message_Block[t * 4 + 2] << 8;
+        W[t] |= context->Message_Block[t * 4 + 3];
     }
 
     for(t = 16; t < 80; t++) {
@@ -251,42 +251,42 @@ static void SHA1ProcessMessageBlock(SHA1Context *context)
     E = context->Intermediate_Hash[4];
 
     for(t = 0; t < 20; t++) {
-       temp =  SHA1CircularShift(5,A) +
-               ((B & C) | ((~B) & D)) + E + W[t] + K[0];
-       E = D;
-       D = C;
-       C = SHA1CircularShift(30,B);
-
-       B = A;
-       A = temp;
+        temp =  SHA1CircularShift(5,A) +
+                ((B & C) | ((~B) & D)) + E + W[t] + K[0];
+        E = D;
+        D = C;
+        C = SHA1CircularShift(30,B);
+
+        B = A;
+        A = temp;
     }
 
     for(t = 20; t < 40; t++) {
-       temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
-       E = D;
-       D = C;
-       C = SHA1CircularShift(30,B);
-       B = A;
-       A = temp;
+        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
+        E = D;
+        D = C;
+        C = SHA1CircularShift(30,B);
+        B = A;
+        A = temp;
     }
 
     for(t = 40; t < 60; t++) {
-       temp = SHA1CircularShift(5,A) +
-              ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
-       E = D;
-       D = C;
-       C = SHA1CircularShift(30,B);
-       B = A;
-       A = temp;
+        temp = SHA1CircularShift(5,A) +
+               ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
+        E = D;
+        D = C;
+        C = SHA1CircularShift(30,B);
+        B = A;
+        A = temp;
     }
 
     for(t = 60; t < 80; t++) {
-       temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
-       E = D;
-       D = C;
-       C = SHA1CircularShift(30,B);
-       B = A;
-       A = temp;
+        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
+        E = D;
+        D = C;
+        C = SHA1CircularShift(30,B);
+        B = A;
+        A = temp;
     }
 
     context->Intermediate_Hash[0] += A;
@@ -303,54 +303,54 @@ static void SHA1ProcessMessageBlock(SHA1Context *context)
  *
 
  *  Description:
- *     According to the standard, the message must be padded to an even
+ *      According to the standard, the message must be padded to an even
  *      512 bits.  The first padding bit must be a '1'.  The last 64
- *     bits represent the length of the original message.  All bits in
- *     between should be 0.  This function will pad the message
- *     according to those rules by filling the Message_Block array
- *     accordingly.  It will also call the ProcessMessageBlock function
- *     provided appropriately.  When it returns, it can be assumed that
- *     the message digest has been computed.
+ *      bits represent the length of the original message.  All bits in
+ *      between should be 0.  This function will pad the message
+ *      according to those rules by filling the Message_Block array
+ *      accordingly.  It will also call the ProcessMessageBlock function
+ *      provided appropriately.  When it returns, it can be assumed that
+ *      the message digest has been computed.
  *
  *  Parameters:
- *     context: [in/out]
- *         The context to pad
- *     ProcessMessageBlock: [in]
- *         The appropriate SHA*ProcessMessageBlock function
+ *      context: [in/out]
+ *          The context to pad
+ *      ProcessMessageBlock: [in]
+ *          The appropriate SHA*ProcessMessageBlock function
  *  Returns:
- *     Nothing.
+ *      Nothing.
  *
  */
 
 static void SHA1PadMessage(SHA1Context *context)
 {
     /*
-     * Check to see if the current message block is too small to hold
-     * the initial padding bits and length.  If so, we will pad the
-     * block, process it, and then continue padding into a second
-     * block.
+     *  Check to see if the current message block is too small to hold
+     *  the initial padding bits and length.  If so, we will pad the
+     *  block, process it, and then continue padding into a second
+     *  block.
      */
     if (context->Message_Block_Index > 55) {
-       context->Message_Block[context->Message_Block_Index++] = 0x80;
-       while(context->Message_Block_Index < 64) {
-           context->Message_Block[context->Message_Block_Index++] = 0;
-       }
+        context->Message_Block[context->Message_Block_Index++] = 0x80;
+        while(context->Message_Block_Index < 64) {
+            context->Message_Block[context->Message_Block_Index++] = 0;
+        }
 
-       SHA1ProcessMessageBlock(context);
+        SHA1ProcessMessageBlock(context);
 
-       while(context->Message_Block_Index < 56) {
-           context->Message_Block[context->Message_Block_Index++] = 0;
-       }
+        while(context->Message_Block_Index < 56) {
+            context->Message_Block[context->Message_Block_Index++] = 0;
+        }
     } else {
-       context->Message_Block[context->Message_Block_Index++] = 0x80;
-       while(context->Message_Block_Index < 56) {
+        context->Message_Block[context->Message_Block_Index++] = 0x80;
+        while(context->Message_Block_Index < 56) {
 
-           context->Message_Block[context->Message_Block_Index++] = 0;
-       }
+            context->Message_Block[context->Message_Block_Index++] = 0;
+        }
     }
 
     /*
-     * Store the message length as the last 8 octets
+     *  Store the message length as the last 8 octets
      */
     context->Message_Block[56] = context->Length_High >> 24;
     context->Message_Block[57] = context->Length_High >> 16;
@@ -370,13 +370,13 @@ static void SHA1PadMessage(SHA1Context *context)
  *  sha1test.c
  *
  *  Description:
- *     This file will exercise the SHA-1 code performing the three
- *     tests documented in FIPS PUB 180-1 plus one which calls
- *     SHA1Input with an exact multiple of 512 bits, plus a few
- *     error test checks.
+ *      This file will exercise the SHA-1 code performing the three
+ *      tests documented in FIPS PUB 180-1 plus one which calls
+ *      SHA1Input with an exact multiple of 512 bits, plus a few
+ *      error test checks.
  *
  *  Portability Issues:
- *     None.
+ *      None.
  *
  */
 
@@ -392,12 +392,12 @@ static void SHA1PadMessage(SHA1Context *context)
 #define TEST2a  "abcdbcdecdefdefgefghfghighijhi"
 
 #define TEST2b  "jkijkljklmklmnlmnomnopnopq"
-#define TEST2  TEST2a TEST2b
+#define TEST2   TEST2a TEST2b
 #define TEST3   "a"
 #define TEST4a  "01234567012345670123456701234567"
 #define TEST4b  "01234567012345670123456701234567"
     /* an exact multiple of 512 bits */
-#define TEST4  TEST4a TEST4b
+#define TEST4   TEST4a TEST4b
 char *testarray[4] =
 {
     TEST1,
@@ -421,47 +421,47 @@ int main()
     uint8_t Message_Digest[20];
 
     /*
-     * Perform SHA-1 tests
+     *  Perform SHA-1 tests
      */
     for(j = 0; j < 4; ++j) {
-       printf( "\nTest %d: %d, '%s'\n",
-               j+1,
-               repeatcount[j],
-               testarray[j]);
-
-       err = SHA1Init(&sha);
-       if (err) {
-           fprintf(stderr, "SHA1Reset Error %d.\n", err );
-           break;    /* out of for j loop */
-       }
-
-       for(i = 0; i < repeatcount[j]; ++i) {
-
-           err = SHA1Input(&sha,
-                 (const unsigned char *) testarray[j],
-                 strlen(testarray[j]));
-           if (err) {
-               fprintf(stderr, "SHA1Input Error %d.\n", err );
-               break;    /* out of for i loop */
-           }
-       }
-
-       err = SHA1Final(&sha, Message_Digest);
-       if (err) {
-           fprintf(stderr,
-           "SHA1Result Error %d, could not compute message digest.\n",
-           err );
-       }
-       else
-       {
-           printf("\t");
-           for(i = 0; i < 20 ; ++i) {
-               printf("%02X ", Message_Digest[i]);
-           }
-           printf("\n");
-       }
-       printf("Should match:\n");
-       printf("\t%s\n", resultarray[j]);
+        printf( "\nTest %d: %d, '%s'\n",
+                j+1,
+                repeatcount[j],
+                testarray[j]);
+
+        err = SHA1Init(&sha);
+        if (err) {
+            fprintf(stderr, "SHA1Reset Error %d.\n", err );
+            break;    /* out of for j loop */
+        }
+
+        for(i = 0; i < repeatcount[j]; ++i) {
+
+            err = SHA1Input(&sha,
+                  (const unsigned char *) testarray[j],
+                  strlen(testarray[j]));
+            if (err) {
+                fprintf(stderr, "SHA1Input Error %d.\n", err );
+                break;    /* out of for i loop */
+            }
+        }
+
+        err = SHA1Final(&sha, Message_Digest);
+        if (err) {
+            fprintf(stderr,
+            "SHA1Result Error %d, could not compute message digest.\n",
+            err );
+        }
+        else
+        {
+            printf("\t");
+            for(i = 0; i < 20 ; ++i) {
+                printf("%02X ", Message_Digest[i]);
+            }
+            printf("\n");
+        }
+        printf("Should match:\n");
+        printf("\t%s\n", resultarray[j]);
     }
 
     /* Test some error returns */
@@ -492,7 +492,8 @@ int main(int argc, char *argv[])
    }
    fd = fopen(argv[1], "rb");
    if (!fd) {
-      printf("Could not open %s: ERR=%s\n", argv[1], strerror(errno));
+      berrno be;
+      printf("Could not open %s: ERR=%s\n", argv[1], be.bstrerror(errno));
       exit(1);
    }
    SHA1Init(&ctx);
index 4e80e5241a4af70f1c98ad34310b090fe1cdc516..68442ddc233e8701a9eff586479f47e9cdd3f37c 100644 (file)
@@ -1,22 +1,7 @@
-/*
- *  Signal handlers for Bacula daemons
- *
- *   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"
- * routine, we leave it to the individual daemons to
- * tweek their signals after calling this routine.
- *
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *  Signal handlers for Bacula daemons
+ *
+ *   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"
+ * routine, we leave it to the individual daemons to
+ * tweek their signals after calling this routine.
+ *
+ */
 
 #ifndef HAVE_WIN32
 #include "bacula.h"
@@ -130,7 +130,7 @@ extern "C" void signal_handler(int sig)
       }
       if (chdir(working_directory) != 0) {  /* dump in working directory */
          berrno be;
-         Pmsg2(000, "chdir to %s failed. ERR=%s\n", working_directory,  be.strerror());
+         Pmsg2(000, "chdir to %s failed. ERR=%s\n", working_directory,  be.bstrerror());
          strcpy((char *)working_directory, "/tmp/");
       }
       unlink("./core");               /* get rid of any old core file */
index 74f5f6a8e91b760a9ded6759c2be103abdd67580..c9c1a0e1c579807e86512f350ed1ef8181ceb4b8 100644 (file)
@@ -1,9 +1,3 @@
-/*
- * Directory tree build/traverse routines
- *
- *    Kern Sibbald, June MMII
- *
-*/
 /*
    Bacula® - The Network Backup Solution
 
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * Directory tree build/traverse routines
+ *
+ *    Kern Sibbald, June MMII
+ *
+*/
 
 
 #include "bacula.h"
@@ -485,7 +485,8 @@ 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));
+         berrno be;
+         printf("lstat() failed. ERR=%s\n", be.bstrerror(errno));
          continue;
       }
 //      printf("got file=%s, pathbuf=%s\n", file, pathbuf);
index bcc41fbd4a73e7764ef6a06c2c7b4f65875e19c5..2e5a1bb11ad5347cbb58781ffc25071301946f0b 100644 (file)
@@ -79,8 +79,9 @@ int start_watchdog(void)
    watchdog_time = time(NULL);
 
    if ((errstat=rwl_init(&lock)) != 0) {
+      berrno be;
       Emsg1(M_ABORT, 0, _("Unable to initialize watchdog lock. ERR=%s\n"),
-            strerror(errstat));
+            be.bstrerror(errstat));
    }
    wd_queue = New(dlist(dummy, &dummy->link));
    wd_inactive = New(dlist(dummy, &dummy->link));
@@ -320,8 +321,9 @@ static void wd_lock()
 {
    int errstat;
    if ((errstat=rwl_writelock(&lock)) != 0) {
+      berrno be;
       Emsg1(M_ABORT, 0, _("rwl_writelock failure. ERR=%s\n"),
-           strerror(errstat));
+           be.bstrerror(errstat));
    }
 }
 
@@ -334,7 +336,8 @@ static void wd_unlock()
 {
    int errstat;
    if ((errstat=rwl_writeunlock(&lock)) != 0) {
+      berrno be;
       Emsg1(M_ABORT, 0, _("rwl_writeunlock failure. ERR=%s\n"),
-           strerror(errstat));
+           be.bstrerror(errstat));
    }
 }
index d28f9adeb0557fc956fea60986487e8f5519eda7..fbf880b2f152069e9711d86ccb63b004676552b6 100644 (file)
  *
  *  Initialize queue
  *  if ((stat = workq_init(&job_wq, max_workers, job_thread)) != 0) {
- *     Emsg1(M_ABORT, 0, "Could not init job work queue: ERR=%s\n", strerror(errno));
+ *     berrno be;
+ *     Emsg1(M_ABORT, 0, "Could not init job work queue: ERR=%s\n", be.bstrerror(errno));
  *   }
  *
  *  Add an item to the queue
  *  if ((stat = workq_add(&job_wq, (void *)jcr)) != 0) {
- *      Emsg1(M_ABORT, 0, "Could not add job to work queue: ERR=%s\n", strerror(errno));
+ *      berrno be;
+ *      Emsg1(M_ABORT, 0, "Could not add job to work queue: ERR=%s\n", be.bstrerror(errno));
  *   }
  *
  *  Terminate the queue
index 7dc9356f238ba79fe752da0c505aaedc14154e36..6fafdc1755d2a0db52aa10681fb04a508b18ab61 100644 (file)
@@ -3,9 +3,9 @@
  */
 
 #undef  VERSION
-#define VERSION "2.1.10"
-#define BDATE   "18 May 2007"
-#define LSMDATE "18May07"
+#define VERSION "2.1.11"
+#define BDATE   "20 May 2007"
+#define LSMDATE "20May07"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2007"       /* year for copyright messages in progs */
index 53dd863cbb53cdb12ce1e246bcbdc2fedbdecc0a..4d6dc1ed60546ca2f0ecda0e318a58812ced8038 100644 (file)
@@ -1,6 +1,10 @@
               Technical notes on version 2.1
 
 General:
+20May07
+kes  Fix tray-monitor by not requiring a timer interval in bnet_connect()
+kes  Complete change of berrno strerror() method to bstrerror() 
+Release: 2.1.10 beta
 18May07
 kes  Cleanup incorrect email addresses in bsmtp.
 kes  Make bat display initial messages rather than discard them.