Deleted Added
full compact
sftp-common.c (124208) sftp-common.c (126274)
1/*
2 * Copyright (c) 2001 Markus Friedl. All rights reserved.
3 * Copyright (c) 2001 Damien Miller. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 10 unchanged lines hidden (view full) ---

19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "includes.h"
1/*
2 * Copyright (c) 2001 Markus Friedl. All rights reserved.
3 * Copyright (c) 2001 Damien Miller. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 10 unchanged lines hidden (view full) ---

19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "includes.h"
27RCSID("$OpenBSD: sftp-common.c,v 1.9 2003/05/24 09:30:40 djm Exp $");
27RCSID("$OpenBSD: sftp-common.c,v 1.10 2003/11/10 16:23:41 jakob Exp $");
28
29#include "buffer.h"
30#include "bufaux.h"
31#include "log.h"
32#include "xmalloc.h"
33
34#include "sftp.h"
35#include "sftp-common.h"

--- 8 unchanged lines hidden (view full) ---

44 a->gid = 0;
45 a->perm = 0;
46 a->atime = 0;
47 a->mtime = 0;
48}
49
50/* Convert from struct stat to filexfer attribs */
51void
28
29#include "buffer.h"
30#include "bufaux.h"
31#include "log.h"
32#include "xmalloc.h"
33
34#include "sftp.h"
35#include "sftp-common.h"

--- 8 unchanged lines hidden (view full) ---

44 a->gid = 0;
45 a->perm = 0;
46 a->atime = 0;
47 a->mtime = 0;
48}
49
50/* Convert from struct stat to filexfer attribs */
51void
52stat_to_attrib(struct stat *st, Attrib *a)
52stat_to_attrib(const struct stat *st, Attrib *a)
53{
54 attrib_clear(a);
55 a->flags = 0;
56 a->flags |= SSH2_FILEXFER_ATTR_SIZE;
57 a->size = st->st_size;
58 a->flags |= SSH2_FILEXFER_ATTR_UIDGID;
59 a->uid = st->st_uid;
60 a->gid = st->st_gid;
61 a->flags |= SSH2_FILEXFER_ATTR_PERMISSIONS;
62 a->perm = st->st_mode;
63 a->flags |= SSH2_FILEXFER_ATTR_ACMODTIME;
64 a->atime = st->st_atime;
65 a->mtime = st->st_mtime;
66}
67
68/* Convert from filexfer attribs to struct stat */
69void
53{
54 attrib_clear(a);
55 a->flags = 0;
56 a->flags |= SSH2_FILEXFER_ATTR_SIZE;
57 a->size = st->st_size;
58 a->flags |= SSH2_FILEXFER_ATTR_UIDGID;
59 a->uid = st->st_uid;
60 a->gid = st->st_gid;
61 a->flags |= SSH2_FILEXFER_ATTR_PERMISSIONS;
62 a->perm = st->st_mode;
63 a->flags |= SSH2_FILEXFER_ATTR_ACMODTIME;
64 a->atime = st->st_atime;
65 a->mtime = st->st_mtime;
66}
67
68/* Convert from filexfer attribs to struct stat */
69void
70attrib_to_stat(Attrib *a, struct stat *st)
70attrib_to_stat(const Attrib *a, struct stat *st)
71{
72 memset(st, 0, sizeof(*st));
73
74 if (a->flags & SSH2_FILEXFER_ATTR_SIZE)
75 st->st_size = a->size;
76 if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) {
77 st->st_uid = a->uid;
78 st->st_gid = a->gid;

--- 40 unchanged lines hidden (view full) ---

119 xfree(data);
120 }
121 }
122 return &a;
123}
124
125/* Encode attributes to buffer */
126void
71{
72 memset(st, 0, sizeof(*st));
73
74 if (a->flags & SSH2_FILEXFER_ATTR_SIZE)
75 st->st_size = a->size;
76 if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) {
77 st->st_uid = a->uid;
78 st->st_gid = a->gid;

--- 40 unchanged lines hidden (view full) ---

119 xfree(data);
120 }
121 }
122 return &a;
123}
124
125/* Encode attributes to buffer */
126void
127encode_attrib(Buffer *b, Attrib *a)
127encode_attrib(Buffer *b, const Attrib *a)
128{
129 buffer_put_int(b, a->flags);
130 if (a->flags & SSH2_FILEXFER_ATTR_SIZE)
131 buffer_put_int64(b, a->size);
132 if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) {
133 buffer_put_int(b, a->uid);
134 buffer_put_int(b, a->gid);
135 }

--- 33 unchanged lines hidden (view full) ---

169 }
170 /* NOTREACHED */
171}
172
173/*
174 * drwxr-xr-x 5 markus markus 1024 Jan 13 18:39 .ssh
175 */
176char *
128{
129 buffer_put_int(b, a->flags);
130 if (a->flags & SSH2_FILEXFER_ATTR_SIZE)
131 buffer_put_int64(b, a->size);
132 if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) {
133 buffer_put_int(b, a->uid);
134 buffer_put_int(b, a->gid);
135 }

--- 33 unchanged lines hidden (view full) ---

169 }
170 /* NOTREACHED */
171}
172
173/*
174 * drwxr-xr-x 5 markus markus 1024 Jan 13 18:39 .ssh
175 */
176char *
177ls_file(char *name, struct stat *st, int remote)
177ls_file(const char *name, const struct stat *st, int remote)
178{
179 int ulen, glen, sz = 0;
180 struct passwd *pw;
181 struct group *gr;
182 struct tm *ltime = localtime(&st->st_mtime);
183 char *user, *group;
184 char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1];
185

--- 28 unchanged lines hidden ---
178{
179 int ulen, glen, sz = 0;
180 struct passwd *pw;
181 struct group *gr;
182 struct tm *ltime = localtime(&st->st_mtime);
183 char *user, *group;
184 char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1];
185

--- 28 unchanged lines hidden ---