Skip to content

Commit

Permalink
Fix read_stdin() for MingGW
Browse files Browse the repository at this point in the history
It doesn't correctly implement the 'hidden' option, but it'll do for now.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Feb 6, 2014
1 parent 28b9007 commit 0907e85
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions main.c
Expand Up @@ -43,12 +43,14 @@
#include <pwd.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <termios.h>
#ifdef LIBPROXY_HDR
#include LIBPROXY_HDR
#endif
#include <getopt.h>
#include <time.h>
#ifndef _WIN32
#include <termios.h>
#endif

#include "openconnect-internal.h"

Expand Down Expand Up @@ -371,16 +373,18 @@ static void usage(void)

static void read_stdin(char **string, int hidden)
{
struct termios t;
char *c = malloc(1025), *ret;
int fd = fileno(stdin);

if (!c) {
fprintf(stderr, _("Allocation failure for string from stdin\n"));
exit(1);
}

#ifndef _WIN32
if (hidden) {
struct termios t;
int fd = fileno(stdin);

tcgetattr(fd, &t);
t.c_lflag &= ~ECHO;
tcsetattr(fd, TCSANOW, &t);
Expand All @@ -391,6 +395,7 @@ static void read_stdin(char **string, int hidden)
tcsetattr(fd, TCSANOW, &t);
fprintf(stderr, "\n");
} else
#endif
ret = fgets(c, 1025, stdin);

if (!ret) {
Expand Down

0 comments on commit 0907e85

Please sign in to comment.