Transmit a literal and/or match token. * * This delightfully-named function is called either when we find a * match and need to transmit all the unmatched data leading up to it, * or when we get bored of accumulating literal data and just need to * transmit it. As a result of this second case, it is called even if * we have not matched at all! * * If i >= 0, the number of a matched token.
| 103 | * only literal data. A -1 will send a 0-token-int too, and a -2 sends |
| 104 | * only literal data, w/o any token-int. */ |
| 105 | static void matched(int f, struct sum_struct *s, struct map_struct *buf, OFF_T offset, int32 i) |
| 106 | { |
| 107 | int32 n = (int32)(offset - last_match); /* max value: block_size (int32) */ |
| 108 | int32 j; |
| 109 | |
| 110 | if (DEBUG_GTE(DELTASUM, 2) && i >= 0) { |
| 111 | rprintf(FINFO, |
| 112 | "match at %s last_match=%s j=%d len=%ld n=%ld\n", |
| 113 | big_num(offset), big_num(last_match), i, |
| 114 | (long)s->sums[i].len, (long)n); |
| 115 | } |
| 116 | |
| 117 | send_token(f, i, buf, last_match, n, i < 0 ? 0 : s->sums[i].len); |
| 118 | data_transfer += n; |
| 119 | |
| 120 | if (i >= 0) { |
| 121 | stats.matched_data += s->sums[i].len; |
| 122 | n += s->sums[i].len; |
| 123 | } |
| 124 | |
| 125 | for (j = 0; j < n; j += CHUNK_SIZE) { |
| 126 | int32 n1 = MIN(CHUNK_SIZE, n - j); |
| 127 | sum_update(map_ptr(buf, last_match + j, n1), n1); |
| 128 | } |
| 129 | |
| 130 | if (i >= 0) |
| 131 | last_match = offset + s->sums[i].len; |
| 132 | else |
| 133 | last_match = offset; |
| 134 | |
| 135 | if (buf && INFO_GTE(PROGRESS, 1)) |
| 136 | show_progress(last_match, buf->file_size); |
| 137 | } |
| 138 | |
| 139 | |
| 140 | static void hash_search(int f,struct sum_struct *s, |
no test coverage detected