utf8proc: Update from 2.1.0 to 2.1.1
[termux-packages] / packages / unrar / getpass.patch
CommitLineData
973267fc
LP
1diff -uNr unrar.mod/consio.cpp unrar.mod2/consio.cpp
2--- unrar.mod/consio.cpp 2017-08-11 16:56:22.000000000 +0300
3+++ unrar.mod2/consio.cpp 2017-09-14 20:34:17.247733000 +0300
4@@ -1,6 +1,10 @@
5 #include "rar.hpp"
6 #include "log.cpp"
7
8+// For getpass()
9+#include <termios.h>
10+#include <readline/readline.h>
11+
12 static MESSAGE_TYPE MsgStream=MSG_STDOUT;
13 static RAR_CHARSET RedirectCharset=RCH_DEFAULT;
14
15@@ -57,6 +61,32 @@
16
17
18 #ifndef SILENT
19+#ifdef __ANDROID__
8da95062 20+static char* getpass(const char *prompt) {
973267fc
LP
21+ struct termios term_old, term_new;
22+ int nread;
23+
24+ /* Turn echoing off and fail if we can't. */
25+ if (tcgetattr (0, &term_old) != 0) {
26+ return NULL;
27+ }
28+
29+ term_new = term_old;
30+ term_new.c_lflag &= ~ECHO;
31+
32+ if (tcsetattr (0, TCSAFLUSH, &term_new) != 0) {
33+ return NULL;
34+ }
35+
36+ /* Read the password. */
37+ char *password = readline(prompt);
38+
39+ /* Restore terminal. */
40+ (void) tcsetattr (0, TCSAFLUSH, &term_old);
41+
42+ return password;
43+}
44+#endif
45 static void cvt_wprintf(FILE *dest,const wchar *fmt,va_list arglist)
46 {
47 // This buffer is for format string only, not for entire output,