+/*
+ * Appends the result of reading from rpc->out to the string represented by
+ * rpc->buf and rpc->len if there is enough space. Returns 1 if there was
+ * enough space, 0 otherwise.
+ *
+ * Writes the number of bytes appended into appended.
+ */
+static int rpc_read_from_out(struct rpc_state *rpc, size_t *appended) {
+ size_t left = rpc->alloc - rpc->len;
+ char *buf = rpc->buf + rpc->len;
+
+ if (left < LARGE_PACKET_MAX)
+ return 0;
+
+ *appended = packet_read(rpc->out, NULL, NULL, buf, left, 0);
+ rpc->len += *appended;
+ return 1;
+}
+