try to discover if there is input waiting on stdin

otherwise give the user a hint
resolves #12
This commit is contained in:
Klas Lindfors
2015-01-12 16:24:47 +01:00
parent 98320c2c0d
commit b1a673b1f9
3 changed files with 38 additions and 0 deletions
+17
View File
@@ -57,6 +57,23 @@ FILE *open_file(const char *file_name, int mode) {
return file;
}
bool input_ready(FILE *file) {
int fd = fileno(file);
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 0;
if(select(fd + 1, &rfds, NULL, NULL, &tv) == 1) {
return true;
}
return false;
}
unsigned char get_algorithm(EVP_PKEY *key) {
int type = EVP_PKEY_type(key->type);
switch(type) {