readpass.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef READPASS_H_
  2. #define READPASS_H_
  3. /* Avoid namespace collisions with other "readpass" functions. */
  4. #ifdef readpass
  5. #undef readpass
  6. #endif
  7. #define readpass libcperciva_readpass
  8. /**
  9. * readpass(passwd, prompt, confirmprompt, devtty):
  10. * If ${devtty} is 0, read a password from stdin. If ${devtty} is 1, read a
  11. * password from /dev/tty if possible; if not, read from stdin. If ${devtty}
  12. * is 2, read a password from /dev/tty if possible; if not, exit with an error.
  13. * If reading from a tty (either /dev/tty or stdin), disable echo and prompt
  14. * the user by printing ${prompt} to stderr. If ${confirmprompt} is non-NULL,
  15. * read a second password (prompting if a terminal is being used) and repeat
  16. * until the user enters the same password twice. Return the password as a
  17. * malloced NUL-terminated string via ${passwd}.
  18. */
  19. int readpass(char **, const char *, const char *, int);
  20. /**
  21. * readpass_file(passwd, filename):
  22. * Read a passphrase from ${filename} and return it as a malloced
  23. * NUL-terminated string via ${passwd}. Print an error and fail if the file
  24. * is 2048 characters or more, or if it contains any newline \n or \r\n
  25. * characters other than at the end of the file. Do not include the \n or
  26. * \r\n characters in the passphrase.
  27. */
  28. int readpass_file(char **, const char *);
  29. #endif /* !READPASS_H_ */