Skip to content

Commit 3b2440e

Browse files
committed
Remove simple_prompt from /contrib C files, now that it is in /port.
They had the old versions anyway.
1 parent 635d00e commit 3b2440e

File tree

2 files changed

+1
-219
lines changed

2 files changed

+1
-219
lines changed

contrib/dbase/dbf2pg.c

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ char *convert_charset(char *string);
6565
void usage(void);
6666
unsigned int isinteger(char *);
6767

68-
char *simple_prompt(const char *prompt, int maxlen, bool echo);
6968

7069

7170
unsigned int
@@ -565,114 +564,6 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
565564
}
566565

567566

568-
/*
569-
* simple_prompt --- borrowed from psql
570-
*
571-
* Generalized function especially intended for reading in usernames and
572-
* password interactively. Reads from /dev/tty or stdin/stderr.
573-
*
574-
* prompt: The prompt to print
575-
* maxlen: How many characters to accept
576-
* echo: Set to false if you want to hide what is entered (for passwords)
577-
*
578-
* Returns a malloc()'ed string with the input (w/o trailing newline).
579-
*/
580-
static bool prompt_state = false;
581-
582-
char *
583-
simple_prompt(const char *prompt, int maxlen, bool echo)
584-
{
585-
int length;
586-
char *destination;
587-
FILE *termin,
588-
*termout;
589-
590-
#ifdef HAVE_TERMIOS_H
591-
struct termios t_orig,
592-
t;
593-
#endif
594-
595-
destination = (char *) malloc(maxlen + 2);
596-
if (!destination)
597-
return NULL;
598-
599-
prompt_state = true; /* disable SIGINT */
600-
601-
/*
602-
* Do not try to collapse these into one "w+" mode file. Doesn't work
603-
* on some platforms (eg, HPUX 10.20).
604-
*/
605-
termin = fopen("/dev/tty", "r");
606-
termout = fopen("/dev/tty", "w");
607-
if (!termin || !termout)
608-
{
609-
if (termin)
610-
fclose(termin);
611-
if (termout)
612-
fclose(termout);
613-
termin = stdin;
614-
termout = stderr;
615-
}
616-
617-
#ifdef HAVE_TERMIOS_H
618-
if (!echo)
619-
{
620-
tcgetattr(fileno(termin), &t);
621-
t_orig = t;
622-
t.c_lflag &= ~ECHO;
623-
tcsetattr(fileno(termin), TCSAFLUSH, &t);
624-
}
625-
#endif
626-
627-
if (prompt)
628-
{
629-
fputs(gettext(prompt), termout);
630-
fflush(termout);
631-
}
632-
633-
if (fgets(destination, maxlen, termin) == NULL)
634-
destination[0] = '\0';
635-
636-
length = strlen(destination);
637-
if (length > 0 && destination[length - 1] != '\n')
638-
{
639-
/* eat rest of the line */
640-
char buf[128];
641-
int buflen;
642-
643-
do
644-
{
645-
if (fgets(buf, sizeof(buf), termin) == NULL)
646-
break;
647-
buflen = strlen(buf);
648-
} while (buflen > 0 && buf[buflen - 1] != '\n');
649-
}
650-
651-
if (length > 0 && destination[length - 1] == '\n')
652-
/* remove trailing newline */
653-
destination[length - 1] = '\0';
654-
655-
#ifdef HAVE_TERMIOS_H
656-
if (!echo)
657-
{
658-
tcsetattr(fileno(termin), TCSAFLUSH, &t_orig);
659-
fputs("\n", termout);
660-
fflush(termout);
661-
}
662-
#endif
663-
664-
if (termin != stdin)
665-
{
666-
fclose(termin);
667-
fclose(termout);
668-
}
669-
670-
prompt_state = false; /* SIGINT okay again */
671-
672-
return destination;
673-
}
674-
675-
676567
int
677568
main(int argc, char **argv)
678569
{

contrib/vacuumlo/vacuumlo.c

Lines changed: 1 addition & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.22 2003/08/04 22:03:39 tgl Exp $
11+
* $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.23 2003/08/08 20:20:49 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -44,118 +44,9 @@ struct _param
4444
};
4545

4646
int vacuumlo(char *, struct _param *);
47-
char *simple_prompt(const char *prompt, int, int);
4847
void usage(void);
4948

5049

51-
/*
52-
* simple_prompt
53-
*
54-
* Generalized function especially intended for reading in usernames and
55-
* password interactively. Reads from /dev/tty or stdin/stderr.
56-
*
57-
* prompt: The prompt to print
58-
* maxlen: How many characters to accept
59-
* echo: Set to 0 if you want to hide what is entered (for passwords)
60-
*
61-
* Returns a malloc()'ed string with the input (w/o trailing newline).
62-
*/
63-
static int prompt_state = 0;
64-
65-
char *
66-
simple_prompt(const char *prompt, int maxlen, int echo)
67-
{
68-
int length;
69-
char *destination;
70-
FILE *termin,
71-
*termout;
72-
73-
#ifdef HAVE_TERMIOS_H
74-
struct termios t_orig,
75-
t;
76-
#endif
77-
78-
destination = (char *) malloc(maxlen + 2);
79-
if (!destination)
80-
return NULL;
81-
82-
prompt_state = 1; /* disable SIGINT */
83-
84-
/*
85-
* Do not try to collapse these into one "w+" mode file. Doesn't work
86-
* on some platforms (eg, HPUX 10.20).
87-
*/
88-
termin = fopen("/dev/tty", "r");
89-
termout = fopen("/dev/tty", "w");
90-
if (!termin || !termout)
91-
{
92-
if (termin)
93-
fclose(termin);
94-
if (termout)
95-
fclose(termout);
96-
termin = stdin;
97-
termout = stderr;
98-
}
99-
100-
#ifdef HAVE_TERMIOS_H
101-
if (!echo)
102-
{
103-
tcgetattr(fileno(termin), &t);
104-
t_orig = t;
105-
t.c_lflag &= ~ECHO;
106-
tcsetattr(fileno(termin), TCSAFLUSH, &t);
107-
}
108-
#endif
109-
110-
if (prompt)
111-
{
112-
fputs(prompt, termout);
113-
fflush(termout);
114-
}
115-
116-
if (fgets(destination, maxlen, termin) == NULL)
117-
destination[0] = '\0';
118-
119-
length = strlen(destination);
120-
if (length > 0 && destination[length - 1] != '\n')
121-
{
122-
/* eat rest of the line */
123-
char buf[128];
124-
int buflen;
125-
126-
do
127-
{
128-
if (fgets(buf, sizeof(buf), termin) == NULL)
129-
break;
130-
buflen = strlen(buf);
131-
} while (buflen > 0 && buf[buflen - 1] != '\n');
132-
}
133-
134-
if (length > 0 && destination[length - 1] == '\n')
135-
/* remove trailing newline */
136-
destination[length - 1] = '\0';
137-
138-
#ifdef HAVE_TERMIOS_H
139-
if (!echo)
140-
{
141-
tcsetattr(fileno(termin), TCSAFLUSH, &t_orig);
142-
fputs("\n", termout);
143-
fflush(termout);
144-
}
145-
#endif
146-
147-
if (termin != stdin)
148-
{
149-
fclose(termin);
150-
fclose(termout);
151-
}
152-
153-
prompt_state = 0; /* SIGINT okay again */
154-
155-
return destination;
156-
}
157-
158-
15950

16051
/*
16152
* This vacuums LOs of one database. It returns 0 on success, -1 on failure.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy