* adds a new integer value at the end position in the packet * * @return: * > 0: success, the size of the packet * < 0: internal buffer limit reached */
| 205 | * < 0: internal buffer limit reached |
| 206 | */ |
| 207 | int bin_push_int(bin_packet_t *packet, int info) |
| 208 | { |
| 209 | if (!packet->buffer.s || !packet->size) { |
| 210 | LM_ERR("not initialized yet, call bin_init before altering buffer\n"); |
| 211 | return -1; |
| 212 | } |
| 213 | |
| 214 | if (packet->buffer.len + sizeof info > packet->size) { |
| 215 | if (bin_extend(packet, sizeof info) < 0) |
| 216 | return -1; |
| 217 | } |
| 218 | |
| 219 | memcpy(packet->buffer.s + packet->buffer.len, &info, sizeof info); |
| 220 | packet->buffer.len += sizeof info; |
| 221 | |
| 222 | set_len(packet); |
| 223 | return packet->buffer.len; |
| 224 | } |
| 225 | |
| 226 | /* |
| 227 | * removes @count integers from the end of the packet |
no test coverage detected