Doxygen documentation can be found here.
CharRing is a simple character ring/circular buffer designed for microcontrollers.
This was designed with microcontrollers in mind, but it might be useful for other purposes as well.
The fastest way to get started is to run this in your project directory:
VERSION=v1.0
wget https://raw.githubusercontent.com/thefekete/CharRing/$VERSION/charring.c \
https://raw.githubusercontent.com/thefekete/CharRing/$VERSION/charring.h
You can replace v1.0 with master to get the latest.. but it may not be stable yet!
Then just include the charring.h file in your project and add charring.o to the objects in your makefile.
#include <stdio.h>
#include "charring.h" // include the header
int main()
{
// Create a buffer (64 chars here)
CharRingBuf *my_buf = CharRing_new(64);
// Add some chars to it
CharRing_putchar(my_buf, 'A');
CharRing_putchar(my_buf, 'B');
CharRing_putchar(my_buf, 'C');
// Read them back
while (CharRing_available(my_buf)) {
putchar(CharRing_getchar(my_buf));
}
putchar('\n');
// Don't forget this!
CharRing_free(my_buf);
}