version 1.11, 2001/03/07 10:11:22 |
version 1.12, 2001/03/13 22:42:54 |
|
|
return(status); |
return(status); |
} |
} |
|
|
|
|
int |
int |
do_ls(int fd_in, int fd_out, char *path) |
do_lsreaddir(int fd_in, int fd_out, char *path, int printflag, |
|
SFTP_DIRENT ***dir) |
{ |
{ |
Buffer msg; |
Buffer msg; |
u_int type, id, handle_len, i, expected_id; |
u_int type, id, handle_len, i, expected_id, ents; |
char *handle; |
char *handle; |
|
|
id = msg_id++; |
id = msg_id++; |
|
|
if (handle == NULL) |
if (handle == NULL) |
return(-1); |
return(-1); |
|
|
|
if (dir) { |
|
ents = 0; |
|
*dir = xmalloc(sizeof(**dir)); |
|
(*dir)[0] = NULL; |
|
} |
|
|
|
|
for(;;) { |
for(;;) { |
int count; |
int count; |
|
|
|
|
longname = buffer_get_string(&msg, NULL); |
longname = buffer_get_string(&msg, NULL); |
a = decode_attrib(&msg); |
a = decode_attrib(&msg); |
|
|
printf("%s\n", longname); |
if (printflag) |
|
printf("%s\n", longname); |
|
|
|
if (dir) { |
|
*dir = xrealloc(*dir, sizeof(**dir) * |
|
(ents + 2)); |
|
(*dir)[ents] = xmalloc(sizeof(***dir)); |
|
(*dir)[ents]->filename = xstrdup(filename); |
|
(*dir)[ents]->longname = xstrdup(longname); |
|
memcpy(&(*dir)[ents]->a, a, sizeof(*a)); |
|
(*dir)[++ents] = NULL; |
|
} |
|
|
xfree(filename); |
xfree(filename); |
xfree(longname); |
xfree(longname); |
} |
} |
|
|
} |
} |
|
|
int |
int |
|
do_ls(int fd_in, int fd_out, char *path) |
|
{ |
|
return(do_lsreaddir(fd_in, fd_out, path, 1, NULL)); |
|
} |
|
|
|
int |
|
do_readdir(int fd_in, int fd_out, char *path, SFTP_DIRENT ***dir) |
|
{ |
|
return(do_lsreaddir(fd_in, fd_out, path, 0, dir)); |
|
} |
|
|
|
void free_sftp_dirents(SFTP_DIRENT **s) |
|
{ |
|
int i; |
|
|
|
for(i = 0; s[i]; i++) { |
|
xfree(s[i]->filename); |
|
xfree(s[i]->longname); |
|
xfree(s[i]); |
|
} |
|
xfree(s); |
|
} |
|
|
|
int |
do_rm(int fd_in, int fd_out, char *path) |
do_rm(int fd_in, int fd_out, char *path) |
{ |
{ |
u_int status, id; |
u_int status, id; |
|
|
buffer_free(&msg); |
buffer_free(&msg); |
return status; |
return status; |
} |
} |
|
|