On Wed, 2014-07-02 at 12:36 -0700, Kevin Cernekee wrote: > On Wed, Jul 2, 2014 at 12:08 PM, Jason Wessel > <jason.wessel at windriver.com> wrote: > > static void read_stdin(char **string, int hidden) > > { > > char *c = malloc(1025), *ret; > > @@ -417,8 +450,12 @@ static void read_stdin(char **string, int hidden) > > exit(1); > > } > > > > -#ifndef _WIN32 > > if (hidden) { > > +#ifdef _WIN32 > > + disable_echo(); > > + ret = fgets(c, 1025, stdin); > > + restore_echo(); > > +#else /* ! _WIN32 */ > > struct termios t; > > int fd = fileno(stdin); > > > > @@ -431,8 +468,8 @@ static void read_stdin(char **string, int hidden) > > t.c_lflag |= ECHO; > > tcsetattr(fd, TCSANOW, &t); > > fprintf(stderr, "\n"); > > - } else > > #endif > > It would be nicer if we could just call {disable,restore}_echo() from > this function without having to worry about WIN32 / !WIN32. Right. We could shift the equivalent POSIX code out into matching disable_echo() and restore_echo() functions and lose the #ifdef in the middle of the function, quite happily. > Maybe if enough of these special cases accumulate, we could wind up > with all of the Windows implementations/stubs in windows.c, and the > UNIX/Linux versions in unix.c. That could also capture the > differences in the syslog and --background logic. > > David, what do you think? Yeah, maybe. Then again, there's plenty of scope for reducing the amount of ifdefs in the code already. Jason's patch also adds more than it needs to ? for example, the additional <wtypes.h> amd <wincon.h> includes could be put in an #else clause for the existing #ifndef _WIN32 in the includes a few lines further up, and the new disable_echo() and restore_echo() functions could possibly have lived inside an existing conditional block too. I'd still like to see a GUI version for Windows though; if you can invoke the DLL from a scripting language surely that can't be particularly hard to produce? -- dwmw2 -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 5745 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/openconnect-devel/attachments/20140704/8384dfab/attachment.bin>