| 1 | #ifndef SIDEBAND_H |
| 2 | #define SIDEBAND_H |
| 3 | |
| 4 | enum sideband_type { |
| 5 | SIDEBAND_PROTOCOL_ERROR = -2, |
| 6 | SIDEBAND_REMOTE_ERROR = -1, |
| 7 | SIDEBAND_FLUSH = 0, |
| 8 | SIDEBAND_PRIMARY = 1 |
| 9 | }; |
| 10 | |
| 11 | /* |
| 12 | * Inspects a multiplexed packet read from the remote. If this packet is a |
| 13 | * progress packet and thus should not be processed by the caller, returns 0. |
| 14 | * Otherwise, returns 1, releases scratch, and sets sideband_type. |
| 15 | * |
| 16 | * If this packet is SIDEBAND_PROTOCOL_ERROR, SIDEBAND_REMOTE_ERROR, or a |
| 17 | * progress packet, also prints a message to stderr. |
| 18 | * |
| 19 | * scratch must be a struct strbuf allocated by the caller. It is used to store |
| 20 | * progress messages split across multiple packets. |
| 21 | * |
| 22 | * The "status" parameter is a pkt-line response as returned by |
| 23 | * packet_read_with_status() (e.g., PACKET_READ_NORMAL). |
| 24 | */ |
| 25 | int demultiplex_sideband(const char *me, int status, |
| 26 | char *buf, int len, |
| 27 | int die_on_error, |
| 28 | struct strbuf *scratch, |
| 29 | enum sideband_type *sideband_type); |
| 30 | |
| 31 | void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max); |
| 32 | |
| 33 | /* |
| 34 | * Apply sideband configuration for the given URL. This should be called |
| 35 | * when a transport is created to allow URL-specific configuration of |
| 36 | * sideband behavior (e.g., sideband.<url>.allowControlCharacters). |
| 37 | */ |
| 38 | void sideband_apply_url_config(const char *url); |
| 39 | |
| 40 | /* |
| 41 | * Parse and set the sideband allow control characters configuration. |
| 42 | * The var parameter should be the key name (without section prefix). |
| 43 | * Returns 0 if the variable was recognized and handled, non-zero otherwise. |
| 44 | */ |
| 45 | int sideband_allow_control_characters_config(const char *var, const char *value); |
| 46 | |
| 47 | #endif |