Bini ==== Endian-independent* binary IO utilities for C. *I only have access to little-endian machines, so it's currently untested on big endian, however it *should* work. If you have a big endian machine and are willing to test that Bini runs as expected, I'd be very grateful. Bini is written in plain ANSI C. If you're compiling in C99 or later, functions for reading/writing long long and bool will be added automatically. You can override the C version Bini sees by passing -Dbini_c=. Usage ----- Examples can be found in the folder. I usually run examples with one of these commands: cc examples/.c -I. -g -Dbini_dbg -Dx_writebin && gdb -q -ex=r --args a.out cc examples/.c -I. -g -Dbini_dbg -Dx_writebin && ./a.out &> out.txt Sample: /* Only define this once! You can use the bini.c file to ensure you don't accidentally define bini_impl twice. */ #define bini_impl #include int main(void) { /* Allocate a new binary stream. */ struct bini_stream *bs = bini_new(); /* Write the meaning of life, the universe, and everything to our binary stream. */ bini_wi(bs, 42); /* Read the meaning of life, the universe, and everything from our binary stream. */ int life = bini_ri(bs); ASSERT(life == 42); /* Close our stream, flushing+freeing the buffer and the stream itself. */ bini_close(bs); } License ------- Copyright 2025 Emmeline Coats Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.