File: include/ring/ring.h
1/* SPDX-FileCopyrightText: 2026 cpdocs developers */2/* SPDX-License-Identifier: Apache-2.0 */3#ifndef RING_RING_H4#define RING_RING_H5 6#include <stddef.h>7 8/// Capacity used when none is given.9#define RING_DEFAULT_CAPACITY 6410 11/// Outcome of a ring operation.12typedef enum ring_status {13 /// The operation succeeded.14 RING_OK = 0,15 /// The ring is full.16 RING_FULL = 1,17} ring_status;18 19/// A fixed-capacity ring buffer of bytes.20typedef struct ring {21 /// Storage owned by the caller.22 unsigned char* data;23 /// Number of bytes the storage holds.24 size_t capacity;25 /// Number of bytes currently stored.26 size_t size;27} ring;28 29/// Append one byte to the ring.30ring_status ring_push(ring* buffer, unsigned char value);31 32#endif