git-2.22.0/remote-curl.c
/*
 * 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.
 *
 * If rpc->write_line_lengths is true, appends the line length as a 4-byte
 * hexadecimal string before appending the result described above.
 *
 * Writes the total number of bytes appended into appended.
 */
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.

If rpc->write_line_lengths is true, appends the line length as a 4-byte
hexadecimal string before appending the result described above.

Writes the total number of bytes appended into appended.
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 . If rpc - > write_line_lengths is true appends the line length as a 4 - byte hexadecimal string before appending the result described above . Writes the total number of bytes appended into appended .
static int rpc_read_from_out(struct rpc_state *rpc, int options,
			     size_t *appended,
			     enum packet_read_status *status) {
	size_t left;
	char *buf;
	int pktlen_raw;
	if (rpc->write_line_lengths) {
		left = rpc->alloc - rpc->len - 4;
		buf = rpc->buf + rpc->len + 4;
	} else {
		left = rpc->alloc - rpc->len;
		buf = rpc->buf + rpc->len;
	}
	if (left < LARGE_PACKET_MAX)
		return 0;
	*status = packet_read_with_status(rpc->out, NULL, NULL, buf,
			left, &pktlen_raw, options);
	if (*status != PACKET_READ_EOF) {
		*appended = pktlen_raw + (rpc->write_line_lengths ? 4 : 0);
		rpc->len += *appended;
	}
	if (rpc->write_line_lengths) {
		switch (*status) {
		case PACKET_READ_EOF:
			if (!(options & PACKET_READ_GENTLE_ON_EOF))
				die(_("shouldn't have EOF when not gentle on EOF"));
			break;
		case PACKET_READ_NORMAL:
			set_packet_header(buf - 4, *appended);
			break;
		case PACKET_READ_DELIM:
			memcpy(buf - 4, "0001", 4);
			break;
		case PACKET_READ_FLUSH:
			memcpy(buf - 4, "0000", 4);
			break;
		}
	}
	return 1;
}
static int rpc_read_from_out ( struct rpc_state * rpc , int options , size_t * appended , enum packet_read_status * status ) { size_t left ; char * buf ; int pktlen_raw ; if ( rpc -> write_line_lengths ) { left = rpc -> alloc - rpc -> len - 4 ; buf = rpc -> buf + rpc -> len + 4 ; } else { left = rpc -> alloc - rpc -> len ; buf = rpc -> buf + rpc -> len ; } if ( left < LARGE_PACKET_MAX ) return 0 ; * status = packet_read_with_status ( rpc -> out , NULL , NULL , buf , left , & pktlen_raw , options ) ; if ( * status != PACKET_READ_EOF ) { * appended = pktlen_raw + ( rpc -> write_line_lengths ? 4 : 0 ) ; rpc -> len += * appended ; } if ( rpc -> write_line_lengths ) { switch ( * status ) { case PACKET_READ_EOF : if ( ! ( options & PACKET_READ_GENTLE_ON_EOF ) ) die ( _ ( " " ) ) ; break ; case PACKET_READ_NORMAL : set_packet_header ( buf - 4 , * appended ) ; break ; case PACKET_READ_DELIM : memcpy ( buf - 4 , " " , 4 ) ; break ; case PACKET_READ_FLUSH : memcpy ( buf - 4 , " " , 4 ) ; break ; } } return 1 ; }
Appends the result of reading from rpc->out to the string represented by
 rpc->buf and rpc->len if there is enough space.
Appends the result of reading from rpc - > out to the string represented by rpc - > buf and rpc - > len if there is enough space .