General utilities used across my projects. This repository contains no stand-alone executables. Instead it is meant to be included as a git module and linked into other projects.
This is due to how compiling and linking work in terms of translation or compilation units. By keeping things in separate files we can guarantee that only the code for the functions used are actually linked into the final binary.
Some of these utility functions replicate functions or capabilities within gnu-libc, but are provided here to be compiler agnostic.
utils.h
- types, macros, and function declarations for general convenience utilitiesfilename.c
: function to return the filename portion of a given path stringdrop_extension.c
: function to remove the extension portion fo a given filename stringfilesize.c
: convenience function to return the size of a given open file.
memstream.h
- types, macros, and function declarations for memory as a stream with stdio like functionsmemstream_eof.c
: function that returns true if the current position is at the end of the given memstreammemstream_getc.c
/memstream_putc.c
: functions for reading and writing a single character/byte to/from the given memstreammemstream_read.c
/memstream_write.c
: functions for reading and writing one or more bytes to/from the given memstreammemstream_tell.c
/memstream_seek.c
: functions for getting and setting the position within the given memstream
To add this submodule into a folder perform the following command:
git submodule add https://github.com/canadianavenger/ca-util.git <folder name>
if git
does not automatically include the contents into <folder name>
perfrom the following
git submodule update --init --recursive
For more info: Working with Submodules on GitHub