/* * State of reading a block and trying to generate its sum. */ static rs_result rs_sig_s_generate(rs_job_t *job) { rs_result result; size_t len; void *block; /* must get a whole block, otherwise try again */ len = job->block_len; result = rs_scoop_read(job, len, &block); /* unless we're near eof, in which case we'll accept * whatever's in there */ if ((result == RS_BLOCKED && rs_job_input_is_ending(job))) { result = rs_scoop_read_rest(job, &len, &block); } else if (result == RS_INPUT_ENDED) { return RS_DONE; } else if (result != RS_DONE) { rs_trace("generate stopped: %s", rs_strerror(result)); return result; } rs_trace("got %ld byte block", (long) len); return rs_sig_do_block(job, block, len); }
/** * \brief State function that does a slack delta containing only * literal data to recreate the input. */ static rs_result rs_delta_s_slack(rs_job_t *job) { rs_buffers_t * const stream = job->stream; size_t avail = stream->avail_in; if (avail) { rs_trace("emit slack delta for " PRINTF_FORMAT_U64 " available bytes", PRINTF_CAST_U64(avail)); rs_emit_literal_cmd(job, avail); rs_tube_copy(job, avail); return RS_RUNNING; } else { if (rs_job_input_is_ending(job)) { job->statefn = rs_delta_s_end; return RS_RUNNING; } else { return RS_BLOCKED; } } }