Lines Matching +full:current +full:- +full:limit

2  * buffer.h -- generic memory buffer.
4 * Copyright (c) 2005-2008, NLnet Labs. All rights reserved.
113 * to the current end of a buffer, read from the current position, and
118 /** The current position used for reading/writing */
121 /** The read/write limit */
133 /** The current state of the buffer. If writing to the buffer fails
150 assert(buffer->_position <= buffer->_limit); in sldns_buffer_invariant()
151 assert(buffer->_limit <= buffer->_capacity); in sldns_buffer_invariant()
152 assert(buffer->_data != NULL); in sldns_buffer_invariant()
185 * clears the buffer and make it ready for writing. The buffer's limit
195 buffer->_position = 0; in sldns_buffer_clear()
196 buffer->_limit = buffer->_capacity; in sldns_buffer_clear()
201 * the buffer. The buffer's limit is set to the current position and
210 buffer->_limit = buffer->_position; in sldns_buffer_flip()
211 buffer->_position = 0; in sldns_buffer_flip()
215 * make the buffer ready for re-reading the data. The buffer's
223 buffer->_position = 0; in sldns_buffer_rewind()
227 * returns the current position in the buffer (as a number of bytes)
229 * \return the current position
234 return buffer->_position; in sldns_buffer_position()
239 * or equal to the buffer's limit.
246 assert(mark <= buffer->_limit); in sldns_buffer_set_position()
247 buffer->_position = mark; in sldns_buffer_set_position()
252 * be moved behind the buffer's limit or before the beginning of the
260 assert(buffer->_position + count <= buffer->_limit); in sldns_buffer_skip()
261 buffer->_position += count; in sldns_buffer_skip()
272 return buffer->_limit; in sldns_buffer_limit()
276 * changes the buffer's limit. If the buffer's position is greater
277 * than the new limit the position is set to the limit.
279 * \param[in] limit the new limit
282 sldns_buffer_set_limit(sldns_buffer *buffer, size_t limit) in sldns_buffer_set_limit() argument
284 assert(limit <= buffer->_capacity); in sldns_buffer_set_limit()
285 buffer->_limit = limit; in sldns_buffer_set_limit()
286 if (buffer->_position > buffer->_limit) in sldns_buffer_set_limit()
287 buffer->_position = buffer->_limit; in sldns_buffer_set_limit()
298 return buffer->_capacity; in sldns_buffer_capacity()
303 * pointers to the data may become invalid. The buffer's limit is set
315 * The buffer's limit is always set to the (possibly increased)
332 assert(at <= buffer->_limit); in sldns_buffer_at()
333 return buffer->_data + at; in sldns_buffer_at()
350 * limit).
357 return sldns_buffer_at(buffer, buffer->_limit); in sldns_buffer_end()
361 * returns a pointer to the data at the buffer's current position.
368 return sldns_buffer_at(buffer, buffer->_position); in sldns_buffer_current()
373 * the limit.
382 assert(at <= buffer->_limit); in sldns_buffer_remaining_at()
383 return at < buffer->_limit ? buffer->_limit - at : 0; in sldns_buffer_remaining_at()
388 * limit.
395 return sldns_buffer_remaining_at(buffer, buffer->_position); in sldns_buffer_remaining()
414 * checks if the buffer has count bytes available at the current position
422 return sldns_buffer_available_at(buffer, buffer->_position, count); in sldns_buffer_available()
436 memcpy(buffer->_data + at, data, count); in sldns_buffer_write_at()
451 memset(buffer->_data + at, c, count); in sldns_buffer_set_at()
456 * writes count bytes of data to the current position of the buffer
464 sldns_buffer_write_at(buffer, buffer->_position, data, count); in sldns_buffer_write()
465 buffer->_position += count; in sldns_buffer_write()
469 * copies the given (null-delimited) string to the specified position at the buffer
481 * copies the given (null-delimited) string to the current position at the buffer
501 buffer->_data[at] = data; in sldns_buffer_write_u8_at()
505 * writes the given byte of data at the current position in the buffer
512 sldns_buffer_write_u8_at(buffer, buffer->_position, data); in sldns_buffer_write_u8()
513 buffer->_position += sizeof(data); in sldns_buffer_write_u8()
526 sldns_write_uint16(buffer->_data + at, data); in sldns_buffer_write_u16_at()
530 * writes the given 2 byte integer at the current position in the buffer
537 sldns_buffer_write_u16_at(buffer, buffer->_position, data); in sldns_buffer_write_u16()
538 buffer->_position += sizeof(data); in sldns_buffer_write_u16()
551 sldns_write_uint32(buffer->_data + at, data); in sldns_buffer_write_u32_at()
564 sldns_write_uint48(buffer->_data + at, data); in sldns_buffer_write_u48_at()
568 * writes the given 4 byte integer at the current position in the buffer
575 sldns_buffer_write_u32_at(buffer, buffer->_position, data); in sldns_buffer_write_u32()
576 buffer->_position += sizeof(data); in sldns_buffer_write_u32()
580 * writes the given 6 byte integer at the current position in the buffer
587 sldns_buffer_write_u48_at(buffer, buffer->_position, data); in sldns_buffer_write_u48()
588 buffer->_position += 6; in sldns_buffer_write_u48()
592 * copies count bytes of data at the given position to the given data-array
602 memcpy(data, buffer->_data + at, count); in sldns_buffer_read_at()
606 * copies count bytes of data at the current position to the given data-array
614 sldns_buffer_read_at(buffer, buffer->_position, data, count); in sldns_buffer_read()
615 buffer->_position += count; in sldns_buffer_read()
628 return buffer->_data[at]; in sldns_buffer_read_u8_at()
632 * returns the byte value at the current position in the buffer
639 uint8_t result = sldns_buffer_read_u8_at(buffer, buffer->_position); in sldns_buffer_read_u8()
640 buffer->_position += sizeof(uint8_t); in sldns_buffer_read_u8()
645 * returns the 2-byte integer value at the given position in the buffer
654 return sldns_read_uint16(buffer->_data + at); in sldns_buffer_read_u16_at()
658 * returns the 2-byte integer value at the current position in the buffer
665 uint16_t result = sldns_buffer_read_u16_at(buffer, buffer->_position); in sldns_buffer_read_u16()
666 buffer->_position += sizeof(uint16_t); in sldns_buffer_read_u16()
671 * returns the 4-byte integer value at the given position in the buffer
680 return sldns_read_uint32(buffer->_data + at); in sldns_buffer_read_u32_at()
684 * returns the 4-byte integer value at the current position in the buffer
691 uint32_t result = sldns_buffer_read_u32_at(buffer, buffer->_position); in sldns_buffer_read_u32()
692 buffer->_position += sizeof(uint32_t); in sldns_buffer_read_u32()
704 return (int)buffer->_status_err; in sldns_buffer_status()
726 * terminating '\\0') or -1 on failure.