| 142 | } |
| 143 | |
| 144 | int bin_append_buffer(bin_packet_t *packet, str *buf) |
| 145 | { |
| 146 | if (!packet->buffer.s || !packet->size) { |
| 147 | LM_ERR("not initialized yet, call bin_init before altering buffer\n"); |
| 148 | return -1; |
| 149 | } |
| 150 | |
| 151 | if (packet->buffer.len + buf->len > packet->size) { |
| 152 | if (bin_extend(packet, buf->len) < 0) |
| 153 | return -1; |
| 154 | } |
| 155 | |
| 156 | memcpy(packet->buffer.s + packet->buffer.len, buf->s, buf->len); |
| 157 | packet->buffer.len += buf->len; |
| 158 | set_len(packet); |
| 159 | |
| 160 | return packet->buffer.len; |
| 161 | } |
| 162 | |
| 163 | /* |
| 164 | * copies the given string at the end position in the packet |
no test coverage detected