aboutsummaryrefslogtreecommitdiff
path: root/lib/getpass.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-11-10 09:18:25 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-11-10 09:18:25 +0000
commita5b2eb7962524aad65f07c5755920379af5717e3 (patch)
tree4a21cc61a7b3cfe1c1a96fc69f37e6daf488af60 /lib/getpass.c
parent78423c5899c3927fc038c0f8ceccce9245c5043d (diff)
new interface, updated Angus' license, dependent on HAVE_GETPASS_R
Diffstat (limited to 'lib/getpass.c')
-rw-r--r--lib/getpass.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/getpass.c b/lib/getpass.c
index 081128684..f5833cc32 100644
--- a/lib/getpass.c
+++ b/lib/getpass.c
@@ -4,8 +4,9 @@
* Redistribution and use are freely permitted provided that:
*
* 1) This header remain in tact.
- * 2) The prototype for getpass is not changed from:
- * int getpass_r(const char *prompt, char *buffer, int buflen)
+ * 2) The prototypes for getpass and getpass_r are not changed from:
+ * char *getpass(const char *prompt)
+ * char *getpass_r(const char *prompt, char* buffer, int buflen)
* 3) This source code is not used outside of this(getpass.c) file.
* 4) Any changes to this(getpass.c) source code are made publicly available.
*
@@ -34,11 +35,13 @@
* Daniel Stenberg <daniel@haxx.se>
*/
-#ifndef WIN32
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
+#ifndef HAVE_GETPASS_R
+
+#ifndef WIN32
#ifdef HAVE_TERMIOS_H
# if !defined(HAVE_TCGETATTR) && !defined(HAVE_TCSETATTR)
# undef HAVE_TERMIOS_H
@@ -68,7 +71,7 @@
# define perror(x) fprintf(stderr, "Error in: %s\n", x)
#endif
-int getpass_r(const char *prompt, char *buffer, int buflen)
+char *getpass_r(const char *prompt, char *buffer, int buflen)
{
FILE *infp;
FILE *outfp;
@@ -176,12 +179,12 @@ int getpass_r(const char *prompt, char *buffer, int buflen)
signal(SIGTSTP, sigtstp);
#endif
- return 0; /* we always return success */
+ return buffer; /* we always return success */
}
#else /* WIN32 */
#include <stdio.h>
#include <conio.h>
-int getpass_r(const char *prompt, char *buffer, int buflen)
+char *getpass_r(const char *prompt, char *buffer, int buflen)
{
int i;
printf("%s", prompt);
@@ -197,7 +200,17 @@ int getpass_r(const char *prompt, char *buffer, int buflen)
if (i==buflen)
buffer[buflen-1]=0;
- return 0; /* we always return success */
+ return buffer; /* we always return success */
}
#endif
+#endif /* ifndef HAVE_GETPASS_R */
+
+#if 0
+/* for consistensy, here's the old-style function: */
+char *getpass(const char *prompt)
+{
+ static char buf[256];
+ return getpass_r(prompt, buf, sizeof(buf));
+}
+#endif