compress: compression disabled by default
We now allow libssh2_session_flag() to enable compression with a new flag and I added documentation for the previous LIBSSH2_FLAG_SIGPIPE flag which I wasn't really aware of!
Этот коммит содержится в:
родитель
64063d5f0b
Коммит
3a391f6cf2
@ -5,11 +5,21 @@
|
||||
libssh2_session_flag - TODO
|
||||
.SH SYNOPSIS
|
||||
int
|
||||
libssh2_session_flag(LIBSSH2_SESSION * session, int flag, int value);
|
||||
libssh2_session_flag(LIBSSH2_SESSION *session, int flag, int value);
|
||||
.SH DESCRIPTION
|
||||
This function has no purpose and no documented flags can be set nor read.
|
||||
Set options for the created session. \fIflag\fP is the option to set, while
|
||||
\fIvalue\fP is typically set to 1 or 0 to enable or disable the option.
|
||||
.SH FLAGS
|
||||
.IP LIBSSH2_FLAG_SIGPIPE
|
||||
If set, libssh2 will not attempt to block SIGPIPEs but will let them trigger
|
||||
from the underlying socket layer.
|
||||
.IP LIBSSH2_FLAG_COMPRESS
|
||||
If set - before the connection negotiation is performed - libssh2 will try to
|
||||
negotiate compression enabling for this connection. By default libssh2 will
|
||||
not attempt to use compression.
|
||||
.SH RETURN VALUE
|
||||
0
|
||||
.SH ERRORS
|
||||
Its mere existence is an error
|
||||
Returns regular libssh2 error code.
|
||||
.SH AVAILABILITY
|
||||
This function has existed since the age of dawn. LIBSSH2_FLAG_COMPRESS was
|
||||
added in version 1.2.8.
|
||||
.SH SEE ALSO
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2009, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2009 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2010 Daniel Stenberg
|
||||
* Copyright (c) 2010 Simon Josefsson <simon@josefsson.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -253,8 +253,9 @@ typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE
|
||||
#define LIBSSH2_METHOD_LANG_CS 8
|
||||
#define LIBSSH2_METHOD_LANG_SC 9
|
||||
|
||||
/* session.flags bits */
|
||||
#define LIBSSH2_FLAG_SIGPIPE 0x00000001
|
||||
/* flags */
|
||||
#define LIBSSH2_FLAG_SIGPIPE 1
|
||||
#define LIBSSH2_FLAG_COMPRESS 2
|
||||
|
||||
typedef struct _LIBSSH2_SESSION LIBSSH2_SESSION;
|
||||
typedef struct _LIBSSH2_CHANNEL LIBSSH2_CHANNEL;
|
||||
|
@ -661,6 +661,11 @@ struct _LIBSSH2_SFTP
|
||||
|
||||
#define LIBSSH2_SCP_RESPONSE_BUFLEN 256
|
||||
|
||||
struct flags {
|
||||
int sigpipe; /* LIBSSH2_FLAG_SIGPIPE */
|
||||
int compress; /* LIBSSH2_FLAG_COMPRESS */
|
||||
};
|
||||
|
||||
struct _LIBSSH2_SESSION
|
||||
{
|
||||
/* Memory management callbacks */
|
||||
@ -681,7 +686,9 @@ struct _LIBSSH2_SESSION
|
||||
char *hostkey_prefs;
|
||||
|
||||
int state;
|
||||
int flags;
|
||||
|
||||
/* Flag options */
|
||||
struct flags flag;
|
||||
|
||||
/* Agreed Key Exchange Method */
|
||||
const LIBSSH2_KEX_METHOD *kex;
|
||||
@ -930,8 +937,8 @@ struct _LIBSSH2_SESSION
|
||||
|
||||
/* session.flag helpers */
|
||||
#ifdef MSG_NOSIGNAL
|
||||
#define LIBSSH2_SOCKET_SEND_FLAGS(session) (((session)->flags & LIBSSH2_FLAG_SIGPIPE) ? 0 : MSG_NOSIGNAL)
|
||||
#define LIBSSH2_SOCKET_RECV_FLAGS(session) (((session)->flags & LIBSSH2_FLAG_SIGPIPE) ? 0 : MSG_NOSIGNAL)
|
||||
#define LIBSSH2_SOCKET_SEND_FLAGS(session) (((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#define LIBSSH2_SOCKET_RECV_FLAGS(session) (((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#else
|
||||
/* If MSG_NOSIGNAL isn't defined we're SOL on blocking SIGPIPE */
|
||||
#define LIBSSH2_SOCKET_SEND_FLAGS(session) 0
|
||||
|
@ -1227,19 +1227,24 @@ libssh2_session_last_errno(LIBSSH2_SESSION * session)
|
||||
*
|
||||
* Set/Get session flags
|
||||
*
|
||||
* Passing flag==0 will avoid changing session->flags while still returning
|
||||
* its current value
|
||||
* Return error code.
|
||||
*/
|
||||
LIBSSH2_API int
|
||||
libssh2_session_flag(LIBSSH2_SESSION * session, int flag, int value)
|
||||
{
|
||||
if (value) {
|
||||
session->flags |= flag;
|
||||
} else {
|
||||
session->flags &= ~flag;
|
||||
switch(flag) {
|
||||
case LIBSSH2_FLAG_SIGPIPE:
|
||||
session->flag.sigpipe = value;
|
||||
break;
|
||||
case LIBSSH2_FLAG_COMPRESS:
|
||||
session->flag.compress = value;
|
||||
break;
|
||||
default:
|
||||
/* unknown flag */
|
||||
return LIBSSH2_ERROR_INVAL;
|
||||
}
|
||||
|
||||
return session->flags;
|
||||
return LIBSSH2_ERROR_NONE;
|
||||
}
|
||||
|
||||
/* _libssh2_session_set_blocking
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user