/* * Secure X Message Passing Library tools. * * (c) Alexander Vdolainen 2016 * * libsxmp is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * libsxmp is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see ."; * * support functions for sxmp tools */ #include #include #define __USE_GNU #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int passkey_promt(char *passbuf, size_t p_len, int cnf, void *priv) { char *promt = (char *)priv; int sym, len = 0; struct termios tio; /* print promt */ fprintf(stdout, "%s", promt); fflush(stdout); tcgetattr(STDIN_FILENO, &tio); /* disable echo */ tio.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &tio); while((sym = fgetc(stdin)) != '\n') { passbuf[len] = sym; if(len + 1 == p_len) break; else len++; } /* enable again */ tio.c_lflag |= (ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &tio); fprintf(stdout, "\n"); return SXT_SUCCESS; }