Add functions to get the extension count, name and data.
Этот коммит содержится в:
родитель
b9b7174d85
Коммит
b4111c5c18
@ -201,6 +201,40 @@ int sftp_init(SFTP_SESSION *sftp);
|
||||
*/
|
||||
int sftp_get_error(SFTP_SESSION *sftp);
|
||||
|
||||
/**
|
||||
* @brief Get the count of extensions provided by the server.
|
||||
*
|
||||
* @param sftp The sftp session to use.
|
||||
*
|
||||
* @return The count of extensions provided by the server, 0 on error or
|
||||
* not available.
|
||||
*/
|
||||
unsigned int sftp_extensions_get_count(SFTP_SESSION *sftp);
|
||||
|
||||
/**
|
||||
* @brief Get the name of the extension provided by the server.
|
||||
*
|
||||
* @param sftp The sftp session to use.
|
||||
*
|
||||
* @param index The index number of the extension name you want.
|
||||
*
|
||||
* @return The name of the extension.
|
||||
*/
|
||||
const char *sftp_extensions_get_name(SFTP_SESSION *sftp, unsigned int index);
|
||||
|
||||
/**
|
||||
* @brief Get the data of the extension provided by the server.
|
||||
*
|
||||
* This is normally the version number of the extension.
|
||||
*
|
||||
* @param sftp The sftp session to use.
|
||||
*
|
||||
* @param index The index number of the extension data you want.
|
||||
*
|
||||
* @return The data of the extension.
|
||||
*/
|
||||
const char *sftp_extensions_get_data(SFTP_SESSION *sftp, unsigned int index);
|
||||
|
||||
/**
|
||||
* @brief Open a directory used to obtain directory entries.
|
||||
*
|
||||
|
@ -587,6 +587,38 @@ int sftp_init(SFTP_SESSION *sftp) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int sftp_extensions_get_count(SFTP_SESSION *sftp) {
|
||||
if (sftp == NULL || sftp->ext == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sftp->ext->count;
|
||||
}
|
||||
|
||||
const char *sftp_extensions_get_name(SFTP_SESSION *sftp, unsigned int index) {
|
||||
if (sftp == NULL || sftp->ext == NULL || sftp->ext->name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (index > sftp->ext->count) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return sftp->ext->name[index];
|
||||
}
|
||||
|
||||
const char *sftp_extensions_get_data(SFTP_SESSION *sftp, unsigned int index) {
|
||||
if (sftp == NULL || sftp->ext == NULL || sftp->ext->data == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (index > sftp->ext->count) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return sftp->ext->data[index];
|
||||
}
|
||||
|
||||
static REQUEST_QUEUE *request_queue_new(SFTP_MESSAGE *msg) {
|
||||
REQUEST_QUEUE *queue = NULL;
|
||||
|
||||
|
12
sample.c
12
sample.c
@ -283,10 +283,12 @@ void do_sftp(SSH_SESSION *session){
|
||||
SFTP_FILE *fichier;
|
||||
SFTP_FILE *to;
|
||||
int len=1;
|
||||
int i;
|
||||
unsigned int i;
|
||||
char data[8000]={0};
|
||||
char *link;
|
||||
|
||||
unsigned int count;
|
||||
|
||||
if(!sftp_session){
|
||||
fprintf(stderr, "sftp error initialising channel: %s\n",
|
||||
ssh_get_error(session));
|
||||
@ -298,6 +300,14 @@ void do_sftp(SSH_SESSION *session){
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Additional SFTP extensions provided by the server:\n");
|
||||
count = sftp_extensions_get_count(sftp_session);
|
||||
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));
|
||||
}
|
||||
|
||||
/* test symlink and readlink */
|
||||
if (sftp_symlink(sftp_session, "/tmp/this_is_the_link",
|
||||
"/tmp/sftp_symlink_test") < 0) {
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user