]> git.sur5r.net Git - bacula/bacula/commitdiff
Add -n option to bconsole to turn off conio
authorKern Sibbald <kern@sibbald.com>
Sun, 20 Aug 2006 18:40:53 +0000 (18:40 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 20 Aug 2006 18:40:53 +0000 (18:40 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3311 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/console/console.c
bacula/technotes-1.39

index 3ad63c9ffff53ce414cc0c1a04e829b04336d44c..bf8f31e598a1ff6c9154b216f7ec48b765c7c6a8 100644 (file)
@@ -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.
-
index 8749296dd5d8cba83adbea1c3fb4af9b1b5272f4..bcaf07a9fce9d7162bf648bcab7311166804b630 100644 (file)
@@ -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 <file>   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)
 {
index b012f0eaf9f8dc3680015ea6fd8a134cb7a42415..6589bf53e64d1916d7fb183092f4a23b9bb246ab 100644 (file)
@@ -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.