Fix input formatting and add a directive.

This commit is contained in:
Ray Hayes 2016-10-18 18:08:30 -07:00
parent 78306c910d
commit f5c9367145
4 changed files with 19 additions and 2 deletions

View File

@ -30,6 +30,7 @@
#define lstat w32_stat
#define mkdir w32_mkdir
#define chdir w32_chdir
#define getcwd w32_getcwd
struct w32_stat {
dev_t st_dev; /* ID of device containing file */

View File

@ -53,6 +53,7 @@ int w32_isatty(int fd);
FILE* w32_fdopen(int fd, const char *mode);
int w32_mkdir(const char *pathname, unsigned short mode);
int w32_chdir(const char *dirname);
char *w32_getcwd(char *buffer, int maxlen);
/*common i/o*/
#define fcntl(a,b,...) w32_fcntl((a), (b), __VA_ARGS__)

View File

@ -437,6 +437,19 @@ int w32_chdir(const char *dirname) {
return 0;
}
char *w32_getcwd(char *buffer, int maxlen) {
wchar_t wdirname[MAX_PATH];
int needed;
wchar_t *wpwd = _wgetcwd(wdirname, MAX_PATH);
if ((needed = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wdirname, -1, NULL, 0, NULL, NULL)) == 0 ||
WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wdirname, -1, buffer, needed, NULL, NULL) != needed)
fatal("failed to covert input arguments");
return buffer;
}
int
w32_isatty(int fd) {
struct w32_io* pio;

6
sftp.c
View File

@ -2357,8 +2357,10 @@ main(int argc, char **argv)
addargs(&args, "\"-oClearAllForwardings yes\"");
ll = SYSLOG_LEVEL_INFO;
infile = stdin;
_setmode(_fileno(infile), O_U16TEXT);
#ifdef WINDOWS
_setmode(_fileno(stdin), O_U16TEXT);
#endif
infile = stdin;
while ((ch = getopt(argc, argv,
"1246afhpqrvCc:D:i:l:o:s:S:b:B:F:P:R:")) != -1) {