]> granicus.if.org Git - postgresql/commitdiff
Remove simple_prompt from /contrib C files, now that it is in /port.
authorBruce Momjian <bruce@momjian.us>
Fri, 8 Aug 2003 20:20:49 +0000 (20:20 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 8 Aug 2003 20:20:49 +0000 (20:20 +0000)
They had the old versions anyway.

contrib/dbase/dbf2pg.c
contrib/vacuumlo/vacuumlo.c

index d679eed1ad895652ad49a75f6787abcbc7c395cc..294dcd8689b78b4196f318d92f1cba1a54c22a8b 100644 (file)
@@ -65,7 +65,6 @@ char     *convert_charset(char *string);
 void           usage(void);
 unsigned int isinteger(char *);
 
-char      *simple_prompt(const char *prompt, int maxlen, bool echo);
 
 
 unsigned int
@@ -565,114 +564,6 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
 }
 
 
-/*
- * simple_prompt  --- borrowed from psql
- *
- * Generalized function especially intended for reading in usernames and
- * password interactively. Reads from /dev/tty or stdin/stderr.
- *
- * prompt:             The prompt to print
- * maxlen:             How many characters to accept
- * echo:               Set to false if you want to hide what is entered (for passwords)
- *
- * Returns a malloc()'ed string with the input (w/o trailing newline).
- */
-static bool prompt_state = false;
-
-char *
-simple_prompt(const char *prompt, int maxlen, bool echo)
-{
-       int                     length;
-       char       *destination;
-       FILE       *termin,
-                          *termout;
-
-#ifdef HAVE_TERMIOS_H
-       struct termios t_orig,
-                               t;
-#endif
-
-       destination = (char *) malloc(maxlen + 2);
-       if (!destination)
-               return NULL;
-
-       prompt_state = true;            /* disable SIGINT */
-
-       /*
-        * Do not try to collapse these into one "w+" mode file. Doesn't work
-        * on some platforms (eg, HPUX 10.20).
-        */
-       termin = fopen("/dev/tty", "r");
-       termout = fopen("/dev/tty", "w");
-       if (!termin || !termout)
-       {
-               if (termin)
-                       fclose(termin);
-               if (termout)
-                       fclose(termout);
-               termin = stdin;
-               termout = stderr;
-       }
-
-#ifdef HAVE_TERMIOS_H
-       if (!echo)
-       {
-               tcgetattr(fileno(termin), &t);
-               t_orig = t;
-               t.c_lflag &= ~ECHO;
-               tcsetattr(fileno(termin), TCSAFLUSH, &t);
-       }
-#endif
-
-       if (prompt)
-       {
-               fputs(gettext(prompt), termout);
-               fflush(termout);
-       }
-
-       if (fgets(destination, maxlen, termin) == NULL)
-               destination[0] = '\0';
-
-       length = strlen(destination);
-       if (length > 0 && destination[length - 1] != '\n')
-       {
-               /* eat rest of the line */
-               char            buf[128];
-               int                     buflen;
-
-               do
-               {
-                       if (fgets(buf, sizeof(buf), termin) == NULL)
-                               break;
-                       buflen = strlen(buf);
-               } while (buflen > 0 && buf[buflen - 1] != '\n');
-       }
-
-       if (length > 0 && destination[length - 1] == '\n')
-               /* remove trailing newline */
-               destination[length - 1] = '\0';
-
-#ifdef HAVE_TERMIOS_H
-       if (!echo)
-       {
-               tcsetattr(fileno(termin), TCSAFLUSH, &t_orig);
-               fputs("\n", termout);
-               fflush(termout);
-       }
-#endif
-
-       if (termin != stdin)
-       {
-               fclose(termin);
-               fclose(termout);
-       }
-
-       prompt_state = false;           /* SIGINT okay again */
-
-       return destination;
-}
-
-
 int
 main(int argc, char **argv)
 {
index 3db7cb9c7133f2a0ad51aa8fd19834f1c6346df0..3a111afca2a4683c6e5414ea4ceb922535416084 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.22 2003/08/04 22:03:39 tgl Exp $
+ *       $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.23 2003/08/08 20:20:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -44,118 +44,9 @@ struct _param
 };
 
 int                    vacuumlo(char *, struct _param *);
-char      *simple_prompt(const char *prompt, int, int);
 void           usage(void);
 
 
-/*
- * simple_prompt
- *
- * Generalized function especially intended for reading in usernames and
- * password interactively. Reads from /dev/tty or stdin/stderr.
- *
- * prompt:             The prompt to print
- * maxlen:             How many characters to accept
- * echo:               Set to 0 if you want to hide what is entered (for passwords)
- *
- * Returns a malloc()'ed string with the input (w/o trailing newline).
- */
-static int     prompt_state = 0;
-
-char *
-simple_prompt(const char *prompt, int maxlen, int echo)
-{
-       int                     length;
-       char       *destination;
-       FILE       *termin,
-                          *termout;
-
-#ifdef HAVE_TERMIOS_H
-       struct termios t_orig,
-                               t;
-#endif
-
-       destination = (char *) malloc(maxlen + 2);
-       if (!destination)
-               return NULL;
-
-       prompt_state = 1;                       /* disable SIGINT */
-
-       /*
-        * Do not try to collapse these into one "w+" mode file. Doesn't work
-        * on some platforms (eg, HPUX 10.20).
-        */
-       termin = fopen("/dev/tty", "r");
-       termout = fopen("/dev/tty", "w");
-       if (!termin || !termout)
-       {
-               if (termin)
-                       fclose(termin);
-               if (termout)
-                       fclose(termout);
-               termin = stdin;
-               termout = stderr;
-       }
-
-#ifdef HAVE_TERMIOS_H
-       if (!echo)
-       {
-               tcgetattr(fileno(termin), &t);
-               t_orig = t;
-               t.c_lflag &= ~ECHO;
-               tcsetattr(fileno(termin), TCSAFLUSH, &t);
-       }
-#endif
-
-       if (prompt)
-       {
-               fputs(prompt, termout);
-               fflush(termout);
-       }
-
-       if (fgets(destination, maxlen, termin) == NULL)
-               destination[0] = '\0';
-
-       length = strlen(destination);
-       if (length > 0 && destination[length - 1] != '\n')
-       {
-               /* eat rest of the line */
-               char            buf[128];
-               int                     buflen;
-
-               do
-               {
-                       if (fgets(buf, sizeof(buf), termin) == NULL)
-                               break;
-                       buflen = strlen(buf);
-               } while (buflen > 0 && buf[buflen - 1] != '\n');
-       }
-
-       if (length > 0 && destination[length - 1] == '\n')
-               /* remove trailing newline */
-               destination[length - 1] = '\0';
-
-#ifdef HAVE_TERMIOS_H
-       if (!echo)
-       {
-               tcsetattr(fileno(termin), TCSAFLUSH, &t_orig);
-               fputs("\n", termout);
-               fflush(termout);
-       }
-#endif
-
-       if (termin != stdin)
-       {
-               fclose(termin);
-               fclose(termout);
-       }
-
-       prompt_state = 0;                       /* SIGINT okay again */
-
-       return destination;
-}
-
-
 
 /*
  * This vacuums LOs of one database. It returns 0 on success, -1 on failure.