]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/console/conio.c
First cut of bat rerun a Job from Jobs Run
[bacula/bacula] / bacula / src / console / conio.c
index 157df55e7c35aa46e0e67010223fb3bb3dea5aba..c04779667c5aa4ebbe7470f25399191278e9a6b4 100755 (executable)
@@ -1,23 +1,13 @@
-/*
-      Generalized console input/output handler
-      A maintanable replacement for readline()
-
-         Updated for Bacula, Kern Sibbald, December MMIII
-
-      This code is in part derived from code that I wrote in
-      1981, so some of it is a bit old and could use a cleanup.
-
-*/
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 1981-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 1981-2010 Free Software Foundation Europe e.V.
              Yes, that is 1981 no error.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -26,7 +16,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+      Generalized console input/output handler
+      A maintanable replacement for readline()
+
+         Updated for Bacula, Kern Sibbald, December MMIII
+
+      This code is in part derived from code that I wrote in
+      1981, so some of it is a bit old and could use a cleanup.
+
+*/
 
 /*
  * UTF-8
 
 #endif
 
-#include <termios.h>
-#ifdef HAVE_SUN_OS
+#include <curses.h>
+#include <term.h>
+
+#if defined(HAVE_SUN_OS)
+#if !defined(_TERM_H)
 extern "C" int tgetent(void *, const char *);
 extern "C" int tgetnum(const char *);
 extern "C" char *tgetstr (const char*, char**);
+#endif
 extern "C" char *tgoto (const char *, int, int);
-#elif HAVE_HPUX_OS
-#include <term.h>
-#elif HAVE_AIX_OS 
-#include <curses.h>
-#include <term.h>
 #elif defined(__sgi)
 extern "C" int tgetent(char *, char *);
 extern "C" int tgetnum(char id[2]);
@@ -82,9 +81,6 @@ extern "C" int tgetent(void *, const char *);
 extern "C" int tgetnum(const char *);
 extern "C" char *tgetstr (const char*, char**);
 extern "C" char *tgoto (const char *, int, int);
-
-#else
-#include <termcap.h>
 #endif
 #include "func.h"
 
@@ -188,7 +184,7 @@ static struct lstr *slptr;            /* store line pointer */
 static int cl, cp;
 static char *getnext(), *getprev();
 static int first = 1;
-static int mode_insert = 0;
+static int mode_insert = 1;
 static int mode_wspace = 1;           /* words separated by spaces */
 
 
@@ -629,8 +625,10 @@ input_line(char *string, int length)
 done:
    curline[cl++] = EOS;              /* terminate */
    bstrncpy(string,curline,length);           /* return line to caller */
-   /* Note, put line zaps curline */
-   putline(curline,cl);              /* save line for posterity */
+   /* Save non-blank lines. Note, put line zaps curline */
+   if (curline[0] != EOS) {
+      putline(curline,cl);            /* save line for posterity */
+   }
    return 0;                         /* give it to him/her */
 }
 
@@ -640,7 +638,7 @@ insert_space(char *curline, int curline_len)
 {
    int i;
 
-   if (cp > cl || cl+1 > curline_len) {
+   if (cp >= cl || cl+1 > curline_len) {
       return;
    }
    /* Note! source and destination overlap */
@@ -739,7 +737,7 @@ delchr(int del, char *curline, int line_len)
    if (cp > cl || del == 0) {
       return;
    }
-   while (del-- && cp > 0) {
+   while (del-- && cl > 0) {
       cnt = char_count(cp, curline);
       if ((i=cl-cp-cnt) > 0) {
          memcpy(&curline[cp], &curline[cp+cnt], i);