]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/message.c
Tweak Win32 build
[bacula/bacula] / bacula / src / lib / message.c
index 514d8860bba36bd1bdd16a672d9160fb913cc368..724015463e3ff9b59ea76dd971d7c7e2d5272a41 100755 (executable)
@@ -11,7 +11,7 @@
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
-   version 2 as ammended with additional clauses defined in the
+   version 2 as amended with additional clauses defined in the
    file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
@@ -192,13 +192,12 @@ init_msg(JCR *jcr, MSGS *msg)
    if (msg == NULL) {
       daemon_msgs = (MSGS *)malloc(sizeof(MSGS));
       memset(daemon_msgs, 0, sizeof(MSGS));
-      for (i=1; i<=M_MAX; i++) {
 #ifndef WIN32
+      for (i=1; i<=M_MAX; i++) {
          add_msg_dest(daemon_msgs, MD_STDOUT, i, NULL, NULL);
-#endif
-         add_msg_dest(daemon_msgs, MD_SYSLOG, i, NULL, NULL);
       }
-      Dmsg1(050, "Create daemon global message resource 0x%x\n", daemon_msgs);
+#endif
+      Dmsg1(050, "Create daemon global message resource %p\n", daemon_msgs);
       return;
    }
 
@@ -236,7 +235,7 @@ init_msg(JCR *jcr, MSGS *msg)
       daemon_msgs->dest_chain = temp_chain;
       memcpy(daemon_msgs->send_msg, msg->send_msg, sizeof(msg->send_msg));
    }
-   Dmsg2(250, "Copy message resource 0x%x to 0x%x\n", msg, temp_chain);
+   Dmsg2(250, "Copy message resource %p to %p\n", msg, temp_chain);
 
 }
 
@@ -290,7 +289,7 @@ void add_msg_dest(MSGS *msg, int dest_code, int msg_type, char *where, char *mai
    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(850, "Add to existing d=%x msgtype=%d destcode=%d where=%s\n",
+         Dmsg4(850, "Add to existing d=%p 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 */
@@ -310,7 +309,7 @@ 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(850, "add new d=%x msgtype=%d destcode=%d where=%s mailcmd=%s\n",
+   Dmsg5(850, "add new d=%p msgtype=%d destcode=%d where=%s mailcmd=%s\n",
           d, msg_type, dest_code, NPRT(where), NPRT(d->mail_cmd));
    msg->dest_chain = d;
 }
@@ -325,11 +324,11 @@ void rem_msg_dest(MSGS *msg, int dest_code, int msg_type, char *where)
    DEST *d;
 
    for (d=msg->dest_chain; d; d=d->next) {
-      Dmsg2(850, "Remove_msg_dest d=%x where=%s\n", d, NPRT(d->where));
+      Dmsg2(850, "Remove_msg_dest d=%p 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(850, "Found for remove d=%x msgtype=%d destcode=%d\n",
+         Dmsg3(850, "Found for remove d=%p msgtype=%d destcode=%d\n",
                d, msg_type, dest_code);
          clear_bit(msg_type, d->msg_types);
          Dmsg0(850, "Return rem_msg_dest\n");
@@ -345,10 +344,10 @@ void rem_msg_dest(MSGS *msg, int dest_code, int msg_type, char *where)
 static void make_unique_mail_filename(JCR *jcr, POOLMEM *&name, DEST *d)
 {
    if (jcr) {
-      Mmsg(name, "%s/%s.mail.%s.%d", working_directory, my_name,
+      Mmsg(name, "%s/%s.%s.%d.mail", working_directory, my_name,
                  jcr->Job, (int)(long)d);
    } else {
-      Mmsg(name, "%s/%s.mail.%s.%d", working_directory, my_name,
+      Mmsg(name, "%s/%s.%s.%d.mail", working_directory, my_name,
                  my_name, (int)(long)d);
    }
    Dmsg1(850, "mailname=%s\n", name);
@@ -370,13 +369,13 @@ 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());
    }
 
    /* If we had to use sendmail, add subject */
    if (!d->mail_cmd) {
-       fprintf(bpipe->wfd, "Subject: Bacula Message\r\n\r\n");
+       fprintf(bpipe->wfd, "Subject: %s\r\n\r\n", _("Bacula Message"));
    }
 
    return bpipe;
@@ -394,7 +393,7 @@ void close_msg(JCR *jcr)
    POOLMEM *cmd, *line;
    int len, stat;
 
-   Dmsg1(850, "Close_msg jcr=0x%x\n", jcr);
+   Dmsg1(580, "Close_msg jcr=%p\n", jcr);
 
    if (jcr == NULL) {                /* NULL -> global chain */
       msgs = daemon_msgs;
@@ -406,7 +405,7 @@ void close_msg(JCR *jcr)
    if (msgs == NULL) {
       return;
    }
-   Dmsg1(850, "===Begin close msg resource at 0x%x\n", msgs);
+   Dmsg1(850, "===Begin close msg resource at %p\n", msgs);
    cmd = get_pool_memory(PM_MESSAGE);
    for (d=msgs->dest_chain; d; ) {
       if (d->fd) {
@@ -429,7 +428,7 @@ void close_msg(JCR *jcr)
             }
 
             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(850, "Opened mail pipe\n");
@@ -441,7 +440,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.strerror());
             }
 
             /*
@@ -613,16 +612,16 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                    Pw(con_lock);      /* get write lock on console message file */
                    errno = 0;
                    if (dtlen) {
-                      fwrite(dt, dtlen, 1, con_fd);
+                      (void)fwrite(dt, dtlen, 1, con_fd);
                    }
                    len = strlen(msg);
                    if (len > 0) {
-                      fwrite(msg, len, 1, con_fd);
+                      (void)fwrite(msg, len, 1, con_fd);
                       if (msg[len-1] != '\n') {
-                         fwrite("\n", 2, 1, con_fd);
+                         (void)fwrite("\n", 2, 1, con_fd);
                       }
                    } else {
-                      fwrite("\n", 2, 1, con_fd);
+                      (void)fwrite("\n", 2, 1, con_fd);
                    }
                    fflush(con_fd);
                    console_msg_pending = TRUE;
@@ -665,7 +664,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                    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);
@@ -687,7 +686,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                    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;
@@ -703,7 +702,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                    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;
@@ -931,30 +930,30 @@ e_msg(const char *file, int line, int type, int level, const char *fmt,...)
     }
     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);
+       len = bsnprintf(buf, sizeof(buf), _("%s: Warning: "), my_name);
        break;
     case M_SECURITY:
-       len = bsnprintf(buf, sizeof(buf), "%s: Security violation: ", my_name);
+       len = bsnprintf(buf, sizeof(buf), _("%s: Security violation: "), my_name);
        break;
     default:
        len = bsnprintf(buf, sizeof(buf), "%s: ", my_name);
@@ -1030,28 +1029,28 @@ Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
     }
     switch (type) {
     case M_ABORT:
-       len = bsnprintf(rbuf, sizeof(rbuf), "%s ABORTING due to ERROR\n", my_name);
+       len = bsnprintf(rbuf, sizeof(rbuf), _("%s ABORTING due to ERROR\n"), my_name);
        break;
     case M_ERROR_TERM:
-       len = bsnprintf(rbuf, sizeof(rbuf), "%s ERROR TERMINATION\n", my_name);
+       len = bsnprintf(rbuf, sizeof(rbuf), _("%s ERROR TERMINATION\n"), my_name);
        break;
     case M_FATAL:
-       len = bsnprintf(rbuf, sizeof(rbuf), "%s: %s Fatal error: ", my_name, job);
+       len = bsnprintf(rbuf, sizeof(rbuf), _("%s: %s Fatal error: "), my_name, job);
        if (jcr) {
           set_jcr_job_status(jcr, JS_FatalError);
        }
        break;
     case M_ERROR:
-       len = bsnprintf(rbuf, sizeof(rbuf), "%s: %s Error: ", my_name, job);
+       len = bsnprintf(rbuf, sizeof(rbuf), _("%s: %s Error: "), my_name, job);
        if (jcr) {
           jcr->Errors++;
        }
        break;
     case M_WARNING:
-       len = bsnprintf(rbuf, sizeof(rbuf), "%s: %s Warning: ", my_name, job);
+       len = bsnprintf(rbuf, sizeof(rbuf), _("%s: %s Warning: "), my_name, job);
        break;
     case M_SECURITY:
-       len = bsnprintf(rbuf, sizeof(rbuf), "%s: %s Security violation: ", my_name, job);
+       len = bsnprintf(rbuf, sizeof(rbuf), _("%s: %s Security violation: "), my_name, job);
        break;
     default:
        len = bsnprintf(rbuf, sizeof(rbuf), "%s: ", my_name);
@@ -1254,7 +1253,6 @@ void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
       P(msg_queue_mutex);
       jcr->msg_queue->append(item);
       V(msg_queue_mutex);
-//    Dmsg1(000, "queue item=%lu\n", (long unsigned)item);
    }
    free_memory(pool_buf);
 }
@@ -1268,7 +1266,6 @@ void dequeue_messages(JCR *jcr)
    P(msg_queue_mutex);
    jcr->dequeuing = true;
    foreach_dlist(item, jcr->msg_queue) {
-//    Dmsg1(000, "dequeue item=%lu\n", (long unsigned)item);
       Jmsg(jcr, item->type, item->mtime, "%s", item->msg);
    }
    jcr->msg_queue->destroy();