[ create a new paste ] login | about

Link: http://codepad.org/RXUgiB5Y    [ raw code | fork ]

C, pasted on Sep 12:
#ifndef _GETPASSWORD_H
#define _GETPASSWORD_H

#ifdef __cplusplus
# include <cstdio>
# include <cstdlib>
# include <cstring>
#else
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#endif

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(WINDOWS)\
    || defined(__WINDOWS__)
# ifndef WINDOWS
#  define WINDOWS
# endif
#elif defined(unix) || defined(UNIX) || defined(__UNIX__) || defined(POSIX)    \
      || defined(__POSIX__) || defined(CYGWIN)
# ifndef POSIX
#  define POSIX
# endif
#endif

#if defined(WINDOWS)
# include <windows.h>
#elif defined(POSIX)
# include <unistd.h>
# include <termios.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \brief Read a password without character echoing.
 * \note Input ends only when an EOF or LF character is encountered.
 * \param prompt Password prompt, if NULL "Password: " is used. If empty ("")
 * no prompt is used.
 * \param buffer Somewhere to store the password. This will be made larger if
 * necessary, although the enlargening operation will be slow. If NULL, the
 * function fails.
 * \param sz Pointer to the size of buffer. This will be increased if necessary.
 * If sz is a NULL pointer the function fails.
 * \param replacement Character to print instead of printing input characters.
 * If this is '\0'; none is used.
 * \return 0 on success or -1 on error.
 */
int getpassword(const char* prompt, char** buffer, unsigned* sz, char replacement);

#ifdef __cplusplus
}
#endif

#endif /* ! _GETPASSWORD_H */


Create a new paste based on this one


Comments: