33 rs_trace(
"emit DELTA magic");
40 int param_len = len <= 64 ? 0 : rs_int_len(len);
44 rs_trace(
"emit LITERAL_%d, cmd_byte=%#04x", len, cmd);
45 }
else if (param_len == 1) {
46 cmd = RS_OP_LITERAL_N1;
47 rs_trace(
"emit LITERAL_N1(len=%d), cmd_byte=%#04x", len, cmd);
48 }
else if (param_len == 2) {
49 cmd = RS_OP_LITERAL_N2;
50 rs_trace(
"emit LITERAL_N2(len=%d), cmd_byte=%#04x", len, cmd);
52 assert(param_len == 4);
53 cmd = RS_OP_LITERAL_N4;
54 rs_trace(
"emit LITERAL_N4(len=%d), cmd_byte=%#04x", len, cmd);
70 const int where_bytes = rs_int_len(where);
71 const int len_bytes = rs_int_len(len);
75 cmd = RS_OP_COPY_N8_N1;
76 else if (where_bytes == 4)
77 cmd = RS_OP_COPY_N4_N1;
78 else if (where_bytes == 2)
79 cmd = RS_OP_COPY_N2_N1;
81 assert(where_bytes == 1);
82 cmd = RS_OP_COPY_N1_N1;
85 else if (len_bytes == 2)
87 else if (len_bytes == 4)
90 assert(len_bytes == 8);
94 rs_trace(
"emit COPY_N%d_N%d(where=" FMT_LONG
", len=" FMT_LONG
95 "), cmd_byte=%#04x", where_bytes, len_bytes, where, len, cmd);
101 stats->copy_bytes += len;
102 stats->copy_cmdbytes += 1 + where_bytes + len_bytes;
109 rs_trace(
"emit END, cmd_byte=%#04x", cmd);
encoding output routines.
void rs_emit_delta_header(rs_job_t *)
Write the magic for the start of a delta.
void rs_emit_copy_cmd(rs_job_t *job, rs_long_t where, rs_long_t len)
Write a COPY command for given offset and length.
void rs_emit_end_cmd(rs_job_t *)
Write an END command.
void rs_emit_literal_cmd(rs_job_t *, int len)
Write a LITERAL command.
Generic state-machine interface.
Public header for librsync.
@ RS_DELTA_MAGIC
A delta file.
Network-byte-order output to the tube.
rs_result rs_squirt_byte(rs_job_t *job, rs_byte_t val)
Write a single byte to a stream output.
rs_result rs_squirt_netint(rs_job_t *job, rs_long_t val, int len)
Write a variable-length integer to a stream.
The contents of this structure are private.
rs_stats_t stats
Encoding statistics.
Performance statistics from a librsync encoding or decoding operation.
int lit_cmds
Number of literal commands.
rs_long_t lit_cmdbytes
Number of bytes used in literal command headers.
rs_long_t lit_bytes
Number of literal bytes.