Improve channel_request_pty_size().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@693 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-05-04 06:54:06 +00:00
parent a08c56baf4
commit 2688c1a1d5

View File

@@ -1061,13 +1061,18 @@ error:
return rc; return rc;
} }
/** \brief requests a pty with a specific type and size /**
* \param channel channel * @brief Request a pty with a specific type and size.
* \param terminal terminal type ("vt100, xterm,...") *
* \param col number of cols * @param channel The channel to sent the request.
* \param row number of rows *
* \return SSH_SUCCESS on success\n * @param terminal The terminal type ("vt100, xterm,...").
* SSH_ERROR on error *
* @param col The number of columns.
*
* @param row The number of rows.
*
* @return SSH_SUCCESS on success, SSH_ERROR on error.
*/ */
int channel_request_pty_size(CHANNEL *channel, const char *terminal, int channel_request_pty_size(CHANNEL *channel, const char *terminal,
int col, int row) { int col, int row) {
@@ -1094,26 +1099,13 @@ int channel_request_pty_size(CHANNEL *channel, const char *terminal,
goto error; goto error;
} }
if (buffer_add_ssh_string(buffer, term) < 0) { if (buffer_add_ssh_string(buffer, term) < 0 ||
goto error; buffer_add_u32(buffer, htonl(col)) < 0 ||
} buffer_add_u32(buffer, htonl(row)) < 0 ||
if (buffer_add_u32(buffer, htonl(col)) < 0) { buffer_add_u32(buffer, 0) < 0 ||
goto error; buffer_add_u32(buffer, 0) < 0 ||
} buffer_add_u32(buffer, htonl(1)) < 0 || /* Add a 0byte string */
if (buffer_add_u32(buffer, htonl(row)) < 0) { buffer_add_u8(buffer, 0) < 0) {
goto error;
}
if (buffer_add_u32(buffer, 0) < 0) {
goto error;
}
if (buffer_add_u32(buffer, 0) < 0) {
goto error;
}
/* a 0byte string */
if (buffer_add_u32(buffer, htonl(1)) < 0) {
goto error;
}
if (buffer_add_u8(buffer, 0) < 0) {
goto error; goto error;
} }
@@ -1121,6 +1113,7 @@ int channel_request_pty_size(CHANNEL *channel, const char *terminal,
error: error:
buffer_free(buffer); buffer_free(buffer);
string_free(term); string_free(term);
leave_function(); leave_function();
return rc; return rc;
} }