*/
#include "includes.h"
-RCSID("$OpenBSD: sftp-common.c,v 1.1 2001/02/04 11:11:54 djm Exp $");
+RCSID("$OpenBSD: sftp-common.c,v 1.6 2002/06/23 09:30:14 deraadt Exp $");
#include "buffer.h"
#include "bufaux.h"
-#include "getput.h"
#include "log.h"
#include "xmalloc.h"
#include "sftp.h"
#include "sftp-common.h"
+/* Clear contents of attributes structure */
void
attrib_clear(Attrib *a)
{
a->mtime = 0;
}
+/* Convert from struct stat to filexfer attribs */
void
stat_to_attrib(struct stat *st, Attrib *a)
{
a->mtime = st->st_mtime;
}
+/* Decode attributes in buffer */
Attrib *
decode_attrib(Buffer *b)
{
static Attrib a;
+
attrib_clear(&a);
a.flags = buffer_get_int(b);
if (a.flags & SSH2_FILEXFER_ATTR_SIZE)
if (a.flags & SSH2_FILEXFER_ATTR_EXTENDED) {
char *type, *data;
int i, count;
+
count = buffer_get_int(b);
for (i = 0; i < count; i++) {
type = buffer_get_string(b, NULL);
return &a;
}
+/* Encode attributes to buffer */
void
encode_attrib(Buffer *b, Attrib *a)
{
}
}
+/* Convert from SSH2_FX_ status to text error message */
const char *
fx2txt(int status)
{
switch (status) {
case SSH2_FX_OK:
- return("No Error");
+ return("No error");
case SSH2_FX_EOF:
- return("End of File");
+ return("End of file");
case SSH2_FX_NO_SUCH_FILE:
- return("No Such File");
+ return("No such file or directory");
case SSH2_FX_PERMISSION_DENIED:
- return("Permission Denied");
+ return("Permission denied");
case SSH2_FX_FAILURE:
return("Failure");
case SSH2_FX_BAD_MESSAGE:
return("Operation unsupported");
default:
return("Unknown status");
- };
+ }
/* NOTREACHED */
}
-