aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-10-10 20:55:17 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2009-10-10 20:55:17 +0200
commite74305c5ebd7d68f0fff01f1cf49eefa132826a2 (patch)
tree3e7fd85bb358c80043f2904ac272fbaba1b561da
parent499f9aa7077301e74dd482d9adbde2a334332f95 (diff)
downloadlibssh-e74305c5ebd7d68f0fff01f1cf49eefa132826a2.tar.gz
libssh-e74305c5ebd7d68f0fff01f1cf49eefa132826a2.tar.xz
libssh-e74305c5ebd7d68f0fff01f1cf49eefa132826a2.zip
updated the sftp subsystem to follow the type conv
-rw-r--r--examples/sample.c54
-rw-r--r--include/libssh/sftp.h218
-rw-r--r--libssh/sftp.c335
-rw-r--r--libssh/sftpserver.c34
4 files changed, 324 insertions, 317 deletions
diff --git a/examples/sample.c b/examples/sample.c
index c0084c4..d8cbc53 100644
--- a/examples/sample.c
+++ b/examples/sample.c
@@ -37,7 +37,7 @@ clients must be made or how a client should react.
#define MAXCMD 10
char *host;
char *user;
-int sftp;
+int is_sftp;
char *cmds[MAXCMD];
struct termios terminal;
@@ -97,7 +97,7 @@ static void usage(){
static int opts(int argc, char **argv){
int i;
if(strstr(argv[0],"sftp"))
- sftp=1;
+ is_sftp=1;
// for(i=0;i<argc;i++)
// printf("%d : %s\n",i,argv[i]);
/* insert your own arguments here */
@@ -311,13 +311,13 @@ static void batch_shell(ssh_session session){
#ifdef WITH_SFTP
/* it's just a proof of concept code for sftp, till i write a real documentation about it */
void do_sftp(ssh_session session){
- SFTP_SESSION *sftp_session=sftp_new(session);
- SFTP_DIR *dir;
- SFTP_ATTRIBUTES *file;
- SFTP_STATVFS *sftpstatvfs;
+ sftp_session sftp=sftp_new(session);
+ sftp_dir dir;
+ sftp_attributes file;
+ sftp_statvfs_t sftpstatvfs;
struct statvfs sysstatvfs;
- SFTP_FILE *fichier;
- SFTP_FILE *to;
+ sftp_file fichier;
+ sftp_file to;
int len=1;
unsigned int i;
char data[8000]={0};
@@ -325,43 +325,43 @@ void do_sftp(ssh_session session){
unsigned int count;
- if(!sftp_session){
+ if(!sftp){
fprintf(stderr, "sftp error initialising channel: %s\n",
ssh_get_error(session));
return;
}
- if(sftp_init(sftp_session)){
+ if(sftp_init(sftp)){
fprintf(stderr, "error initialising sftp: %s\n",
ssh_get_error(session));
return;
}
printf("Additional SFTP extensions provided by the server:\n");
- count = sftp_extensions_get_count(sftp_session);
+ count = sftp_extensions_get_count(sftp);
for (i = 0; i < count; i++) {
printf("\t%s, version: %s\n",
- sftp_extensions_get_name(sftp_session, i),
- sftp_extensions_get_data(sftp_session, i));
+ sftp_extensions_get_name(sftp, i),
+ sftp_extensions_get_data(sftp, i));
}
/* test symlink and readlink */
- if (sftp_symlink(sftp_session, "/tmp/this_is_the_link",
+ if (sftp_symlink(sftp, "/tmp/this_is_the_link",
"/tmp/sftp_symlink_test") < 0) {
fprintf(stderr, "Could not create link (%s)\n", ssh_get_error(session));
return;
}
- lnk = sftp_readlink(sftp_session, "/tmp/sftp_symlink_test");
+ lnk = sftp_readlink(sftp, "/tmp/sftp_symlink_test");
if (lnk == NULL) {
fprintf(stderr, "Could not read link (%s)\n", ssh_get_error(session));
return;
}
printf("readlink /tmp/sftp_symlink_test: %s\n", lnk);
- sftp_unlink(sftp_session, "/tmp/sftp_symlink_test");
+ sftp_unlink(sftp, "/tmp/sftp_symlink_test");
- if (sftp_extension_supported(sftp_session, "statvfs@openssh.com", "2")) {
- sftpstatvfs = sftp_statvfs(sftp_session, "/tmp");
+ if (sftp_extension_supported(sftp, "statvfs@openssh.com", "2")) {
+ sftpstatvfs = sftp_statvfs(sftp, "/tmp");
if (sftpstatvfs == NULL) {
fprintf(stderr, "statvfs failed (%s)\n", ssh_get_error(session));
return;
@@ -425,13 +425,13 @@ void do_sftp(ssh_session session){
/* the connection is made */
/* opening a directory */
- dir=sftp_opendir(sftp_session,"./");
+ dir=sftp_opendir(sftp,"./");
if(!dir) {
fprintf(stderr, "Directory not opened(%s)\n", ssh_get_error(session));
return ;
}
/* reading the whole directory, file by file */
- while((file=sftp_readdir(sftp_session,dir))){
+ while((file=sftp_readdir(sftp,dir))){
fprintf(stderr, "%30s(%.8o) : %.5d.%.5d : %.10llu bytes\n",
file->name,
file->permissions,
@@ -452,14 +452,14 @@ void do_sftp(ssh_session session){
/* this will open a file and copy it into your /home directory */
/* the small buffer size was intended to stress the library. of course, you can use a buffer till 20kbytes without problem */
- fichier=sftp_open(sftp_session,"/usr/bin/ssh",O_RDONLY, 0);
+ fichier=sftp_open(sftp,"/usr/bin/ssh",O_RDONLY, 0);
if(!fichier){
fprintf(stderr, "Error opening /usr/bin/ssh: %s\n",
ssh_get_error(session));
return;
}
/* open a file for writing... */
- to=sftp_open(sftp_session,"ssh-copy",O_WRONLY | O_CREAT, 0700);
+ to=sftp_open(sftp,"ssh-copy",O_WRONLY | O_CREAT, 0700);
if(!to){
fprintf(stderr, "Error opening ssh-copy for writing: %s\n",
ssh_get_error(session));
@@ -478,7 +478,7 @@ void do_sftp(ssh_session session){
sftp_close(fichier);
sftp_close(to);
printf("fichiers ferm\n");
- to=sftp_open(sftp_session,"/tmp/grosfichier",O_WRONLY|O_CREAT, 0644);
+ to=sftp_open(sftp,"/tmp/grosfichier",O_WRONLY|O_CREAT, 0644);
for(i=0;i<1000;++i){
len=sftp_write(to,data,8000);
printf("wrote %d bytes\n",len);
@@ -489,7 +489,7 @@ void do_sftp(ssh_session session){
sftp_close(to);
/* close the sftp session */
- sftp_free(sftp_session);
+ sftp_free(sftp);
printf("sftp session terminated\n");
}
#endif
@@ -682,10 +682,10 @@ int main(int argc, char **argv){
}
ssh_log(session, SSH_LOG_FUNCTIONS, "Authentication success");
if(strstr(argv[0],"sftp")){
- sftp=1;
+ is_sftp=1;
ssh_log(session, SSH_LOG_FUNCTIONS, "Doing sftp instead");
}
- if(!sftp){
+ if(!is_sftp){
if(!cmds[0])
shell(session);
else
@@ -695,7 +695,7 @@ int main(int argc, char **argv){
else
do_sftp(session);
#endif
- if(!sftp && !cmds[0])
+ if(!is_sftp && !cmds[0])
do_cleanup(0);
ssh_disconnect(session);
ssh_free(session);
diff --git a/include/libssh/sftp.h b/include/libssh/sftp.h
index 68c0788..6d6d71a 100644
--- a/include/libssh/sftp.h
+++ b/include/libssh/sftp.h
@@ -25,12 +25,12 @@
* @brief SFTP handling functions
*
* SFTP commands are channeled by the ssh sftp subsystem. Every packet is
- * sent/read using a SFTP_PACKET type structure. Related to these packets,
+ * sent/read using a sftp_packet type structure. Related to these packets,
* most of the server answers are messages having an ID and a message
- * specific part. It is described by SFTP_MESSAGE when reading a message,
+ * specific part. It is described by sftp_message when reading a message,
* the sftp system puts it into the queue, so the process having asked for
* it can fetch it, while continuing to read for other messages (it is
- * inspecified in which order messages may be sent back to the client
+ * unspecified in which order messages may be sent back to the client
*
* @defgroup ssh_sftp SFTP Functions
* @{
@@ -67,86 +67,96 @@ extern "C" {
#endif /* _MSC_VER */
#endif /* _WIN32 */
+typedef struct sftp_attributes_struct* sftp_attributes;
+typedef struct sftp_client_message_struct* sftp_client_message;
+typedef struct sftp_dir_struct* sftp_dir;
typedef struct sftp_ext_struct *sftp_ext;
-
-typedef struct sftp_session_struct {
+typedef struct sftp_file_struct* sftp_file;
+typedef struct sftp_message_struct* sftp_message;
+typedef struct sftp_packet_struct* sftp_packet;
+typedef struct sftp_request_queue_struct* sftp_request_queue;
+typedef struct sftp_session_struct* sftp_session;
+typedef struct sftp_status_message_struct* sftp_status_message;
+typedef struct sftp_statvfs_struct* sftp_statvfs_t;
+
+struct sftp_session_struct {
ssh_session session;
ssh_channel channel;
int server_version;
int client_version;
int version;
- struct request_queue *queue;
+ sftp_request_queue queue;
uint32_t id_counter;
int errnum;
void **handles;
- struct sftp_ext_struct *ext;
-} SFTP_SESSION ;
+ sftp_ext ext;
+};
-typedef struct {
- SFTP_SESSION *sftp;
+struct sftp_packet_struct {
+ sftp_session sftp;
uint8_t type;
ssh_buffer payload;
-} SFTP_PACKET;
+};
/* file handler */
-typedef struct sftp_file{
- SFTP_SESSION *sftp;
+struct sftp_file_struct {
+ sftp_session sftp;
char *name;
uint64_t offset;
ssh_string handle;
int eof;
int nonblocking;
-} SFTP_FILE ;
+};
-typedef struct sftp_dir {
- SFTP_SESSION *sftp;
+struct sftp_dir_struct {
+ sftp_session sftp;
char *name;
ssh_string handle; /* handle to directory */
ssh_buffer buffer; /* contains raw attributes from server which haven't been parsed */
uint32_t count; /* counts the number of following attributes structures into buffer */
int eof; /* end of directory listing */
-} SFTP_DIR;
+};
-typedef struct {
- SFTP_SESSION *sftp;
+struct sftp_message_struct {
+ sftp_session sftp;
uint8_t packet_type;
ssh_buffer payload;
uint32_t id;
-} SFTP_MESSAGE;
+};
/* this is a bunch of all data that could be into a message */
-typedef struct sftp_client_message{
- SFTP_SESSION *sftp;
+struct sftp_client_message_struct {
+ sftp_session sftp;
uint8_t type;
uint32_t id;
char *filename; /* can be "path" */
uint32_t flags;
- struct sftp_attributes *attr;
+ sftp_attributes attr;
ssh_string handle;
uint64_t offset;
uint32_t len;
int attr_num;
ssh_buffer attrbuf; /* used by sftp_reply_attrs */
ssh_string data; /* can be newpath of rename() */
-} SFTP_CLIENT_MESSAGE;
+};
-typedef struct request_queue{
- struct request_queue *next;
- SFTP_MESSAGE *message;
-} REQUEST_QUEUE;
+struct sftp_request_queue_struct {
+ sftp_request_queue next;
+ sftp_message message;
+};
/* SSH_FXP_MESSAGE described into .7 page 26 */
-typedef struct {
- uint32_t id;
- uint32_t status;
+struct sftp_status_message_struct {
+ uint32_t id;
+ uint32_t status;
ssh_string error;
ssh_string lang;
char *errormsg;
char *langmsg;
-} STATUS_MESSAGE;
+};
/* don't worry much of these aren't really used */
-typedef struct sftp_attributes{
+struct sftp_attributes_struct {
char *name;
char *longname; /* some weird stuff */
uint32_t flags;
@@ -169,9 +179,9 @@ typedef struct sftp_attributes{
uint32_t extended_count;
ssh_string extended_type;
ssh_string extended_data;
-} SFTP_ATTRIBUTES;
+};
-typedef struct sftp_statvfs_struct {
+struct sftp_statvfs_struct {
uint64_t f_bsize; /* file system block size */
uint64_t f_frsize; /* fundamental fs block size */
uint64_t f_blocks; /* number of blocks (unit f_frsize) */
@@ -183,7 +193,7 @@ typedef struct sftp_statvfs_struct {
uint64_t f_fsid; /* file system id */
uint64_t f_flag; /* bit mask of f_flag values */
uint64_t f_namemax; /* maximum filename length */
-} SFTP_STATVFS;
+};
#define LIBSFTP_VERSION 3
@@ -194,14 +204,14 @@ typedef struct sftp_statvfs_struct {
*
* @return A new sftp session or NULL on error.
*/
-LIBSSH_API SFTP_SESSION *sftp_new(ssh_session session);
+LIBSSH_API sftp_session sftp_new(ssh_session session);
/**
* @brief Close and deallocate a sftp session.
*
* @param sftp The sftp session handle to free.
*/
-LIBSSH_API void sftp_free(SFTP_SESSION *sftp);
+LIBSSH_API void sftp_free(sftp_session sftp);
/**
* @brief Initialize the sftp session with the server.
@@ -210,7 +220,7 @@ LIBSSH_API void sftp_free(SFTP_SESSION *sftp);
*
* @return 0 on success, < 0 on error with ssh error set.
*/
-LIBSSH_API int sftp_init(SFTP_SESSION *sftp);
+LIBSSH_API int sftp_init(sftp_session sftp);
/**
* @brief Get the last sftp error.
@@ -222,7 +232,7 @@ LIBSSH_API int sftp_init(SFTP_SESSION *sftp);
* @return The saved error (see server responses), < 0 if an error
* in the function occured.
*/
-LIBSSH_API int sftp_get_error(SFTP_SESSION *sftp);
+LIBSSH_API int sftp_get_error(sftp_session sftp);
/**
* @brief Get the count of extensions provided by the server.
@@ -232,7 +242,7 @@ LIBSSH_API int sftp_get_error(SFTP_SESSION *sftp);
* @return The count of extensions provided by the server, 0 on error or
* not available.
*/
-LIBSSH_API unsigned int sftp_extensions_get_count(SFTP_SESSION *sftp);
+LIBSSH_API unsigned int sftp_extensions_get_count(sftp_session sftp);
/**
* @brief Get the name of the extension provided by the server.
@@ -243,7 +253,7 @@ LIBSSH_API unsigned int sftp_extensions_get_count(SFTP_SESSION *sftp);
*
* @return The name of the extension.
*/
-LIBSSH_API const char *sftp_extensions_get_name(SFTP_SESSION *sftp, unsigned int index);
+LIBSSH_API const char *sftp_extensions_get_name(sftp_session sftp, unsigned int index);
/**
* @brief Get the data of the extension provided by the server.
@@ -256,7 +266,7 @@ LIBSSH_API const char *sftp_extensions_get_name(SFTP_SESSION *sftp, unsigned int
*
* @return The data of the extension.
*/
-LIBSSH_API const char *sftp_extensions_get_data(SFTP_SESSION *sftp, unsigned int index);
+LIBSSH_API const char *sftp_extensions_get_data(sftp_session sftp, unsigned int index);
/**
* @brief Check if the given extension is supported.
@@ -275,7 +285,7 @@ LIBSSH_API const char *sftp_extensions_get_data(SFTP_SESSION *sftp, unsigned int
* sftp_extension_supported(sftp, "statvfs@openssh.com", "2");
* @endcode
*/
-LIBSSH_API int sftp_extension_supported(SFTP_SESSION *sftp, const char *name,
+LIBSSH_API int sftp_extension_supported(sftp_session sftp, const char *name,
const char *data);
/**
@@ -290,7 +300,7 @@ LIBSSH_API int sftp_extension_supported(SFTP_SESSION *sftp, const char *name,
* @see sftp_readdir
* @see sftp_closedir
*/
-LIBSSH_API SFTP_DIR *sftp_opendir(SFTP_SESSION *session, const char *path);
+LIBSSH_API sftp_dir sftp_opendir(sftp_session session, const char *path);
/**
* @brief Get a single file attributes structure of a directory.
@@ -305,7 +315,7 @@ LIBSSH_API SFTP_DIR *sftp_opendir(SFTP_SESSION *session, const char *path);
* @see sftp_attribute_free()
* @see sftp_closedir()
*/
-LIBSSH_API SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *session, SFTP_DIR *dir);
+LIBSSH_API sftp_attributes sftp_readdir(sftp_session session, sftp_dir dir);
/**
* @brief Tell if the directory has reached EOF (End Of File).
@@ -316,7 +326,7 @@ LIBSSH_API SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *session, SFTP_DIR *dir);
*
* @see sftp_readdir()
*/
-LIBSSH_API int sftp_dir_eof(SFTP_DIR *dir);
+LIBSSH_API int sftp_dir_eof(sftp_dir dir);
/**
* @brief Get information about a file or directory.
@@ -328,7 +338,7 @@ LIBSSH_API int sftp_dir_eof(SFTP_DIR *dir);
* @return The sftp attributes structure of the file or directory,
* NULL on error with ssh and sftp error set.
*/
-LIBSSH_API SFTP_ATTRIBUTES *sftp_stat(SFTP_SESSION *session, const char *path);
+LIBSSH_API sftp_attributes sftp_stat(sftp_session session, const char *path);
/**
* @brief Get information about a file or directory.
@@ -343,7 +353,7 @@ LIBSSH_API SFTP_ATTRIBUTES *sftp_stat(SFTP_SESSION *session, const char *path);
* @return The sftp attributes structure of the file or directory,
* NULL on error with ssh and sftp error set.
*/
-LIBSSH_API SFTP_ATTRIBUTES *sftp_lstat(SFTP_SESSION *session, const char *path);
+LIBSSH_API sftp_attributes sftp_lstat(sftp_session session, const char *path);
/**
* @brief Get information about a file or directory from a file handle.
@@ -353,14 +363,14 @@ LIBSSH_API SFTP_ATTRIBUTES *sftp_lstat(SFTP_SESSION *session, const char *path);
* @return The sftp attributes structure of the file or directory,
* NULL on error with ssh and sftp error set.
*/
-LIBSSH_API SFTP_ATTRIBUTES *sftp_fstat(SFTP_FILE *file);
+LIBSSH_API sftp_attributes sftp_fstat(sftp_file file);
/**
* @brief Free a sftp attribute structure.
*
* @param file The sftp attribute structure to free.
*/
-LIBSSH_API void sftp_attributes_free(SFTP_ATTRIBUTES *file);
+LIBSSH_API void sftp_attributes_free(sftp_attributes file);
/**
* @brief Close a directory handle opened by sftp_opendir().
@@ -369,12 +379,12 @@ LIBSSH_API void sftp_attributes_free(SFTP_ATTRIBUTES *file);
*
* @return Returns SSH_NO_ERROR or SSH_ERROR if an error occured.
*/
-LIBSSH_API int sftp_closedir(SFTP_DIR *dir);
+LIBSSH_API int sftp_closedir(sftp_dir dir);
/**
* @deprecated Use sftp_closedir() instead.
*/
-LIBSSH_API int sftp_dir_close(SFTP_DIR *dir) SFTP_DEPRECATED;
+LIBSSH_API int sftp_dir_close(sftp_dir dir) SFTP_DEPRECATED;
/**
* @brief Close an open file handle.
@@ -385,12 +395,12 @@ LIBSSH_API int sftp_dir_close(SFTP_DIR *dir) SFTP_DEPRECATED;
*
* @see sftp_open()
*/
-LIBSSH_API int sftp_close(SFTP_FILE *file);
+LIBSSH_API int sftp_close(sftp_file file);
/**
* @deprecated Use sftp_close() instead.
*/
-LIBSSH_API int sftp_file_close(SFTP_FILE *file) SFTP_DEPRECATED;
+LIBSSH_API int sftp_file_close(sftp_file file) SFTP_DEPRECATED;
/**
* @brief Open a file on the server.
@@ -418,12 +428,12 @@ LIBSSH_API int sftp_file_close(SFTP_FILE *file) SFTP_DEPRECATED;
* @return A sftp file handle, NULL on error with ssh and sftp
* error set.
*/
-LIBSSH_API SFTP_FILE *sftp_open(SFTP_SESSION *session, const char *file, int accesstype,
+LIBSSH_API sftp_file sftp_open(sftp_session session, const char *file, int accesstype,
mode_t mode);
-LIBSSH_API void sftp_file_set_nonblocking(SFTP_FILE *handle);
+LIBSSH_API void sftp_file_set_nonblocking(sftp_file handle);
-LIBSSH_API void sftp_file_set_blocking(SFTP_FILE *handle);
+LIBSSH_API void sftp_file_set_blocking(sftp_file handle);
/**
* @brief Read from a file using an opened sftp file handle.
@@ -437,7 +447,7 @@ LIBSSH_API void sftp_file_set_blocking(SFTP_FILE *handle);
* @return Number of bytes written, < 0 on error with ssh and sftp
* error set.
*/
-LIBSSH_API ssize_t sftp_read(SFTP_FILE *file, void *buf, size_t count);
+LIBSSH_API ssize_t sftp_read(sftp_file file, void *buf, size_t count);
/**
* @brief Start an asynchronous read from a file using an opened sftp file handle.
@@ -470,7 +480,7 @@ LIBSSH_API ssize_t sftp_read(SFTP_FILE *file, void *buf, size_t count);
* @see sftp_async_read()
* @see sftp_open()
*/
-LIBSSH_API int sftp_async_read_begin(SFTP_FILE *file, uint32_t len);
+LIBSSH_API int sftp_async_read_begin(sftp_file file, uint32_t len);
/**
* @brief Wait for an asynchronous read to complete and save the data.
@@ -495,7 +505,7 @@ LIBSSH_API int sftp_async_read_begin(SFTP_FILE *file, uint32_t len);
*
* @see sftp_async_read_begin()
*/
-LIBSSH_API int sftp_async_read(SFTP_FILE *file, void *data, uint32_t len, uint32_t id);
+LIBSSH_API int sftp_async_read(sftp_file file, void *data, uint32_t len, uint32_t id);
/**
* @brief Write to a file using an opened sftp file handle.
@@ -513,7 +523,7 @@ LIBSSH_API int sftp_async_read(SFTP_FILE *file, void *data, uint32_t len, uint32
* @see sftp_read()
* @see sftp_close()
*/
-LIBSSH_API ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count);
+LIBSSH_API ssize_t sftp_write(sftp_file file, const void *buf, size_t count);
/**
* @brief Seek to a specific location in a file.
@@ -524,7 +534,7 @@ LIBSSH_API ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count);
*
* @return 0 on success, < 0 on error.
*/
-LIBSSH_API int sftp_seek(SFTP_FILE *file, uint32_t new_offset);
+LIBSSH_API int sftp_seek(sftp_file file, uint32_t new_offset);
/**
* @brief Seek to a specific location in a file. This is the
@@ -536,7 +546,7 @@ LIBSSH_API int sftp_seek(SFTP_FILE *file, uint32_t new_offset);
*
* @return 0 on success, < 0 on error.
*/
-LIBSSH_API int sftp_seek64(SFTP_FILE *file, uint64_t new_offset);
+LIBSSH_API int sftp_seek64(sftp_file file, uint64_t new_offset);
/**
* @brief Report current byte position in file.
@@ -547,7 +557,7 @@ LIBSSH_API int sftp_seek64(SFTP_FILE *file, uint64_t new_offset);
* of the file associated with the file descriptor. < 0 on
* error.
*/
-LIBSSH_API unsigned long sftp_tell(SFTP_FILE *file);
+LIBSSH_API unsigned long sftp_tell(sftp_file file);
/**
* @brief Report current byte position in file.
@@ -558,7 +568,7 @@ LIBSSH_API unsigned long sftp_tell(SFTP_FILE *file);
* of the file associated with the file descriptor. < 0 on
* error.
*/
-LIBSSH_API uint64_t sftp_tell64(SFTP_FILE *file);
+LIBSSH_API uint64_t sftp_tell64(sftp_file file);
/**
* @brief Rewinds the position of the file pointer to the beginning of the
@@ -566,12 +576,12 @@ LIBSSH_API uint64_t sftp_tell64(SFTP_FILE *file);
*
* @param file Open sftp file handle.
*/
-LIBSSH_API void sftp_rewind(SFTP_FILE *file);
+LIBSSH_API void sftp_rewind(sftp_file file);
/**
* @deprecated Use sftp_unlink() instead.
*/
-LIBSSH_API int sftp_rm(SFTP_SESSION *sftp, const char *file) SFTP_DEPRECATED;
+LIBSSH_API int sftp_rm(sftp_session sftp, const char *file) SFTP_DEPRECATED;
/**
* @brief Unlink (delete) a file.
@@ -582,7 +592,7 @@ LIBSSH_API int sftp_rm(SFTP_SESSION *sftp, const char *file) SFTP_DEPRECATED;
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
-LIBSSH_API int sftp_unlink(SFTP_SESSION *sftp, const char *file);
+LIBSSH_API int sftp_unlink(sftp_session sftp, const char *file);
/**
* @brief Remove a directoy.
@@ -593,7 +603,7 @@ LIBSSH_API int sftp_unlink(SFTP_SESSION *sftp, const char *file);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
-LIBSSH_API int sftp_rmdir(SFTP_SESSION *sftp, const char *directory);
+LIBSSH_API int sftp_rmdir(sftp_session sftp, const char *directory);
/**
* @brief Create a directory.
@@ -608,7 +618,7 @@ LIBSSH_API int sftp_rmdir(SFTP_SESSION *sftp, const char *directory);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
-LIBSSH_API int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode);
+LIBSSH_API int sftp_mkdir(sftp_session sftp, const char *directory, mode_t mode);
/**
* @brief Rename or move a file or directory.
@@ -623,7 +633,7 @@ LIBSSH_API int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
-LIBSSH_API int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname);
+LIBSSH_API int sftp_rename(sftp_session sftp, const char *original, const char *newname);
/**
* @brief Set file attributes on a file, directory or symbolic link.
@@ -637,7 +647,7 @@ LIBSSH_API int sftp_rename(SFTP_SESSION *sftp, const char *original, const char
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
-LIBSSH_API int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr);
+LIBSSH_API int sftp_setstat(sftp_session sftp, const char *file, sftp_attributes attr);
/**
* @brief Change the file owner and group
@@ -652,7 +662,7 @@ LIBSSH_API int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTE
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
-LIBSSH_API int sftp_chown(SFTP_SESSION *sftp, const char *file, uid_t owner, gid_t group);
+LIBSSH_API int sftp_chown(sftp_session sftp, const char *file, uid_t owner, gid_t group);
/**
* @brief Change permissions of a file
@@ -667,7 +677,7 @@ LIBSSH_API int sftp_chown(SFTP_SESSION *sftp, const char *file, uid_t owner, gid
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
-LIBSSH_API int sftp_chmod(SFTP_SESSION *sftp, const char *file, mode_t mode);
+LIBSSH_API int sftp_chmod(sftp_session sftp, const char *file, mode_t mode);
/**
* @brief Change the last modification and access time of a file.
@@ -681,7 +691,7 @@ LIBSSH_API int sftp_chmod(SFTP_SESSION *sftp, const char *file, mode_t mode);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
-LIBSSH_API int sftp_utimes(SFTP_SESSION *sftp, const char *file, const struct timeval *times);
+LIBSSH_API int sftp_utimes(sftp_session sftp, const char *file, const struct timeval *times);
/**
* @brief Create a symbolic link.
@@ -694,7 +704,7 @@ LIBSSH_API int sftp_utimes(SFTP_SESSION *sftp, const char *file, const struct ti
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
-LIBSSH_API int sftp_symlink(SFTP_SESSION *sftp, const char *target, const char *dest);
+LIBSSH_API int sftp_symlink(sftp_session sftp, const char *target, const char *dest);
/**
* @brief Read the value of a symbolic link.
@@ -705,7 +715,7 @@ LIBSSH_API int sftp_symlink(SFTP_SESSION *sftp, const char *target, const char *
*
* @return The target of the link, NULL on error.
*/
-LIBSSH_API char *sftp_readlink(SFTP_SESSION *sftp, const char *path);
+LIBSSH_API char *sftp_readlink(sftp_session sftp, const char *path);
/**
* @brief Get information about a mounted file system.
@@ -716,7 +726,7 @@ LIBSSH_API char *sftp_readlink(SFTP_SESSION *sftp, const char *path);
*
* @return A statvfs structure or NULL on error.
*/
-LIBSSH_API SFTP_STATVFS *sftp_statvfs(SFTP_SESSION *sftp, const char *path);
+LIBSSH_API sftp_statvfs_t sftp_statvfs(sftp_session sftp, const char *path);
/**
* @brief Get information about a mounted file system.
@@ -725,14 +735,14 @@ LIBSSH_API SFTP_STATVFS *sftp_statvfs(SFTP_SESSION *sftp, const char *path);
*
* @return A statvfs structure or NULL on error.
*/
-LIBSSH_API SFTP_STATVFS *sftp_fstatvfs(SFTP_FILE *file);
+LIBSSH_API sftp_statvfs_t sftp_fstatvfs(sftp_file file);
/**
* @brief Free the memory of an allocated statvfs.
*
* @param statvfs_o The statvfs to free.
*/
-LIBSSH_API void sftp_statvfs_free(SFTP_STATVFS *statvfs_o);
+LIBSSH_API void sftp_statvfs_free(sftp_statvfs_t statvfs_o);
/**
* @brief Canonicalize a sftp path.
@@ -743,7 +753,7 @@ LIBSSH_API void sftp_statvfs_free(SFTP_STATVFS *statvfs_o);
*
* @return The canonicalize path, NULL on error.
*/
-LIBSSH_API char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path);
+LIBSSH_API char *sftp_canonicalize_path(sftp_session sftp, const char *path);
/**
* @brief Get the version of the SFTP protocol supported by the server
@@ -752,7 +762,7 @@ LIBSSH_API char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path);
*
* @return The server version.
*/
-LIBSSH_API int sftp_server_version(SFTP_SESSION *sftp);
+LIBSSH_API int sftp_server_version(sftp_session sftp);
#ifdef WITH_SERVER
/**
@@ -764,7 +774,7 @@ LIBSSH_API int sftp_server_version(SFTP_SESSION *sftp);
*
* @return A new sftp server session.
*/
-LIBSSH_API SFTP_SESSION *sftp_server_new(ssh_session session, ssh_channel chan);
+LIBSSH_API sftp_session sftp_server_new(ssh_session session, ssh_channel chan);
/**
* @brief Intialize the sftp server.
@@ -773,32 +783,32 @@ LIBSSH_API SFTP_SESSION *sftp_server_new(ssh_session session, ssh_channel chan);
*
* @return 0 on success, < 0 on error.
*/
-LIBSSH_API int sftp_server_init(SFTP_SESSION *sftp);
+LIBSSH_API int sftp_server_init(sftp_session sftp);
#endif /* WITH_SERVER */
/* this is not a public interface */
#define SFTP_HANDLES 256
-SFTP_PACKET *sftp_packet_read(SFTP_SESSION *sftp);
-int sftp_packet_write(SFTP_SESSION *sftp,uint8_t type, ssh_buffer payload);
-void sftp_packet_free(SFTP_PACKET *packet);
-int buffer_add_attributes(ssh_buffer buffer, SFTP_ATTRIBUTES *attr);
-SFTP_ATTRIBUTES *sftp_parse_attr(SFTP_SESSION *session, ssh_buffer buf,int expectname);
+sftp_packet sftp_packet_read(sftp_session sftp);
+int sftp_packet_write(sftp_session sftp,uint8_t type, ssh_buffer payload);
+void sftp_packet_free(sftp_packet packet);
+int buffer_add_attributes(ssh_buffer buffer, sftp_attributes attr);
+sftp_attributes sftp_parse_attr(sftp_session session, ssh_buffer buf,int expectname);
/* sftpserver.c */
-SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp);
-void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg);
-int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
- SFTP_ATTRIBUTES *attr);
-int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, ssh_string handle);
-ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info);
-int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr);
-void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle);
-int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, uint32_t status, const char *message);
-int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file,
- const char *longname, SFTP_ATTRIBUTES *attr);
-int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg);
-int sftp_reply_data(SFTP_CLIENT_MESSAGE *msg, const void *data, int len);
-void sftp_handle_remove(SFTP_SESSION *sftp, void *handle);
+sftp_client_message sftp_get_client_message(sftp_session sftp);
+void sftp_client_message_free(sftp_client_message msg);
+int sftp_reply_name(sftp_client_message msg, const char *name,
+ sftp_attributes attr);
+int sftp_reply_handle(sftp_client_message msg, ssh_string handle);
+ssh_string sftp_handle_alloc(sftp_session sftp, void *info);
+int sftp_reply_attr(sftp_client_message msg, sftp_attributes attr);
+void *sftp_handle(sftp_session sftp, ssh_string handle);
+int sftp_reply_status(sftp_client_message msg, uint32_t status, const char *message);
+int sftp_reply_names_add(sftp_client_message msg, const char *file,
+ const char *longname, sftp_attributes attr);
+int sftp_reply_names(sftp_client_message msg);
+int sftp_reply_data(sftp_client_message msg, const void *data, int len);
+void sftp_handle_remove(sftp_session sftp, void *handle);
/* SFTP commands and constants */
#define SSH_FXP_INIT 1
diff --git a/libssh/sftp.c b/libssh/sftp.c
index ec244a2..cdeb9e2 100644
--- a/libssh/sftp.c
+++ b/libssh/sftp.c
@@ -63,10 +63,10 @@ struct sftp_ext_struct {
};
/* functions */
-static int sftp_enqueue(SFTP_SESSION *session, SFTP_MESSAGE *msg);
-static void sftp_message_free(SFTP_MESSAGE *msg);
-static void sftp_set_error(SFTP_SESSION *sftp, int errnum);
-static void status_msg_free(STATUS_MESSAGE *status);
+static int sftp_enqueue(sftp_session session, sftp_message msg);
+static void sftp_message_free(sftp_message msg);
+static void sftp_set_error(sftp_session sftp, int errnum);
+static void status_msg_free(sftp_status_message status);
static sftp_ext sftp_ext_new(void) {
sftp_ext ext;
@@ -99,8 +99,8 @@ static void sftp_ext_free(sftp_ext ext) {
SAFE_FREE(ext);
}
-SFTP_SESSION *sftp_new(ssh_session session){
- SFTP_SESSION *sftp;
+sftp_session sftp_new(ssh_session session){
+ sftp_session sftp;
enter_function();
@@ -109,7 +109,7 @@ SFTP_SESSION *sftp_new(ssh_session session){
return NULL;
}
- sftp = malloc(sizeof(SFTP_SESSION));
+ sftp = malloc(sizeof(struct sftp_session_struct));
if (sftp == NULL) {
leave_function();
return NULL;
@@ -149,10 +149,10 @@ SFTP_SESSION *sftp_new(ssh_session session){
}
#ifdef WITH_SERVER
-SFTP_SESSION *sftp_server_new(ssh_session session, ssh_channel chan){
- SFTP_SESSION *sftp = NULL;
+sftp_session sftp_server_new(ssh_session session, ssh_channel chan){
+ sftp_session sftp = NULL;
- sftp = malloc(sizeof(SFTP_SESSION));
+ sftp = malloc(sizeof(struct sftp_session_struct));
if (sftp == NULL) {
return NULL;
}
@@ -164,9 +164,9 @@ SFTP_SESSION *sftp_server_new(ssh_session session, ssh_channel chan){
return sftp;
}
-int sftp_server_init(SFTP_SESSION *sftp){
+int sftp_server_init(sftp_session sftp){
ssh_session session = sftp->session;
- SFTP_PACKET *packet = NULL;
+ sftp_packet packet = NULL;
ssh_buffer reply = NULL;
uint32_t version;
@@ -229,8 +229,8 @@ int sftp_server_init(SFTP_SESSION *sftp){
}
#endif /* WITH_SERVER */
-void sftp_free(SFTP_SESSION *sftp){
- struct request_queue *ptr;
+void sftp_free(sftp_session sftp){
+ sftp_request_queue ptr;
if (sftp == NULL) {
return;
@@ -239,7 +239,7 @@ void sftp_free(SFTP_SESSION *sftp){
channel_send_eof(sftp->channel);
ptr = sftp->queue;
while(ptr) {
- struct request_queue *old;
+ sftp_request_queue old;
sftp_message_free(ptr->message);
old = ptr->next;
SAFE_FREE(ptr);
@@ -253,7 +253,7 @@ void sftp_free(SFTP_SESSION *sftp){
SAFE_FREE(sftp);
}
-int sftp_packet_write(SFTP_SESSION *sftp, uint8_t type, ssh_buffer payload){
+int sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload){
int size;
if (buffer_prepend_data(payload, &type, sizeof(uint8_t)) < 0) {
@@ -279,13 +279,13 @@ int sftp_packet_write(SFTP_SESSION *sftp, uint8_t type, ssh_buffer payload){
return size;
}
-SFTP_PACKET *sftp_packet_read(SFTP_SESSION *sftp) {
- SFTP_PACKET *packet = NULL;
+sftp_packet sftp_packet_read(sftp_session sftp) {
+ sftp_packet packet = NULL;
uint32_t size;
sftp_enter_function();
- packet = malloc(sizeof(SFTP_PACKET));
+ packet = malloc(sizeof(struct sftp_packet_struct));
if (packet == NULL) {
return NULL;
}
@@ -332,14 +332,14 @@ SFTP_PACKET *sftp_packet_read(SFTP_SESSION *sftp) {
return packet;
}
-static void sftp_set_error(SFTP_SESSION *sftp, int errnum) {
+static void sftp_set_error(sftp_session sftp, int errnum) {
if (sftp != NULL) {
sftp->errnum = errnum;
}
}
/* Get the last sftp error */
-int sftp_get_error(SFTP_SESSION *sftp) {
+int sftp_get_error(sftp_session sftp) {
if (sftp == NULL) {
return -1;
}
@@ -347,12 +347,12 @@ int sftp_get_error(SFTP_SESSION *sftp) {
return sftp->errnum;
}
-static SFTP_MESSAGE *sftp_message_new(SFTP_SESSION *sftp){
- SFTP_MESSAGE *msg = NULL;
+static sftp_message sftp_message_new(sftp_session sftp){
+ sftp_message msg = NULL;
sftp_enter_function();
- msg = malloc(sizeof(SFTP_MESSAGE));
+ msg = malloc(sizeof(struct sftp_message_struct));
if (msg == NULL) {
return NULL;
}
@@ -369,8 +369,8 @@ static SFTP_MESSAGE *sftp_message_new(SFTP_SESSION *sftp){
return msg;
}
-static void sftp_message_free(SFTP_MESSAGE *msg) {
- SFTP_SESSION *sftp;
+static void sftp_message_free(sftp_message msg) {
+ sftp_session sftp;
if (msg == NULL) {
return;
@@ -385,9 +385,9 @@ static void sftp_message_free(SFTP_MESSAGE *msg) {
sftp_leave_function();
}
-static SFTP_MESSAGE *sftp_get_message(SFTP_PACKET *packet) {
- SFTP_SESSION *sftp = packet->sftp;
- SFTP_MESSAGE *msg = NULL;
+static sftp_message sftp_get_message(sftp_packet packet) {
+ sftp_session sftp = packet->sftp;
+ sftp_message msg = NULL;
sftp_enter_function();
@@ -434,9 +434,9 @@ static SFTP_MESSAGE *sftp_get_message(SFTP_PACKET *packet) {
return msg;
}
-static int sftp_read_and_dispatch(SFTP_SESSION *sftp) {
- SFTP_PACKET *packet = NULL;
- SFTP_MESSAGE *msg = NULL;
+static int sftp_read_and_dispatch(sftp_session sftp) {
+ sftp_packet packet = NULL;
+ sftp_message msg = NULL;
sftp_enter_function();
@@ -463,7 +463,7 @@ static int sftp_read_and_dispatch(SFTP_SESSION *sftp) {
return 0;
}
-void sftp_packet_free(SFTP_PACKET *packet) {
+void sftp_packet_free(sftp_packet packet) {
if (packet == NULL) {
return;
}
@@ -473,8 +473,8 @@ void sftp_packet_free(SFTP_PACKET *packet) {
}
/* Initialize the sftp session with the server. */
-int sftp_init(SFTP_SESSION *sftp) {
- SFTP_PACKET *packet = NULL;
+int sftp_init(sftp_session sftp) {
+ sftp_packet packet = NULL;
ssh_buffer buffer = NULL;
ssh_string ext_name_s = NULL;
ssh_string ext_data_s = NULL;
@@ -582,7 +582,7 @@ int sftp_init(SFTP_SESSION *sftp) {
return 0;
}
-unsigned int sftp_extensions_get_count(SFTP_SESSION *sftp) {
+unsigned int sftp_extensions_get_count(sftp_session sftp) {
if (sftp == NULL || sftp->ext == NULL) {
return 0;
}
@@ -590,7 +590,7 @@ unsigned int sftp_extensions_get_count(SFTP_SESSION *sftp) {
return sftp->ext->count;
}
-const char *sftp_extensions_get_name(SFTP_SESSION *sftp, unsigned int idx) {
+const char *sftp_extensions_get_name(sftp_session sftp, unsigned int idx) {
if (sftp == NULL || sftp->ext == NULL || sftp->ext->name == NULL) {
return NULL;
}
@@ -602,7 +602,7 @@ const char *sftp_extensions_get_name(SFTP_SESSION *sftp, unsigned int idx) {
return sftp->ext->name[idx];
}
-const char *sftp_extensions_get_data(SFTP_SESSION *sftp, unsigned int idx) {
+const char *sftp_extensions_get_data(sftp_session sftp, unsigned int idx) {
if (sftp == NULL || sftp->ext == NULL || sftp->ext->data == NULL) {
return NULL;
}
@@ -614,7 +614,7 @@ const char *sftp_extensions_get_data(SFTP_SESSION *sftp, unsigned int idx) {
return sftp->ext->data[idx];
}
-int sftp_extension_supported(SFTP_SESSION *sftp, const char *name,
+int sftp_extension_supported(sftp_session sftp, const char *name,
const char *data) {
int i, n;
@@ -629,10 +629,10 @@ int sftp_extension_supported(SFTP_SESSION *sftp, const char *name,
return 0;
}
-static REQUEST_QUEUE *request_queue_new(SFTP_MESSAGE *msg) {
- REQUEST_QUEUE *queue = NULL;
+static sftp_request_queue request_queue_new(sftp_message msg) {
+ sftp_request_queue queue = NULL;
- queue = malloc(sizeof(REQUEST_QUEUE));
+ queue = malloc(sizeof(struct sftp_request_queue_struct));
if (queue == NULL) {
return NULL;
}
@@ -643,7 +643,7 @@ static REQUEST_QUEUE *request_queue_new(SFTP_MESSAGE *msg) {
return queue;
}
-static void request_queue_free(REQUEST_QUEUE *queue) {
+static void request_queue_free(sftp_request_queue queue) {
if (queue == NULL) {
return;
}
@@ -652,9 +652,9 @@ static void request_queue_free(REQUEST_QUEUE *queue) {
SAFE_FREE(queue);
}
-static int sftp_enqueue(SFTP_SESSION *sftp, SFTP_MESSAGE *msg) {
- REQUEST_QUEUE *queue = NULL;
- REQUEST_QUEUE *ptr;
+static int sftp_enqueue(sftp_session sftp, sftp_message msg) {
+ sftp_request_queue queue = NULL;
+ sftp_request_queue ptr;
queue = request_queue_new(msg);
if (queue == NULL) {
@@ -682,10 +682,10 @@ static int sftp_enqueue(SFTP_SESSION *sftp, SFTP_MESSAGE *msg) {
* Pulls of a message from the queue based on the ID.
* Returns NULL if no message has been found.
*/
-static SFTP_MESSAGE *sftp_dequeue(SFTP_SESSION *sftp, uint32_t id){
- REQUEST_QUEUE *prev = NULL;
- REQUEST_QUEUE *queue;
- SFTP_MESSAGE *msg;
+static sftp_message sftp_dequeue(sftp_session sftp, uint32_t id){
+ sftp_request_queue prev = NULL;
+ sftp_request_queue queue;
+ sftp_message msg;
if(sftp->queue == NULL) {
return NULL;
@@ -720,12 +720,12 @@ static SFTP_MESSAGE *sftp_dequeue(SFTP_SESSION *sftp, uint32_t id){
* between them.
* Returns a new ID ready to use in a request
*/
-static inline uint32_t sftp_get_new_id(SFTP_SESSION *session) {
+static inline uint32_t sftp_get_new_id(sftp_session session) {
return ++session->id_counter;
}
-static STATUS_MESSAGE *parse_status_msg(SFTP_MESSAGE *msg){
- STATUS_MESSAGE *status;
+static sftp_status_message parse_status_msg(sftp_message msg){
+ sftp_status_message status;
if (msg->packet_type != SSH_FXP_STATUS) {
ssh_set_error(msg->sftp->session, SSH_FATAL,
@@ -733,7 +733,7 @@ static STATUS_MESSAGE *parse_status_msg(SFTP_MESSAGE *msg){
return NULL;
}
- status = malloc(sizeof(STATUS_MESSAGE));
+ status = malloc(sizeof(struct sftp_message_struct));
if (status == NULL) {
return NULL;
}
@@ -762,7 +762,7 @@ static STATUS_MESSAGE *parse_status_msg(SFTP_MESSAGE *msg){
return status;
}
-static void status_msg_free(STATUS_MESSAGE *status){
+static void status_msg_free(sftp_status_message status){
if (status == NULL) {
return;
}
@@ -774,8 +774,8 @@ static void status_msg_free(STATUS_MESSAGE *status){
SAFE_FREE(status);
}
-static SFTP_FILE *parse_handle_msg(SFTP_MESSAGE *msg){
- SFTP_FILE *file;
+static sftp_file parse_handle_msg(sftp_message msg){
+ sftp_file file;
if(msg->packet_type != SSH_FXP_HANDLE) {
ssh_set_error(msg->sftp->session, SSH_FATAL,
@@ -783,7 +783,7 @@ static SFTP_FILE *parse_handle_msg(SFTP_MESSAGE *msg){
return NULL;
}
- file = malloc(sizeof(SFTP_FILE));
+ file = malloc(sizeof(struct sftp_file_struct));
if (file == NULL) {
return NULL;
}
@@ -805,11 +805,11 @@ static SFTP_FILE *parse_handle_msg(SFTP_MESSAGE *msg){
}
/* Open a directory */
-SFTP_DIR *sftp_opendir(SFTP_SESSION *sftp, const char *path){
- SFTP_MESSAGE *msg = NULL;
- SFTP_FILE *file = NULL;
- SFTP_DIR *dir = NULL;
- STATUS_MESSAGE *status;
+sftp_dir sftp_opendir(sftp_session sftp, const char *path){
+ sftp_message msg = NULL;
+ sftp_file file = NULL;
+ sftp_dir dir = NULL;
+ sftp_status_message status;
ssh_string path_s;
ssh_buffer payload;
uint32_t id;
@@ -864,7 +864,7 @@ SFTP_DIR *sftp_opendir(SFTP_SESSION *sftp, const char *path){
file = parse_handle_msg(msg);
sftp_message_free(msg);
if (file != NULL) {
- dir = malloc(sizeof(SFTP_DIR));
+ dir = malloc(sizeof(struct sftp_dir_struct));
if (dir == NULL) {
return NULL;
}
@@ -895,9 +895,9 @@ SFTP_DIR *sftp_opendir(SFTP_SESSION *sftp, const char *path){
* baselines from the protocol version 4.
* This code is more or less dead but maybe we need it in future.
*/
-static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, ssh_buffer buf,
+static sftp_attributes sftp_parse_attr_4(sftp_session sftp, ssh_buffer buf,
int expectnames) {
- SFTP_ATTRIBUTES *attr;
+ sftp_attributes attr;
ssh_string owner = NULL;
ssh_string group = NULL;
uint32_t flags = 0;
@@ -906,7 +906,7 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, ssh_buffer buf,
/* unused member variable */
(void) expectnames;
- attr = malloc(sizeof(SFTP_ATTRIBUTES));
+ attr = malloc(sizeof(struct sftp_attributes_struct));
if (attr == NULL) {
return NULL;
}
@@ -1069,15 +1069,15 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, ssh_buffer buf,
string extended_data
... more extended data (extended_type - extended_data pairs),
so that number of pairs equals extended_count */
-static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, ssh_buffer buf,
+static sftp_attributes sftp_parse_attr_3(sftp_session sftp, ssh_buffer buf,
int expectname) {
ssh_string longname = NULL;
ssh_string name = NULL;
- SFTP_ATTRIBUTES *attr;
+ sftp_attributes attr;
uint32_t flags = 0;
int ok = 0;
- attr = malloc(sizeof(SFTP_ATTRIBUTES));
+ attr = malloc(sizeof(struct sftp_attributes_struct));
if (attr == NULL) {
return NULL;
}
@@ -1208,7 +1208,7 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, ssh_buffer buf,
}
/* FIXME is this really needed as a public function? */
-int buffer_add_attributes(ssh_buffer buffer, SFTP_ATTRIBUTES *attr) {
+int buffer_add_attributes(ssh_buffer buffer, sftp_attributes attr) {
uint32_t flags = (attr ? attr->flags : 0);
flags &= (SSH_FILEXFER_ATTR_SIZE | SSH_FILEXFER_ATTR_UIDGID |
@@ -1250,7 +1250,7 @@ int buffer_add_attributes(ssh_buffer buffer, SFTP_ATTRIBUTES *attr) {
}
-SFTP_ATTRIBUTES *sftp_parse_attr(SFTP_SESSION *session, ssh_buffer buf,
+sftp_attributes sftp_parse_attr(sftp_session session, ssh_buffer buf,
int expectname) {
switch(session->version) {
case 4:
@@ -1267,15 +1267,15 @@ SFTP_ATTRIBUTES *sftp_parse_attr(SFTP_SESSION *session, ssh_buffer buf,
}
/* Get the version of the SFTP protocol supported by the server */
-int sftp_server_version(SFTP_SESSION *sftp) {
+int sftp_server_version(sftp_session sftp) {
return sftp->server_version;
}
/* Get a single file attributes structure of a directory. */
-SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *sftp, SFTP_DIR *dir) {
- SFTP_MESSAGE *msg = NULL;
- STATUS_MESSAGE *status;
- SFTP_ATTRIBUTES *attr;
+sftp_attributes sftp_readdir(sftp_session sftp, sftp_dir dir) {
+ sftp_message msg = NULL;
+ sftp_status_message status;
+ sftp_attributes attr;
ssh_buffer payload;
uint32_t id;
@@ -1374,12 +1374,12 @@ SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *sftp, SFTP_DIR *dir) {
}
/* Tell if the directory has reached EOF (End Of File). */
-int sftp_dir_eof(SFTP_DIR *dir) {
+int sftp_dir_eof(sftp_dir dir) {
return dir->eof;
}
/* Free a SFTP_ATTRIBUTE handle */
-void sftp_attributes_free(SFTP_ATTRIBUTES *file){
+void sftp_attributes_free(sftp_attributes file){
if (file == NULL) {
return;
}
@@ -1396,9 +1396,9 @@ void sftp_attributes_free(SFTP_ATTRIBUTES *file){
SAFE_FREE(file);
}
-static int sftp_handle_close(SFTP_SESSION *sftp, ssh_string handle) {
- STATUS_MESSAGE *status;
- SFTP_MESSAGE *msg = NULL;
+static int sftp_handle_close(sftp_session sftp, ssh_string handle) {
+ sftp_status_message status;
+ sftp_message msg = NULL;
ssh_buffer buffer = NULL;
uint32_t id;
@@ -1453,12 +1453,12 @@ static int sftp_handle_close(SFTP_SESSION *sftp, ssh_string handle) {
return -1;
}
-int sftp_file_close(SFTP_FILE *file) {
+int sftp_file_close(sftp_file file) {
return sftp_close(file);
}
/* Close an open file handle. */
-int sftp_close(SFTP_FILE *file){
+int sftp_close(sftp_file file){
int err = SSH_NO_ERROR;
SAFE_FREE(file->name);
@@ -1472,12 +1472,12 @@ int sftp_close(SFTP_FILE *file){
return err;
}
-int sftp_dir_close(SFTP_DIR *dir) {
+int sftp_dir_close(sftp_dir dir) {
return sftp_closedir(dir);
}
/* Close an open directory. */
-int sftp_closedir(SFTP_DIR *dir){
+int sftp_closedir(sftp_dir dir){
int err = SSH_NO_ERROR;
SAFE_FREE(dir->name);
@@ -1493,12 +1493,12 @@ int sftp_closedir(SFTP_DIR *dir){
}
/* Open a file on the server. */
-SFTP_FILE *sftp_open(SFTP_SESSION *sftp, const char *file, int flags,
+sftp_file sftp_open(sftp_session sftp, const char *file, int flags,
mode_t mode) {
- SFTP_MESSAGE *msg = NULL;
- STATUS_MESSAGE *status;
- SFTP_ATTRIBUTES attr;
- SFTP_FILE *handle;
+ sftp_message msg = NULL;
+ sftp_status_message status;
+ struct sftp_attributes_struct attr;
+ sftp_file handle;
ssh_string filename;
ssh_buffer buffer;
uint32_t sftp_flags = 0;
@@ -1584,18 +1584,18 @@ SFTP_FILE *sftp_open(SFTP_SESSION *sftp, const char *file, int flags,
return NULL;
}
-void sftp_file_set_nonblocking(SFTP_FILE *handle){
+void sftp_file_set_nonblocking(sftp_file handle){
handle->nonblocking=1;
}
-void sftp_file_set_blocking(SFTP_FILE *handle){
+void sftp_file_set_blocking(sftp_file handle){
handle->nonblocking=0;
}
/* Read from a file using an opened sftp file handle. */
-ssize_t sftp_read(SFTP_FILE *handle, void *buf, size_t count) {
- SFTP_SESSION *sftp = handle->sftp;
- SFTP_MESSAGE *msg = NULL;
- STATUS_MESSAGE *status;
+ssize_t sftp_read(sftp_file handle, void *buf, size_t count) {
+ sftp_session sftp = handle->sftp;
+ sftp_message msg = NULL;
+ sftp_status_message status;
ssh_string datastring;
ssh_buffer buffer;
int id;
@@ -1686,8 +1686,8 @@ ssize_t sftp_read(SFTP_FILE *handle, void *buf, size_t count) {
}
/* Start an asynchronous read from a file using an opened sftp file handle. */
-int sftp_async_read_begin(SFTP_FILE *file, uint32_t len){
- SFTP_SESSION *sftp = file->sftp;
+int sftp_async_read_begin(sftp_file file, uint32_t len){
+ sftp_session sftp = file->sftp;
ssh_buffer buffer;
uint32_t id;
@@ -1716,10 +1716,10 @@ int sftp_async_read_begin(SFTP_FILE *file, uint32_t len){
}
/* Wait for an asynchronous read to complete and save the data. */
-int sftp_async_read(SFTP_FILE *file, void *data, uint32_t size, uint32_t id){
- SFTP_SESSION *sftp = file->sftp;
- SFTP_MESSAGE *msg = NULL;
- STATUS_MESSAGE *status;
+int sftp_async_read(sftp_file file, void *data, uint32_t size, uint32_t id){
+ sftp_session sftp = file->sftp;
+ sftp_message msg = NULL;
+ sftp_status_message status;
ssh_string datastring;
int err = SSH_OK;
uint32_t len;
@@ -1806,10 +1806,10 @@ int sftp_async_read(SFTP_FILE *file, void *data, uint32_t size, uint32_t id){
return SSH_ERROR;
}
-ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count) {
- SFTP_SESSION *sftp = file->sftp;
- SFTP_MESSAGE *msg = NULL;
- STATUS_MESSAGE *status;
+ssize_t sftp_write(sftp_file file, const void *buf, size_t count) {
+ sftp_session sftp = file->sftp;
+ sftp_message msg = NULL;
+ sftp_status_message status;
ssh_string datastring;
ssh_buffer buffer;
uint32_t id;
@@ -1888,7 +1888,7 @@ ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count) {
}
/* Seek to a specific location in a file. */
-int sftp_seek(SFTP_FILE *file, uint32_t new_offset) {
+int sftp_seek(sftp_file file, uint32_t new_offset) {
if (file == NULL) {
return -1;
}
@@ -1898,7 +1898,7 @@ int sftp_seek(SFTP_FILE *file, uint32_t new_offset) {
return 0;
}
-int sftp_seek64(SFTP_FILE *file, uint64_t new_offset) {
+int sftp_seek64(sftp_file file, uint64_t new_offset) {
if (file == NULL) {
return -1;
}
@@ -1909,28 +1909,28 @@ int sftp_seek64(SFTP_FILE *file, uint64_t new_offset) {
}
/* Report current byte position in file. */
-unsigned long sftp_tell(SFTP_FILE *file) {
+unsigned long sftp_tell(sftp_file file) {
return (unsigned long)file->offset;
}
/* Report current byte position in file. */
-uint64_t sftp_tell64(SFTP_FILE *file) {
+uint64_t sftp_tell64(sftp_file file) {
return (uint64_t) file->offset;
}
/* Rewinds the position of the file pointer to the beginning of the file.*/
-void sftp_rewind(SFTP_FILE *file) {
+void sftp_rewind(sftp_file file) {
file->offset = 0;
}
/* deprecated */
-int sftp_rm(SFTP_SESSION *sftp, const char *file) {
+int sftp_rm(sftp_session sftp, const char *file) {
return sftp_unlink(sftp, file);
}
/* code written by Nick */
-int sftp_unlink(SFTP_SESSION *sftp, const char *file) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
+int sftp_unlink(sftp_session sftp, const char *file) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
ssh_string filename;
ssh_buffer buffer;
uint32_t id;
@@ -1997,9 +1997,9 @@ int sftp_unlink(SFTP_SESSION *sftp, const char *file) {
}
/* code written by Nick */
-int sftp_rmdir(SFTP_SESSION *sftp, const char *directory) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
+int sftp_rmdir(sftp_session sftp, const char *directory) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
ssh_string filename;
ssh_buffer buffer;
uint32_t id;
@@ -2064,11 +2064,11 @@ int sftp_rmdir(SFTP_SESSION *sftp, const char *directory) {
}
/* Code written by Nick */
-int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
- SFTP_ATTRIBUTES *errno_attr = NULL;
- SFTP_ATTRIBUTES attr;
+int sftp_mkdir(sftp_session sftp, const char *directory, mode_t mode) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
+ sftp_attributes errno_attr = NULL;
+ struct sftp_attributes_struct attr;
ssh_buffer buffer;
ssh_string path;
uint32_t id;
@@ -2153,9 +2153,9 @@ int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode) {
}
/* code written by nick */
-int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
+int sftp_rename(sftp_session sftp, const char *original, const char *newname) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
ssh_buffer buffer;
ssh_string oldpath;
ssh_string newpath;
@@ -2237,12 +2237,12 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) {
/* Code written by Nick */
/* Set file attributes on a file, directory or symbolic link. */
-int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr) {
+int sftp_setstat(sftp_session sftp, const char *file, sftp_attributes attr) {
uint32_t id = sftp_get_new_id(sftp);
ssh_buffer buffer = buffer_new();
ssh_string path = string_from_char(file);
- SFTP_MESSAGE *msg = NULL;
- STATUS_MESSAGE *status = NULL;
+ sftp_message msg = NULL;
+ sftp_status_message status = NULL;
buffer = buffer_new();
if (buffer == NULL) {
@@ -2307,9 +2307,8 @@ int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr) {
}
/* Change the file owner and group */
-int sftp_chown(SFTP_SESSION *sftp, const char *file, uid_t owner, gid_t group) {
- SFTP_ATTRIBUTES attr;
-
+int sftp_chown(sftp_session sftp, const char *file, uid_t owner, gid_t group) {
+ struct sftp_attributes_struct attr;
ZERO_STRUCT(attr);
attr.uid = owner;
@@ -2320,9 +2319,8 @@ int sftp_chown(SFTP_SESSION *sftp, const char *file, uid_t owner, gid_t group) {
}
/* Change permissions of a file */
-int sftp_chmod(SFTP_SESSION *sftp, const char *file, mode_t mode) {
- SFTP_ATTRIBUTES attr;
-
+int sftp_chmod(sftp_session sftp, const char *file, mode_t mode) {
+ struct sftp_attributes_struct attr;
ZERO_STRUCT(attr);
attr.permissions = mode;
attr.flags = SSH_FILEXFER_ATTR_PERMISSIONS;
@@ -2331,10 +2329,9 @@ int sftp_chmod(SFTP_SESSION *sftp, const char *file, mode_t mode) {
}
/* Change the last modification and access time of a file. */
-int sftp_utimes(SFTP_SESSION *sftp, const char *file,
+int sftp_utimes(sftp_session sftp, const char *file,
const struct timeval *times) {
- SFTP_ATTRIBUTES attr;
-
+ struct sftp_attributes_struct attr;
ZERO_STRUCT(attr);
attr.atime = times[0].tv_sec;
@@ -2349,9 +2346,9 @@ int sftp_utimes(SFTP_SESSION *sftp, const char *file,
return sftp_setstat(sftp, file, &attr);
}
-int sftp_symlink(SFTP_SESSION *sftp, const char *target, const char *dest) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
+int sftp_symlink(sftp_session sftp, const char *target, const char *dest) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
ssh_string target_s;
ssh_string dest_s;
ssh_buffer buffer;
@@ -2454,9 +2451,9 @@ int sftp_symlink(SFTP_SESSION *sftp, const char *target, const char *dest) {
return -1;
}
-char *sftp_readlink(SFTP_SESSION *sftp, const char *path) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
+char *sftp_readlink(sftp_session sftp, const char *path) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
ssh_string path_s = NULL;
ssh_string link_s = NULL;
ssh_buffer buffer;
@@ -2528,12 +2525,12 @@ char *sftp_readlink(SFTP_SESSION *sftp, const char *path) {
return NULL;
}
-static SFTP_STATVFS *sftp_parse_statvfs(SFTP_SESSION *sftp, ssh_buffer buf) {
- SFTP_STATVFS *statvfs;
+static sftp_statvfs_t sftp_parse_statvfs(sftp_session sftp, ssh_buffer buf) {
+ sftp_statvfs_t statvfs;
uint64_t tmp;
int ok = 0;
- statvfs = malloc(sizeof(SFTP_STATVFS));
+ statvfs = malloc(sizeof(struct sftp_statvfs_struct));
if (statvfs == NULL) {
return NULL;
}
@@ -2619,9 +2616,9 @@ static SFTP_STATVFS *sftp_parse_statvfs(SFTP_SESSION *sftp, ssh_buffer buf) {
return statvfs;
}
-SFTP_STATVFS *sftp_statvfs(SFTP_SESSION *sftp, const char *path) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
+sftp_statvfs_t sftp_statvfs(sftp_session sftp, const char *path) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
ssh_string pathstr;
ssh_string ext;
ssh_buffer buffer;
@@ -2671,7 +2668,7 @@ SFTP_STATVFS *sftp_statvfs(SFTP_SESSION *sftp, const char *path) {
}
if (msg->packet_type == SSH_FXP_EXTENDED_REPLY) {
- SFTP_STATVFS *buf = sftp_parse_statvfs(sftp, msg->payload);
+ sftp_statvfs_t buf = sftp_parse_statvfs(sftp, msg->payload);
sftp_message_free(msg);
if (buf == NULL) {
return NULL;
@@ -2696,10 +2693,10 @@ SFTP_STATVFS *sftp_statvfs(SFTP_SESSION *sftp, const char *path) {
return NULL;
}
-SFTP_STATVFS *sftp_fstatvfs(SFTP_FILE *file) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
- SFTP_SESSION *sftp;
+sftp_statvfs_t sftp_fstatvfs(sftp_file file) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
+ sftp_session sftp;
ssh_string ext;
ssh_buffer buffer;
uint32_t id;
@@ -2740,7 +2737,7 @@ SFTP_STATVFS *sftp_fstatvfs(SFTP_FILE *file) {
}
if (msg->packet_type == SSH_FXP_EXTENDED_REPLY) {
- SFTP_STATVFS *buf = sftp_parse_statvfs(sftp, msg->payload);
+ sftp_statvfs_t buf = sftp_parse_statvfs(sftp, msg->payload);
sftp_message_free(msg);
if (buf == NULL) {
return NULL;
@@ -2765,7 +2762,7 @@ SFTP_STATVFS *sftp_fstatvfs(SFTP_FILE *file) {
return NULL;
}
-void sftp_statvfs_free(SFTP_STATVFS *statvfs) {
+void sftp_statvfs_free(sftp_statvfs_t statvfs) {
if (statvfs == NULL) {
return;
}
@@ -2774,9 +2771,9 @@ void sftp_statvfs_free(SFTP_STATVFS *statvfs) {
}
/* another code written by Nick */
-char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
+char *sftp_canonicalize_path(sftp_session sftp, const char *path) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
ssh_string name = NULL;
ssh_string pathstr;
ssh_buffer buffer;
@@ -2848,10 +2845,10 @@ char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path) {
return NULL;
}
-static SFTP_ATTRIBUTES *sftp_xstat(SFTP_SESSION *sftp, const char *path,
+static sftp_attributes sftp_xstat(sftp_session sftp, const char *path,
int param) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
ssh_string pathstr;
ssh_buffer buffer;
uint32_t id;
@@ -2906,17 +2903,17 @@ static SFTP_ATTRIBUTES *sftp_xstat(SFTP_SESSION *sftp, const char *path,
return NULL;
}
-SFTP_ATTRIBUTES *sftp_stat(SFTP_SESSION *session, const char *path) {
+sftp_attributes sftp_stat(sftp_session session, const char *path) {
return sftp_xstat(session, path, SSH_FXP_STAT);
}
-SFTP_ATTRIBUTES *sftp_lstat(SFTP_SESSION *session, const char *path) {
+sftp_attributes sftp_lstat(sftp_session session, const char *path) {
return sftp_xstat(session, path, SSH_FXP_LSTAT);
}
-SFTP_ATTRIBUTES *sftp_fstat(SFTP_FILE *file) {
- STATUS_MESSAGE *status = NULL;
- SFTP_MESSAGE *msg = NULL;
+sftp_attributes sftp_fstat(sftp_file file) {
+ sftp_status_message status = NULL;
+ sftp_message msg = NULL;
ssh_buffer buffer;
uint32_t id;
diff --git a/libssh/sftpserver.c b/libssh/sftpserver.c
index 431b40d..bc72f57 100644
--- a/libssh/sftpserver.c
+++ b/libssh/sftpserver.c
@@ -36,13 +36,13 @@
#include "libssh/buffer.h"
#include "libssh/misc.h"
-SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp) {
- SFTP_PACKET *packet;
- SFTP_CLIENT_MESSAGE *msg;
+sftp_client_message sftp_get_client_message(sftp_session sftp) {
+ sftp_packet packet;
+ sftp_client_message msg;
ssh_buffer payload;
ssh_string tmp;
- msg = malloc(sizeof (SFTP_CLIENT_MESSAGE));
+ msg = malloc(sizeof (struct sftp_client_message_struct));
if (msg == NULL) {
return NULL;
}
@@ -213,7 +213,7 @@ SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp) {
return msg;
}
-void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg) {
+void sftp_client_message_free(sftp_client_message msg) {
if (msg == NULL) {
return;
}
@@ -227,8 +227,8 @@ void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg) {
SAFE_FREE(msg);
}
-int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
- SFTP_ATTRIBUTES *attr) {
+int sftp_reply_name(sftp_client_message msg, const char *name,
+ sftp_attributes attr) {
ssh_buffer out;
ssh_string file;
@@ -259,7 +259,7 @@ int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
return 0;
}
-int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, ssh_string handle){
+int sftp_reply_handle(sftp_client_message msg, ssh_string handle){
ssh_buffer out;
out = buffer_new();
@@ -278,7 +278,7 @@ int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, ssh_string handle){
return 0;
}
-int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr) {
+int sftp_reply_attr(sftp_client_message msg, sftp_attributes attr) {
ssh_buffer out;
out = buffer_new();
@@ -297,8 +297,8 @@ int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr) {
return 0;
}
-int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file,
- const char *longname, SFTP_ATTRIBUTES *attr) {
+int sftp_reply_names_add(sftp_client_message msg, const char *file,
+ const char *longname, sftp_attributes attr) {
ssh_string name;
name = string_from_char(file);
@@ -335,7 +335,7 @@ int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file,
return 0;
}
-int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg) {
+int sftp_reply_names(sftp_client_message msg) {
ssh_buffer out;
out = buffer_new();
@@ -363,7 +363,7 @@ int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg) {
return 0;
}
-int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, uint32_t status,
+int sftp_reply_status(sftp_client_message msg, uint32_t status,
const char *message) {
ssh_buffer out;
ssh_string s;
@@ -395,7 +395,7 @@ int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, uint32_t status,
return 0;
}
-int sftp_reply_data(SFTP_CLIENT_MESSAGE *msg, const void *data, int len) {
+int sftp_reply_data(sftp_client_message msg, const void *data, int len) {
ssh_buffer out;
out = buffer_new();
@@ -421,7 +421,7 @@ int sftp_reply_data(SFTP_CLIENT_MESSAGE *msg, const void *data, int len) {
* the handle. Care is given that a corrupted handle won't give a
* valid info (or worse).
*/
-ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info) {
+ssh_string sftp_handle_alloc(sftp_session sftp, void *info) {
ssh_string ret;
uint32_t val;
int i;
@@ -456,7 +456,7 @@ ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info) {
return ret;
}
-void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle){
+void *sftp_handle(sftp_session sftp, ssh_string handle){
uint32_t val;
if (sftp->handles == NULL) {
@@ -476,7 +476,7 @@ void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle){
return sftp->handles[val];
}
-void sftp_handle_remove(SFTP_SESSION *sftp, void *handle) {
+void sftp_handle_remove(sftp_session sftp, void *handle) {
int i;
for (i = 0; i < SFTP_HANDLES; i++) {