MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / bin_push_str

Function bin_push_str

bin_interface.c:171–198  ·  view source on GitHub ↗

* copies the given string at the end position in the packet * allows null strings (NULL content or NULL param) * * @return: * > 0: success, the size of the packet * < 0: internal buffer limit reached */

Source from the content-addressed store, hash-verified

169 * < 0: internal buffer limit reached
170 */
171int bin_push_str(bin_packet_t *packet, const str *info)
172{
173 if (!packet->buffer.s || !packet->size) {
174 LM_ERR("not initialized yet, call bin_init before altering buffer\n");
175 return -1;
176 }
177
178 if (packet->buffer.len + LEN_FIELD_SIZE + (info ? info->len : 0) > packet->size) {
179 if (bin_extend(packet, LEN_FIELD_SIZE + (info ? info->len : 0)) < 0)
180 return -1;
181 }
182
183 if (!info || info->len == 0 || !info->s) {
184 memset(packet->buffer.s + packet->buffer.len, 0, LEN_FIELD_SIZE);
185 packet->buffer.len += LEN_FIELD_SIZE;
186
187 set_len(packet);
188 return packet->buffer.len;
189 }
190
191 memcpy(packet->buffer.s + packet->buffer.len, &info->len, LEN_FIELD_SIZE);
192 packet->buffer.len += LEN_FIELD_SIZE;
193 memcpy(packet->buffer.s + packet->buffer.len, info->s, info->len);
194 packet->buffer.len += info->len;
195
196 set_len(packet);
197 return packet->buffer.len;
198}
199
200/*
201 * adds a new integer value at the end position in the packet

Callers 15

bin_push_pres_updateFunction · 0.85
bin_push_dst_statusFunction · 0.85
bin_push_dst_statusFunction · 0.85
bin_push_presentityFunction · 0.85
replicate_cache_insertFunction · 0.85
replicate_cache_removeFunction · 0.85
receive_sync_requestFunction · 0.85
bin_push_streamFunction · 0.85

Calls 2

bin_extendFunction · 0.85
set_lenFunction · 0.85

Tested by

no test coverage detected