/usr/include/gwenhywfar4/gwenhywfar/ringbuffer.h is in libgwenhywfar60-dev 4.15.2beta-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | /***************************************************************************
$RCSfile$
-------------------
cvs : $Id$
begin : Sun Jan 25 2004
copyright : (C) 2004 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
* *
***************************************************************************/
#ifndef GWEN_RINGBUFFER_H
#define GWEN_RINGBUFFER_H
#include <gwenhywfar/types.h>
#include <gwenhywfar/gwenhywfarapi.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup MOD_RINGBUFFER Ringbuffer Management
* @ingroup MOD_BASE
*
* @brief This file contains the definition of a GWEN_RINGBUFFER.
*
*/
/*@{*/
typedef struct GWEN_RINGBUFFER GWEN_RINGBUFFER;
/** @name Constructor And Destructor
*
*/
/*@{*/
/**
* Creates a new ring buffer
* @param size maximum size of the ring buffer
*/
GWENHYWFAR_API
GWEN_RINGBUFFER *GWEN_RingBuffer_new(unsigned int size);
/**
* Destructor.
*/
GWENHYWFAR_API
void GWEN_RingBuffer_free(GWEN_RINGBUFFER *rb);
/** @name Reading And Writing
*
*/
/*@{*/
/**
* Writes the given bytes into the ring buffer.
* @param rb ring buffer
* @param buffer pointer to bytes to write
* @param size pointer to a variable that contains the number of bytes
* to write. Upon return this variable contains the number of bytes actually
* copied.
*/
GWENHYWFAR_API
int GWEN_RingBuffer_WriteBytes(GWEN_RINGBUFFER *rb,
const char *buffer,
uint32_t *size);
/**
* Writes a single byte to the ring buffer.
*/
GWENHYWFAR_API
int GWEN_RingBuffer_WriteByte(GWEN_RINGBUFFER *rb, char c);
/**
* Read bytes from the ring buffer.
* @param rb ring buffer
* @param buffer pointer to the destination buffer
* @param size pointer to a variable that contains the number of bytes
* to read. Upon return this variable contains the number of bytes actually
* copied.
*/
GWENHYWFAR_API
int GWEN_RingBuffer_ReadBytes(GWEN_RINGBUFFER *rb,
char *buffer,
uint32_t *size);
/**
* Reads a single byte from the ring buffer.
*/
GWENHYWFAR_API
int GWEN_RingBuffer_ReadByte(GWEN_RINGBUFFER *rb);
/*@}*/
/** @name Informational Functions
*
*/
/*@{*/
/**
* Returns the number of bytes stored inside the ring buffer.
*/
GWENHYWFAR_API
uint32_t GWEN_RingBuffer_GetUsedBytes(const GWEN_RINGBUFFER *rb);
/**
* Returns the number of bytes which still can be stored inside the ring
* buffer.
*/
GWENHYWFAR_API
uint32_t GWEN_RingBuffer_GetBytesLeft(const GWEN_RINGBUFFER *rb);
/**
* Returns the size of the ring buffer.
*/
GWENHYWFAR_API
uint32_t GWEN_RingBuffer_GetBufferSize(const GWEN_RINGBUFFER *rb);
/*@}*/
/** @name Statistical Functions
*
*/
/*@{*/
/**
* Returns the number of times the buffer was empty.
*/
GWENHYWFAR_API
uint32_t GWEN_RingBuffer_GetEmptyCounter(const GWEN_RINGBUFFER *rb);
GWENHYWFAR_API
void GWEN_RingBuffer_ResetEmptyCounter(GWEN_RINGBUFFER *rb);
/**
* Returns the number of times the buffer was full.
*/
GWENHYWFAR_API
uint32_t GWEN_RingBuffer_GetFullCounter(const GWEN_RINGBUFFER *rb);
GWENHYWFAR_API
void GWEN_RingBuffer_ResetFullCounter(GWEN_RINGBUFFER *rb);
/**
* Returns the number of bytes which have passed through this buffer (i.e.
* bytes that have been written to <strong>and</strong> read from the buffer.
*/
GWENHYWFAR_API
uint32_t GWEN_RingBuffer_GetThroughput(GWEN_RINGBUFFER *rb);
/**
* Resets the buffers throughput counter to zero.
*/
GWENHYWFAR_API
void GWEN_RingBuffer_ResetThroughput(GWEN_RINGBUFFER *rb);
/**
* Returns the maximum number of bytes which has been stored in the buffer.
*/
GWENHYWFAR_API
uint32_t GWEN_RingBuffer_GetMaxUsedBytes(const GWEN_RINGBUFFER *rb);
/**
* Resets the counter for the maximum number of bytes stored in the
* buffer.
*/
GWENHYWFAR_API
void GWEN_RingBuffer_ResetMaxUsedBytes(GWEN_RINGBUFFER *rb);
GWENHYWFAR_API
void GWEN_RingBuffer_Reset(GWEN_RINGBUFFER *rb);
/*@}*/ /* name */
/** @name Functions For Direct Manipulation Of The Buffer
*
* Please use these functions with care. These function are supported in order
* to avoid unnecessary copying.
*/
/*@{*/
/**
* Returns the maximum number of bytes which can be read with a following
* call to @ref GWEN_RingBuffer_ReadBytes. This value (if not 0) can be
* used for @ref GWEN_RingBuffer_SkipBytesRead.
*/
GWENHYWFAR_API
uint32_t
GWEN_RingBuffer_GetMaxUnsegmentedRead(GWEN_RINGBUFFER *rb);
/**
* Returns the maximum number of bytes which can be written with a following
* call to @ref GWEN_RingBuffer_WriteBytes. This value (if not 0) can be
* used for @ref GWEN_RingBuffer_SkipBytesWrite.
*/
GWENHYWFAR_API
uint32_t
GWEN_RingBuffer_GetMaxUnsegmentedWrite(GWEN_RINGBUFFER *rb);
/**
* Adjusts the internal pointers and statistical data as if
* @ref GWEN_RingBuffer_ReadBytes had been called. Please note that the
* size value given here MUST be <= the value returned by
* @ref GWEN_RingBuffer_GetMaxUnsegmentedRead !
*/
GWENHYWFAR_API
void GWEN_RingBuffer_SkipBytesRead(GWEN_RINGBUFFER *rb,
uint32_t psize);
/**
* Adjusts the internal pointers and statistical data as if
* @ref GWEN_RingBuffer_WriteBytes had been called. Please note that the
* size value given here MUST be <= the value returned by
* @ref GWEN_RingBuffer_GetMaxUnsegmentedWrite !
*/
GWENHYWFAR_API
void GWEN_RingBuffer_SkipBytesWrite(GWEN_RINGBUFFER *rb,
uint32_t psize);
/**
* Returne the current read pointer. Please note that the return value of
* @ref GWEN_RingBuffer_GetMaxUnsegmentedRead indicates the maximum number
* of bytes at this position available! Trying to access bytes beyond that
* boundary will most likely result in segmentation faults.
* Please make sure that you call @ref GWEN_RingBuffer_SkipBytesRead after
* taking data from the buffer in order to keep the internal structure
* intact.
*/
GWENHYWFAR_API
const char *GWEN_RingBuffer_GetReadPointer(const GWEN_RINGBUFFER *rb);
/**
* Returne the current write pointer. Please note that the return value of
* @ref GWEN_RingBuffer_GetMaxUnsegmentedWrite indicates the maximum number
* of bytes at this position available! Trying to access bytes beyond that
* boundary will most likely result in segmentation faults.
* Please make sure that you call @ref GWEN_RingBuffer_SkipBytesWrite after
* writing data to the buffer in order to keep the internal structure
* intact.
*/
GWENHYWFAR_API
char *GWEN_RingBuffer_GetWritePointer(const GWEN_RINGBUFFER *rb);
/*@}*/ /* name */
/*@}*/ /* group */
#ifdef __cplusplus
}
#endif
#endif /* GWEN_RINGBUFFER_H */
|