Changed the *_abbbrevint() functions to *_varint().
authorWayne Davison <wayned@samba.org>
Fri, 20 Apr 2007 02:17:58 +0000 (02:17 +0000)
committerWayne Davison <wayned@samba.org>
Fri, 20 Apr 2007 02:17:58 +0000 (02:17 +0000)
acls.c
flist.c
io.c
io.h
uidlist.c
xattrs.c

diff --git a/acls.c b/acls.c
index bfb12c7..6f20cf3 100644 (file)
--- a/acls.c
+++ b/acls.c
@@ -559,11 +559,11 @@ static void send_ida_entries(const ida_entries *idal, int user_names, int f)
        id_access *ida;
        size_t count = idal->count;
 
-       write_abbrevint(f, idal->count);
+       write_varint(f, idal->count);
 
        for (ida = idal->idas; count--; ida++) {
                char *name = user_names ? add_uid(ida->id) : add_gid(ida->id);
-               write_abbrevint(f, ida->id);
+               write_varint(f, ida->id);
                if (inc_recurse && name) {
                        int len = strlen(name);
                        write_byte(f, ida->access | (uchar)0x80);
@@ -580,7 +580,7 @@ static void send_rsync_acl(rsync_acl *racl, SMB_ACL_TYPE_T type,
        int ndx = find_matching_rsync_acl(racl, type, racl_list);
 
        /* Send 0 (-1 + 1) to indicate that literal ACL data follows. */
-       write_abbrevint(f, ndx + 1);
+       write_varint(f, ndx + 1);
 
        if (ndx < 0) {
                rsync_acl *new_racl = EXPAND_ITEM_LIST(racl_list, rsync_acl, 1000);
@@ -672,7 +672,7 @@ static uchar recv_acl_access(uchar *name_follows_val, int f)
 static uchar recv_ida_entries(ida_entries *ent, int user_names, int f)
 {
        uchar computed_mask_bits = 0;
-       int i, count = read_abbrevint(f);
+       int i, count = read_varint(f);
 
        if (count) {
                if (!(ent->idas = new_array(id_access, ent->count)))
@@ -684,7 +684,7 @@ static uchar recv_ida_entries(ida_entries *ent, int user_names, int f)
 
        for (i = 0; i < count; i++) {
                uchar has_name;
-               id_t id = read_abbrevint(f);
+               id_t id = read_varint(f);
                int access = recv_acl_access(&has_name, f);
 
                if (has_name) {
@@ -713,7 +713,7 @@ static int recv_rsync_acl(item_list *racl_list, SMB_ACL_TYPE_T type, int f)
        uchar computed_mask_bits = 0;
        acl_duo *duo_item;
        uchar flags;
-       int ndx = read_abbrevint(f);
+       int ndx = read_varint(f);
 
        if (ndx < 0 || (size_t)ndx > racl_list->count) {
                rprintf(FERROR, "recv_acl_index: %s ACL index %d > %d\n",
diff --git a/flist.c b/flist.c
index 23def37..aa1efac 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -471,13 +471,13 @@ static void send_file_entry(int f, struct file_struct *file, int ndx)
        if (flags & XMIT_SAME_NAME)
                write_byte(f, l1);
        if (flags & XMIT_LONG_NAME)
-               write_abbrevint30(f, l2);
+               write_varint30(f, l2);
        else
                write_byte(f, l2);
        write_buf(f, fname + l1, l2);
 
        if (first_hlink_ndx >= 0) {
-               write_abbrevint30(f, first_hlink_ndx);
+               write_varint30(f, first_hlink_ndx);
                goto the_end;
        }
 
@@ -490,7 +490,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx)
                if (protocol_version < 30)
                        write_int(f, uid);
                else {
-                       write_abbrevint(f, uid);
+                       write_varint(f, uid);
                        if (flags & XMIT_USER_NAME_FOLLOWS) {
                                int len = strlen(user_name);
                                write_byte(f, len);
@@ -502,7 +502,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx)
                if (protocol_version < 30)
                        write_int(f, gid);
                else {
-                       write_abbrevint(f, gid);
+                       write_varint(f, gid);
                        if (flags & XMIT_GROUP_NAME_FOLLOWS) {
                                int len = strlen(group_name);
                                write_byte(f, len);
@@ -517,9 +517,9 @@ static void send_file_entry(int f, struct file_struct *file, int ndx)
                                write_int(f, (int)rdev);
                } else {
                        if (!(flags & XMIT_SAME_RDEV_MAJOR))
-                               write_abbrevint30(f, major(rdev));
+                               write_varint30(f, major(rdev));
                        if (protocol_version >= 30)
-                               write_abbrevint(f, minor(rdev));
+                               write_varint(f, minor(rdev));
                        else if (flags & XMIT_RDEV_MINOR_8_pre30)
                                write_byte(f, minor(rdev));
                        else
@@ -531,7 +531,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx)
        if (preserve_links && S_ISLNK(mode)) {
                const char *sl = F_SYMLINK(file);
                int len = strlen(sl);
-               write_abbrevint30(f, len);
+               write_varint30(f, len);
                write_buf(f, sl, len);
        }
 #endif
@@ -597,7 +597,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
                l1 = read_byte(f);
 
        if (flags & XMIT_LONG_NAME)
-               l2 = read_abbrevint30(f);
+               l2 = read_varint30(f);
        else
                l2 = read_byte(f);
 
@@ -636,7 +636,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
        if (protocol_version >= 30
         && BITS_SETnUNSET(flags, XMIT_HLINKED, XMIT_HLINK_FIRST)) {
                struct file_struct *first;
-               first_hlink_ndx = read_abbrevint30(f);
+               first_hlink_ndx = read_varint30(f);
                if (first_hlink_ndx < 0 || first_hlink_ndx >= flist->count) {
                        rprintf(FERROR,
                                "hard-link reference out of range: %d (%d)\n",
@@ -678,7 +678,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
                if (protocol_version < 30)
                        uid = (uid_t)read_int(f);
                else {
-                       uid = (uid_t)read_abbrevint(f);
+                       uid = (uid_t)read_varint(f);
                        if (flags & XMIT_USER_NAME_FOLLOWS)
                                uid = recv_user_name(f, uid);
                        else if (inc_recurse && am_root && !numeric_ids)
@@ -689,7 +689,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
                if (protocol_version < 30)
                        gid = (gid_t)read_int(f);
                else {
-                       gid = (gid_t)read_abbrevint(f);
+                       gid = (gid_t)read_varint(f);
                        if (flags & XMIT_GROUP_NAME_FOLLOWS)
                                gid = recv_group_name(f, gid);
                        else if (inc_recurse && (!am_root || !numeric_ids))
@@ -705,9 +705,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
                } else {
                        uint32 rdev_minor;
                        if (!(flags & XMIT_SAME_RDEV_MAJOR))
-                               rdev_major = read_abbrevint30(f);
+                               rdev_major = read_varint30(f);
                        if (protocol_version >= 30)
-                               rdev_minor = read_abbrevint(f);
+                               rdev_minor = read_varint(f);
                        else if (flags & XMIT_RDEV_MINOR_8_pre30)
                                rdev_minor = read_byte(f);
                        else
@@ -721,7 +721,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
 
 #ifdef SUPPORT_LINKS
        if (preserve_links && S_ISLNK(mode)) {
-               linkname_len = read_abbrevint30(f) + 1; /* count the '\0' */
+               linkname_len = read_varint30(f) + 1; /* count the '\0' */
                if (linkname_len <= 0 || linkname_len > MAXPATHLEN) {
                        rprintf(FERROR, "overflow: linkname_len=%d\n",
                                linkname_len - 1);
diff --git a/io.c b/io.c
index eecab20..2557440 100644 (file)
--- a/io.c
+++ b/io.c
@@ -998,7 +998,7 @@ unsigned short read_shortint(int f)
        return (UVAL(b, 1) << 8) + UVAL(b, 0);
 }
 
-int32 read_abbrevint(int f)
+int32 read_varint(int f)
 {
        int32 num;
        char b[5];
@@ -1404,7 +1404,7 @@ void write_shortint(int f, unsigned short x)
        writefd(f, b, 2);
 }
 
-void write_abbrevint(int f, int32 x)
+void write_varint(int f, int32 x)
 {
        char b[5];
        if ((uint32)x < ((uint32)1<<(1*8-1))) {
diff --git a/io.h b/io.h
index 360a947..dc43683 100644 (file)
--- a/io.h
+++ b/io.h
 extern int protocol_version;
 
 static inline int32
-read_abbrevint30(int f)
+read_varint30(int f)
 {
        if (protocol_version < 30)
                return read_int(f);
-       return read_abbrevint(f);
+       return read_varint(f);
 }
 
 static inline void
-write_abbrevint30(int f, int32 x)
+write_varint30(int f, int32 x)
 {
        if (protocol_version < 30)
                write_int(f, x);
        else
-               write_abbrevint(f, x);
+               write_varint(f, x);
 }
index 47c5aba..72bff3c 100644 (file)
--- a/uidlist.c
+++ b/uidlist.c
@@ -280,14 +280,14 @@ void send_uid_list(int f)
                        if (!list->name)
                                continue;
                        len = strlen(list->name);
-                       write_abbrevint30(f, list->id);
+                       write_varint30(f, list->id);
                        write_byte(f, len);
                        write_buf(f, list->name, len);
                }
 
                /* terminate the uid list with a 0 uid. We explicitly exclude
                 * 0 from the list */
-               write_abbrevint30(f, 0);
+               write_varint30(f, 0);
        }
 
        if (preserve_gid || preserve_acls) {
@@ -296,11 +296,11 @@ void send_uid_list(int f)
                        if (!list->name)
                                continue;
                        len = strlen(list->name);
-                       write_abbrevint30(f, list->id);
+                       write_varint30(f, list->id);
                        write_byte(f, len);
                        write_buf(f, list->name, len);
                }
-               write_abbrevint30(f, 0);
+               write_varint30(f, 0);
        }
 }
 
@@ -332,13 +332,13 @@ void recv_uid_list(int f, struct file_list *flist)
 
        if ((preserve_uid || preserve_acls) && !numeric_ids) {
                /* read the uid list */
-               while ((id = read_abbrevint30(f)) != 0)
+               while ((id = read_varint30(f)) != 0)
                        recv_user_name(f, (uid_t)id);
        }
 
        if ((preserve_gid || preserve_acls) && !numeric_ids) {
                /* read the gid list */
-               while ((id = read_abbrevint30(f)) != 0)
+               while ((id = read_varint30(f)) != 0)
                        recv_group_name(f, (gid_t)id);
        }
 
index 793ebbf..e4d8dde 100644 (file)
--- a/xattrs.c
+++ b/xattrs.c
@@ -316,28 +316,28 @@ int send_xattr(statx *sxp, int f)
        int ndx = find_matching_xattr(sxp->xattr);
 
        /* Send 0 (-1 + 1) to indicate that literal xattr data follows. */
-       write_abbrevint(f, ndx + 1);
+       write_varint(f, ndx + 1);
 
        if (ndx < 0) {
                rsync_xa *rxa;
                int count = sxp->xattr->count;
-               write_abbrevint(f, count);
+               write_varint(f, count);
                for (rxa = sxp->xattr->items; count--; rxa++) {
 #ifdef HAVE_LINUX_XATTRS
-                       write_abbrevint(f, rxa->name_len);
-                       write_abbrevint(f, rxa->datum_len);
+                       write_varint(f, rxa->name_len);
+                       write_varint(f, rxa->datum_len);
                        write_buf(f, rxa->name, rxa->name_len);
 #else
                        /* We strip the rsync prefix from disguised namespaces
                         * and put everything else in the user namespace. */
                        if (HAS_PREFIX(rxa->name, RSYNC_PREFIX)
                         && rxa->name[RPRE_LEN] != '%') {
-                               write_abbrevint(f, rxa->name_len - RPRE_LEN);
-                               write_abbrevint(f, rxa->datum_len);
+                               write_varint(f, rxa->name_len - RPRE_LEN);
+                               write_varint(f, rxa->datum_len);
                                write_buf(f, rxa->name + RPRE_LEN, rxa->name_len - RPRE_LEN);
                        } else {
-                               write_abbrevint(f, rxa->name_len + UPRE_LEN);
-                               write_abbrevint(f, rxa->datum_len);
+                               write_varint(f, rxa->name_len + UPRE_LEN);
+                               write_varint(f, rxa->datum_len);
                                write_buf(f, USER_PREFIX, UPRE_LEN);
                                write_buf(f, rxa->name, rxa->name_len);
                        }
@@ -454,7 +454,7 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
                /* Flag that we handled this abbreviated item. */
                rxa->datum[0] = XSTATE_DONE;
 
-               write_abbrevint(f_out, j - prior_req);
+               write_varint(f_out, j - prior_req);
                prior_req = j;
 
                if (fname) {
@@ -465,7 +465,7 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
                        if (!(ptr = get_xattr_data(fname, rxa->name, &len, 0)))
                                continue;
 
-                       write_abbrevint(f_out, len); /* length might have changed! */
+                       write_varint(f_out, len); /* length might have changed! */
                        write_buf(f_out, ptr, len);
                        free(ptr);
                }
@@ -515,7 +515,7 @@ void recv_xattr_request(struct file_struct *file, int f_in)
        cnt = lst->count;
        rxa = lst->items;
        rxa -= 1;
-       while ((rel_pos = read_abbrevint(f_in)) != 0) {
+       while ((rel_pos = read_varint(f_in)) != 0) {
                rxa += rel_pos;
                cnt -= rel_pos;
                if (cnt < 0 || rxa->datum_len <= MAX_FULL_DATUM
@@ -530,7 +530,7 @@ void recv_xattr_request(struct file_struct *file, int f_in)
                }
 
                old_datum = rxa->datum;
-               rxa->datum_len = read_abbrevint(f_in);
+               rxa->datum_len = read_varint(f_in);
 
                if (rxa->name_len + rxa->datum_len < rxa->name_len)
                        out_of_memory("recv_xattr_request"); /* overflow */
@@ -552,7 +552,7 @@ void receive_xattr(struct file_struct *file, int f)
 {
        static item_list temp_xattr = EMPTY_ITEM_LIST;
        int count;
-       int ndx = read_abbrevint(f);
+       int ndx = read_varint(f);
 
        if (ndx < 0 || (size_t)ndx > rsync_xal_l.count) {
                rprintf(FERROR, "receive_xattr: xa index %d out of"
@@ -565,7 +565,7 @@ void receive_xattr(struct file_struct *file, int f)
                return;
        }
        
-       if ((count = read_abbrevint(f)) != 0) {
+       if ((count = read_varint(f)) != 0) {
                (void)EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, count);
                temp_xattr.count = 0;
        }
@@ -573,8 +573,8 @@ void receive_xattr(struct file_struct *file, int f)
        while (count--) {
                char *ptr, *name;
                rsync_xa *rxa;
-               size_t name_len = read_abbrevint(f);
-               size_t datum_len = read_abbrevint(f);
+               size_t name_len = read_varint(f);
+               size_t datum_len = read_varint(f);
                size_t dget_len = datum_len > MAX_FULL_DATUM ? 1 + MAX_DIGEST_LEN : datum_len;
 #ifdef HAVE_LINUX_XATTRS
                size_t extra_len = 0;