From: Kern Sibbald Date: Thu, 27 Jul 2006 10:22:28 +0000 (+0000) Subject: - Several important commits from Robert Nelson for code cleanup and X-Git-Tag: Release-2.0.0~710 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3e859b4590b82212c58dee12c11c5b2b299c4bfd;p=bacula%2Fbacula - 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. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3192 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 51d2a2c102..a61bfa79aa 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -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. - diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index d48a51b92a..a9f995bff8 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -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. diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 8e1d32e0e8..bd24519f05 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -25,8 +25,10 @@ #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 } diff --git a/bacula/src/version.h b/bacula/src/version.h index 54eac9bcda..81709076ae 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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