|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
310c69 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
310c69 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
310c69 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
310c69 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
310c69 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
310c69 |
* GNU General Public License for more details.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
310c69 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
310c69 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
310c69 |
* 02110-1301, USA.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* $Id: //eng/uds-releases/jasper/src/uds/buffer.h#2 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef BUFFER_H
|
|
Packit Service |
310c69 |
#define BUFFER_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "common.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef struct buffer Buffer;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Create a buffer which wraps an existing byte array.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param bytes The bytes to wrap
|
|
Packit Service |
310c69 |
* @param length The length of the buffer
|
|
Packit Service |
310c69 |
* @param contentLength The length of the current contents of the buffer
|
|
Packit Service |
310c69 |
* @param bufferPtr A pointer to hold the buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int wrapBuffer(byte *bytes,
|
|
Packit Service |
310c69 |
size_t length,
|
|
Packit Service |
310c69 |
size_t contentLength,
|
|
Packit Service |
310c69 |
Buffer **bufferPtr)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Create a new buffer and allocate its memory.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param length The length of the buffer
|
|
Packit Service |
310c69 |
* @param bufferPtr A pointer to hold the buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int makeBuffer(size_t length, Buffer **bufferPtr)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Release a buffer and, if not wrapped, free its memory.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param pBuffer Pointer to the buffer to release
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void freeBuffer(Buffer **pBuffer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Grow a non-wrapped buffer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer to resize
|
|
Packit Service |
310c69 |
* @param length The new length of the buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int growBuffer(Buffer *buffer, size_t length)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Ensure that a buffer has a given amount of space available, compacting the
|
|
Packit Service |
310c69 |
* buffer if necessary.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param bytes The number of available bytes desired
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the requested number of bytes are now available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool ensureAvailableSpace(Buffer *buffer, size_t bytes)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Clear the buffer. The start position is set to zero and the end position
|
|
Packit Service |
310c69 |
* is set to the buffer length.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void clearBuffer(Buffer *buffer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Eliminate buffer contents which have been extracted. This function copies
|
|
Packit Service |
310c69 |
* any data between the start and end pointers to the beginning of the buffer,
|
|
Packit Service |
310c69 |
* moves the start pointer to the beginning, and the end pointer to the end
|
|
Packit Service |
310c69 |
* of the copied data.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer to compact
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void compactBuffer(Buffer *buffer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Skip forward the specified number of bytes in a buffer (advance the
|
|
Packit Service |
310c69 |
* start pointer).
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param bytesToSkip The number of bytes to skip
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if the buffer is not long
|
|
Packit Service |
310c69 |
* enough to skip forward the requested number of bytes
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int skipForward(Buffer *buffer, size_t bytesToSkip)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Rewind the specified number of bytes in a buffer (back up the start
|
|
Packit Service |
310c69 |
* pointer).
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param bytesToRewind The number of bytes to rewind
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if the buffer is not long
|
|
Packit Service |
310c69 |
* enough to rewind backward the requested number of bytes
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int rewindBuffer(Buffer *buffer, size_t bytesToRewind)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Return the length of the buffer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer the buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return the buffer length
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
size_t bufferLength(Buffer *buffer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Compute the amount of data current in the buffer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer to examine
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The number of bytes between the start and end pointers of the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
size_t contentLength(Buffer *buffer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Compute the amount of available space in this buffer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer to examine
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The number of bytes between the end pointer and the end of the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
size_t availableSpace(Buffer *buffer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Amount of buffer that has already been processed.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer the buffer to examine
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The number of bytes between the beginning of the buffer and the
|
|
Packit Service |
310c69 |
* start pointer.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
size_t uncompactedAmount(Buffer *buffer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Return the amount of the buffer that is currently utilized.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer the buffer to examine
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The number of bytes between the beginning of the buffer and
|
|
Packit Service |
310c69 |
* the end pointer.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
size_t bufferUsed(Buffer *buffer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Reset the end of buffer to a different position.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer the buffer
|
|
Packit Service |
310c69 |
* @param end the new end of the buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS unless the end is larger than can fit
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int resetBufferEnd(Buffer *buffer, size_t end)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether the start of the content of a buffer matches a specified
|
|
Packit Service |
310c69 |
* array of bytes.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer to check
|
|
Packit Service |
310c69 |
* @param data The desired data
|
|
Packit Service |
310c69 |
* @param length The length of the desired data
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the first length bytes of the buffer's
|
|
Packit Service |
310c69 |
* contents match data
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool hasSameBytes(Buffer *buffer, const byte *data, size_t length)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether two buffers have the same contents.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer1 The first buffer
|
|
Packit Service |
310c69 |
* @param buffer2 The second buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the contents of the two buffers are the
|
|
Packit Service |
310c69 |
* same
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool equalBuffers(Buffer *buffer1, Buffer *buffer2);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a single byte from a buffer and advance the start pointer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param bytePtr A pointer to hold the byte
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are no bytes to
|
|
Packit Service |
310c69 |
* retrieve
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getByte(Buffer *buffer, byte *bytePtr) __attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a single byte from a buffer without advancing the start pointer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param offset The offset past the start pointer of the desired byte
|
|
Packit Service |
310c69 |
* @param bytePtr A pointer to hold the byte
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if the offset is past the end
|
|
Packit Service |
310c69 |
* of the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int peekByte(Buffer *buffer, size_t offset, byte *bytePtr)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a single byte into a buffer and advance the end pointer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param b The byte to put
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is no space in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putByte(Buffer *buffer, byte b) __attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get bytes out of a buffer and advance the start of the buffer past the
|
|
Packit Service |
310c69 |
* copied data.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer from which to copy
|
|
Packit Service |
310c69 |
* @param length The number of bytes to copy
|
|
Packit Service |
310c69 |
* @param destination A pointer to hold the data
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getBytesFromBuffer(Buffer *buffer, size_t length, void *destination)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a pointer to the current contents of the buffer. This will be a pointer
|
|
Packit Service |
310c69 |
* to the actual memory managed by the buffer. It is the caller's responsibility
|
|
Packit Service |
310c69 |
* to ensure that the buffer is not modified while this pointer is in use.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer from which to get the contents
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return a pointer to the current contents of the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
byte *getBufferContents(Buffer *buffer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Copy bytes out of a buffer and advance the start of the buffer past the
|
|
Packit Service |
310c69 |
* copied data. Memory will be allocated to hold the copy.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer from which to copy
|
|
Packit Service |
310c69 |
* @param length The number of bytes to copy
|
|
Packit Service |
310c69 |
* @param destinationPtr A pointer to hold the copied data
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int copyBytes(Buffer *buffer, size_t length, byte **destinationPtr)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Copy bytes into a buffer and advance the end of the buffer past the
|
|
Packit Service |
310c69 |
* copied data.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer to copy into
|
|
Packit Service |
310c69 |
* @param length The length of the data to copy
|
|
Packit Service |
310c69 |
* @param source The data to copy
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if the buffer does not have
|
|
Packit Service |
310c69 |
* length bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putBytes(Buffer *buffer, size_t length, const void *source)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Copy the contents of a source buffer into the target buffer. Advances the
|
|
Packit Service |
310c69 |
* start of the source buffer and the end of the target buffer past the copied
|
|
Packit Service |
310c69 |
* data.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param target The buffer to receive the copy of the data
|
|
Packit Service |
310c69 |
* @param source The buffer containing the data to copy
|
|
Packit Service |
310c69 |
* @param length The length of the data to copy
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if the target buffer does not have
|
|
Packit Service |
310c69 |
* length bytes available or if the source buffer does not have length
|
|
Packit Service |
310c69 |
* bytes of content
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putBuffer(Buffer *target, Buffer *source, size_t length)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Zero bytes in a buffer starting at the start pointer, and advance the
|
|
Packit Service |
310c69 |
* end of the buffer past the zeros.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer to zero
|
|
Packit Service |
310c69 |
* @param length The number of bytes to zero
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if the buffer does not have
|
|
Packit Service |
310c69 |
* length bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int zeroBytes(Buffer *buffer, size_t length)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a boolean value from a buffer and advance the start pointer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param b A pointer to hold the boolean value
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is not enough data
|
|
Packit Service |
310c69 |
* in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getBoolean(Buffer *buffer, bool *b) __attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a boolean value into a buffer and advance the end pointer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param b The boolean to put
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is no space in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putBoolean(Buffer *buffer, bool b) __attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a 2 byte, big endian encoded integer from a buffer and advance the
|
|
Packit Service |
310c69 |
* start pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui A pointer to hold the integer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 2
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getUInt16BEFromBuffer(Buffer *buffer, uint16_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a 2 byte, big endian encoded integer into a buffer and advance the
|
|
Packit Service |
310c69 |
* end pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui The integer to put
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 2
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putUInt16BEIntoBuffer(Buffer *buffer, uint16_t ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a 4 byte, big endian encoded integer from a buffer and advance the
|
|
Packit Service |
310c69 |
* start pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui A pointer to hold the integer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 4
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getUInt32BEFromBuffer(Buffer *buffer, uint32_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a 4 byte, big endian encoded integer into a buffer and advance the
|
|
Packit Service |
310c69 |
* end pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui The integer to put
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 4
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putUInt32BEIntoBuffer(Buffer *buffer, uint32_t ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a series of 4 byte, big endian encoded integer from a buffer and
|
|
Packit Service |
310c69 |
* advance the start pointer past them.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param count The number of integers to get
|
|
Packit Service |
310c69 |
* @param ui A pointer to hold the integers
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is not enough data
|
|
Packit Service |
310c69 |
* in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getUInt32BEsFromBuffer(Buffer *buffer, size_t count, uint32_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a series of 4 byte, big endian encoded integers into a buffer and
|
|
Packit Service |
310c69 |
* advance the end pointer past them.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param count The number of integers to put
|
|
Packit Service |
310c69 |
* @param ui A pointer to the integers
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is not enough space
|
|
Packit Service |
310c69 |
* in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putUInt32BEsIntoBuffer(Buffer *buffer, size_t count, const uint32_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a series of 8 byte, big endian encoded integer from a buffer and
|
|
Packit Service |
310c69 |
* advance the start pointer past them.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param count The number of integers to get
|
|
Packit Service |
310c69 |
* @param ui A pointer to hold the integers
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is not enough data
|
|
Packit Service |
310c69 |
* in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getUInt64BEsFromBuffer(Buffer *buffer, size_t count, uint64_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a series of 8 byte, big endian encoded integers into a buffer and
|
|
Packit Service |
310c69 |
* advance the end pointer past them.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param count The number of integers to put
|
|
Packit Service |
310c69 |
* @param ui A pointer to the integers
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is not enough space
|
|
Packit Service |
310c69 |
* in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putUInt64BEsIntoBuffer(Buffer *buffer, size_t count, const uint64_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a 2 byte, little endian encoded integer from a buffer and
|
|
Packit Service |
310c69 |
* advance the start pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui A pointer to hold the integer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 2
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getUInt16LEFromBuffer(Buffer *buffer, uint16_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a 2 byte, little endian encoded integer into a buffer and advance the
|
|
Packit Service |
310c69 |
* end pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui The integer to put
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 2
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putUInt16LEIntoBuffer(Buffer *buffer, uint16_t ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a series of 2 byte, little endian encoded integer from a buffer
|
|
Packit Service |
310c69 |
* and advance the start pointer past them.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param count The number of integers to get
|
|
Packit Service |
310c69 |
* @param ui A pointer to hold the integers
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is not enough data
|
|
Packit Service |
310c69 |
* in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getUInt16LEsFromBuffer(Buffer *buffer, size_t count, uint16_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a series of 2 byte, little endian encoded integers into a
|
|
Packit Service |
310c69 |
* buffer and advance the end pointer past them.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param count The number of integers to put
|
|
Packit Service |
310c69 |
* @param ui A pointer to the integers
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is not enough space
|
|
Packit Service |
310c69 |
* in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putUInt16LEsIntoBuffer(Buffer *buffer, size_t count, const uint16_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a 4 byte, little endian encoded integer from a buffer and advance the
|
|
Packit Service |
310c69 |
* start pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param i A pointer to hold the integer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 4
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getInt32LEFromBuffer(Buffer *buffer, int32_t *i)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a 4 byte, little endian encoded integer from a buffer and advance the
|
|
Packit Service |
310c69 |
* start pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui A pointer to hold the integer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 4
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getUInt32LEFromBuffer(Buffer *buffer, uint32_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a 4 byte, little endian encoded integer into a buffer and advance the
|
|
Packit Service |
310c69 |
* end pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui The integer to put
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 4
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putUInt32LEIntoBuffer(Buffer *buffer, uint32_t ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get an 8 byte, little endian encoded, unsigned integer from a
|
|
Packit Service |
310c69 |
* buffer and advance the start pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui A pointer to hold the integer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 8
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getUInt64LEFromBuffer(Buffer *buffer, uint64_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put an 8 byte, little endian encoded signed integer into a buffer
|
|
Packit Service |
310c69 |
* and advance the end pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param i The integer to put
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 8
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putInt64LEIntoBuffer(Buffer *buffer, int64_t i)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put an 8 byte, little endian encoded integer into a buffer and advance the
|
|
Packit Service |
310c69 |
* end pointer past it.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param ui The integer to put
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there are fewer than 8
|
|
Packit Service |
310c69 |
* bytes available
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putUInt64LEIntoBuffer(Buffer *buffer, uint64_t ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a series of 8 byte, little endian encoded integer from a buffer
|
|
Packit Service |
310c69 |
* and advance the start pointer past them.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param count The number of integers to get
|
|
Packit Service |
310c69 |
* @param ui A pointer to hold the integers
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is not enough data
|
|
Packit Service |
310c69 |
* in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getUInt64LEsFromBuffer(Buffer *buffer, size_t count, uint64_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a series of 8 byte, little endian encoded integers into a buffer and
|
|
Packit Service |
310c69 |
* advance the end pointer past them.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer
|
|
Packit Service |
310c69 |
* @param count The number of integers to put
|
|
Packit Service |
310c69 |
* @param ui A pointer to the integers
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or UDS_BUFFER_ERROR if there is not enough space
|
|
Packit Service |
310c69 |
* in the buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putUInt64LEsIntoBuffer(Buffer *buffer, size_t count, const uint64_t *ui)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif /* BUFFER_H */
|