-void
-attrib_clear(Attrib *a)
-{
- a->flags = 0;
- a->size_low = 0;
- a->size_high = 0;
- a->size = 0;
- a->uid = 0;
- a->gid = 0;
- a->perm = 0;
- a->atime = 0;
- a->mtime = 0;
-}
-
-Attrib *
-decode_attrib(Buffer *b)
-{
- static Attrib a;
- attrib_clear(&a);
- a.flags = buffer_get_int(b);
- if (a.flags & SSH_FXA_HAVE_SIZE) {
- a.size_high = buffer_get_int(b);
- a.size_low = buffer_get_int(b);
- a.size = (((u_int64_t) a.size_high) << 32) + a.size_low;
- }
- if (a.flags & SSH_FXA_HAVE_UGID) {
- a.uid = buffer_get_int(b);
- a.gid = buffer_get_int(b);
- }
- if (a.flags & SSH_FXA_HAVE_PERM) {
- a.perm = buffer_get_int(b);
- }
- if (a.flags & SSH_FXA_HAVE_TIME) {
- a.atime = buffer_get_int(b);
- a.mtime = buffer_get_int(b);
- }
- return &a;
-}
-
-void
-encode_attrib(Buffer *b, Attrib *a)
-{
- buffer_put_int(b, a->flags);
- if (a->flags & SSH_FXA_HAVE_SIZE) {
- buffer_put_int(b, a->size_high);
- buffer_put_int(b, a->size_low);
- }
- if (a->flags & SSH_FXA_HAVE_UGID) {
- buffer_put_int(b, a->uid);
- buffer_put_int(b, a->gid);
- }
- if (a->flags & SSH_FXA_HAVE_PERM) {
- buffer_put_int(b, a->perm);
- }
- if (a->flags & SSH_FXA_HAVE_TIME) {
- buffer_put_int(b, a->atime);
- buffer_put_int(b, a->mtime);
- }
-}
-
-Attrib *
-stat_to_attrib(struct stat *st)
-{
- static Attrib a;
- attrib_clear(&a);
- a.flags = 0;
- a.flags |= SSH_FXA_HAVE_SIZE;
- a.size = st->st_size;
- a.size_low = a.size;
- a.size_high = (u_int32_t) (a.size >> 32);
- a.flags |= SSH_FXA_HAVE_UGID;
- a.uid = st->st_uid;
- a.gid = st->st_gid;
- a.flags |= SSH_FXA_HAVE_PERM;
- a.perm = st->st_mode;
- a.flags |= SSH_FXA_HAVE_TIME;
- a.atime = st->st_atime;
- a.mtime = st->st_mtime;
- return &a;
-}
-
-Attrib *