From 4607929367c751a2ddb96d572a50def0bf84f887 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 20 Aug 2006 18:40:53 +0000 Subject: [PATCH] Add -n option to bconsole to turn off conio git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3311 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 2 +- bacula/src/console/console.c | 40 ++++++++++++++++++++++++++---------- bacula/technotes-1.39 | 1 + 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 3ad63c9fff..bf8f31e598 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -33,6 +33,7 @@ Document: Priority: For 1.39: +- Fix wx-console scanning problem with commas in names. - Change dbcheck to tell users to use native tools for fixing broken databases, and to ensure they have the proper indexes. - add udev rules for Bacula devices. @@ -1648,4 +1649,3 @@ Block Position: 0 - Update llist to include new fields. - Make unmount unload autochanger. Make mount load slot. - Fix bscan to report the JobType when restoring a job. - diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 8749296dd5..bcaf07a9fc 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -38,7 +38,7 @@ #define usrbrk() 0 #endif -#ifdef HAVE_WIN32 +#if defined(HAVE_WIN32) #define isatty(fd) (fd==0) #endif @@ -70,6 +70,7 @@ static DIRRES *dir; static FILE *output = stdout; static bool teeout = false; /* output to output and stdout */ static bool stop = false; +static bool no_conio = false; static int argc; static int numdir; static POOLMEM *args; @@ -97,6 +98,7 @@ static void usage() "Usage: bconsole [-s] [-c config_file] [-d debug_level]\n" " -c set configuration file to file\n" " -dnn set debug level to nn\n" +" -n no conio\n" " -s no signals\n" " -t test - read configuration and exit\n" " -? print this message.\n" @@ -335,9 +337,8 @@ int main(int argc, char *argv[]) init_msg(NULL, NULL); working_directory = "/tmp"; args = get_pool_memory(PM_FNAME); - con_init(stdin); - while ((ch = getopt(argc, argv, "bc:d:r:st?")) != -1) { + while ((ch = getopt(argc, argv, "bc:d:nst?")) != -1) { switch (ch) { case 'c': /* configuration file */ if (configfile != NULL) { @@ -353,6 +354,10 @@ int main(int argc, char *argv[]) } break; + case 'n': /* no conio */ + no_conio = true; + break; + case 's': /* turn off signals */ no_signals = true; break; @@ -364,7 +369,6 @@ int main(int argc, char *argv[]) case '?': default: usage(); - con_term(); exit(1); } } @@ -390,7 +394,6 @@ int main(int argc, char *argv[]) if (argc) { usage(); - con_term(); exit(1); } @@ -408,6 +411,10 @@ int main(int argc, char *argv[]) Emsg1(M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile); } + if (!no_conio) { + con_init(stdin); + } + if (test_config) { terminate_console(0); exit(0); @@ -555,7 +562,9 @@ static void terminate_console(int sig) already_here = true; cleanup_crypto(); free_pool_memory(args); - con_term(); + if (!no_conio) { + con_term(); + } (void)WSACleanup(); /* Cleanup Windows sockets */ if (sig != 0) { exit(1); @@ -661,6 +670,14 @@ get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec) #else /* no readline, do it ourselves */ +static bool bisatty(int fd) +{ + if (no_conio) { + return false; + } + return isatty(fd); +} + /* * Returns: 1 if data available * 0 if timeout @@ -669,11 +686,11 @@ get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec) static int wait_for_data(int fd, int sec) { +#if defined(HAVE_WIN32) + return 1; +#else fd_set fdset; struct timeval tv; -#ifdef HAVE_WIN32 - return 1; /* select doesn't seem to work on Win32 */ -#endif tv.tv_sec = sec; tv.tv_usec = 0; @@ -692,6 +709,7 @@ wait_for_data(int fd, int sec) return 1; } } +#endif } /* @@ -723,7 +741,7 @@ again: goto again; } #ifdef HAVE_CONIO - if (isatty(fileno(input))) { + if (bisatty(fileno(input))) { input_line(sock->msg, len); break; } @@ -750,7 +768,7 @@ again: return 1; } -#endif +#endif /* end non-readline code */ static int versioncmd(FILE *input, BSOCK *UA_sock) { diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index b012f0eaf9..6589bf53e6 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -2,6 +2,7 @@ General: 20Aug06 +kes Add -n option to bconsole to turn off conio. kes Print JobIds to be migrated in Job Report. kes Add additional user supplied notes to the messages part of bacula-dir.conf concerning multiple email addresses. -- 2.39.5