1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-23 01:22:37 +03:00

rename libssh2_error to the correct _libssh2_error

We reserve ^libssh2_ for public symbols and we use _libssh2 as
prefix for internal ones. I fixed the intendation of all these
edits with emacs afterwards, which then changed it slightly more
than just _libssh2_error() expressions but I didn't see any
obvious problems.
This commit is contained in:
Daniel Stenberg
2010-04-16 00:18:51 +02:00
parent 9cc824e27b
commit 1adcb5234f
17 changed files with 1083 additions and 1083 deletions

View File

@@ -122,8 +122,8 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
(int) data[0], data_len);
packet = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_PACKET));
if (!packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate datablock for SFTP packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate datablock for SFTP packet");
}
memset(packet, 0, sizeof(LIBSSH2_PACKET));
@@ -174,22 +174,22 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
/* TODO: this is stupid since we can in fact get 1-3 bytes in a
legitimate working case as well if the connection happens to be
super slow or something */
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Read part of packet");
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Read part of packet");
}
packet_len = _libssh2_ntohu32(buffer);
_libssh2_debug(session, LIBSSH2_TRACE_SFTP,
"Data begin - Packet Length: %lu", packet_len);
if (packet_len > LIBSSH2_SFTP_PACKET_MAXLEN) {
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED,
"SFTP packet too large");
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED,
"SFTP packet too large");
}
packet = LIBSSH2_ALLOC(session, packet_len);
if (!packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate SFTP packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate SFTP packet");
}
packet_received = 0;
@@ -216,8 +216,8 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
}
else if (bytes_received < 0) {
LIBSSH2_FREE(session, packet);
return libssh2_error(session, bytes_received,
"Receive error waiting for SFTP packet");
return _libssh2_error(session, bytes_received,
"Receive error waiting for SFTP packet");
}
packet_received += bytes_received;
}
@@ -484,8 +484,8 @@ sftp_bin2attr(LIBSSH2_SFTP_ATTRIBUTES * attrs, const unsigned char *p)
}
/* ************
* SFTP API *
************ */
* SFTP API *
************ */
LIBSSH2_CHANNEL_CLOSE_FUNC(libssh2_sftp_dtor);
@@ -554,12 +554,12 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
LIBSSH2_CHANNEL_PACKET_DEFAULT, NULL, 0);
if (!session->sftpInit_channel) {
if (libssh2_session_last_errno(session) == LIBSSH2_ERROR_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block starting up channel");
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block starting up channel");
}
else {
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Unable to startup channel");
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Unable to startup channel");
session->sftpInit_state = libssh2_NB_state_idle;
}
return NULL;
@@ -574,12 +574,12 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
sizeof("subsystem") - 1, "sftp",
strlen("sftp"));
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block to request SFTP subsystem");
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block to request SFTP subsystem");
return NULL;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Unable to request SFTP subsystem");
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Unable to request SFTP subsystem");
goto sftp_init_error;
}
@@ -590,8 +590,8 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
rc = _libssh2_channel_extended_data(session->sftpInit_channel,
LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block requesting handle extended data");
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block requesting handle extended data");
return NULL;
}
@@ -599,8 +599,8 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
session->sftpInit_sftp =
LIBSSH2_ALLOC(session, sizeof(LIBSSH2_SFTP));
if (!sftp_handle) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a new SFTP structure");
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a new SFTP structure");
goto sftp_init_error;
}
memset(sftp_handle, 0, sizeof(LIBSSH2_SFTP));
@@ -626,13 +626,13 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
session->sftpInit_sent,
9 - session->sftpInit_sent);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending SSH_FXP_INIT");
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending SSH_FXP_INIT");
return NULL;
}
else if(rc < 0) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send SSH_FXP_INIT");
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send SSH_FXP_INIT");
goto sftp_init_error;
}
else {
@@ -650,17 +650,17 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
rc = sftp_packet_require(sftp_handle, SSH_FXP_VERSION,
0, &data, &data_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting for response from SFTP subsystem");
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting for response from SFTP subsystem");
return NULL;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for response from SFTP subsystem");
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for response from SFTP subsystem");
goto sftp_init_error;
}
if (data_len < 5) {
libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Invalid SSH_FXP_VERSION response");
_libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Invalid SSH_FXP_VERSION response");
goto sftp_init_error;
}
@@ -810,8 +810,8 @@ libssh2_sftp_shutdown(LIBSSH2_SFTP *sftp)
}
/* *******************************
* SFTP File and Directory Ops *
******************************* */
* SFTP File and Directory Ops *
******************************* */
/* sftp_open
*/
@@ -841,9 +841,9 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
s = sftp->open_packet = LIBSSH2_ALLOC(session, sftp->open_packet_len);
if (!sftp->open_packet) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_OPEN or "
"FXP_OPENDIR packet");
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_OPEN or "
"FXP_OPENDIR packet");
return NULL;
}
/* Filetype in SFTP 3 and earlier */
@@ -881,16 +881,16 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
rc = _libssh2_channel_write(channel, 0, (char *) sftp->open_packet,
sftp->open_packet_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending FXP_OPEN or FXP_OPENDIR command");
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending FXP_OPEN or FXP_OPENDIR command");
return NULL;
}
else if (sftp->open_packet_len != rc) {
/* TODO: partial writes should be fine too and is not a sign of
an error when in non-blocking mode! */
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_OPEN or FXP_OPENDIR command");
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_OPEN or FXP_OPENDIR command");
LIBSSH2_FREE(session, sftp->open_packet);
sftp->open_packet = NULL;
sftp->open_state = libssh2_NB_state_idle;
@@ -907,12 +907,12 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
sftp->open_request_id, &data,
&data_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting for status message");
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting for status message");
return NULL;
}
else if (rc) {
libssh2_error(session, rc, "Timeout waiting for status message");
_libssh2_error(session, rc, "Timeout waiting for status message");
sftp->open_state = libssh2_NB_state_idle;
return NULL;
}
@@ -945,8 +945,8 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
}
if(badness) {
libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Failed opening remote file");
_libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Failed opening remote file");
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "got FXP_STATUS %d",
sftp->last_errno);
LIBSSH2_FREE(session, data);
@@ -956,8 +956,8 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
fp = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_SFTP_HANDLE));
if (!fp) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate new SFTP handle structure");
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate new SFTP handle structure");
LIBSSH2_FREE(session, data);
return NULL;
}
@@ -1101,8 +1101,8 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
non-blocking mode! */
sftp->read_packet = NULL;
sftp->read_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"_libssh2_channel_write() failed");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"_libssh2_channel_write() failed");
}
sftp->read_packet = packet;
sftp->read_request_id = request_id;
@@ -1115,13 +1115,13 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
sftp_packet_requirev(sftp, 2, read_responses,
request_id, &data, &data_len);
if (retcode == PACKET_EAGAIN) {
return libssh2_error(session, retcode,
"Would block waiting for status message");
return _libssh2_error(session, retcode,
"Would block waiting for status message");
} else if (retcode) {
sftp->read_packet = NULL;
sftp->read_state = libssh2_NB_state_idle;
return libssh2_error(session, retcode,
"Timeout waiting for status message");
return _libssh2_error(session, retcode,
"Timeout waiting for status message");
}
sftp->read_state = libssh2_NB_state_sent1;
@@ -1141,8 +1141,8 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
return total_read;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
case SSH_FXP_DATA:
@@ -1260,9 +1260,9 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
s = sftp->readdir_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->readdir_packet)
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"FXP_READDIR packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"FXP_READDIR packet");
_libssh2_htonu32(s, packet_len - 4);
s += 4;
@@ -1291,8 +1291,8 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
LIBSSH2_FREE(session, sftp->readdir_packet);
sftp->readdir_packet = NULL;
sftp->readdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"_libssh2_channel_write() failed");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"_libssh2_channel_write() failed");
}
LIBSSH2_FREE(session, sftp->readdir_packet);
@@ -1308,8 +1308,8 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
return retcode;
else if (retcode) {
sftp->readdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
if (data[0] == SSH_FXP_STATUS) {
@@ -1322,8 +1322,8 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
else {
sftp->last_errno = retcode;
sftp->readdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@@ -1395,8 +1395,8 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
(unsigned long) count);
s = sftp->write_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->write_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_WRITE");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_WRITE");
}
_libssh2_htonu32(s, packet_len - 4);
s += 4;
@@ -1444,8 +1444,8 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
}
else if (rc) {
sftp->write_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
"Timeout waiting for status message");
return _libssh2_error(session, rc,
"Timeout waiting for status message");
}
sftp->write_state = libssh2_NB_state_idle;
@@ -1459,8 +1459,8 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
}
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
/* libssh2_sftp_write
@@ -1502,9 +1502,9 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
setstat ? "set-stat" : "stat");
s = sftp->fstat_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->fstat_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"FSTAT/FSETSTAT packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"FSTAT/FSETSTAT packet");
}
_libssh2_htonu32(s, packet_len - 4);
@@ -1533,9 +1533,9 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
LIBSSH2_FREE(session, sftp->fstat_packet);
sftp->fstat_packet = NULL;
sftp->fstat_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
(setstat ? "Unable to send FXP_FSETSTAT"
: "Unable to send FXP_FSTAT command"));
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
(setstat ? "Unable to send FXP_FSETSTAT"
: "Unable to send FXP_FSTAT command"));
}
LIBSSH2_FREE(session, sftp->fstat_packet);
sftp->fstat_packet = NULL;
@@ -1550,8 +1550,8 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
return rc;
} else if (rc) {
sftp->fstat_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
sftp->fstat_state = libssh2_NB_state_idle;
@@ -1565,8 +1565,8 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@@ -1650,9 +1650,9 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Closing handle");
s = handle->close_packet = LIBSSH2_ALLOC(session, packet_len);
if (!handle->close_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_CLOSE "
"packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_CLOSE "
"packet");
}
_libssh2_htonu32(s, packet_len - 4);
@@ -1678,8 +1678,8 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
LIBSSH2_FREE(session, handle->close_packet);
handle->close_packet = NULL;
handle->close_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_CLOSE command");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_CLOSE command");
}
LIBSSH2_FREE(session, handle->close_packet);
handle->close_packet = NULL;
@@ -1695,8 +1695,8 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
return rc;
} else if (rc) {
handle->close_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
handle->close_state = libssh2_NB_state_sent1;
@@ -1708,8 +1708,8 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
if (retcode != LIBSSH2_FX_OK) {
sftp->last_errno = retcode;
handle->close_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
/* remove this handle from the parent's list */
@@ -1759,9 +1759,9 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Unlinking %s", filename);
s = sftp->unlink_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->unlink_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_REMOVE "
"packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_REMOVE "
"packet");
}
_libssh2_htonu32(s, packet_len - 4);
@@ -1787,8 +1787,8 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
LIBSSH2_FREE(session, sftp->unlink_packet);
sftp->unlink_packet = NULL;
sftp->unlink_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_REMOVE command");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_REMOVE command");
}
LIBSSH2_FREE(session, sftp->unlink_packet);
sftp->unlink_packet = NULL;
@@ -1804,8 +1804,8 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
}
else if (rc) {
sftp->unlink_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
sftp->unlink_state = libssh2_NB_state_idle;
@@ -1817,8 +1817,8 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@@ -1858,8 +1858,8 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
int rc;
if (sftp->version < 2) {
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Server does not support RENAME");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Server does not support RENAME");
}
if (sftp->rename_state == libssh2_NB_state_idle) {
@@ -1868,9 +1868,9 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
sftp->rename_s = sftp->rename_packet =
LIBSSH2_ALLOC(session, packet_len);
if (!sftp->rename_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_RENAME "
"packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_RENAME "
"packet");
}
_libssh2_htonu32(sftp->rename_s, packet_len - 4);
@@ -1905,8 +1905,8 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
LIBSSH2_FREE(session, sftp->rename_packet);
sftp->rename_packet = NULL;
sftp->rename_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_RENAME command");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_RENAME command");
}
LIBSSH2_FREE(session, sftp->rename_packet);
sftp->rename_packet = NULL;
@@ -1921,8 +1921,8 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
return rc;
} else if (rc) {
sftp->rename_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
sftp->rename_state = libssh2_NB_state_idle;
@@ -1940,19 +1940,19 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
break;
case LIBSSH2_FX_FILE_ALREADY_EXISTS:
retcode = libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"File already exists and "
"SSH_FXP_RENAME_OVERWRITE not specified");
retcode = _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"File already exists and "
"SSH_FXP_RENAME_OVERWRITE not specified");
break;
case LIBSSH2_FX_OP_UNSUPPORTED:
retcode = libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Operation Not Supported");
retcode = _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Operation Not Supported");
break;
default:
retcode = libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
retcode = _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
break;
}
@@ -2000,9 +2000,9 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path,
"Creating directory %s with mode 0%lo", path, mode);
s = packet = LIBSSH2_ALLOC(session, packet_len);
if (!packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_MKDIR "
"packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_MKDIR "
"packet");
}
/* Filetype in SFTP 3 and earlier */
attrs.permissions = mode | LIBSSH2_SFTP_ATTR_PFILETYPE_DIR;
@@ -2034,8 +2034,8 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path,
if (packet_len != rc) {
LIBSSH2_FREE(session, packet);
sftp->mkdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"_libssh2_channel_write() failed");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"_libssh2_channel_write() failed");
}
LIBSSH2_FREE(session, packet);
sftp->mkdir_state = libssh2_NB_state_sent;
@@ -2048,8 +2048,8 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path,
return rc;
} else if (rc) {
sftp->mkdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
sftp->mkdir_state = libssh2_NB_state_idle;
@@ -2062,8 +2062,8 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@@ -2102,9 +2102,9 @@ static int sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path,
path);
s = sftp->rmdir_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->rmdir_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_RMDIR "
"packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_RMDIR "
"packet");
}
_libssh2_htonu32(s, packet_len - 4);
@@ -2130,8 +2130,8 @@ static int sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path,
LIBSSH2_FREE(session, sftp->rmdir_packet);
sftp->rmdir_packet = NULL;
sftp->rmdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_RMDIR command");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_RMDIR command");
}
LIBSSH2_FREE(session, sftp->rmdir_packet);
sftp->rmdir_packet = NULL;
@@ -2145,8 +2145,8 @@ static int sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path,
return rc;
} else if (rc) {
sftp->rmdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
sftp->rmdir_state = libssh2_NB_state_idle;
@@ -2158,8 +2158,8 @@ static int sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@@ -2203,9 +2203,9 @@ static int sftp_stat(LIBSSH2_SFTP *sftp, const char *path,
LIBSSH2_SFTP_LSTAT ? "LStatting" : "Statting"), path);
s = sftp->stat_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->stat_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_*STAT "
"packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_*STAT "
"packet");
}
_libssh2_htonu32(s, packet_len - 4);
@@ -2246,8 +2246,8 @@ static int sftp_stat(LIBSSH2_SFTP *sftp, const char *path,
LIBSSH2_FREE(session, sftp->stat_packet);
sftp->stat_packet = NULL;
sftp->stat_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send STAT/LSTAT/SETSTAT command");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send STAT/LSTAT/SETSTAT command");
}
LIBSSH2_FREE(session, sftp->stat_packet);
sftp->stat_packet = NULL;
@@ -2261,8 +2261,8 @@ static int sftp_stat(LIBSSH2_SFTP *sftp, const char *path,
return rc;
} else if (rc) {
sftp->stat_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
sftp->stat_state = libssh2_NB_state_idle;
@@ -2276,8 +2276,8 @@ static int sftp_stat(LIBSSH2_SFTP *sftp, const char *path,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@@ -2322,16 +2322,16 @@ static int sftp_symlink(LIBSSH2_SFTP *sftp, const char *path,
int rc;
if ((sftp->version < 3) && (link_type != LIBSSH2_SFTP_REALPATH)) {
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Server does not support SYMLINK or READLINK");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Server does not support SYMLINK or READLINK");
}
if (sftp->symlink_state == libssh2_NB_state_idle) {
s = sftp->symlink_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->symlink_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"SYMLINK/READLINK/REALPATH packet");
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"SYMLINK/READLINK/REALPATH packet");
}
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "%s %s on %s",
@@ -2381,8 +2381,8 @@ static int sftp_symlink(LIBSSH2_SFTP *sftp, const char *path,
LIBSSH2_FREE(session, sftp->symlink_packet);
sftp->symlink_packet = NULL;
sftp->symlink_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send SYMLINK/READLINK command");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send SYMLINK/READLINK command");
}
LIBSSH2_FREE(session, sftp->symlink_packet);
sftp->symlink_packet = NULL;
@@ -2398,8 +2398,8 @@ static int sftp_symlink(LIBSSH2_SFTP *sftp, const char *path,
}
else if (rc) {
sftp->symlink_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
sftp->symlink_state = libssh2_NB_state_idle;
@@ -2413,16 +2413,16 @@ static int sftp_symlink(LIBSSH2_SFTP *sftp, const char *path,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
if (_libssh2_ntohu32(data + 5) < 1) {
LIBSSH2_FREE(session, data);
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Invalid READLINK/REALPATH response, "
"no name entries");
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Invalid READLINK/REALPATH response, "
"no name entries");
}
link_len = _libssh2_ntohu32(data + 9);
@@ -2459,5 +2459,3 @@ libssh2_sftp_last_error(LIBSSH2_SFTP *sftp)
{
return sftp->last_errno;
}