str_extra.c

Extra string functions library for C
git clone git://git.finwo.net/lib/str_extra.c
Log | Files | Refs | README

commit 428ad56e3dee370731c208a6cced4c51365ea108
parent aae4c2aad5fdad94f02d4373a79df3237d77af45
Author: finwo <finwo@pm.me>
Date:   Fri, 10 Apr 2026 20:25:54 +0200

Add readme, rename config.mk to export.mk

Diffstat:
AREADME.md | 39+++++++++++++++++++++++++++++++++++++++
Rconfig.mk -> export.mk | 0
2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -0,0 +1,39 @@ +# c-strextra + +A lightweight C library providing additional string utility functions. + +## Functions + +### `str_isHex(const char *subject)` +Checks if a string contains only hexadecimal characters (0-9, a-f, A-F). +Returns `true` if all characters are hex digits, `false` otherwise. + +### `strnstr(const char *haystack, const char *needle, size_t len)` +Finds the first occurrence of a substring in a string with a length limit. +Similar to `strstr()` but only searches the first `len` characters. +Returns a pointer to the found substring or `NULL` if not found. + +### `strtoupper(char *str)` +Converts all characters in a string to uppercase. +Modifies the input string in-place and returns a pointer to it. + +### `strcasecmp(const char *a, const char *b)` +Case-insensitive string comparison. +On Windows (where this function may not be available), provides a custom implementation. +Returns 0 if strings are equal (case-insensitive), negative if `a < b`, positive if `a > b`. + +## Usage + +Include the main header file: + +```c +#include "str_extra.h" +``` + +Or include individual headers for specific functions. + +## Platform Support + +- Works on POSIX systems (Linux, macOS) and Windows +- `strcasecmp` uses system implementation where available, provides fallback for Windows +- Standard C library dependencies: `<ctype.h>`, `<string.h>`, `<stdlib.h>`, `<stdbool.h>` diff --git a/config.mk b/export.mk