MCPcopy Index your code
hub / github.com/RsyncProject/rsync / read_ndx

Function read_ndx

io.c:2365–2397  ·  view source on GitHub ↗

Receive a file-list index using a byte-reduction method. */

Source from the content-addressed store, hash-verified

2363
2364/* Receive a file-list index using a byte-reduction method. */
2365int32 read_ndx(int f)
2366{
2367 static int32 prev_positive = -1, prev_negative = 1;
2368 int32 *prev_ptr, num;
2369 char b[4];
2370
2371 if (protocol_version < 30)
2372 return read_int(f);
2373
2374 read_buf(f, b, 1);
2375 if (CVAL(b, 0) == 0xFF) {
2376 read_buf(f, b, 1);
2377 prev_ptr = &prev_negative;
2378 } else if (CVAL(b, 0) == 0)
2379 return NDX_DONE;
2380 else
2381 prev_ptr = &prev_positive;
2382 if (CVAL(b, 0) == 0xFE) {
2383 read_buf(f, b, 2);
2384 if (CVAL(b, 0) & 0x80) {
2385 b[3] = CVAL(b, 0) & ~0x80;
2386 b[0] = b[1];
2387 read_buf(f, b+1, 2);
2388 num = IVAL(b, 0);
2389 } else
2390 num = (UVAL(b,0)<<8) + UVAL(b,1) + *prev_ptr;
2391 } else
2392 num = UVAL(b, 0) + *prev_ptr;
2393 *prev_ptr = num;
2394 if (prev_ptr == &prev_negative)
2395 num = -num;
2396 return num;
2397}
2398
2399/* Read a line of up to bufsiz-1 characters into buf. Strips
2400 * the (required) trailing newline and all carriage returns.

Callers 2

read_ndx_and_attrsFunction · 0.85

Calls 3

read_intFunction · 0.85
IVALFunction · 0.85
read_bufFunction · 0.70

Tested by

no test coverage detected