aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2003-08-08 20:20:49 +0000
committerBruce Momjian <bruce@momjian.us>2003-08-08 20:20:49 +0000
commit3b2440ebec237d39619d5ad083a7818f016ae5a9 (patch)
tree6642415158cc11b4c1188a1095be2af6eaaffeda
parent635d00ecea111cf316fcd430159012f39402403a (diff)
downloadpostgresql-3b2440ebec237d39619d5ad083a7818f016ae5a9.tar.gz
postgresql-3b2440ebec237d39619d5ad083a7818f016ae5a9.zip
Remove simple_prompt from /contrib C files, now that it is in /port.
They had the old versions anyway.
-rw-r--r--contrib/dbase/dbf2pg.c109
-rw-r--r--contrib/vacuumlo/vacuumlo.c111
2 files changed, 1 insertions, 219 deletions
diff --git a/contrib/dbase/dbf2pg.c b/contrib/dbase/dbf2pg.c
index d679eed1ad8..294dcd8689b 100644
--- a/contrib/dbase/dbf2pg.c
+++ b/contrib/dbase/dbf2pg.c
@@ -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)
{
diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
index 3db7cb9c713..3a111afca2a 100644
--- a/contrib/vacuumlo/vacuumlo.c
+++ b/contrib/vacuumlo/vacuumlo.c
@@ -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.