X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/9486289ce452ab82ca8b3f16fae8c2ef5247a923..45f133b9769fb45a329d3d41e121109d430e307d:/token.c?ds=sidebyside diff --git a/token.c b/token.c index a377b295..318bdbc2 100644 --- a/token.c +++ b/token.c @@ -26,44 +26,46 @@ extern int do_compression; /* non-compressing recv token */ static int simple_recv_token(int f,char **data) { - static int residue; - static char *buf; - int n; - - if (!buf) { - buf = (char *)malloc(CHUNK_SIZE); - if (!buf) out_of_memory("simple_recv_token"); - } + static int residue; + static char *buf; + int n; + if (!buf) { + buf = (char *)malloc(CHUNK_SIZE); + if (!buf) out_of_memory("simple_recv_token"); + } - if (residue == 0) { - int i = read_int(f); - if (i <= 0) return i; - residue = i; - } + if (residue == 0) { + int i = read_int(f); + if (i <= 0) return i; + residue = i; + } - *data = buf; - n = MIN(CHUNK_SIZE,residue); - residue -= n; - read_buf(f,buf,n); - return n; + *data = buf; + n = MIN(CHUNK_SIZE,residue); + residue -= n; + read_buf(f,buf,n); + return n; } /* non-compressing send token */ static void simple_send_token(int f,int token, - struct map_struct *buf,int offset,int n) + struct map_struct *buf,OFF_T offset,int n) { - if (n > 0) { - int l = 0; - while (l < n) { - int n1 = MIN(CHUNK_SIZE,n-l); - write_int(f,n1); - write_buf(f,map_ptr(buf,offset+l,n1),n1); - l += n1; - } - } - write_int(f,-(token+1)); + if (n > 0) { + int l = 0; + while (l < n) { + int n1 = MIN(CHUNK_SIZE,n-l); + write_int(f,n1); + write_buf(f,map_ptr(buf,offset+l,n1),n1); + l += n1; + } + } + /* a -2 token means to send data only and no token */ + if (token != -2) { + write_int(f,-(token+1)); + } } @@ -104,7 +106,7 @@ static char *obuf; /* Send a deflated token */ static void send_deflated_token(int f, int token, - struct map_struct *buf, int offset, int nb, int toklen) + struct map_struct *buf, OFF_T offset, int nb, int toklen) { int n, r; static int init_done; @@ -351,7 +353,7 @@ see_deflate_token(char *buf, int len) * If token == -1 then we have reached EOF * If n == 0 then don't send a buffer */ -void send_token(int f,int token,struct map_struct *buf,int offset, +void send_token(int f,int token,struct map_struct *buf,OFF_T offset, int n,int toklen) { if (!do_compression) {