]> git.sur5r.net Git - bacula/bacula/commitdiff
Doc + DB script updates
authorKern Sibbald <kern@sibbald.com>
Tue, 27 Apr 2004 08:19:23 +0000 (08:19 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 27 Apr 2004 08:19:23 +0000 (08:19 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1314 91ce42f0-d328-0410-95d8-f526ca767f89

16 files changed:
bacula/kernstodo
bacula/src/cats/cats.h
bacula/src/cats/create_bacula_database.in
bacula/src/cats/create_postgresql_database.in
bacula/src/cats/drop_bacula_database.in
bacula/src/cats/drop_bacula_tables.in
bacula/src/cats/grant_bacula_privileges.in
bacula/src/cats/grant_mysql_privileges.in
bacula/src/cats/grant_postgresql_privileges.in
bacula/src/cats/make_bacula_tables.in
bacula/src/cats/make_catalog_backup.in
bacula/src/cats/make_postgresql_tables.in
bacula/src/cats/sql.c
bacula/src/cats/update_bacula_tables.in
bacula/src/console/conio.c
bacula/src/version.h

index 34db384b9153fd257715d105936a28636b87f4d2..50c1a46713f3fad70344eec9eb6b374426a33fbc 100644 (file)
@@ -43,6 +43,10 @@ For 1.33 Testing/Documentation:
 
 
 For version 1.35:
+- Add a "base" package to the window installer for pthreadsVCE.dll
+  which is needed by all packages.
+- Add message to user to check for fixed block size when the forward
+  space test fails in btape.
 - When unmarking a directory check if all files below are unmarked and
   then remove the + flag -- in the restore tree.
 - Possibly implement: Action = Unmount Device="TapeDrive1" in Admin jobs.
index 2e4dafd3fbeb1ccb78839f4f9697e6179aee3342..4c6355a7c4e1e906fca90ec6f71091b4b7ac48e4 100644 (file)
@@ -260,6 +260,7 @@ typedef struct s_db {
    POOLMEM *cached_path;
    int cached_path_len;           /* length of cached path */
    uint32_t cached_path_id;
+   int transaction;                   /* transaction started */
    int changes;                   /* changes made to db */
    POOLMEM *fname;                /* Filename only */
    POOLMEM *path;                 /* Path only */
index 9609be8ad6d9aea69bf0834fd9d50e8cc06a3b94..57123c07d6a667cdd3238eba383d7ada88907741 100644 (file)
@@ -5,13 +5,13 @@
 #
 if test xsqlite = x@DB_NAME@ ; then
   echo "Creating SQLite database"
-  @scriptdir@/create_sqlite_database
+  @scriptdir@/create_sqlite_database $*
 else
   if test xmysql = x@DB_NAME@ ; then
     echo "Creating MySQL database"
     @scriptdir@/create_mysql_database $*
   else
     echo "Creating PostgreSQL database"
-    @scriptdir@/create_postgresql_database template1
+    @scriptdir@/create_postgresql_database $*
   fi
 fi
index 2d9e43f3d0727aceb8f565196bbd7c196e485b6c..5ec7a8f7e945835dd333d2a374ad87431a315662 100644 (file)
@@ -5,7 +5,7 @@
 
 bindir=@SQL_BINDIR@
 
-if $bindir/psql $* -f - <<END-OF-DATA
+if $bindir/psql template1 $* -f - <<END-OF-DATA
 CREATE DATABASE bacula;
 END-OF-DATA
 then
index d4aed3e00e4a9624af00dde95bfa1b5530d86c3d..cf9adc360de3db8be3af7d4594faa53759548873 100755 (executable)
@@ -4,7 +4,7 @@
 #    MySQL, SQLite, PostgreSQL
 #
 if test xsqlite = x@DB_NAME@ ; then
-  @scriptdir@/drop_sqlite_database
+  @scriptdir@/drop_sqlite_database $*
   echo "Dropped SQLite database"
 else
   if test xmysql = x@DB_NAME@ ; then 
@@ -12,8 +12,7 @@ else
     @scriptdir@/drop_mysql_database $*
     echo "Dropped MySQL database"
   else
-    # hardcoded database name - should be a parameter
-    @scriptdir@/drop_postgresql_database bacula
+    @scriptdir@/drop_postgresql_database $*
     echo "Dropped PostgreSQL database"
   fi
 fi
index 4ff69a54f10dba93ac2b3ef13dd8c4f3718d191b..96c0fb7d98819466edf5e17a10b6f719166d0a55 100755 (executable)
@@ -4,7 +4,7 @@
 #    MySQL, SQLite, or PostgreSQL
 #
 if test xsqlite = x@DB_NAME@ ; then
-  @scriptdir@/drop_sqlite_tables
+  @scriptdir@/drop_sqlite_tables $*
   echo "Dropped SQLite tables"
 else
   if test xmysql = x@DB_NAME@ ; then 
@@ -13,7 +13,7 @@ else
     echo "Dropped MySQL tables"
   else
     # hardcoded database name - should be a parameter
-    @scriptdir@/drop_postgresql_tables bacula
+    @scriptdir@/drop_postgresql_tables $*
     echo "Dropped PostgreSQL tables"
   fi
 fi
index ba2b8a04cf4c64b2a7c9a8308ee89175b2e00381..d7e66f1224eb484868a7ae4c724e092a61919dbc 100755 (executable)
@@ -10,13 +10,12 @@ if test xmysql = x@DB_NAME@ ; then
 else
   if test xpostgresql = x@DB_NAME@ ; then 
     echo "Granting PostgreSQL privileges"
-    # hard coded database name
-    @scriptdir@/grant_postgresql_privileges bacula
+    @scriptdir@/grant_postgresql_privileges $*
   else
     if test xsqlite = x@DB_NAME@ ; then 
       echo "Granting SQLite privileges"
       # hard coded database name
-      @scriptdir@/grant_sqlite_privileges
+      @scriptdir@/grant_sqlite_privileges $*
     fi
   fi
 fi
index 0c0c6a597b721beff32a04e858dbb1761471a8df..a95021e7199459f88685f7ef892d75a70130ce10 100644 (file)
@@ -2,17 +2,18 @@
 #
 # shell script to grant privileges to the bacula database
 #
+USER=bacula
 bindir=@SQL_BINDIR@
 
 if $bindir/mysql $* -u root -f <<END-OF-DATA
 use mysql
-grant all privileges on bacula.* to bacula@localhost with grant option;
-grant all privileges on bacula.* to bacula@"%" with grant option;
+grant all privileges on bacula.* to ${USER}@localhost with grant option;
+grant all privileges on bacula.* to ${USER}@"%" with grant option;
 select * from user;
 flush privileges;
 END-OF-DATA
 then
-   echo "Privileges for bacula granted."
+   echo "Privileges for ${USER} granted."
    exit 0
 else
    echo "Error creating privileges."
index a6699049ea610dc1b1634cb96ad0e406be5a6b94..fc69abd1f11d1bfa366487ada2b5b6d091b465ba 100644 (file)
@@ -2,44 +2,45 @@
 #
 # shell script to grant privileges to the bacula database
 #
+USER=bacula
 bindir=@SQL_BINDIR@
 
 if $bindir/psql $* -f - <<END-OF-DATA
 \c bacula
 
-create user bacula;
+create user ${USER};
 
 -- for tables
-grant all on unsavedfiles to bacula;
-grant all on basefiles    to bacula;
-grant all on jobmedia     to bacula;
-grant all on file         to bacula;
-grant all on job          to bacula;
-grant all on media        to bacula;
-grant all on client       to bacula;
-grant all on pool         to bacula;
-grant all on fileset      to bacula;
-grant all on path         to bacula;
-grant all on filename     to bacula;
-grant all on counters     to bacula;
-grant all on version      to bacula;
+grant all on unsavedfiles to ${USER};
+grant all on basefiles   to ${USER};
+grant all on jobmedia    to ${USER};
+grant all on file        to ${USER};
+grant all on job         to ${USER};
+grant all on media       to ${USER};
+grant all on client      to ${USER};
+grant all on pool        to ${USER};
+grant all on fileset     to ${USER};
+grant all on path        to ${USER};
+grant all on filename    to ${USER};
+grant all on counters    to ${USER};
+grant all on version     to ${USER};
 
 -- for sequences on those tables
 
-grant select, update on filename_filenameid_seq to bacula;
-grant select, update on path_pathid_seq         to bacula;
-grant select, update on fileset_filesetid_seq   to bacula;
-grant select, update on pool_poolid_seq         to bacula;
-grant select, update on client_clientid_seq     to bacula;
-grant select, update on media_mediaid_seq       to bacula;
-grant select, update on job_jobid_seq           to bacula;
-grant select, update on file_fileid_seq         to bacula;
-grant select, update on jobmedia_jobmediaid_seq to bacula;
-grant select, update on basefiles_baseid_seq    to bacula;
+grant select, update on filename_filenameid_seq to ${USER};
+grant select, update on path_pathid_seq        to ${USER};
+grant select, update on fileset_filesetid_seq  to ${USER};
+grant select, update on pool_poolid_seq        to ${USER};
+grant select, update on client_clientid_seq    to ${USER};
+grant select, update on media_mediaid_seq      to ${USER};
+grant select, update on job_jobid_seq          to ${USER};
+grant select, update on file_fileid_seq        to ${USER};
+grant select, update on jobmedia_jobmediaid_seq to ${USER};
+grant select, update on basefiles_baseid_seq   to ${USER};
 
 END-OF-DATA
 then
-   echo "Privileges for bacula granted."
+   echo "Privileges for ${USER} granted."
    exit 0
 else
    echo "Error creating privileges."
index 1759dd7a631f804e6bbaef0aa3c90091b1f3a767..29615e906e7319162688b222e7579053f198fd2d 100755 (executable)
@@ -5,7 +5,7 @@
 #
 if test xsqlite = x@DB_NAME@ ; then
   echo "Making SQLite tables"
-  @scriptdir@/make_sqlite_tables
+  @scriptdir@/make_sqlite_tables $*
 else
   if test xmysql = x@DB_NAME@ ; then 
     echo "Making MySQL tables"
@@ -13,6 +13,6 @@ else
   else
     echo "Making PostgreSQL tables"
     # hard coded database name
-    @scriptdir@/make_postgresql_tables bacula
+    @scriptdir@/make_postgresql_tables $*
   fi
 fi
index f2327dee593b8a8acae50ea45179843cbc401f0c..61cb4b6d1da95baa1c09896a4308d7ec46f7d62a 100755 (executable)
@@ -6,7 +6,7 @@
 cd @working_dir@
 rm -f bacula.sql
 if test xsqlite = x@DB_NAME@ ; then
-  echo ".dump" | @SQL_BINDIR@/sqlite bacula.db >bacula.sql
+  echo ".dump" | @SQL_BINDIR@/sqlite $* bacula.db >bacula.sql
 else
   if test xmysql = x@DB_NAME@ ; then
     @SQL_BINDIR@/mysqldump $* -f --opt bacula >bacula.sql
index ea7292bb020465cccc6e0c86965b4a56c61926a4..9f7131c48d608f56d0f442c04163246cc433a877 100644 (file)
@@ -250,75 +250,79 @@ create table unsavedfiles
     primary key (UnsavedId)
 );
 
-alter table pool
-    add foreign key  (scratchpoolid)
-       references pool (poolid) on update cascade on delete cascade;
-
-alter table pool
-    add foreign key  (recyclepoolid)
-       references pool (poolid) on update cascade on delete cascade;
-
-alter table media
-    add foreign key  (poolid)
-       references pool (poolid) on update cascade on delete cascade;
-
-alter table job
-    add foreign key  (poolid)
-       references pool (poolid) on update cascade on delete cascade;
-
-alter table job
-    add foreign key  (filesetid)
-       references fileset (filesetid) on update cascade on delete cascade;
-
-alter table job
-    add foreign key  (clientid)
-       references client (clientid) on update cascade on delete cascade;
-
-alter table file
-    add foreign key  (jobid)
-       references job (jobid) on update cascade on delete cascade;
-
-alter table file
-    add foreign key  (pathid)
-       references path (pathid) on update cascade on delete restrict;
-
-alter table file
-    add foreign key  (filenameid)
-       references filename (filenameid) on update cascade on delete cascade;
-
-alter table jobmedia
-    add foreign key  (jobid)
-       references job (jobid) on update cascade on delete cascade;
-
-alter table jobmedia
-    add foreign key  (mediaid)
-       references media (mediaid) on update cascade on delete cascade;
-
-alter table basefiles
-    add foreign key  (jobid)
-       references job (jobid) on update cascade on delete cascade;
-
-alter table basefiles
-    add foreign key  (fileid)
-       references file (fileid) on update cascade on delete cascade;
-
-alter table basefiles
-    add foreign key  (basejobid)
-       references job (jobid) on update cascade on delete cascade;
-
-alter table unsavedfiles
-    add foreign key  (jobid)
-       references job (jobid) on update restrict on delete restrict;
-
-alter table unsavedfiles
-    add foreign key  (pathid)
-       references path (pathid) on update restrict on delete restrict;
-
-alter table unsavedfiles
-    add foreign key  (filenameid)
-       references filename (filenameid) on update restrict on delete restrict;
-
-
+-- Make sure we have appropriate permissions
+
+--
+-- The following alter table commands have been removed
+--  because they seem to create severe performance problems
+--
+--alter table pool
+--    add foreign key  (scratchpoolid)
+--      references pool (poolid) on update cascade on delete cascade;
+
+--alter table pool
+--    add foreign key  (recyclepoolid)
+--      references pool (poolid) on update cascade on delete cascade;
+
+--alter table media
+--    add foreign key  (poolid)
+--      references pool (poolid) on update cascade on delete cascade;
+
+--alter table job
+--    add foreign key  (poolid)
+--      references pool (poolid) on update cascade on delete cascade;
+
+--alter table job
+--    add foreign key  (filesetid)
+--      references fileset (filesetid) on update cascade on delete cascade;
+
+--alter table job
+--    add foreign key  (clientid)
+--      references client (clientid) on update cascade on delete cascade;
+
+--alter table file
+--    add foreign key  (jobid)
+--      references job (jobid) on update cascade on delete cascade;
+
+--alter table file
+--    add foreign key  (pathid)
+--      references path (pathid) on update cascade on delete restrict;
+
+--alter table file
+--    add foreign key  (filenameid)
+--      references filename (filenameid) on update cascade on delete cascade;
+
+--alter table jobmedia
+--    add foreign key  (jobid)
+--      references job (jobid) on update cascade on delete cascade;
+
+--alter table jobmedia
+--    add foreign key  (mediaid)
+--      references media (mediaid) on update cascade on delete cascade;
+
+--alter table basefiles
+--    add foreign key  (jobid)
+--      references job (jobid) on update cascade on delete cascade;
+
+--alter table basefiles
+--    add foreign key  (fileid)
+--      references file (fileid) on update cascade on delete cascade;
+
+--alter table basefiles
+--    add foreign key  (basejobid)
+--      references job (jobid) on update cascade on delete cascade;
+
+--alter table unsavedfiles
+--    add foreign key  (jobid)
+--      references job (jobid) on update restrict on delete restrict;
+
+--alter table unsavedfiles
+--    add foreign key  (pathid)
+--      references path (pathid) on update restrict on delete restrict;
+
+--alter table unsavedfiles
+--    add foreign key  (filenameid)
+--      references filename (filenameid) on update restrict on delete restrict;
 
 END-OF-DATA
 then
index 8e605c30425f66d71549da9cf2eea303454118dc..25f079cad65afd99976a171b674af4a38218e23d 100644 (file)
@@ -276,6 +276,19 @@ void db_start_transaction(JCR *jcr, B_DB *mdb)
    db_unlock(mdb);
 #endif
 
+#ifdef HAVE_POSTGRESQL
+   db_lock(mdb);
+   /* Allow only 25,000 changes per transaction */
+   if (mdb->transaction && mdb->changes > 25000) {
+      db_end_transaction(jcr, mdb);
+   }
+   if (!mdb->transaction) {   
+      db_sql_query(mdb, "BEGIN", NULL, NULL);  /* begin transaction */
+      Dmsg0(400, "Start SQLite transaction\n");
+      mdb->transaction = 1;
+   }
+   db_unlock(mdb);
+#endif
 }
 
 void db_end_transaction(JCR *jcr, B_DB *mdb)
@@ -290,6 +303,17 @@ void db_end_transaction(JCR *jcr, B_DB *mdb)
    mdb->changes = 0;
    db_unlock(mdb);
 #endif
+
+#ifdef HAVE_POSTGRESQL
+   db_lock(mdb);
+   if (mdb->transaction) {
+      db_sql_query(mdb, "COMMIT", NULL, NULL); /* end transaction */
+      mdb->transaction = 0;
+      Dmsg1(400, "End SQLite transaction changes=%d\n", mdb->changes);
+   }
+   mdb->changes = 0;
+   db_unlock(mdb);
+#endif
 }
 
 /*
index 40b9a89a2e85350aa883fab85a474108971a3f55..5a7dc8926149c3a87fa0bc827dd33f69e42612eb 100755 (executable)
@@ -5,7 +5,7 @@
 #
 if test xsqlite = x@DB_NAME@ ; then
   echo "Altering SQLite tables"
-  @scriptdir@/update_sqlite_tables
+  @scriptdir@/update_sqlite_tables $*
 fi
 if test xmysql = x@DB_NAME@ ; then
   echo "Altering MySQL tables"
@@ -13,6 +13,5 @@ if test xmysql = x@DB_NAME@ ; then
 fi
 if test xpostgresql = x@DB_NAME@ ; then
   echo "Altering PostgreSQL tables"
-  # we need the bacula datbase name in here... Should not be hardcoded
-  @scriptdir@/update_postgresql_tables bacula
+  @scriptdir@/update_postgresql_tables $*
 fi
index 232e663d9ab307cfb286f200a809e6dc14b06c61..41127d2705c42fd63c98229e8683761f98ed8ce2 100755 (executable)
@@ -178,12 +178,6 @@ static short char_map[600]= {
   };
 
 
-#define NVID  0x1E                   /* normal video -- blue */
-#define RVID  0x4F                   /* reverse video -- red */
-#define MNVID 0x07                   /* normal video (monochrome tube) */
-#define MRVID 0x70                   /* reverse video (monochrome tube) */
-
-
 /* Local variables */
 
 #define CR '\r'                       /* carriage return */
@@ -425,189 +419,190 @@ input_char()
 int
 input_line(char *string, int length)
 {
-   char curline[200];                /* edit buffer */
+   char curline[2000];               /* edit buffer */
    int noline;
    int c;
 
     if (first) {
-       poolinit();                   /* build line pool */
-       first = 0;
+       poolinit();                  /* build line pool */
+       first = 0;
     }
     noline = 1;                      /* no line fetched yet */
     for (cl=cp=0; cl<length && cl<(int)sizeof(curline); ) {
-       if (usrbrk()) {
-          clrbrk();
+       if (usrbrk()) {
+         clrbrk();
+         break;
+       }
+       switch (c=(int)input_char()) {
+       case F_RETURN:               /* CR */
+           t_sendl("\r\n", 2);       /* yes, print it and */
+          goto done;                /* get out */
+       case F_CLRSCRN:              /* clear screen */
+         asclrs();
+         t_sendl(curline, cl);
+         ascurs(0, cp);
+         break;
+       case F_CSRUP:
+          if (noline) {             /* no line fetched yet */
+              getnext();            /* getnext so getprev gets current */
+              noline = 0;           /* we now have line */
+          }
+          bstrncpy(curline, getprev(), sizeof(curline));
+          prtcur(curline);
           break;
-       }
-       switch (c=(int)input_char()) {
-       case F_RETURN:                /* CR */
-            t_sendl("\r\n", 2);       /* yes, print it and */
-           goto done;                /* get out */
-       case F_CLRSCRN:               /* clear screen */
-          asclrs();
-          t_sendl(curline, cl);
-          ascurs(0, cp);
+       case F_CSRDWN:
+          noline = 0;               /* mark line fetched */
+          bstrncpy(curline, getnext(), sizeof(curline));
+          prtcur(curline);
           break;
-       case F_CSRUP:
-           if (noline) {             /* no line fetched yet */
-               getnext();            /* getnext so getprev gets current */
-               noline = 0;           /* we now have line */
-           }
-           bstrncpy(curline, getprev(), sizeof(curline));
-           prtcur(curline);
-           break;
-       case F_CSRDWN:
-           noline = 0;               /* mark line fetched */
-           bstrncpy(curline, getnext(), sizeof(curline));
-           prtcur(curline);
-           break;
-       case F_INSCHR:
-           insert_space(curline, sizeof(curline));
-           break;
-       case F_DELCHR:
-           delchr(1, curline, sizeof(curline));       /* delete one character */
-           break;
-       case F_CSRLFT:                /* Backspace */
-           backup(1);
-           break;
-       case F_CSRRGT:
-           forward(1,curline, sizeof(curline));
-           break;
-       case F_ERSCHR:                /* Rubout */
-           backup(1);
-           delchr(1, curline, sizeof(curline));
-           break;
-       case F_DELEOL:
-           t_clrline(0, t_width);
-           if (cl > cp)
-               cl = cp;
-           break;
-       case F_NXTWRD:
-           forward(next_word(curline),curline, sizeof(curline));
-           break;
-       case F_PRVWRD:
-           backup(prev_word(curline));
-           break;
-       case F_DELWRD:
-           delchr(next_word(curline), curline, sizeof(curline)); /* delete word */
-           break;
-       case F_NXTMCH:                /* Ctl-X */
-           if (cl==0) {
-               *string = EOS;        /* terminate string */
-               return(c);            /* give it to him */
-           }
-           /* Note fall through */
-       case F_DELLIN:
-       case F_ERSLIN:
-           backup(cp);               /* backup to beginning of line */
-           t_clrline(0,t_width);     /* erase line */
-           cp = 0;
-           cl = 0;                   /* reset cursor counter */
-           break;
-       case F_SOL:
-           backup(cp);
-           break;
-       case F_EOL:
-           while (cp < cl) {
-               forward(1,curline, sizeof(curline));
-           }
-           while (cp > cl) {
-               backup(1);
-           }
-           break;
-       case F_TINS:                  /* toggle insert mode */
-           mode_insert = !mode_insert;  /* flip bit */
-           break;
-       default:
-           if (c > 255) {            /* function key hit */
-               if (cl==0) {          /* if first character then */
-                   *string = EOS;         /* terminate string */
-                   return c;              /* return it */
-               }
-               t_honk_horn();        /* complain */
-           } else {
-               if (mode_insert) {
-                   insert_space(curline, sizeof(curline));
-               }
-               curline[cp++] = c;    /* store character in line being built */
-               t_char((char)c);      /* echo character to terminal */
-               if (cp > cl) {
-                   cl = cp;          /* keep current length */
-               }
-           }
-           break;
-       }                             /* end switch */
+       case F_INSCHR:
+          insert_space(curline, sizeof(curline));
+          break;
+       case F_DELCHR:
+          delchr(1, curline, sizeof(curline));       /* delete one character */
+          break;
+       case F_CSRLFT:               /* Backspace */
+          backup(1);
+          break;
+       case F_CSRRGT:
+          forward(1,curline, sizeof(curline));
+          break;
+       case F_ERSCHR:               /* Rubout */
+          backup(1);
+          delchr(1, curline, sizeof(curline));
+          break;
+       case F_DELEOL:
+          t_clrline(0, t_width);
+          if (cl > cp)
+              cl = cp;
+          break;
+       case F_NXTWRD:
+          forward(next_word(curline),curline, sizeof(curline));
+          break;
+       case F_PRVWRD:
+          backup(prev_word(curline));
+          break;
+       case F_DELWRD:
+          delchr(next_word(curline), curline, sizeof(curline)); /* delete word */
+          break;
+       case F_NXTMCH:               /* Ctl-X */
+          if (cl==0) {
+              *string = EOS;        /* terminate string */
+              return(c);            /* give it to him */
+          }
+          /* Note fall through */
+       case F_DELLIN:
+       case F_ERSLIN:
+          backup(cp);               /* backup to beginning of line */
+          t_clrline(0,t_width);     /* erase line */
+          cp = 0;
+          cl = 0;                   /* reset cursor counter */
+          break;
+       case F_SOL:
+          backup(cp);
+          break;
+       case F_EOL:
+          while (cp < cl) {
+              forward(1,curline, sizeof(curline));
+          }
+          while (cp > cl) {
+              backup(1);
+          }
+          break;
+       case F_TINS:                 /* toggle insert mode */
+          mode_insert = !mode_insert;  /* flip bit */
+          break;
+       default:
+          if (c > 255) {            /* function key hit */
+              if (cl==0) {          /* if first character then */
+                 *string = EOS;     /* terminate string */
+                 return c;          /* return it */
+              }
+              t_honk_horn();        /* complain */
+          } else {
+              if (mode_insert) {
+                 insert_space(curline, sizeof(curline));
+              }
+              curline[cp++] = c;    /* store character in line being built */
+              t_char((char)c);      /* echo character to terminal */
+              if (cp > cl) {
+                 cl = cp;           /* keep current length */
+              }
+          }
+          break;
+       }                            /* end switch */
     }
 /* If we fall through here rather than goto done, the line is too long
    simply return what we have now. */
 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 */
-    return 0;                        /* give it to him/her */
+   curline[cl++] = EOS;             /* terminate */
+   bstrncpy(string,curline,length);          /* return line to caller */
+   /* Note, put line zaps curline */
+   putline(curline,cl);             /* save line for posterity */
+   return 0;                        /* give it to him/her */
 }
 
 /* Insert a space at the current cursor position */
 static void
 insert_space(char *curline, int curline_len)
 {
-    int i;
-
-    if (cp > cl || cl+1 > curline_len) return;
-    /* Note! source and destination overlap */
-    memmove(&curline[cp+1],&curline[cp],i=cl-cp);
-    cl++;
-    i++;
-    curline[cp] = ' ';
-    forward(i,curline, curline_len);
-    backup(i);
+   int i;
+
+   if (cp > cl || cl+1 > curline_len) return;
+   /* Note! source and destination overlap */
+   memmove(&curline[cp+1],&curline[cp],i=cl-cp);
+   cl++;
+   i++;
+   curline[cp] = ' ';
+   forward(i,curline, curline_len);
+   backup(i);
 }
 
 
 /* Move cursor forward keeping characters under it */
 static void
-forward(int i,char *str, int str_len)
+forward(int i, char *str, int str_len)
 {
-    while (i--) {
-       if (cp > str_len) {
-          return;
-       }
-       if (cp>=cl) {
-            t_char(' ');
-            str[cp+1] = ' ';
-       } else {
-           t_char(str[cp]);
-       }
-       cp++;
-    }
+   while (i--) {
+      if (cp > str_len) {
+        return;
+      }
+      if (cp>=cl) {
+          t_char(' ');
+          str[cp+1] = ' ';
+      } else {
+         t_char(str[cp]);
+      }
+      cp++;
+   }
 }
 
 /* Backup cursor keeping characters under it */
 static void
 backup(int i)
 {
-    for ( ;i && cp; i--,cp--)
-        t_char('\010');
+    for ( ; i && cp; i--,cp--) {
+       t_char('\010');
+    }
 }
 
 /* Delete the character under the cursor */
 static void
 delchr(int cnt, char *curline, int line_len) 
 {
-    register int i;
+   register int i;
 
-    if (cp > cl)
-       return;
-    if ((i=cl-cp-cnt+1) > 0) {
-       memcpy(&curline[cp],&curline[cp+cnt],i);
-    }
-    curline[cl -= cnt] = EOS;
-    t_clrline(0,t_width);
-    if (cl > cp) {
-       forward(i=cl-cp,curline, line_len);
-       backup(i);
-    }
+   if (cp > cl)
+      return;
+   if ((i=cl-cp-cnt+1) > 0) {
+      memcpy(&curline[cp], &curline[cp+cnt],i);
+   }
+   curline[cl -= cnt] = EOS;
+   t_clrline(0,t_width);
+   if (cl > cp) {
+      forward(i=cl-cp,curline, line_len);
+      backup(i);
+   }
 }
 
 /* Determine if character is part of a word */
@@ -627,14 +622,14 @@ iswordc(char c)
 static int
 next_word(char *ldb_buf)
 {
-    int ncp;
-
-    if (cp > cl)
-       return 0;
-    ncp = cp;
-    for ( ; ncp<cl && iswordc(*(ldb_buf+ncp)); ncp++) ;
-    for ( ; ncp<cl && !iswordc(*(ldb_buf+ncp)); ncp++) ;
-    return ncp-cp;
+   int ncp;
+
+   if (cp > cl)
+      return 0;
+   ncp = cp;
+   for ( ; ncp<cl && iswordc(*(ldb_buf+ncp)); ncp++) ;
+   for ( ; ncp<cl && !iswordc(*(ldb_buf+ncp)); ncp++) ;
+   return ncp-cp;
 }
 
 /* Return number of characters to get to previous word */
@@ -677,12 +672,12 @@ prtcur(char *str)
 static void
 poolinit()
 {
-    slptr = lptr = (struct lstr *)pool;
-    lptr->nextl = lptr;
-    lptr->prevl = lptr;
-    lptr->used = 1;
-    lptr->line = 0;
-    lptr->len = POOLEN;
+   slptr = lptr = (struct lstr *)pool;
+   lptr->nextl = lptr;
+   lptr->prevl = lptr;
+   lptr->used = 1;
+   lptr->line = 0;
+   lptr->len = POOLEN;
 }
 
 
@@ -690,59 +685,59 @@ poolinit()
 static char *
 getnext()
 {
-    do {                             /* find next used line */
-       lptr = lptr->nextl;
-    } while (!lptr->used);
-    return (char *)&lptr->line;
+   do {                             /* find next used line */
+      lptr = lptr->nextl;
+   } while (!lptr->used);
+   return (char *)&lptr->line;
 }
 
 /* Return pointer to previous line in the pool */
 static char *
 getprev()
 {
-    do {                             /* find previous used line */
-       lptr = lptr->prevl;
-    } while (!lptr->used);
-    return (char *)&lptr->line;
+   do {                             /* find previous used line */
+      lptr = lptr->prevl;
+   } while (!lptr->used);
+   return (char *)&lptr->line;
 }
 
 static void
 putline(char *newl, int newlen)
 {
-    struct lstr *nptr;               /* points to next line */
-    char *p;
-
-    lptr = slptr;                    /* get ptr to last line stored */
-    lptr = lptr->nextl;              /* advance pointer */
-    if ((char *)lptr-pool+newlen+PHDRL > POOLEN) { /* not enough room */
-       lptr->used = 0;               /* delete line */
-       lptr = (struct lstr *)pool;   /* start at beginning of buffer */
-    }
-    while (lptr->len < newlen+PHDRL) { /* concatenate buffers */
-       nptr = lptr->nextl;           /* point to next line */
-       lptr->nextl = nptr->nextl;    /* unlink it from list */
-       nptr->nextl->prevl = lptr;
-       lptr->len += nptr->len;
-    }
-    if (lptr->len > newlen + 2 * PHDRL) { /* split buffer */
-       nptr = (struct lstr *)((char *)lptr + newlen + PHDRL);
-       /* Appropriate byte alignment - normally 2 byte, but on
-          sparc we need 4 byte alignment, so we always do 4 */
-       if (((unsigned)nptr & 3) != 0) { /* test four byte alignment */
-           p = (char *)nptr;
-           nptr = (struct lstr *)((((unsigned) p) & ~3) + 4);
-       }
-       nptr->len = lptr->len - ((char *)nptr - (char *)lptr);
-       lptr->len -= nptr->len;
-       nptr->nextl = lptr->nextl;    /* link in new buffer */
-       lptr->nextl->prevl = nptr;
-       lptr->nextl = nptr;
-       nptr->prevl = lptr;
-       nptr->used = 0;
-    }
-    memcpy(&lptr->line,newl,newlen);
-    lptr->used = 1;                  /* mark line used */
-    slptr = lptr;                    /* save as stored line */
+   struct lstr *nptr;               /* points to next line */
+   char *p;
+
+   lptr = slptr;                    /* get ptr to last line stored */
+   lptr = lptr->nextl;              /* advance pointer */
+   if ((char *)lptr-pool+newlen+PHDRL > POOLEN) { /* not enough room */
+       lptr->used = 0;              /* delete line */
+       lptr = (struct lstr *)pool;   /* start at beginning of buffer */
+   }
+   while (lptr->len < newlen+PHDRL) { /* concatenate buffers */
+       nptr = lptr->nextl;          /* point to next line */
+       lptr->nextl = nptr->nextl;    /* unlink it from list */
+       nptr->nextl->prevl = lptr;
+       lptr->len += nptr->len;
+   }
+   if (lptr->len > newlen + 2 * PHDRL) { /* split buffer */
+       nptr = (struct lstr *)((char *)lptr + newlen + PHDRL);
+       /* Appropriate byte alignment - normally 2 byte, but on
+         sparc we need 4 byte alignment, so we always do 4 */
+       if (((unsigned)nptr & 3) != 0) { /* test four byte alignment */
+          p = (char *)nptr;
+          nptr = (struct lstr *)((((unsigned) p) & ~3) + 4);
+       }
+       nptr->len = lptr->len - ((char *)nptr - (char *)lptr);
+       lptr->len -= nptr->len;
+       nptr->nextl = lptr->nextl;    /* link in new buffer */
+       lptr->nextl->prevl = nptr;
+       lptr->nextl = nptr;
+       nptr->prevl = lptr;
+       nptr->used = 0;
+   }
+   memcpy(&lptr->line,newl,newlen);
+   lptr->used = 1;                  /* mark line used */
+   slptr = lptr;                    /* save as stored line */
 }
 
 #ifdef DEBUGOUT
@@ -761,21 +756,21 @@ dump(struct lstr *ptr, char *msg)
 static void
 t_honk_horn()
 {
-    t_send(t_honk);
+   t_send(t_honk);
 }
 
 /* Insert line on terminal */
 static void
 t_insert_line()
 {
-    asinsl();
+   asinsl();
 }
 
 /* Delete line from terminal */
 static void
 t_delete_line()
 {
-    asdell();
+   asdell();
 }
 
 /* clear line from pos to width */
@@ -789,7 +784,7 @@ t_clrline(int pos, int width)
  *  ESC to smap table */
 static void add_esc_smap(char *str, int func)
 {
-   char buf[100];
+   char buf[1000];
    buf[0] = 0x1B;                    /* esc */
    bstrncpy(buf+1, str, sizeof(buf)-1);
    add_smap(buf, func);
@@ -905,13 +900,6 @@ static void rawmode(FILE *input)
    add_esc_smap("[4~",  F_EOF);
    add_esc_smap("f",    F_NXTWRD);
    add_esc_smap("b",    F_PRVWRD);
-
-
-#ifdef needed
-   for (i=301; i<600; i++) {
-      char_map[i] = i;               /* setup IBM function codes */
-   }
-#endif
 }
 
 
@@ -943,31 +931,20 @@ static int t_getch(void)
    return (int)c;   
 }
     
-#ifdef xxx
-
-/* window_size -- Return window height and width to caller. */
-static int window_size(int *height, int *width)        /* /window_size/ */
-{
-   *width = tgetnum("co") - 1;
-   *height = tgetnum("li");
-   return 1;
-}
-#endif
-
 /* Send message to terminal - primitive routine */
 void
-t_sendl(char *msg,int len)
+t_sendl(char *msg, int len)
 {
-    write(1, msg, len);
+   write(1, msg, len);
 }
 
 void
 t_send(char *msg)
 {
-    if (msg == NULL) {
-       return;
-    }
-    t_sendl(msg, strlen(msg));   /* faster than one char at time */
+   if (msg == NULL) {
+      return;
+   }
+   t_sendl(msg, strlen(msg));   /* faster than one char at time */
 }
 
 /* Send single character to terminal - primitive routine - */
@@ -1015,22 +992,22 @@ void trapctlc()
 /* ASCLRL() -- Clear to end of line from current position */
 static void asclrl(int pos, int width) 
 {
-    int i;
+   int i;
 
-    if (t_cl) {
-       t_send(t_cl);                 /* use clear to eol function */
-       return;
-    }
-    if (pos==1 && linsdel_ok) {
-       t_delete_line();              /* delete line */
-       t_insert_line();              /* reinsert it */
-       return;
-    }
-    for (i=1; i<=width-pos+1; i++)
-        t_char(' ');                  /* last resort, blank it out */
-    for (i=1; i<=width-pos+1; i++)    /* backspace to original position */
-       t_char(0x8);
-    return;
+   if (t_cl) {
+       t_send(t_cl);                /* use clear to eol function */
+       return;
+   }
+   if (pos==1 && linsdel_ok) {
+       t_delete_line();             /* delete line */
+       t_insert_line();             /* reinsert it */
+       return;
+   }
+   for (i=1; i<=width-pos+1; i++)
+       t_char(' ');                  /* last resort, blank it out */
+   for (i=1; i<=width-pos+1; i++)    /* backspace to original position */
+       t_char(0x8);
+   return;
   
 }
 
index c0ebc39de321eae58f7b709abdcdb8cc32e969ed..9fbc00dc2c1b846a0a7b55cc84a6792135a8aaf7 100644 (file)
@@ -1,9 +1,9 @@
 /* */
 #undef  VERSION
-#define VERSION "1.34.2"
+#define VERSION "1.34.3"
 #define VSTRING "1"
-#define BDATE   "24 Apr 2004"
-#define LSMDATE "24Apr04"
+#define BDATE   "27 Apr 2004"
+#define LSMDATE "27Apr04"
 
 /* Debug flags */
 #undef  DEBUG