X-Git-Url: https://git.datadissipation.net/libcext/blobdiff_plain/5512033073932aaa28f2b7c2cdcf6d7190e7d5d0..refs/heads/master:/README.md diff --git a/README.md b/README.md index 59cf6d6..e9373ec 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,80 @@ -A (WIP) collection of portable, strict C99, single-header implementations of common libc extensions. +A collection of portable, strict C99, single-header implementations of common libc extensions. + +All functions are implemented as macros expanding to an internal function reference, this allows to use the headers with no meta build system - it compiles even if the extensions are already present, see _How to_ on disabling this behaviour. ### How to Include the header in every file needed as usual: ``` -#include "" +#include "${function}.h" ``` In the file chosen for the function implementation: ``` -#define _IMPLEMENTATION_ -#include "" +#define LCE_${FUNCTION}_IMPLEMENTATION +#include "${function}.h>" ``` -By default, the header won't have any includes, change that with: +By default, the header won't have any stdlib includes, change that with: ``` -#define _INCLUDE_LIBC_ +#define LCE_${FUNCTION}_INCLUDE_LIBC ``` -Or disable function override with: +Or disable function, type and variable override with: ``` -#define HAVE_ +#define HAVE_${FUNCTION} ``` + +### Specifics + +--- + +### asprintf + +includes `vasprintf()` and `asprintf()` + +--- + +### fgetln + +includes `fgetln()` + +--- + +### getopt\_long + +includes `getopt()`, `getsubopt()`, `getopt_long()` and `getopt_long_only()` + +`getopt_long.h` has additional macros related to argument +permuting, defining those enables it per function (GNU behaviour, can still be disabled at runtime by setting `$POSIXLY_CORRECT`): + +``` +#define LCE_GETOPT_PERMUTE_ARGS +#define LCE_GETOPT_LONG_PERMUTE_ARGS +#define LCE_GETOPT_LONG_ONLY_PERMUTE_ARGS +``` + +--- + +### strdup + +includes `strdup()` and `strndup()` + +`strndup()` follows the latest standard, meaning that it copies at most _n_ chars, not _n_ + 1. +Also, no standard specifies that `strndup()` should return less than _n_ if `strlen(s) + 1` < _n_, but this implementation does so. + +--- + +### strlcat + +includes `strlcat()` and `strlcpy()` + +--- + +### strtonum + +includes `strtonum()`