mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-21 04:54:48 +02:00
Reviewed some more Win32 macros in libssh and enabled SFTP progress meter. Not tested yet
This commit is contained in:
parent
65ccbe645c
commit
0958df5875
@ -47,8 +47,9 @@
|
|||||||
#define W32_SIGTERM 8
|
#define W32_SIGTERM 8
|
||||||
#define W32_SIGTTIN 9
|
#define W32_SIGTTIN 9
|
||||||
#define W32_SIGTTOU 10
|
#define W32_SIGTTOU 10
|
||||||
|
#define W32_SIGWINCH 11
|
||||||
|
|
||||||
#define W32_SIGMAX 11
|
#define W32_SIGMAX 12
|
||||||
|
|
||||||
/* signal action codes*/
|
/* signal action codes*/
|
||||||
#define W32_SIG_ERR -1
|
#define W32_SIG_ERR -1
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#define SIGTERM W32_SIGTERM
|
#define SIGTERM W32_SIGTERM
|
||||||
#define SIGTTIN W32_SIGTTIN
|
#define SIGTTIN W32_SIGTTIN
|
||||||
#define SIGTTOU W32_SIGTTOU
|
#define SIGTTOU W32_SIGTTOU
|
||||||
|
#define SIGWINCH W32_SIGWINCH
|
||||||
|
|
||||||
#define SIG_DFL W32_SIG_DFL
|
#define SIG_DFL W32_SIG_DFL
|
||||||
#define SIG_IGN W32_SIG_IGN
|
#define SIG_IGN W32_SIG_IGN
|
||||||
|
4
log.c
4
log.c
@ -434,7 +434,7 @@ do_log(LogLevel level, const char *fmt, va_list args)
|
|||||||
} else {
|
} else {
|
||||||
vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
|
vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
|
||||||
}
|
}
|
||||||
#ifdef WIN32_FIXME
|
#ifdef WIN32_FIXME//N
|
||||||
strncpy(fmtbuf, msgbuf, sizeof(fmtbuf));
|
strncpy(fmtbuf, msgbuf, sizeof(fmtbuf));
|
||||||
#else
|
#else
|
||||||
strnvis(fmtbuf, msgbuf, sizeof(fmtbuf),
|
strnvis(fmtbuf, msgbuf, sizeof(fmtbuf),
|
||||||
@ -449,7 +449,7 @@ do_log(LogLevel level, const char *fmt, va_list args)
|
|||||||
log_handler = tmp_handler;
|
log_handler = tmp_handler;
|
||||||
} else if (log_on_stderr) {
|
} else if (log_on_stderr) {
|
||||||
snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf);
|
snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf);
|
||||||
#ifdef WIN32_FIXME
|
#ifdef WIN32_FIXME//N
|
||||||
_write(STDERR_FILENO, msgbuf, strlen(msgbuf));
|
_write(STDERR_FILENO, msgbuf, strlen(msgbuf));
|
||||||
#else
|
#else
|
||||||
(void)write(log_stderr_fd, msgbuf, strlen(msgbuf));
|
(void)write(log_stderr_fd, msgbuf, strlen(msgbuf));
|
||||||
|
22
misc.c
22
misc.c
@ -81,15 +81,6 @@ chop(char *s)
|
|||||||
int
|
int
|
||||||
set_nonblock(int fd)
|
set_nonblock(int fd)
|
||||||
{
|
{
|
||||||
#if(0)//def WIN32_FIXME
|
|
||||||
|
|
||||||
int on = 1;
|
|
||||||
|
|
||||||
ioctlsocket(fd, FIONBIO, &on);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#else
|
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
val = fcntl(fd, F_GETFL, 0);
|
val = fcntl(fd, F_GETFL, 0);
|
||||||
@ -109,21 +100,11 @@ set_nonblock(int fd)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
#endif /* else WIN32_FIXME */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
unset_nonblock(int fd)
|
unset_nonblock(int fd)
|
||||||
{
|
{
|
||||||
#if(0)//def WIN32_FIXME
|
|
||||||
|
|
||||||
int on = 0;
|
|
||||||
|
|
||||||
ioctlsocket(fd, FIONBIO, &on);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#else
|
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
val = fcntl(fd, F_GETFL, 0);
|
val = fcntl(fd, F_GETFL, 0);
|
||||||
@ -143,7 +124,6 @@ unset_nonblock(int fd)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
@ -243,7 +223,7 @@ pwcopy(struct passwd *pw)
|
|||||||
copy->pw_class = xstrdup(pw->pw_class);
|
copy->pw_class = xstrdup(pw->pw_class);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32_FIXME
|
#ifdef WIN32_FIXME//N
|
||||||
copy -> pw_dir = (char*)_wcsdup((wchar_t*)pw->pw_dir);
|
copy -> pw_dir = (char*)_wcsdup((wchar_t*)pw->pw_dir);
|
||||||
#else
|
#else
|
||||||
copy->pw_dir = xstrdup(pw->pw_dir);
|
copy->pw_dir = xstrdup(pw->pw_dir);
|
||||||
|
2
moduli.c
2
moduli.c
@ -458,7 +458,7 @@ write_checkpoint(char *cpfile, u_int32_t lineno)
|
|||||||
logit("write_checkpoint: temp pathname too long");
|
logit("write_checkpoint: temp pathname too long");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifndef WIN32_FIXME
|
#ifndef WIN32_FIXME//N
|
||||||
//PRAGMA:TODO
|
//PRAGMA:TODO
|
||||||
if ((r = mkstemp(tmp)) == -1) {
|
if ((r = mkstemp(tmp)) == -1) {
|
||||||
logit("mkstemp(%s): %s", tmp, strerror(errno));
|
logit("mkstemp(%s): %s", tmp, strerror(errno));
|
||||||
|
26
nchan.c
26
nchan.c
@ -75,12 +75,6 @@
|
|||||||
* ACTIONS: should never update the channel states
|
* ACTIONS: should never update the channel states
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WIN32_FIXME
|
|
||||||
|
|
||||||
//void StopSocketThreads();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void chan_send_ieof1(Channel *);
|
static void chan_send_ieof1(Channel *);
|
||||||
static void chan_send_oclose1(Channel *);
|
static void chan_send_oclose1(Channel *);
|
||||||
static void chan_send_close2(Channel *);
|
static void chan_send_close2(Channel *);
|
||||||
@ -122,24 +116,6 @@ chan_rcvd_oclose1(Channel *c)
|
|||||||
{
|
{
|
||||||
debug2("channel %d: rcvd oclose", c->self);
|
debug2("channel %d: rcvd oclose", c->self);
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME. This function forces stopping all socket threads
|
|
||||||
* at next select. This workaround nivelate problem with
|
|
||||||
* infinite hangs up in below scenario:
|
|
||||||
*
|
|
||||||
* a) read select start.
|
|
||||||
* b) write select start.
|
|
||||||
* c) read select ends: SSH2_MSG_CHANNEL_CLOSE received.
|
|
||||||
* d) close input channel.
|
|
||||||
* e) now write select may never ends.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef WIN32_FIXME
|
|
||||||
|
|
||||||
//StopSocketThreads();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (c->istate) {
|
switch (c->istate) {
|
||||||
case CHAN_INPUT_WAIT_OCLOSE:
|
case CHAN_INPUT_WAIT_OCLOSE:
|
||||||
chan_set_istate(c, CHAN_INPUT_CLOSED);
|
chan_set_istate(c, CHAN_INPUT_CLOSED);
|
||||||
@ -188,7 +164,7 @@ chan_ibuf_empty(Channel *c)
|
|||||||
case CHAN_INPUT_WAIT_DRAIN:
|
case CHAN_INPUT_WAIT_DRAIN:
|
||||||
if (compat20) {
|
if (compat20) {
|
||||||
if (!(c->flags & (CHAN_CLOSE_SENT | CHAN_LOCAL))) {
|
if (!(c->flags & (CHAN_CLOSE_SENT | CHAN_LOCAL))) {
|
||||||
#ifdef WIN32_FIXME
|
#ifdef WIN32_FIXME//N
|
||||||
// reset the other side if tty to be how it was before
|
// reset the other side if tty to be how it was before
|
||||||
if (c->isatty) {
|
if (c->isatty) {
|
||||||
char *inittermseq =
|
char *inittermseq =
|
||||||
|
21
packet.c
21
packet.c
@ -415,7 +415,7 @@ ssh_packet_connection_af(struct ssh *ssh)
|
|||||||
if (getsockname(ssh->state->connection_out, (struct sockaddr *)&to,
|
if (getsockname(ssh->state->connection_out, (struct sockaddr *)&to,
|
||||||
&tolen) < 0)
|
&tolen) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef WIN32_FIXME
|
#ifdef WIN32_FIXME//N
|
||||||
if (to.ss_family == AF_INET)
|
if (to.ss_family == AF_INET)
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
@ -1314,15 +1314,10 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
|
|||||||
struct timeval timeout, start, *timeoutp = NULL;
|
struct timeval timeout, start, *timeoutp = NULL;
|
||||||
|
|
||||||
DBG(debug("packet_read()"));
|
DBG(debug("packet_read()"));
|
||||||
#if(1)//ndef WIN32_FIXME
|
|
||||||
int d = howmany(state->connection_in + 1, NFDBITS);
|
int d = howmany(state->connection_in + 1, NFDBITS);
|
||||||
d = sizeof(fd_mask);
|
d = sizeof(fd_mask);
|
||||||
setp = calloc(howmany(state->connection_in + 1,
|
setp = calloc(howmany(state->connection_in + 1,
|
||||||
NFDBITS), sizeof(fd_mask));
|
NFDBITS), sizeof(fd_mask));
|
||||||
#else
|
|
||||||
setp = xmalloc(sizeof(fd_set));
|
|
||||||
FD_ZERO(setp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (setp == NULL)
|
if (setp == NULL)
|
||||||
return SSH_ERR_ALLOC_FAIL;
|
return SSH_ERR_ALLOC_FAIL;
|
||||||
@ -1354,12 +1349,8 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
|
|||||||
* Otherwise, wait for some data to arrive, add it to the
|
* Otherwise, wait for some data to arrive, add it to the
|
||||||
* buffer, and try again.
|
* buffer, and try again.
|
||||||
*/
|
*/
|
||||||
#if(1)//ndef WIN32_FIXME
|
|
||||||
memset(setp, 0, howmany(state->connection_in + 1,
|
memset(setp, 0, howmany(state->connection_in + 1,
|
||||||
NFDBITS) * sizeof(fd_mask));
|
NFDBITS) * sizeof(fd_mask));
|
||||||
#else
|
|
||||||
FD_ZERO(setp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FD_SET(state->connection_in, setp);
|
FD_SET(state->connection_in, setp);
|
||||||
|
|
||||||
@ -2094,24 +2085,16 @@ ssh_packet_write_wait(struct ssh *ssh)
|
|||||||
int ret, r, ms_remain = 0;
|
int ret, r, ms_remain = 0;
|
||||||
struct timeval start, timeout, *timeoutp = NULL;
|
struct timeval start, timeout, *timeoutp = NULL;
|
||||||
struct session_state *state = ssh->state;
|
struct session_state *state = ssh->state;
|
||||||
#if(1)//ndef WIN32_FIXME
|
|
||||||
setp = calloc(howmany(state->connection_out + 1,
|
setp = calloc(howmany(state->connection_out + 1,
|
||||||
NFDBITS), sizeof(fd_mask));
|
NFDBITS), sizeof(fd_mask));
|
||||||
#else
|
|
||||||
setp = (fd_set *)xmalloc(sizeof(fd_set));
|
|
||||||
FD_ZERO(setp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (setp == NULL)
|
if (setp == NULL)
|
||||||
return SSH_ERR_ALLOC_FAIL;
|
return SSH_ERR_ALLOC_FAIL;
|
||||||
ssh_packet_write_poll(ssh);
|
ssh_packet_write_poll(ssh);
|
||||||
while (ssh_packet_have_data_to_write(ssh)) {
|
while (ssh_packet_have_data_to_write(ssh)) {
|
||||||
#if(1)//ndef WIN32_FIXME
|
|
||||||
memset(setp, 0, howmany(state->connection_out + 1,
|
memset(setp, 0, howmany(state->connection_out + 1,
|
||||||
NFDBITS) * sizeof(fd_mask));
|
NFDBITS) * sizeof(fd_mask));
|
||||||
#else
|
|
||||||
FD_ZERO(setp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FD_SET(state->connection_out, setp);
|
FD_SET(state->connection_out, setp);
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ static const char unit[] = " KMGT";
|
|||||||
static int
|
static int
|
||||||
can_output(void)
|
can_output(void)
|
||||||
{
|
{
|
||||||
#ifndef WIN32_FIXME
|
#ifndef WIN32_FIXME//R
|
||||||
return (getpgrp() == tcgetpgrp(STDOUT_FILENO));
|
return (getpgrp() == tcgetpgrp(STDOUT_FILENO));
|
||||||
#else
|
#else
|
||||||
return 1;
|
return 1;
|
||||||
@ -123,7 +123,7 @@ format_size(char *buf, int size, off_t bytes)
|
|||||||
void
|
void
|
||||||
refresh_progress_meter(void)
|
refresh_progress_meter(void)
|
||||||
{
|
{
|
||||||
#ifndef WIN32_FIXME
|
#if(1)//ndef WIN32_FIXME
|
||||||
char buf[MAX_WINSIZE + 1];
|
char buf[MAX_WINSIZE + 1];
|
||||||
time_t now;
|
time_t now;
|
||||||
off_t transferred;
|
off_t transferred;
|
||||||
@ -248,10 +248,8 @@ update_progress_meter(int ignore)
|
|||||||
if (can_output())
|
if (can_output())
|
||||||
refresh_progress_meter();
|
refresh_progress_meter();
|
||||||
|
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
signal(SIGALRM, update_progress_meter);
|
signal(SIGALRM, update_progress_meter);
|
||||||
alarm(UPDATE_INTERVAL);
|
alarm(UPDATE_INTERVAL);
|
||||||
#endif
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,17 +269,15 @@ start_progress_meter(const char *f, off_t filesize, off_t *ctr)
|
|||||||
if (can_output())
|
if (can_output())
|
||||||
refresh_progress_meter();
|
refresh_progress_meter();
|
||||||
|
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
signal(SIGALRM, update_progress_meter);
|
signal(SIGALRM, update_progress_meter);
|
||||||
signal(SIGWINCH, sig_winch);
|
signal(SIGWINCH, sig_winch);
|
||||||
alarm(UPDATE_INTERVAL);
|
alarm(UPDATE_INTERVAL);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
stop_progress_meter(void)
|
stop_progress_meter(void)
|
||||||
{
|
{
|
||||||
#ifndef WIN32_FIXME
|
|
||||||
alarm(0);
|
alarm(0);
|
||||||
|
|
||||||
if (!can_output())
|
if (!can_output())
|
||||||
@ -292,7 +288,6 @@ stop_progress_meter(void)
|
|||||||
refresh_progress_meter();
|
refresh_progress_meter();
|
||||||
|
|
||||||
atomicio(vwrite, STDOUT_FILENO, "\n", 1);
|
atomicio(vwrite, STDOUT_FILENO, "\n", 1);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
@ -305,7 +300,7 @@ sig_winch(int sig)
|
|||||||
static void
|
static void
|
||||||
setscreensize(void)
|
setscreensize(void)
|
||||||
{
|
{
|
||||||
#ifndef WIN32_FIXME
|
#ifndef WIN32_FIXME//N
|
||||||
struct winsize winsize;
|
struct winsize winsize;
|
||||||
|
|
||||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) != -1 &&
|
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) != -1 &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user