]> git.sur5r.net Git - bacula/bacula/commitdiff
- Several important commits from Robert Nelson for code cleanup and
authorKern Sibbald <kern@sibbald.com>
Thu, 27 Jul 2006 10:22:28 +0000 (10:22 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 27 Jul 2006 10:22:28 +0000 (10:22 +0000)
  Win32 build.
- Modify console.c so that when conio is enabled, it converts \n to
  \n\r before outputting to the console.  Hopefully this will fix
  the problems with expect in Perl that Eric saw.

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

bacula/kernstodo
bacula/kes-1.39
bacula/src/console/console.c
bacula/src/version.h

index 51d2a2c1028dbb63607c255ee48f2c1d80d184f5..a61bfa79aa1e2c8156fb35f9b58e9db8ab21af28 100644 (file)
@@ -29,6 +29,7 @@ Priority:
 
 For 1.39:
 - Remove queue.c code.
+- Add bconsole option to use stdin/out instead of conio.
 - Fix ClientRunBefore/AfterJob compatibility.
 - Fix re-read of last block to check if job has actually written
   a block, and check if block was written by a different job
@@ -1626,4 +1627,3 @@ Block Position: 0
 - Fix auth compatibility with 1.38
 - Update dbcheck to include Log table
 - Update llist to include new fields.
-
index d48a51b92adb2b26c0443ecfcaebccd0427f6f71..a9f995bff839a15be68ed30039adf88075d55f33 100644 (file)
@@ -2,6 +2,12 @@
                         Kern Sibbald
 
 General:
+27Jul06
+- Several important commits from Robert Nelson for code cleanup and
+  Win32 build.
+- Modify console.c so that when conio is enabled, it converts \n to
+  \n\r before outputting to the console.  Hopefully this will fix
+  the problems with expect in Perl that Eric saw.
 24Jul06
 - Change cats/sql.c to elimate %-*s format, which I think is turned
   off in bsnprintf.
index 8e1d32e0e8782340b12d8933a924432cecef4016..bd24519f05e91fb6505bc7563f32b0a97f6ab008 100644 (file)
 #include "console_conf.h"
 #include "jcr.h"
 
+
 #ifdef HAVE_CONIO
 #include "conio.h"
+#define CONIO_FIX 1
 #else
 #define con_init(x)
 #define con_term()
@@ -66,7 +68,7 @@ static char *configfile = NULL;
 static BSOCK *UA_sock = NULL;
 static DIRRES *dir;
 static FILE *output = stdout;
-static bool tee = false;                  /* output to output and stdout */
+static bool teeout = false;               /* output to output and stdout */
 static bool stop = false;
 static int argc;
 static int numdir;
@@ -704,7 +706,7 @@ get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
 {
    int len;
    if (!stop) {
-      if (output == stdout || tee) {
+      if (output == stdout || teeout) {
          sendit(prompt);
       }
    }
@@ -783,14 +785,14 @@ static int inputcmd(FILE *input, BSOCK *UA_sock)
 /* Send output to both termina and specified file */
 static int teecmd(FILE *input, BSOCK *UA_sock)
 {
-   tee = true;
+   teeout = true;
    return do_outputcmd(input, UA_sock);
 }
 
 /* Send output to specified "file" */
 static int outputcmd(FILE *input, BSOCK *UA_sock)
 {
-   tee = false;
+   teeout = false;
    return do_outputcmd(input, UA_sock);
 }
 
@@ -808,7 +810,7 @@ static int do_outputcmd(FILE *input, BSOCK *UA_sock)
       if (output != stdout) {
          fclose(output);
          output = stdout;
-         tee = false;
+         teeout = false;
       }
       return 1;
    }
@@ -855,48 +857,50 @@ static int timecmd(FILE *input, BSOCK *UA_sock)
  */
 void senditf(const char *fmt,...)
 {
-    char buf[3000];
-    va_list arg_ptr;
+   char buf[3000];
+   va_list arg_ptr;
 
-    va_start(arg_ptr, fmt);
-    bvsnprintf(buf, sizeof(buf), (char *)fmt, arg_ptr);
-    va_end(arg_ptr);
-    sendit(buf);
+   va_start(arg_ptr, fmt);
+   bvsnprintf(buf, sizeof(buf), (char *)fmt, arg_ptr);
+   va_end(arg_ptr);
+   sendit(buf);
 }
 
 void sendit(const char *buf)
 {
-#ifdef xHAVE_CONIO
-    if (output == stdout || tee) {
-       char *p, *q;
-       /*
-        * 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 */
-       }
-       if (*q) {
-          t_send(q);
-       }
-    }
-    if (output != stdout) {
-       fputs(buf, output);
-    }
+#ifdef CONIO_FIX
+   char obuf[3000];
+   if (output == stdout || teeout) {
+      const char *p, *q;
+      /*
+       * 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')); ) {
+         int len = p - q;
+         if (len > 0) {
+            memcpy(obuf, q, len);
+         }
+         memcpy(obuf+len, "\r\n", 3);
+         q = ++p;                    /* point after \n */
+         fputs(obuf, output);
+      }
+      if (*q) {
+         fputs(q, output);
+      }
+      fflush(output);
+   }
+   if (output != stdout) {
+      fputs(buf, output);
+   }
 #else
 
-    fputs(buf, output);
-    fflush(output);
-    if (tee) {
-       fputs(buf, stdout);
-    }
-    if (output != stdout || tee) {
-       fflush(stdout);
-    }
+   fputs(buf, output);
+   fflush(output);
+   if (teeout) {
+      fputs(buf, stdout);
+      fflush(stdout);
+   }
 #endif
 }
index 54eac9bcda938d808f366f13caa40412a96ccb53..81709076ae2bd592e28274d24eb1b52f091e2a41 100644 (file)
@@ -3,9 +3,9 @@
  */
 
 #undef  VERSION
-#define VERSION "1.39.16"
-#define BDATE   "22 July 2006"
-#define LSMDATE "22Jul06"
+#define VERSION "1.39.17"
+#define BDATE   "27 July 2006"
+#define LSMDATE "27Jul06"
 
 /* Debug flags */
 #undef  DEBUG