mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
new interface, updated Angus' license, dependent on HAVE_GETPASS_R
This commit is contained in:
parent
78423c5899
commit
a5b2eb7962
@ -4,8 +4,9 @@
|
|||||||
* Redistribution and use are freely permitted provided that:
|
* Redistribution and use are freely permitted provided that:
|
||||||
*
|
*
|
||||||
* 1) This header remain in tact.
|
* 1) This header remain in tact.
|
||||||
* 2) The prototype for getpass is not changed from:
|
* 2) The prototypes for getpass and getpass_r are not changed from:
|
||||||
* int getpass_r(const char *prompt, char *buffer, int buflen)
|
* 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.
|
* 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.
|
* 4) Any changes to this(getpass.c) source code are made publicly available.
|
||||||
*
|
*
|
||||||
@ -34,11 +35,13 @@
|
|||||||
* Daniel Stenberg <daniel@haxx.se>
|
* Daniel Stenberg <daniel@haxx.se>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETPASS_R
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
#ifdef HAVE_TERMIOS_H
|
#ifdef HAVE_TERMIOS_H
|
||||||
# if !defined(HAVE_TCGETATTR) && !defined(HAVE_TCSETATTR)
|
# if !defined(HAVE_TCGETATTR) && !defined(HAVE_TCSETATTR)
|
||||||
# undef HAVE_TERMIOS_H
|
# undef HAVE_TERMIOS_H
|
||||||
@ -68,7 +71,7 @@
|
|||||||
# define perror(x) fprintf(stderr, "Error in: %s\n", x)
|
# define perror(x) fprintf(stderr, "Error in: %s\n", x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int getpass_r(const char *prompt, char *buffer, int buflen)
|
char *getpass_r(const char *prompt, char *buffer, int buflen)
|
||||||
{
|
{
|
||||||
FILE *infp;
|
FILE *infp;
|
||||||
FILE *outfp;
|
FILE *outfp;
|
||||||
@ -176,12 +179,12 @@ int getpass_r(const char *prompt, char *buffer, int buflen)
|
|||||||
signal(SIGTSTP, sigtstp);
|
signal(SIGTSTP, sigtstp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0; /* we always return success */
|
return buffer; /* we always return success */
|
||||||
}
|
}
|
||||||
#else /* WIN32 */
|
#else /* WIN32 */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <conio.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;
|
int i;
|
||||||
printf("%s", prompt);
|
printf("%s", prompt);
|
||||||
@ -197,7 +200,17 @@ int getpass_r(const char *prompt, char *buffer, int buflen)
|
|||||||
if (i==buflen)
|
if (i==buflen)
|
||||||
buffer[buflen-1]=0;
|
buffer[buflen-1]=0;
|
||||||
|
|
||||||
return 0; /* we always return success */
|
return buffer; /* we always return success */
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef __GETPASS_H
|
#ifndef __GETPASS_H
|
||||||
#define __GETPASS_H
|
#define __GETPASS_H
|
||||||
/*
|
/*
|
||||||
* Returning non-zero will abort the continued operation!
|
* Returning NULL will abort the continued operation!
|
||||||
*/
|
*/
|
||||||
int getpass_r(char *prompt, char* buffer, int buflen );
|
char* getpass_r(char *prompt, char* buffer, int buflen );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user