|
5 | 5 | * Implements the basic DB functions used by the archiver.
|
6 | 6 | *
|
7 | 7 | * IDENTIFICATION
|
8 |
| - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.34 2002/07/04 15:35:07 momjian Exp $ |
| 8 | + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.35 2002/07/06 20:12:30 momjian Exp $ |
9 | 9 | *
|
10 | 10 | *-------------------------------------------------------------------------
|
11 | 11 | */
|
@@ -37,114 +37,6 @@ static char *_sendSQLLine(ArchiveHandle *AH, char *qry, char *eos);
|
37 | 37 | static char *_sendCopyLine(ArchiveHandle *AH, char *qry, char *eos);
|
38 | 38 |
|
39 | 39 |
|
40 |
| -/* |
41 |
| - * simple_prompt --- borrowed from psql |
42 |
| - * |
43 |
| - * Generalized function especially intended for reading in usernames and |
44 |
| - * password interactively. Reads from /dev/tty or stdin/stderr. |
45 |
| - * |
46 |
| - * prompt: The prompt to print |
47 |
| - * maxlen: How many characters to accept |
48 |
| - * echo: Set to false if you want to hide what is entered (for passwords) |
49 |
| - * |
50 |
| - * Returns a malloc()'ed string with the input (w/o trailing newline). |
51 |
| - */ |
52 |
| -static bool prompt_state = false; |
53 |
| - |
54 |
| -char * |
55 |
| -simple_prompt(const char *prompt, int maxlen, bool echo) |
56 |
| -{ |
57 |
| - int length; |
58 |
| - char *destination; |
59 |
| - FILE *termin, |
60 |
| - *termout; |
61 |
| - |
62 |
| -#ifdef HAVE_TERMIOS_H |
63 |
| - struct termios t_orig, |
64 |
| - t; |
65 |
| -#endif |
66 |
| - |
67 |
| - destination = (char *) malloc(maxlen + 2); |
68 |
| - if (!destination) |
69 |
| - return NULL; |
70 |
| - |
71 |
| - prompt_state = true; /* disable SIGINT */ |
72 |
| - |
73 |
| - /* |
74 |
| - * Do not try to collapse these into one "w+" mode file. Doesn't work |
75 |
| - * on some platforms (eg, HPUX 10.20). |
76 |
| - */ |
77 |
| - termin = fopen("/dev/tty", "r"); |
78 |
| - termout = fopen("/dev/tty", "w"); |
79 |
| - if (!termin || !termout) |
80 |
| - { |
81 |
| - if (termin) |
82 |
| - fclose(termin); |
83 |
| - if (termout) |
84 |
| - fclose(termout); |
85 |
| - termin = stdin; |
86 |
| - termout = stderr; |
87 |
| - } |
88 |
| - |
89 |
| -#ifdef HAVE_TERMIOS_H |
90 |
| - if (!echo) |
91 |
| - { |
92 |
| - tcgetattr(fileno(termin), &t); |
93 |
| - t_orig = t; |
94 |
| - t.c_lflag &= ~ECHO; |
95 |
| - tcsetattr(fileno(termin), TCSAFLUSH, &t); |
96 |
| - } |
97 |
| -#endif |
98 |
| - |
99 |
| - if (prompt) |
100 |
| - { |
101 |
| - fputs(gettext(prompt), termout); |
102 |
| - fflush(termout); |
103 |
| - } |
104 |
| - |
105 |
| - if (fgets(destination, maxlen, termin) == NULL) |
106 |
| - destination[0] = '\0'; |
107 |
| - |
108 |
| - length = strlen(destination); |
109 |
| - if (length > 0 && destination[length - 1] != '\n') |
110 |
| - { |
111 |
| - /* eat rest of the line */ |
112 |
| - char buf[128]; |
113 |
| - int buflen; |
114 |
| - |
115 |
| - do |
116 |
| - { |
117 |
| - if (fgets(buf, sizeof(buf), termin) == NULL) |
118 |
| - break; |
119 |
| - buflen = strlen(buf); |
120 |
| - } while (buflen > 0 && buf[buflen - 1] != '\n'); |
121 |
| - } |
122 |
| - |
123 |
| - if (length > 0 && destination[length - 1] == '\n') |
124 |
| - /* remove trailing newline */ |
125 |
| - destination[length - 1] = '\0'; |
126 |
| - |
127 |
| -#ifdef HAVE_TERMIOS_H |
128 |
| - if (!echo) |
129 |
| - { |
130 |
| - tcsetattr(fileno(termin), TCSAFLUSH, &t_orig); |
131 |
| - fputs("\n", termout); |
132 |
| - fflush(termout); |
133 |
| - } |
134 |
| -#endif |
135 |
| - |
136 |
| - if (termin != stdin) |
137 |
| - { |
138 |
| - fclose(termin); |
139 |
| - fclose(termout); |
140 |
| - } |
141 |
| - |
142 |
| - prompt_state = false; /* SIGINT okay again */ |
143 |
| - |
144 |
| - return destination; |
145 |
| -} |
146 |
| - |
147 |
| - |
148 | 40 | static int
|
149 | 41 | _parse_version(ArchiveHandle *AH, const char *versionString)
|
150 | 42 | {
|
|
0 commit comments