libsheepy
Data Structures | Macros | Typedefs | Functions | Variables
libsheepy.h File Reference

This file has basic file, random, string, list functions. More...

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <setjmp.h>
#include <iso646.h>
#include <inttypes.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
Include dependency graph for libsheepy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  staticArrayBase
 staticArray type definition More...
 
struct  fiberBaseT
 all contexts must start with fiberBaseT More...
 
struct  fibersT
 data type for fiber system More...
 

Macros

#define _GNU_SOURCE
 
#define LIBSHEEPY_VERSION   "2.2.12.1"
 
#define SH_PREFIX(NAME)   NAME
 
#define internal   static
 file internal declarations More...
 
#define local   static
 file local declarations (same as internal, shorter word) More...
 
#define var   __auto_type
 declare variable type automaticaly: var a = ARGC; More...
 
#define null   NULL
 convenience defines More...
 
#define yes   true
 
#define on   true
 
#define no   false
 
#define off   false
 
#define boolS(x)   x ? "TRUE" : "FALSE"
 bool to const string: printf("%s\n", boolS(boolValue)); More...
 
#define XSUCCESS   exit(EXIT_SUCCESS);
 success More...
 
#define XSuccess   XSUCCESS
 
#define XFAILURE   exit(EXIT_FAILURE);
 failure More...
 
#define XFailure   XFAILURE
 
#define logXSuccess(string)
 log string with logP and exit with success More...
 
#define logXSuccessf(format, ...)
 log formated string with logP and exit with success More...
 
#define logXFailure(string)
 
#define logXFailuref(format, ...)
 log formated string with logC and exit with failure More...
 
#define logExit(exitCode, string)
 log string with logI and exit with exitCode More...
 
#define exitFailure(cond)
 exit failure More...
 
#define procbegin   do{
 defines for macro begin and end More...
 
#define procend   }while(0)
 
#define funcbegin   ({
 
#define funcend   })
 
#define MACRO(STATEMENTS)   do { STATEMENTS } while(0)
 do while(0) alternative macro definition More...
 
#define FUNC(STATEMENTS)   ({ STATEMENTS })
 Macro returning a value (GNU extension): #define macro(value) FUNC(\ int returnResult = value + 2;\ returnResult;\ ) More...
 
#define is   =
 additions to iso646 int a is 0; if (a equals 1 or a equals 2) a shl = 2; else a inc; return ptr_to a; More...
 
#define equals   ==
 
#define nequal   !=
 
#define shr   >>
 
#define shl   <<
 
#define inc   ++
 
#define dec   --
 
#define ptr_to   &
 
#define val_of   *
 
#define stringifyExpr(expr)   stringifyExpr1(expr)
 stringify Expression - Turn expression into a string literal More...
 
#define stringifyExpr1(expr)   #expr
 
#define libsheepyErrorMask   0x8000000000000000UL
 
#define disableLibsheepyErrorLogs   do{logMask &= (~libsheepyErrorMask);}while(0)
 
#define shperror(string)
 
#define pFuncError   do{ if ((libsheepyErrorMask) & logMask) { shperror(__func__);logEBtrace;} }while(0);
 print function name and system error More...
 
#define pStrError(str)   do{ if ((libsheepyErrorMask) & logMask) { shperror(str);logEBtrace;} }while(0);
 print string and system error More...
 
#define shPrintError   do{ if ((libsheepyErrorMask) & logMask) { logE("Error line "stringifyExpr(__LINE__)", function %s, file "__FILE__"\n", __func__); logEBtrace;} }while(0);
 print error with line number, function name and file name to stderr More...
 
#define pError(func)   if (func == -1) shPrintError
 print error when function failed. More...
 
#define pError0(func)   if (func == 0) shPrintError
 print error when function failed. More...
 
#define pErrorNot0(func)   if (func != 0) shPrintError
 print error when function failed. More...
 
#define pErrorNULL(func)   if (func == NULL) shPrintError
 print error when function failed. More...
 
#define pErrorValue(func, errorValue)   if (func == errorValue) shPrintError
 print error when function failed. More...
 
#define pTestError(test)   if (test) shPrintError
 print error when test is true More...
 
#define pTestErrorCmd(test, cmd)   if (test) { shPrintError cmd; }
 print error and run command when test is true More...
 
#define pErrorCmd(func, test, cmd)   if (func test) { shPrintError cmd; }
 print error and run cmd when test is true More...
 
#define pErrorResult(result, func, test)   if ((result = func) test) shPrintError
 print error when test is true and return func result in result More...
 
#define pErrorResultCmd(result, func, test, cmd)   if ((result = func) test) { shPrintError cmd; }
 print error and run cmd when test is true and return func result in result More...
 
#define isError(assigned, left)   if (!(assigned = left))
 is Assigment Error catch error when assigned is false, 0 or NULL after being assigned with left More...
 
#define maxTryThrowCount   16
 setjmp buffers for try/throw,throwV macros More...
 
#define setJump(slot)   setjmp(tryJumpBuffers[slot])
 run setjmp using slot in tryJumpBuffers More...
 
#define try(slot)   if (!setjmp(tryJumpBuffers[slot]))
 try throw else try(slot) saves the environment in slot throw(slot) executes the else associated with try(slot) More...
 
#define throw(slot)   longjmp(tryJumpBuffers[slot], 1)
 throw goes to else associated with try(slot) More...
 
#define tryV(result, slot)   if (!(result = setjmp(tryJumpBuffers[slot])))
 tryV stores the value from setjmp in result More...
 
#define throwV(slot, value)   longjmp(tryJumpBuffers[slot], value)
 throwV returns value and goes to else associated with tryV(slot) More...
 
#define goNLabel(go, label)   goto go; label:
 
#define i8   int8_t
 types More...
 
#define i16   int16_t
 
#define i32   int32_t
 
#define i64   int64_t
 
#define u8   uint8_t
 
#define u16   uint16_t
 
#define u32   uint32_t
 
#define u64   uint64_t
 
#define f32   float
 
#define f64   double
 
#define I8(value)   (i8)(value)
 type cast More...
 
#define I16(value)   (i16)(value)
 
#define I32(value)   (i32)(value)
 
#define I64(value)   (i64)(value)
 
#define U8(value)   (u8)(value)
 
#define U16(value)   (u16)(value)
 
#define U32(value)   (u32)(value)
 
#define U64(value)   (u64)(value)
 
#define F32(value)   (f32)(value)
 
#define F64(value)   (f64)(value)
 
#define MAX(a, b)   (((a) > (b)) ? (a) : (b))
 
#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
 
#define MIN3(a, b, c)   MIN((typeof(a))MIN(a, b), c)
 
#define MAX3(a, b, c)   MAX((typeof(a))MAX(a, b), c)
 
#define ABS(a)   (((a) < 0) ? -(a) : (a))
 
#define CLAMP(x, low, high)   (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
 
#define COUNT_ELEMENTS(arr)   (sizeof (arr) / sizeof ((arr)[0]))
 
#define ARRAY_SIZE   COUNT_ELEMENTS
 
#define EXTRACT(x, msb, lsb)   ((~(0xFFFFFFFFFFFFFFFEUL << (msb)) & (x)) >> (lsb))
 get a bitfield in an integer (opposite of FIELD_SET) More...
 
#define CMP(a, b)
 compare a to b a and b have to numbers More...
 
#define init0Var   {0}
 initialize array or struct to zero More...
 
#define ZEROVAR(name)   zeroBuf(&(name), sizeof(name))
 memset array or struct to zero More...
 
#define BUCKETS(count, divider)   ((count)/(divider) + (((count) % (divider)) ? 1 : 0))
 divide count by divider and add one when remainder is not zero this is used in segmented arrays to count the number of buckets from the element count More...
 
#define swapV(a, b)
 swap a and b, a and b should have the same type More...
 
#define setMax(result, a, b)
 max a,b and store result in result, a and b are evaluated only once More...
 
#define setMin(result, a, b)
 min a,b and store result in result, a and b are evaluated only once More...
 
#define maxV(a, b)
 max a,b and return result, a and b are evaluated only once More...
 
#define minV(a, b)
 min a,b and return result, a and b are evaluated only once More...
 
#define absV(a)   ({var UNIQVAR(_a) = a; ((UNIQVAR(_a)) < 0) ? -(UNIQVAR(_a)) : (UNIQVAR(_a));})
 absV return absolute value for a, a is evaluated only once More...
 
#define FIELD_SIZEOF(t, f)   (sizeof(((t*)0)->f))
 FIELD_SIZEOF - get the size of a struct's field : the target struct : the target struct's field Return: the size of in the struct definition without having a declared instance of . More...
 
#define isIntOdd(value)   (value&1)
 true when value is odd integer More...
 
#define isIntEven(value)   (!(value&1))
 true when value is even integer More...
 
#define typ   typedef
 typ definition as alternative to typedef More...
 
#define ret   return
 ret definition as alternative to return More...
 
#define elif   else if
 elif definition as alternative to else if More...
 
#define unless(cond)   if(not(cond))
 unless executes the statement unless the condition is true (that is, if the condition is false). More...
 
#define until(cond)   while(not(cond))
 until repeats the statement until the condition is true (or while the condition is false) More...
 
#define cast(type, casted, toCast)   type casted = (type) (toCast);
 define variable and cast pointer More...
 
#define freen(ptr)
 free pointer and set it to NULL More...
 
#define EVA(var, func)   (var = func, var)
 Evaluate and assign Evaluate, assign result from func and return result using the comma operator. More...
 
#define loopBreakerInit
 initialize the loop breaker declares loop breaker variables More...
 
#define loopBreakerReset
 reset the loop breaker variables More...
 
#define loopBreaker(breakCount)
 break the loop when the counter exceed breakCount More...
 
#define FILE_LINE   __FILE__":"stringifyExpr(__LINE__)
 generate a string FILE:LINE number More...
 
#define PFILE_LINE   puts(FILE_LINE)
 
#define AT   pLog(LOG_DEBUG, __FILE__", %s:"stringifyExpr(__LINE__)"\n",__func__);
 print file, function name and line More...
 
#define TODO(message)   logD(BLD MGT BGBLK"TODO"RST BLD MGT": "message RST)
 print a todo message in log More...
 
#define TOKENPASTE2(a, b)   a ## b
 
#define TOKENPASTE(a, b)   TOKENPASTE2(a, b)
 
#define UNIQVAR(name)   TOKENPASTE(name, __LINE__)
 
#define cleanCharP(name)   char *name CLEANUP(cleanUpCharFree)
 declare pointer name with type char* and free name when it is out of scope More...
 
#define cleanListP(name)   char **name CLEANUP(cleanUpListFree)
 declare pointer name with type char* and free name when it is out of scope More...
 
#define cleanFileP(name)   FILE *name CLEANUP(cleanUpFileFree)
 declare pointer name with type FILE and free (close) name when it is out of scope More...
 
#define cleanFd(name)   int name CLEANUP(cleanUpFd)
 declare a file descriptor name and close name when it is out of scope More...
 
#define cleanFdInit(name)   int name CLEANUP(cleanUpFd) = -1
 
#define logVar(var, format)   logD("%s=%" format, stringifyExpr(var), var);
 log variable and its value More...
 
#define logMVar(mask, var, format)   logMD(mask, "%s=%" format, stringifyExpr(var), var);
 
#define logBoolVar(var)   logVar(var, "b");
 log bool variable More...
 
#define logMBoolVar(mask, var)   logMVar(mask, var, "b");
 
#define logPtr(pointer)   logD("%s=%p", stringifyExpr(pointer), pointer);
 log pointer More...
 
#define logMPtr(mask, pointer)   logMD(mask, "%s=%p", stringifyExpr(pointer), pointer);
 
#define RST   "\x1B[0m"
 reset for color function More...
 
#define BLD   "\x1B[1m"
 bold for color function More...
 
#define FNT   "\x1B[2m"
 faint More...
 
#define ITL   "\x1B[3m"
 italic More...
 
#define UDL   "\x1B[4m"
 underline for color function More...
 
#define BLI   "\x1B[5m"
 blink More...
 
#define INV   "\x1B[7m"
 inverse for color function More...
 
#define COC   "\x1B[8m"
 conceal/hidden for color function More...
 
#define CRD   "\x1B[9m"
 crossed for color function More...
 
#define BLK   "\x1B[30m"
 black for color function More...
 
#define RED   "\x1B[31m"
 red for color function More...
 
#define GRN   "\x1B[32m"
 green for color function More...
 
#define YLW   "\x1B[33m"
 yellow for color function More...
 
#define BLU   "\x1B[34m"
 blue for color function More...
 
#define MGT   "\x1B[35m"
 magenta for color function More...
 
#define CYN   "\x1B[36m"
 cyan for color function More...
 
#define WHT   "\x1B[37m"
 white for color function More...
 
#define BGBLK   "\x1B[40m"
 bg black for color function More...
 
#define BGRED   "\x1B[41m"
 bg red for color function More...
 
#define BGGRN   "\x1B[42m"
 bg green for color function More...
 
#define BGYLW   "\x1B[43m"
 bg yellow for color function More...
 
#define BGBLU   "\x1B[44m"
 bg blue for color function More...
 
#define BGMGT   "\x1B[45m"
 bg magenta for color function More...
 
#define BGCYN   "\x1B[46m"
 bg cyan for color function More...
 
#define BGWHT   "\x1B[47m"
 bg white for color function More...
 
#define sheepyRGBFP   len = fprintf(stream, "%*s", (int)(info->left ? -info->width : info->width), b)
 
#define sheepyBOOLFP   len = fprintf(stream, "%*s", (int)(info->left ? -info->width : info->width), boolS(value))
 
#define timeNs(func)
 time a function in nanoseconds More...
 
#define TIMEUNITUS   "us"
 
#define TIMEUNITMS   "ms"
 
#define TIMEUNITSC   "s"
 
#define timeDivs(func, div, timeunit)
 time a function with div More...
 
#define timeUs(func)   timeDivs(func,1E3, TIMEUNITUS)
 time a function in microseconds More...
 
#define timeMs(func)   timeDivs(func,1E6, TIMEUNITMS)
 time a function in miliseconds More...
 
#define timeSec(func)   timeDivs(func,1E9, TIMEUNITSC)
 time a function in seconds More...
 
#define stopwatchStart   shStopwatch(0)
 
#define stopwatchLog   printf(BLD GRN "time" RST ": %" PRIu64 "ns\n", shStopwatch(1))
 print stopwatch value in ns since last start More...
 
#define stopwatchLogDivs(div, timeunit)   printf(BLD GRN "time" RST ": %f"timeunit"\n", ((float)shStopwatch(1))/div)
 print stopwatch value in provided unit since last start More...
 
#define stopwatchLogUs   stopwatchLogDivs(1E3, TIMEUNITUS)
 print stopwatch value in microseconds since last start More...
 
#define stopwatchLogMs   stopwatchLogDivs(1E6, TIMEUNITMS)
 print stopwatch value in milliseconds since last start More...
 
#define stopwatchLogSec   stopwatchLogDivs(1E9, TIMEUNITSC)
 print stopwatch value in seconds since last start More...
 
#define LOG_EMERGENCY   0
 LOG LEVELS Note: When adding log levels or modes, the log_tags array in libsheepy.c must be updated. More...
 
#define LOG_ALERT   1
 
#define LOG_CRITICAL   2
 
#define LOG_ERROR   3
 
#define LOG_WARNING   4
 
#define LOG_NOTICE   5
 
#define LOG_PASS   6
 
#define LOG_INFO   7
 
#define LOG_DEBUG   8
 
#define LOG_INVALID   9
 
#define LOG_MAX_LEVEL   LOG_INVALID
 
#define LOG_DISABLE   -1
 getMaxLogLevel and setMaxLogLevel value disabling all logs More...
 
#define LOG_VERBOSE   0
 LOG MODES when a new mode is added, add symbols in log_tags in libsheepy.c. More...
 
#define LOG_CONCISE   1
 log symbol More...
 
#define LOG_DATE   2
 log symbol and date More...
 
#define LOG_FUNC   3
 log symbol and function More...
 
#define LOG_PROG   4
 log symbol and program name More...
 
#define LOG_PROGNDATE   5
 log symbol, program name and date More...
 
#define LOG_VOID   6
 log message only More...
 
#define LOG_UTF8   7
 UTF8 symbols and concise. More...
 
#define LOG_PROGNFUNC   8
 log symbol, program name and function More...
 
#define LOG_INVALID_MODE   9
 invalid More...
 
#define openLogFile   setLogFile
 
#define MUST_CHECK
 
#define pLog(level, ...)   _pLog(level, __FILE__, __func__, __LINE__, __VA_ARGS__);
 print logging levels More...
 
#define logY(...)   pLog(LOG_EMERGENCY, __VA_ARGS__)
 
#define logA(...)   pLog(LOG_ALERT, __VA_ARGS__)
 
#define logC(...)   pLog(LOG_CRITICAL, __VA_ARGS__)
 
#define logE(...)   pLog(LOG_ERROR, __VA_ARGS__)
 
#define logW(...)   pLog(LOG_WARNING, __VA_ARGS__)
 
#define logN(...)   pLog(LOG_NOTICE, __VA_ARGS__)
 
#define logP(...)   pLog(LOG_PASS, __VA_ARGS__)
 
#define logI(...)   pLog(LOG_INFO, __VA_ARGS__)
 
#define logD(...)   pLog(LOG_DEBUG, __VA_ARGS__)
 
#define logSY(format, string)
 log string and free Example: logSY("The list: %s", catS("1", "2")); More...
 
#define logSA(format, string)
 log string and free Example: logSA("The list: %s", catS("1", "2")); More...
 
#define logSC(format, string)
 log string and free Example: logSC("The list: %s", catS("1", "2")); More...
 
#define logSE(format, string)
 log string and free Example: logSE("The list: %s", catS("1", "2")); More...
 
#define logSW(format, string)
 log string and free Example: logSW("The list: %s", catS("1", "2")); More...
 
#define logSN(format, string)
 log string and free Example: logSN("The list: %s", catS("1", "2")); More...
 
#define logSP(format, string)
 log string and free Example: logSP("The list: %s", catS("1", "2")); More...
 
#define logSI(format, string)
 log string and free Example: logSI("The list: %s", catS("1", "2")); More...
 
#define logSD(format, string)
 log string and free Example: logSD("The list: %s", catS("1", "2")); More...
 
#define pLogMask(mask, level, ...)   if ((mask) & logMask) pLog(level, __VA_ARGS__)
 print mask logging levels More...
 
#define logMY(mask, ...)   pLogMask(mask, LOG_EMERGENCY, __VA_ARGS__)
 
#define logMA(mask, ...)   pLogMask(mask, LOG_ALERT, __VA_ARGS__)
 
#define logMC(mask, ...)   pLogMask(mask, LOG_CRITICAL, __VA_ARGS__)
 
#define logME(mask, ...)   pLogMask(mask, LOG_ERROR, __VA_ARGS__)
 
#define logMW(mask, ...)   pLogMask(mask, LOG_WARNING, __VA_ARGS__)
 
#define logMN(mask, ...)   pLogMask(mask, LOG_NOTICE, __VA_ARGS__)
 
#define logMP(mask, ...)   pLogMask(mask, LOG_PASS, __VA_ARGS__)
 
#define logMI(mask, ...)   pLogMask(mask, LOG_INFO, __VA_ARGS__)
 
#define logMD(mask, ...)   pLogMask(mask, LOG_DEBUG, __VA_ARGS__)
 
#define showLogsInMask(mask)   logMask |= mask
 
#define hideLogsInMask(mask)   logMask &= ~(mask)
 
#define logSMY(mask, format, string)
 log and mask string and then free Example: logSMY("The list: %s", catS("1", "2")); More...
 
#define logSMA(mask, format, string)
 log and mask string and then free Example: logSMA("The list: %s", catS("1", "2")); More...
 
#define logSMC(mask, format, string)
 log and mask string and then free Example: logSMI("The list: %s", catS("1", "2")); More...
 
#define logSME(mask, format, string)
 log and mask string and then free Example: logSME("The list: %s", catS("1", "2")); More...
 
#define logSMW(mask, format, string)
 log and mask string and then free Example: logSMW("The list: %s", catS("1", "2")); More...
 
#define logSMN(mask, format, string)
 log and mask string and then free Example: logSMN("The list: %s", catS("1", "2")); More...
 
#define logSMP(mask, format, string)
 log and mask string and then free Example: logSMP("The list: %s", catS("1", "2")); More...
 
#define logSMI(mask, format, string)
 log and mask string and then free Example: logSMI("The list: %s", catS("1", "2")); More...
 
#define logSMD(mask, format, string)
 log and mask string and then free Example: logSMD("The list: %s", catS("1", "2")); More...
 
#define Q_SORT3(q_a1, q_a2, q_a3, Q_LESS, Q_SWAP)
 
#define Q_PARTITION(q_l, q_r, q_i, q_j, Q_UINT, Q_LESS, Q_SWAP)
 
#define Q_INSERTION_SORT(q_l, q_r, Q_UINT, Q_LESS, Q_SWAP)
 
#define Q_THRESH   16
 
#define Q_LOOP(Q_UINT, Q_N, Q_LESS, Q_SWAP)
 
#define Q_SUBFILES(q_l1, q_r1, q_l2, q_r2)
 
#define QSORT(Q_N, Q_LESS, Q_SWAP)
 
#define BSEARCH(RESULT_INDEX, SEARCH_ELEMENT, B_N, B_LESS, B_EQUAL)
 binary search macro More...
 
#define libsheepyPrealloc   (1024*1024)
 
#define makeRoom(length, alloc, addlength)
 
#define initLibsheepy(progPath)   initLibsheepyF(progPath, NULL)
 
#define systemNFree(command)   systemNFreeF(command, __LINE__, __func__, __FILE__)
 
#define isPath   fileExists
 
#define readFileS   readFileToS
 
#define bReadFileS   bReadFileToS
 
#define bLReadFileS   bLReadFileToS
 
#define readStreamS   readStreamToS
 
#define bReadStreamS   bReadStreamToS
 
#define bLReadStreamS   bLReadStreamToS
 
#define charToS(dst, c)   ;char dst[2] = {c, 0}
 
#define freeManyS(...)   freeManySF("", __VA_ARGS__, NULL)
 
#define put   puts("");
 
#define catS(...)   catSF("", __VA_ARGS__, NULL)
 
#define iCatS(dst, ...)   iCatSF(dst, "", __VA_ARGS__, NULL)
 
#define bCatS   iCatS
 
#define bLCatS(dst, dstSize, ...)   bLCatSF(dst, dstSize, "", __VA_ARGS__, NULL)
 
#define iAppendManyS(s, s1, ...)   iAppendManySF(s, s1, __VA_ARGS__, NULL)
 
#define bAppendManyS(s, s1, ...)   bAppendManySF(s, s1, __VA_ARGS__, NULL)
 
#define bLAppendManyS(s, sSize, s1, ...)   bLAppendManySF(s, sSize, s1, __VA_ARGS__, NULL)
 
#define replaceS_max(s, olds, news)   replaceS(s,olds,news, 0)
 
#define replaceSMax   replaceS_max
 
#define replaceSMaxLen(s, olds, news)   replaceSLen(s,olds,news, 0)
 
#define iReplaceS_max(s, olds, news)   iReplaceS(s,olds,news, 0)
 
#define iReplaceSMax   iReplaceS_max
 
#define bReplaceS_max(s, olds, news)   bReplaceS(s,olds,news, 0)
 
#define bReplaceSMax   bReplaceS_max
 
#define bLReplaceS_max(s, sSize, olds, news)   bLReplaceS(s,sSize,olds,news, 0)
 
#define bLReplaceSMax   bLReplaceS_max
 
#define replaceManyS(s, ...)   replaceManySF(s, __VA_ARGS__, NULL)
 
#define iReplaceManyS(s, olds, ...)   iReplaceManySF(s, olds, __VA_ARGS__, NULL)
 
#define bReplaceManyS(s, olds, ...)   bReplaceManySF(s, olds, __VA_ARGS__, NULL)
 
#define bLReplaceManyS(s, sSize, olds, ...)   bLReplaceManySF(s, sSize, olds, __VA_ARGS__, NULL)
 
#define icReplaceS_max(s, olds, news)   icReplaceS(s,olds,news, 0)
 
#define icReplaceSMax   icReplaceS_max
 
#define iicReplaceS_max(s, olds, news)   iicReplaceS(s,olds,news, 0)
 
#define iicReplaceSMax   iicReplaceS_max
 
#define bicReplaceS_max(s, olds, news)   bicReplaceS(s,olds,news, 0)
 
#define bicReplaceSMax   bicReplaceS_max
 
#define bLicReplaceS_max(s, sSize, olds, news)   bLicReplaceS(s,sSize,olds,news, 0)
 
#define bLicReplaceSMax   bLicReplaceS_max
 
#define icReplaceManyS(s, ...)   icReplaceManySF(s, __VA_ARGS__, NULL)
 
#define iicReplaceManyS(s, olds, ...)   iicReplaceManySF(s, olds, __VA_ARGS__, NULL)
 
#define bicReplaceManyS(s, olds, ...)   bicReplaceManySF(s, olds, __VA_ARGS__, NULL)
 
#define bLicReplaceManyS(s, sSize, olds, ...)   bLicReplaceManySF(s, sSize, olds, __VA_ARGS__, NULL)
 
#define strEq   eqS
 
#define strIEq   eqIS
 
#define toUpper(c)   ((c) = toupper(c), c)
 upper case and store the result in c and return the result More...
 
#define toLower(c)   ((c) = tolower(c), c)
 lower case and store the result in c and return the result More...
 
#define uniqSlash(s)   uniqS(s, '/')
 
#define iUniqSlash(s)   iUniqS(&(s), '/')
 
#define bUniqSlash(s)   bUniqS(s, '/')
 
#define codeSizeUTF8(utf8)   codeSzUTF8[*(const uint8_t *)(utf8)]
 size in bytes of UTF-8 code point More...
 
#define nextCodeUTF8(utf8)   ((utf8) + codeSizeUTF8(utf8))
 move pointer to next UTF-8 code point, no checks are done, the utf8 pointer parameter is unchanged More...
 
#define nxtCodeUTF8(utf8)   EVA(utf8, nextCodeUTF8(utf8))
 change the utf8 pointer parameter to next UTF-8 code point, like char *s; s++; More...
 
#define nxCodeUTF8(utf8)   (utf8 = nextCodeUTF8(utf8))
 
#define emptyS(string)   string = strdup("");
 
#define bEmptyS(string)   (string)[0] = 0
 
#define orS(string, alternative)   !isEmptyS(string) ? (string) : (alternative)
 orS - if string is empty, the value is alternative More...
 
#define orBlankS(string, alternative)   !isBlankS(string) ? (string) : (alternative)
 blankS - if string is blank(white spaces) or empty, the value is alternative More...
 
#define nS(string)   (string) ? (string) : ""
 nS - null String - replace null string with "" string (empty string) More...
 
#define nAS(string, alternative)   (string) ? (string) : (alternative)
 nAS - null Alternative String - replace null string with alternative string More...
 
#define listEmptyS(list)
 
#define listCreateS(...)   listCreateSF("", __VA_ARGS__, NULL)
 
#define listFreeManyS(...)   listFreeManySF(NULL, __VA_ARGS__, NULL)
 
#define listCatS(...)   listCatSF(NULL, __VA_ARGS__, NULL)
 
#define forever   while(1)
 forever loop More...
 
#define range(index, maxCount)
 range loop ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define rangeInf(index)   for (size_t index = 0 ;; index++)
 infinity loop increase the index infinitly More...
 
#define rangeDown(index, maxCount)   for (ssize_t index = (maxCount)-1 ; index >= 0 ; index--)
 range down loop, index is ssize_t More...
 
#define rangeDownTo(index, maxCount, to)
 range down loop to to index, index is ssize_t ;ssize_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define rangeFrom(index, from, maxCount)
 range loop starting at value from ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define arange(index, array)   range(index, ARRAY_SIZE(array))
 loop on the elements of C static array of any type More...
 
#define arangeDown(index, array)   rangeDown(index, ARRAY_SIZE(array))
 loop on the elements of C static array of any type from highest index down to 0 More...
 
#define arangeDownTo(index, array, to)   rangeDownTo(index, ARRAY_SIZE(array), to)
 loop on the elements of C static array of any type from highest index down to index 'to' More...
 
#define arangeFrom(index, from, array)   rangeFrom(index, from, ARRAY_SIZE(array))
 loop on the elements of C static array of any type starting at index 'from' More...
 
#define circular(index, from, maxCount)
 range from value from to maxCount-1 then from 0 to from-1 More...
 
#define circularDown(index, from, maxCount)
 range from value from down to 0 then from maxCount-1 to from+1 More...
 
#define rangeStep(index, maxCount, step)
 range step loop ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define rangeDownStep(index, maxCount, step)   for (int64_t index = (maxCount)-1 ; index >= 0 ; index-=step)
 range down step loop, index is int64_t More...
 
#define rangeFromStep(index, from, maxCount, step)
 range step loop starting at value from ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define loop(maxCount)
 loops without index ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define loopDownTo(maxCount, to)
 loop to to index ;ssize_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define loopFrom(from, maxCount)
 loop starting at value from ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define loopStep(maxCount, step)
 step loop ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define loopFromStep(from, maxCount, step)
 step loop starting at value from ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define aForEach(array, element)
 loop on array elements element is a pointer to a value in the array More...
 
#define aEnumerate(array, index, element)
 enumerate array elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array More...
 
#define forEachCharP(list, element)   for (char **element=list ; *element != NULL ; element++)
 forEach - loop macro on list indexes to access the element in the loop, use *element More...
 
#define forEachCCharP(list, element)   for (const char **element=list ; *element != NULL ; element++)
 forEach for const char** lists More...
 
#define forEachS(list, element)
 forEach - loop macro on list indexes to access the element in the loop, use element ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define forEachCS(list, element)
 forEach for const char** lists More...
 
#define forEachType(type, list, element)   for (type **element=list ; *element != NULL ; element++)
 forEach - loop macro on list indexes More...
 
#define enumerateCharP(list, element, index)
 enumerateCharP list to access the element in the loop, use *element ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define enumerateCCharP(list, element, index)
 enumerateCCharP const list to access the element in the loop, use *element ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define enumerateS(list, element, index)
 enumerateS list to acess the element in the loop, use element ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define enumerateCS(list, element, index)
 enumerateCS const list to acess the element in the loop, use element ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define enumerateType(type, list, element, index)
 enumerateType list ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers More...
 
#define lForEach(node, startNode)   for(var node = startNode; node ; node = (node)->next)
 loop for linked lists from startNode to last More...
 
#define lForEachDown(node, startNode)   for(var node = startNode; node ; node = (node)->prev)
 loop for linked lists from startNode to head More...
 
#define lForEachPrev   lForEachDown
 
#define execOutf   systemOutf
 
#define execf   systemf
 
#define systemOut   execOut
 
#define logSystem(cmd)
 
#define logExec   logSystem
 
#define logSystemOut(cmd)
 
#define logExecOut   logSystemOut
 
#define logSystemOutf(fmt, ...)
 
#define logExecOutf   logSystemOutf
 
#define logSystemf(fmt, ...)
 
#define logExecf   logSystemf
 
#define command(cmd)   commandF(cmd, __LINE__, __func__, __FILE__)
 
#define commandf(...)   commandfF(__LINE__, __func__, __FILE__, __VA_ARGS__)
 
#define commandNFree(cmd)   commandNFreeF(cmd, __LINE__, __func__, __FILE__)
 
#define commandOut   execOut
 
#define commandOutf   systemOutf
 
#define logCommand(cmd)
 
#define logCommandf(fmt, ...)
 
#define logCommandNFree(cmd)
 
#define logCommandOut   logExecOut
 
#define logCommandOutf   logExecOutf
 
#define logBtrace   char **UNIQVAR(r)=btrace();if(UNIQVAR(r)){logN("\n"BLD WHT"Backtrace:"RST);forEachS(UNIQVAR(r), element){logN(element);}listFreeS(UNIQVAR(r));logN("---");}
 
#define logEBtrace   if (btraceCfg) { char **UNIQVAR(r)=btrace();if(UNIQVAR(r)){logE("\n"BLD WHT"Backtrace:"RST);forEachS(UNIQVAR(r), element){logE(element);}listFreeS(UNIQVAR(r));logE("---");} }
 print backtrace in error messages, default is on, use btraceEnable and btraceDisable to configure More...
 
#define listEmpty(list)
 
#define listCreate(...)   listCreateF(NULL, __VA_ARGS__, NULL)
 
#define listFreeMany(...)   listFreeManyF(NULL, __VA_ARGS__, NULL)
 
#define listCat(...)   listCatF(NULL, __VA_ARGS__, NULL)
 
#define newPtr(name, type)   ;type *name = malloc(sizeof(type))
 
#define new0Ptr(name, type)   ;type *name = calloc(1, sizeof(type))
 
#define allocAPtr(name)   name = malloc(sizeof(*(name)))
 
#define callocAPtr(name)   name = calloc(1, sizeof(*(name)))
 
#define newArray(name, type, count)   ;type *name = malloc((count) * sizeof(type))
 
#define new0Array(name, type, count)   ;type *name = calloc(count, sizeof(type))
 
#define allocArray(name, count)   malloc((count) * sizeof(*(name)))
 
#define allocAArray(name, count)   name = malloc((count) * sizeof(*(name)))
 
#define callocArray(name, count)   calloc(count, sizeof(*(name)))
 
#define callocAArray(name, count)   name = calloc(count, sizeof(*(name)))
 
#define reallocArray(name, count)   realloc(name, (count) * sizeof(*(name)))
 
#define sliceSz   1
 slice - dynamic array in one chunk of memory (similar to vector and slab below) More...
 
#define sliceT(typeName, elementType)
 declares type for slice More...
 
#define createSlice(typeName, name)   ;typeName name; sliceInit(&name)
 
#define createSliceCount(typeName, name, count)   ;typeName name; sliceInitCount(&name, count)
 
#define createSliceClearCount(typeName, name, count)   ;typeName name; sliceCalloc(&name, count)
 
#define createAllocateSlice(typeName, name)   ;typeName *name = calloc(1, sizeof(typeName))
 
#define createAllocateSliceCount(typeName, name, count)   ;typeName *name = calloc(1, sizeof(typeName)); sliceInitCount(name, count)
 
#define createAllocateSliceClearCount(typeName, name, count)   ;typeName *name = calloc(1, sizeof(typeName)); sliceCalloc(name, count)
 
#define sliceTerminate(name)   if (name) sliceFree(name);free(name)
 
#define sliceInit(name)
 initialize empty slice More...
 
#define sliceInitCount(name, countInt)
 initialize slice and count More...
 
#define sliceCalloc(name, countInt)
 initialize slice and count and set slice data to 0 More...
 
#define sliceResize(name, countInt)
 resize slice (even empty slices) More...
 
#define sliceClearResize(name, countInt)
 resize slice and clear the new elements with memset even empty slices can be resized and cleared More...
 
#define sliceFree(name)   free((name)->array)
 free the internal buffers More...
 
#define sliceElemType(name)   typeof((name)->array[0])
 element type in slice More...
 
#define sliceElemPtrType(name)   typeof(&(name)->array[0])
 element pointer type in slice More...
 
#define sliceDup(name)
 duplicate slice More...
 
#define sliceCreateNDup(name, dest)   ;typeof(*(name)) dest; sliceInitCount(&dest, (name)->count); if ((name)->array) { memcpy(dest.array, (name)->array, (name)->count * sizeof (name)->array[0]); dest.count = (name)->count;}
 assign slice from to slice to the data is shared between slice from and slice to the counts are not shared More...
 
#define sliceBDup(name, dest)
 duplicate slice to already declared dest slice More...
 
#define sliceData(name)   (name)->array
 direct access to underlying array More...
 
#define sliceFrom(name, array, countInt)
 copy data from array to slice More...
 
#define sliceMirror(name, start, end)
 mirror a range in a slice the data is not copied to dest slice, to copy data see sliceCopy or sliceBCopy More...
 
#define sliceBMirror(name, dest, start, end)
 mirror a range in a slice the data is not copied to dest slice, to copy data see sliceCopy or sliceBCopy More...
 
#define sliceMirrorFrom(name, array, countInt)
 mirror from array to slice the data is not copied to dest slice, to copy data see sliceCopy or sliceBCopy More...
 
#define sliceClear(name)
 set 0 in slice elements count is unchanged More...
 
#define sliceClearRange(name, start, end)
 
#define sliceEmpty(name)   (name)->count = 0
 Empty slice Set count to 0 Allocated buffers in the slice must be freed before running sliceEmpty. More...
 
#define sliceIsEmpty(name)   ((name)->count == 0 || !(name)->array)
 is slice Empty More...
 
#define sliceFit(name)
 realloc slice to count More...
 
#define sliceCount(name)   (name)->count
 return element count More...
 
#define sliceElemSize(name)   sizeof((name)->array[0])
 size of slice element More...
 
#define sliceAlloc(name)
 allocate an element only when the slice is full More...
 
#define sliceClearElem(name, index)   memset(&(name)->array[index], 0, sizeof (name)->array[0])
 clear (set 0) in element at index More...
 
#define slicePush(name)
 push element and expand the slice no data (random) is set in the new element More...
 
#define sliceAppend(name, v)
 append element and expand the slice More...
 
#define sliceClearPush(name)
 push element and expand the slice the new element is cleared More...
 
#define slicePop(name)   ((name)->count--, (name)->array[(name)->count])
 pop element the element count is decreased More...
 
#define sliceDelLast(name)   ((name)->count--)
 delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used More...
 
#define sliceSet(name, index, v)
 set value at index and clearResize slice when index is outside slice count More...
 
#define sliceAt(name, index)   ((name)->array[index])
 get / set element at index More...
 
#define slicePtr(name, index)   ((name)->array + index)
 get pointer to element at index More...
 
#define sliceLast(name)   ((name)->array[(name)->count-1])
 last element More...
 
#define sliceLastPtr(name)   ((name)->array + (name)->count - 1)
 pointer to last element More...
 
#define sliceLastIndex(name)   ((name)->count - 1)
 index of last element More...
 
#define sliceFirst(name)   ((name)->array[0])
 first element More...
 
#define sliceWriteFilename(name, filename)
 write the slice content to filename file No NULL checks are done on the parameters More...
 
#define sliceWrite(name, file)   fwrite((name)->array, sizeof((name)->array[0]), sliceCount(name), file)
 write the slice content to disk No NULL checks are done on the parameters More...
 
#define sliceReadFilename(name, filename)
 read a slice from filename file No NULL checks are done on the parameters More...
 
#define sliceRead(name, file)
 read a slice from disk No NULL checks are done on the parameters More...
 
#define forEachSc(name, index)   range(index, (name)->count)
 loop index on slice elements More...
 
#define sliceForEach(name, element)
 loop on slice elements element is a pointer to a value in the array More...
 
#define sliceEnumerate(name, index, element)
 enumerate slice elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array More...
 
#define sliceInject(name, index)
 insert an element at index the data is moved to create space for the new element to set data at the new element, use sliceAt(name, index) = value; More...
 
#define slicePrepend(name, v)
 prepend element More...
 
#define sliceDequeue(name)
 dequeue element More...
 
#define sliceDelFirst(name)
 delete first element in slice the data is moved when count > 1 More...
 
#define sliceDelElem(name, index)
 delete an element in slice the data is moved when index < (count-1) when index = count -1, the last element is deleted and no data is moved More...
 
#define sliceDel(name, start, end)
 delete range in slice start must be between 0 and last index end must be between 1 and count More...
 
#define sliceVAppend(name, slice)
 append slice to slice name the data is copied More...
 
#define sliceAppendFrom(name, array, countInt)
 append array to slice the data is copied More...
 
#define sliceVPrepend(name, slice)
 prepend slice to slice name the data in slice name is moved and the data in slice is copied to slice name More...
 
#define slicePrependFrom(name, array, countInt)
 prepend array to slice the data in slice is moved and the data in array is copied to slice More...
 
#define sliceInsert(name, index, slice)
 insert slice at position index the data in slice name is moved and the data in slice is copied to slice name More...
 
#define sliceInsertFrom(name, index, array, countInt)
 insert array at position index the data in slice is moved and the data in array is copied to slice More...
 
#define sliceSlice(name, start, end)
 slice slice, keep only elements between start and end start must be between 0 and last index end must be between 1 and count the slice is returned More...
 
#define sliceCopy(name, start, end)
 copy slice elements between start and end to a new slice start must be between 0 and last index end must be between 1 and count the new slice is returned and must be freed with sliceTerminate More...
 
#define sliceBCopy(name, dest, start, end)
 copy slice elements between start and end to the dest slice start must be between 0 and last index end must be between 1 and count More...
 
#define sliceSort(name, compareFunction)
 sort the slice the compareFunction must prototype of type: int cmp(const void * a, const void * b); the results of the compareFunction should be: <0 when a < b 0 when a = b >0 when a > b More...
 
#define sliceEq(name, slice, eqFunction)
 return true when slice name is equal to slice eqFunction should return true when the elements are equal eqFunction can be either a macro or a function More...
 
#define sliceHas(name, value, eqFunction)
 return true when slice has value eqFunction should return true when the elements are equal eqFunction can be either a macro or a function More...
 
#define sliceIndexOf(name, value, eqFunction)
 return index (ssize_t) of value in slice eqFunction should return true when the elements are equal eqFunction can be either a macro or a function More...
 
#define sliceBinarySearch(name, value, less, equal)
 binary search value in slice More...
 
#define sliceUniq(name, eqFunction)
 Uniquify elements in slice each elements are unique in the slice. More...
 
#define staticSliceT(typeName, elementType, MAXCOUNT)
 staticSlice - static array with element count More...
 
#define createStaticSlice(typeName, name)   ;typeName name; staticSliceInit(&name)
 
#define staticSliceInit(name)
 initialize empty staticSlice More...
 
#define staticSliceElemType(name)   typeof((name)->array[0])
 element type in slice More...
 
#define staticSliceElemPtrType(name)   typeof(&(name)->array[0])
 element pointer type in slice More...
 
#define staticSliceBDup(name, dest)
 duplicate staticSlice to already declared dest staticSlice More...
 
#define staticSliceData   sliceData
 direct access to underlying array More...
 
#define staticSliceFrom(name, array, countInt)
 copy data from array to staticSlice More...
 
#define staticSliceClear(name)   memset((name)->array, 0, (name)->count * sizeof (name)->array[0])
 set 0 in staticSlice elements count is unchanged More...
 
#define staticSliceClearRange(name, start, end)   memset((name)->array + start, 0, (end-start) * sizeof (name)->array[0])
 
#define staticSliceEmpty   sliceEmpty
 Empty staticSlice Set count to 0 Allocated buffers in the staticSlice must be freed before running staticSliceEmpty. More...
 
#define staticSliceIsEmpty(name)   ((name)->count == 0)
 is staticSlice Empty More...
 
#define staticSliceCount   sliceCount
 return element count More...
 
#define staticSliceElemSize   sliceElemSize
 size of staticSlice element More...
 
#define staticSliceClearElem   sliceClearElem
 clear (set 0) in element at index More...
 
#define staticSlicePush(name)   (name)->count++
 push element and expand the staticSlice no data (random) is set in the new element More...
 
#define staticSliceAppend(name, v)
 append element and expand the staticSlice More...
 
#define staticSliceClearPush(name)
 push element and expand the staticSlice the new element is cleared More...
 
#define staticSlicePop   slicePop
 pop element the element count is decreased More...
 
#define staticSliceDelLast   sliceDelLast
 delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used More...
 
#define staticSliceAt   sliceAt
 get / set element at index More...
 
#define staticSlicePtr   slicePtr
 get pointer to element at index More...
 
#define staticSliceLast   sliceLast
 last element More...
 
#define staticSliceLastPtr   sliceLastPtr
 pointer to last element More...
 
#define staticSliceLastIndex   sliceLastIndex
 index of last element More...
 
#define staticSliceFirst   sliceFirst
 first element More...
 
#define staticSliceWriteFilename   sliceWriteFilename
 write the staticSlice content to filename file No NULL checks are done on the parameters More...
 
#define staticSliceWrite   sliceWrite
 write the staticSlice content to disk No NULL checks are done on the parameters More...
 
#define staticSliceReadFilename(name, filename)
 read a staticSlice from filename file No NULL checks are done on the parameters More...
 
#define staticSliceRead(name, file)
 read a staticSlice from disk No NULL checks are done on the parameters More...
 
#define forEachSSc   forEachSc
 loop index on staticSlice elements More...
 
#define staticSliceForEach(name, element)
 loop on slice elements element is a pointer to a value in the array More...
 
#define staticSliceEnumerate(name, index, element)
 enumerate slice elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array More...
 
#define staticSliceInject(name, index)
 insert an element at index the data is moved to create space for the new element to set data at the new element, use staticSliceAt(name, index) = value; More...
 
#define staticSlicePrepend(name, v)
 prepend element More...
 
#define staticSliceDequeue   sliceDequeue
 dequeue element More...
 
#define staticSliceDelFirst   sliceDelFirst
 delete first element in staticSlice the data is moved when count > 1 More...
 
#define staticSliceDelElem   sliceDelElem
 delete an element in staticSlice the data is moved when index < (count-1) when index = count -1, the last element is deleted and no data is moved More...
 
#define staticSliceDel   sliceDel
 delete range in staticSlice start must be between 0 and last index end must be between 1 and count More...
 
#define staticSliceVAppend(name, staticSlice)
 append staticSlice to staticSlice name the data is copied More...
 
#define staticSliceAppendFrom(name, array, countInt)
 append array to staticSlice the data is copied More...
 
#define staticSliceVPrepend(name, staticSlice)
 prepend staticSlice to staticSlice name the data in staticSlice name is moved and the data in staticSlice is copied to staticSlice name More...
 
#define staticSlicePrependFrom(name, array, countInt)
 prepend array to staticSlice the data in staticSlice is moved and the data in array is copied to staticSlice More...
 
#define staticSliceInsert(name, index, staticSlice)
 insert staticSlice at position index the data in staticSlice name is moved and the data in staticSlice is copied to staticSlice name More...
 
#define staticSliceInsertFrom(name, index, array, countInt)
 insert array at position index the data in staticSlice is moved and the data in array is copied to staticSlice More...
 
#define staticSliceSlice   sliceSlice
 staticSlice staticSlice, keep only elements between start and end start must be between 0 and last index end must be between 1 and count the staticSlice is returned More...
 
#define staticSliceBCopy(name, dest, start, end)
 copy staticSlice elements between start and end to the dest staticSlice start must be between 0 and last index end must be between 1 and count More...
 
#define staticSliceSort   sliceSort
 sort the staticSlice the compareFunction must prototype of type: int cmp(const void * a, const void * b); the results of the compareFunction should be: <0 when a < b 0 when a = b >0 when a > b More...
 
#define staticSliceEq   sliceEq
 return true when staticSlice name is equal to staticSlice eqFunction should return true when the elements are equal eqFunction can be either a macro or a function More...
 
#define staticSliceHas   sliceHas
 return true when staticSlice has value eqFunction should return true when the elements are equal eqFunction can be either a macro or a function More...
 
#define staticSliceIndexOf   sliceIndexOf
 return index (ssize_t) of value in staticSlice eqFunction should return true when the elements are equal eqFunction can be either a macro or a function More...
 
#define staticSliceBinarySearch   sliceBinarySearch
 binary search value in staticSlice More...
 
#define staticSliceUniq   sliceUniq
 Uniquify elements in staticSlice each elements are unique in the staticSlice. More...
 
#define vectorSz   1
 vector - dynamic array in one chunk of memory (similar to slab below) More...
 
#define vectorT(typeName, elementType)
 declares type for vector More...
 
#define createVector(typeName, name)   ;typeName name; vectorInit(&name)
 
#define createVectorCount(typeName, name, count)   ;typeName name; vectorInitCount(&name, count)
 
#define createVectorClearCount(typeName, name, count)   ;typeName name; vectorCalloc(&name, count)
 
#define createAllocateVector(typeName, name)   ;typeName *name = calloc(1, sizeof(typeName))
 
#define createAllocateVectorCount(typeName, name, count)   ;typeName *name = calloc(1, sizeof(typeName)); vectorInitCount(name, count)
 
#define createAllocateVectorClearCount(typeName, name, count)   ;typeName *name = calloc(1, sizeof(typeName)); vectorCalloc(name, count)
 
#define vectorTerminate(name)   if (name) vectorFree(name);free(name)
 
#define vectorInit(name)
 initialize empty vector More...
 
#define vectorInitCount(name, countInt)
 initialize vector and count More...
 
#define vectorCalloc(name, countInt)
 initialize vector and count and set vector data to 0 More...
 
#define vectorResize(name, countInt)
 resize vector (even empty vectors) More...
 
#define vectorClearResize(name, countInt)
 resize vector and clear the new elements with memset even empty vectors can be resized and cleared More...
 
#define vectorFree   sliceFree
 free the internal buffers More...
 
#define vectorElemType(name)   typeof((name)->array[0])
 element type in vector More...
 
#define vectorElemPtrType(name)   typeof(&(name)->array[0])
 element pointer type in vector More...
 
#define vectorDup(name)
 duplicate vector More...
 
#define vectorCreateNDup(name, dest)   ;typeof(*(name)) dest; vectorInitCount(dest, (name)->count); if ((name)->array) { memcpy(dest->array, (name)->array, (name)->count * sizeof (name)->array[0]); dest->count = (name)->count;}
 declare dest vector and duplicate vector More...
 
#define vectorBDup(name, dest)
 duplicate vector to already declared dest vector More...
 
#define vectorData   sliceData
 direct access to underlying array More...
 
#define vectorFrom(name, array, countInt)
 copy data from array to vector More...
 
#define vectorClear   sliceClear
 set 0 in vector elements count is unchanged More...
 
#define vectorClearRange   sliceClearRange
 
#define vectorEmpty   sliceEmpty
 Empty vector Set count to 0 Allocated buffers in the vector must be freed before running vectorEmpty. More...
 
#define vectorIsEmpty   sliceIsEmpty
 is vector Empty More...
 
#define vectorFit(name)
 resize vector from maxCount to count More...
 
#define vectorCount   sliceCount
 return element count More...
 
#define vectorMaxCount(name)   (name)->maxCount
 return max element count More...
 
#define vectorElemSize   sliceElemSize
 size of vector element More...
 
#define vectorAlloc(name)
 allocate an element only when the vector is full More...
 
#define vectorClearElem   sliceClearElem
 clear (set 0) in element at index More...
 
#define vectorPush(name)
 push element and expand the vector no data (random) is set in the new element More...
 
#define vectorAppend(name, v)
 append element and expand the vector More...
 
#define vectorClearPush(name)
 push element and expand the vector the new element is cleared More...
 
#define vectorPop   slicePop
 pop element the element count is decreased More...
 
#define vectorDelLast   sliceDelLast
 delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used More...
 
#define vectorPushCount(name, countp)
 push multiple elements at once More...
 
#define vectorSet(name, index, v)
 set value at index and clearResize vector when index is outside vector maxCount More...
 
#define vectorAt   sliceAt
 get / set element at index More...
 
#define vectorPtr   slicePtr
 get pointer to element at index More...
 
#define vectorLast   sliceLast
 last element More...
 
#define vectorLastPtr   sliceLastPtr
 pointer to last element More...
 
#define vectorLastIndex   sliceLastIndex
 index of last element More...
 
#define vectorFirst   sliceFirst
 first element More...
 
#define vectorWriteFilename   sliceWriteFilename
 write the vector content to filename file No NULL checks are done on the parameters More...
 
#define vectorWrite   sliceWrite
 write the vector content to disk No NULL checks are done on the parameters More...
 
#define vectorReadFilename(name, filename)
 read a vector from filename file No NULL checks are done on the parameters More...
 
#define vectorRead(name, file)
 read a vector from disk No NULL checks are done on the parameters More...
 
#define forEachV   forEachSc
 loop index on vector elements More...
 
#define vectorForEach(name, element)
 loop on vector elements element is a pointer to a value in the array More...
 
#define vectorEnumerate(name, index, element)
 enumerate vector elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array More...
 
#define vectorInject(name, index)
 insert an element at index the data is moved to create space for the new element to set data at the new element, use vectorAt(name, index) = value; More...
 
#define vectorPrepend(name, v)
 prepend element More...
 
#define vectorDequeue   sliceDequeue
 dequeue element More...
 
#define vectorDelFirst   sliceDelFirst
 delete first element in vector the data is moved when count > 1 More...
 
#define vectorDelElem   sliceDelElem
 delete an element in vector the data is moved when index < (count-1) when index = count -1, the last element is deleted and no data is moved More...
 
#define vectorDel   sliceDel
 delete range in vector start must be between 0 and last index end must be between 1 and count More...
 
#define vectorVAppend(name, vector)
 append vector to vector name the data is copied More...
 
#define vectorAppendFrom(name, array, countInt)
 append array to vector the data is copied More...
 
#define vectorVPrepend(name, vector)
 prepend vector to vector name the data in vector name is moved and the data in vector is copied to vector name More...
 
#define vectorPrependFrom(name, array, countInt)
 prepend array to vector the data in vector is moved and the data in array is copied to vector More...
 
#define vectorInsert(name, index, vector)
 insert vector at position index the data in vector name is moved and the data in vector is copied to vector name More...
 
#define vectorInsertFrom(name, index, array, countInt)
 insert array at position index the data in vector is moved and the data in array is copied to vector More...
 
#define vectorSlice   sliceSlice
 slice vector, keep only elements between start and end start must be between 0 and last index end must be between 1 and count the vector is returned More...
 
#define vectorCopy(name, start, end)
 copy vector elements between start and end to a new vector start must be between 0 and last index end must be between 1 and count the new vector is returned and must be freed with vectorTerminate More...
 
#define vectorBCopy(name, dest, start, end)
 copy vector elements between start and end to the dest vector start must be between 0 and last index end must be between 1 and count More...
 
#define vectorSort   sliceSort
 sort the vector the compareFunction must prototype of type: int cmp(const void * a, const void * b); the results of the compareFunction should be: <0 when a < b 0 when a = b >0 when a > b More...
 
#define vectorEq   sliceEq
 return true when vector name is equal to vector eqFunction should return true when the elements are equal eqFunction can be either a macro or a function More...
 
#define vectorHas   sliceHas
 return true when vector has value eqFunction should return true when the elements are equal eqFunction can be either a macro or a function More...
 
#define vectorIndexOf   sliceIndexOf
 return index (ssize_t) of value in vector eqFunction should return true when the elements are equal eqFunction can be either a macro or a function More...
 
#define vectorBinarySearch   sliceBinarySearch
 binary search value in vector More...
 
#define vectorUniq   sliceUniq
 Uniquify elements in vector each elements are unique in the vector. More...
 
#define dVectorBits   6
 dynamic segmented vector More...
 
#define dVectorSz   (1<<dVectorBits)
 
#define dVectorMask   (dVectorSz-1)
 
#define dVectorT(typeName, elementType)
 declares type for dynamic array More...
 
#define createDVector(typeName, name)   ;typeName name; dVectorInit(&name)
 
#define createDVectorCount(typeName, name, count)   ;typeName name; dVectorInitCount(&name, count)
 
#define dVectorInit(a)
 initialize dynamic array with minimum element count More...
 
#define dVectorInitCount(a, count)
 initialize dynamic array and count More...
 
#define dVectorResize(a, count)
 
#define dVectorFree(a)
 free the internal buffers More...
 
#define dVectorElemType(name)   typeof((name)->element)
 element type in vector More...
 
#define dVectorElemPtrType(name)   typeof(&(name)->element)
 element pointer type in vector More...
 
#define dVectorEmpty(name)   (name)->count = 0
 Empty Array Allocated buffers in the array must be freed before running dVectorEmpty. More...
 
#define dVectorIsEmpty(name)   ((name)->count == 0)
 is Array Empty More...
 
#define dVectorCount(name)   (name)->count
 return element count More...
 
#define dVectorMaxCount(name)   ((name)->maxCount * dVectorSz)
 return max element count More...
 
#define dVectorAlloc(a)
 allocate buffer for new elements only when the array is full More...
 
#define dVectorPush(a)
 push element and expand the dynamic array no data (random) is set in the new element. More...
 
#define dVectorAppend(a, v)
 append element and expand the dynamic array More...
 
#define dVectorPop(a)   ((a)->count--, *((typeof((a)->element)*)((a)->buffers[((a)->count)>>dVectorBits])+(((a)->count)&dVectorMask)))
 pop element the index of the last element is decreased More...
 
#define dVectorDelLast(a)   ((a)->count--)
 delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used More...
 
#define dVectorAt(a, index)   (*((typeof((a)->element)*)((a)->buffers[(index)>>dVectorBits])+((index)&dVectorMask)))
 get / set element at index More...
 
#define dVectorPtr(a, index)   ((typeof((a)->element)*)((a)->buffers[(index)>>dVectorBits])+((index)&dVectorMask))
 get pointer to element at index More...
 
#define dVectorLast(a)   (*((typeof((a)->element)*)((a)->buffers[((a)->count-1)>>dVectorBits])+(((a)->count-1)&dVectorMask)))
 last element More...
 
#define dVectorLastPtr(a)   ((typeof((a)->element)*)((a)->buffers[((a)->count-1)>>dVectorBits])+(((a)->count-1)&dVectorMask))
 pointer to last element More...
 
#define dVectorLastIndex(a)   ((a)->count-1)
 index of last element More...
 
#define dVectorFirst(a)   (*((typeof((a)->element)*)((a)->buffers[0])))
 first element More...
 
#define dVectorWriteFilename(a, filename)
 write the dVector content to filename file No NULL checks are done on the parameters More...
 
#define dVectorWrite(a, file)
 write the dVector content to disk No NULL checks are done on the parameters More...
 
#define dVectorReadFilename(a, filename)
 read a dVector from filename file No NULL checks are done on the parameters More...
 
#define dVectorRead(a, file)
 read a dVector from disk No NULL checks are done on the parameters More...
 
#define dVectorForEach(name, element)
 loop on dVector elements element is a pointer to a value in the array More...
 
#define dVectorEnumerate(name, index, element)
 enumerate dVector elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array More...
 
#define staticArrayT(typeName, element, MAXCOUNT)
 declares type for staticArray or ring More...
 
#define createStaticArray(typeName, name)   ;typeName name; staticArrayInit(name)
 
#define staticArrayInit(name)
 initialize count in array/static ring this macro can initialize rings if the struct is accessed directly More...
 
#define staticArrayElemType(name)   typeof((name).list[0])
 element type in array More...
 
#define staticArrayElemPtrType(name)   typeof(&(name).list[0])
 element pointer type in array More...
 
#define staticArrayEmpty(name)
 Empty Array Allocated buffers in the list must be freed before running staticArrayEmpty. More...
 
#define staticArrayIsEmpty(name)   ((name).isEmpty)
 is Array Empty More...
 
#define staticArrayIsFull(name)   ((name).isEmpty ? 0 : ((((name).last+1) % (name).maxCount) == (name).head))
 is Array Full More...
 
#define staticArrayCount(name)   ((name).isEmpty ? 0 : ((((name).last) >= ((name).head)) ? ((name).last-(name).head+1) : (((name).maxCount-(name).head + (name).last+1))) )
 return elements count More...
 
#define staticArrayPush(name)
 push element to array (only increases last) use staticArrayLast to access the element More...
 
#define staticArrayPop(name)
 pop element from array (only decreases last) More...
 
#define staticArrayDelLast   staticArrayPop
 
#define staticArrayPrepend(name)
 prepend element to array (only decreases head) use staticArrayFirst to access the element More...
 
#define staticArrayDequeue(name)
 dequeue element from array (only increases head) More...
 
#define staticArrayDelFirst   staticArrayDequeue
 
#define staticArrayGet(name, index)   (name).list[(((index) >= 0) ? (index) : staticArrayCount(name) + (index) )]
 get element at index, negative index is supported More...
 
#define staticArrayAt   staticArrayGet
 
#define staticArrayGetIndex(name, index)   ((((index) >= 0) ? (index) : staticArrayCount(name) + (index) ))
 index of element for an index relative to 0, negative index is supported More...
 
#define staticArrayRef(name, index)   (name).list[((((index) >= 0) ? (index) : staticArrayCount(name) + (index) ) + name.head) % name.maxCount]
 get element at index with name->head index 0, negative index is supported More...
 
#define staticArrayRefIndex(name, index)   (((((index) >= 0) ? (index) : staticArrayCount(name) + (index) ) + name.head) % name.maxCount)
 index of element for an index relative to head, negative index is supported More...
 
#define staticArrayLast(name)   (name).list[(name).last]
 last element in array More...
 
#define staticArrayLastIndex(name)   (name).last
 index of last element More...
 
#define staticArrayFirst(name)   (name).list[(name).head]
 first element in array More...
 
#define staticArrayFirstIndex(name)   (name).head
 index of first element More...
 
#define staticArrayDelElem(name, index)
 delete an element in the array and move elements after it to fill the gap More...
 
#define staticArrayWriteFilename(name, filename)
 write the staticArray content to filename file No NULL checks are done on the parameters More...
 
#define staticArrayWrite(name, file)
 write the staticArray content to disk No NULL checks are done on the parameters More...
 
#define staticArrayReadFilename(name, filename)
 read name staticArray from filename file No NULL checks are done on the parameters More...
 
#define staticArrayRead(name, file)
 read name staticArray from disk No NULL checks are done on the parameters More...
 
#define staticArrayForEach(name, element)
 loop on staticArray elements element is a pointer to a value in the array More...
 
#define staticArrayEnumerate(name, index, element)
 enumerate staticArray elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array More...
 
#define indexer   staticArrayBase
 indexer is a staticArray without the list It indexes an independent array More...
 
#define indexerT(typeName, INT_TYPE)
 declare an indexer type with INT_TYPE counters instead of the default i64 INT_TYPE has to be signed integer More...
 
#define createIndexer(typeName, name, maxCount)   ;typeName name; indexerInit(name, maxCount)
 
#define indexerInit(name, MAXCOUNT)
 initialize count in array/static ring this macro can initialize rings if the struct is accessed directly More...
 
#define indexerPInit   ringInit
 
#define indexerEmpty   staticArrayEmpty
 Empty Array Allocated buffers in the list must be freed before running staticArrayEmpty. More...
 
#define indexerPEmpty   ringEmpty
 
#define indexerIsEmpty   staticArrayIsEmpty
 is Array Empty More...
 
#define indexerPIsEmpty   ringIsEmpty
 
#define indexerIsFull   staticArrayIsFull
 is Array Full More...
 
#define indexerPIsFull   ringIsFull
 
#define indexerCount   staticArrayCount
 return elements count More...
 
#define indexerPCount   ringCount
 
#define indexerPush   staticArrayPush
 push element to array (only increases last) use staticArrayLast to access the element More...
 
#define indexerPPush   ringPush
 
#define indexerPop   staticArrayPop
 pop element from array (only decreases last) More...
 
#define indexerPPop   ringPop
 
#define indexerPrepend   staticArrayPrepend
 prepend element to array (only decreases head) use staticArrayFirst to access the element More...
 
#define indexerPPrepend   ringPrepend
 
#define indexerDequeue   staticArrayDequeue
 dequeue element from array (only increases head) More...
 
#define indexerPDequeue   ringDequeue
 
#define indexerRef(name, index)   (((((index) >= 0) ? (index) : indexerCount(name) + (index) ) + name.head) % name.maxCount)
 index element at index with name->head index 0, negative index is supported More...
 
#define indexerPRef(name, index)   (((((index) >= 0) ? (index) : indexerPCount(name) + (index) ) + name->head) % name->maxCount)
 
#define indexerLast(name)   name.last
 index of last element in array More...
 
#define indexerPLast(name)   (name)->last
 
#define indexerFirst(name)   (name.head)
 index of first element in array More...
 
#define indexerPFirst(name)   (name)->head
 
#define ringBase   staticArrayBase
 rings usage More...
 
#define ringMake   staticArrayT
 declares type for staticArray or ring staticArrayT(typeName, element, MAXCOUNT) More...
 
#define ringStaticInit   staticArrayInit
 initialize count in array/static ring staticArrayInit(name, MAXCOUNT) More...
 
#define ringGet(name, index)   (name)->list[(((index) >= 0) ? (index) : ringCount(name) + (index) )]
 get element at index, negative index is supported More...
 
#define ringRef(name, index)   (name)->list[((((index) >= 0) ? (index) : ringCount(name) + (index) ) + name->head) % name->maxCount]
 get element at index with name->head index 0, negative index is supported More...
 
#define ringLast(name)   (name)->list[(name)->last]
 last element in ring More...
 
#define ringLastIndex(name)   (name)->last
 index of last element More...
 
#define ringFirst(name)   (name)->list[(name)->head]
 last element in ring More...
 
#define ringSend(name, value)
 send data in ring More...
 
#define ringSendSt(status, name, value)
 
#define ringRecv(name, result)
 receive data from ring More...
 
#define ringRecvSt(status, name, result)
 
#define tCount   10
 
#define fiberCtx(thisSlot)   fibers.context[thisSlot]
 get fiber context for thisSlot More...
 
#define startJump(func)
 fibers with setjmp (not ucontext) internal More...
 
#define yield(slotValue, slot)
 yield jumps back to other fiber slot should be a local variable in the fiber slot is set to the index in fiberJumpBuffers for current fiber backToSlot is the index in fiberJumpBuffers for the other fiber More...
 
#define fiberEnd(slot)
 return to scheduler and end the fiber More...
 
#define schedulerYield(backToSlot)
 
#define dArrayBits   6
 dynamic segmented array More...
 
#define dArraySz   (1<<dArrayBits)
 
#define dArrayMask   (dArraySz-1)
 
#define dArrayT(typeName, elementType)
 declares type for dynamic array More...
 
#define createDArray(typeName, name)   ;typeName name; dArrayInit(&name)
 
#define createDArrayCount(typeName, name, count)   ;typeName name; dArrayInitCount(&name, count)
 
#define dArrayInit(a)
 initialize dynamic array with minimum element count More...
 
#define dArrayInitCount(a, count)
 initialize dynamic array and count More...
 
#define dArrayResize(a, count)
 
#define dArrayFree   dVectorFree
 free the internal buffers More...
 
#define dArrayElemType(a)   typeof((a)->element)
 element type in array More...
 
#define dArrayElemPtrType(a)   typeof(&(a)->element)
 element pointer type in array More...
 
#define dArrayEmpty(name)
 Empty Array Allocated buffers in the array must be freed before running dArrayEmpty. More...
 
#define dArrayIsEmpty(name)   ((name)->head == (name)->last)
 is Array Empty More...
 
#define dArrayCount(name)   ((name)->last - (name)->head)
 return element count More...
 
#define dArrayMaxCount(name)   ((name)->maxCount * dArraySz)
 return max element count More...
 
#define dArrayAlloc(a)
 allocate buffer for new elements only when the array is full More...
 
#define dArrayPush(a)
 push element and expand the dynamic array no data (random) is set in the new element. More...
 
#define dArrayAppend(a, v)
 append element and expand the dynamic array More...
 
#define dArrayPop(a)   ((a)->last--, *((typeof((a)->element)*)((a)->buffers[((a)->last)>>dArrayBits])+(((a)->last)&dArrayMask)))
 pop element the index of the last element is decreased More...
 
#define dArrayDelLast(a)   ((a)->last--)
 delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used More...
 
#define dArrayPrepend(a, v)
 prepend element More...
 
#define dArrayDequeue(a)   ((a)->head++, *((typeof((a)->element)*)((a)->buffers[((a)->head-1)>>dArrayBits])+(((a)->head-1)&dArrayMask)))
 dequeue element the index of the head element is increased More...
 
#define dArrayDelFirst(a)   ((a)->head++)
 delete the first element useful for avoiding warning: right-hand operand of comma expression has no effect when the dequeued value is not used More...
 
#define dArrayAt(a, index)   (*((typeof((a)->element)*)((a)->buffers[(index)>>dArrayBits])+((index)&dArrayMask)))
 get / set element at index More...
 
#define dArrayPtr(a, index)   ((typeof((a)->element)*)((a)->buffers[(index)>>dArrayBits])+((index)&dArrayMask))
 get pointer to element at index More...
 
#define dArraySet(a, index, v)
 set at index and resize dArray when index is greater then maxCount More...
 
#define dArraySparseSet(a, index, v)
 sparse set at index and resize dArray when index is greater then maxCount dArraySparseSet allows using dArray as a sparse array More...
 
#define dArrayLast(a)   (*((typeof((a)->element)*)((a)->buffers[((a)->last-1)>>dArrayBits])+(((a)->last-1)&dArrayMask)))
 last element More...
 
#define dArrayLastPtr(a)   ((typeof((a)->element)*)((a)->buffers[((a)->last-1)>>dArrayBits])+(((a)->last-1)&dArrayMask))
 pointer to last element More...
 
#define dArrayLastIndex(a)   ((a)->last-1)
 index of last element More...
 
#define dArrayLastIndexVar(a)   ((a)->last)
 direct access to the last element index variable for assignments More...
 
#define dArrayFirst(a)   (*((typeof((a)->element)*)((a)->buffers[((a)->head)>>dArrayBits])+((a)->head)&dArrayMask))
 first element More...
 
#define dArrayFirstIndex(a)   ((a)->head)
 index of first element More...
 
#define dArrayWriteFilename(a, filename)
 write the dArray content to filename file No NULL checks are done on the parameters More...
 
#define dArrayWrite(a, file)
 write the dArray content to disk No NULL checks are done on the parameters More...
 
#define dArrayReadFilename(a, filename)
 read a dArray from filename file No NULL checks are done on the parameters More...
 
#define dArrayRead(a, file)
 read a dArray from disk No NULL checks are done on the parameters More...
 
#define dArrayForEach(name, element)
 loop on dArray elements element is a pointer to a value in the array More...
 
#define dArrayEnumerate(name, index, element)
 enumerate dArray elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array More...
 
#define slabSz   64
 slab - dynamic array in one chunk of memory More...
 
#define slabT(typeName, elementType)
 declares type for dynamic array More...
 
#define createSlab(typeName, name)   ;typeName name; slabInit(&name)
 
#define createSlabCount(typeName, name, count)   ;typeName name; slabInitCount(&name, count)
 
#define slabInit(a)
 initialize dynamic array with minimum element count More...
 
#define slabInitCount(a, count)
 initialize slab and count More...
 
#define slabResize(a, count)
 
#define slabFree   sliceFree
 free the internal buffers More...
 
#define slabElemType(name)   typeof((name)->array[0])
 element type in array More...
 
#define slabElemPtrType(name)   typeof(&(name)->array[0])
 element pointer type in array More...
 
#define slabEmpty(name)
 Empty Array. More...
 
#define slabIsEmpty(name)   ((name)->head == (name)->last)
 is Array Empty More...
 
#define slabCount(name)   ((name)->last - (name)->head)
 return element count More...
 
#define slabMaxCount   vectorMaxCount
 return max element count More...
 
#define slabAlloc(a)
 allocate buffer for new elements only when the slab is full More...
 
#define slabPush(a)
 push element and expand the slab no data (random) is set in the new element More...
 
#define slabAppend(a, v)
 append element and expand the slab More...
 
#define slabPop(a)   ((a)->last--, *((a)->array + (a)->last))
 pop element the index of the last element is decreased More...
 
#define slabDelLast(a)   ((a)->last--)
 delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used More...
 
#define slabPrepend(a, v)
 prepend element More...
 
#define slabDequeue(a)   ((a)->head++, *((a)->array + (a)->head -1))
 dequeue element the index of the head element is increased More...
 
#define slabDelFirst(a)   ((a)->head++)
 delete the first element useful for avoiding warning: right-hand operand of comma expression has no effect when the dequeued value is not used More...
 
#define slabAt   sliceAt
 get / set element at index More...
 
#define slabPtr   slicePtr
 get pointer to element at index More...
 
#define slabLast(a)   (*((a)->array + (a)->last -1))
 last element More...
 
#define slabLastPtr(a)   ((a)->array + (a)->last -1)
 pointer to last element More...
 
#define slabLastIndex(a)   ((a)->last-1)
 index of last element More...
 
#define slabLastIndexVar(a)   ((a)->last)
 direct access to the last element index variable for assignments More...
 
#define slabFirst(a)   (*((a)->array + (a)->head))
 first element More...
 
#define slabFirstIndex(a)   ((a)->head)
 index of first element More...
 
#define slabWriteFilename(a, filename)
 write the slab content to filename file No NULL checks are done on the parameters More...
 
#define slabWrite(a, file)   fwrite((a)->array + (a)->head, 1, sizeof(*((a)->array)) * slabCount(a), file)
 write the slab content to disk No NULL checks are done on the parameters More...
 
#define slabReadFilename(a, filename)
 read a slab from filename file No NULL checks are done on the parameters More...
 
#define slabRead(a, file)
 read a slab from disk No NULL checks are done on the parameters More...
 
#define slabForEach(name, element)
 loop on slab elements element is a pointer to a value in the array More...
 
#define slabEnumerate(name, index, element)
 enumerate slab elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array More...
 
#define staticBitsetT(typeName, containerType, count)   typedef struct {containerType map[BUCKETS(count, 8 * sizeof(containerType))];} typeName;
 static bitset More...
 
#define staticBitsetInit   staticBitsetClear
 
#define staticBitsetCount(name)   (sizeof((name)->map) * 8)
 bitset count More...
 
#define staticBitsetClear(name)   memset(name, 0, sizeof(*(name)));
 clear all bits in bitset More...
 
#define staticBitsetBucket(name, index)   (name)->map[index / (8 * sizeof((name)->map[0]))]
 bucket containing bit at given index More...
 
#define staticBitset0(name, index)
 set 0 at index More...
 
#define staticBitset1(name, index)
 set 1 at index More...
 
#define staticBitsetSet(name, index, value)
 set bit value at index More...
 
#define staticBitsetInv(name, index)
 invert bit at index More...
 
#define staticBitsetGet(name, index)
 get bit at index More...
 
#define bitsetModulo   8
 end static bitset More...
 
#define bitsetBucket(name, index)   (name)->map[index / (bitsetModulo)]
 bucket containing bit at given index More...
 
#define bitset0(name, at, index)
 set 0 at index at must be macro or function taking 2 parameters: at(name, intIndex) and point to value at intIndex More...
 
#define bitset1(name, at, index)
 set 1 at index at must be macro or function taking 2 parameters: at(name, intIndex) and point to value at intIndex More...
 
#define bitsetSet(name, at, index, value)
 set bit value at index at must be macro or function taking 2 parameters: at(name, intIndex) and point to value at intIndex More...
 
#define bitsetInv(name, at, index)
 invert bit at index at must be macro or function taking 2 parameters: at(name, intIndex) and point to value at intIndex More...
 
#define bitsetGet(name, at, index)
 get bit at index at must be macro or function taking 2 parameters: at(name, intIndex) and return the value at intIndex More...
 
#define FIELD_SET(dst, val, msb, lsb)   dst = (/*clear field in dst*/ (dst) & ((0xFFFFFFFFFFFFFFFEUL << (msb)) | ((1UL<<(lsb))-1) )) | (/*clear highest bits in val and shift to field lsb*/(~(0xFFFFFFFFFFFFFFFEUL << ((msb)-(lsb))) & (val)) << (lsb))
 end bitset More...
 
#define FIELD_GET   EXTRACT
 
#define FIELD_SETL(dst, index, val, len)   FIELD_SET(dst, val, ((index)+1)*(len)-1, (index)*(len))
 set bitfield value in destination, given bitfield index and length More...
 
#define BITFIELD_SET(array, index, val, len)   FIELD_SET((array)[((index)*(len))/64], val, ((index)*(len))%64+(len)-1, ((index)*(len))%64)
 set bitfield value in array of bitfields the boundaries are not checked More...
 
#define BITFIELD_GET(array, index, len)   EXTRACT((array)[((index)*(len))/64], ((index)*(len))%64+(len)-1, ((index)*(len))%64)
 get bitfield value in array of bitfields the boundaries are not checked More...
 
#define BITFIELD_SIZE(count, len, containerType)   BUCKETS((count)*(len), 8 * sizeof(containerType))
 return number of u64 necessary to hold count bitfields of length len More...
 
#define BITFIELD_VAR(array, count, len)   u64 array[BITFIELD_SIZE(count, len, u64)]
 declare an array to hold count bitfields of length len More...
 
#define nanoSleep(time)   pError0(nanoSleepF(time))
 sleep nanoseconds More...
 
#define nanoSleep(time)   pError0(nanoSleepF(time))
 sleep nanoseconds More...
 
#define nanoSleepE(time, cmd)   pErrorCmd(nanoSleepF(time), == 0, cmd)
 nanoSleep and error code More...
 
#define usSleep(time)   pError0(nanoSleepF(1000 * (uint64_t)time))
 sleep microseconds More...
 
#define msSleep(time)   pError0(nanoSleepF(1000000 * (uint64_t)time))
 sleep miliseconds More...
 
#define UNUSED
 
#define DEPRECATED
 
#define PACKED
 
#define CLEANUP
 
#define FALLTHRU
 
#define AINLINE
 
#define NOINLINE
 
#define PURE
 
#define CONST
 
#define NORETURN
 
#define AMALLOC
 
#define MUST_CHECK
 
#define USED
 
#define ALIGN(X)
 
#define ALIGN_MAX
 
#define likely(x)   (x)
 
#define unlikely(x)   (x)
 

Typedefs

typedef void(* initLibsheepyObjectP) (void)
 
typedef int rune
 
typedef int(* shCmpt) (const void *a, const void *b)
 
typedef void(* fiberFT) (int)
 fiber function type More...
 

Functions

void cleanUpCharFree (char **val)
 
void cleanUpListFree (char ***val)
 
void cleanUpFileFree (FILE **val)
 
void cleanUpFd (int *val)
 
uint64_t shStopwatch (uint8_t op)
 nanosecond stopwatch More...
 
FILE *SH_PREFIX() setLogFile (char *filename)
 set log file the logs are appended to all log files set with this function More...
 
int getLogSymbols (void) MUST_CHECK
 get current log symbols More...
 
void setLogSymbols (int mode)
 set log symbols More...
 
int getMaxLogLevel (void) MUST_CHECK
 get current max log level More...
 
void setMaxLogLevel (int logLevel)
 set max log level logs above logMaxLevel are skipped More...
 
void closeLogFiles (void)
 close logfiles opened with setLogFile More...
 
int getLogMode (void) MUST_CHECK
 get current log mode (verbose, concise) More...
 
void setLogMode (int mode)
 set log mode LOG_VERBOSE, LOG_CONCISE, . More...
 
bool getLogShortPath (void) MUST_CHECK
 get current log long/short path value More...
 
void setLogShortPath (bool shortPath)
 set log long/short file path value for VERBOSE mode More...
 
bool getLogStdout (void) MUST_CHECK
 get stdout state, when TRUE (default) all logs are printed to stdout More...
 
void setLogStdout (bool state)
 enable/disable printing logs to stdout More...
 
bool openProgLogFile (void) MUST_CHECK
 log to a file named progName.log Use closeLogFiles when finished logging More...
 
void keepAnsiColorsInLog (bool state)
 enable/disable ansi color codes in logs More...
 
void _pLog (int, const char *, const char *, int, const char *,...)
 
void initLibsheepyF (const char *progPath, initLibsheepyObjectP initF)
 initialize libsheepy (optional, for debug) More...
 
void finalizeLibsheepyCharAtExit (void)
 finalize libsheepy char at exit More...
 
int64_t getStackLimit (void) MUST_CHECK
 get current stack limit More...
 
int setStackLimit (int64_t stackSize) MUST_CHECK
 set stack limit More...
 
int enableCoreDump (void) MUST_CHECK
 enable core dump More...
 
const char * getProgName (void) MUST_CHECK
 get program name More...
 
bool setProgName (const char *name) MUST_CHECK
 set program name More...
 
void setDefaultProgName (void)
 set default program name More...
 
void freeProgName (void)
 free ProgName if set with setProgName More...
 
const char * getProgPath (void) MUST_CHECK
 get program path When initLibsheepy is called before this function, it returns the given program path. More...
 
const char * getRealProgPath (void) MUST_CHECK
 get real program path The first call allocates libSheepyRealProgPath, it is freed with freeRealProgPath More...
 
void freeRealProgPath (void)
 free real program path finalizeLibsheepy calls this function More...
 
int systemNFreeF (char *command, int line, const char *thisFunc, const char *thisFileName) MUST_CHECK
 run system command and free command buffer a message is printed when an error occurs More...
 
time_t getModificationTime (const char *path) MUST_CHECK
 get modification time for path More...
 
int setModificationTime (const char *path, time_t mtime) MUST_CHECK
 set modification time for path More...
 
bool isReadable (const char *path) MUST_CHECK
 is path readable More...
 
bool isWritable (const char *path) MUST_CHECK
 is path writable More...
 
bool isExecutable (const char *path) MUST_CHECK
 is path executable More...
 
bool equalModificationTimes (const char *path1, const char *path2) MUST_CHECK
 compare modification times for path1 and path2 More...
 
time_t getCurrentUnixTime (void) MUST_CHECK
 get current unix time in seconds More...
 
time_t strToUnixTime (const char *date, const char *format) MUST_CHECK
 convert date string to unix time More...
 
char * timeToS (const time_t t) MUST_CHECK
 time To String convert unix time to string (ctime is not used here because it adds
at the end of the string) More...
 
char * bTimeToS (char *dst, const time_t t) MUST_CHECK
 
char * bLTimeToS (char *dst, size_t dstSize, const time_t t) MUST_CHECK
 
char * timeToYMDS (const time_t t) MUST_CHECK
 time To Year-Month-Day Hour:Minute:Second String convert unix time to string More...
 
char * bTimeToYMDS (char *dst, const time_t t) MUST_CHECK
 
char * bLTimeToYMDS (char *dst, size_t dstSize, const time_t t) MUST_CHECK
 
char * getCurrentDate (void) MUST_CHECK
 get current date in ctime format (Wed Dec 12 11:44:08 2018) More...
 
char * bGetCurrentDate (char *dst) MUST_CHECK
 
char * bLGetCurrentDate (char *dst, size_t dstSize) MUST_CHECK
 
char * getCurrentDateYMD (void) MUST_CHECK
 get current date in Y-m-d H:M:S format More...
 
char * bGetCurrentDateYMD (char *dst) MUST_CHECK
 
char * bLGetCurrentDateYMD (char *dst, size_t dstSize) MUST_CHECK
 
char * shDirname (const char *path) MUST_CHECK
 sheepy dirname More...
 
char * bDirname (char *path) MUST_CHECK
 buffer dirname More...
 
char * bLDirname (char *path, size_t pathSize) MUST_CHECK
 buffer size dirname More...
 
char * expandHome (const char *path) MUST_CHECK
 expands ~/ ($HOME) or ~USER
duplicate and expand path. More...
 
char * iExpandHome (char **path) MUST_CHECK
 expands ~/ ($HOME) or ~USER
More...
 
char * bExpandHome (char *path) MUST_CHECK
 buffer expands ~/ ($HOME) or ~USER
More...
 
char * bLExpandHome (char *path, size_t pathSize) MUST_CHECK
 buffer size expands ~/ ($HOME) or ~USER
More...
 
char * normalizePath (const char *path) MUST_CHECK
 normalize path More...
 
char * iNormalizePath (char **path) MUST_CHECK
 normalize path More...
 
char * bNormalizePath (char *path) MUST_CHECK
 buffer normalize path More...
 
char * bLNormalizePath (char *path, size_t pathSize) MUST_CHECK
 buffer size normalize path More...
 
char * relPath (const char *path, const char *start) MUST_CHECK
 relative path More...
 
char * iRelPath (char **path, const char *start) MUST_CHECK
 relative path More...
 
char * bRelPath (char *dest, const char *path, const char *start) MUST_CHECK
 relative path More...
 
char * bLRelPath (char *dest, size_t destSize, char *path, const char *start) MUST_CHECK
 relative path More...
 
char * getHomePath (void) MUST_CHECK
 get home path More...
 
char * bGetHomePath (char *path) MUST_CHECK
 copy home path to path More...
 
char * bLGetHomePath (char *path, size_t pathSize) MUST_CHECK
 copy home path to path maximum pathSize More...
 
const char * getCHomePath (void) MUST_CHECK
 get home path as a const char* More...
 
char * getCwd (void) MUST_CHECK
 get current working directory More...
 
char * bLGetCwd (char *path, size_t pathSize) MUST_CHECK
 
int chDir (const char *path) MUST_CHECK
 change directory More...
 
bool isDir (const char *path) MUST_CHECK
 is directory More...
 
char * shReadlink (const char *path) MUST_CHECK
 sheepy read link More...
 
char * endlink (const char *path) MUST_CHECK
 end link More...
 
bool isLink (const char *path) MUST_CHECK
 is symbolic link More...
 
bool fileExists (const char *filePath) MUST_CHECK
 detect files and directories More...
 
bool fileChmod (const char *filePath, mode_t mode) MUST_CHECK
 like chmod in stdlibc but return true/false More...
 
ssize_t fileSize (const char *filePath) MUST_CHECK
 get file size More...
 
ssize_t fileSizeFP (FILE *fp) MUST_CHECK
 get file size from file pointer More...
 
void * readFileToS (const char *filePath) MUST_CHECK
 read file to string More...
 
void * bReadFileToS (const char *filePath, void *dst) MUST_CHECK
 buffer read file to string More...
 
void * bLReadFileToS (const char *filePath, void *dst, size_t dstSize) MUST_CHECK
 buffer size read file to string More...
 
ssize_t readFile (const char *filePath, void **buffer) MUST_CHECK
 read file to buffer More...
 
ssize_t bReadFile (const char *filePath, void *buffer) MUST_CHECK
 buffer read file to buffer More...
 
ssize_t bLReadFile (const char *filePath, void *buffer, size_t dstSize) MUST_CHECK
 buffer size read file to buffer More...
 
void * readStreamToS (FILE *fp) MUST_CHECK
 read file to string More...
 
void * bReadStreamToS (FILE *fp, void *dst) MUST_CHECK
 buffer read file to string More...
 
void * bLReadStreamToS (FILE *fp, void *dst, size_t dstSize) MUST_CHECK
 buffer size read file to string More...
 
int writeFileS (const char *filePath, const char *string) MUST_CHECK
 write string to file More...
 
int writeFile (const char *filePath, void *buffer, size_t len) MUST_CHECK
 write buffer to file More...
 
int writeStreamS (FILE *fp, const char *string) MUST_CHECK
 write string to file More...
 
int writeLStream (FILE *fp, void *buffer, size_t len) MUST_CHECK
 write buffer to file More...
 
bool appendFileS (const char *filePath, const char *string) MUST_CHECK
 append string to filePath More...
 
bool appendFile (const char *filePath, void *buffer, size_t len) MUST_CHECK
 append buffer to file More...
 
char ** walkDir (const char *dirPath) MUST_CHECK
 list all files in a directory recursively and sort the list More...
 
char ** walkDirDir (const char *dirPath) MUST_CHECK
 list all directories in a directory recursively and sort the list More...
 
char ** readDir (const char *dirPath) MUST_CHECK
 list files in a directory and sort the list More...
 
char ** readDirDir (const char *dirPath) MUST_CHECK
 list directories in a directory and sort the list More...
 
char ** walkDirAll (const char *dirPath) MUST_CHECK
 list all files and directories in a directory recursively and sort the list More...
 
char ** readDirAll (const char *dirPath) MUST_CHECK
 list files in a directory and sort the list More...
 
mode_t getUmask (void) MUST_CHECK
 get umask More...
 
mode_t getCurrentPermissions (void) MUST_CHECK
 get current permissions for creating directories More...
 
int mkdirParents (const char *path) MUST_CHECK
 recursive mkdir More...
 
int rmAll (const char *path) MUST_CHECK
 remove all delete recursively files and directories More...
 
int copy (const char *src, const char *dst) MUST_CHECK
 copy files recursively This function is equivalent to 'cp -Ra' without wildcards and circular link detection More...
 
int shRename (const char *src, const char *dst) MUST_CHECK
 rename file More...
 
int shMove (const char *src, const char *dst) MUST_CHECK
 move files recursively More...
 
void setSoftwareRandom (void)
 use software random numbers works on all cpu architectures the default random function is software More...
 
void setHardwareRandom (void)
 use cpu hardware random number generator More...
 
int randomUrandomOpen (void) MUST_CHECK
 open /dev/urandom in libsheepy More...
 
void randomUrandomClose (void)
 close /dev/urandom in libsheepy call this function when random are not needed anymore More...
 
uint64_t randomWord (void) MUST_CHECK
 return random 64 bit unsigned integer call randomUrandomOpen before this calling function More...
 
uint64_t randomWordFromHW (void) MUST_CHECK
 return random 64 bit unsigned integer from the cpu when the cpu doesn't have the random generator instruction, the program stops with 'Illegal instruction' More...
 
uint64_t randomChoice (uint64_t range) MUST_CHECK
 return a random value between 0 and range 0<=value<range call randomUrandomOpen before this calling function More...
 
char * randomS (uint64_t length) MUST_CHECK
 random string More...
 
char * bRandomS (char *dst, size_t length) MUST_CHECK
 buffer random string More...
 
char * randomAlphaNumS (uint64_t length) MUST_CHECK
 random alpha numerical string More...
 
char * bRandomAlphaNumS (char *dst, size_t dstSize) MUST_CHECK
 buffer random alpha numerical string More...
 
char * readS (void) MUST_CHECK
 read String read user input (one line) as a string More...
 
char * bLReadS (char *dst, size_t dstSize) MUST_CHECK
 buffer read String read user input (one line) as a string More...
 
char * readPasswordS (void) MUST_CHECK
 read hidden password string More...
 
bool zeroS (char *string) MUST_CHECK
 write zero to all bytes in string with memset, for clearing password buffers More...
 
bool zeroBuf (void *buf, size_t len) MUST_CHECK
 write zero to all bytes in buffer with memset More...
 
void * memdup (const void *buf, size_t size) MUST_CHECK
 memory duplicate allocate and copy buffer More...
 
void readEnter (void)
 read Enter key wait until press the enter key More...
 
char * readLine (FILE *fp) MUST_CHECK
 readLine from file stream the fist new line is converted to 0 More...
 
void freeManySF (char *paramType,...)
 free Many String More...
 
char * dupS (const char *string) MUST_CHECK
 duplicate string More...
 
void shPrintfS (const char *fmt,...)
 sheepy Print String More...
 
void shEPrintfS (const char *fmt,...)
 sheepy Error printf String print with logE More...
 
void logNFree (char *s)
 log and free More...
 
void loghex (const void *buf, size_t len)
 print buffer as hexadecimal string More...
 
char * toHexS (const void *buf, size_t len) MUST_CHECK
 create a string with bytes in buf converted to hex strings More...
 
char * toHexSepS (const void *buf, size_t len, const char *separator) MUST_CHECK
 create a string with bytes in buf converted to hex strings separated by separator More...
 
char * toHexHeadSepS (const void *buf, size_t len, const char *head, const char *separator) MUST_CHECK
 create a string with bytes in buf converted to hex strings separated by separator and with head string in front of earch byte: HEADffSEP More...
 
char * strCpy (char *restrict dst, const char *restrict src) MUST_CHECK
 strCpy - copy src to dst More...
 
char * strNCpy (char *restrict dst, const char *restrict src, size_t srcSize) MUST_CHECK
 strNCpy - copy src to dst More...
 
char * strLCpy (char *restrict dst, size_t dstSize, const char *restrict src) MUST_CHECK
 strLCpy - copy src to dst More...
 
char * strCat (char *restrict dst, const char *restrict src) MUST_CHECK
 strCat - concatenate two strings More...
 
char * strNCat (char *restrict dst, const char *restrict src, size_t srcLen) MUST_CHECK
 strNCat - concatenate two strings More...
 
char * strLCat (char *restrict dst, size_t dstSize, const char *restrict src) MUST_CHECK
 strLCat - concatenate two strings More...
 
char * strLNCat (char *restrict dst, size_t dstSize, const char *restrict src, size_t srcLen) MUST_CHECK
 strLNCat - concatenate two strings More...
 
char * catSF (const char *paramType,...) MUST_CHECK
 cat String Function More...
 
char * iCatSF (char *dst, const char *paramType,...) MUST_CHECK
 cat and copy String Function dst has to be big enough to hold the result More...
 
char * bLCatSF (char *dst, size_t dstSize, const char *paramType,...) MUST_CHECK
 cat and copy String Function More...
 
char * formatS (const char *fmt,...) MUST_CHECK
 format string allocate and format string using asprintf More...
 
char * bFormatS (char *string, const char *fmt,...) MUST_CHECK
 format and store in string: bFormatS(string, "Value %d", i); More...
 
char * bLFormatS (char *string, size_t stringSize, const char *fmt,...) MUST_CHECK
 format and store in string: bLFormatS(string, sizeof(string), "Value %d", i); More...
 
char * appendS (const char *string1, const char *string2) MUST_CHECK
 append strings More...
 
char * appendCharS (const char *string1, char c) MUST_CHECK
 append char to string when c is 0 the result is string1 More...
 
char * appendSChar (char c, const char *string2) MUST_CHECK
 append string to char More...
 
char * iAppendS (char **string1, const char *string2) MUST_CHECK
 append strings More...
 
char * iAppendCharS (char **string1, char c) MUST_CHECK
 append char to string More...
 
char * iAppendNFreeS (char **string1, char *string2) MUST_CHECK
 append and free strings More...
 
char * iAppendManySF (char **string, const char *paramType,...) MUST_CHECK
 append many strings More...
 
char * bAppendManySF (char *string, const char *paramType,...) MUST_CHECK
 buffer append many strings More...
 
char * bLAppendManySF (char *string, size_t stringSize, const char *paramType,...) MUST_CHECK
 buffer size append many strings More...
 
char * prependS (const char *string1, const char *string2) MUST_CHECK
 prepend strings More...
 
char * prependCharS (const char *string1, char c) MUST_CHECK
 prepend char to string More...
 
char * prependSChar (char c, const char *string2) MUST_CHECK
 prepend string to char More...
 
char * iPrependS (char **string1, const char *string2) MUST_CHECK
 prepend strings More...
 
char * iPrependCharS (char **string1, char c) MUST_CHECK
 prepend char to string More...
 
char * iPrependNFreeS (char **string1, char *string2) MUST_CHECK
 prepend and free strings More...
 
char * bPrependS (char *string1, const char *string2) MUST_CHECK
 buffer prepend strings More...
 
char * bLPrependS (char *string1, size_t string1Size, const char *string2) MUST_CHECK
 buffer prepend strings More...
 
char * replaceS (const char *s, const char *olds, const char *news, size_t max) MUST_CHECK
 replace String the original remains unchanged duplicate s the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings More...
 
char * replaceCharSS (const char *s, char olds, const char *news, size_t max) MUST_CHECK
 
char * replaceSCharS (const char *s, const char *olds, char news, size_t max) MUST_CHECK
 
char * replaceCharCharS (const char *s, char olds, char news, size_t max) MUST_CHECK
 
size_t replaceSLen (const char *s, const char *olds, const char *news, size_t max) MUST_CHECK
 replaceSLen returns the length of the resulting string More...
 
char * iReplaceS (char **s, const char *olds, const char *news, size_t max) MUST_CHECK
 replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings More...
 
char * iReplaceCharSS (char **s, char olds, const char *news, size_t max) MUST_CHECK
 
char * iReplaceSCharS (char **s, const char *olds, char news, size_t max) MUST_CHECK
 
char * iReplaceCharCharS (char **s, char olds, char news, size_t max) MUST_CHECK
 
char * bReplaceS (char *s, const char *olds, const char *news, size_t max) MUST_CHECK
 buffer replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings More...
 
char * bLReplaceS (char *s, size_t sSize, const char *olds, const char *news, size_t max) MUST_CHECK
 buffer size replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings More...
 
char * replaceManySF (const char *paramType,...) MUST_CHECK
 replace Many Strings the original remains unchanged duplicate s the olds string is replaced with the news string max times in the result More...
 
char * iReplaceManySF (char **string, char *paramType,...) MUST_CHECK
 replace Many Strings the olds string is replaced with the news string max times in the result More...
 
char * bReplaceManySF (char *s, char *paramType,...) MUST_CHECK
 buffer replace Many Strings the olds string is replaced with the news string max times in the result More...
 
char * bLReplaceManySF (char *s, size_t sSize, char *paramType,...) MUST_CHECK
 buffer size replace Many Strings the olds string is replaced with the news string max times in the result More...
 
char * icReplaceS (const char *s, const char *olds, const char *news, size_t max) MUST_CHECK
 ignore case Replace String the original remains unchanged duplicate s the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings More...
 
char * icReplaceCharSS (const char *s, char olds, const char *news, size_t max) MUST_CHECK
 
char * icReplaceSCharS (const char *s, const char *olds, char news, size_t max) MUST_CHECK
 
char * icReplaceCharCharS (const char *s, char olds, char news, size_t max) MUST_CHECK
 
char * iicReplaceS (char **s, const char *olds, const char *news, size_t max) MUST_CHECK
 in place ignore case replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings More...
 
char * iicReplaceCharSS (char **s, char olds, const char *news, size_t max) MUST_CHECK
 
char * iicReplaceSCharS (char **s, const char *olds, char news, size_t max) MUST_CHECK
 
char * iicReplaceCharCharS (char **s, char olds, char news, size_t max) MUST_CHECK
 
char * bicReplaceS (char *s, const char *olds, const char *news, size_t max) MUST_CHECK
 buffer ignore case replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings More...
 
char * bLicReplaceS (char *s, size_t sSize, const char *olds, const char *news, size_t max) MUST_CHECK
 buffer size ignore case replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings More...
 
char * icReplaceManySF (const char *paramType,...) MUST_CHECK
 ignore case replace Many Strings the original remains unchanged duplicate s the olds string is replaced with the news string max times in the result More...
 
char * iicReplaceManySF (char **string, char *paramType,...) MUST_CHECK
 in place ignore case replace Many Strings the olds string is replaced with the news string max times in the result More...
 
char * bicReplaceManySF (char *s, char *paramType,...) MUST_CHECK
 buffer ignore case replace Many Strings the olds string is replaced with the news string max times in the result More...
 
char * bLicReplaceManySF (char *s, size_t sSize, char *paramType,...) MUST_CHECK
 buffer size ignore case replace Many Strings the olds string is replaced with the news string max times in the result More...
 
bool eqS (const char *string1, const char *string2) MUST_CHECK
 string Equal compare string1 to string2 More...
 
bool eqCharS (char c, const char *string2) MUST_CHECK
 
bool eqSChar (const char *string1, char c) MUST_CHECK
 
bool eqIS (const char *string1, const char *string2, int64_t index) MUST_CHECK
 string Index Equal compare string1 at index to string2 when string2 is empty, the result is false More...
 
bool eqICharS (const char *string1, char c, int64_t index) MUST_CHECK
 
bool startsWithS (const char *string1, const char *string2) MUST_CHECK
 starts With String compare start of string1 with string2 More...
 
bool startsWithCharS (const char *string1, char c) MUST_CHECK
 
bool endsWithS (const char *string1, const char *string2) MUST_CHECK
 ends With String compare end of string1 with string2 More...
 
bool endsWithCharS (const char *string1, char c) MUST_CHECK
 
ssize_t countS (const char *s, const char *needle) MUST_CHECK
 count String count number of (non-overlapping) occurrences of a substring More...
 
ssize_t countCharS (const char *s, char c) MUST_CHECK
 
bool icEqS (const char *string1, const char *string2) MUST_CHECK
 ignore case string Equal compare string1 to string2 More...
 
bool icEqCharS (char c, const char *string2) MUST_CHECK
 
bool icEqSChar (const char *string1, char c) MUST_CHECK
 
bool icEqIS (const char *string1, const char *string2, int64_t index) MUST_CHECK
 ignore case string Index Equal compare string1 at index to string2 when string2 is empty, the result is false More...
 
bool icEqICharS (const char *string1, char c, int64_t index) MUST_CHECK
 
bool icStartsWithS (const char *string1, const char *string2) MUST_CHECK
 ignore case starts With String compare start of string1 with string2 More...
 
bool icStartsWithCharS (const char *string1, char c) MUST_CHECK
 
bool icEndsWithS (const char *string1, const char *string2) MUST_CHECK
 ignore case ends With String compare end of string1 with string2 More...
 
bool icEndsWithCharS (const char *string1, char c) MUST_CHECK
 
ssize_t icCountS (const char *s, const char *needle) MUST_CHECK
 ignore case count String count number of (non-overlapping) occurrences of a substring More...
 
ssize_t icCountCharS (const char *s, char c) MUST_CHECK
 
bool hasCtrlChar (const char *string) MUST_CHECK
 has control char More...
 
char * stripCtrlS (const char *string) MUST_CHECK
 remove terminal control char from string More...
 
char * iStripCtrlS (char **string) MUST_CHECK
 remove terminal control char from string More...
 
char * bStripCtrlS (char *string) MUST_CHECK
 remove terminal control char from string More...
 
char * stripColorsS (const char *string) MUST_CHECK
 remove ansi colors from string More...
 
char * iStripColorsS (char **string) MUST_CHECK
 remove ansi colors from string More...
 
char * bStripColorsS (char *string) MUST_CHECK
 remove terminal control char from string More...
 
char * quoteS (const char *s, char delim) MUST_CHECK
 add backslash '\' before delim('\'' or '"') and backslash the backslashes in the result avoid splitting the string when it is in a source file or a json string More...
 
char * bQuoteS (char *dest, const char *s, char delim) MUST_CHECK
 add backslash '\' before delim('\'' or '"') and backslash the backslashes in the result avoid splitting the string when it is in a source file or a json string More...
 
char * bLQuoteS (char *dest, size_t destSize, const char *s, char delim) MUST_CHECK
 add backslash '\' before delim('\'' or '"') and backslash the backslashes in the result avoid splitting the string when it is in a source file or a json string More...
 
size_t quoteLenS (const char *s, char delim) MUST_CHECK
 return the length of the escaped string (without the terminating \0) More...
 
char * escapeS (const char *s, char delim) MUST_CHECK
 escape string according the json specification (RFC 8259) if there is in the string, the backslash is escaped and it will be parsed as the string '' be the json parsers the unicode characters should be converted to UTF8 codepoints instead of using the result can be included in a json string and the parsing will be correct More...
 
char * bEscapeS (char *dest, const char *s, char delim) MUST_CHECK
 escape string according the json specification (RFC 8259) if there is in the string, the backslash is escaped and it will be parsed as the string '' be the json parsers the unicode characters should be converted to UTF8 codepoints instead of using the result can be included in a json string and the parsing will be correct More...
 
char * bLEscapeS (char *dest, size_t destSize, const char *s, char delim) MUST_CHECK
 escape string according the json specification (RFC 8259) if there is in the string, the backslash is escaped and it will be parsed as the string '' be the json parsers the unicode characters should be converted to UTF8 codepoints instead of using the result can be included in a json string and the parsing will be correct More...
 
size_t escapeLenS (const char *s, char delim) MUST_CHECK
 return the length of the escaped string (without the terminating \0) More...
 
char nibbleToHex (u8 n) MUST_CHECK
 convert number between 0 and 15 to hexadecimal character '0' to 'F' More...
 
char * cEscapeS (const char *S) MUST_CHECK
 escape string to become a valid C source string control characters, backslash and double quotes are escaped. More...
 
char * bCEscapeS (char *dest, const char *S) MUST_CHECK
 escape string to become a valid C source string control characters, backslash and double quotes are escaped. More...
 
char * bLCEscapeS (char *dest, size_t destSize, const char *S) MUST_CHECK
 escape string to become a valid C source string control characters, backslash and double quotes are escaped. More...
 
size_t cEscapeLenS (const char *s) MUST_CHECK
 return the length of the escaped string (without the terminating \0) More...
 
bool isNumber (const char *string) MUST_CHECK
 is Number (integer or float) String More...
 
bool isInt (const char *string) MUST_CHECK
 is Integer String More...
 
int64_t parseInt (const char *string) MUST_CHECK
 convert string to decimal integer More...
 
int64_t parseIntChar (char c) MUST_CHECK
 
int64_t parseI64 (const char *string) MUST_CHECK
 convert string to decimal integer More...
 
int64_t parseI64Char (char c) MUST_CHECK
 
double parseDouble (const char *string) MUST_CHECK
 convert string to double More...
 
double parseDoubleChar (char c) MUST_CHECK
 
uint64_t parseHex (const char *string) MUST_CHECK
 parse hexadecimal number in a string More...
 
char * intToS (int64_t n) MUST_CHECK
 int To String More...
 
char * bIntToS (char *s, int64_t n) MUST_CHECK
 buffer int To String More...
 
char * doubleToS (double n) MUST_CHECK
 double To String More...
 
char * bDoubleToS (char *s, double n) MUST_CHECK
 buffer double To String More...
 
size_t lenS (const char *string) MUST_CHECK
 length string More...
 
size_t sizeS (const char *string) MUST_CHECK
 string buffer size More...
 
char * upperS (const char *string) MUST_CHECK
 upper case String duplicate string More...
 
char * iUpperS (char **string) MUST_CHECK
 upper case String More...
 
char * bUpperS (char *string) MUST_CHECK
 buffer upper case String More...
 
char * lowerS (const char *string) MUST_CHECK
 lower case String duplicate string More...
 
char * iLowerS (char **string) MUST_CHECK
 lower case String More...
 
char * bLowerS (char *string) MUST_CHECK
 buffer lower case String More...
 
char * trimS (const char *string) MUST_CHECK
 trim String duplicate string More...
 
char * iTrimS (char **string) MUST_CHECK
 trim String More...
 
char * bTrimS (char *string) MUST_CHECK
 buffer trim String More...
 
char * lTrimS (const char *string) MUST_CHECK
 left trim String duplicate string More...
 
char * iLTrimS (char **string) MUST_CHECK
 left trim String More...
 
char * bLTrimS (char *string) MUST_CHECK
 buffer left trim String More...
 
char * rTrimS (const char *string) MUST_CHECK
 right trim String duplicate string More...
 
char * iRTrimS (char **string) MUST_CHECK
 right trim String More...
 
char * bRTrimS (char *string) MUST_CHECK
 buffer right trim String More...
 
char * uniqS (const char *string, char c) MUST_CHECK
 uniq String duplicate string More...
 
char * iUniqS (char **string, char c) MUST_CHECK
 uniq String More...
 
char * bUniqS (char *string, char c) MUST_CHECK
 buffer uniq String More...
 
char * icUniqS (const char *string, char c) MUST_CHECK
 ignore case uniq String duplicate string More...
 
char * iicUniqS (char **string, char c) MUST_CHECK
 in place ignore case uniq String More...
 
char * bicUniqS (char *string, char c) MUST_CHECK
 ignore case buffer uniq String More...
 
char * repeatS (const char *string, size_t count) MUST_CHECK
 repeat string count times More...
 
char * iRepeatS (char **string, size_t count) MUST_CHECK
 repeat string count times More...
 
char * bRepeatS (char *dest, const char *string, size_t count) MUST_CHECK
 repeat string count times More...
 
char * bLRepeatS (char *dest, size_t destSize, const char *string, size_t count) MUST_CHECK
 repeat string count times More...
 
char * repeatCharS (char c, size_t count) MUST_CHECK
 repeat char count times More...
 
char * bRepeatCharS (char *dest, char c, size_t count) MUST_CHECK
 repeat char count times More...
 
char * bLRepeatCharS (char *dest, size_t destSize, char c, size_t count) MUST_CHECK
 repeat char count times More...
 
ssize_t repeatLenS (const char *string, size_t count) MUST_CHECK
 length of string repeated count times More...
 
char * ellipsisStartS (const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK
 ellipsis start string More...
 
char * iEllipsisStartS (char **string, size_t targetLength, const char *ellipsisString) MUST_CHECK
 ellipsis start string More...
 
char * bEllipsisStartS (char *dest, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK
 ellipsis start string More...
 
char * bLEllipsisStartS (char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK
 ellipsis start string More...
 
char * ellipsisStartCharS (const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK
 ellipsis start string More...
 
char * iEllipsisStartCharS (char **string, size_t targetLength, char ellipsisChar) MUST_CHECK
 ellipsis start string More...
 
char * bEllipsisStartCharS (char *dest, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK
 ellipsis start string More...
 
char * bLEllipsisStartCharS (char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK
 ellipsis start string More...
 
ssize_t ellipsisLenS (const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK
 length of string after ellipsis More...
 
char * ellipsisEndS (const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK
 ellipsis end string More...
 
char * iEllipsisEndS (char **string, size_t targetLength, const char *ellipsisString) MUST_CHECK
 ellipsis end string More...
 
char * bEllipsisEndS (char *dest, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK
 ellipsis end string More...
 
char * bLEllipsisEndS (char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK
 ellipsis end string More...
 
char * ellipsisEndCharS (const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK
 ellipsis end string More...
 
char * iEllipsisEndCharS (char **string, size_t targetLength, char ellipsisChar) MUST_CHECK
 ellipsis end string More...
 
char * bEllipsisEndCharS (char *dest, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK
 ellipsis end string More...
 
char * bLEllipsisEndCharS (char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK
 ellipsis end string More...
 
char * padStartS (const char *string, size_t targetLength, const char *padString) MUST_CHECK
 pad start string More...
 
char * iPadStartS (char **string, size_t targetLength, const char *padString) MUST_CHECK
 pad start string More...
 
char * bPadStartS (char *dest, const char *string, size_t targetLength, const char *padString) MUST_CHECK
 pad start string More...
 
char * bLPadStartS (char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString) MUST_CHECK
 pad start string More...
 
char * padStartCharS (const char *string, size_t targetLength, char padChar) MUST_CHECK
 pad start string More...
 
char * iPadStartCharS (char **string, size_t targetLength, char padChar) MUST_CHECK
 pad start string More...
 
char * bPadStartCharS (char *dest, const char *string, size_t targetLength, char padChar) MUST_CHECK
 pad start string More...
 
char * bLPadStartCharS (char *dest, size_t destSize, const char *string, size_t targetLength, char padChar) MUST_CHECK
 pad start string More...
 
ssize_t padStartLenS (const char *string, size_t targetLength, const char *padString) MUST_CHECK
 length of string after padStart More...
 
char * padEndS (const char *string, size_t targetLength, const char *padString) MUST_CHECK
 pad end string More...
 
char * iPadEndS (char **string, size_t targetLength, const char *padString) MUST_CHECK
 pad end string More...
 
char * bPadEndS (char *dest, const char *string, size_t targetLength, const char *padString) MUST_CHECK
 pad end string More...
 
char * bLPadEndS (char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString) MUST_CHECK
 pad end string More...
 
char * padEndCharS (const char *string, size_t targetLength, char padChar) MUST_CHECK
 pad end string More...
 
char * iPadEndCharS (char **string, size_t targetLength, char padChar) MUST_CHECK
 pad end string More...
 
char * bPadEndCharS (char *dest, const char *string, size_t targetLength, char padChar) MUST_CHECK
 pad end string More...
 
char * bLPadEndCharS (char *dest, size_t destSize, const char *string, size_t targetLength, char padChar) MUST_CHECK
 pad end string More...
 
ssize_t padEndLenS (const char *string, size_t targetLength, const char *padString) MUST_CHECK
 length of string after padEnd More...
 
char getS (const char *string, int64_t index) MUST_CHECK
 get string More...
 
char * setS (char *string, int64_t index, char c) MUST_CHECK
 set string More...
 
char * swapS (char *string, int64_t index1, int64_t index2) MUST_CHECK
 swap characters in string More...
 
char * iSwapS (char **string, int64_t index1, int64_t index2) MUST_CHECK
 swap characters in string More...
 
char * bSwapS (char *string, int64_t index1, int64_t index2) MUST_CHECK
 swap characters in string More...
 
char * bLSwapS (char *string, size_t size, int64_t index1, int64_t index2) MUST_CHECK
 swap characters in string More...
 
char * sliceS (const char *string, int64_t start, int64_t end) MUST_CHECK
 slice String return new string which is the string between start and end negative indexes are allowed More...
 
char * iSliceS (char **string, int64_t start, int64_t end) MUST_CHECK
 slice String return string which is the string between start and end negative indexes are allowed More...
 
char * bSliceS (char *string, int64_t start, int64_t end) MUST_CHECK
 buffer slice String return string which is the string between start and end negative indexes are allowed More...
 
char * bLSliceS (char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK
 buffer size slice String return string which is the string between start and end negative indexes are allowed More...
 
char * cropS (char *string, int64_t start, int64_t end) MUST_CHECK
 Crop String return a new string with characters from start and end in string and delete characters from start to end in the original string negative indexes are allowed. More...
 
char * iCropS (char **string, int64_t start, int64_t end) MUST_CHECK
 Crop String return a new string with characters from start and end in string and delete characters from start to end in the original string negative indexes are allowed. More...
 
char cropElemS (char *string, int64_t index) MUST_CHECK
 
char iCropElemS (char **string, int64_t index) MUST_CHECK
 
char * insertS (const char *string, int64_t index, const char *toInsert) MUST_CHECK
 insert string in string at index More...
 
char * insertNFreeS (const char *string, int64_t index, char *toInsert) MUST_CHECK
 insert string in string at index and free toInsert when successful More...
 
char * iInsertS (char **string, int64_t index, const char *toInsert) MUST_CHECK
 insert string in string at index More...
 
char * iInsertNFreeS (char **string, int64_t index, char *toInsert) MUST_CHECK
 insert string in string at index and free toInsert More...
 
char * bInsertS (char *string, int64_t index, const char *toInsert) MUST_CHECK
 buffer insert string in string at index More...
 
char * bLInsertS (char *string, size_t stringSize, int64_t index, const char *toInsert) MUST_CHECK
 buffer size insert string in string at index More...
 
char * injectS (const char *string, int64_t index, char toInject) MUST_CHECK
 inject a char in string at index More...
 
char * iInjectS (char **string, int64_t index, char toInject) MUST_CHECK
 inject a char in string at index More...
 
char * bInjectS (char *string, int64_t index, char toInject) MUST_CHECK
 buffer inject a char in string at index More...
 
char * bLInjectS (char *string, size_t stringSize, int64_t index, char toInject) MUST_CHECK
 buffer size inject a char in string at index More...
 
char * delS (const char *string, int64_t start, int64_t end) MUST_CHECK
 delete string More...
 
char * iDelS (char **string, int64_t start, int64_t end) MUST_CHECK
 delete string More...
 
char * bDelS (char *string, int64_t start, int64_t end) MUST_CHECK
 buffer delete string More...
 
char * bLDelS (char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK
 buffer size delete string More...
 
char * delElemS (const char *string, int64_t index) MUST_CHECK
 delete element/character string More...
 
char * iDelElemS (char **string, int64_t index) MUST_CHECK
 delete element/character string More...
 
char * bDelElemS (char *string, int64_t index) MUST_CHECK
 buffer delete element/character string More...
 
char * bLDelElemS (char *string, size_t stringSize, int64_t index) MUST_CHECK
 buffer size delete element/character string More...
 
char * findS (const char *string, const char *needle) MUST_CHECK
 find String More...
 
char * findCharS (const char *string, char c) MUST_CHECK
 
ssize_t indexOfS (const char *string, const char *needle) MUST_CHECK
 indexOf String relative to start More...
 
ssize_t indexOfCharS (const char *string, char c) MUST_CHECK
 
bool hasS (const char *string, const char *needle) MUST_CHECK
 has String More...
 
bool hasCharS (const char *string, char c) MUST_CHECK
 
char * icFindS (const char *string, const char *needle) MUST_CHECK
 ignore case Find String More...
 
char * icFindCharS (const char *string, char c) MUST_CHECK
 
ssize_t icIndexOfS (const char *string, const char *needle) MUST_CHECK
 ignore case indexOf String relative to start More...
 
ssize_t icIndexOfCharS (const char *string, char c) MUST_CHECK
 
bool icHasS (const char *string, const char *needle) MUST_CHECK
 ignore case has String More...
 
bool icHasCharS (const char *string, char c) MUST_CHECK
 
char * tokS (char *s, const char *delim, char **saveptr) MUST_CHECK
 token in String More...
 
char * icTokS (char *s, const char *delim, char **saveptr) MUST_CHECK
 ignore case token in String More...
 
size_t lenUTF8 (const char *s) MUST_CHECK
 character length of UTF-8 string More...
 
size_t bLLenUTF8 (const char *s, size_t maxSize) MUST_CHECK
 buffer character length of UTF-8 string More...
 
bool isUTF8 (const char *string) MUST_CHECK
 is UTF-8 string More...
 
bool bLIsUTF8 (const char *string, size_t stringSize) MUST_CHECK
 buffer length is UTF-8 string More...
 
bool isCodeUTF8 (const char *code) MUST_CHECK
 is code point UTF8 encoded string More...
 
const char * nextUTF8 (const char *utf8) MUST_CHECK
 next UTF-8 code point More...
 
const char * bLNextUTF8 (const char *string, size_t utf8Size, const char *utf8) MUST_CHECK
 buffer length next UTF-8 code point More...
 
const char * findNextUTF8 (const char *string, size_t utf8Size, const char *utf8) MUST_CHECK
 find next UTF-8 code point even not at the start of a code point More...
 
const char * prevUTF8 (const char *utf8) MUST_CHECK
 previous UTF-8 code point More...
 
const char * bPrevUTF8 (const char *string, const char *utf8) MUST_CHECK
 buffer previous UTF-8 code point More...
 
const char * idx2PtrUTF8 (const char *utf8, int64_t index) MUST_CHECK
 index to pointer UTF8 encoded string More...
 
const char * bLIdx2PtrUTF8 (const char *utf8, size_t utf8Size, int64_t index) MUST_CHECK
 
int64_t ptr2IdxUTF8 (const char *utf8, const char *pos) MUST_CHECK
 pointer to code point index UTF8 encoded string More...
 
int64_t bPtr2IdxUTF8 (const char *start, const char *utf8, const char *pos) MUST_CHECK
 buffer pointer to code point index UTF8 encoded string More...
 
int64_t bLPtr2IdxUTF8 (const char *utf8, size_t utf8Size, const char *pos) MUST_CHECK
 buffer size pointer to code point index UTF8 encoded string More...
 
int64_t bLPtr2NegIdxUTF8 (const char *utf8, size_t utf8Size, const char *pos) MUST_CHECK
 buffer size pointer to negative code point index UTF8 encoded string More...
 
char * makeValidUTF8 (const char *utf8) MUST_CHECK
 make valid UTF-8 encoded string More...
 
char * bMakeValidUTF8 (char *utf8) MUST_CHECK
 buffer make valid UTF-8 encoded string More...
 
char * nMakeValidUTF8 (const char *utf8, size_t utf8Len) MUST_CHECK
 length make valid UTF-8 encoded string More...
 
char * bNMakeValidUTF8 (char *dst, const char *utf8, size_t utf8Len) MUST_CHECK
 buffer length make valid UTF-8 encoded string More...
 
char * bLMakeValidUTF8 (char *dst, size_t dstSize, const char *utf8) MUST_CHECK
 buffer destination size make valid UTF-8 encoded string More...
 
char * bLNMakeValidUTF8 (char *dst, size_t dstSize, const char *utf8, size_t utf8Len) MUST_CHECK
 buffer destination size source length make valid UTF-8 encoded string More...
 
char * strNCpyUTF8 (char *dst, const char *src, size_t srcLen) MUST_CHECK
 strNCpyUTF8 - copy src to dst with srcLen in code points More...
 
char * strLCpyUTF8 (char *dst, size_t dstSize, const char *src) MUST_CHECK
 strLCpyUTF8 - copy src to dst More...
 
char * strNCatUTF8 (char *dst, const char *src, size_t srcLen) MUST_CHECK
 strNCatUTF8 - concatenate two UTF-8 encoded strings More...
 
char * strLCatUTF8 (char *dst, size_t dstSize, const char *src) MUST_CHECK
 strLCatUTF8 - concatenate two UTF-8 encoded strings More...
 
char * strLNCatUTF8 (char *dst, size_t dstSize, const char *src, size_t srcLen) MUST_CHECK
 strLNCatUTF8 - concatenate two UTF-8 encoded strings More...
 
char * icReplaceUTF8 (const char *s, const char *olds, const char *news, size_t max) MUST_CHECK
 
char * icReplaceCharSUTF8 (const char *s, char olds, const char *news, size_t max) MUST_CHECK
 
char * icReplaceSCharUTF8 (const char *s, const char *olds, char news, size_t max) MUST_CHECK
 
char * iicReplaceUTF8 (char **s, const char *olds, const char *news, size_t max) MUST_CHECK
 
char * iicReplaceCharSUTF8 (char **s, char olds, const char *news, size_t max) MUST_CHECK
 
char * iicReplaceSCharUTF8 (char **s, const char *olds, char news, size_t max) MUST_CHECK
 
char * bicReplaceUTF8 (char *s, const char *olds, const char *news, size_t max) MUST_CHECK
 
char * bLicReplaceUTF8 (char *s, size_t sSize, const char *olds, const char *news, size_t max) MUST_CHECK
 
char * icReplaceManyUTF8F (const char *paramType,...) MUST_CHECK
 
char * iicReplaceManyUTF8F (char **s, char *paramType,...) MUST_CHECK
 
char * bicReplaceManyUTF8F (char *s, char *paramType,...) MUST_CHECK
 
char * bLicReplaceManyUTF8F (char *s, size_t sSize, char *paramType,...) MUST_CHECK
 
bool eqIUTF8 (const char *string1, const char *string2, int64_t index) MUST_CHECK
 UTF8 encoded string Index Equal compare string1 at character index to string2 when string2 is empty, the result is false. More...
 
bool eqICharUTF8 (const char *string1, char c, int64_t index) MUST_CHECK
 
bool icEqUTF8 (const char *string1, const char *string2) MUST_CHECK
 ignore case UTF8 encoded string Equal compare string1 to string2 More...
 
bool icEqCharUTF8 (char c, const char *string2) MUST_CHECK
 
bool icEqUTF8Char (const char *string1, char c) MUST_CHECK
 
bool icEqIUTF8 (const char *string1, const char *string2, int64_t index) MUST_CHECK
 
bool icEqICharUTF8 (const char *string1, char c, int64_t index) MUST_CHECK
 
bool icStartsWithUTF8 (const char *string1, const char *string2) MUST_CHECK
 ignore case starts With UTF8 encoded String compare start of string1 with string2 More...
 
bool icEndsWithUTF8 (const char *string1, const char *string2) MUST_CHECK
 ignore case ends With UTF8 encoded String compare end of string1 with string2 More...
 
ssize_t icCountUTF8 (const char *s, const char *needle) MUST_CHECK
 ignore case count UTF8 encoded String count number of (non-overlapping) occurrences of a substring More...
 
rune code2RuneUTF8 (const char *code) MUST_CHECK
 UTF-8 code point to rune. More...
 
rune code2RuneLUTF8 (const char *code, uint8_t *n) MUST_CHECK
 UTF-8 code point to rune and length. More...
 
size_t bRune2CodeUTF8 (char *dst, rune c) MUST_CHECK
 rune to UTF-8 code point More...
 
uint8_t runeLenUTF8 (rune r) MUST_CHECK
 rune length as UTF-8 code point More...
 
rune toupperUTF8 (rune c) MUST_CHECK
 rune toupper UTF8 More...
 
char * upperUTF8 (const char *string) MUST_CHECK
 upper case UTF-8 encoded string duplicate string More...
 
char * iUpperUTF8 (char **string) MUST_CHECK
 upper case UTF-8 encoded string More...
 
char * bUpperUTF8 (char *string) MUST_CHECK
 
rune tolowerUTF8 (rune c) MUST_CHECK
 rune tolower UTF8 More...
 
char * lowerUTF8 (const char *string) MUST_CHECK
 lower case UTF-8 String duplicate string More...
 
char * iLowerUTF8 (char **string) MUST_CHECK
 lower case String More...
 
char * bLowerUTF8 (char *string) MUST_CHECK
 
char * casefoldUTF8 (const char *utf8) MUST_CHECK
 casefold UTF-8 encoded string More...
 
char * uniqUTF8 (const char *string, const char *code) MUST_CHECK
 uniq UTF-8 String duplicate string More...
 
char * iUniqUTF8 (char **string, const char *code) MUST_CHECK
 uniq UTF-8 String More...
 
char * bUniqUTF8 (char *string, const char *code) MUST_CHECK
 buffer uniq String More...
 
char * icUniqUTF8 (const char *string, const char *code) MUST_CHECK
 
char * iicUniqUTF8 (char **string, const char *code) MUST_CHECK
 
char * bicUniqUTF8 (char *string, char c) MUST_CHECK
 
rune getUTF8 (const char *string, int64_t index) MUST_CHECK
 get UTF8 encoded string More...
 
char * setUTF8 (char *string, int64_t index, rune c) MUST_CHECK
 set UTF8 encoded string More...
 
char * sliceUTF8 (const char *string, int64_t start, int64_t end) MUST_CHECK
 slice UTF8 encoded String return new string which is the string between start and end negative indexes are allowed More...
 
char * iSliceUTF8 (char **string, int64_t start, int64_t end) MUST_CHECK
 slice UTF8 encoded String return string which is the string between start and end negative indexes are allowed More...
 
char * bSliceUTF8 (char *string, int64_t start, int64_t end) MUST_CHECK
 buffer slice UTF8 encoded String return string which is the string between start and end negative indexes are allowed More...
 
char * bLSliceUTF8 (char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK
 buffer size slice UTF8 encoded String return string which is the string between start and end negative indexes are allowed More...
 
char * insertUTF8 (const char *string, int64_t index, const char *toInsert) MUST_CHECK
 insert string in UTF8 encoded string at index More...
 
char * insertNFreeUTF8 (const char *string, int64_t index, char *toInsert) MUST_CHECK
 insert string in UTF8 encoded string at index and free toInsert More...
 
char * iInsertUTF8 (char **string, int64_t index, const char *toInsert) MUST_CHECK
 insert string in UTF8 encoded string at index More...
 
char * iInsertNFreeUTF8 (char **string, int64_t index, char *toInsert) MUST_CHECK
 insert string in UTF8 encoded string at index and free toInsert More...
 
char * bInsertUTF8 (char *string, int64_t index, const char *toInsert) MUST_CHECK
 buffer insert string in UTF8 encoded string at index More...
 
char * bLInsertUTF8 (char *string, size_t stringSize, int64_t index, const char *toInsert) MUST_CHECK
 buffer size insert string in UTF8 encoded string at index More...
 
char * delUTF8 (const char *string, int64_t start, int64_t end) MUST_CHECK
 delete UTF8 encoded string More...
 
char * iDelUTF8 (char **string, int64_t start, int64_t end) MUST_CHECK
 delete UTF8 encoded string More...
 
char * bDelUTF8 (char *string, int64_t start, int64_t end) MUST_CHECK
 buffer delete UTF8 encoded string More...
 
char * bLDelUTF8 (char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK
 buffer size delete UTF8 encoded string More...
 
ssize_t indexOfUTF8 (const char *string, const char *needle) MUST_CHECK
 indexOf UTF8 encoded String relative to start More...
 
ssize_t icIndexOfUTF8 (const char *string, const char *needle) MUST_CHECK
 
bool icHasUTF8 (const char *string, const char *needle) MUST_CHECK
 ignore case has UTF8 encoded String More...
 
char * icTokUTF8 (const char *s, const char *delim, char **saveptr) MUST_CHECK
 
char ** icExtractUTF8 (const char *string, const char *delim1, const char *delim2) MUST_CHECK
 
char ** icExtractCharSUTF8 (const char *string, char delim1, const char *delim2) MUST_CHECK
 
char ** icExtractSCharUTF8 (const char *string, const char *delim1, char delim2) MUST_CHECK
 
char ** icListSortUTF8 (char **list) MUST_CHECK
 ignore case list Sort UTF8 encoded String duplicate list and sort More...
 
char ** iicListSortUTF8 (char ***list) MUST_CHECK
 ignore case list Sort UTF8 encoded String More...
 
bool icListEqUTF8 (char **list1, char **list2) MUST_CHECK
 ignore case list Equal UTF8 encoded String compare each element of list1 and list2 More...
 
bool icListHasUTF8 (char **list, const char *string) MUST_CHECK
 ignore case and return true when list has UTF8 encoded string More...
 
ssize_t icListIndexOfUTF8 (char **list, const char *string) MUST_CHECK
 ignore case and return index of UTF8 encoded string in list More...
 
ssize_t icListBinarySearchUTF8 (char **list, const char *string) MUST_CHECK
 ignore case list binary search UTF8 encoded string More...
 
char ** icListUniqUTF8 (char **list) MUST_CHECK
 ignore case and uniquify UTF8 encoded elements of list duplicate list each elements are unique in the new list More...
 
char ** iicListUniqUTF8 (char ***list) MUST_CHECK
 ignore case and uniquify UTF8 encoded elements of list each elements are unique in the list More...
 
char * emptySF (void) MUST_CHECK
 empty String Function More...
 
char * iEmptySF (char **string) MUST_CHECK
 empty String Function More...
 
bool isEmptyS (const char *string) MUST_CHECK
 is Empty String More...
 
bool isBlankS (const char *string) MUST_CHECK
 is Blank String More...
 
ssize_t intIndex (int64_t index, int64_t length)
 int to positive index index can be negative More...
 
char ** listEmptySF (void) MUST_CHECK
 list Empty String Function More...
 
char ** iListEmptySF (char ***list) MUST_CHECK
 list Empty String Function More...
 
bool listIsEmptyS (char **list) MUST_CHECK
 list Is Empty String More...
 
bool listIsBlankS (char **list) MUST_CHECK
 list Is Empty String More...
 
char ** listCreateSF (const char *paramType,...) MUST_CHECK
 list Create String Function create a list from the list of parameters used from the listCreateS(...) macro More...
 
char ** listFromArrayS (char **array, size_t size) MUST_CHECK
 list From Array String More...
 
char ** listFromCArrayS (const char **array, size_t size) MUST_CHECK
 list From Const Array String More...
 
char ** listPushS (char ***list, const char *s) MUST_CHECK
 list Push String append s at the end of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, NULL is pushed at the end of the list More...
 
char ** listPushCharS (char ***list, char c) MUST_CHECK
 
char ** iListPushS (char ***list, char *s) MUST_CHECK
 list Push String append s pointer at the end of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, NULL is pushed at the end of the list More...
 
char * listPopS (char ***list) MUST_CHECK
 list Pop String return last string from list and remove last element from the list More...
 
char ** listPrependS (char ***list, const char *s) MUST_CHECK
 list Prepend String append s at the beginning of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, the operation is canceled More...
 
char ** listPrependCharS (char ***list, char c) MUST_CHECK
 
char ** iListPrependS (char ***list, char *s) MUST_CHECK
 list Prepend String append s pointer at the beginning of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, the operation is canceled More...
 
char * listDequeueS (char ***list) MUST_CHECK
 list Dequeue String return first string from list and remove it from the list More...
 
void listFreeS (char **list)
 list Free String More...
 
void listFreeManySF (char **paramType,...)
 list free many String More...
 
size_t listLengthS (char **list) MUST_CHECK
 list Length String return number of elements until the first NULL element More...
 
size_t listLengthCS (const char **list) MUST_CHECK
 const list Length String return number of elements until the first NULL element More...
 
ssize_t listStrLengthS (char **list) MUST_CHECK
 list String Length String More...
 
ssize_t listIntIndexS (char **list, int64_t index) MUST_CHECK
 list int to index String index can be negative More...
 
char ** listAddrS (char **list, int64_t index) MUST_CHECK
 list address String index can be negative More...
 
char * listGetS (char **list, int64_t index) MUST_CHECK
 list Get String duplicate string at given index index can be negative More...
 
char * iListGetS (char **list, int64_t index) MUST_CHECK
 list Get String index can be negative More...
 
char * listGetCS (const char **list, int64_t index) MUST_CHECK
 const list Get String duplicate string at given index index can be negative More...
 
const char * iListGetCS (const char **list, int64_t index) MUST_CHECK
 const list Get String index can be negative More...
 
char ** listSetS (char **list, int64_t index, const char *s) MUST_CHECK
 list Set String duplicate string and store at given index, the existing element is freed index can be negative More...
 
char ** listSetCharS (char **list, int64_t index, char c) MUST_CHECK
 
char ** iListSetS (char **list, int64_t index, char *s) MUST_CHECK
 list Set String store string at given index index can be negative More...
 
char ** listSwapS (char **list, int64_t index1, int64_t index2) MUST_CHECK
 swap elements in list More...
 
char ** iListSwapS (char **list, int64_t index1, int64_t index2) MUST_CHECK
 swap elements in list More...
 
char ** split (const char *string, const char *delim) MUST_CHECK
 split string with delim string when updating this function, also update splitS (identical to split) return list More...
 
char ** splitS (const char *string, const char *delim) MUST_CHECK
 
char ** splitChar (const char *string, char delim) MUST_CHECK
 
char ** icSplit (const char *string, const char *delim) MUST_CHECK
 ignore case split string with delim string when updating this function, also update icSplitS (identical to icSplit) return list More...
 
char ** icSplitS (const char *string, const char *delim) MUST_CHECK
 
char ** icSplitChar (const char *string, char delim) MUST_CHECK
 
ssize_t joinLength (char **list, const char *delim) MUST_CHECK
 join Length list length after joined with delimiter More...
 
char * join (char **list, const char *delim) MUST_CHECK
 join list, the elements are seperated with delim in the resulting string when updating this function, also update joinS (identical to join) More...
 
char * joinS (char **list, const char *delim) MUST_CHECK
 
char * joinCS (const char **list, const char *delim) MUST_CHECK
 join list, the elements are seperated with delim in the resulting string More...
 
char * joinChar (char **list, char delim) MUST_CHECK
 
char * bJoin (char *string, char **list, const char *delim) MUST_CHECK
 buffer join list, the elements are seperated with delim in the resulting string More...
 
char * bJoinChar (char *string, char **list, char delim) MUST_CHECK
 
char * bLJoin (char *string, size_t stringSize, char **list, const char *delim) MUST_CHECK
 buffer size join list, the elements are seperated with delim in the resulting string More...
 
char * bLJoinChar (char *string, size_t stringSize, char **list, char delim) MUST_CHECK
 
char ** extractS (const char *string, const char *delim1, const char *delim2) MUST_CHECK
 extract string between delim1 and delim2 strings return list More...
 
char ** extractCharSS (const char *string, char delim1, const char *delim2) MUST_CHECK
 
char ** extractSCharS (const char *string, const char *delim1, char delim2) MUST_CHECK
 
char ** extractCharCharS (const char *string, char delim1, char delim2) MUST_CHECK
 
char ** icExtractS (const char *string, const char *delim1, const char *delim2) MUST_CHECK
 ignore case extract string between delim1 and delim2 strings return list More...
 
char ** icExtractCharSS (const char *string, char delim1, const char *delim2) MUST_CHECK
 
char ** icExtractSCharS (const char *string, const char *delim1, char delim2) MUST_CHECK
 
char ** icExtractCharCharS (const char *string, char delim1, char delim2) MUST_CHECK
 
char ** listDupS (char **list) MUST_CHECK
 list Duplicate String More...
 
char ** listDupCS (const char **list) MUST_CHECK
 const list Duplicate String More...
 
char ** iListDupS (char **list) MUST_CHECK
 list Duplicate String More...
 
char ** listReverseS (char **list) MUST_CHECK
 list Reverse String duplicate and reverse list, the last element is the first element of the new list More...
 
char ** iListReverseS (char ***list) MUST_CHECK
 list Reverse String reverse list, the last element is the first element of the list More...
 
char ** listCatSF (char **paramType,...) MUST_CHECK
 list Cat String More...
 
char ** listAppendS (char ***list1, char **list2) MUST_CHECK
 list Append String Append list2 at the end of list1 More...
 
char ** iListAppendS (char ***list1, char **list2) MUST_CHECK
 in place list Append String Append list2 at the end of list1 by copying the pointers from list2 to list1. More...
 
char ** iListAppendNSmashS (char ***list1, char **list2) MUST_CHECK
 list Append and smash list2 Append list2 at the end of list1 by copying the pointers from list2 to list1. More...
 
char ** listShiftS (char ***list1, char **list2) MUST_CHECK
 list Shift String Append list2 at the start of list1 More...
 
char ** iListShiftS (char ***list1, char **list2) MUST_CHECK
 in place list Shift String Append list2 at the start of list1 by copying the pointers from list2 to list1. More...
 
char ** iListShiftNSmashS (char ***list1, char **list2) MUST_CHECK
 list Append and smash list2 Append list2 at the start of list1 by copying the pointers from list2 to list1. More...
 
char ** listAddS (char **list1, char **list2)
 list Add String add list1 and list2 in a new list More...
 
char ** listAddCS (char **list1, const char **list2)
 const list Add String add list1 and list2 in a new list More...
 
char ** listSliceS (char **list, int64_t start, int64_t end) MUST_CHECK
 list Slice String return new list with elements from start and end in list negative indexes are allowed More...
 
char ** iListCopyS (char **list, int64_t start, int64_t end) MUST_CHECK
 list Copy String return new list with element pointers from start and end in list negative indexes are allowed More...
 
char ** iListSliceS (char ***list, int64_t start, int64_t end) MUST_CHECK
 list Slice String return list with elements from start and end in list negative indexes are allowed More...
 
char ** listCropS (char **list, int64_t start, int64_t end) MUST_CHECK
 list Crop String return a new list with elements from start and end in list and delete elements from start to end in the original list negative indexes are allowed More...
 
char ** iListCropS (char ***list, int64_t start, int64_t end) MUST_CHECK
 list Crop String return a new list with elements from start and end in list and delete elements from start to end in the original list negative indexes are allowed More...
 
char * listCropElemS (char **list, int64_t index) MUST_CHECK
 list Crop Element String return element at index and delete element at index in the original list negative indexes are allowed More...
 
char * iListCropElemS (char ***list, int64_t index) MUST_CHECK
 list Crop Element String return element at index and delete element at index in the original list negative indexes are allowed More...
 
char ** listInsertS (char **list, int64_t index, char **toInsert) MUST_CHECK
 list Insert string More...
 
char ** iListInsertS (char ***list, int64_t index, char **toInsert) MUST_CHECK
 list Insert string More...
 
char ** iListInsertNFreeS (char ***list, int64_t index, char **toInsert) MUST_CHECK
 list Insert string and free toInsert More...
 
char ** listInjectS (char **list, int64_t index, char *toInject) MUST_CHECK
 list Inject string More...
 
char ** listInjectCharS (char **list, int64_t index, char toInject) MUST_CHECK
 
char ** iListInjectS (char ***list, int64_t index, char *toInject) MUST_CHECK
 list Inject string More...
 
char ** iListInjectCharS (char ***list, int64_t index, char toInject) MUST_CHECK
 
char ** listDelS (char **list, int64_t start, int64_t end) MUST_CHECK
 list Delete String return new list without elements from start and end in list negative indexes are allowed More...
 
char ** iListDelS (char ***list, int64_t start, int64_t end) MUST_CHECK
 list Delete String return list without elements from start and end in list negative indexes are allowed More...
 
char ** iListRemoveS (char ***list, int64_t start, int64_t end)
 list Remove String return list without elements from start and end in list the elements are removed without being freed negative indexes are allowed More...
 
char ** listDelElemS (char **list, int64_t index) MUST_CHECK
 list Delete Element String return new list without the element at index negative indexes are allowed More...
 
char ** iListDelElemS (char ***list, int64_t index) MUST_CHECK
 list Delete Element String return list without the element at index negative indexes are allowed More...
 
char ** iListRemoveElemS (char ***list, int64_t index) MUST_CHECK
 list Remove Element String return list without the element at index the element is removed without being freed negative indexes are allowed More...
 
int listPrintS (char **list) MUST_CHECK
 print list elements to stdout More...
 
int listPrintCS (const char **list) MUST_CHECK
 
char ** listSortS (char **list) MUST_CHECK
 list Sort String duplicate list and sort More...
 
char ** iListSortS (char ***list) MUST_CHECK
 list Sort String More...
 
char ** listSortFS (char **list, shCmpt compareFunction) MUST_CHECK
 list Sort String duplicate list and sort More...
 
char ** iListSortFS (char ***list, shCmpt compareFunction) MUST_CHECK
 list Sort String More...
 
char ** icListSortS (char **list) MUST_CHECK
 ignore case list Sort String duplicate list and sort More...
 
char ** iicListSortS (char ***list) MUST_CHECK
 ignore case list Sort String More...
 
char ** readText (const char *filePath) MUST_CHECK
 return text from filePath in a list new line characters are removed More...
 
char ** readStream (FILE *fp) MUST_CHECK
 return text from stream fp in a list new line characters are removed More...
 
bool writeText (const char *filePath, char **list) MUST_CHECK
 write list to filePath More...
 
bool writeCText (const char *filePath, const char **list) MUST_CHECK
 write const list to filePath More...
 
bool writeStream (FILE *fp, char **list) MUST_CHECK
 write list to stream More...
 
bool writeCStream (FILE *fp, const char **list) MUST_CHECK
 write const list to stream More...
 
bool appendText (const char *filePath, char **list) MUST_CHECK
 append list to filePath More...
 
bool appendCText (const char *filePath, const char **list) MUST_CHECK
 append const list to filePath More...
 
char ** execOut (const char *cmd) MUST_CHECK
 execute command return stdout from cmd More...
 
char ** systemOutf (const char *fmt,...) MUST_CHECK
 execute system command with formatting More...
 
int systemf (const char *fmt,...) MUST_CHECK
 execute system command with formatting More...
 
int commandF (const char *cmd, int line, const char *thisFunc, const char *thisFileName) MUST_CHECK
 run command in default shell More...
 
int commandfF (int line, const char *thisFunc, const char *thisFileName, const char *fmt,...) MUST_CHECK
 run command with formatting in default shell More...
 
int commandNFreeF (char *cmd, int line, const char *thisFunc, const char *thisFileName) MUST_CHECK
 run command in default shell and free the cmd parameter More...
 
bool listEqS (char **list1, char **list2) MUST_CHECK
 list Equal String compare each element of list1 and list2 More...
 
bool listEqCS (char **list1, const char **list2) MUST_CHECK
 const(list2) list Equal String compare each element of list1 and list2 More...
 
bool listEqC1S (const char **list1, char **list2) MUST_CHECK
 const(list1) list Equal String compare each element of list1 and list2 More...
 
bool listEqCCS (const char **list1, const char **list2) MUST_CHECK
 const(list1 and 2) list Equal String compare each element of list1 and list2 More...
 
bool listHasS (char **list, const char *string) MUST_CHECK
 return true when list has string More...
 
bool listHasCS (const char **list, const char *string) MUST_CHECK
 return true when const list has string More...
 
bool listHasCharS (char **list, char c) MUST_CHECK
 
bool listHasCharCS (const char **list, char c) MUST_CHECK
 
ssize_t listIndexOfS (char **list, const char *string) MUST_CHECK
 return index of string in list More...
 
ssize_t listIndexOfCS (const char **list, const char *string) MUST_CHECK
 return index of string in const list More...
 
ssize_t listIndexOfCharS (char **list, char c) MUST_CHECK
 
ssize_t listIndexOfCharCS (const char **list, char c) MUST_CHECK
 
ssize_t listBinarySearchS (char **list, const char *string) MUST_CHECK
 list binary search string More...
 
ssize_t listBinarySearchCharS (char **list, char c) MUST_CHECK
 
char ** listUniqS (char **list) MUST_CHECK
 Uniquify elements of list duplicate list each elements are unique in the new list. More...
 
char ** iListUniqS (char ***list) MUST_CHECK
 Uniquify elements of list each elements are unique in the list. More...
 
bool icListEqS (char **list1, char **list2) MUST_CHECK
 ignore case list Equal String compare each element of list1 and list2 More...
 
bool icListEqCS (char **list1, const char **list2) MUST_CHECK
 ignore case const(list2) list Equal String compare each element of list1 and list2 More...
 
bool icListEqC1S (const char **list1, char **list2) MUST_CHECK
 ignore case const(list1) list Equal String compare each element of list1 and list2 More...
 
bool icListEqCCS (const char **list1, const char **list2) MUST_CHECK
 ignore case const(list1 and 2) list Equal String compare each element of list1 and list2 More...
 
bool icListHasS (char **list, const char *string) MUST_CHECK
 ignore case and return true when list has string More...
 
bool icListHasCharS (char **list, char c) MUST_CHECK
 
bool icListHasCS (const char **list, const char *string) MUST_CHECK
 ignore case and return true when const list has string More...
 
bool icListHasCharCS (const char **list, char c) MUST_CHECK
 
ssize_t icListIndexOfS (char **list, const char *string) MUST_CHECK
 ignore case and return index of string in list More...
 
ssize_t icListIndexOfCS (const char **list, const char *string) MUST_CHECK
 ignore case and return index of string in const list More...
 
ssize_t icListIndexOfCharS (char **list, char c) MUST_CHECK
 
ssize_t icListIndexOfCharCS (const char **list, char c) MUST_CHECK
 
ssize_t icListBinarySearchS (char **list, const char *string) MUST_CHECK
 ignore case list binary search string More...
 
ssize_t icListBinarySearchCharS (char **list, char c) MUST_CHECK
 
char ** icListUniqS (char **list) MUST_CHECK
 ignore case and uniquify elements of list duplicate list each elements are unique in the new list More...
 
char ** iicListUniqS (char ***list) MUST_CHECK
 ignore case and uniquify elements of list each elements are unique in the list More...
 
char ** listCompactS (char **list) MUST_CHECK
 remove empty strings from list More...
 
char ** iListCompactS (char ***list) MUST_CHECK
 remove empty strings from list More...
 
void btraceEnable (void)
 
void btraceDisable (void)
 
bool btraceConfig (void) MUST_CHECK
 
char ** btrace (void)
 generate backtrace the program has to be linked the -rdynamic option for btrace to work btrace can backtrace 50 functions at most. More...
 
void ** listEmptyF (void) MUST_CHECK
 list Empty Function More...
 
void ** iListEmptyF (void ***list) MUST_CHECK
 list Empty Function More...
 
bool listIsEmpty (void **list) MUST_CHECK
 list Is Empty More...
 
void ** listCreateF (void *paramType,...) MUST_CHECK
 list Create Function create a list from the list of parameters used from the listCreate(...) macro More...
 
void ** listFromArray (void **array, size_t size) MUST_CHECK
 list From Array More...
 
void ** listPush (void ***list, void *s) MUST_CHECK
 list Push More...
 
void * listPop (void ***list) MUST_CHECK
 list Pop return last element from list and remove last element from the list More...
 
void ** listPrepend (void ***list, void *s) MUST_CHECK
 list Prepend More...
 
void * listDequeue (void ***list) MUST_CHECK
 list Dequeue return first element from list and remove last element from the list More...
 
void listFree (void **list)
 list Free More...
 
void listFreeManyF (void **paramType,...)
 list free many More...
 
size_t listLength (void **list) MUST_CHECK
 list Length return number of elements until the first NULL element More...
 
void * listGet (void **list, int64_t index) MUST_CHECK
 list Get More...
 
void ** listSet (void **list, int64_t index, void *s) MUST_CHECK
 list Set More...
 
void ** listDup (void **list) MUST_CHECK
 list Duplicate More...
 
void ** listReverse (void **list) MUST_CHECK
 list Reverse create index list and reverse list, the last element is the first element of the new list More...
 
void ** iListReverse (void ***list) MUST_CHECK
 list Reverse reverse list, the last element is the first element of the list More...
 
void ** listCatF (void **paramType,...) MUST_CHECK
 list Cat More...
 
void ** listAppend (void ***list1, void **list2) MUST_CHECK
 list Append More...
 
void ** listAdd (void **list1, void **list2) MUST_CHECK
 list Add add list1 and list2 in a new list More...
 
void ** listSlice (void **list, int64_t start, int64_t end) MUST_CHECK
 list Slice More...
 
void ** iListSlice (void ***list, int64_t start, int64_t end) MUST_CHECK
 list Slice return list with elements from start and end in list negative indexes are allowed More...
 
void ** listInsert (void **list, int64_t index, void **toInsert) MUST_CHECK
 list Insert More...
 
void ** iListInsert (void ***list, int64_t index, void **toInsert) MUST_CHECK
 list Insert More...
 
void ** listDel (void **list, int64_t start, int64_t end) MUST_CHECK
 list Delete return new list without elements from start and end in list negative indexes are allowed More...
 
void ** iListDel (void ***list, int64_t start, int64_t end) MUST_CHECK
 list Delete return list without elements from start and end in list negative indexes are allowed More...
 
int ringInit (void *ring, int maxCount)
 list Sort duplicate list and sort More...
 
int ringEmpty (void *ring)
 empty ring Allocated buffers in the list must be freed before running staticArrayEmpty More...
 
int ringIsEmpty (void *ring)
 1 when empty 0 not empty -1 error More...
 
int ringIsFull (void *ring)
 1 when full 0 not full -1 error More...
 
ssize_t ringCount (void *ring)
 return elements count More...
 
i64 ringPush (void *ring)
 push element to ring (only increases last, use ringSend) use ringLast to access the element More...
 
int ringPop (void *ring)
 pop element from ring (only decreases last) More...
 
i64 ringPrepend (void *ring)
 prepend element to ring (only decreases head) use ringFirst to access the element More...
 
int ringDequeue (void *ring)
 dequeue element from ring (only increases head, use ringRecv) More...
 
void scheduler (void)
 fiber usage More...
 
 staticArrayT (fiberLT, int, tCount)
 staticArray to hold the fiber slots More...
 
bool fiberAdd (void *ctx, int thisSlot, fiberFT func)
 add new fiber More...
 
bool fiberPrepend (void *ctx, int thisSlot, fiberFT func)
 add new fiber and start immediately after next yield More...
 
uint64_t getMonotonicTime (void) MUST_CHECK
 end bitfield More...
 
int nanoSleepF (uint64_t time) MUST_CHECK
 nanosleep More...
 

Variables

const bool TRUE
 type bool true (glibc true is not bool), for use in generics More...
 
const bool FALSE
 type bool false (glibc true is not bool), for use in generics More...
 
jmp_buf tryJumpBuffers [maxTryThrowCount]
 setjmp buffers for try/throw,throwV macros More...
 
uint64_t logMask
 variable to control which group logs to show, all logs are enabled by default (0xFFFFFFFFFFFFFFFF) More...
 
const uint8_t codeSzUTF8 [256]
 
bool btraceCfg
 backtrace in error messages is enabled by default More...
 
fibersT fibers
 data for fiber system More...
 

Detailed Description

This file has basic file, random, string, list functions.

There are 2 types of lists: char** and void**

The *S (not i*S) functions duplicate the parameters and results. You must free the result if result is non-NULL and free the parameters

The functions starting with i*S are in place functions.

In Place functions: iList*S and i*S The iList*S and i*S functions modify the input buffers The input buffers must be allocated with malloc/calloc Returns are pointers to original buffers

buffer functions: b*, bL* In these functions, the destination buffer is allocated by the caller In the bL* functions, the destination size is the size of the buffer (strlen+1)

Ignore case functions: ic*

UTF-8 functions: *UTF8 Rune is defined as single UTF-8 code point.

libsheepy.h also has:

It is advised to use the C11 generics from libsheepyObject.h instead of the libsheepy.h functions directly because there are many functions.

If you want to add a prefix for libsheepy functions, define a macro like this: #define SH_PREFIX(NAME) MY_PREFIX ## NAME

Error from any function returning a status have 0, false or NULL for value (or specifed otherwise in the function description). Errors are reported when the parameters are NULL or invalid, when it happens no parameters and no data stuctures are freed or changed. Errors are detected with if (!func)

For more information, the documentation is located at http://spartatek.se/libsheepy/

Definition in file libsheepy.h.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 29 of file libsheepy.h.

◆ LIBSHEEPY_VERSION

#define LIBSHEEPY_VERSION   "2.2.12.1"

Definition at line 101 of file libsheepy.h.

◆ SH_PREFIX

#define SH_PREFIX (   NAME)    NAME

Definition at line 104 of file libsheepy.h.

◆ internal

#define internal   static

file internal declarations

Definition at line 110 of file libsheepy.h.

◆ local

#define local   static

file local declarations (same as internal, shorter word)

Definition at line 113 of file libsheepy.h.

◆ var

#define var   __auto_type

declare variable type automaticaly: var a = ARGC;

Definition at line 116 of file libsheepy.h.

◆ null

#define null   NULL

convenience defines

Definition at line 126 of file libsheepy.h.

◆ yes

#define yes   true

Definition at line 127 of file libsheepy.h.

◆ on

#define on   true

Definition at line 128 of file libsheepy.h.

◆ no

#define no   false

Definition at line 129 of file libsheepy.h.

◆ off

#define off   false

Definition at line 130 of file libsheepy.h.

◆ boolS

#define boolS (   x)    x ? "TRUE" : "FALSE"

bool to const string: printf("%s\n", boolS(boolValue));

Definition at line 133 of file libsheepy.h.

◆ XSUCCESS

#define XSUCCESS   exit(EXIT_SUCCESS);

success

Definition at line 138 of file libsheepy.h.

◆ XSuccess

#define XSuccess   XSUCCESS

Definition at line 139 of file libsheepy.h.

◆ XFAILURE

#define XFAILURE   exit(EXIT_FAILURE);

failure

Definition at line 144 of file libsheepy.h.

◆ XFailure

#define XFailure   XFAILURE

Definition at line 145 of file libsheepy.h.

◆ logXSuccess

#define logXSuccess (   string)
Value:
logP("Success: %s", string);\
XSuccess;\
)
#define logP(...)
Definition: libsheepy.h:1063
#define MACRO(STATEMENTS)
do while(0) alternative macro definition
Definition: libsheepy.h:243

log string with logP and exit with success

This is useful to know at which line a program exits

Definition at line 152 of file libsheepy.h.

◆ logXSuccessf

#define logXSuccessf (   format,
  ... 
)
Value:
logP(format, __VA_ARGS__);\
XSuccess;\
)
#define logP(...)
Definition: libsheepy.h:1063
#define MACRO(STATEMENTS)
do while(0) alternative macro definition
Definition: libsheepy.h:243

log formated string with logP and exit with success

This is useful to know at which line a program exits The format string is printed as given, "Success" is not added unlike logXSuccess

Definition at line 164 of file libsheepy.h.

◆ logXFailure

#define logXFailure (   string)
Value:
logC("Failed: %s", string);\
XFailure;\
)
#define MACRO(STATEMENTS)
do while(0) alternative macro definition
Definition: libsheepy.h:243
#define logC(...)
Definition: libsheepy.h:1059
  • * log string with logC and exit with failure

    This is useful to know at which line a program exits

Definition at line 174 of file libsheepy.h.

◆ logXFailuref

#define logXFailuref (   format,
  ... 
)
Value:
logC(format, __VA_ARGS__);\
XFailure;\
)
#define MACRO(STATEMENTS)
do while(0) alternative macro definition
Definition: libsheepy.h:243
#define logC(...)
Definition: libsheepy.h:1059

log formated string with logC and exit with failure

This is useful to know at which line a program exits The format string is printed as given, "Failed" is not added unlike logXFailure

Definition at line 186 of file libsheepy.h.

◆ logExit

#define logExit (   exitCode,
  string 
)
Value:
logI("Exit: %s", string);\
exit(exitCode);\
)
#define logI(...)
Definition: libsheepy.h:1064
#define MACRO(STATEMENTS)
do while(0) alternative macro definition
Definition: libsheepy.h:243

log string with logI and exit with exitCode

This is useful to know at which line a program exits

Definition at line 196 of file libsheepy.h.

◆ exitFailure

#define exitFailure (   cond)
Value:
if (!cond) \
exit(EXIT_FAILURE);

exit failure

Exits when cond is false

Definition at line 206 of file libsheepy.h.

◆ procbegin

#define procbegin   do{

defines for macro begin and end

Macros not returning values are usually written as do while loops: #define macro(value) do{ puts(value); } while(0)

Using the defines below: #define macro(value) procbegin\ puts(value);\ procend

procbegin and procend are for macros not returning a value (like procedure in pascal) funcbegin and funcend are for macros returning a value like functions

Macro returning a value (GNU extension): #define macro(value) funcbegin\ int returnResult = value + 2;\ returnResult;\ funcend

Definition at line 233 of file libsheepy.h.

◆ procend

#define procend   }while(0)

Definition at line 234 of file libsheepy.h.

◆ funcbegin

#define funcbegin   ({

Definition at line 235 of file libsheepy.h.

◆ funcend

#define funcend   })

Definition at line 236 of file libsheepy.h.

◆ MACRO

#define MACRO (   STATEMENTS)    do { STATEMENTS } while(0)

do while(0) alternative macro definition

#define macro(param) MACRO( logVarG(param) )

Definition at line 243 of file libsheepy.h.

◆ FUNC

#define FUNC (   STATEMENTS)    ({ STATEMENTS })

Macro returning a value (GNU extension): #define macro(value) FUNC(\ int returnResult = value + 2;\ returnResult;\ )

Definition at line 253 of file libsheepy.h.

◆ is

#define is   =

additions to iso646 int a is 0; if (a equals 1 or a equals 2) a shl = 2; else a inc; return ptr_to a;

int *b is val_of b is a; val_of b dec;

Definition at line 265 of file libsheepy.h.

◆ equals

#define equals   ==

Definition at line 266 of file libsheepy.h.

◆ nequal

#define nequal   !=

Definition at line 267 of file libsheepy.h.

◆ shr

#define shr   >>

Definition at line 268 of file libsheepy.h.

◆ shl

#define shl   <<

Definition at line 269 of file libsheepy.h.

◆ inc

#define inc   ++

Definition at line 270 of file libsheepy.h.

◆ dec

#define dec   --

Definition at line 271 of file libsheepy.h.

◆ ptr_to

#define ptr_to   &

Definition at line 272 of file libsheepy.h.

◆ val_of

#define val_of   *

Definition at line 273 of file libsheepy.h.

◆ stringifyExpr

#define stringifyExpr (   expr)    stringifyExpr1(expr)

stringify Expression - Turn expression into a string literal

Example: #define PRINT_COND_IF_FALSE(cond) \ ((cond) || printf("%s is false!", stringifyExpr(cond)))

Definition at line 282 of file libsheepy.h.

◆ stringifyExpr1

#define stringifyExpr1 (   expr)    #expr

Definition at line 284 of file libsheepy.h.

◆ libsheepyErrorMask

#define libsheepyErrorMask   0x8000000000000000UL

Definition at line 291 of file libsheepy.h.

◆ disableLibsheepyErrorLogs

#define disableLibsheepyErrorLogs   do{logMask &= (~libsheepyErrorMask);}while(0)

Definition at line 293 of file libsheepy.h.

◆ shperror

#define shperror (   string)
Value:
procbegin\
char *errstr = strerror(errno);\
logE("%s: %s", string, errstr);\
procend

Definition at line 295 of file libsheepy.h.

◆ pFuncError

#define pFuncError   do{ if ((libsheepyErrorMask) & logMask) { shperror(__func__);logEBtrace;} }while(0);

print function name and system error

to print error, use either pFuncError and shEPrintfS or shPrintError and shEPrintfS

Definition at line 306 of file libsheepy.h.

◆ pStrError

#define pStrError (   str)    do{ if ((libsheepyErrorMask) & logMask) { shperror(str);logEBtrace;} }while(0);

print string and system error

Definition at line 311 of file libsheepy.h.

◆ shPrintError

#define shPrintError   do{ if ((libsheepyErrorMask) & logMask) { logE("Error line "stringifyExpr(__LINE__)", function %s, file "__FILE__"\n", __func__); logEBtrace;} }while(0);

print error with line number, function name and file name to stderr

to print error, use either pFuncError and shEPrintfS or shPrintError and shEPrintfS

Definition at line 319 of file libsheepy.h.

◆ pError

#define pError (   func)    if (func == -1) shPrintError

print error when function failed.

The error code must be -1

Definition at line 324 of file libsheepy.h.

◆ pError0

#define pError0 (   func)    if (func == 0) shPrintError

print error when function failed.

The error code must be 0

Definition at line 329 of file libsheepy.h.

◆ pErrorNot0

#define pErrorNot0 (   func)    if (func != 0) shPrintError

print error when function failed.

The error code must be not 0

Definition at line 334 of file libsheepy.h.

◆ pErrorNULL

#define pErrorNULL (   func)    if (func == NULL) shPrintError

print error when function failed.

The error code must be NULL

Definition at line 339 of file libsheepy.h.

◆ pErrorValue

#define pErrorValue (   func,
  errorValue 
)    if (func == errorValue) shPrintError

print error when function failed.

The error code must be -1

Definition at line 344 of file libsheepy.h.

◆ pTestError

#define pTestError (   test)    if (test) shPrintError

print error when test is true

Definition at line 349 of file libsheepy.h.

◆ pTestErrorCmd

#define pTestErrorCmd (   test,
  cmd 
)    if (test) { shPrintError cmd; }

print error and run command when test is true

Definition at line 354 of file libsheepy.h.

◆ pErrorCmd

#define pErrorCmd (   func,
  test,
  cmd 
)    if (func test) { shPrintError cmd; }

print error and run cmd when test is true

Definition at line 359 of file libsheepy.h.

◆ pErrorResult

#define pErrorResult (   result,
  func,
  test 
)    if ((result = func) test) shPrintError

print error when test is true and return func result in result

Example: pErrorResult(k, randomWordF(), == 0)

Definition at line 367 of file libsheepy.h.

◆ pErrorResultCmd

#define pErrorResultCmd (   result,
  func,
  test,
  cmd 
)    if ((result = func) test) { shPrintError cmd; }

print error and run cmd when test is true and return func result in result

Example: pErrorResultCmd(k, randomWordF(), == 0, XFAILURE)

Definition at line 375 of file libsheepy.h.

◆ isError

#define isError (   assigned,
  left 
)    if (!(assigned = left))

is Assigment Error catch error when assigned is false, 0 or NULL after being assigned with left

Example: isError(r, malloc(16384)) { return 0; }

Definition at line 386 of file libsheepy.h.

◆ maxTryThrowCount

#define maxTryThrowCount   16

setjmp buffers for try/throw,throwV macros

Definition at line 391 of file libsheepy.h.

◆ setJump

#define setJump (   slot)    setjmp(tryJumpBuffers[slot])

run setjmp using slot in tryJumpBuffers

Definition at line 397 of file libsheepy.h.

◆ try

#define try (   slot)    if (!setjmp(tryJumpBuffers[slot]))

try throw else try(slot) saves the environment in slot throw(slot) executes the else associated with try(slot)

there are 16 slots

Example: try(0) { throw(0); } else puts("except");

Definition at line 414 of file libsheepy.h.

◆ throw

#define throw (   slot)    longjmp(tryJumpBuffers[slot], 1)

throw goes to else associated with try(slot)

Definition at line 419 of file libsheepy.h.

◆ tryV

#define tryV (   result,
  slot 
)    if (!(result = setjmp(tryJumpBuffers[slot])))

tryV stores the value from setjmp in result

it is valid to try with throwV and tryV with throw (returns 1)

Example:

Definition at line 428 of file libsheepy.h.

◆ throwV

#define throwV (   slot,
  value 
)    longjmp(tryJumpBuffers[slot], value)

throwV returns value and goes to else associated with tryV(slot)

Definition at line 433 of file libsheepy.h.

◆ goNLabel

#define goNLabel (   go,
  label 
)    goto go; label:

Definition at line 436 of file libsheepy.h.

◆ i8

#define i8   int8_t

types

Definition at line 441 of file libsheepy.h.

◆ i16

#define i16   int16_t

Definition at line 442 of file libsheepy.h.

◆ i32

#define i32   int32_t

Definition at line 443 of file libsheepy.h.

◆ i64

#define i64   int64_t

Definition at line 444 of file libsheepy.h.

◆ u8

#define u8   uint8_t

Definition at line 445 of file libsheepy.h.

◆ u16

#define u16   uint16_t

Definition at line 446 of file libsheepy.h.

◆ u32

#define u32   uint32_t

Definition at line 447 of file libsheepy.h.

◆ u64

#define u64   uint64_t

Definition at line 448 of file libsheepy.h.

◆ f32

#define f32   float

Definition at line 449 of file libsheepy.h.

◆ f64

#define f64   double

Definition at line 450 of file libsheepy.h.

◆ I8

#define I8 (   value)    (i8)(value)

type cast

Definition at line 455 of file libsheepy.h.

◆ I16

#define I16 (   value)    (i16)(value)

Definition at line 456 of file libsheepy.h.

◆ I32

#define I32 (   value)    (i32)(value)

Definition at line 457 of file libsheepy.h.

◆ I64

#define I64 (   value)    (i64)(value)

Definition at line 458 of file libsheepy.h.

◆ U8

#define U8 (   value)    (u8)(value)

Definition at line 459 of file libsheepy.h.

◆ U16

#define U16 (   value)    (u16)(value)

Definition at line 460 of file libsheepy.h.

◆ U32

#define U32 (   value)    (u32)(value)

Definition at line 461 of file libsheepy.h.

◆ U64

#define U64 (   value)    (u64)(value)

Definition at line 462 of file libsheepy.h.

◆ F32

#define F32 (   value)    (f32)(value)

Definition at line 463 of file libsheepy.h.

◆ F64

#define F64 (   value)    (f64)(value)

Definition at line 464 of file libsheepy.h.

◆ MAX

#define MAX (   a,
  b 
)    (((a) > (b)) ? (a) : (b))

Definition at line 466 of file libsheepy.h.

◆ MIN

#define MIN (   a,
  b 
)    (((a) < (b)) ? (a) : (b))

Definition at line 467 of file libsheepy.h.

◆ MIN3

#define MIN3 (   a,
  b,
  c 
)    MIN((typeof(a))MIN(a, b), c)

Definition at line 468 of file libsheepy.h.

◆ MAX3

#define MAX3 (   a,
  b,
  c 
)    MAX((typeof(a))MAX(a, b), c)

Definition at line 469 of file libsheepy.h.

◆ ABS

#define ABS (   a)    (((a) < 0) ? -(a) : (a))

Definition at line 470 of file libsheepy.h.

◆ CLAMP

#define CLAMP (   x,
  low,
  high 
)    (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))

Definition at line 471 of file libsheepy.h.

◆ COUNT_ELEMENTS

#define COUNT_ELEMENTS (   arr)    (sizeof (arr) / sizeof ((arr)[0]))

Definition at line 472 of file libsheepy.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE   COUNT_ELEMENTS

Definition at line 473 of file libsheepy.h.

◆ EXTRACT

#define EXTRACT (   x,
  msb,
  lsb 
)    ((~(0xFFFFFFFFFFFFFFFEUL << (msb)) & (x)) >> (lsb))

get a bitfield in an integer (opposite of FIELD_SET)

Definition at line 478 of file libsheepy.h.

◆ CMP

#define CMP (   a,
  b 
)
Value:
({\
var UNIQVAR(_a) = a;\
var UNIQVAR(_b) = b;\
UNIQVAR(_a) > UNIQVAR(_b) ? 1 : UNIQVAR(_a) < UNIQVAR(_b) ? -1 : 0;\
})
baset * b
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

compare a to b a and b have to numbers

Returns
0 when a equals b -1 when a is less than b 1 when a is more than b

Definition at line 489 of file libsheepy.h.

◆ init0Var

#define init0Var   {0}

initialize array or struct to zero

int a[10] = init0Var; struct {} s = init0Var;

Definition at line 501 of file libsheepy.h.

◆ ZEROVAR

#define ZEROVAR (   name)    zeroBuf(&(name), sizeof(name))

memset array or struct to zero

Definition at line 506 of file libsheepy.h.

◆ BUCKETS

#define BUCKETS (   count,
  divider 
)    ((count)/(divider) + (((count) % (divider)) ? 1 : 0))

divide count by divider and add one when remainder is not zero this is used in segmented arrays to count the number of buckets from the element count

For example, bucket have 64 elements and there are 66 elements in the array 66/64 = 1 and there are 2 buckets, so BUCKETS returns 2

could be: (((count) + (1UL<<(divider) -1))/ (divider))

Definition at line 519 of file libsheepy.h.

◆ swapV

#define swapV (   a,
  b 
)
Value:
do{\
var UNIQVAR(swaptmp) = a;\
a = b;\
b = UNIQVAR(swaptmp);\
} while(0)
baset * b
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

swap a and b, a and b should have the same type

Definition at line 524 of file libsheepy.h.

◆ setMax

#define setMax (   result,
  a,
  b 
)
Value:
do{\
var UNIQVAR(_a) = a;\
var UNIQVAR(_b) = b;\
result = MAX(UNIQVAR(_a), UNIQVAR(_b));\
} while(0)
baset * b
#define MAX(a, b)
Definition: libsheepy.h:466
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

max a,b and store result in result, a and b are evaluated only once

Definition at line 531 of file libsheepy.h.

◆ setMin

#define setMin (   result,
  a,
  b 
)
Value:
do{\
var UNIQVAR(_a) = a;\
var UNIQVAR(_b) = b;\
result = MIN(UNIQVAR(_a), UNIQVAR(_b));\
} while(0)
#define MIN(a, b)
Definition: libsheepy.h:467
baset * b
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

min a,b and store result in result, a and b are evaluated only once

Definition at line 538 of file libsheepy.h.

◆ maxV

#define maxV (   a,
  b 
)
Value:
({\
var UNIQVAR(_a) = a;\
var UNIQVAR(_b) = b;\
MAX(UNIQVAR(_a), UNIQVAR(_b));\
})
baset * b
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

max a,b and return result, a and b are evaluated only once

Definition at line 545 of file libsheepy.h.

◆ minV

#define minV (   a,
  b 
)
Value:
({\
var UNIQVAR(_a) = a;\
var UNIQVAR(_b) = b;\
MIN(UNIQVAR(_a), UNIQVAR(_b));\
})
baset * b
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

min a,b and return result, a and b are evaluated only once

Definition at line 552 of file libsheepy.h.

◆ absV

#define absV (   a)    ({var UNIQVAR(_a) = a; ((UNIQVAR(_a)) < 0) ? -(UNIQVAR(_a)) : (UNIQVAR(_a));})

absV return absolute value for a, a is evaluated only once

Definition at line 559 of file libsheepy.h.

◆ FIELD_SIZEOF

#define FIELD_SIZEOF (   t,
 
)    (sizeof(((t*)0)->f))

FIELD_SIZEOF - get the size of a struct's field : the target struct : the target struct's field Return: the size of in the struct definition without having a declared instance of .

Definition at line 568 of file libsheepy.h.

◆ isIntOdd

#define isIntOdd (   value)    (value&1)

true when value is odd integer

Definition at line 571 of file libsheepy.h.

◆ isIntEven

#define isIntEven (   value)    (!(value&1))

true when value is even integer

Definition at line 574 of file libsheepy.h.

◆ typ

#define typ   typedef

typ definition as alternative to typedef

Definition at line 579 of file libsheepy.h.

◆ ret

#define ret   return

ret definition as alternative to return

Definition at line 584 of file libsheepy.h.

◆ elif

#define elif   else if

elif definition as alternative to else if

Definition at line 589 of file libsheepy.h.

◆ unless

#define unless (   cond)    if(not(cond))

unless executes the statement unless the condition is true (that is, if the condition is false).

Example: unless(isPath("/void")) { put("the '/void' directory doesn't exist."); }

Definition at line 599 of file libsheepy.h.

◆ until

#define until (   cond)    while(not(cond))

until repeats the statement until the condition is true (or while the condition is false)

Example: i16 i = 0; do { i++; logVarG(i); } until(i == 3);

Definition at line 611 of file libsheepy.h.

◆ cast

#define cast (   type,
  casted,
  toCast 
)    type casted = (type) (toCast);

define variable and cast pointer

Definition at line 617 of file libsheepy.h.

◆ freen

#define freen (   ptr)
Value:
do {\
free(ptr);\
(ptr) = NULL;\
} while(0)

free pointer and set it to NULL

Definition at line 622 of file libsheepy.h.

◆ EVA

#define EVA (   var,
  func 
)    (var = func, var)

Evaluate and assign Evaluate, assign result from func and return result using the comma operator.

Example: save pointer returned by a function in a function parameter: void *p; func2( EVA(p,func1()) ); free(p);

Using libsheepy functions: char *s; puts( EVA(s, normalizePath("/wef/./../")) ); free(s);

Definition at line 642 of file libsheepy.h.

◆ loopBreakerInit

#define loopBreakerInit
Value:
uint32_t libsheepyLoopCounter = 0;\
bool didBreak = false;

initialize the loop breaker declares loop breaker variables

Example:

loopBreakerInit; forever { loopBreaker(20); } if (didBreak) logE("infinite loop detected"); loopBreakerReset; forever { loopBreaker(100); } if (didBreak) logE("infinite loop detected");

Definition at line 661 of file libsheepy.h.

◆ loopBreakerReset

#define loopBreakerReset
Value:
libsheepyLoopCounter = 0;\
didBreak = false;

reset the loop breaker variables

Definition at line 668 of file libsheepy.h.

◆ loopBreaker

#define loopBreaker (   breakCount)
Value:
libsheepyLoopCounter++;\
if(libsheepyLoopCounter>breakCount){didBreak=true;break;}

break the loop when the counter exceed breakCount

Definition at line 675 of file libsheepy.h.

◆ FILE_LINE

#define FILE_LINE   __FILE__":"stringifyExpr(__LINE__)

generate a string FILE:LINE number

Example: puts(FILE_LINE);

Definition at line 684 of file libsheepy.h.

◆ PFILE_LINE

#define PFILE_LINE   puts(FILE_LINE)

Definition at line 685 of file libsheepy.h.

◆ AT

#define AT   pLog(LOG_DEBUG, __FILE__", %s:"stringifyExpr(__LINE__)"\n",__func__);

print file, function name and line

Example: AT; libsheepy.c, main:9149

Definition at line 694 of file libsheepy.h.

◆ TODO

#define TODO (   message)    logD(BLD MGT BGBLK"TODO"RST BLD MGT": "message RST)

print a todo message in log

Definition at line 699 of file libsheepy.h.

◆ TOKENPASTE2

#define TOKENPASTE2 (   a,
  b 
)    a ## b

Definition at line 703 of file libsheepy.h.

◆ TOKENPASTE

#define TOKENPASTE (   a,
  b 
)    TOKENPASTE2(a, b)

Definition at line 704 of file libsheepy.h.

◆ UNIQVAR

#define UNIQVAR (   name)    TOKENPASTE(name, __LINE__)

Definition at line 705 of file libsheepy.h.

◆ cleanCharP

#define cleanCharP (   name)    char *name CLEANUP(cleanUpCharFree)

declare pointer name with type char* and free name when it is out of scope

Definition at line 714 of file libsheepy.h.

◆ cleanListP

#define cleanListP (   name)    char **name CLEANUP(cleanUpListFree)

declare pointer name with type char* and free name when it is out of scope

Definition at line 722 of file libsheepy.h.

◆ cleanFileP

#define cleanFileP (   name)    FILE *name CLEANUP(cleanUpFileFree)

declare pointer name with type FILE and free (close) name when it is out of scope

Definition at line 730 of file libsheepy.h.

◆ cleanFd

#define cleanFd (   name)    int name CLEANUP(cleanUpFd)

declare a file descriptor name and close name when it is out of scope

Definition at line 738 of file libsheepy.h.

◆ cleanFdInit

#define cleanFdInit (   name)    int name CLEANUP(cleanUpFd) = -1

Definition at line 739 of file libsheepy.h.

◆ logVar

#define logVar (   var,
  format 
)    logD("%s=%" format, stringifyExpr(var), var);

log variable and its value

Example: logVar(k, PRIu64) k=14

Definition at line 748 of file libsheepy.h.

◆ logMVar

#define logMVar (   mask,
  var,
  format 
)    logMD(mask, "%s=%" format, stringifyExpr(var), var);

Definition at line 749 of file libsheepy.h.

◆ logBoolVar

#define logBoolVar (   var)    logVar(var, "b");

log bool variable

Definition at line 752 of file libsheepy.h.

◆ logMBoolVar

#define logMBoolVar (   mask,
  var 
)    logMVar(mask, var, "b");

Definition at line 753 of file libsheepy.h.

◆ logPtr

#define logPtr (   pointer)    logD("%s=%p", stringifyExpr(pointer), pointer);

log pointer

Definition at line 758 of file libsheepy.h.

◆ logMPtr

#define logMPtr (   mask,
  pointer 
)    logMD(mask, "%s=%p", stringifyExpr(pointer), pointer);

Definition at line 759 of file libsheepy.h.

◆ RST

#define RST   "\x1B[0m"

reset for color function

Definition at line 763 of file libsheepy.h.

◆ BLD

#define BLD   "\x1B[1m"

bold for color function

Definition at line 765 of file libsheepy.h.

◆ FNT

#define FNT   "\x1B[2m"

faint

Definition at line 767 of file libsheepy.h.

◆ ITL

#define ITL   "\x1B[3m"

italic

Definition at line 769 of file libsheepy.h.

◆ UDL

#define UDL   "\x1B[4m"

underline for color function

Definition at line 771 of file libsheepy.h.

◆ BLI

#define BLI   "\x1B[5m"

blink

Definition at line 773 of file libsheepy.h.

◆ INV

#define INV   "\x1B[7m"

inverse for color function

Definition at line 775 of file libsheepy.h.

◆ COC

#define COC   "\x1B[8m"

conceal/hidden for color function

Definition at line 777 of file libsheepy.h.

◆ CRD

#define CRD   "\x1B[9m"

crossed for color function

Definition at line 779 of file libsheepy.h.

◆ BLK

#define BLK   "\x1B[30m"

black for color function

Definition at line 783 of file libsheepy.h.

◆ RED

#define RED   "\x1B[31m"

red for color function

Definition at line 785 of file libsheepy.h.

◆ GRN

#define GRN   "\x1B[32m"

green for color function

Definition at line 787 of file libsheepy.h.

◆ YLW

#define YLW   "\x1B[33m"

yellow for color function

Definition at line 789 of file libsheepy.h.

◆ BLU

#define BLU   "\x1B[34m"

blue for color function

Definition at line 791 of file libsheepy.h.

◆ MGT

#define MGT   "\x1B[35m"

magenta for color function

Definition at line 793 of file libsheepy.h.

◆ CYN

#define CYN   "\x1B[36m"

cyan for color function

Definition at line 795 of file libsheepy.h.

◆ WHT

#define WHT   "\x1B[37m"

white for color function

Definition at line 797 of file libsheepy.h.

◆ BGBLK

#define BGBLK   "\x1B[40m"

bg black for color function

Definition at line 801 of file libsheepy.h.

◆ BGRED

#define BGRED   "\x1B[41m"

bg red for color function

Definition at line 803 of file libsheepy.h.

◆ BGGRN

#define BGGRN   "\x1B[42m"

bg green for color function

Definition at line 805 of file libsheepy.h.

◆ BGYLW

#define BGYLW   "\x1B[43m"

bg yellow for color function

Definition at line 807 of file libsheepy.h.

◆ BGBLU

#define BGBLU   "\x1B[44m"

bg blue for color function

Definition at line 809 of file libsheepy.h.

◆ BGMGT

#define BGMGT   "\x1B[45m"

bg magenta for color function

Definition at line 811 of file libsheepy.h.

◆ BGCYN

#define BGCYN   "\x1B[46m"

bg cyan for color function

Definition at line 813 of file libsheepy.h.

◆ BGWHT

#define BGWHT   "\x1B[47m"

bg white for color function

Definition at line 815 of file libsheepy.h.

◆ sheepyRGBFP

#define sheepyRGBFP   len = fprintf(stream, "%*s", (int)(info->left ? -info->width : info->width), b)

Definition at line 818 of file libsheepy.h.

◆ sheepyBOOLFP

#define sheepyBOOLFP   len = fprintf(stream, "%*s", (int)(info->left ? -info->width : info->width), boolS(value))

Definition at line 819 of file libsheepy.h.

◆ timeNs

#define timeNs (   func)
Value:
do{\
u64 UNIQVAR(endTime);\
u64 UNIQVAR(startTime) = getMonotonicTime();\
func;\
UNIQVAR(endTime) = getMonotonicTime();\
printf(BLD GRN "time" RST ": %" PRIu64 "ns " BLD UDL YLW "%s" RST "\n", UNIQVAR(endTime)-UNIQVAR(startTime), stringifyExpr(func));\
}while(0)
#define YLW
yellow for color function
Definition: libsheepy.h:789
#define RST
reset for color function
Definition: libsheepy.h:763
#define GRN
green for color function
Definition: libsheepy.h:787
#define stringifyExpr(expr)
stringify Expression - Turn expression into a string literal
Definition: libsheepy.h:282
#define UDL
underline for color function
Definition: libsheepy.h:771
#define BLD
bold for color function
Definition: libsheepy.h:765
uint64_t getMonotonicTime(void) MUST_CHECK
end bitfield
Definition: libsheepy.c:57411
#define UNIQVAR(name)
Definition: libsheepy.h:705

time a function in nanoseconds

Example: timeNs(func(anInt));

Definition at line 827 of file libsheepy.h.

◆ TIMEUNITUS

#define TIMEUNITUS   "us"

Definition at line 835 of file libsheepy.h.

◆ TIMEUNITMS

#define TIMEUNITMS   "ms"

Definition at line 836 of file libsheepy.h.

◆ TIMEUNITSC

#define TIMEUNITSC   "s"

Definition at line 837 of file libsheepy.h.

◆ timeDivs

#define timeDivs (   func,
  div,
  timeunit 
)
Value:
do{\
u64 UNIQVAR(endTime);\
u64 UNIQVAR(startTime) = getMonotonicTime();\
func;\
UNIQVAR(endTime) = getMonotonicTime();\
printf(BLD GRN "time:" RST " %f"timeunit" " BLD UDL YLW "%s" RST "\n", (f32)(UNIQVAR(endTime)-UNIQVAR(startTime))/div, stringifyExpr(func));\
}while(0)
#define YLW
yellow for color function
Definition: libsheepy.h:789
#define RST
reset for color function
Definition: libsheepy.h:763
#define GRN
green for color function
Definition: libsheepy.h:787
#define f32
Definition: libsheepy.h:449
#define stringifyExpr(expr)
stringify Expression - Turn expression into a string literal
Definition: libsheepy.h:282
#define UDL
underline for color function
Definition: libsheepy.h:771
#define BLD
bold for color function
Definition: libsheepy.h:765
uint64_t getMonotonicTime(void) MUST_CHECK
end bitfield
Definition: libsheepy.c:57411
#define UNIQVAR(name)
Definition: libsheepy.h:705

time a function with div

Example: timeDivs(func(anInt), 1E3);

Definition at line 845 of file libsheepy.h.

◆ timeUs

#define timeUs (   func)    timeDivs(func,1E3, TIMEUNITUS)

time a function in microseconds

Example: timeUs(func(anInt));

Definition at line 859 of file libsheepy.h.

◆ timeMs

#define timeMs (   func)    timeDivs(func,1E6, TIMEUNITMS)

time a function in miliseconds

Example: timeMs(func(anInt));

Definition at line 867 of file libsheepy.h.

◆ timeSec

#define timeSec (   func)    timeDivs(func,1E9, TIMEUNITSC)

time a function in seconds

Example: timeSec(func(anInt));

Definition at line 875 of file libsheepy.h.

◆ stopwatchStart

#define stopwatchStart   shStopwatch(0)

Definition at line 880 of file libsheepy.h.

◆ stopwatchLog

#define stopwatchLog   printf(BLD GRN "time" RST ": %" PRIu64 "ns\n", shStopwatch(1))

print stopwatch value in ns since last start

Definition at line 885 of file libsheepy.h.

◆ stopwatchLogDivs

#define stopwatchLogDivs (   div,
  timeunit 
)    printf(BLD GRN "time" RST ": %f"timeunit"\n", ((float)shStopwatch(1))/div)

print stopwatch value in provided unit since last start

Definition at line 890 of file libsheepy.h.

◆ stopwatchLogUs

#define stopwatchLogUs   stopwatchLogDivs(1E3, TIMEUNITUS)

print stopwatch value in microseconds since last start

Definition at line 895 of file libsheepy.h.

◆ stopwatchLogMs

#define stopwatchLogMs   stopwatchLogDivs(1E6, TIMEUNITMS)

print stopwatch value in milliseconds since last start

Definition at line 900 of file libsheepy.h.

◆ stopwatchLogSec

#define stopwatchLogSec   stopwatchLogDivs(1E9, TIMEUNITSC)

print stopwatch value in seconds since last start

Definition at line 905 of file libsheepy.h.

◆ LOG_EMERGENCY

#define LOG_EMERGENCY   0

LOG LEVELS Note: When adding log levels or modes, the log_tags array in libsheepy.c must be updated.

Definition at line 912 of file libsheepy.h.

◆ LOG_ALERT

#define LOG_ALERT   1

Definition at line 913 of file libsheepy.h.

◆ LOG_CRITICAL

#define LOG_CRITICAL   2

Definition at line 914 of file libsheepy.h.

◆ LOG_ERROR

#define LOG_ERROR   3

Definition at line 915 of file libsheepy.h.

◆ LOG_WARNING

#define LOG_WARNING   4

Definition at line 919 of file libsheepy.h.

◆ LOG_NOTICE

#define LOG_NOTICE   5

Definition at line 920 of file libsheepy.h.

◆ LOG_PASS

#define LOG_PASS   6

Definition at line 921 of file libsheepy.h.

◆ LOG_INFO

#define LOG_INFO   7

Definition at line 925 of file libsheepy.h.

◆ LOG_DEBUG

#define LOG_DEBUG   8

Definition at line 926 of file libsheepy.h.

◆ LOG_INVALID

#define LOG_INVALID   9

Definition at line 927 of file libsheepy.h.

◆ LOG_MAX_LEVEL

#define LOG_MAX_LEVEL   LOG_INVALID

Definition at line 928 of file libsheepy.h.

◆ LOG_DISABLE

#define LOG_DISABLE   -1

getMaxLogLevel and setMaxLogLevel value disabling all logs

Definition at line 931 of file libsheepy.h.

◆ LOG_VERBOSE

#define LOG_VERBOSE   0

LOG MODES when a new mode is added, add symbols in log_tags in libsheepy.c.

log symbol, program name, filename, function, line, date

Definition at line 941 of file libsheepy.h.

◆ LOG_CONCISE

#define LOG_CONCISE   1

log symbol

Definition at line 946 of file libsheepy.h.

◆ LOG_DATE

#define LOG_DATE   2

log symbol and date

Definition at line 951 of file libsheepy.h.

◆ LOG_FUNC

#define LOG_FUNC   3

log symbol and function

Definition at line 956 of file libsheepy.h.

◆ LOG_PROG

#define LOG_PROG   4

log symbol and program name

Definition at line 961 of file libsheepy.h.

◆ LOG_PROGNDATE

#define LOG_PROGNDATE   5

log symbol, program name and date

Definition at line 966 of file libsheepy.h.

◆ LOG_VOID

#define LOG_VOID   6

log message only

Definition at line 971 of file libsheepy.h.

◆ LOG_UTF8

#define LOG_UTF8   7

UTF8 symbols and concise.

Definition at line 976 of file libsheepy.h.

◆ LOG_PROGNFUNC

#define LOG_PROGNFUNC   8

log symbol, program name and function

Definition at line 981 of file libsheepy.h.

◆ LOG_INVALID_MODE

#define LOG_INVALID_MODE   9

invalid

Definition at line 986 of file libsheepy.h.

◆ openLogFile

#define openLogFile   setLogFile

Definition at line 990 of file libsheepy.h.

◆ MUST_CHECK [1/2]

#define MUST_CHECK

Definition at line 8206 of file libsheepy.h.

◆ pLog

#define pLog (   level,
  ... 
)    _pLog(level, __FILE__, __func__, __LINE__, __VA_ARGS__);

print logging levels

to disable logging, empty pLog define: #undef pLog #define pLog

Parameters
levelLOG_CRITICAL, LOG_ERROR, LOG_WARNING or LOG_INFO, anything else has log level LOG_INVALID
messagelike printf

Definition at line 1053 of file libsheepy.h.

◆ logY

#define logY (   ...)    pLog(LOG_EMERGENCY, __VA_ARGS__)

Definition at line 1057 of file libsheepy.h.

◆ logA

#define logA (   ...)    pLog(LOG_ALERT, __VA_ARGS__)

Definition at line 1058 of file libsheepy.h.

◆ logC

#define logC (   ...)    pLog(LOG_CRITICAL, __VA_ARGS__)

Definition at line 1059 of file libsheepy.h.

◆ logE

#define logE (   ...)    pLog(LOG_ERROR, __VA_ARGS__)

Definition at line 1060 of file libsheepy.h.

◆ logW

#define logW (   ...)    pLog(LOG_WARNING, __VA_ARGS__)

Definition at line 1061 of file libsheepy.h.

◆ logN

#define logN (   ...)    pLog(LOG_NOTICE, __VA_ARGS__)

Definition at line 1062 of file libsheepy.h.

◆ logP

#define logP (   ...)    pLog(LOG_PASS, __VA_ARGS__)

Definition at line 1063 of file libsheepy.h.

◆ logI

#define logI (   ...)    pLog(LOG_INFO, __VA_ARGS__)

Definition at line 1064 of file libsheepy.h.

◆ logD

#define logD (   ...)    pLog(LOG_DEBUG, __VA_ARGS__)

Definition at line 1065 of file libsheepy.h.

◆ logSY

#define logSY (   format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logY(format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log string and free Example: logSY("The list: %s", catS("1", "2"));

Definition at line 1072 of file libsheepy.h.

◆ logSA

#define logSA (   format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logA(format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log string and free Example: logSA("The list: %s", catS("1", "2"));

Definition at line 1083 of file libsheepy.h.

◆ logSC

#define logSC (   format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logC(format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log string and free Example: logSC("The list: %s", catS("1", "2"));

Definition at line 1094 of file libsheepy.h.

◆ logSE

#define logSE (   format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logE(format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log string and free Example: logSE("The list: %s", catS("1", "2"));

Definition at line 1105 of file libsheepy.h.

◆ logSW

#define logSW (   format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logW(format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log string and free Example: logSW("The list: %s", catS("1", "2"));

Definition at line 1116 of file libsheepy.h.

◆ logSN

#define logSN (   format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logN(format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log string and free Example: logSN("The list: %s", catS("1", "2"));

Definition at line 1127 of file libsheepy.h.

◆ logSP

#define logSP (   format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logP(format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log string and free Example: logSP("The list: %s", catS("1", "2"));

Definition at line 1138 of file libsheepy.h.

◆ logSI

#define logSI (   format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logI(format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log string and free Example: logSI("The list: %s", catS("1", "2"));

Definition at line 1149 of file libsheepy.h.

◆ logSD

#define logSD (   format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logD(format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log string and free Example: logSD("The list: %s", catS("1", "2"));

Definition at line 1160 of file libsheepy.h.

◆ pLogMask

#define pLogMask (   mask,
  level,
  ... 
)    if ((mask) & logMask) pLog(level, __VA_ARGS__)

print mask logging levels

print logs with a mask in logMask normally, mask is 1 bit wide.

pLogMask allows enabling/disabling groups of logs

to disable logging, empty pLogMask define: #undef pLogMask #define pLogMask

Example:

#define group1 0x03 #define group11 0x01 #define group12 0x02 #define group2 0x04

logMask = group11; logMI(group1, "is shown when logMask has bit 0 or 1 set"); logMI(group11, "is shown when logMask has bit 0 set"); logMI(group12, "is shown when logMask has bit 1 set"); logMI(group2, "is shown when logMask has bit 2 set");

Parameters
levelLOG_CRITICAL, LOG_ERROR, LOG_WARNING or LOG_INFO, anything else has log level LOG_INVALID
messagelike printf

Definition at line 1200 of file libsheepy.h.

◆ logMY

#define logMY (   mask,
  ... 
)    pLogMask(mask, LOG_EMERGENCY, __VA_ARGS__)

Definition at line 1202 of file libsheepy.h.

◆ logMA

#define logMA (   mask,
  ... 
)    pLogMask(mask, LOG_ALERT, __VA_ARGS__)

Definition at line 1203 of file libsheepy.h.

◆ logMC

#define logMC (   mask,
  ... 
)    pLogMask(mask, LOG_CRITICAL, __VA_ARGS__)

Definition at line 1204 of file libsheepy.h.

◆ logME

#define logME (   mask,
  ... 
)    pLogMask(mask, LOG_ERROR, __VA_ARGS__)

Definition at line 1205 of file libsheepy.h.

◆ logMW

#define logMW (   mask,
  ... 
)    pLogMask(mask, LOG_WARNING, __VA_ARGS__)

Definition at line 1206 of file libsheepy.h.

◆ logMN

#define logMN (   mask,
  ... 
)    pLogMask(mask, LOG_NOTICE, __VA_ARGS__)

Definition at line 1207 of file libsheepy.h.

◆ logMP

#define logMP (   mask,
  ... 
)    pLogMask(mask, LOG_PASS, __VA_ARGS__)

Definition at line 1208 of file libsheepy.h.

◆ logMI

#define logMI (   mask,
  ... 
)    pLogMask(mask, LOG_INFO, __VA_ARGS__)

Definition at line 1209 of file libsheepy.h.

◆ logMD

#define logMD (   mask,
  ... 
)    pLogMask(mask, LOG_DEBUG, __VA_ARGS__)

Definition at line 1210 of file libsheepy.h.

◆ showLogsInMask

#define showLogsInMask (   mask)    logMask |= mask

Definition at line 1213 of file libsheepy.h.

◆ hideLogsInMask

#define hideLogsInMask (   mask)    logMask &= ~(mask)

Definition at line 1216 of file libsheepy.h.

◆ logSMY

#define logSMY (   mask,
  format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logMY(mask, format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log and mask string and then free Example: logSMY("The list: %s", catS("1", "2"));

Definition at line 1223 of file libsheepy.h.

◆ logSMA

#define logSMA (   mask,
  format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logMA(mask, format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log and mask string and then free Example: logSMA("The list: %s", catS("1", "2"));

Definition at line 1234 of file libsheepy.h.

◆ logSMC

#define logSMC (   mask,
  format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logMC(mask, format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log and mask string and then free Example: logSMI("The list: %s", catS("1", "2"));

Definition at line 1245 of file libsheepy.h.

◆ logSME

#define logSME (   mask,
  format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logME(mask, format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log and mask string and then free Example: logSME("The list: %s", catS("1", "2"));

Definition at line 1256 of file libsheepy.h.

◆ logSMW

#define logSMW (   mask,
  format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logMW(mask, format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log and mask string and then free Example: logSMW("The list: %s", catS("1", "2"));

Definition at line 1267 of file libsheepy.h.

◆ logSMN

#define logSMN (   mask,
  format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logMN(mask, format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log and mask string and then free Example: logSMN("The list: %s", catS("1", "2"));

Definition at line 1278 of file libsheepy.h.

◆ logSMP

#define logSMP (   mask,
  format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logMP(mask, format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log and mask string and then free Example: logSMP("The list: %s", catS("1", "2"));

Definition at line 1289 of file libsheepy.h.

◆ logSMI

#define logSMI (   mask,
  format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logMI(mask, format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log and mask string and then free Example: logSMI("The list: %s", catS("1", "2"));

Definition at line 1300 of file libsheepy.h.

◆ logSMD

#define logSMD (   mask,
  format,
  string 
)
Value:
do {\
char *libsheepyInternalString = string;\
logMD(mask, format, libsheepyInternalString);\
free(libsheepyInternalString);\
} while(0)

log and mask string and then free Example: logSMD("The list: %s", catS("1", "2"));

Definition at line 1311 of file libsheepy.h.

◆ Q_SORT3

#define Q_SORT3 (   q_a1,
  q_a2,
  q_a3,
  Q_LESS,
  Q_SWAP 
)
Value:
do {\
if (Q_LESS(q_a2, q_a1)) {\
if (Q_LESS(q_a3, q_a2))\
Q_SWAP(q_a1, q_a3);\
else {\
Q_SWAP(q_a1, q_a2);\
if (Q_LESS(q_a3, q_a2))\
Q_SWAP(q_a2, q_a3);\
}\
}\
else if (Q_LESS(q_a3, q_a2)) {\
Q_SWAP(q_a2, q_a3);\
if (Q_LESS(q_a2, q_a1))\
Q_SWAP(q_a1, q_a2); \
}\
} while (0)

Definition at line 1386 of file libsheepy.h.

◆ Q_PARTITION

#define Q_PARTITION (   q_l,
  q_r,
  q_i,
  q_j,
  Q_UINT,
  Q_LESS,
  Q_SWAP 
)
Value:
do {\
/* The middle element, not to be confused with the median. */\
Q_UINT UNIQVAR(q_m) = q_l + ((q_r - q_l) >> 1);\
/* Reorder the second, the middle, and the last items.\
* As [Edelkamp Weiss 2016] explain, using the second element\
* instead of the first one helps avoid bad behaviour for\
* decreasingly sorted arrays. This method is used in recent\
* versions of gcc's std::sort, see gcc bug 58437#c13, although\
* the details are somewhat different (cf. #c14). */\
Q_SORT3(q_l + 1, UNIQVAR(q_m), q_r, Q_LESS, Q_SWAP);\
/* Place the median at the beginning. */\
Q_SWAP(q_l, UNIQVAR(q_m));\
/* Partition [q_l+2, q_r-1] around the median which is in q_l.\
* q_i and q_j are initially off by one, they get decremented\
* in the do-while loops. */\
q_i = q_l + 1; q_j = q_r;\
while (1) {\
do q_i++; while (Q_LESS(q_i, q_l));\
do q_j--; while (Q_LESS(q_l, q_j));\
if (q_i >= q_j) break; /* Sedgewick says "until j < i" */\
Q_SWAP(q_i, q_j);\
}\
/* Compensate for the i==j case. */\
q_i = q_j + 1;\
/* Put the median to its final place. */\
Q_SWAP(q_l, q_j);\
/* The median is not part of the left subfile. */\
q_j--;\
} while (0)
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 1406 of file libsheepy.h.

◆ Q_INSERTION_SORT

#define Q_INSERTION_SORT (   q_l,
  q_r,
  Q_UINT,
  Q_LESS,
  Q_SWAP 
)
Value:
do {\
Q_UINT UNIQVAR(q_i), UNIQVAR(q_j);\
/* For each item starting with the second... */\
for (UNIQVAR(q_i) = q_l + 1; UNIQVAR(q_i) <= q_r; UNIQVAR(q_i)++)\
/* move it down the array so that the first part is sorted. */\
for (UNIQVAR(q_j) = UNIQVAR(q_i); UNIQVAR(q_j) > q_l && (Q_LESS(UNIQVAR(q_j), UNIQVAR(q_j) - 1)); UNIQVAR(q_j)--)\
Q_SWAP(UNIQVAR(q_j), UNIQVAR(q_j) - 1);\
} while (0)
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 1443 of file libsheepy.h.

◆ Q_THRESH

#define Q_THRESH   16

Definition at line 1457 of file libsheepy.h.

◆ Q_LOOP

#define Q_LOOP (   Q_UINT,
  Q_N,
  Q_LESS,
  Q_SWAP 
)

Definition at line 1460 of file libsheepy.h.

◆ Q_SUBFILES

#define Q_SUBFILES (   q_l1,
  q_r1,
  q_l2,
  q_r2 
)
Value:
do {\
/* If the second subfile is only a single element, it needs\
* no further processing. The first subfile will be processed\
* on the next iteration (both subfiles cannot be only a single\
* element, due to Q_THRESH). */\
if (q_l2 == q_r2) {\
UNIQVAR(q_l) = q_l1;\
UNIQVAR(q_r) = q_r1;\
}\
else {\
/* Otherwise, both subfiles need processing.\
* Push the larger subfile onto the stack. */\
UNIQVAR(q_st)[UNIQVAR(q_sp)].q_l = q_l1;\
UNIQVAR(q_st)[UNIQVAR(q_sp)].q_r = q_r1;\
UNIQVAR(q_sp)++;\
/* Process the smaller subfile on the next iteration. */\
UNIQVAR(q_l) = q_l2;\
UNIQVAR(q_r) = q_r2;\
}\
} while (0)
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 1494 of file libsheepy.h.

◆ QSORT

#define QSORT (   Q_N,
  Q_LESS,
  Q_SWAP 
)
Value:
do {\
if ((Q_N) > 1) {\
if (sizeof(Q_N) == sizeof(unsigned long)) {\
Q_LOOP(unsigned long, Q_N, Q_LESS, Q_SWAP);}\
else if (sizeof(Q_N) <= sizeof(unsigned)) {\
Q_LOOP(unsigned, Q_N, Q_LESS, Q_SWAP);}\
}\
} while (0)

Definition at line 1516 of file libsheepy.h.

◆ BSEARCH

#define BSEARCH (   RESULT_INDEX,
  SEARCH_ELEMENT,
  B_N,
  B_LESS,
  B_EQUAL 
)
Value:
do {\
ssize_t UNIQVAR(b_first) = 0, UNIQVAR(b_middle), UNIQVAR(b_last);\
UNIQVAR(b_last) = B_N-1;\
while (UNIQVAR(b_first) <= UNIQVAR(b_last)) {\
UNIQVAR(b_middle) = (UNIQVAR(b_first)+UNIQVAR(b_last))/2;\
if (B_LESS(UNIQVAR(b_middle), SEARCH_ELEMENT)) UNIQVAR(b_first) = UNIQVAR(b_middle) + 1;\
else if (B_EQUAL(UNIQVAR(b_middle), SEARCH_ELEMENT)) {\
RESULT_INDEX = UNIQVAR(b_middle);\
goto UNIQVAR(end);\
}\
else UNIQVAR(b_last) = UNIQVAR(b_middle) -1;\
}\
/* element not found */\
RESULT_INDEX = -1;\
UNIQVAR(end):;\
} while(0)
#define UNIQVAR(name)
Definition: libsheepy.h:705

binary search macro

Synopsis: BSEARCH(RESULT_INDEX, SEARCH_ELEMENT, N, LESS, EQUAL); where RESULT_INDEX - variable holding the result index, signed int type (example: ssize_t), declare RESULT_INDEX before calling BSEARCH; SEARCH_ELEMENT - element to search in the array; N - the number of elements in A[]; LESS(i, SEARCH_ELEMENT) - compares A[i] to SEARCH_ELEMENT, 1 when less; EQUAL(i, SEARCH_ELEMENT) - compares A[i] to SEARCH_ELEMENT, 1 when equal;

Example: int A[] = {1,5,7,9,10,65}; ssize_t bsr;

#define LESS(i, se) A[i] < se #define EQUAL(i, se) A[i] == se BSEARCH(bsr, 9, COUNT_ELEMENTS(A), LESS, EQUAL); #undef LESS #undef EQUAL

logVar(bsr,"zd");

Definition at line 1555 of file libsheepy.h.

◆ libsheepyPrealloc

#define libsheepyPrealloc   (1024*1024)

Definition at line 1578 of file libsheepy.h.

◆ makeRoom

#define makeRoom (   length,
  alloc,
  addlength 
)
Value:
funcbegin\
typeof(alloc) r;\
typeof(alloc) newlen = (length) + (addlength);\
if (newlen < (alloc)) {\
r = alloc;\
} \
else {\
if (newlen < libsheepyPrealloc) {\
r = newlen * 2;\
}\
else {\
r = newlen + libsheepyPrealloc;\
}\
}\
r;\
funcend
#define libsheepyPrealloc
Definition: libsheepy.h:1578
bool r

Definition at line 1579 of file libsheepy.h.

◆ initLibsheepy

#define initLibsheepy (   progPath)    initLibsheepyF(progPath, NULL)

Definition at line 1599 of file libsheepy.h.

◆ systemNFree

#define systemNFree (   command)    systemNFreeF(command, __LINE__, __func__, __FILE__)

Definition at line 1635 of file libsheepy.h.

◆ isPath

#define isPath   fileExists

Definition at line 1732 of file libsheepy.h.

◆ readFileS

#define readFileS   readFileToS

Definition at line 1752 of file libsheepy.h.

◆ bReadFileS

#define bReadFileS   bReadFileToS

Definition at line 1753 of file libsheepy.h.

◆ bLReadFileS

#define bLReadFileS   bLReadFileToS

Definition at line 1754 of file libsheepy.h.

◆ readStreamS

#define readStreamS   readStreamToS

Definition at line 1755 of file libsheepy.h.

◆ bReadStreamS

#define bReadStreamS   bReadStreamToS

Definition at line 1756 of file libsheepy.h.

◆ bLReadStreamS

#define bLReadStreamS   bLReadStreamToS

Definition at line 1757 of file libsheepy.h.

◆ charToS

#define charToS (   dst,
  c 
)    ;char dst[2] = {c, 0}

Definition at line 1862 of file libsheepy.h.

◆ freeManyS

#define freeManyS (   ...)    freeManySF("", __VA_ARGS__, NULL)

Definition at line 1867 of file libsheepy.h.

◆ put

#define put   puts("");

Definition at line 1894 of file libsheepy.h.

◆ catS

#define catS (   ...)    catSF("", __VA_ARGS__, NULL)

Definition at line 1911 of file libsheepy.h.

◆ iCatS

#define iCatS (   dst,
  ... 
)    iCatSF(dst, "", __VA_ARGS__, NULL)

Definition at line 1915 of file libsheepy.h.

◆ bCatS

#define bCatS   iCatS

Definition at line 1916 of file libsheepy.h.

◆ bLCatS

#define bLCatS (   dst,
  dstSize,
  ... 
)    bLCatSF(dst, dstSize, "", __VA_ARGS__, NULL)

Definition at line 1918 of file libsheepy.h.

◆ iAppendManyS

#define iAppendManyS (   s,
  s1,
  ... 
)    iAppendManySF(s, s1, __VA_ARGS__, NULL)

Definition at line 1937 of file libsheepy.h.

◆ bAppendManyS

#define bAppendManyS (   s,
  s1,
  ... 
)    bAppendManySF(s, s1, __VA_ARGS__, NULL)

Definition at line 1939 of file libsheepy.h.

◆ bLAppendManyS

#define bLAppendManyS (   s,
  sSize,
  s1,
  ... 
)    bLAppendManySF(s, sSize, s1, __VA_ARGS__, NULL)

Definition at line 1941 of file libsheepy.h.

◆ replaceS_max

#define replaceS_max (   s,
  olds,
  news 
)    replaceS(s,olds,news, 0)

Definition at line 1958 of file libsheepy.h.

◆ replaceSMax

#define replaceSMax   replaceS_max

Definition at line 1959 of file libsheepy.h.

◆ replaceSMaxLen

#define replaceSMaxLen (   s,
  olds,
  news 
)    replaceSLen(s,olds,news, 0)

Definition at line 1962 of file libsheepy.h.

◆ iReplaceS_max

#define iReplaceS_max (   s,
  olds,
  news 
)    iReplaceS(s,olds,news, 0)

Definition at line 1967 of file libsheepy.h.

◆ iReplaceSMax

#define iReplaceSMax   iReplaceS_max

Definition at line 1968 of file libsheepy.h.

◆ bReplaceS_max

#define bReplaceS_max (   s,
  olds,
  news 
)    bReplaceS(s,olds,news, 0)

Definition at line 1970 of file libsheepy.h.

◆ bReplaceSMax

#define bReplaceSMax   bReplaceS_max

Definition at line 1971 of file libsheepy.h.

◆ bLReplaceS_max

#define bLReplaceS_max (   s,
  sSize,
  olds,
  news 
)    bLReplaceS(s,sSize,olds,news, 0)

Definition at line 1973 of file libsheepy.h.

◆ bLReplaceSMax

#define bLReplaceSMax   bLReplaceS_max

Definition at line 1974 of file libsheepy.h.

◆ replaceManyS

#define replaceManyS (   s,
  ... 
)    replaceManySF(s, __VA_ARGS__, NULL)

Definition at line 1978 of file libsheepy.h.

◆ iReplaceManyS

#define iReplaceManyS (   s,
  olds,
  ... 
)    iReplaceManySF(s, olds, __VA_ARGS__, NULL)

Definition at line 1980 of file libsheepy.h.

◆ bReplaceManyS

#define bReplaceManyS (   s,
  olds,
  ... 
)    bReplaceManySF(s, olds, __VA_ARGS__, NULL)

Definition at line 1982 of file libsheepy.h.

◆ bLReplaceManyS

#define bLReplaceManyS (   s,
  sSize,
  olds,
  ... 
)    bLReplaceManySF(s, sSize, olds, __VA_ARGS__, NULL)

Definition at line 1984 of file libsheepy.h.

◆ icReplaceS_max

#define icReplaceS_max (   s,
  olds,
  news 
)    icReplaceS(s,olds,news, 0)

Definition at line 1991 of file libsheepy.h.

◆ icReplaceSMax

#define icReplaceSMax   icReplaceS_max

Definition at line 1992 of file libsheepy.h.

◆ iicReplaceS_max

#define iicReplaceS_max (   s,
  olds,
  news 
)    iicReplaceS(s,olds,news, 0)

Definition at line 1997 of file libsheepy.h.

◆ iicReplaceSMax

#define iicReplaceSMax   iicReplaceS_max

Definition at line 1998 of file libsheepy.h.

◆ bicReplaceS_max

#define bicReplaceS_max (   s,
  olds,
  news 
)    bicReplaceS(s,olds,news, 0)

Definition at line 2000 of file libsheepy.h.

◆ bicReplaceSMax

#define bicReplaceSMax   bicReplaceS_max

Definition at line 2001 of file libsheepy.h.

◆ bLicReplaceS_max

#define bLicReplaceS_max (   s,
  sSize,
  olds,
  news 
)    bLicReplaceS(s,sSize,olds,news, 0)

Definition at line 2003 of file libsheepy.h.

◆ bLicReplaceSMax

#define bLicReplaceSMax   bLicReplaceS_max

Definition at line 2004 of file libsheepy.h.

◆ icReplaceManyS

#define icReplaceManyS (   s,
  ... 
)    icReplaceManySF(s, __VA_ARGS__, NULL)

Definition at line 2008 of file libsheepy.h.

◆ iicReplaceManyS

#define iicReplaceManyS (   s,
  olds,
  ... 
)    iicReplaceManySF(s, olds, __VA_ARGS__, NULL)

Definition at line 2010 of file libsheepy.h.

◆ bicReplaceManyS

#define bicReplaceManyS (   s,
  olds,
  ... 
)    bicReplaceManySF(s, olds, __VA_ARGS__, NULL)

Definition at line 2012 of file libsheepy.h.

◆ bLicReplaceManyS

#define bLicReplaceManyS (   s,
  sSize,
  olds,
  ... 
)    bLicReplaceManySF(s, sSize, olds, __VA_ARGS__, NULL)

Definition at line 2014 of file libsheepy.h.

◆ strEq

#define strEq   eqS

Definition at line 2018 of file libsheepy.h.

◆ strIEq

#define strIEq   eqIS

Definition at line 2024 of file libsheepy.h.

◆ toUpper

#define toUpper (   c)    ((c) = toupper(c), c)

upper case and store the result in c and return the result

Definition at line 2127 of file libsheepy.h.

◆ toLower

#define toLower (   c)    ((c) = tolower(c), c)

lower case and store the result in c and return the result

Definition at line 2137 of file libsheepy.h.

◆ uniqSlash

#define uniqSlash (   s)    uniqS(s, '/')

Definition at line 2159 of file libsheepy.h.

◆ iUniqSlash

#define iUniqSlash (   s)    iUniqS(&(s), '/')

Definition at line 2160 of file libsheepy.h.

◆ bUniqSlash

#define bUniqSlash (   s)    bUniqS(s, '/')

Definition at line 2161 of file libsheepy.h.

◆ codeSizeUTF8

#define codeSizeUTF8 (   utf8)    codeSzUTF8[*(const uint8_t *)(utf8)]

size in bytes of UTF-8 code point

Definition at line 2328 of file libsheepy.h.

◆ nextCodeUTF8

#define nextCodeUTF8 (   utf8)    ((utf8) + codeSizeUTF8(utf8))

move pointer to next UTF-8 code point, no checks are done, the utf8 pointer parameter is unchanged

Definition at line 2331 of file libsheepy.h.

◆ nxtCodeUTF8

#define nxtCodeUTF8 (   utf8)    EVA(utf8, nextCodeUTF8(utf8))

change the utf8 pointer parameter to next UTF-8 code point, like char *s; s++;

Definition at line 2334 of file libsheepy.h.

◆ nxCodeUTF8

#define nxCodeUTF8 (   utf8)    (utf8 = nextCodeUTF8(utf8))

Definition at line 2335 of file libsheepy.h.

◆ emptyS

#define emptyS (   string)    string = strdup("");

Definition at line 2544 of file libsheepy.h.

◆ bEmptyS

#define bEmptyS (   string)    (string)[0] = 0

Definition at line 2549 of file libsheepy.h.

◆ orS

#define orS (   string,
  alternative 
)    !isEmptyS(string) ? (string) : (alternative)

orS - if string is empty, the value is alternative

Definition at line 2558 of file libsheepy.h.

◆ orBlankS

#define orBlankS (   string,
  alternative 
)    !isBlankS(string) ? (string) : (alternative)

blankS - if string is blank(white spaces) or empty, the value is alternative

Definition at line 2567 of file libsheepy.h.

◆ nS

#define nS (   string)    (string) ? (string) : ""

nS - null String - replace null string with "" string (empty string)

Definition at line 2573 of file libsheepy.h.

◆ nAS

#define nAS (   string,
  alternative 
)    (string) ? (string) : (alternative)

nAS - null Alternative String - replace null string with alternative string

Definition at line 2579 of file libsheepy.h.

◆ listEmptyS

#define listEmptyS (   list)
Value:
do {\
list = malloc(1 * sizeof(char *)); \
if (list) list[0] = NULL; \
} while(0);

Definition at line 2587 of file libsheepy.h.

◆ listCreateS

#define listCreateS (   ...)    listCreateSF("", __VA_ARGS__, NULL)

Definition at line 2605 of file libsheepy.h.

◆ listFreeManyS

#define listFreeManyS (   ...)    listFreeManySF(NULL, __VA_ARGS__, NULL)

Definition at line 2634 of file libsheepy.h.

◆ listCatS

#define listCatS (   ...)    listCatSF(NULL, __VA_ARGS__, NULL)

Definition at line 2710 of file libsheepy.h.

◆ forever

#define forever   while(1)

forever loop

Definition at line 2765 of file libsheepy.h.

◆ range

#define range (   index,
  maxCount 
)
Value:
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
for (size_t index = 0 ; index < UNIQVAR(maxCnt) ; index++)
#define UNIQVAR(name)
Definition: libsheepy.h:705

range loop ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2772 of file libsheepy.h.

◆ rangeInf

#define rangeInf (   index)    for (size_t index = 0 ;; index++)

infinity loop increase the index infinitly

Definition at line 2780 of file libsheepy.h.

◆ rangeDown

#define rangeDown (   index,
  maxCount 
)    for (ssize_t index = (maxCount)-1 ; index >= 0 ; index--)

range down loop, index is ssize_t

Definition at line 2786 of file libsheepy.h.

◆ rangeDownTo

#define rangeDownTo (   index,
  maxCount,
  to 
)
Value:
;ssize_t UNIQVAR(_to) = to;\
for (ssize_t index = (maxCount)-1 ; index >= UNIQVAR(_to) ; index--)
#define UNIQVAR(name)
Definition: libsheepy.h:705

range down loop to to index, index is ssize_t ;ssize_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2794 of file libsheepy.h.

◆ rangeFrom

#define rangeFrom (   index,
  from,
  maxCount 
)
Value:
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
for (size_t index = from ; index < UNIQVAR(maxCnt) ; index++)
#define UNIQVAR(name)
Definition: libsheepy.h:705

range loop starting at value from ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2803 of file libsheepy.h.

◆ arange

#define arange (   index,
  array 
)    range(index, ARRAY_SIZE(array))

loop on the elements of C static array of any type

Example: u32 array[20]; arange(i, array) {}

Definition at line 2814 of file libsheepy.h.

◆ arangeDown

#define arangeDown (   index,
  array 
)    rangeDown(index, ARRAY_SIZE(array))

loop on the elements of C static array of any type from highest index down to 0

Example: u32 array[20]; arangeDown(i, array) {}

Definition at line 2823 of file libsheepy.h.

◆ arangeDownTo

#define arangeDownTo (   index,
  array,
  to 
)    rangeDownTo(index, ARRAY_SIZE(array), to)

loop on the elements of C static array of any type from highest index down to index 'to'

Example: u32 array[20]; arangeDownTo(i, array, 5) {}

Definition at line 2832 of file libsheepy.h.

◆ arangeFrom

#define arangeFrom (   index,
  from,
  array 
)    rangeFrom(index, from, ARRAY_SIZE(array))

loop on the elements of C static array of any type starting at index 'from'

Example: u32 array[20]; arange(i, 10, array) {}

Definition at line 2841 of file libsheepy.h.

◆ circular

#define circular (   index,
  from,
  maxCount 
)
Value:
;bool UNIQVAR(libsheepyInternalStatus) = true; \
size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
size_t UNIQVAR(frm) = (size_t)(from); \
for (size_t index = UNIQVAR(frm) ; (index != UNIQVAR(frm)) || (UNIQVAR(libsheepyInternalStatus)); index == (UNIQVAR(maxCnt)-1) ? index = 0 : index++, UNIQVAR(libsheepyInternalStatus) = false)
#define UNIQVAR(name)
Definition: libsheepy.h:705

range from value from to maxCount-1 then from 0 to from-1

Example: circular(i, 2, 4)

counts: 2, 3, 0, 1

;bool UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2854 of file libsheepy.h.

◆ circularDown

#define circularDown (   index,
  from,
  maxCount 
)
Value:
;bool UNIQVAR(libsheepyInternalStatus) = true; \
size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
size_t UNIQVAR(frm) = (size_t)(from); \
for (size_t index = UNIQVAR(frm) ; (index != UNIQVAR(frm)) || (UNIQVAR(libsheepyInternalStatus)); index == 0 ? index = (UNIQVAR(maxCnt)-1) : index--, UNIQVAR(libsheepyInternalStatus) = false)
#define UNIQVAR(name)
Definition: libsheepy.h:705

range from value from down to 0 then from maxCount-1 to from+1

Example: circularDown(i, 2, 4)

counts: 2, 1, 0, 3

;bool UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2871 of file libsheepy.h.

◆ rangeStep

#define rangeStep (   index,
  maxCount,
  step 
)
Value:
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
for (size_t index = 0 ; index < UNIQVAR(maxCnt) ; index+=step)
#define UNIQVAR(name)
Definition: libsheepy.h:705

range step loop ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2882 of file libsheepy.h.

◆ rangeDownStep

#define rangeDownStep (   index,
  maxCount,
  step 
)    for (int64_t index = (maxCount)-1 ; index >= 0 ; index-=step)

range down step loop, index is int64_t

Definition at line 2889 of file libsheepy.h.

◆ rangeFromStep

#define rangeFromStep (   index,
  from,
  maxCount,
  step 
)
Value:
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
for (size_t index = from ; index < UNIQVAR(maxCnt) ; index+=(size_t)step)
#define UNIQVAR(name)
Definition: libsheepy.h:705

range step loop starting at value from ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2897 of file libsheepy.h.

◆ loop

#define loop (   maxCount)
Value:
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
for (size_t UNIQVAR(index) = 0 ; UNIQVAR(index) < UNIQVAR(maxCnt) ; UNIQVAR(index)++)
#define UNIQVAR(name)
Definition: libsheepy.h:705

loops without index ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2907 of file libsheepy.h.

◆ loopDownTo

#define loopDownTo (   maxCount,
  to 
)
Value:
;ssize_t UNIQVAR(_to) = to;\
for (ssize_t UNIQVAR(index) = (maxCount)-1 ; UNIQVAR(index) >= UNIQVAR(_to) ; UNIQVAR(index)--)
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop to to index ;ssize_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2916 of file libsheepy.h.

◆ loopFrom

#define loopFrom (   from,
  maxCount 
)
Value:
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
for (size_t UNIQVAR(index) = from ; UNIQVAR(index) < UNIQVAR(maxCnt) ; UNIQVAR(index)++)
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop starting at value from ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2925 of file libsheepy.h.

◆ loopStep

#define loopStep (   maxCount,
  step 
)
Value:
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
for (size_t UNIQVAR(index) = 0 ; UNIQVAR(index) < UNIQVAR(maxCnt) ; UNIQVAR(index)+=step)
#define UNIQVAR(name)
Definition: libsheepy.h:705

step loop ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2934 of file libsheepy.h.

◆ loopFromStep

#define loopFromStep (   from,
  maxCount,
  step 
)
Value:
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
for (size_t UNIQVAR(index) = from ; UNIQVAR(index) < UNIQVAR(maxCnt) ; UNIQVAR(index)+=step)
#define UNIQVAR(name)
Definition: libsheepy.h:705

step loop starting at value from ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2943 of file libsheepy.h.

◆ aForEach

#define aForEach (   array,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
for (typeof(&array[0]) element = &array[0] ; UNIQVAR(libsheepyInternalIndex) < ARRAY_SIZE(array) ; UNIQVAR(libsheepyInternalIndex)++, element = &array[UNIQVAR(libsheepyInternalIndex)])
char * array[]
#define ARRAY_SIZE
Definition: libsheepy.h:473
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop on array elements element is a pointer to a value in the array

aForEach(array, e) { e->x = 0; }

Definition at line 2956 of file libsheepy.h.

◆ aEnumerate

#define aEnumerate (   array,
  index,
  element 
)
Value:
; size_t index = 0 ; \
for (typeof(&array[0]) element = &array[0] ; index < ARRAY_SIZE(array) ; index++, element = &array[index])
char * array[]
#define ARRAY_SIZE
Definition: libsheepy.h:473

enumerate array elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array

aEnumerate(array, i, e) { e->x = 0; printf("aEnumerate %d\n", i); }

Definition at line 2971 of file libsheepy.h.

◆ forEachCharP

#define forEachCharP (   list,
  element 
)    for (char **element=list ; *element != NULL ; element++)

forEach - loop macro on list indexes to access the element in the loop, use *element

Definition at line 2979 of file libsheepy.h.

◆ forEachCCharP

#define forEachCCharP (   list,
  element 
)    for (const char **element=list ; *element != NULL ; element++)

forEach for const char** lists

Definition at line 2985 of file libsheepy.h.

◆ forEachS

#define forEachS (   list,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
for (char *element = (list)[0]; (list)[UNIQVAR(libsheepyInternalIndex)]!= NULL ; UNIQVAR(libsheepyInternalIndex)++, element = (list)[UNIQVAR(libsheepyInternalIndex)])
#define UNIQVAR(name)
Definition: libsheepy.h:705

forEach - loop macro on list indexes to access the element in the loop, use element ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 2994 of file libsheepy.h.

◆ forEachCS

#define forEachCS (   list,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
for (const char *element = (list)[0]; (list)[UNIQVAR(libsheepyInternalIndex)]!= NULL ; UNIQVAR(libsheepyInternalIndex)++, element = (list)[UNIQVAR(libsheepyInternalIndex)])
#define UNIQVAR(name)
Definition: libsheepy.h:705

forEach for const char** lists

Definition at line 3001 of file libsheepy.h.

◆ forEachType

#define forEachType (   type,
  list,
  element 
)    for (type **element=list ; *element != NULL ; element++)

forEach - loop macro on list indexes

Definition at line 3008 of file libsheepy.h.

◆ enumerateCharP

#define enumerateCharP (   list,
  element,
  index 
)
Value:
;size_t index = 0; \
for (char **element=list; *element != NULL ; element++, index++)

enumerateCharP list to access the element in the loop, use *element ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 3017 of file libsheepy.h.

◆ enumerateCCharP

#define enumerateCCharP (   list,
  element,
  index 
)
Value:
;size_t index = 0; \
for (const char **element=list; *element != NULL ; element++, index++)

enumerateCCharP const list to access the element in the loop, use *element ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 3027 of file libsheepy.h.

◆ enumerateS

#define enumerateS (   list,
  element,
  index 
)
Value:
;size_t index = 0; \
for (char *element=(list)[0]; element != NULL ; index++, element = (list)[index])

enumerateS list to acess the element in the loop, use element ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 3037 of file libsheepy.h.

◆ enumerateCS

#define enumerateCS (   list,
  element,
  index 
)
Value:
;size_t index = 0; \
for (const char *element=(list)[0]; element != NULL ; index++, element = (list)[index])

enumerateCS const list to acess the element in the loop, use element ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 3047 of file libsheepy.h.

◆ enumerateType

#define enumerateType (   type,
  list,
  element,
  index 
)
Value:
;size_t index = 0; \
for (type **element=list; *element != NULL ; element++, index++)

enumerateType list ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement on older compilers

Definition at line 3056 of file libsheepy.h.

◆ lForEach

#define lForEach (   node,
  startNode 
)    for(var node = startNode; node ; node = (node)->next)

loop for linked lists from startNode to last

node must be a pointer to a struct with a next member pointing to the next node in the list

when node->next is NULL, the list end is reached

Definition at line 3068 of file libsheepy.h.

◆ lForEachDown

#define lForEachDown (   node,
  startNode 
)    for(var node = startNode; node ; node = (node)->prev)

loop for linked lists from startNode to head

node must be a pointer to a struct with a prev member pointing to the previous node in the list

when node->prev is NULL, the list head is reached

Definition at line 3079 of file libsheepy.h.

◆ lForEachPrev

#define lForEachPrev   lForEachDown

Definition at line 3082 of file libsheepy.h.

◆ execOutf

#define execOutf   systemOutf

Definition at line 3119 of file libsheepy.h.

◆ execf

#define execf   systemf

Definition at line 3120 of file libsheepy.h.

◆ systemOut

#define systemOut   execOut

Definition at line 3125 of file libsheepy.h.

◆ logSystem

#define logSystem (   cmd)
Value:
funcbegin\
var UNIQVAR(cm) = cmd;\
logI("%s",UNIQVAR(cm));\
system (UNIQVAR(cm));\
funcend
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 3129 of file libsheepy.h.

◆ logExec

#define logExec   logSystem

Definition at line 3134 of file libsheepy.h.

◆ logSystemOut

#define logSystemOut (   cmd)
Value:
({\
var UNIQVAR(cm) = cmd;\
logI("%s",UNIQVAR(cm));\
systemOut(UNIQVAR(cm));\
})
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 3135 of file libsheepy.h.

◆ logExecOut

#define logExecOut   logSystemOut

Definition at line 3140 of file libsheepy.h.

◆ logSystemOutf

#define logSystemOutf (   fmt,
  ... 
)
Value:
({\
logI (fmt, __VA_ARGS__);\
systemOutf(fmt, __VA_ARGS__);})

Definition at line 3141 of file libsheepy.h.

◆ logExecOutf

#define logExecOutf   logSystemOutf

Definition at line 3144 of file libsheepy.h.

◆ logSystemf

#define logSystemf (   fmt,
  ... 
)
Value:
({\
logI (fmt, __VA_ARGS__);\
systemf(fmt, __VA_ARGS__);})

Definition at line 3145 of file libsheepy.h.

◆ logExecf

#define logExecf   logSystemf

Definition at line 3148 of file libsheepy.h.

◆ command

#define command (   cmd)    commandF(cmd, __LINE__, __func__, __FILE__)

Definition at line 3151 of file libsheepy.h.

◆ commandf

#define commandf (   ...)    commandfF(__LINE__, __func__, __FILE__, __VA_ARGS__)

Definition at line 3153 of file libsheepy.h.

◆ commandNFree

#define commandNFree (   cmd)    commandNFreeF(cmd, __LINE__, __func__, __FILE__)

Definition at line 3155 of file libsheepy.h.

◆ commandOut

#define commandOut   execOut

Definition at line 3157 of file libsheepy.h.

◆ commandOutf

#define commandOutf   systemOutf

Definition at line 3158 of file libsheepy.h.

◆ logCommand

#define logCommand (   cmd)
Value:
funcbegin\
var UNIQVAR(cm) = cmd;\
logI("%s",UNIQVAR(cm));\
command (UNIQVAR(cm));\
funcend
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 3161 of file libsheepy.h.

◆ logCommandf

#define logCommandf (   fmt,
  ... 
)
Value:
logI (fmt, __VA_ARGS__);\
commandf(fmt, __VA_ARGS__);\
funcend
#define logI(...)
Definition: libsheepy.h:1064

Definition at line 3167 of file libsheepy.h.

◆ logCommandNFree

#define logCommandNFree (   cmd)
Value:
funcbegin\
var UNIQVAR(cm) = cmd;\
logI ("%s",UNIQVAR(cm));\
commandNFree(UNIQVAR(cm));\
funcend
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 3172 of file libsheepy.h.

◆ logCommandOut

#define logCommandOut   logExecOut

Definition at line 3178 of file libsheepy.h.

◆ logCommandOutf

#define logCommandOutf   logExecOutf

Definition at line 3179 of file libsheepy.h.

◆ logBtrace

#define logBtrace   char **UNIQVAR(r)=btrace();if(UNIQVAR(r)){logN("\n"BLD WHT"Backtrace:"RST);forEachS(UNIQVAR(r), element){logN(element);}listFreeS(UNIQVAR(r));logN("---");}

Definition at line 3249 of file libsheepy.h.

◆ logEBtrace

#define logEBtrace   if (btraceCfg) { char **UNIQVAR(r)=btrace();if(UNIQVAR(r)){logE("\n"BLD WHT"Backtrace:"RST);forEachS(UNIQVAR(r), element){logE(element);}listFreeS(UNIQVAR(r));logE("---");} }

print backtrace in error messages, default is on, use btraceEnable and btraceDisable to configure

Definition at line 3255 of file libsheepy.h.

◆ listEmpty

#define listEmpty (   list)
Value:
do {\
list = malloc(1 * sizeof(void *)); \
if (list) list[0] = NULL; \
} while(0);

Definition at line 3263 of file libsheepy.h.

◆ listCreate

#define listCreate (   ...)    listCreateF(NULL, __VA_ARGS__, NULL)

Definition at line 3277 of file libsheepy.h.

◆ listFreeMany

#define listFreeMany (   ...)    listFreeManyF(NULL, __VA_ARGS__, NULL)

Definition at line 3301 of file libsheepy.h.

◆ listCat

#define listCat (   ...)    listCatF(NULL, __VA_ARGS__, NULL)

Definition at line 3321 of file libsheepy.h.

◆ newPtr

#define newPtr (   name,
  type 
)    ;type *name = malloc(sizeof(type))

Definition at line 3364 of file libsheepy.h.

◆ new0Ptr

#define new0Ptr (   name,
  type 
)    ;type *name = calloc(1, sizeof(type))

Definition at line 3368 of file libsheepy.h.

◆ allocAPtr

#define allocAPtr (   name)    name = malloc(sizeof(*(name)))

Definition at line 3372 of file libsheepy.h.

◆ callocAPtr

#define callocAPtr (   name)    name = calloc(1, sizeof(*(name)))

Definition at line 3375 of file libsheepy.h.

◆ newArray

#define newArray (   name,
  type,
  count 
)    ;type *name = malloc((count) * sizeof(type))

Definition at line 3378 of file libsheepy.h.

◆ new0Array

#define new0Array (   name,
  type,
  count 
)    ;type *name = calloc(count, sizeof(type))

Definition at line 3382 of file libsheepy.h.

◆ allocArray

#define allocArray (   name,
  count 
)    malloc((count) * sizeof(*(name)))

Definition at line 3386 of file libsheepy.h.

◆ allocAArray

#define allocAArray (   name,
  count 
)    name = malloc((count) * sizeof(*(name)))

Definition at line 3389 of file libsheepy.h.

◆ callocArray

#define callocArray (   name,
  count 
)    calloc(count, sizeof(*(name)))

Definition at line 3392 of file libsheepy.h.

◆ callocAArray

#define callocAArray (   name,
  count 
)    name = calloc(count, sizeof(*(name)))

Definition at line 3395 of file libsheepy.h.

◆ reallocArray

#define reallocArray (   name,
  count 
)    realloc(name, (count) * sizeof(*(name)))

Definition at line 3398 of file libsheepy.h.

◆ sliceSz

#define sliceSz   1

slice - dynamic array in one chunk of memory (similar to vector and slab below)

This is a simple dynamic array holding element count and the data

this type of array has a dynamic element count pushing elements into the array increases the element count poping elements only decreases the element count, call sliceFit to realloc the slice

no sanity checks are done

the prefix is slice

Usage:

to declare a slice:

sliceT(typeName, type);

typeName slce;

sliceInit(&slce); or sliceInitCount(&slce, 17);

sliceAppend(&slce, value);

// get an element int a = sliceAt(&slce, 0);

set sliceAt(&slce, 1) = 3;

sliceFree(&slce);

Slice variables: slce.array: elements slce.count: current element count

Note: some functions are macros to be able to have structs as element and access the struct members directly, for example: sliceLast(chan).a = 0;number of elements added by sliceAlloc

Definition at line 3445 of file libsheepy.h.

◆ sliceT

#define sliceT (   typeName,
  elementType 
)
Value:
typedef struct {\
size_t count;\
elementType *array;\
} typeName
char * array[]

declares type for slice

Parameters
typeNameslice type name
elementtype of elements (int, struct, pointer...)

Definition at line 3455 of file libsheepy.h.

◆ createSlice

#define createSlice (   typeName,
  name 
)    ;typeName name; sliceInit(&name)

Definition at line 3461 of file libsheepy.h.

◆ createSliceCount

#define createSliceCount (   typeName,
  name,
  count 
)    ;typeName name; sliceInitCount(&name, count)

Definition at line 3463 of file libsheepy.h.

◆ createSliceClearCount

#define createSliceClearCount (   typeName,
  name,
  count 
)    ;typeName name; sliceCalloc(&name, count)

Definition at line 3465 of file libsheepy.h.

◆ createAllocateSlice

#define createAllocateSlice (   typeName,
  name 
)    ;typeName *name = calloc(1, sizeof(typeName))

Definition at line 3467 of file libsheepy.h.

◆ createAllocateSliceCount

#define createAllocateSliceCount (   typeName,
  name,
  count 
)    ;typeName *name = calloc(1, sizeof(typeName)); sliceInitCount(name, count)

Definition at line 3469 of file libsheepy.h.

◆ createAllocateSliceClearCount

#define createAllocateSliceClearCount (   typeName,
  name,
  count 
)    ;typeName *name = calloc(1, sizeof(typeName)); sliceCalloc(name, count)

Definition at line 3471 of file libsheepy.h.

◆ sliceTerminate

#define sliceTerminate (   name)    if (name) sliceFree(name);free(name)

Definition at line 3473 of file libsheepy.h.

◆ sliceInit

#define sliceInit (   name)
Value:
do{\
(name)->array = NULL;\
(name)->count = 0;\
} while(0)
char * array[]

initialize empty slice

Parameters
namevariable name for slice

Definition at line 3481 of file libsheepy.h.

◆ sliceInitCount

#define sliceInitCount (   name,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
/* TODO check if countInt is 0 then +1 */\
(name)->array = malloc(UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count = 0;\
} while(0)
char * array[]
char c
#define UNIQVAR(name)
Definition: libsheepy.h:705

initialize slice and count

Parameters
namevariable name for slice
countinitial element count for name type

Definition at line 3494 of file libsheepy.h.

◆ sliceCalloc

#define sliceCalloc (   name,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
(name)->array = calloc(UNIQVAR(c), sizeof (name)->array[0]);\
(name)->count = 0;\
} while(0)
char * array[]
char c
#define UNIQVAR(name)
Definition: libsheepy.h:705

initialize slice and count and set slice data to 0

Parameters
namevariable name for slice
countinitial element count for name type

Definition at line 3509 of file libsheepy.h.

◆ sliceResize

#define sliceResize (   name,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
if ((name)->array) {\
/* realloc */\
(name)->array = realloc((name)->array, sizeof((name)->array[0]) * UNIQVAR(c));\
}\
else {\
/* was empty */\
(name)->array = malloc(sizeof((name)->array[0]) * UNIQVAR(c));\
}\
/* element count when shrinking */\
if (UNIQVAR(c) < (name)->count) (name)->count = UNIQVAR(c);\
} while(0)
char * array[]
char c
#define UNIQVAR(name)
Definition: libsheepy.h:705

resize slice (even empty slices)

Definition at line 3518 of file libsheepy.h.

◆ sliceClearResize

#define sliceClearResize (   name,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
if ((name)->array) {\
/* realloc */\
(name)->array = realloc((name)->array, sizeof((name)->array[0]) * UNIQVAR(c));\
if ((name)->count < UNIQVAR(c)) {\
/* there are new elements */\
memset(&(name)->array[(name)->count], 0, (UNIQVAR(c) - (name)->count) * sizeof (name)->array[0]);\
}\
}\
else {\
/* was empty */\
(name)->array = calloc(UNIQVAR(c), sizeof((name)->array[0]));\
}\
/* element count when shrinking */\
if (UNIQVAR(c) < (name)->count) (name)->count = UNIQVAR(c);\
} while(0)
char * array[]
char c
#define UNIQVAR(name)
Definition: libsheepy.h:705

resize slice and clear the new elements with memset even empty slices can be resized and cleared

Definition at line 3536 of file libsheepy.h.

◆ sliceFree

#define sliceFree (   name)    free((name)->array)

free the internal buffers

Parameters
nameslice

Definition at line 3560 of file libsheepy.h.

◆ sliceElemType

#define sliceElemType (   name)    typeof((name)->array[0])

element type in slice

Definition at line 3565 of file libsheepy.h.

◆ sliceElemPtrType

#define sliceElemPtrType (   name)    typeof(&(name)->array[0])

element pointer type in slice

Definition at line 3570 of file libsheepy.h.

◆ sliceDup

#define sliceDup (   name)
Value:
({\
typeof(*(name)) dest;\
sliceInitCount(&dest, (name)->count);\
if ((name)->array) {\
memcpy(dest.array, (name)->array, (name)->count * sizeof (name)->array[0]);\
dest.count = (name)->count;\
}\
/* return */ dest;\
})
char * array[]

duplicate slice

Definition at line 3575 of file libsheepy.h.

◆ sliceCreateNDup

#define sliceCreateNDup (   name,
  dest 
)    ;typeof(*(name)) dest; sliceInitCount(&dest, (name)->count); if ((name)->array) { memcpy(dest.array, (name)->array, (name)->count * sizeof (name)->array[0]); dest.count = (name)->count;}

assign slice from to slice to the data is shared between slice from and slice to the counts are not shared

NO need for this macro, do like this: *to = *from; declare dest slice and duplicate slice

Definition at line 3601 of file libsheepy.h.

◆ sliceBDup

#define sliceBDup (   name,
  dest 
)
Value:
do{\
var UNIQVAR(dst) = dest;\
sliceResize(UNIQVAR(dst), (name)->count);\
if ((name)->array) {\
memcpy(UNIQVAR(dst)->array, (name)->array, (name)->count * sizeof (name)->array[0]);\
UNIQVAR(dst)->count = (name)->count;\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

duplicate slice to already declared dest slice

Definition at line 3606 of file libsheepy.h.

◆ sliceData

#define sliceData (   name)    (name)->array

direct access to underlying array

Definition at line 3619 of file libsheepy.h.

◆ sliceFrom

#define sliceFrom (   name,
  array,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (sizeof((name)->array[0]) == sizeof(*(UNIQVAR(a)))) {\
sliceResize(name, UNIQVAR(c));\
memcpy((name)->array, UNIQVAR(a), UNIQVAR(c) * sizeof UNIQVAR(a)[0]);\
(name)->count = UNIQVAR(c);\
}\
} while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

copy data from array to slice

Definition at line 3624 of file libsheepy.h.

◆ sliceMirror

#define sliceMirror (   name,
  start,
  end 
)
Value:
({\
var UNIQVAR(strt) = start;\
typeof(*(name)) UNIQVAR(r);\
UNIQVAR(r).array = slicePtr(name, UNIQVAR(strt));\
UNIQVAR(r).count = end - UNIQVAR(strt);\
UNIQVAR(r);\
})
#define slicePtr(name, index)
get pointer to element at index
Definition: libsheepy.h:3820
bool r
#define UNIQVAR(name)
Definition: libsheepy.h:705

mirror a range in a slice the data is not copied to dest slice, to copy data see sliceCopy or sliceBCopy

Definition at line 3638 of file libsheepy.h.

◆ sliceBMirror

#define sliceBMirror (   name,
  dest,
  start,
  end 
)
Value:
do{\
var UNIQVAR(strt) = start;\
var UNIQVAR(dst) = dest;\
UNIQVAR(dst)->array = slicePtr(name, UNIQVAR(strt));\
UNIQVAR(dst)->count = end - UNIQVAR(strt);\
} while(0)
#define slicePtr(name, index)
get pointer to element at index
Definition: libsheepy.h:3820
#define UNIQVAR(name)
Definition: libsheepy.h:705

mirror a range in a slice the data is not copied to dest slice, to copy data see sliceCopy or sliceBCopy

name can be slice, vector or slab dest must be slice

Definition at line 3653 of file libsheepy.h.

◆ sliceMirrorFrom

#define sliceMirrorFrom (   name,
  array,
  countInt 
)
Value:
do{\
var UNIQVAR(strt) = start;\
(name)->array = array;\
(name)->count = countInt;\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

mirror from array to slice the data is not copied to dest slice, to copy data see sliceCopy or sliceBCopy

Definition at line 3664 of file libsheepy.h.

◆ sliceClear

#define sliceClear (   name)
Value:
do{\
if ((name)->array)\
memset((name)->array, 0, (name)->count * sizeof (name)->array[0]);\
} while(0)
char * array[]

set 0 in slice elements count is unchanged

Definition at line 3675 of file libsheepy.h.

◆ sliceClearRange

#define sliceClearRange (   name,
  start,
  end 
)
Value:
do{\
if ((name)->array)\
memset((name)->array + start, 0, (end-start) * sizeof (name)->array[0]);\
} while(0)
char * array[]

Definition at line 3680 of file libsheepy.h.

◆ sliceEmpty

#define sliceEmpty (   name)    (name)->count = 0

Empty slice Set count to 0 Allocated buffers in the slice must be freed before running sliceEmpty.

Definition at line 3690 of file libsheepy.h.

◆ sliceIsEmpty

#define sliceIsEmpty (   name)    ((name)->count == 0 || !(name)->array)

is slice Empty

Definition at line 3695 of file libsheepy.h.

◆ sliceFit

#define sliceFit (   name)
Value:
do{\
sliceResize(name, (name)->count);\
} while(0)

realloc slice to count

Definition at line 3700 of file libsheepy.h.

◆ sliceCount

#define sliceCount (   name)    (name)->count

return element count

Definition at line 3707 of file libsheepy.h.

◆ sliceElemSize

#define sliceElemSize (   name)    sizeof((name)->array[0])

size of slice element

Definition at line 3712 of file libsheepy.h.

◆ sliceAlloc

#define sliceAlloc (   name)
Value:
do{\
if (!(name)->array) {\
(name)->array = malloc(sliceSz * sizeof (name)->array[0]);\
}\
else {\
(name)->array = realloc((name)->array, ((name)->count + sliceSz) * sizeof (name)->array[0]);\
}\
} while(0)
char * array[]
#define sliceSz
slice - dynamic array in one chunk of memory (similar to vector and slab below)
Definition: libsheepy.h:3445

allocate an element only when the slice is full

Definition at line 3718 of file libsheepy.h.

◆ sliceClearElem

#define sliceClearElem (   name,
  index 
)    memset(&(name)->array[index], 0, sizeof (name)->array[0])

clear (set 0) in element at index

Definition at line 3730 of file libsheepy.h.

◆ slicePush

#define slicePush (   name)
Value:
do {\
sliceAlloc(name);\
(name)->count++;\
} while(0)

push element and expand the slice no data (random) is set in the new element

Parameters
nameslice

Definition at line 3739 of file libsheepy.h.

◆ sliceAppend

#define sliceAppend (   name,
 
)
Value:
do{\
slicePush(name);\
sliceLast(name) = v;\
} while(0)

append element and expand the slice

Parameters
nameslice
velement to push

Definition at line 3752 of file libsheepy.h.

◆ sliceClearPush

#define sliceClearPush (   name)
Value:
do{\
slicePush(name);\
sliceClearElem(name, (name)->count - 1);\
} while(0)

push element and expand the slice the new element is cleared

Parameters
nameslice

Definition at line 3765 of file libsheepy.h.

◆ slicePop

#define slicePop (   name)    ((name)->count--, (name)->array[(name)->count])

pop element the element count is decreased

NOTE: using comma operator to avoid warning warning: operation on ‘b.head’ may be undefined [-Wsequence-point]

Parameters
nameslice

Definition at line 3781 of file libsheepy.h.

◆ sliceDelLast

#define sliceDelLast (   name)    ((name)->count--)

delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used

Definition at line 3788 of file libsheepy.h.

◆ sliceSet

#define sliceSet (   name,
  index,
 
)
Value:
do{\
var UNIQVAR(idx) = index;\
if (UNIQVAR(idx) >= (name)->count) {\
/* clear and resize */\
sliceClearResize(name, UNIQVAR(idx)+1);\
}\
sliceAt(name, UNIQVAR(idx)) = v;\
} while(0)
#define UNIQVAR(name)
Definition: libsheepy.h:705

set value at index and clearResize slice when index is outside slice count

Definition at line 3793 of file libsheepy.h.

◆ sliceAt

#define sliceAt (   name,
  index 
)    ((name)->array[index])

get / set element at index

Parameters
nameslice
indexindex in array

Definition at line 3810 of file libsheepy.h.

◆ slicePtr

#define slicePtr (   name,
  index 
)    ((name)->array + index)

get pointer to element at index

Parameters
nameslice
indexindex in array

Definition at line 3820 of file libsheepy.h.

◆ sliceLast

#define sliceLast (   name)    ((name)->array[(name)->count-1])

last element

Parameters
nameslice

Definition at line 3828 of file libsheepy.h.

◆ sliceLastPtr

#define sliceLastPtr (   name)    ((name)->array + (name)->count - 1)

pointer to last element

Parameters
nameslice

Definition at line 3836 of file libsheepy.h.

◆ sliceLastIndex

#define sliceLastIndex (   name)    ((name)->count - 1)

index of last element

Definition at line 3841 of file libsheepy.h.

◆ sliceFirst

#define sliceFirst (   name)    ((name)->array[0])

first element

Parameters
nameslice

Definition at line 3850 of file libsheepy.h.

◆ sliceWriteFilename

#define sliceWriteFilename (   name,
  filename 
)
Value:
do {\
FILE *UNIQVAR(f) = fopen(filename, "w");\
if (UNIQVAR(f)) {\
fwrite((name)->array, sizeof((name)->array[0]), sliceCount(name), UNIQVAR(f));\
fclose(UNIQVAR(f));\
}\
} while(0)
#define sliceCount(name)
return element count
Definition: libsheepy.h:3707
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

write the slice content to filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 3860 of file libsheepy.h.

◆ sliceWrite

#define sliceWrite (   name,
  file 
)    fwrite((name)->array, sizeof((name)->array[0]), sliceCount(name), file)

write the slice content to disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 3875 of file libsheepy.h.

◆ sliceReadFilename

#define sliceReadFilename (   name,
  filename 
)
Value:
do {\
if (fileExists(filename)) {\
size_t UNIQVAR(sz) = fileSize(filename);\
FILE *UNIQVAR(f) = fopen(filename, "r");\
if (UNIQVAR(f)) {\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((name)->array[0])) {\
slicePush(name);\
fread(sliceLastPtr(name), 1, sizeof((name)->array[0]), UNIQVAR(f));\
}\
fclose(UNIQVAR(f));\
}\
}\
} while(0)
smallt * i
bool fileExists(const char *filePath) MUST_CHECK
detect files and directories
Definition: libsheepy.c:4321
#define sliceLastPtr(name)
pointer to last element
Definition: libsheepy.h:3836
char * array[]
ssize_t fileSize(const char *filePath) MUST_CHECK
get file size
Definition: libsheepy.c:4369
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a slice from filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 3884 of file libsheepy.h.

◆ sliceRead

#define sliceRead (   name,
  file 
)
Value:
do {\
fseek(file, 0 , SEEK_END);\
size_t UNIQVAR(sz) = ftell(file);\
fseek(file, 0 , SEEK_SET);\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((name)->array[0])) {\
slicePush(name);\
fread(sliceLastPtr(name), 1, sizeof((name)->array[0]), file);\
}\
} while(0)
char ** file
smallt * i
#define sliceLastPtr(name)
pointer to last element
Definition: libsheepy.h:3836
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a slice from disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 3905 of file libsheepy.h.

◆ forEachSc

#define forEachSc (   name,
  index 
)    range(index, (name)->count)

loop index on slice elements

For example: forEachV(vec, i) { sliceAt(vec, i) = 0; }

Definition at line 3924 of file libsheepy.h.

◆ sliceForEach

#define sliceForEach (   name,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
for (sliceElemPtrType(name) element = slicePtr(name, 0) ; UNIQVAR(libsheepyInternalIndex) < (name)->count ; UNIQVAR(libsheepyInternalIndex)++, element = slicePtr(name, UNIQVAR(libsheepyInternalIndex)))
#define sliceElemPtrType(name)
element pointer type in slice
Definition: libsheepy.h:3570
#define slicePtr(name, index)
get pointer to element at index
Definition: libsheepy.h:3820
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop on slice elements element is a pointer to a value in the array

sliceForEach(&slc, e) { e->x = 0; }

Definition at line 3934 of file libsheepy.h.

◆ sliceEnumerate

#define sliceEnumerate (   name,
  index,
  element 
)
Value:
; size_t index = 0 ; \
for (sliceElemPtrType(name) element = slicePtr(name, 0) ; index < (name)->count ; index++, element = slicePtr(name, index))
#define sliceElemPtrType(name)
element pointer type in slice
Definition: libsheepy.h:3570
#define slicePtr(name, index)
get pointer to element at index
Definition: libsheepy.h:3820

enumerate slice elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array

sliceEnumerate(&slc, i, e) { e->x = 0; printf("sliceEnumerate %d\n", i); }

Definition at line 3949 of file libsheepy.h.

◆ sliceInject

#define sliceInject (   name,
  index 
)
Value:
do {\
var UNIQVAR(idx) = index;\
slicePush(name);\
if (index < sliceCount(name)) {\
memmove(slicePtr(name, UNIQVAR(idx) +1), slicePtr(name, UNIQVAR(idx)), ((name)->count - UNIQVAR(idx)-1) * sizeof (name)->array[0]);\
}\
} while(0)
#define sliceCount(name)
return element count
Definition: libsheepy.h:3707
char * array[]
#define slicePtr(name, index)
get pointer to element at index
Definition: libsheepy.h:3820
#define UNIQVAR(name)
Definition: libsheepy.h:705

insert an element at index the data is moved to create space for the new element to set data at the new element, use sliceAt(name, index) = value;

Definition at line 3958 of file libsheepy.h.

◆ slicePrepend

#define slicePrepend (   name,
 
)
Value:
do {\
sliceInject(name, 0);\
sliceAt(name, 0) = v;\
} while(0)

prepend element

Parameters
nameslice
velement to prepend

Definition at line 3974 of file libsheepy.h.

◆ sliceDequeue

#define sliceDequeue (   name)
Value:
({\
var r = sliceAt(name, 0);\
sliceDelFirst(name);\
/* return */r;\
})
#define sliceAt(name, index)
get / set element at index
Definition: libsheepy.h:3810
bool r

dequeue element

Parameters
nameslice

Definition at line 3985 of file libsheepy.h.

◆ sliceDelFirst

#define sliceDelFirst (   name)
Value:
do {\
if ((name)->count) {\
if ((name)->count > 1) {\
/* move elements */\
memcpy((name)->array, (name)->array +1 , ((name)->count - 1) * sizeof (name)->array[0]);\
}\
(name)->count--;\
}\
} while(0)
char * array[]

delete first element in slice the data is moved when count > 1

Definition at line 3995 of file libsheepy.h.

◆ sliceDelElem

#define sliceDelElem (   name,
  index 
)
Value:
do {\
var UNIQVAR(idx) = index;\
if ((size_t)UNIQVAR(idx) < (size_t)sliceLastIndex(name)) {\
/* move elements */\
memmove(slicePtr(name, UNIQVAR(idx)), slicePtr(name, UNIQVAR(idx) +1), ((name)->count - (UNIQVAR(idx) +1)) * sizeof (name)->array[0]);\
}\
(name)->count--;\
} while(0)
char * array[]
#define sliceLastIndex(name)
index of last element
Definition: libsheepy.h:3841
#define slicePtr(name, index)
get pointer to element at index
Definition: libsheepy.h:3820
#define UNIQVAR(name)
Definition: libsheepy.h:705

delete an element in slice the data is moved when index < (count-1) when index = count -1, the last element is deleted and no data is moved

Definition at line 4011 of file libsheepy.h.

◆ sliceDel

#define sliceDel (   name,
  start,
  end 
)
Value:
do {\
var UNIQVAR(strt) = start;\
var UNIQVAR(ed) = end;\
if (UNIQVAR(ed) < (name)->count and UNIQVAR(strt) < UNIQVAR(ed)) {\
/* move elements */\
memmove(slicePtr(name, UNIQVAR(strt)), slicePtr(name, UNIQVAR(ed)), ((name)->count - UNIQVAR(ed)) * sizeof (name)->array[0]);\
}\
(name)->count -= UNIQVAR(ed) - UNIQVAR(strt);\
} while(0)
char * array[]
#define slicePtr(name, index)
get pointer to element at index
Definition: libsheepy.h:3820
#define UNIQVAR(name)
Definition: libsheepy.h:705

delete range in slice start must be between 0 and last index end must be between 1 and count

Definition at line 4025 of file libsheepy.h.

◆ sliceVAppend

#define sliceVAppend (   name,
  slice 
)
Value:
do {\
var UNIQVAR(vec) = slice;\
if (sizeof((name)->array[0]) == sizeof((UNIQVAR(vec))->array[0])) {\
sliceResize(name, (name)->count + (UNIQVAR(vec))->count);\
memmove((name)->array + (name)->count, (UNIQVAR(vec))->array, (UNIQVAR(vec))->count * sizeof (name)->array[0]);\
(name)->count += (UNIQVAR(vec))->count;\
}\
} while(0)
char * array[]
o f slice(o, 1,-1)
#define UNIQVAR(name)
Definition: libsheepy.h:705

append slice to slice name the data is copied

Definition at line 4039 of file libsheepy.h.

◆ sliceAppendFrom

#define sliceAppendFrom (   name,
  array,
  countInt 
)
Value:
do {\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (sizeof((name)->array[0]) == sizeof(*(UNIQVAR(a)))) {\
sliceResize(name, (name)->count + UNIQVAR(c));\
memmove((name)->array + (name)->count, UNIQVAR(a), UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(c);\
}\
} while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

append array to slice the data is copied

Definition at line 4052 of file libsheepy.h.

◆ sliceVPrepend

#define sliceVPrepend (   name,
  slice 
)
Value:
do {\
var UNIQVAR(vec) = slice;\
if (sizeof((name)->array[0]) == sizeof((UNIQVAR(vec))->array[0])) {\
sliceResize(name, (name)->count + (UNIQVAR(vec))->count);\
memmove((name)->array + (UNIQVAR(vec))->count, (name)->array, (name)->count * sizeof (name)->array[0]);\
memmove((name)->array, (UNIQVAR(vec))->array, (UNIQVAR(vec))->count * sizeof (name)->array[0]);\
(name)->count += (UNIQVAR(vec))->count;\
}\
} while(0)
char * array[]
o f slice(o, 1,-1)
#define UNIQVAR(name)
Definition: libsheepy.h:705

prepend slice to slice name the data in slice name is moved and the data in slice is copied to slice name

Definition at line 4067 of file libsheepy.h.

◆ slicePrependFrom

#define slicePrependFrom (   name,
  array,
  countInt 
)
Value:
do {\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (sizeof((name)->array[0]) == sizeof(*(UNIQVAR(a)))) {\
sliceResize(name, (name)->count + UNIQVAR(c));\
memmove((name)->array + UNIQVAR(c), (name)->array, (name)->count * sizeof (name)->array[0]);\
memmove((name)->array, UNIQVAR(a), UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(c);\
}\
} while(0);
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

prepend array to slice the data in slice is moved and the data in array is copied to slice

Definition at line 4082 of file libsheepy.h.

◆ sliceInsert

#define sliceInsert (   name,
  index,
  slice 
)
Value:
do {\
var UNIQVAR(idx) = index;\
var UNIQVAR(vec) = slice;\
if (UNIQVAR(idx) == (name)->count) {\
sliceAppend(name, UNIQVAR(vec));\
}\
else if (sizeof((name)->array[0]) == sizeof((UNIQVAR(vec))->array[0])) {\
sliceResize(name, (name)->count + (UNIQVAR(vec))->count);\
memmove((name)->array + UNIQVAR(idx) + (UNIQVAR(vec))->count, (name)->array + UNIQVAR(idx), ((name)->count - UNIQVAR(idx)) * sizeof (name)->array[0]);\
memmove((name)->array + UNIQVAR(idx), (UNIQVAR(vec))->array, (UNIQVAR(vec))->count * sizeof (name)->array[0]);\
(name)->count += (UNIQVAR(vec))->count;\
}\
} while(0)
char * array[]
o f slice(o, 1,-1)
#define UNIQVAR(name)
Definition: libsheepy.h:705

insert slice at position index the data in slice name is moved and the data in slice is copied to slice name

Definition at line 4098 of file libsheepy.h.

◆ sliceInsertFrom

#define sliceInsertFrom (   name,
  index,
  array,
  countInt 
)
Value:
do {\
var UNIQVAR(idx) = index;\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (UNIQVAR(idx) == (name)->count) {\
sliceAppendFrom(name, UNIQVAR(a), UNIQVAR(c));\
}\
else if (sizeof((name)->array[0]) == sizeof(UNIQVAR(a)[0])) {\
sliceResize(name, (name)->count + UNIQVAR(c));\
memmove((name)->array + UNIQVAR(idx) + UNIQVAR(c), (name)->array + UNIQVAR(idx), ((name)->count - UNIQVAR(idx)) * sizeof (name)->array[0]);\
memmove((name)->array + UNIQVAR(idx), UNIQVAR(a), UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(c);\
}\
} while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

insert array at position index the data in slice is moved and the data in array is copied to slice

Definition at line 4117 of file libsheepy.h.

◆ sliceSlice

#define sliceSlice (   name,
  start,
  end 
)
Value:
({\
var UNIQVAR(strt) = start;\
var UNIQVAR(ed) = end;\
if (UNIQVAR(strt))\
memmove((name)->array, (name)->array + UNIQVAR(strt), (UNIQVAR(ed) - UNIQVAR(strt)) * sizeof (name)->array[0]);\
(name)->count = UNIQVAR(ed) - UNIQVAR(strt);\
name;\
})
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

slice slice, keep only elements between start and end start must be between 0 and last index end must be between 1 and count the slice is returned

Definition at line 4138 of file libsheepy.h.

◆ sliceCopy

#define sliceCopy (   name,
  start,
  end 
)
Value:
({\
var UNIQVAR(strt) = start;\
var UNIQVAR(ed) = end;\
createAllocateSliceCount(typeof(*(name)),UNIQVAR(r), UNIQVAR(ed) - UNIQVAR(strt));\
memmove(UNIQVAR(r)->array, (name)->array + UNIQVAR(strt), (UNIQVAR(ed) - UNIQVAR(strt)) * sizeof (name)->array[0]);\
UNIQVAR(r)->count = UNIQVAR(ed) - UNIQVAR(strt);\
UNIQVAR(r);\
})
char * array[]
bool r
#define UNIQVAR(name)
Definition: libsheepy.h:705

copy slice elements between start and end to a new slice start must be between 0 and last index end must be between 1 and count the new slice is returned and must be freed with sliceTerminate

Definition at line 4153 of file libsheepy.h.

◆ sliceBCopy

#define sliceBCopy (   name,
  dest,
  start,
  end 
)
Value:
do{\
if (sizeof((name)->array[0]) == sizeof((dest)->array[0])) {\
var UNIQVAR(strt) = start;\
var UNIQVAR(ed) = end;\
sliceResize(dest, UNIQVAR(ed) - UNIQVAR(strt));\
memmove((dest)->array, (name)->array + UNIQVAR(strt), (UNIQVAR(ed) - UNIQVAR(strt)) * sizeof (name)->array[0]);\
(dest)->count = UNIQVAR(ed) - UNIQVAR(strt);\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

copy slice elements between start and end to the dest slice start must be between 0 and last index end must be between 1 and count

Definition at line 4167 of file libsheepy.h.

◆ sliceSort

#define sliceSort (   name,
  compareFunction 
)
Value:
do{ \
qsort((name)->array, sizeof (name)->array[0], compareFunction);\
} while(0)
char * array[]

sort the slice the compareFunction must prototype of type: int cmp(const void * a, const void * b); the results of the compareFunction should be: <0 when a < b 0 when a = b >0 when a > b

Definition at line 4186 of file libsheepy.h.

◆ sliceEq

#define sliceEq (   name,
  slice,
  eqFunction 
)
Value:
({\
var UNIQVAR(vec) = slice;\
bool UNIQVAR(r) = true;\
if (sizeof((name)->array[0]) == sizeof((UNIQVAR(vec))->array[0]) and (name)->count == UNIQVAR(vec)->count) {\
forEachV(name, UNIQVAR(idx)) {\
if (not eqFunction(sliceAt(name,UNIQVAR(idx)), sliceAt(UNIQVAR(vec),UNIQVAR(idx)))) {\
UNIQVAR(r) = false;\
break;\
}\
}\
}\
else UNIQVAR(r) = false;\
UNIQVAR(r);\
})
char * array[]
o f slice(o, 1,-1)
#define sliceAt(name, index)
get / set element at index
Definition: libsheepy.h:3810
bool r
#define UNIQVAR(name)
Definition: libsheepy.h:705

return true when slice name is equal to slice eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

Definition at line 4195 of file libsheepy.h.

◆ sliceHas

#define sliceHas (   name,
  value,
  eqFunction 
)
Value:
({\
var UNIQVAR(v) = value;\
bool UNIQVAR(r) = false;\
forEachV(name, UNIQVAR(idx)) {\
if (eqFunction(sliceAt(name,UNIQVAR(idx)), UNIQVAR(v))) {\
UNIQVAR(r) = true;\
break;\
}\
}\
UNIQVAR(r);\
})
in value value
#define sliceAt(name, index)
get / set element at index
Definition: libsheepy.h:3810
bool r
#define UNIQVAR(name)
Definition: libsheepy.h:705

return true when slice has value eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

Definition at line 4215 of file libsheepy.h.

◆ sliceIndexOf

#define sliceIndexOf (   name,
  value,
  eqFunction 
)
Value:
({\
var UNIQVAR(v) = value;\
ssize_t UNIQVAR(r) = -1;\
forEachV(name, UNIQVAR(idx)) {\
if (eqFunction(sliceAt(name,UNIQVAR(idx)), UNIQVAR(v))) {\
UNIQVAR(r) = UNIQVAR(idx);\
break;\
}\
}\
UNIQVAR(r);\
})
in value value
#define sliceAt(name, index)
get / set element at index
Definition: libsheepy.h:3810
bool r
#define UNIQVAR(name)
Definition: libsheepy.h:705

return index (ssize_t) of value in slice eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

return value is -1 when value is not found

Definition at line 4234 of file libsheepy.h.

◆ sliceBinarySearch

#define sliceBinarySearch (   name,
  value,
  less,
  equal 
)
Value:
({\
var UNIQVAR(v) = value;\
ssize_t UNIQVAR(r);\
BSEARCH(UNIQVAR(r), UNIQVAR(v), (name)->count, less, equal);\
UNIQVAR(r);\
})
in value value
bool r
#define UNIQVAR(name)
Definition: libsheepy.h:705

binary search value in slice

efficiently finds the index of value in slice the slice has to be sorted before calling sliceBinarySearch

less is a macro taking an index and the search value returning 1 when sliceAt(name,index) is less than value: #define less(index, value) sliceAt(name, index) < value

equal is a macro returning 1 when sliceAt(name,index) is equal to value: #define equal(index, value) sliceAt(name,index) == value

return value is -1 when value is not found

Definition at line 4260 of file libsheepy.h.

◆ sliceUniq

#define sliceUniq (   name,
  eqFunction 
)

Uniquify elements in slice each elements are unique in the slice.

eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

Definition at line 4274 of file libsheepy.h.

◆ staticSliceT

#define staticSliceT (   typeName,
  elementType,
  MAXCOUNT 
)
Value:
typedef struct {\
size_t count;\
elementType array[MAXCOUNT];\
} typeName
char * array[]

staticSlice - static array with element count

pushing elements into the array increases the element count poping elements only decreases the element count

no sanity checks are done

the prefix is staticSlice

Usage:

to declare a staticSlice:

staticSliceT(typeName, type, 10);

typeName slce;

staticSliceInit(&slce);

staticSliceAppend(&slce, value);

// get an element int a = staticSliceAt(&slce, 0);

set staticSliceAt(&slce, 1) = 3;

staticSliceFree(&slce);

StaticSlice variables: slce.array: elements slce.count: current element count

Note: some functions are macros to be able to have structs as element and access the struct members directly, for example: staticSliceLast(chan).a = 0; declares type for staticSlice

Parameters
typeNamestaticSlice type name
elementtype of elements (int, struct, pointer...)
MAXCOUNTarray/ring buffer size

Definition at line 4360 of file libsheepy.h.

◆ createStaticSlice

#define createStaticSlice (   typeName,
  name 
)    ;typeName name; staticSliceInit(&name)

Definition at line 4366 of file libsheepy.h.

◆ staticSliceInit

#define staticSliceInit (   name)
Value:
do{\
(name)->count = 0;\
} while(0)

initialize empty staticSlice

Parameters
namevariable name for staticSlice

Definition at line 4374 of file libsheepy.h.

◆ staticSliceElemType

#define staticSliceElemType (   name)    typeof((name)->array[0])

element type in slice

Definition at line 4381 of file libsheepy.h.

◆ staticSliceElemPtrType

#define staticSliceElemPtrType (   name)    typeof(&(name)->array[0])

element pointer type in slice

Definition at line 4386 of file libsheepy.h.

◆ staticSliceBDup

#define staticSliceBDup (   name,
  dest 
)
Value:
do{\
var UNIQVAR(dst) = dest;\
if ((name)->count <= ARRAY_SIZE(UNIQVAR(dst)->array)) {\
memcpy(UNIQVAR(dst)->array, (name)->array, (name)->count * sizeof (name)->array[0]);\
UNIQVAR(dst)->count = (name)->count;\
}\
} while(0)
char * array[]
#define ARRAY_SIZE
Definition: libsheepy.h:473
#define UNIQVAR(name)
Definition: libsheepy.h:705

duplicate staticSlice to already declared dest staticSlice

Definition at line 4391 of file libsheepy.h.

◆ staticSliceData

#define staticSliceData   sliceData

direct access to underlying array

Definition at line 4403 of file libsheepy.h.

◆ staticSliceFrom

#define staticSliceFrom (   name,
  array,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (sizeof((name)->array[0]) == sizeof(*(UNIQVAR(a))) /* slice compatibility and UNIQVAR(c) <= ARRAY_SIZE((name)->array)*/) {\
memcpy((name)->array, UNIQVAR(a), UNIQVAR(c) * sizeof UNIQVAR(a)[0]);\
(name)->count = UNIQVAR(c);\
}\
} while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

copy data from array to staticSlice

Definition at line 4408 of file libsheepy.h.

◆ staticSliceClear

#define staticSliceClear (   name)    memset((name)->array, 0, (name)->count * sizeof (name)->array[0])

set 0 in staticSlice elements count is unchanged

Definition at line 4422 of file libsheepy.h.

◆ staticSliceClearRange

#define staticSliceClearRange (   name,
  start,
  end 
)    memset((name)->array + start, 0, (end-start) * sizeof (name)->array[0])

Definition at line 4424 of file libsheepy.h.

◆ staticSliceEmpty

#define staticSliceEmpty   sliceEmpty

Empty staticSlice Set count to 0 Allocated buffers in the staticSlice must be freed before running staticSliceEmpty.

Definition at line 4431 of file libsheepy.h.

◆ staticSliceIsEmpty

#define staticSliceIsEmpty (   name)    ((name)->count == 0)

is staticSlice Empty

Definition at line 4436 of file libsheepy.h.

◆ staticSliceCount

#define staticSliceCount   sliceCount

return element count

Definition at line 4441 of file libsheepy.h.

◆ staticSliceElemSize

#define staticSliceElemSize   sliceElemSize

size of staticSlice element

Definition at line 4446 of file libsheepy.h.

◆ staticSliceClearElem

#define staticSliceClearElem   sliceClearElem

clear (set 0) in element at index

Definition at line 4451 of file libsheepy.h.

◆ staticSlicePush

#define staticSlicePush (   name)    (name)->count++

push element and expand the staticSlice no data (random) is set in the new element

Parameters
namestaticSlice

Definition at line 4460 of file libsheepy.h.

◆ staticSliceAppend

#define staticSliceAppend (   name,
 
)
Value:
do{\
staticSlicePush(name);\
staticSliceLast(name) = v;\
} while(0)

append element and expand the staticSlice

Parameters
namestaticSlice
velement to push

Definition at line 4470 of file libsheepy.h.

◆ staticSliceClearPush

#define staticSliceClearPush (   name)
Value:
do{\
staticSlicePush(name);\
staticSliceClearElem(name, (name)->count - 1);\
} while(0)

push element and expand the staticSlice the new element is cleared

Parameters
namestaticSlice

Definition at line 4483 of file libsheepy.h.

◆ staticSlicePop

#define staticSlicePop   slicePop

pop element the element count is decreased

NOTE: using comma operator to avoid warning warning: operation on ‘b.head’ may be undefined [-Wsequence-point]

Parameters
namestaticSlice

Definition at line 4499 of file libsheepy.h.

◆ staticSliceDelLast

#define staticSliceDelLast   sliceDelLast

delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used

Definition at line 4506 of file libsheepy.h.

◆ staticSliceAt

#define staticSliceAt   sliceAt

get / set element at index

Parameters
namestaticSlice
indexindex in array

Definition at line 4516 of file libsheepy.h.

◆ staticSlicePtr

#define staticSlicePtr   slicePtr

get pointer to element at index

Parameters
namestaticSlice
indexindex in array

Definition at line 4526 of file libsheepy.h.

◆ staticSliceLast

#define staticSliceLast   sliceLast

last element

Parameters
namestaticSlice

Definition at line 4534 of file libsheepy.h.

◆ staticSliceLastPtr

#define staticSliceLastPtr   sliceLastPtr

pointer to last element

Parameters
namestaticSlice

Definition at line 4542 of file libsheepy.h.

◆ staticSliceLastIndex

#define staticSliceLastIndex   sliceLastIndex

index of last element

Definition at line 4547 of file libsheepy.h.

◆ staticSliceFirst

#define staticSliceFirst   sliceFirst

first element

Parameters
namestaticSlice

Definition at line 4556 of file libsheepy.h.

◆ staticSliceWriteFilename

#define staticSliceWriteFilename   sliceWriteFilename

write the staticSlice content to filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 4566 of file libsheepy.h.

◆ staticSliceWrite

#define staticSliceWrite   sliceWrite

write the staticSlice content to disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 4575 of file libsheepy.h.

◆ staticSliceReadFilename

#define staticSliceReadFilename (   name,
  filename 
)
Value:
do {\
if (fileExists(filename)) {\
size_t UNIQVAR(sz) = fileSize(filename);\
FILE *UNIQVAR(f) = fopen(filename, "r");\
if (UNIQVAR(f)) {\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((name)->array[0])) {\
staticSlicePush(name);\
fread(staticSliceLastPtr(name), 1, sizeof((name)->array[0]), UNIQVAR(f));\
}\
fclose(UNIQVAR(f));\
}\
}\
} while(0)
smallt * i
bool fileExists(const char *filePath) MUST_CHECK
detect files and directories
Definition: libsheepy.c:4321
char * array[]
#define staticSliceLastPtr
pointer to last element
Definition: libsheepy.h:4542
ssize_t fileSize(const char *filePath) MUST_CHECK
get file size
Definition: libsheepy.c:4369
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a staticSlice from filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 4584 of file libsheepy.h.

◆ staticSliceRead

#define staticSliceRead (   name,
  file 
)
Value:
do {\
fseek(file, 0 , SEEK_END);\
size_t UNIQVAR(sz) = ftell(file);\
fseek(file, 0 , SEEK_SET);\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((name)->array[0])) {\
staticSlicePush(name);\
fread(staticSliceLastPtr(name), 1, sizeof((name)->array[0]), file);\
}\
} while(0)
char ** file
smallt * i
char * array[]
#define staticSliceLastPtr
pointer to last element
Definition: libsheepy.h:4542
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a staticSlice from disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 4605 of file libsheepy.h.

◆ forEachSSc

#define forEachSSc   forEachSc

loop index on staticSlice elements

For example: forEachV(vec, i) { staticSliceAt(vec, i) = 0; }

Definition at line 4624 of file libsheepy.h.

◆ staticSliceForEach

#define staticSliceForEach (   name,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
for (staticSliceElemPtrType(name) element = staticSlicePtr(name, 0) ; UNIQVAR(libsheepyInternalIndex) < (name)->count ; UNIQVAR(libsheepyInternalIndex)++, element = staticSlicePtr(name, UNIQVAR(libsheepyInternalIndex)))
#define staticSliceElemPtrType(name)
element pointer type in slice
Definition: libsheepy.h:4386
#define staticSlicePtr
get pointer to element at index
Definition: libsheepy.h:4526
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop on slice elements element is a pointer to a value in the array

staticSliceForEach(&slc, e) { e->x = 0; }

Definition at line 4634 of file libsheepy.h.

◆ staticSliceEnumerate

#define staticSliceEnumerate (   name,
  index,
  element 
)
Value:
; size_t index = 0 ; \
for (staticSliceElemPtrType(name) element = staticSlicePtr(name, 0) ; index < (name)->count ; index++, element = staticSlicePtr(name, index))
#define staticSliceElemPtrType(name)
element pointer type in slice
Definition: libsheepy.h:4386
#define staticSlicePtr
get pointer to element at index
Definition: libsheepy.h:4526

enumerate slice elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array

sliceEnumerate(&slc, i, e) { e->x = 0; printf("sliceEnumerate %d\n", i); }

Definition at line 4649 of file libsheepy.h.

◆ staticSliceInject

#define staticSliceInject (   name,
  index 
)
Value:
do {\
var UNIQVAR(idx) = index;\
staticSlicePush(name);\
memmove(staticSlicePtr(name, UNIQVAR(idx) +1), staticSlicePtr(name, UNIQVAR(idx)), ((name)->count - UNIQVAR(idx)) * sizeof (name)->array[0]);\
} while(0)
char * array[]
#define staticSlicePtr
get pointer to element at index
Definition: libsheepy.h:4526
#define UNIQVAR(name)
Definition: libsheepy.h:705

insert an element at index the data is moved to create space for the new element to set data at the new element, use staticSliceAt(name, index) = value;

Definition at line 4658 of file libsheepy.h.

◆ staticSlicePrepend

#define staticSlicePrepend (   name,
 
)
Value:
do {\
staticSliceInject(name, 0);\
staticSliceAt(name, 0) = v;\
} while(0)

prepend element

Parameters
namestaticSlice
velement to prepend

Definition at line 4672 of file libsheepy.h.

◆ staticSliceDequeue

#define staticSliceDequeue   sliceDequeue

dequeue element

Parameters
namestaticSlice

Definition at line 4683 of file libsheepy.h.

◆ staticSliceDelFirst

#define staticSliceDelFirst   sliceDelFirst

delete first element in staticSlice the data is moved when count > 1

Definition at line 4689 of file libsheepy.h.

◆ staticSliceDelElem

#define staticSliceDelElem   sliceDelElem

delete an element in staticSlice the data is moved when index < (count-1) when index = count -1, the last element is deleted and no data is moved

Definition at line 4697 of file libsheepy.h.

◆ staticSliceDel

#define staticSliceDel   sliceDel

delete range in staticSlice start must be between 0 and last index end must be between 1 and count

Definition at line 4704 of file libsheepy.h.

◆ staticSliceVAppend

#define staticSliceVAppend (   name,
  staticSlice 
)
Value:
do {\
var UNIQVAR(vec) = staticSlice;\
if (sizeof((name)->array[0]) == sizeof(UNIQVAR(vec)->array[0]) /* slice compatibility and ((name)->count + UNIQVAR(vec)->count) <= ARRAY_SIZE((name)->array)*/) {\
memcpy((name)->array + (name)->count, UNIQVAR(vec)->array, UNIQVAR(vec)->count * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(vec)->count;\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

append staticSlice to staticSlice name the data is copied

Definition at line 4710 of file libsheepy.h.

◆ staticSliceAppendFrom

#define staticSliceAppendFrom (   name,
  array,
  countInt 
)
Value:
do {\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (sizeof((name)->array[0]) == sizeof(*(UNIQVAR(a))) /* slice compatibility and ((name)->count + UNIQVAR(c)) <= ARRAY_SIZE((name)->array)*/) {\
memcpy((name)->array + (name)->count, UNIQVAR(a), UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(c);\
}\
} while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

append array to staticSlice the data is copied

Definition at line 4722 of file libsheepy.h.

◆ staticSliceVPrepend

#define staticSliceVPrepend (   name,
  staticSlice 
)
Value:
do {\
var UNIQVAR(vec) = staticSlice;\
if (sizeof((name)->array[0]) == sizeof((UNIQVAR(vec))->array[0]) /* slice compatibility and ((name)->count + UNIQVAR(vec)->count) <= ARRAY_SIZE((name)->array)*/) {\
memmove((name)->array + (UNIQVAR(vec))->count, (name)->array, (name)->count * sizeof (name)->array[0]);\
memcpy((name)->array, (UNIQVAR(vec))->array, (UNIQVAR(vec))->count * sizeof (name)->array[0]);\
(name)->count += (UNIQVAR(vec))->count;\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

prepend staticSlice to staticSlice name the data in staticSlice name is moved and the data in staticSlice is copied to staticSlice name

Definition at line 4736 of file libsheepy.h.

◆ staticSlicePrependFrom

#define staticSlicePrependFrom (   name,
  array,
  countInt 
)
Value:
do {\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (sizeof((name)->array[0]) == sizeof(*(UNIQVAR(a))) /* slice compatibility and ((name)->count + UNIQVAR(c)) <= ARRAY_SIZE((name)->array)*/) {\
staticSliceResize(name, (name)->count + UNIQVAR(c));\
memmove((name)->array + UNIQVAR(c), (name)->array, (name)->count * sizeof (name)->array[0]);\
memcpy((name)->array, UNIQVAR(a), UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(c);\
}\
} while(0);
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

prepend array to staticSlice the data in staticSlice is moved and the data in array is copied to staticSlice

Definition at line 4750 of file libsheepy.h.

◆ staticSliceInsert

#define staticSliceInsert (   name,
  index,
  staticSlice 
)
Value:
do {\
var UNIQVAR(idx) = index;\
var UNIQVAR(vec) = staticSlice;\
if (UNIQVAR(idx) == (name)->count) {\
staticSliceAppend(name, UNIQVAR(vec));\
}\
else if (sizeof((name)->array[0]) == sizeof((UNIQVAR(vec))->array[0]) /* slice compatibility and ((name)->count + UNIQVAR(vec)->count) <= ARRAY_SIZE((name)->array)*/) {\
memmove((name)->array + UNIQVAR(idx) + (UNIQVAR(vec))->count, (name)->array + UNIQVAR(idx), ((name)->count - UNIQVAR(idx)) * sizeof (name)->array[0]);\
memcpy((name)->array + UNIQVAR(idx), (UNIQVAR(vec))->array, (UNIQVAR(vec))->count * sizeof (name)->array[0]);\
(name)->count += (UNIQVAR(vec))->count;\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

insert staticSlice at position index the data in staticSlice name is moved and the data in staticSlice is copied to staticSlice name

Definition at line 4766 of file libsheepy.h.

◆ staticSliceInsertFrom

#define staticSliceInsertFrom (   name,
  index,
  array,
  countInt 
)
Value:
do {\
var UNIQVAR(idx) = index;\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (UNIQVAR(idx) == (name)->count) {\
staticSliceAppendFrom(name, UNIQVAR(a), UNIQVAR(c));\
}\
else if (sizeof((name)->array[0]) == sizeof(UNIQVAR(a)[0]) /* slice compatibility and ((name)->count + UNIQVAR(c)) <= ARRAY_SIZE((name)->array)*/) {\
memmove((name)->array + UNIQVAR(idx) + UNIQVAR(c), (name)->array + UNIQVAR(idx), ((name)->count - UNIQVAR(idx)) * sizeof (name)->array[0]);\
memcpy((name)->array + UNIQVAR(idx), UNIQVAR(a), UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(c);\
}\
} while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

insert array at position index the data in staticSlice is moved and the data in array is copied to staticSlice

Definition at line 4784 of file libsheepy.h.

◆ staticSliceSlice

#define staticSliceSlice   sliceSlice

staticSlice staticSlice, keep only elements between start and end start must be between 0 and last index end must be between 1 and count the staticSlice is returned

Definition at line 4804 of file libsheepy.h.

◆ staticSliceBCopy

#define staticSliceBCopy (   name,
  dest,
  start,
  end 
)
Value:
do{\
if (sizeof((name)->array[0]) == sizeof((dest)->array[0]) /* slice compatibility and (UNIQVAR(ed) - UNIQVAR(strt)) <= ARRAY_SIZE((dest)->array)*/) {\
var UNIQVAR(strt) = start;\
var UNIQVAR(ed) = end;\
staticSliceResize(dest, UNIQVAR(ed) - UNIQVAR(strt));\
memcpy((dest)->array, (name)->array + UNIQVAR(strt), (UNIQVAR(ed) - UNIQVAR(strt)) * sizeof (name)->array[0]);\
(dest)->count = UNIQVAR(ed) - UNIQVAR(strt);\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

copy staticSlice elements between start and end to the dest staticSlice start must be between 0 and last index end must be between 1 and count

Definition at line 4811 of file libsheepy.h.

◆ staticSliceSort

#define staticSliceSort   sliceSort

sort the staticSlice the compareFunction must prototype of type: int cmp(const void * a, const void * b); the results of the compareFunction should be: <0 when a < b 0 when a = b >0 when a > b

Definition at line 4830 of file libsheepy.h.

◆ staticSliceEq

#define staticSliceEq   sliceEq

return true when staticSlice name is equal to staticSlice eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

Definition at line 4837 of file libsheepy.h.

◆ staticSliceHas

#define staticSliceHas   sliceHas

return true when staticSlice has value eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

Definition at line 4844 of file libsheepy.h.

◆ staticSliceIndexOf

#define staticSliceIndexOf   sliceIndexOf

return index (ssize_t) of value in staticSlice eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

return value is -1 when value is not found

Definition at line 4853 of file libsheepy.h.

◆ staticSliceBinarySearch

#define staticSliceBinarySearch   sliceBinarySearch

binary search value in staticSlice

efficiently finds the index of value in staticSlice the staticSlice has to be sorted before calling staticSliceBinarySearch

less is a macro taking an index and the search value returning 1 when staticSliceAt(name,index) is less than value: #define less(index, value) staticSliceAt(name, index) < value

equal is a macro returning 1 when staticSliceAt(name,index) is equal to value: #define equal(index, value) staticSliceAt(name,index) == value

return value is -1 when value is not found

Definition at line 4869 of file libsheepy.h.

◆ staticSliceUniq

#define staticSliceUniq   sliceUniq

Uniquify elements in staticSlice each elements are unique in the staticSlice.

eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

Definition at line 4878 of file libsheepy.h.

◆ vectorSz

#define vectorSz   1

vector - dynamic array in one chunk of memory (similar to slab below)

This is a simple dynamic array holding element count, maximum element count and the data

vector supports shrinking through vectorResize

this type of array has a dynamic element count pushing elements into the array increases the element count poping elements only decreases the element count, call vectorFit to resize the vector

no sanity checks are done

the prefix is vector

Usage:

to declare a vector:

vectorT(typeName, type);

typeName vectr;

vectorInit(&vectr); or vectorInitCount(&vectr, 17);

vectorAppend(&vectr, value);

// get an element int a = vectorAt(&vectr, 0);

set vectorAt(&vectr, 1) = 3;

vectorFree(&vectr);

Vector variables: vectr.array: elements vectr.count: current element count vectr.maxCount: maximum element count allowed

Note: some functions are macros to be able to have structs as element and access the struct members directly, for example: vectorLast(chan).a = 0;number of elements added by vectorAlloc

Definition at line 4932 of file libsheepy.h.

◆ vectorT

#define vectorT (   typeName,
  elementType 
)
Value:
typedef struct {\
size_t count;\
size_t maxCount;\
elementType *array;\
} typeName
char * array[]

declares type for vector

Parameters
typeNamevector type name
elementtype of elements (int, struct, pointer...)

Definition at line 4942 of file libsheepy.h.

◆ createVector

#define createVector (   typeName,
  name 
)    ;typeName name; vectorInit(&name)

Definition at line 4950 of file libsheepy.h.

◆ createVectorCount

#define createVectorCount (   typeName,
  name,
  count 
)    ;typeName name; vectorInitCount(&name, count)

Definition at line 4952 of file libsheepy.h.

◆ createVectorClearCount

#define createVectorClearCount (   typeName,
  name,
  count 
)    ;typeName name; vectorCalloc(&name, count)

Definition at line 4954 of file libsheepy.h.

◆ createAllocateVector

#define createAllocateVector (   typeName,
  name 
)    ;typeName *name = calloc(1, sizeof(typeName))

Definition at line 4956 of file libsheepy.h.

◆ createAllocateVectorCount

#define createAllocateVectorCount (   typeName,
  name,
  count 
)    ;typeName *name = calloc(1, sizeof(typeName)); vectorInitCount(name, count)

Definition at line 4958 of file libsheepy.h.

◆ createAllocateVectorClearCount

#define createAllocateVectorClearCount (   typeName,
  name,
  count 
)    ;typeName *name = calloc(1, sizeof(typeName)); vectorCalloc(name, count)

Definition at line 4960 of file libsheepy.h.

◆ vectorTerminate

#define vectorTerminate (   name)    if (name) vectorFree(name);free(name)

Definition at line 4962 of file libsheepy.h.

◆ vectorInit

#define vectorInit (   name)
Value:
do{\
(name)->array = NULL;\
(name)->count = 0;\
(name)->maxCount = 0;\
} while(0)
char * array[]

initialize empty vector

Parameters
namevariable name for vector

Definition at line 4970 of file libsheepy.h.

◆ vectorInitCount

#define vectorInitCount (   name,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
(name)->array = malloc(UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count = 0;\
(name)->maxCount = UNIQVAR(c);\
} while(0)
char * array[]
char c
#define UNIQVAR(name)
Definition: libsheepy.h:705

initialize vector and count

Parameters
namevariable name for vector
countinitial element count for name type

Definition at line 4984 of file libsheepy.h.

◆ vectorCalloc

#define vectorCalloc (   name,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
(name)->array = calloc(UNIQVAR(c), sizeof (name)->array[0]);\
(name)->count = 0;\
(name)->maxCount = UNIQVAR(c);\
} while(0)
char * array[]
char c
#define UNIQVAR(name)
Definition: libsheepy.h:705

initialize vector and count and set vector data to 0

Parameters
namevariable name for vector
countinitial element count for name type

Definition at line 4999 of file libsheepy.h.

◆ vectorResize

#define vectorResize (   name,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
if ((name)->array) {\
/* realloc */\
(name)->array = realloc((name)->array, sizeof((name)->array[0]) * UNIQVAR(c));\
}\
else {\
/* was empty */\
(name)->array = malloc(sizeof((name)->array[0]) * UNIQVAR(c));\
}\
/* element count when shrinking */\
if (UNIQVAR(c) < (name)->count) (name)->count = UNIQVAR(c);\
(name)->maxCount = UNIQVAR(c);\
} while(0)
char * array[]
char c
#define UNIQVAR(name)
Definition: libsheepy.h:705

resize vector (even empty vectors)

Definition at line 5009 of file libsheepy.h.

◆ vectorClearResize

#define vectorClearResize (   name,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
if ((name)->array) {\
/* realloc */\
(name)->array = realloc((name)->array, sizeof((name)->array[0]) * UNIQVAR(c));\
if ((name)->count < UNIQVAR(c)) {\
/* there are new elements */\
memset(&(name)->array[(name)->count], 0, (UNIQVAR(c) - (name)->count) * sizeof (name)->array[0]);\
}\
}\
else {\
/* was empty */\
(name)->array = calloc(UNIQVAR(c), sizeof((name)->array[0]));\
}\
/* element count when shrinking */\
if (UNIQVAR(c) < (name)->count) (name)->count = UNIQVAR(c);\
(name)->maxCount = UNIQVAR(c);\
} while(0)
char * array[]
char c
#define UNIQVAR(name)
Definition: libsheepy.h:705

resize vector and clear the new elements with memset even empty vectors can be resized and cleared

Definition at line 5028 of file libsheepy.h.

◆ vectorFree

#define vectorFree   sliceFree

free the internal buffers

Parameters
namevector

Definition at line 5053 of file libsheepy.h.

◆ vectorElemType

#define vectorElemType (   name)    typeof((name)->array[0])

element type in vector

Definition at line 5058 of file libsheepy.h.

◆ vectorElemPtrType

#define vectorElemPtrType (   name)    typeof(&(name)->array[0])

element pointer type in vector

Definition at line 5063 of file libsheepy.h.

◆ vectorDup

#define vectorDup (   name)
Value:
({\
typeof(*(name)) dest;\
vectorInitCount(dest, (name)->count);\
if ((name)->array) {\
memcpy(dest->array, (name)->array, (name)->count * sizeof (name)->array[0]);\
dest->count = (name)->count;\
}\
/* return */ dest;\
})
char * array[]

duplicate vector

Definition at line 5068 of file libsheepy.h.

◆ vectorCreateNDup

#define vectorCreateNDup (   name,
  dest 
)    ;typeof(*(name)) dest; vectorInitCount(dest, (name)->count); if ((name)->array) { memcpy(dest->array, (name)->array, (name)->count * sizeof (name)->array[0]); dest->count = (name)->count;}

declare dest vector and duplicate vector

Definition at line 5080 of file libsheepy.h.

◆ vectorBDup

#define vectorBDup (   name,
  dest 
)
Value:
do{\
var UNIQVAR(dst) = dest;\
vectorResize(UNIQVAR(dst), (name)->count);\
if ((name)->array) {\
memcpy(UNIQVAR(dst)->array, (name)->array, (name)->count * sizeof (name)->array[0]);\
dest->count = (name)->count;\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

duplicate vector to already declared dest vector

Definition at line 5085 of file libsheepy.h.

◆ vectorData

#define vectorData   sliceData

direct access to underlying array

Definition at line 5097 of file libsheepy.h.

◆ vectorFrom

#define vectorFrom (   name,
  array,
  countInt 
)
Value:
do{\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (sizeof((name)->array[0]) == sizeof(*(UNIQVAR(a)))) {\
if (UNIQVAR(c) > (name)->maxCount)\
vectorResize(name, UNIQVAR(c));\
memcpy((name)->array, UNIQVAR(a), UNIQVAR(c) * sizeof UNIQVAR(a)[0]);\
(name)->count = UNIQVAR(c);\
}\
} while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

copy data from array to vector

Definition at line 5102 of file libsheepy.h.

◆ vectorClear

#define vectorClear   sliceClear

set 0 in vector elements count is unchanged

Definition at line 5117 of file libsheepy.h.

◆ vectorClearRange

#define vectorClearRange   sliceClearRange

Definition at line 5119 of file libsheepy.h.

◆ vectorEmpty

#define vectorEmpty   sliceEmpty

Empty vector Set count to 0 Allocated buffers in the vector must be freed before running vectorEmpty.

Definition at line 5126 of file libsheepy.h.

◆ vectorIsEmpty

#define vectorIsEmpty   sliceIsEmpty

is vector Empty

Definition at line 5131 of file libsheepy.h.

◆ vectorFit

#define vectorFit (   name)
Value:
do{\
if ((name)->maxCount > (name)->count) {\
vectorResize(name, (name)->count);\
}\
} while(0)

resize vector from maxCount to count

Definition at line 5136 of file libsheepy.h.

◆ vectorCount

#define vectorCount   sliceCount

return element count

Definition at line 5145 of file libsheepy.h.

◆ vectorMaxCount

#define vectorMaxCount (   name)    (name)->maxCount

return max element count

Definition at line 5150 of file libsheepy.h.

◆ vectorElemSize

#define vectorElemSize   sliceElemSize

size of vector element

Definition at line 5155 of file libsheepy.h.

◆ vectorAlloc

#define vectorAlloc (   name)
Value:
do{\
if (!(name)->array) {\
(name)->array = malloc(vectorSz * sizeof (name)->array[0]);\
(name)->maxCount = vectorSz;\
}\
else if ((name)->count == (name)->maxCount) {\
(name)->maxCount += vectorSz;\
(name)->array = realloc((name)->array, (name)->maxCount * sizeof (name)->array[0]);\
}\
} while(0)
#define vectorSz
vector - dynamic array in one chunk of memory (similar to slab below)
Definition: libsheepy.h:4932
char * array[]

allocate an element only when the vector is full

Definition at line 5161 of file libsheepy.h.

◆ vectorClearElem

#define vectorClearElem   sliceClearElem

clear (set 0) in element at index

Definition at line 5175 of file libsheepy.h.

◆ vectorPush

#define vectorPush (   name)
Value:
do {\
vectorAlloc(name);\
(name)->count++;\
} while(0)

push element and expand the vector no data (random) is set in the new element

Parameters
namevector

Definition at line 5184 of file libsheepy.h.

◆ vectorAppend

#define vectorAppend (   name,
 
)
Value:
do{\
vectorPush(name);\
vectorLast(name) = v;\
} while(0)

append element and expand the vector

Parameters
namevector
velement to push

Definition at line 5197 of file libsheepy.h.

◆ vectorClearPush

#define vectorClearPush (   name)
Value:
do{\
vectorPush(name);\
vectorClearElem(name, (name)->count - 1);\
} while(0)

push element and expand the vector the new element is cleared

Parameters
namevector

Definition at line 5210 of file libsheepy.h.

◆ vectorPop

#define vectorPop   slicePop

pop element the element count is decreased

NOTE: using comma operator to avoid warning warning: operation on ‘b.head’ may be undefined [-Wsequence-point]

Parameters
namevector

Definition at line 5226 of file libsheepy.h.

◆ vectorDelLast

#define vectorDelLast   sliceDelLast

delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used

Definition at line 5233 of file libsheepy.h.

◆ vectorPushCount

#define vectorPushCount (   name,
  countp 
)
Value:
procbegin\
u32 UNIQVAR(count) = countp;\
if (((name)->count + UNIQVAR(count)) > (name)->maxCount) {\
(name)->maxCount += UNIQVAR(count);\
(name)->array = realloc((name)->array, (name)->maxCount * sizeof (name)->array[0]);\
}\
(name)->count += UNIQVAR(count);\
procend
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

push multiple elements at once

Parameters
namevector
countpnumber of elements to add

Definition at line 5243 of file libsheepy.h.

◆ vectorSet

#define vectorSet (   name,
  index,
 
)
Value:
do{\
var UNIQVAR(idx) = index;\
if (UNIQVAR(idx) >= (name)->count) {\
/* clear and resize */\
vectorClearResize(name, UNIQVAR(idx)+1);\
}\
vectorAt(name, UNIQVAR(idx)) = v;\
} while(0)
#define UNIQVAR(name)
Definition: libsheepy.h:705

set value at index and clearResize vector when index is outside vector maxCount

Definition at line 5256 of file libsheepy.h.

◆ vectorAt

#define vectorAt   sliceAt

get / set element at index

Parameters
namevector
indexindex in array

Definition at line 5273 of file libsheepy.h.

◆ vectorPtr

#define vectorPtr   slicePtr

get pointer to element at index

Parameters
namevector
indexindex in array

Definition at line 5283 of file libsheepy.h.

◆ vectorLast

#define vectorLast   sliceLast

last element

Parameters
namevector

Definition at line 5291 of file libsheepy.h.

◆ vectorLastPtr

#define vectorLastPtr   sliceLastPtr

pointer to last element

Parameters
namevector

Definition at line 5299 of file libsheepy.h.

◆ vectorLastIndex

#define vectorLastIndex   sliceLastIndex

index of last element

Definition at line 5304 of file libsheepy.h.

◆ vectorFirst

#define vectorFirst   sliceFirst

first element

Parameters
namevector

Definition at line 5313 of file libsheepy.h.

◆ vectorWriteFilename

#define vectorWriteFilename   sliceWriteFilename

write the vector content to filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 5323 of file libsheepy.h.

◆ vectorWrite

#define vectorWrite   sliceWrite

write the vector content to disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 5332 of file libsheepy.h.

◆ vectorReadFilename

#define vectorReadFilename (   name,
  filename 
)
Value:
do {\
if (fileExists(filename)) {\
size_t UNIQVAR(sz) = fileSize(filename);\
FILE *UNIQVAR(f) = fopen(filename, "r");\
if (UNIQVAR(f)) {\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((name)->array[0])) {\
vectorPush(name);\
fread(vectorLastPtr(name), 1, sizeof((name)->array[0]), UNIQVAR(f));\
}\
fclose(UNIQVAR(f));\
}\
}\
} while(0)
smallt * i
bool fileExists(const char *filePath) MUST_CHECK
detect files and directories
Definition: libsheepy.c:4321
char * array[]
ssize_t fileSize(const char *filePath) MUST_CHECK
get file size
Definition: libsheepy.c:4369
#define vectorLastPtr
pointer to last element
Definition: libsheepy.h:5299
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a vector from filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 5341 of file libsheepy.h.

◆ vectorRead

#define vectorRead (   name,
  file 
)
Value:
do {\
fseek(file, 0 , SEEK_END);\
size_t UNIQVAR(sz) = ftell(file);\
fseek(file, 0 , SEEK_SET);\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((name)->array[0])) {\
vectorPush(name);\
fread(vectorLastPtr(name), 1, sizeof((name)->array[0]), file);\
}\
} while(0)
char ** file
smallt * i
char * array[]
#define vectorLastPtr
pointer to last element
Definition: libsheepy.h:5299
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a vector from disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 5362 of file libsheepy.h.

◆ forEachV

#define forEachV   forEachSc

loop index on vector elements

For example: forEachV(vec, i) { vectorAt(vec, i) = 0; }

Definition at line 5381 of file libsheepy.h.

◆ vectorForEach

#define vectorForEach (   name,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
for (vectorElemPtrType(name) element = vectorPtr(name, 0) ; UNIQVAR(libsheepyInternalIndex) < (name)->count ; UNIQVAR(libsheepyInternalIndex)++, element = vectorPtr(name, UNIQVAR(libsheepyInternalIndex)))
#define vectorPtr
get pointer to element at index
Definition: libsheepy.h:5283
#define vectorElemPtrType(name)
element pointer type in vector
Definition: libsheepy.h:5063
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop on vector elements element is a pointer to a value in the array

vectorForEach(&slc, e) { e->x = 0; }

Definition at line 5391 of file libsheepy.h.

◆ vectorEnumerate

#define vectorEnumerate (   name,
  index,
  element 
)
Value:
; size_t index = 0 ; \
for (vectorElemPtrType(name) element = vectorPtr(name, 0) ; index < (name)->count ; index++, element = vectorPtr(name, index))
#define vectorPtr
get pointer to element at index
Definition: libsheepy.h:5283
#define vectorElemPtrType(name)
element pointer type in vector
Definition: libsheepy.h:5063

enumerate vector elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array

vectorEnumerate(&slc, i, e) { e->x = 0; printf("vectorEnumerate %d\n", i); }

Definition at line 5406 of file libsheepy.h.

◆ vectorInject

#define vectorInject (   name,
  index 
)
Value:
do {\
var UNIQVAR(idx) = index;\
vectorPush(name);\
memmove(vectorPtr(name, UNIQVAR(idx) +1), vectorPtr(name, UNIQVAR(idx)), ((name)->count - UNIQVAR(idx)) * sizeof (name)->array[0]);\
} while(0)
char * array[]
#define vectorPtr
get pointer to element at index
Definition: libsheepy.h:5283
#define UNIQVAR(name)
Definition: libsheepy.h:705

insert an element at index the data is moved to create space for the new element to set data at the new element, use vectorAt(name, index) = value;

Definition at line 5415 of file libsheepy.h.

◆ vectorPrepend

#define vectorPrepend (   name,
 
)
Value:
do {\
vectorInject(name, 0);\
vectorAt(name, 0) = v;\
} while(0)

prepend element

Parameters
namevector
velement to prepend

Definition at line 5429 of file libsheepy.h.

◆ vectorDequeue

#define vectorDequeue   sliceDequeue

dequeue element

Parameters
namevector

Definition at line 5440 of file libsheepy.h.

◆ vectorDelFirst

#define vectorDelFirst   sliceDelFirst

delete first element in vector the data is moved when count > 1

Definition at line 5446 of file libsheepy.h.

◆ vectorDelElem

#define vectorDelElem   sliceDelElem

delete an element in vector the data is moved when index < (count-1) when index = count -1, the last element is deleted and no data is moved

Definition at line 5454 of file libsheepy.h.

◆ vectorDel

#define vectorDel   sliceDel

delete range in vector start must be between 0 and last index end must be between 1 and count

Definition at line 5461 of file libsheepy.h.

◆ vectorVAppend

#define vectorVAppend (   name,
  vector 
)
Value:
do {\
var UNIQVAR(vec) = vector;\
if (sizeof((name)->array[0]) == sizeof((UNIQVAR(vec))->array[0])) {\
if (((name)->count + (UNIQVAR(vec))->count) > (name)->maxCount)\
vectorResize(name, (name)->count + (UNIQVAR(vec))->count);\
memcpy((name)->array + (name)->count, (UNIQVAR(vec))->array, (UNIQVAR(vec))->count * sizeof (name)->array[0]);\
(name)->count += (UNIQVAR(vec))->count;\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

append vector to vector name the data is copied

Definition at line 5467 of file libsheepy.h.

◆ vectorAppendFrom

#define vectorAppendFrom (   name,
  array,
  countInt 
)
Value:
do {\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (sizeof((name)->array[0]) == sizeof(*(UNIQVAR(a)))) {\
if (((name)->count + UNIQVAR(c)) > (name)->maxCount)\
vectorResize(name, (name)->count + UNIQVAR(c));\
memcpy((name)->array + (name)->count, UNIQVAR(a), UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(c);\
}\
} while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

append array to vector the data is copied

Definition at line 5481 of file libsheepy.h.

◆ vectorVPrepend

#define vectorVPrepend (   name,
  vector 
)
Value:
do {\
var UNIQVAR(vec) = vector;\
if (sizeof((name)->array[0]) == sizeof((UNIQVAR(vec))->array[0])) {\
if (((name)->count + (UNIQVAR(vec))->count) > (name)->maxCount)\
vectorResize(name, (name)->count + (UNIQVAR(vec))->count);\
memmove((name)->array + (UNIQVAR(vec))->count, (name)->array, (name)->count * sizeof (name)->array[0]);\
memcpy((name)->array, (UNIQVAR(vec))->array, (UNIQVAR(vec))->count * sizeof (name)->array[0]);\
(name)->count += (UNIQVAR(vec))->count;\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

prepend vector to vector name the data in vector name is moved and the data in vector is copied to vector name

Definition at line 5497 of file libsheepy.h.

◆ vectorPrependFrom

#define vectorPrependFrom (   name,
  array,
  countInt 
)
Value:
do {\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (sizeof((name)->array[0]) == sizeof(*(UNIQVAR(a)))) {\
if (((name)->count + UNIQVAR(c)) > (name)->maxCount)\
vectorResize(name, (name)->count + UNIQVAR(c));\
memmove((name)->array + UNIQVAR(c), (name)->array, (name)->count * sizeof (name)->array[0]);\
memcpy((name)->array, UNIQVAR(a), UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(c);\
}\
} while(0);
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

prepend array to vector the data in vector is moved and the data in array is copied to vector

Definition at line 5513 of file libsheepy.h.

◆ vectorInsert

#define vectorInsert (   name,
  index,
  vector 
)
Value:
do {\
var UNIQVAR(idx) = index;\
var UNIQVAR(vec) = vector;\
if (UNIQVAR(idx) == (name)->count) {\
vectorAppend(name, UNIQVAR(vec));\
}\
else if (sizeof((name)->array[0]) == sizeof((UNIQVAR(vec))->array[0])) {\
if (((name)->count + (UNIQVAR(vec))->count) > (name)->maxCount)\
vectorResize(name, (name)->count + (UNIQVAR(vec))->count);\
memmove((name)->array + UNIQVAR(idx) + (UNIQVAR(vec))->count, (name)->array + UNIQVAR(idx), ((name)->count - UNIQVAR(idx)) * sizeof (name)->array[0]);\
memcpy((name)->array + UNIQVAR(idx), (UNIQVAR(vec))->array, (UNIQVAR(vec))->count * sizeof (name)->array[0]);\
(name)->count += (UNIQVAR(vec))->count;\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

insert vector at position index the data in vector name is moved and the data in vector is copied to vector name

Definition at line 5530 of file libsheepy.h.

◆ vectorInsertFrom

#define vectorInsertFrom (   name,
  index,
  array,
  countInt 
)
Value:
do {\
var UNIQVAR(idx) = index;\
var UNIQVAR(c) = countInt;\
var UNIQVAR(a) = array;\
if (UNIQVAR(idx) == (name)->count) {\
vectorAppendFrom(name, UNIQVAR(a), UNIQVAR(c));\
}\
else if (sizeof((name)->array[0]) == sizeof(UNIQVAR(a)[0])) {\
if (((name)->count + UNIQVAR(c)) > (name)->maxCount)\
vectorResize(name, (name)->count + UNIQVAR(c));\
memmove((name)->array + UNIQVAR(idx) + UNIQVAR(c), (name)->array + UNIQVAR(idx), ((name)->count - UNIQVAR(idx)) * sizeof (name)->array[0]);\
memcpy((name)->array + UNIQVAR(idx), UNIQVAR(a), UNIQVAR(c) * sizeof (name)->array[0]);\
(name)->count += UNIQVAR(c);\
}\
} while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

insert array at position index the data in vector is moved and the data in array is copied to vector

Definition at line 5550 of file libsheepy.h.

◆ vectorSlice

#define vectorSlice   sliceSlice

slice vector, keep only elements between start and end start must be between 0 and last index end must be between 1 and count the vector is returned

Definition at line 5572 of file libsheepy.h.

◆ vectorCopy

#define vectorCopy (   name,
  start,
  end 
)
Value:
({\
var UNIQVAR(strt) = start;\
var UNIQVAR(ed) = end;\
createAllocateVectorCount(typeof(*(name)),UNIQVAR(r), UNIQVAR(ed) - UNIQVAR(strt));\
memcpy(UNIQVAR(r)->array, (name)->array + UNIQVAR(strt), (UNIQVAR(ed) - UNIQVAR(strt)) * sizeof (name)->array[0]);\
UNIQVAR(r)->count = UNIQVAR(ed) - UNIQVAR(strt);\
UNIQVAR(r);\
})
char * array[]
bool r
#define UNIQVAR(name)
Definition: libsheepy.h:705

copy vector elements between start and end to a new vector start must be between 0 and last index end must be between 1 and count the new vector is returned and must be freed with vectorTerminate

Definition at line 5580 of file libsheepy.h.

◆ vectorBCopy

#define vectorBCopy (   name,
  dest,
  start,
  end 
)
Value:
do{\
if (sizeof((name)->array[0]) == sizeof((dest)->array[0])) {\
var UNIQVAR(strt) = start;\
var UNIQVAR(ed) = end;\
if ((UNIQVAR(ed) - UNIQVAR(strt)) > (dest)->maxCount)\
vectorResize(dest, UNIQVAR(ed) - UNIQVAR(strt));\
memcpy((dest)->array, (name)->array + UNIQVAR(strt), (UNIQVAR(ed) - UNIQVAR(strt)) * sizeof (name)->array[0]);\
(dest)->count = UNIQVAR(ed) - UNIQVAR(strt);\
}\
} while(0)
char * array[]
#define UNIQVAR(name)
Definition: libsheepy.h:705

copy vector elements between start and end to the dest vector start must be between 0 and last index end must be between 1 and count

Definition at line 5594 of file libsheepy.h.

◆ vectorSort

#define vectorSort   sliceSort

sort the vector the compareFunction must prototype of type: int cmp(const void * a, const void * b); the results of the compareFunction should be: <0 when a < b 0 when a = b >0 when a > b

Definition at line 5614 of file libsheepy.h.

◆ vectorEq

#define vectorEq   sliceEq

return true when vector name is equal to vector eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

Definition at line 5621 of file libsheepy.h.

◆ vectorHas

#define vectorHas   sliceHas

return true when vector has value eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

Definition at line 5628 of file libsheepy.h.

◆ vectorIndexOf

#define vectorIndexOf   sliceIndexOf

return index (ssize_t) of value in vector eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

return value is -1 when value is not found

Definition at line 5637 of file libsheepy.h.

◆ vectorBinarySearch

#define vectorBinarySearch   sliceBinarySearch

binary search value in vector

efficiently finds the index of value in vector the vector has to be sorted before calling vectorBinarySearch

less is a macro taking an index and the search value returning 1 when vectorAt(name,index) is less than value: #define less(index, value) vectorAt(name, index) < value

equal is a macro returning 1 when vectorAt(name,index) is equal to value: #define equal(index, value) vectorAt(name,index) == value

return value is -1 when value is not found

Definition at line 5653 of file libsheepy.h.

◆ vectorUniq

#define vectorUniq   sliceUniq

Uniquify elements in vector each elements are unique in the vector.

eqFunction should return true when the elements are equal eqFunction can be either a macro or a function

Definition at line 5662 of file libsheepy.h.

◆ dVectorBits

#define dVectorBits   6

dynamic segmented vector

this type of array is faster than vector when there are many elements and has a dynamic element count pushing elements into the array increases the element count the data is stored in static array segments

no sanity checks are done

usage examples: regular array, stack

the prefix is dVector

Usage:

to declare an array:

dVectorT(typeName, type);

typeName dvector;

dVectorInit(&dvector); or dVectorInitCount(&dvector, 17);

dVectorAppend(&dvector, value);

// get an element int a = dVectorAt(&dvector, 0);

set dVectorAt(&dvector, 1) = 3;

dVectorFree(&dvector);

dVector variables: dvector.maxCount: maximum element count allowed

Note: dont combine the macros, it gives wrong results: a = dVectorAt(&dvector, dVectorPop(&dvector2)); dVectorPop is run several time, more than one element is popped

Note: some functions are macros to be able to have structs as element and access the struct members directly, for example: dVectorLast(chan).a = 0; chunk size: 2^dVectorBits elements

Definition at line 5720 of file libsheepy.h.

◆ dVectorSz

#define dVectorSz   (1<<dVectorBits)

Definition at line 5723 of file libsheepy.h.

◆ dVectorMask

#define dVectorMask   (dVectorSz-1)

Definition at line 5724 of file libsheepy.h.

◆ dVectorT

#define dVectorT (   typeName,
  elementType 
)
Value:
typedef struct {\
int64_t count;\
int64_t maxCount;\
void** buffers;\
elementType element;\
} typeName

declares type for dynamic array

Parameters
typeNamedVector type name
elementtype of elements (int, struct, pointer...)

Definition at line 5734 of file libsheepy.h.

◆ createDVector

#define createDVector (   typeName,
  name 
)    ;typeName name; dVectorInit(&name)

Definition at line 5743 of file libsheepy.h.

◆ createDVectorCount

#define createDVectorCount (   typeName,
  name,
  count 
)    ;typeName name; dVectorInitCount(&name, count)

Definition at line 5745 of file libsheepy.h.

◆ dVectorInit

#define dVectorInit (   a)
Value:
do{\
(a)->count = 0;\
(a)->buffers = malloc(sizeof(void*));\
(a)->buffers[0] = malloc(dVectorSz * sizeof((a)->element));\
(a)->maxCount = 1;\
}while(0)
smallArrayt * a
#define dVectorSz
Definition: libsheepy.h:5723

initialize dynamic array with minimum element count

Parameters
avariable name for dVector

Definition at line 5753 of file libsheepy.h.

◆ dVectorInitCount

#define dVectorInitCount (   a,
  count 
)
Value:
do{\
dVectorInit(a);\
if (count > dVectorSz) {\
(a)->buffers = realloc((a)->buffers, ((count>>dVectorBits)+1) * sizeof(void*));\
rangeFrom(UNIQVAR(i), 1, (count>>dVectorBits)+1) {\
(a)->buffers[UNIQVAR(i)] = malloc(dVectorSz * sizeof((a)->element));\
}\
(a)->maxCount = (count>>dVectorBits)+1;\
}\
}while(0)
smallt * i
#define dVectorBits
dynamic segmented vector
Definition: libsheepy.h:5720
smallArrayt * a
#define dVectorSz
Definition: libsheepy.h:5723
#define UNIQVAR(name)
Definition: libsheepy.h:705

initialize dynamic array and count

Parameters
avariable name for dVector
countinitial element count for name type

Definition at line 5769 of file libsheepy.h.

◆ dVectorResize

#define dVectorResize (   a,
  count 
)
Value:
do{\
if (count > (a)->maxCount * dVectorSz) {\
/* grow array */\
(a)->buffers = realloc((a)->buffers, ((count>>dVectorBits)+1) * sizeof(void*));\
rangeFrom(UNIQVAR(i), (a)->maxCount, (count>>dVectorBits)+1) {\
(a)->buffers[UNIQVAR(i)] = malloc(dVectorSz * sizeof((a)->element));\
}\
(a)->maxCount = (count>>dVectorBits)+1;\
}\
/*else TODO dVector shrink */\
}while(0)
smallt * i
#define dVectorBits
dynamic segmented vector
Definition: libsheepy.h:5720
smallArrayt * a
#define dVectorSz
Definition: libsheepy.h:5723
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 5780 of file libsheepy.h.

◆ dVectorFree

#define dVectorFree (   a)
Value:
do{\
range(UNIQVAR(i), (size_t)(a)->maxCount) {\
free((a)->buffers[UNIQVAR(i)]);\
}\
free((a)->buffers);\
}while(0)
smallt * i
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

free the internal buffers

Parameters
adynamic array

Definition at line 5798 of file libsheepy.h.

◆ dVectorElemType

#define dVectorElemType (   name)    typeof((name)->element)

element type in vector

Definition at line 5808 of file libsheepy.h.

◆ dVectorElemPtrType

#define dVectorElemPtrType (   name)    typeof(&(name)->element)

element pointer type in vector

Definition at line 5813 of file libsheepy.h.

◆ dVectorEmpty

#define dVectorEmpty (   name)    (name)->count = 0

Empty Array Allocated buffers in the array must be freed before running dVectorEmpty.

Definition at line 5819 of file libsheepy.h.

◆ dVectorIsEmpty

#define dVectorIsEmpty (   name)    ((name)->count == 0)

is Array Empty

Definition at line 5824 of file libsheepy.h.

◆ dVectorCount

#define dVectorCount (   name)    (name)->count

return element count

Definition at line 5829 of file libsheepy.h.

◆ dVectorMaxCount

#define dVectorMaxCount (   name)    ((name)->maxCount * dVectorSz)

return max element count

Definition at line 5834 of file libsheepy.h.

◆ dVectorAlloc

#define dVectorAlloc (   a)
Value:
do{\
if ((a)->count == dVectorMaxCount(a)) {\
(a)->maxCount++;\
(a)->buffers = realloc((a)->buffers, (a)->maxCount * sizeof(void*));\
(a)->buffers[(a)->maxCount-1] = malloc(dVectorSz * sizeof((a)->element));\
}\
}while(0)
#define dVectorMaxCount(name)
return max element count
Definition: libsheepy.h:5834
smallArrayt * a
#define dVectorSz
Definition: libsheepy.h:5723

allocate buffer for new elements only when the array is full

Parameters
adynamic array

Definition at line 5843 of file libsheepy.h.

◆ dVectorPush

#define dVectorPush (   a)
Value:
do{\
dVectorAlloc(a);\
(a)->count++;\
}while(0)
smallArrayt * a

push element and expand the dynamic array no data (random) is set in the new element.

Parameters
adynamic array
velement to push

Definition at line 5860 of file libsheepy.h.

◆ dVectorAppend

#define dVectorAppend (   a,
 
)
Value:
do{\
dVectorAlloc(a);\
if ((a)->count < dVectorMaxCount(a)) {\
typeof((a)->element) *UNIQVAR(buffer) = (a)->buffers[((a)->count)>>dVectorBits];\
*(UNIQVAR(buffer)+ (((a)->count)&dVectorMask)) = v;\
(a)->count++;\
}\
}while(0)
#define dVectorMask
Definition: libsheepy.h:5724
#define dVectorMaxCount(name)
return max element count
Definition: libsheepy.h:5834
#define dVectorBits
dynamic segmented vector
Definition: libsheepy.h:5720
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

append element and expand the dynamic array

Parameters
adynamic array
velement to push

Definition at line 5873 of file libsheepy.h.

◆ dVectorPop

#define dVectorPop (   a)    ((a)->count--, *((typeof((a)->element)*)((a)->buffers[((a)->count)>>dVectorBits])+(((a)->count)&dVectorMask)))

pop element the index of the last element is decreased

NOTE: using comma operator to avoid warning warning: operation on ‘b.head’ may be undefined [-Wsequence-point]

Parameters
adynamic array

Definition at line 5893 of file libsheepy.h.

◆ dVectorDelLast

#define dVectorDelLast (   a)    ((a)->count--)

delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used

Definition at line 5900 of file libsheepy.h.

◆ dVectorAt

#define dVectorAt (   a,
  index 
)    (*((typeof((a)->element)*)((a)->buffers[(index)>>dVectorBits])+((index)&dVectorMask)))

get / set element at index

Parameters
adynamic array
indexindex in array

Definition at line 5916 of file libsheepy.h.

◆ dVectorPtr

#define dVectorPtr (   a,
  index 
)    ((typeof((a)->element)*)((a)->buffers[(index)>>dVectorBits])+((index)&dVectorMask))

get pointer to element at index

Parameters
adynamic array
indexindex in array

Definition at line 5926 of file libsheepy.h.

◆ dVectorLast

#define dVectorLast (   a)    (*((typeof((a)->element)*)((a)->buffers[((a)->count-1)>>dVectorBits])+(((a)->count-1)&dVectorMask)))

last element

Parameters
adynamic array

Definition at line 5934 of file libsheepy.h.

◆ dVectorLastPtr

#define dVectorLastPtr (   a)    ((typeof((a)->element)*)((a)->buffers[((a)->count-1)>>dVectorBits])+(((a)->count-1)&dVectorMask))

pointer to last element

Parameters
adynamic array

Definition at line 5942 of file libsheepy.h.

◆ dVectorLastIndex

#define dVectorLastIndex (   a)    ((a)->count-1)

index of last element

Definition at line 5947 of file libsheepy.h.

◆ dVectorFirst

#define dVectorFirst (   a)    (*((typeof((a)->element)*)((a)->buffers[0])))

first element

Parameters
adynamic array

Definition at line 5955 of file libsheepy.h.

◆ dVectorWriteFilename

#define dVectorWriteFilename (   a,
  filename 
)
Value:
do {\
FILE *UNIQVAR(f) = fopen(filename, "w");\
if (UNIQVAR(f)) {\
range(UNIQVAR(i), (size_t)dVectorCount(a)) {\
typeof((a)->element) *firstElement = (a)->buffers[UNIQVAR(i)/dVectorSz];\
fwrite(firstElement+(UNIQVAR(i)%dVectorSz), 1, sizeof((a)->element), UNIQVAR(f));\
}\
fclose(UNIQVAR(f));\
}\
} while(0)
smallt * i
smallArrayt * a
#define dVectorSz
Definition: libsheepy.h:5723
#define dVectorCount(name)
return element count
Definition: libsheepy.h:5829
#define UNIQVAR(name)
Definition: libsheepy.h:705

write the dVector content to filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 5964 of file libsheepy.h.

◆ dVectorWrite

#define dVectorWrite (   a,
  file 
)
Value:
do {\
range(UNIQVAR(i), (size_t)dVectorCount(a)) {\
typeof((a)->element) *firstElement = (a)->buffers[UNIQVAR(i)/dVectorSz];\
fwrite(firstElement+(UNIQVAR(i)%dVectorSz), 1, sizeof((a)->element), file);\
}\
} while(0)
char ** file
smallt * i
smallArrayt * a
#define dVectorSz
Definition: libsheepy.h:5723
#define dVectorCount(name)
return element count
Definition: libsheepy.h:5829
#define UNIQVAR(name)
Definition: libsheepy.h:705

write the dVector content to disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 5982 of file libsheepy.h.

◆ dVectorReadFilename

#define dVectorReadFilename (   a,
  filename 
)
Value:
do {\
if (fileExists(filename)) {\
size_t UNIQVAR(sz) = fileSize(filename);\
FILE *UNIQVAR(f) = fopen(filename, "r");\
if (UNIQVAR(f)) {\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((a)->element)) {\
dVectorPush(a);\
fread(dVectorLastPtr(a), 1, sizeof((a)->element), UNIQVAR(f));\
}\
fclose(UNIQVAR(f));\
}\
}\
} while(0)
smallt * i
bool fileExists(const char *filePath) MUST_CHECK
detect files and directories
Definition: libsheepy.c:4321
smallArrayt * a
#define dVectorLastPtr(a)
pointer to last element
Definition: libsheepy.h:5942
ssize_t fileSize(const char *filePath) MUST_CHECK
get file size
Definition: libsheepy.c:4369
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a dVector from filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 5996 of file libsheepy.h.

◆ dVectorRead

#define dVectorRead (   a,
  file 
)
Value:
do {\
fseek(file, 0 , SEEK_END);\
size_t UNIQVAR(sz) = ftell(file);\
fseek(file, 0 , SEEK_SET);\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((a)->element)) {\
dVectorPush(a);\
fread(dVectorLastPtr(a), 1, sizeof((a)->element), file);\
}\
} while(0)
char ** file
smallt * i
smallArrayt * a
#define dVectorLastPtr(a)
pointer to last element
Definition: libsheepy.h:5942
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a dVector from disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 6017 of file libsheepy.h.

◆ dVectorForEach

#define dVectorForEach (   name,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
for (dVectorElemPtrType(name) element = dVectorPtr(name, 0) ; UNIQVAR(libsheepyInternalIndex) < (name)->count ; UNIQVAR(libsheepyInternalIndex)++, element = dVectorPtr(name, UNIQVAR(libsheepyInternalIndex)))
#define dVectorElemPtrType(name)
element pointer type in vector
Definition: libsheepy.h:5813
#define dVectorPtr(a, index)
get pointer to element at index
Definition: libsheepy.h:5926
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop on dVector elements element is a pointer to a value in the array

dVectorForEach(&vec, e) { e->x = 0; }

Definition at line 6035 of file libsheepy.h.

◆ dVectorEnumerate

#define dVectorEnumerate (   name,
  index,
  element 
)
Value:
; size_t index = 0 ; \
for (dVectorElemPtrType(name) element = dVectorPtr(name, 0) ; index < (name)->count ; index++, element = dVectorPtr(name, index))
#define dVectorElemPtrType(name)
element pointer type in vector
Definition: libsheepy.h:5813
#define dVectorPtr(a, index)
get pointer to element at index
Definition: libsheepy.h:5926

enumerate dVector elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array

dVectorEnumerate(&vec, i, e) { e->x = 0; printf("dVectorEnumerate %d\n", i); }

Definition at line 6050 of file libsheepy.h.

◆ staticArrayT

#define staticArrayT (   typeName,
  element,
  MAXCOUNT 
)
Value:
typedef struct {\
i64 last;\
i64 head;\
i64 maxCount;\
bool isEmpty;\
element list[MAXCOUNT];\
} typeName;

declares type for staticArray or ring

Parameters
typeNamestaticArray/ring type name
elementtype of elements (int, struct, pointer...)
MAXCOUNTarray/ring buffer size

Definition at line 6124 of file libsheepy.h.

◆ createStaticArray

#define createStaticArray (   typeName,
  name 
)    ;typeName name; staticArrayInit(name)

Definition at line 6133 of file libsheepy.h.

◆ staticArrayInit

#define staticArrayInit (   name)
Value:
do{\
(name).last = (name).head = 0;\
(name).maxCount = COUNT_ELEMENTS((name).list);\
(name).isEmpty = true;\
} while(0);
#define COUNT_ELEMENTS(arr)
Definition: libsheepy.h:472

initialize count in array/static ring this macro can initialize rings if the struct is accessed directly

Parameters
namevariable name for staticArray

Definition at line 6142 of file libsheepy.h.

◆ staticArrayElemType

#define staticArrayElemType (   name)    typeof((name).list[0])

element type in array

Definition at line 6152 of file libsheepy.h.

◆ staticArrayElemPtrType

#define staticArrayElemPtrType (   name)    typeof(&(name).list[0])

element pointer type in array

Definition at line 6157 of file libsheepy.h.

◆ staticArrayEmpty

#define staticArrayEmpty (   name)
Value:
do{\
(name).last = (name).head = 0;\
(name).isEmpty = true;\
} while(0);

Empty Array Allocated buffers in the list must be freed before running staticArrayEmpty.

Definition at line 6163 of file libsheepy.h.

◆ staticArrayIsEmpty

#define staticArrayIsEmpty (   name)    ((name).isEmpty)

is Array Empty

Definition at line 6172 of file libsheepy.h.

◆ staticArrayIsFull

#define staticArrayIsFull (   name)    ((name).isEmpty ? 0 : ((((name).last+1) % (name).maxCount) == (name).head))

is Array Full

Definition at line 6177 of file libsheepy.h.

◆ staticArrayCount

#define staticArrayCount (   name)    ((name).isEmpty ? 0 : ((((name).last) >= ((name).head)) ? ((name).last-(name).head+1) : (((name).maxCount-(name).head + (name).last+1))) )

return elements count

Definition at line 6182 of file libsheepy.h.

◆ staticArrayPush

#define staticArrayPush (   name)
Value:
do{\
if ((name).isEmpty) {\
(name).isEmpty = false;\
}\
else {\
(name).last++;\
(name).last %= (name).maxCount;\
}\
} while(0);

push element to array (only increases last) use staticArrayLast to access the element

Definition at line 6188 of file libsheepy.h.

◆ staticArrayPop

#define staticArrayPop (   name)
Value:
do{\
if (!(name).isEmpty && ((name).last == (name).head)) {\
(name).isEmpty = true;\
}\
else if (!(name).isEmpty && ((name).last != (name).head)) {\
if ((name).last)\
(name).last--;\
else\
(name).last+=(name).maxCount-1;\
}\
} while(0);

pop element from array (only decreases last)

Definition at line 6202 of file libsheepy.h.

◆ staticArrayDelLast

#define staticArrayDelLast   staticArrayPop

Definition at line 6215 of file libsheepy.h.

◆ staticArrayPrepend

#define staticArrayPrepend (   name)
Value:
do{\
if ((name).isEmpty) {\
(name).isEmpty = false;\
}\
else {\
if ((name).head)\
(name).head--;\
else\
(name).head+=(name).maxCount-1;\
}\
} while(0);

prepend element to array (only decreases head) use staticArrayFirst to access the element

Definition at line 6221 of file libsheepy.h.

◆ staticArrayDequeue

#define staticArrayDequeue (   name)
Value:
do{\
if (!(name).isEmpty && ((name).last == (name).head)) {\
(name).isEmpty = true;\
}\
else if (!(name).isEmpty && ((name).last != (name).head)) {\
(name).head++;\
(name).head %= (name).maxCount;\
}\
} while(0);

dequeue element from array (only increases head)

Definition at line 6237 of file libsheepy.h.

◆ staticArrayDelFirst

#define staticArrayDelFirst   staticArrayDequeue

Definition at line 6248 of file libsheepy.h.

◆ staticArrayGet

#define staticArrayGet (   name,
  index 
)    (name).list[(((index) >= 0) ? (index) : staticArrayCount(name) + (index) )]

get element at index, negative index is supported

Definition at line 6253 of file libsheepy.h.

◆ staticArrayAt

#define staticArrayAt   staticArrayGet

Definition at line 6254 of file libsheepy.h.

◆ staticArrayGetIndex

#define staticArrayGetIndex (   name,
  index 
)    ((((index) >= 0) ? (index) : staticArrayCount(name) + (index) ))

index of element for an index relative to 0, negative index is supported

Definition at line 6259 of file libsheepy.h.

◆ staticArrayRef

#define staticArrayRef (   name,
  index 
)    (name).list[((((index) >= 0) ? (index) : staticArrayCount(name) + (index) ) + name.head) % name.maxCount]

get element at index with name->head index 0, negative index is supported

Definition at line 6264 of file libsheepy.h.

◆ staticArrayRefIndex

#define staticArrayRefIndex (   name,
  index 
)    (((((index) >= 0) ? (index) : staticArrayCount(name) + (index) ) + name.head) % name.maxCount)

index of element for an index relative to head, negative index is supported

Definition at line 6269 of file libsheepy.h.

◆ staticArrayLast

#define staticArrayLast (   name)    (name).list[(name).last]

last element in array

Definition at line 6274 of file libsheepy.h.

◆ staticArrayLastIndex

#define staticArrayLastIndex (   name)    (name).last

index of last element

Definition at line 6279 of file libsheepy.h.

◆ staticArrayFirst

#define staticArrayFirst (   name)    (name).list[(name).head]

first element in array

Definition at line 6284 of file libsheepy.h.

◆ staticArrayFirstIndex

#define staticArrayFirstIndex (   name)    (name).head

index of first element

Definition at line 6289 of file libsheepy.h.

◆ staticArrayDelElem

#define staticArrayDelElem (   name,
  index 
)
Value:
do {\
if ((name).head < (name).last) {\
/* move elements after index in latest static array */\
if (index < (name).last) {\
memmove(&(name).list[index], &(name).list[index+1], ((name).last - index) * sizeof((name).list[0]));\
}\
}\
elif ((name).head > (name).last) {\
if (index >= (name).head) {\
/* move elements after index in latest static array */\
if (index < (name).maxCount - 1) {\
memmove(&(name).list[index], &(name).list[index+1], ((name).maxCount - index -1) * sizeof((name).list[0]));\
}\
/* move list[0] to list[maxCount-1] */\
/* then shift elements in [1..last+1] to [0..last] if needed */\
staticArrayAt((name), (name).maxCount-1) = staticArrayAt((name), 0);\
if ((name).last > 0) {\
memmove(&(name).list[0], &(name).list[1], (name).last * sizeof((name).list[0]));\
}\
}\
else {\
/* 0 < index < last+1 */\
/* move elements after index in latest static array */\
if (index < (name).last) {\
memmove(&(name).list[index], &(name).list[index+1], ((name).last - index) * sizeof((name).list[0]));\
}\
}\
}\
staticArrayDelLast((name));\
} while(0)
#define staticArrayAt
Definition: libsheepy.h:6254

delete an element in the array and move elements after it to fill the gap

Definition at line 6294 of file libsheepy.h.

◆ staticArrayWriteFilename

#define staticArrayWriteFilename (   name,
  filename 
)
Value:
do {\
FILE *UNIQVAR(f) = fopen(filename, "w");\
if (UNIQVAR(f)) {\
if ((name).head <= (name).last) {\
fwrite(&((name).list[(name).head]), 1, (size_t)staticArrayCount(name) * sizeof((name).list[0]), UNIQVAR(f));\
} else {\
/* write from head to maxcount and then from 0 to last*/\
fwrite(&((name).list[(name).head]), 1, (size_t)((name).maxCount - (name).head) * sizeof((name).list[0]), UNIQVAR(f));\
fwrite(&((name).list[(name).head])+((name).maxCount - (name).head), 1, (size_t)((name).last+1) * sizeof((name).list[0]), UNIQVAR(f));\
}\
fclose(UNIQVAR(f));\
}\
} while(0)
#define staticArrayCount(name)
return elements count
Definition: libsheepy.h:6182
#define UNIQVAR(name)
Definition: libsheepy.h:705

write the staticArray content to filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 6332 of file libsheepy.h.

◆ staticArrayWrite

#define staticArrayWrite (   name,
  file 
)
Value:
do {\
if ((name).head <= (name).last) {\
fwrite(&((name).list[(name).head]), 1, (size_t)staticArrayCount(name) * sizeof((name).list[0]), file);\
} else {\
/* write from head to maxcount and then from 0 to last*/\
fwrite(&((name).list[(name).head]), 1, (size_t)((name).maxCount - (name).head) * sizeof((name).list[0]), file);\
fwrite(&((name).list[(name).head])+((name).maxCount - (name).head), 1, (size_t)((name).last+1) * sizeof((name).list[0]), file);\
}\
} while(0)
char ** file
#define staticArrayCount(name)
return elements count
Definition: libsheepy.h:6182

write the staticArray content to disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 6353 of file libsheepy.h.

◆ staticArrayReadFilename

#define staticArrayReadFilename (   name,
  filename 
)
Value:
do {\
if (fileExists(filename)) {\
size_t UNIQVAR(sz) = fileSize(filename);\
if (UNIQVAR(sz) > sizeof((name).list)) break;\
/* check that UNIQVAR(sz) is a multiple of sizeof((name).list[0]), if not the file data doesnt fit the array */\
if (UNIQVAR(sz) % sizeof((name).list[0])) break;\
FILE *UNIQVAR(f) = fopen(filename, "r");\
if (UNIQVAR(f)) {\
fread((name).list, 1, UNIQVAR(sz), UNIQVAR(f));\
fclose(UNIQVAR(f));\
(name).head = 0;\
if (UNIQVAR(sz)) {\
(name).last = (UNIQVAR(sz) / sizeof((name).list[0])) - 1;\
(name).isEmpty = false;\
}\
else {\
(name).last = 0;\
(name).isEmpty = true;\
}\
}\
}\
} while(0)
bool fileExists(const char *filePath) MUST_CHECK
detect files and directories
Definition: libsheepy.c:4321
ssize_t fileSize(const char *filePath) MUST_CHECK
get file size
Definition: libsheepy.c:4369
#define UNIQVAR(name)
Definition: libsheepy.h:705

read name staticArray from filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 6370 of file libsheepy.h.

◆ staticArrayRead

#define staticArrayRead (   name,
  file 
)
Value:
do {\
fseek(file, 0 , SEEK_END);\
size_t UNIQVAR(sz) = ftell(file);\
fseek(file, 0 , SEEK_SET);\
if (UNIQVAR(sz) > sizeof((name).list)) break;\
/* check that UNIQVAR(sz) is a multiple of sizeof((name).list[0]), if not the file data doesnt fit the array */\
if (UNIQVAR(sz) % sizeof((name).list[0])) break;\
fread((name).list, 1, UNIQVAR(sz), file);\
(name).head = 0;\
if (UNIQVAR(sz)) {\
(name).last = (UNIQVAR(sz) / sizeof((name).list[0])) - 1;\
(name).isEmpty = false;\
}\
else {\
(name).last = 0;\
(name).isEmpty = true;\
}\
} while(0)
char ** file
#define UNIQVAR(name)
Definition: libsheepy.h:705

read name staticArray from disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 6400 of file libsheepy.h.

◆ staticArrayForEach

#define staticArrayForEach (   name,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
for (staticArrayElemPtrType(name) element = &staticArrayRef(name, 0) ; UNIQVAR(libsheepyInternalIndex) < staticArrayCount(name) ; UNIQVAR(libsheepyInternalIndex)++, element = &staticArrayRef(name, UNIQVAR(libsheepyInternalIndex)))
#define staticArrayElemPtrType(name)
element pointer type in array
Definition: libsheepy.h:6157
#define staticArrayCount(name)
return elements count
Definition: libsheepy.h:6182
#define staticArrayRef(name, index)
get element at index with name->head index 0, negative index is supported
Definition: libsheepy.h:6264
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop on staticArray elements element is a pointer to a value in the array

staticArrayForEach(sa, e) { e->x = 0; }

Definition at line 6427 of file libsheepy.h.

◆ staticArrayEnumerate

#define staticArrayEnumerate (   name,
  index,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
; size_t index = name.head ; \
for (staticArrayElemPtrType(name) element = &staticArrayRef(name, 0) ; UNIQVAR(libsheepyInternalIndex) < staticArrayCount(name) ; UNIQVAR(libsheepyInternalIndex)++, index = (name.head + UNIQVAR(libsheepyInternalIndex)) % name.maxCount, element = &staticArrayRef(name, index))
#define staticArrayElemPtrType(name)
element pointer type in array
Definition: libsheepy.h:6157
#define staticArrayCount(name)
return elements count
Definition: libsheepy.h:6182
#define staticArrayRef(name, index)
get element at index with name->head index 0, negative index is supported
Definition: libsheepy.h:6264
#define UNIQVAR(name)
Definition: libsheepy.h:705

enumerate staticArray elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array

staticArrayEnumerate(sa, i, e) { e->x = 0; printf("staticArrayEnumerate %d\n", i); }

Definition at line 6442 of file libsheepy.h.

◆ indexer

#define indexer   staticArrayBase

indexer is a staticArray without the list It indexes an independent array

Usage:

declare an array: char array[10][5];

declare an indexer: indexer indx;

or declare an indexer with smaller counters (default is int64_t): indexerT(typeName, i8); typeName indx;

indexerInit(indx, 10);

indexerPush(indx); array[indexerLast(indx)][0] = '0';

// or indexerPush(indx); array[indx.last][0] = '0';

indexerPop(indx);

// accessing the first/head element

char c = array[indexerFirst(indx)][0]; char c = array[indx.head][0];

For pointer to indexers (idxP), use: indexerPInit, indexerPEmpty, indexerPIsEmpty, indexerPIsFull, indexerPCount, indexerPPush, indexerPPop, indexerPPrepend, indexerPDequeue, indexerPRef, indexerPLast or idxP->last, indexerPFirst or idxP->head base type, same as staticArray

Definition at line 6499 of file libsheepy.h.

◆ indexerT

#define indexerT (   typeName,
  INT_TYPE 
)
Value:
typedef struct {\
INT_TYPE last;\
INT_TYPE head;\
INT_TYPE maxCount;\
bool isEmpty;\
} typeName;

declare an indexer type with INT_TYPE counters instead of the default i64 INT_TYPE has to be signed integer

The indexers of this type are not compatible with the indexerP* functions

Definition at line 6507 of file libsheepy.h.

◆ createIndexer

#define createIndexer (   typeName,
  name,
  maxCount 
)    ;typeName name; indexerInit(name, maxCount)

Definition at line 6515 of file libsheepy.h.

◆ indexerInit

#define indexerInit (   name,
  MAXCOUNT 
)
Value:
do{\
(name).last = (name).head = 0;\
(name).maxCount = MAXCOUNT;\
(name).isEmpty = true;\
} while(0);

initialize count in array/static ring this macro can initialize rings if the struct is accessed directly

Parameters
namevariable name for staticArray
MAXCOUNTmax count for name type

Definition at line 6526 of file libsheepy.h.

◆ indexerPInit

#define indexerPInit   ringInit

Definition at line 6533 of file libsheepy.h.

◆ indexerEmpty

#define indexerEmpty   staticArrayEmpty

Empty Array Allocated buffers in the list must be freed before running staticArrayEmpty.

Definition at line 6539 of file libsheepy.h.

◆ indexerPEmpty

#define indexerPEmpty   ringEmpty

Definition at line 6540 of file libsheepy.h.

◆ indexerIsEmpty

#define indexerIsEmpty   staticArrayIsEmpty

is Array Empty

Definition at line 6545 of file libsheepy.h.

◆ indexerPIsEmpty

#define indexerPIsEmpty   ringIsEmpty

Definition at line 6546 of file libsheepy.h.

◆ indexerIsFull

#define indexerIsFull   staticArrayIsFull

is Array Full

Definition at line 6551 of file libsheepy.h.

◆ indexerPIsFull

#define indexerPIsFull   ringIsFull

Definition at line 6552 of file libsheepy.h.

◆ indexerCount

#define indexerCount   staticArrayCount

return elements count

Definition at line 6557 of file libsheepy.h.

◆ indexerPCount

#define indexerPCount   ringCount

Definition at line 6558 of file libsheepy.h.

◆ indexerPush

#define indexerPush   staticArrayPush

push element to array (only increases last) use staticArrayLast to access the element

Definition at line 6564 of file libsheepy.h.

◆ indexerPPush

#define indexerPPush   ringPush

Definition at line 6565 of file libsheepy.h.

◆ indexerPop

#define indexerPop   staticArrayPop

pop element from array (only decreases last)

Definition at line 6570 of file libsheepy.h.

◆ indexerPPop

#define indexerPPop   ringPop

Definition at line 6571 of file libsheepy.h.

◆ indexerPrepend

#define indexerPrepend   staticArrayPrepend

prepend element to array (only decreases head) use staticArrayFirst to access the element

Definition at line 6577 of file libsheepy.h.

◆ indexerPPrepend

#define indexerPPrepend   ringPrepend

Definition at line 6578 of file libsheepy.h.

◆ indexerDequeue

#define indexerDequeue   staticArrayDequeue

dequeue element from array (only increases head)

Definition at line 6583 of file libsheepy.h.

◆ indexerPDequeue

#define indexerPDequeue   ringDequeue

Definition at line 6584 of file libsheepy.h.

◆ indexerRef

#define indexerRef (   name,
  index 
)    (((((index) >= 0) ? (index) : indexerCount(name) + (index) ) + name.head) % name.maxCount)

index element at index with name->head index 0, negative index is supported

Definition at line 6589 of file libsheepy.h.

◆ indexerPRef

#define indexerPRef (   name,
  index 
)    (((((index) >= 0) ? (index) : indexerPCount(name) + (index) ) + name->head) % name->maxCount)

Definition at line 6590 of file libsheepy.h.

◆ indexerLast

#define indexerLast (   name)    name.last

index of last element in array

Definition at line 6595 of file libsheepy.h.

◆ indexerPLast

#define indexerPLast (   name)    (name)->last

Definition at line 6596 of file libsheepy.h.

◆ indexerFirst

#define indexerFirst (   name)    (name.head)

index of first element in array

Definition at line 6601 of file libsheepy.h.

◆ indexerPFirst

#define indexerPFirst (   name)    (name)->head

Definition at line 6602 of file libsheepy.h.

◆ ringBase

#define ringBase   staticArrayBase

rings usage

Make the ring type:

#define chanMax 30 // max message count in ring type chanT ringMake(chanT, int, chanMax); // ring type is chanT, list 30 of ints

Add ring to a fiber context:

typedef struct {int slot; int a; chanT *c;} AArgs;

Declare a ring of type chanT and initialize:

chanT c; ringInit(&c, chanMax);

When the ring is empty, ringLast and ringFirst are valid and equal (same index).

Send and receive data through the ring:

ringSend(ctx->c, 10); int r; if (!ringIsEmpty(ctx->c)) ringRecv(ctx->c, r);

Note: some functions are macros to be able to have structs as element and access the struct members directly, for example: ringLast(chan).a = 0; base type, same as staticArray

Definition at line 6639 of file libsheepy.h.

◆ ringMake

#define ringMake   staticArrayT

declares type for staticArray or ring staticArrayT(typeName, element, MAXCOUNT)

Parameters
typeNamestaticArray/ring type name
elementtype of elements (int, struct, pointer...) MAXCOUNT array/ring buffer size

Definition at line 6652 of file libsheepy.h.

◆ ringStaticInit

#define ringStaticInit   staticArrayInit

initialize count in array/static ring staticArrayInit(name, MAXCOUNT)

this macro can initialize rings if the struct is accessed directly

Parameters
namevariable name for ring

Definition at line 6663 of file libsheepy.h.

◆ ringGet

#define ringGet (   name,
  index 
)    (name)->list[(((index) >= 0) ? (index) : ringCount(name) + (index) )]

get element at index, negative index is supported

Definition at line 6698 of file libsheepy.h.

◆ ringRef

#define ringRef (   name,
  index 
)    (name)->list[((((index) >= 0) ? (index) : ringCount(name) + (index) ) + name->head) % name->maxCount]

get element at index with name->head index 0, negative index is supported

Definition at line 6703 of file libsheepy.h.

◆ ringLast

#define ringLast (   name)    (name)->list[(name)->last]

last element in ring

Definition at line 6708 of file libsheepy.h.

◆ ringLastIndex

#define ringLastIndex (   name)    (name)->last

index of last element

Definition at line 6713 of file libsheepy.h.

◆ ringFirst

#define ringFirst (   name)    (name)->list[(name)->head]

last element in ring

Definition at line 6718 of file libsheepy.h.

◆ ringSend

#define ringSend (   name,
  value 
)
Value:
do {\
if (ringPush(name) >= 0) ringLast(name) = value;\
} while(0);
#define ringLast(name)
last element in ring
Definition: libsheepy.h:6708
in value value
i64 ringPush(void *ring)
push element to ring (only increases last, use ringSend) use ringLast to access the element ...
Definition: libsheepy.c:57186

send data in ring

Parameters
namevariable name for ring
valuedata

Definition at line 6729 of file libsheepy.h.

◆ ringSendSt

#define ringSendSt (   status,
  name,
  value 
)
Value:
do {\
if ((status = ringPush(name)) >= 0) ringLast(name) = value;\
} while(0);
#define ringLast(name)
last element in ring
Definition: libsheepy.h:6708
in value value
i64 ringPush(void *ring)
push element to ring (only increases last, use ringSend) use ringLast to access the element ...
Definition: libsheepy.c:57186

Definition at line 6735 of file libsheepy.h.

◆ ringRecv

#define ringRecv (   name,
  result 
)
Value:
do {\
result = ringFirst(name);\
ringDequeue(name);\
} while(0);
#define ringFirst(name)
last element in ring
Definition: libsheepy.h:6718

receive data from ring

Parameters
namevariable name for ring
resultpreviously declared variable to store the data

Definition at line 6749 of file libsheepy.h.

◆ ringRecvSt

#define ringRecvSt (   status,
  name,
  result 
)
Value:
do {\
if ((status = ringIsEmpty(name)) == 0) {\
result = ringFirst(name);\
ringDequeue(name);\
}\
} while(0);
#define ringFirst(name)
last element in ring
Definition: libsheepy.h:6718
int ringIsEmpty(void *ring)
1 when empty 0 not empty -1 error
Definition: libsheepy.c:57121

Definition at line 6756 of file libsheepy.h.

◆ tCount

#define tCount   10

Definition at line 6820 of file libsheepy.h.

◆ fiberCtx

#define fiberCtx (   thisSlot)    fibers.context[thisSlot]

get fiber context for thisSlot

Definition at line 6869 of file libsheepy.h.

◆ startJump

#define startJump (   func)
Value:
if (!setjmp(fibers.jumpBuffers[0])) {\
func;\
}
fibersT fibers
data for fiber system
Definition: libsheepy.c:57307
jmp_buf jumpBuffers[tCount]
setjmp buffers for fibers
Definition: libsheepy.h:6842

fibers with setjmp (not ucontext) internal

startJump starts another fiber slot is the index in fiberJumpBuffers for current fiber func is the fiber to start

the first fiber has to finish last

Definition at line 6896 of file libsheepy.h.

◆ yield

#define yield (   slotValue,
  slot 
)
Value:
if (!(slotValue = setjmp(fibers.jumpBuffers[slot]))) {\
staticArrayPush(fibers.L);\
staticArrayLast(fibers.L) = slot;\
longjmp(fibers.jumpBuffers[0], 1);\
}
fiberLT L
running fibers
Definition: libsheepy.h:6846
fibersT fibers
data for fiber system
Definition: libsheepy.c:57307
jmp_buf jumpBuffers[tCount]
setjmp buffers for fibers
Definition: libsheepy.h:6842

yield jumps back to other fiber slot should be a local variable in the fiber slot is set to the index in fiberJumpBuffers for current fiber backToSlot is the index in fiberJumpBuffers for the other fiber

Definition at line 6908 of file libsheepy.h.

◆ fiberEnd

#define fiberEnd (   slot)
Value:
if (!setjmp(fibers.jumpBuffers[slot])) {\
longjmp(fibers.jumpBuffers[0], 1);\
}
fibersT fibers
data for fiber system
Definition: libsheepy.c:57307
jmp_buf jumpBuffers[tCount]
setjmp buffers for fibers
Definition: libsheepy.h:6842

return to scheduler and end the fiber

Definition at line 6919 of file libsheepy.h.

◆ schedulerYield

#define schedulerYield (   backToSlot)
Value:
if (!setjmp(fibers.jumpBuffers[0])) {\
longjmp(fibers.jumpBuffers[backToSlot], backToSlot);\
}
fibersT fibers
data for fiber system
Definition: libsheepy.c:57307
jmp_buf jumpBuffers[tCount]
setjmp buffers for fibers
Definition: libsheepy.h:6842

Definition at line 6925 of file libsheepy.h.

◆ dArrayBits

#define dArrayBits   6

dynamic segmented array

this type of array is faster than slab when there are many elements and has a dynamic element count pushing elements into the array increases the element count the data is stored in static array segments dArray has head and last indexes, this allows dequeuing from head elements fast

no sanity checks are done

usage examples: regular array, stack, lifo, fifo

the prefix is dArray

Usage:

to declare an array:

dArrayT(typeName, type);

typeName darray;

dArrayInit(&darray); or dArrayInitCount(&darray, 17);

dArrayAppend(&darray, value);

// get an element int a = dArrayAt(&darray, 0);

set dArrayAt(&darray, 1) = 3;

dArrayFree(&darray);

dArray variables: darray.maxCount: maximum element count allowed

Note: dont combine the macros, it gives wrong results: a = dArrayAt(&darray, dArrayPop(&darray2)); dArrayPop is run several time, more than one element is popped

Note: some functions are macros to be able to have structs as element and access the struct members directly, for example: dArrayLast(chan).a = 0; chunk size: 2^dArrayBits elements

Definition at line 6984 of file libsheepy.h.

◆ dArraySz

#define dArraySz   (1<<dArrayBits)

Definition at line 6987 of file libsheepy.h.

◆ dArrayMask

#define dArrayMask   (dArraySz-1)

Definition at line 6988 of file libsheepy.h.

◆ dArrayT

#define dArrayT (   typeName,
  elementType 
)
Value:
typedef struct {\
int64_t last;\
int64_t head;\
int64_t maxCount;\
void** buffers;\
elementType element;\
} typeName

declares type for dynamic array

Parameters
typeNamedArray type name
elementtype of elements (int, struct, pointer...)

Definition at line 6998 of file libsheepy.h.

◆ createDArray

#define createDArray (   typeName,
  name 
)    ;typeName name; dArrayInit(&name)

Definition at line 7008 of file libsheepy.h.

◆ createDArrayCount

#define createDArrayCount (   typeName,
  name,
  count 
)    ;typeName name; dArrayInitCount(&name, count)

Definition at line 7010 of file libsheepy.h.

◆ dArrayInit

#define dArrayInit (   a)
Value:
do{\
(a)->last = (a)->head = 0;\
(a)->buffers = malloc(sizeof(void*));\
(a)->buffers[0] = malloc(dArraySz * sizeof((a)->element));\
(a)->maxCount = 1;\
}while(0)
smallArrayt * a
#define dArraySz
Definition: libsheepy.h:6987

initialize dynamic array with minimum element count

Parameters
avariable name for dArray

Definition at line 7018 of file libsheepy.h.

◆ dArrayInitCount

#define dArrayInitCount (   a,
  count 
)
Value:
do{\
dArrayInit(a);\
if ((count) > dArraySz) {\
(a)->buffers = realloc((a)->buffers, (((count)>>dArrayBits)+1) * sizeof(void*));\
rangeFrom(UNIQVAR(i), 1, ((count)>>dArrayBits)+1) {\
(a)->buffers[UNIQVAR(i)] = malloc(dArraySz * sizeof((a)->element));\
}\
(a)->maxCount = ((count)>>dArrayBits)+1;\
}\
}while(0)
smallt * i
smallArrayt * a
#define dArraySz
Definition: libsheepy.h:6987
#define dArrayBits
dynamic segmented array
Definition: libsheepy.h:6984
#define UNIQVAR(name)
Definition: libsheepy.h:705

initialize dynamic array and count

Parameters
avariable name for dArray
countinitial element count for name type

Definition at line 7033 of file libsheepy.h.

◆ dArrayResize

#define dArrayResize (   a,
  count 
)
Value:
do{\
if ((count) > (a)->maxCount * dArraySz) {\
/* grow array */\
(a)->buffers = realloc((a)->buffers, (((count)>>dArrayBits)+1) * sizeof(void*));\
rangeFrom(UNIQVAR(i), (a)->maxCount, ((count)>>dArrayBits)+1) {\
(a)->buffers[UNIQVAR(i)] = malloc(dArraySz * sizeof((a)->element));\
}\
(a)->maxCount = ((count)>>dArrayBits)+1;\
}\
/*else TODO dArray shrink */\
}while(0)
smallt * i
smallArrayt * a
#define dArraySz
Definition: libsheepy.h:6987
#define dArrayBits
dynamic segmented array
Definition: libsheepy.h:6984
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 7044 of file libsheepy.h.

◆ dArrayFree

#define dArrayFree   dVectorFree

free the internal buffers

Parameters
adynamic array

Definition at line 7062 of file libsheepy.h.

◆ dArrayElemType

#define dArrayElemType (   a)    typeof((a)->element)

element type in array

Definition at line 7067 of file libsheepy.h.

◆ dArrayElemPtrType

#define dArrayElemPtrType (   a)    typeof(&(a)->element)

element pointer type in array

Definition at line 7072 of file libsheepy.h.

◆ dArrayEmpty

#define dArrayEmpty (   name)
Value:
do{\
(name)->last = (name)->head = 0;\
} while(0);

Empty Array Allocated buffers in the array must be freed before running dArrayEmpty.

Definition at line 7078 of file libsheepy.h.

◆ dArrayIsEmpty

#define dArrayIsEmpty (   name)    ((name)->head == (name)->last)

is Array Empty

Definition at line 7085 of file libsheepy.h.

◆ dArrayCount

#define dArrayCount (   name)    ((name)->last - (name)->head)

return element count

Definition at line 7090 of file libsheepy.h.

◆ dArrayMaxCount

#define dArrayMaxCount (   name)    ((name)->maxCount * dArraySz)

return max element count

Definition at line 7095 of file libsheepy.h.

◆ dArrayAlloc

#define dArrayAlloc (   a)
Value:
do{\
if ((a)->last == dArrayMaxCount(a)) {\
(a)->maxCount++;\
(a)->buffers = realloc((a)->buffers, (size_t)(a)->maxCount * sizeof(void*));\
(a)->buffers[(a)->maxCount-1] = malloc(dArraySz * sizeof((a)->element));\
}\
}while(0)
smallArrayt * a
#define dArraySz
Definition: libsheepy.h:6987
#define dArrayMaxCount(name)
return max element count
Definition: libsheepy.h:7095

allocate buffer for new elements only when the array is full

Parameters
adynamic array

Definition at line 7104 of file libsheepy.h.

◆ dArrayPush

#define dArrayPush (   a)
Value:
do{\
dArrayAlloc(a);\
(a)->last++;\
}while(0)
smallArrayt * a

push element and expand the dynamic array no data (random) is set in the new element.

Parameters
adynamic array
velement to push

Definition at line 7121 of file libsheepy.h.

◆ dArrayAppend

#define dArrayAppend (   a,
 
)
Value:
do{\
dArrayAlloc(a);\
if ((a)->last < dArrayMaxCount(a)) {\
typeof((a)->element) *UNIQVAR(buffer) = (a)->buffers[((a)->last)>>dArrayBits];\
*(UNIQVAR(buffer)+ (((a)->last)&dArrayMask)) = v;\
(a)->last++;\
}\
}while(0)
#define dArrayMask
Definition: libsheepy.h:6988
smallArrayt * a
#define dArrayBits
dynamic segmented array
Definition: libsheepy.h:6984
#define dArrayMaxCount(name)
return max element count
Definition: libsheepy.h:7095
#define UNIQVAR(name)
Definition: libsheepy.h:705

append element and expand the dynamic array

Parameters
adynamic array
velement to push

Definition at line 7134 of file libsheepy.h.

◆ dArrayPop

#define dArrayPop (   a)    ((a)->last--, *((typeof((a)->element)*)((a)->buffers[((a)->last)>>dArrayBits])+(((a)->last)&dArrayMask)))

pop element the index of the last element is decreased

NOTE: using comma operator to avoid warning warning: operation on ‘b.head’ may be undefined [-Wsequence-point]

Parameters
adynamic array

Definition at line 7154 of file libsheepy.h.

◆ dArrayDelLast

#define dArrayDelLast (   a)    ((a)->last--)

delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used

Definition at line 7161 of file libsheepy.h.

◆ dArrayPrepend

#define dArrayPrepend (   a,
 
)
Value:
do{\
if ((a)->head > 0) {\
(a)->head--;\
typeof((a)->element) *UNIQVAR(buffer) = (a)->buffers[((a)->head)>>dArrayBits];\
*(UNIQVAR(buffer)+ (((a)->head)&dArrayMask)) = v;\
}\
}while(0)
#define dArrayMask
Definition: libsheepy.h:6988
smallArrayt * a
#define dArrayBits
dynamic segmented array
Definition: libsheepy.h:6984
#define UNIQVAR(name)
Definition: libsheepy.h:705

prepend element

Parameters
adynamic array
velement to prepend

Definition at line 7171 of file libsheepy.h.

◆ dArrayDequeue

#define dArrayDequeue (   a)    ((a)->head++, *((typeof((a)->element)*)((a)->buffers[((a)->head-1)>>dArrayBits])+(((a)->head-1)&dArrayMask)))

dequeue element the index of the head element is increased

NOTE: using comma operator to avoid warning warning: operation on ‘b.head’ may be undefined [-Wsequence-point]

Parameters
adynamic array

Definition at line 7190 of file libsheepy.h.

◆ dArrayDelFirst

#define dArrayDelFirst (   a)    ((a)->head++)

delete the first element useful for avoiding warning: right-hand operand of comma expression has no effect when the dequeued value is not used

Definition at line 7197 of file libsheepy.h.

◆ dArrayAt

#define dArrayAt (   a,
  index 
)    (*((typeof((a)->element)*)((a)->buffers[(index)>>dArrayBits])+((index)&dArrayMask)))

get / set element at index

Parameters
adynamic array
indexindex in array

Definition at line 7207 of file libsheepy.h.

◆ dArrayPtr

#define dArrayPtr (   a,
  index 
)    ((typeof((a)->element)*)((a)->buffers[(index)>>dArrayBits])+((index)&dArrayMask))

get pointer to element at index

Parameters
adynamic array
indexindex in array

Definition at line 7217 of file libsheepy.h.

◆ dArraySet

#define dArraySet (   a,
  index,
 
)
Value:
do{\
var UNIQVAR(idx) = index;\
if (UNIQVAR(idx) < (a)->last) {\
/* index is inside current array */\
dArrayAt(a, UNIQVAR(idx)) = v;\
if (UNIQVAR(idx) < (a)->head) {\
/* update head since index is lower */\
(a)->head = UNIQVAR(idx);\
}\
}\
else {\
/* index is after last element */\
/* check if index is under maxCount */\
if (UNIQVAR(idx) >= dArrayMaxCount(a)) {\
/* resize array */\
dArrayResize(a, UNIQVAR(idx)+1);\
}\
dArrayAt(a, UNIQVAR(idx)) = v;\
/* update last since index is higher*/\
(a)->last = UNIQVAR(idx)+1;\
}\
}while(0)
smallArrayt * a
#define dArrayMaxCount(name)
return max element count
Definition: libsheepy.h:7095
#define UNIQVAR(name)
Definition: libsheepy.h:705

set at index and resize dArray when index is greater then maxCount

Definition at line 7222 of file libsheepy.h.

◆ dArraySparseSet

#define dArraySparseSet (   a,
  index,
 
)
Value:
do{\
var UNIQVAR(idx) = index;\
var UNIQVAR(bIdx) = UNIQVAR(idx)>>dArrayBits;\
if (UNIQVAR(idx) >= dArrayMaxCount(a)) {\
/* sparse resize array - grow array */\
(a)->buffers = realloc((a)->buffers, (((UNIQVAR(bIdx)+1)>>dArrayBits)+1) * sizeof(void*));\
/* empty segments are marked with NULL */\
memset(&(a)->buffers[(a)->maxCount], 0, (UNIQVAR(bIdx)+1) - (a)->maxCount);\
(a)->maxCount = UNIQVAR(bIdx)+1;\
/* allocate new segment */\
(a)->buffers[UNIQVAR(bIdx)] = malloc(dArraySz * sizeof((a)->element));\
dArrayAt(a, UNIQVAR(idx)) = v;\
}\
else {\
/* check if the segment is already allocated */\
if (!(a)->buffers[UNIQVAR(bIdx)]) {\
/* allocate new segment */\
(a)->buffers[UNIQVAR(bIdx)] = malloc(dArraySz * sizeof((a)->element));\
}\
dArrayAt(a, UNIQVAR(idx)) = v;\
}\
}while(0)
smallArrayt * a
#define dArraySz
Definition: libsheepy.h:6987
#define dArrayBits
dynamic segmented array
Definition: libsheepy.h:6984
#define dArrayMaxCount(name)
return max element count
Definition: libsheepy.h:7095
#define UNIQVAR(name)
Definition: libsheepy.h:705

sparse set at index and resize dArray when index is greater then maxCount dArraySparseSet allows using dArray as a sparse array

head and last are not updated because there are empty regions in the sparse array

the empty segments are marked with NULL in the a->buffers array

after using dArraySparseSet only these macros are valid: dArrayResize, dArrayElemType, dArrayElemPtrType, dArrayMaxCount, dArrayAt, dArrayPtr, dArrayFree

Definition at line 7256 of file libsheepy.h.

◆ dArrayLast

#define dArrayLast (   a)    (*((typeof((a)->element)*)((a)->buffers[((a)->last-1)>>dArrayBits])+(((a)->last-1)&dArrayMask)))

last element

Parameters
adynamic array

Definition at line 7285 of file libsheepy.h.

◆ dArrayLastPtr

#define dArrayLastPtr (   a)    ((typeof((a)->element)*)((a)->buffers[((a)->last-1)>>dArrayBits])+(((a)->last-1)&dArrayMask))

pointer to last element

Parameters
adynamic array

Definition at line 7293 of file libsheepy.h.

◆ dArrayLastIndex

#define dArrayLastIndex (   a)    ((a)->last-1)

index of last element

Definition at line 7298 of file libsheepy.h.

◆ dArrayLastIndexVar

#define dArrayLastIndexVar (   a)    ((a)->last)

direct access to the last element index variable for assignments

Definition at line 7303 of file libsheepy.h.

◆ dArrayFirst

#define dArrayFirst (   a)    (*((typeof((a)->element)*)((a)->buffers[((a)->head)>>dArrayBits])+((a)->head)&dArrayMask))

first element

Parameters
adynamic array

Definition at line 7311 of file libsheepy.h.

◆ dArrayFirstIndex

#define dArrayFirstIndex (   a)    ((a)->head)

index of first element

Definition at line 7316 of file libsheepy.h.

◆ dArrayWriteFilename

#define dArrayWriteFilename (   a,
  filename 
)
Value:
do {\
FILE *UNIQVAR(f) = fopen(filename, "w");\
if (UNIQVAR(f)) {\
range(UNIQVAR(i), (size_t)dArrayCount(a)) {\
typeof((a)->element) *firstElement = (a)->buffers[UNIQVAR(i)/dArraySz];\
fwrite(firstElement+(UNIQVAR(i)%dArraySz), 1, sizeof((a)->element), UNIQVAR(f));\
}\
fclose(UNIQVAR(f));\
}\
} while(0)
smallt * i
#define dArrayCount(name)
return element count
Definition: libsheepy.h:7090
smallArrayt * a
#define dArraySz
Definition: libsheepy.h:6987
#define UNIQVAR(name)
Definition: libsheepy.h:705

write the dArray content to filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 7325 of file libsheepy.h.

◆ dArrayWrite

#define dArrayWrite (   a,
  file 
)
Value:
do {\
range(UNIQVAR(i), (size_t)dArrayCount(a)) {\
typeof((a)->element) *firstElement = (a)->buffers[UNIQVAR(i)/dArraySz];\
fwrite(firstElement+(UNIQVAR(i)%dArraySz), 1, sizeof((a)->element), file);\
}\
} while(0)
char ** file
smallt * i
#define dArrayCount(name)
return element count
Definition: libsheepy.h:7090
smallArrayt * a
#define dArraySz
Definition: libsheepy.h:6987
#define UNIQVAR(name)
Definition: libsheepy.h:705

write the dArray content to disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 7343 of file libsheepy.h.

◆ dArrayReadFilename

#define dArrayReadFilename (   a,
  filename 
)
Value:
do {\
if (fileExists(filename)) {\
size_t UNIQVAR(sz) = fileSize(filename);\
FILE *UNIQVAR(f) = fopen(filename, "r");\
if (UNIQVAR(f)) {\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((a)->element)) {\
dArrayPush(a);\
fread(dArrayLastPtr(a), 1, sizeof((a)->element), UNIQVAR(f));\
}\
fclose(UNIQVAR(f));\
}\
}\
} while(0)
#define dArrayLastPtr(a)
pointer to last element
Definition: libsheepy.h:7293
smallt * i
bool fileExists(const char *filePath) MUST_CHECK
detect files and directories
Definition: libsheepy.c:4321
smallArrayt * a
ssize_t fileSize(const char *filePath) MUST_CHECK
get file size
Definition: libsheepy.c:4369
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a dArray from filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 7357 of file libsheepy.h.

◆ dArrayRead

#define dArrayRead (   a,
  file 
)
Value:
do {\
fseek(file, 0 , SEEK_END);\
size_t UNIQVAR(sz) = ftell(file);\
fseek(file, 0 , SEEK_SET);\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof((a)->element)) {\
dArrayPush(a);\
fread(dArrayLastPtr(a), 1, sizeof((a)->element), file);\
}\
} while(0)
char ** file
#define dArrayLastPtr(a)
pointer to last element
Definition: libsheepy.h:7293
smallt * i
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a dArray from disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 7378 of file libsheepy.h.

◆ dArrayForEach

#define dArrayForEach (   name,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = (name)->head; \
for (dArrayElemPtrType(name) element = dArrayPtr(name, (name)->head) ; UNIQVAR(libsheepyInternalIndex) < (name)->last + 1 ; UNIQVAR(libsheepyInternalIndex)++, element = dArrayPtr(name, UNIQVAR(libsheepyInternalIndex)))
#define dArrayElemPtrType(a)
element pointer type in array
Definition: libsheepy.h:7072
#define dArrayPtr(a, index)
get pointer to element at index
Definition: libsheepy.h:7217
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop on dArray elements element is a pointer to a value in the array

dArrayForEach(&a, e) { e->x = 0; }

Definition at line 7396 of file libsheepy.h.

◆ dArrayEnumerate

#define dArrayEnumerate (   name,
  index,
  element 
)
Value:
; size_t index = (name)->head; \
for (dArrayElemPtrType(name) element = dArrayPtr(name, (name)->head) ; index < (name)->last + 1 ; index++, element = dArrayPtr(name, index))
#define dArrayElemPtrType(a)
element pointer type in array
Definition: libsheepy.h:7072
#define dArrayPtr(a, index)
get pointer to element at index
Definition: libsheepy.h:7217

enumerate dArray elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array

dArrayEnumerate(&a, i, e) { e->x = 0; printf("dArrayEnumerate %d\n", i); }

Definition at line 7411 of file libsheepy.h.

◆ slabSz

#define slabSz   64

slab - dynamic array in one chunk of memory

slab supports shrinking through slabResize, the slab is reset when head or last are outside the new size slab has head and last indexes, this allows dequeuing from head elements fast

this type of array has a dynamic element count pushing elements into the array increases the element count

no sanity checks are done

usage examples: regular array, stack, lifo, fifo

the prefix is slab

Usage:

to declare an array:

slabT(typeName, type);

typeName slab;

slabInit(&slab); or slabInitCount(&slab, 17);

slabAppend(&slab, value);

// get an element int a = slabAt(&slab, 0);

set slabAt(&slab, 1) = 3;

slabFree(&slab);

Slab variables: slab.array: elements slab.maxCount: maximum element count allowed

Note: some functions are macros to be able to have structs as element and access the struct members directly, for example: slabLast(chan).a = 0;number of elements added by slabAlloc

Definition at line 7469 of file libsheepy.h.

◆ slabT

#define slabT (   typeName,
  elementType 
)
Value:
typedef struct {\
int64_t last;\
int64_t head;\
int64_t maxCount;\
elementType *array;\
} typeName
char * array[]

declares type for dynamic array

Parameters
typeNameslab type name
elementtype of elements (int, struct, pointer...)

Definition at line 7479 of file libsheepy.h.

◆ createSlab

#define createSlab (   typeName,
  name 
)    ;typeName name; slabInit(&name)

Definition at line 7488 of file libsheepy.h.

◆ createSlabCount

#define createSlabCount (   typeName,
  name,
  count 
)    ;typeName name; slabInitCount(&name, count)

Definition at line 7490 of file libsheepy.h.

◆ slabInit

#define slabInit (   a)
Value:
do{\
(a)->last = (a)->head = 0;\
(a)->array = malloc(sizeof(*((a)->array)) * slabSz);\
(a)->maxCount = slabSz;\
}while(0)
#define slabSz
slab - dynamic array in one chunk of memory
Definition: libsheepy.h:7469
char * array[]
smallArrayt * a

initialize dynamic array with minimum element count

Parameters
avariable name for slab

Definition at line 7498 of file libsheepy.h.

◆ slabInitCount

#define slabInitCount (   a,
  count 
)
Value:
do{\
var UNIQVAR(c) = count;\
(a)->last = (a)->head = 0;\
(a)->array = malloc(sizeof(*((a)->array)) * UNIQVAR(c));\
(a)->maxCount = UNIQVAR(c);\
}while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

initialize slab and count

Parameters
avariable name for slab
countinitial element count for name type

Definition at line 7513 of file libsheepy.h.

◆ slabResize

#define slabResize (   a,
  count 
)
Value:
do{\
var UNIQVAR(c) = count;\
(a)->array = realloc((a)->array, sizeof(*((a)->array)) * UNIQVAR(c));\
(a)->maxCount = UNIQVAR(c);\
if (((a)->last >= (a)->maxCount) || ((a)->head >= (a)->maxCount)) {\
/* shrinking error - head or last outside the new array, reset to 0 */\
(a)->last = (a)->head = 0;\
}\
}while(0)
char * array[]
char c
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

Definition at line 7520 of file libsheepy.h.

◆ slabFree

#define slabFree   sliceFree

free the internal buffers

Parameters
aslab

Definition at line 7536 of file libsheepy.h.

◆ slabElemType

#define slabElemType (   name)    typeof((name)->array[0])

element type in array

Definition at line 7541 of file libsheepy.h.

◆ slabElemPtrType

#define slabElemPtrType (   name)    typeof(&(name)->array[0])

element pointer type in array

Definition at line 7546 of file libsheepy.h.

◆ slabEmpty

#define slabEmpty (   name)
Value:
do{\
(name)->last = (name)->head = 0;\
} while(0);

Empty Array.

Definition at line 7551 of file libsheepy.h.

◆ slabIsEmpty

#define slabIsEmpty (   name)    ((name)->head == (name)->last)

is Array Empty

Definition at line 7558 of file libsheepy.h.

◆ slabCount

#define slabCount (   name)    ((name)->last - (name)->head)

return element count

Definition at line 7563 of file libsheepy.h.

◆ slabMaxCount

#define slabMaxCount   vectorMaxCount

return max element count

Definition at line 7568 of file libsheepy.h.

◆ slabAlloc

#define slabAlloc (   a)
Value:
do{\
if ((a)->last == slabMaxCount(a)) {\
(a)->maxCount += slabSz;\
slabResize(a, (a)->maxCount);\
}\
}while(0)
#define slabSz
slab - dynamic array in one chunk of memory
Definition: libsheepy.h:7469
#define slabMaxCount
return max element count
Definition: libsheepy.h:7568
smallArrayt * a

allocate buffer for new elements only when the slab is full

Parameters
adynamic array

Definition at line 7577 of file libsheepy.h.

◆ slabPush

#define slabPush (   a)
Value:
do{\
slabAlloc(a);\
(a)->last++;\
}while(0)
smallArrayt * a

push element and expand the slab no data (random) is set in the new element

Parameters
aslab

Definition at line 7591 of file libsheepy.h.

◆ slabAppend

#define slabAppend (   a,
 
)
Value:
do{\
slabAlloc(a);\
if ((a)->last < slabMaxCount(a)) {\
*( (a)->array + (a)->last ) = v;\
(a)->last++;\
}\
}while(0)
#define slabMaxCount
return max element count
Definition: libsheepy.h:7568
char * array[]
smallArrayt * a

append element and expand the slab

Parameters
aslab
velement to push

Definition at line 7604 of file libsheepy.h.

◆ slabPop

#define slabPop (   a)    ((a)->last--, *((a)->array + (a)->last))

pop element the index of the last element is decreased

NOTE: using comma operator to avoid warning warning: operation on ‘b.head’ may be undefined [-Wsequence-point]

Parameters
aslab

Definition at line 7623 of file libsheepy.h.

◆ slabDelLast

#define slabDelLast (   a)    ((a)->last--)

delete the last element useful for avoiding warning: right-hand operand of comma expression has no effect when the poped value is not used

Definition at line 7630 of file libsheepy.h.

◆ slabPrepend

#define slabPrepend (   a,
 
)
Value:
do{\
if ((a)->head > 0) {\
(a)->head--;\
*( (a)->array + (a)->head ) = v;\
}\
}while(0)
char * array[]
smallArrayt * a

prepend element

Parameters
aslab
velement to prepend

Definition at line 7640 of file libsheepy.h.

◆ slabDequeue

#define slabDequeue (   a)    ((a)->head++, *((a)->array + (a)->head -1))

dequeue element the index of the head element is increased

NOTE: using comma operator to avoid warning warning: operation on ‘b.head’ may be undefined [-Wsequence-point]

Parameters
aslab

Definition at line 7658 of file libsheepy.h.

◆ slabDelFirst

#define slabDelFirst (   a)    ((a)->head++)

delete the first element useful for avoiding warning: right-hand operand of comma expression has no effect when the dequeued value is not used

Definition at line 7665 of file libsheepy.h.

◆ slabAt

#define slabAt   sliceAt

get / set element at index

Parameters
aslab
indexindex in array

Definition at line 7675 of file libsheepy.h.

◆ slabPtr

#define slabPtr   slicePtr

get pointer to element at index

Parameters
aslab
indexindex in array

Definition at line 7685 of file libsheepy.h.

◆ slabLast

#define slabLast (   a)    (*((a)->array + (a)->last -1))

last element

Parameters
aslab

Definition at line 7693 of file libsheepy.h.

◆ slabLastPtr

#define slabLastPtr (   a)    ((a)->array + (a)->last -1)

pointer to last element

Parameters
aslab

Definition at line 7701 of file libsheepy.h.

◆ slabLastIndex

#define slabLastIndex (   a)    ((a)->last-1)

index of last element

Definition at line 7706 of file libsheepy.h.

◆ slabLastIndexVar

#define slabLastIndexVar (   a)    ((a)->last)

direct access to the last element index variable for assignments

Definition at line 7711 of file libsheepy.h.

◆ slabFirst

#define slabFirst (   a)    (*((a)->array + (a)->head))

first element

Parameters
aslab

Definition at line 7719 of file libsheepy.h.

◆ slabFirstIndex

#define slabFirstIndex (   a)    ((a)->head)

index of first element

Definition at line 7724 of file libsheepy.h.

◆ slabWriteFilename

#define slabWriteFilename (   a,
  filename 
)
Value:
do {\
FILE *UNIQVAR(f) = fopen(filename, "w");\
if (UNIQVAR(f)) {\
fwrite((a)->array + (a)->head, 1, sizeof(*((a)->array)) * slabCount(a), UNIQVAR(f));\
fclose(UNIQVAR(f));\
}\
} while(0)
char * array[]
#define slabCount(name)
return element count
Definition: libsheepy.h:7563
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

write the slab content to filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 7733 of file libsheepy.h.

◆ slabWrite

#define slabWrite (   a,
  file 
)    fwrite((a)->array + (a)->head, 1, sizeof(*((a)->array)) * slabCount(a), file)

write the slab content to disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 7748 of file libsheepy.h.

◆ slabReadFilename

#define slabReadFilename (   a,
  filename 
)
Value:
do {\
if (fileExists(filename)) {\
size_t UNIQVAR(sz) = fileSize(filename);\
FILE *UNIQVAR(f) = fopen(filename, "r");\
if (UNIQVAR(f)) {\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof(*((a)->array))) {\
slabPush(a);\
fread(slabLastPtr(a), 1, sizeof(*((a)->array)), UNIQVAR(f));\
}\
fclose(UNIQVAR(f));\
}\
}\
} while(0)
smallt * i
bool fileExists(const char *filePath) MUST_CHECK
detect files and directories
Definition: libsheepy.c:4321
#define slabLastPtr(a)
pointer to last element
Definition: libsheepy.h:7701
char * array[]
smallArrayt * a
ssize_t fileSize(const char *filePath) MUST_CHECK
get file size
Definition: libsheepy.c:4369
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a slab from filename file No NULL checks are done on the parameters

Parameters
filenamefile name string

Definition at line 7757 of file libsheepy.h.

◆ slabRead

#define slabRead (   a,
  file 
)
Value:
do {\
fseek(file, 0 , SEEK_END);\
size_t UNIQVAR(sz) = ftell(file);\
fseek(file, 0 , SEEK_SET);\
range(UNIQVAR(i), UNIQVAR(sz)/sizeof(*((a)->array))) {\
slabPush(a);\
fread(slabLastPtr(a), 1, sizeof(*((a)->array)), file);\
}\
} while(0)
char ** file
smallt * i
#define slabLastPtr(a)
pointer to last element
Definition: libsheepy.h:7701
char * array[]
smallArrayt * a
#define UNIQVAR(name)
Definition: libsheepy.h:705

read a slab from disk No NULL checks are done on the parameters

Parameters
filealready opened file

Definition at line 7778 of file libsheepy.h.

◆ slabForEach

#define slabForEach (   name,
  element 
)
Value:
;size_t UNIQVAR(libsheepyInternalIndex) = (name)->head; \
for (slabElemPtrType(name) element = slabPtr(name, (name)->head) ; UNIQVAR(libsheepyInternalIndex) < (name)->last + 1 ; UNIQVAR(libsheepyInternalIndex)++, element = slabPtr(name, UNIQVAR(libsheepyInternalIndex)))
#define slabElemPtrType(name)
element pointer type in array
Definition: libsheepy.h:7546
#define slabPtr
get pointer to element at index
Definition: libsheepy.h:7685
#define UNIQVAR(name)
Definition: libsheepy.h:705

loop on slab elements element is a pointer to a value in the array

slabForEach(&a, e) { e->x = 0; }

Definition at line 7796 of file libsheepy.h.

◆ slabEnumerate

#define slabEnumerate (   name,
  index,
  element 
)
Value:
; size_t index = (name)->head; \
for (slabElemPtrType(name) element = slabPtr(name, (name)->head) ; index < (name)->last + 1 ; index++, element = slabPtr(name, index))
#define slabElemPtrType(name)
element pointer type in array
Definition: libsheepy.h:7546
#define slabPtr
get pointer to element at index
Definition: libsheepy.h:7685

enumerate slab elements index is the position of the element in the array index is declared as size_t and is available after the loop element is a pointer to a value in the array

slabEnumerate(&a, i, e) { e->x = 0; printf("slabEnumerate %d\n", i); }

Definition at line 7811 of file libsheepy.h.

◆ staticBitsetT

#define staticBitsetT (   typeName,
  containerType,
  count 
)    typedef struct {containerType map[BUCKETS(count, 8 * sizeof(containerType))];} typeName;

static bitset

no sanity checks are done

Usage:

staticBitsetT(typeName, u64 , 8);

typeName bits;

staticBitsetInit(&bits);

staticBitset1(&bits, index);

bool bit = staticBitsetGet(&bits, index); typedef for staticBitset

Parameters
typeNametypedef name
containerTypeelement type in array: u8, u16, u32, u64...
countbit count in array

Definition at line 7850 of file libsheepy.h.

◆ staticBitsetInit

#define staticBitsetInit   staticBitsetClear

Definition at line 7853 of file libsheepy.h.

◆ staticBitsetCount

#define staticBitsetCount (   name)    (sizeof((name)->map) * 8)

bitset count

Definition at line 7856 of file libsheepy.h.

◆ staticBitsetClear

#define staticBitsetClear (   name)    memset(name, 0, sizeof(*(name)));

clear all bits in bitset

Definition at line 7859 of file libsheepy.h.

◆ staticBitsetBucket

#define staticBitsetBucket (   name,
  index 
)    (name)->map[index / (8 * sizeof((name)->map[0]))]

bucket containing bit at given index

Definition at line 7862 of file libsheepy.h.

◆ staticBitset0

#define staticBitset0 (   name,
  index 
)
Value:
do{\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (8 * sizeof((name)->map[0]));\
size_t bitOffset = UNIQVAR(idx) % (8 * sizeof((name)->map[0]));\
(name)->map[byteOffset] &= 0xFFFFFFFFFFFFFFFFUL ^ (1UL<<bitOffset);\
} while(0)
#define UNIQVAR(name)
Definition: libsheepy.h:705

set 0 at index

Definition at line 7865 of file libsheepy.h.

◆ staticBitset1

#define staticBitset1 (   name,
  index 
)
Value:
do{\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (8 * sizeof((name)->map[0]));\
size_t bitOffset = UNIQVAR(idx) % (8 * sizeof((name)->map[0]));\
(name)->map[byteOffset] |= 1UL<<bitOffset;\
} while(0)
#define UNIQVAR(name)
Definition: libsheepy.h:705

set 1 at index

Definition at line 7873 of file libsheepy.h.

◆ staticBitsetSet

#define staticBitsetSet (   name,
  index,
  value 
)
Value:
do{\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (8 * sizeof((name)->map[0]));\
size_t bitOffset = UNIQVAR(idx) % (8 * sizeof((name)->map[0]));\
/* performance is about the same as the if version with gcc 6.3 on skylake cpu, use the less obscure version - (name)->map[byteOffset] = ( (name)->map[byteOffset] & ~(1UL<<bitOffset)) | (-(value) & (1UL<<bitOffset));*/\
if (!value)\
(name)->map[byteOffset] &= 0xFFFFFFFFFFFFFFFFUL ^ (1UL<<bitOffset);\
else\
(name)->map[byteOffset] |= 1UL<<bitOffset;\
} while(0)
in value value
#define UNIQVAR(name)
Definition: libsheepy.h:705

set bit value at index

Definition at line 7881 of file libsheepy.h.

◆ staticBitsetInv

#define staticBitsetInv (   name,
  index 
)
Value:
do{\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (8 * sizeof((name)->map[0]));\
size_t bitOffset = UNIQVAR(idx) % (8 * sizeof((name)->map[0]));\
(name)->map[byteOffset] ^= 1UL<<bitOffset;\
} while(0)
#define UNIQVAR(name)
Definition: libsheepy.h:705

invert bit at index

Definition at line 7893 of file libsheepy.h.

◆ staticBitsetGet

#define staticBitsetGet (   name,
  index 
)
Value:
({\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (8 * sizeof((name)->map[0]));\
size_t bitOffset = UNIQVAR(idx) % (8 * sizeof((name)->map[0]));\
((name)->map[byteOffset] & (1UL<<bitOffset)) == 1UL<<bitOffset;\
})
#define UNIQVAR(name)
Definition: libsheepy.h:705

get bit at index

Definition at line 7901 of file libsheepy.h.

◆ bitsetModulo

#define bitsetModulo   8

end static bitset

bitset the underlying array is defined in the provided at macro or function

no sanity checks are done

a dynamic bitset can be created using slice and sliceAt

Definition at line 7921 of file libsheepy.h.

◆ bitsetBucket

#define bitsetBucket (   name,
  index 
)    (name)->map[index / (bitsetModulo)]

bucket containing bit at given index

Definition at line 7924 of file libsheepy.h.

◆ bitset0

#define bitset0 (   name,
  at,
  index 
)
Value:
do{\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (bitsetModulo);\
size_t bitOffset = UNIQVAR(idx) % (bitsetModulo);\
at(name, byteOffset) &= 0xFFFFFFFFFFFFFFFFUL ^ (1UL<<bitOffset);\
} while(0)
#define bitsetModulo
end static bitset
Definition: libsheepy.h:7921
#define UNIQVAR(name)
Definition: libsheepy.h:705

set 0 at index at must be macro or function taking 2 parameters: at(name, intIndex) and point to value at intIndex

Definition at line 7931 of file libsheepy.h.

◆ bitset1

#define bitset1 (   name,
  at,
  index 
)
Value:
do{\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (bitsetModulo);\
size_t bitOffset = UNIQVAR(idx) % (bitsetModulo);\
at(name, byteOffset) |= 1UL<<bitOffset;\
} while(0)
#define bitsetModulo
end static bitset
Definition: libsheepy.h:7921
#define UNIQVAR(name)
Definition: libsheepy.h:705

set 1 at index at must be macro or function taking 2 parameters: at(name, intIndex) and point to value at intIndex

Definition at line 7943 of file libsheepy.h.

◆ bitsetSet

#define bitsetSet (   name,
  at,
  index,
  value 
)
Value:
do{\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (bitsetModulo);\
size_t bitOffset = UNIQVAR(idx) % (bitsetModulo);\
/* performance is about the same as the if version with gcc 6.3 on skylake cpu, use the less obscure version - at(name, byteOffset) = ( at(name, byteOffset) & ~(1UL<<bitOffset)) | (-(value) & (1UL<<bitOffset)); */\
if (!value)\
at(name, byteOffset) &= 0xFFFFFFFFFFFFFFFFUL ^ (1UL<<bitOffset);\
else\
at(name, byteOffset) |= 1UL<<bitOffset;\
} while(0)
#define bitsetModulo
end static bitset
Definition: libsheepy.h:7921
in value value
#define UNIQVAR(name)
Definition: libsheepy.h:705

set bit value at index at must be macro or function taking 2 parameters: at(name, intIndex) and point to value at intIndex

Definition at line 7955 of file libsheepy.h.

◆ bitsetInv

#define bitsetInv (   name,
  at,
  index 
)
Value:
do{\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (bitsetModulo);\
size_t bitOffset = UNIQVAR(idx) % (bitsetModulo);\
at(name, byteOffset) ^= 1UL<<bitOffset;\
} while(0)
#define bitsetModulo
end static bitset
Definition: libsheepy.h:7921
#define UNIQVAR(name)
Definition: libsheepy.h:705

invert bit at index at must be macro or function taking 2 parameters: at(name, intIndex) and point to value at intIndex

Definition at line 7971 of file libsheepy.h.

◆ bitsetGet

#define bitsetGet (   name,
  at,
  index 
)
Value:
({\
var UNIQVAR(idx) = index;\
size_t byteOffset = UNIQVAR(idx) / (bitsetModulo);\
size_t bitOffset = UNIQVAR(idx) % (bitsetModulo);\
(at(name, byteOffset) & (1UL<<bitOffset)) == 1UL<<bitOffset;\
})
#define bitsetModulo
end static bitset
Definition: libsheepy.h:7921
#define UNIQVAR(name)
Definition: libsheepy.h:705

get bit at index at must be macro or function taking 2 parameters: at(name, intIndex) and return the value at intIndex

Definition at line 7984 of file libsheepy.h.

◆ FIELD_SET

#define FIELD_SET (   dst,
  val,
  msb,
  lsb 
)    dst = (/*clear field in dst*/ (dst) & ((0xFFFFFFFFFFFFFFFEUL << (msb)) | ((1UL<<(lsb))-1) )) | (/*clear highest bits in val and shift to field lsb*/(~(0xFFFFFFFFFFFFFFFEUL << ((msb)-(lsb))) & (val)) << (lsb))

end bitset

bitfield array

a field is a group of bit representing an int stored in a larger int

bitfield array is an array of fields (short int) similar to bitset

Example:

u64 v = 0; // field storage FIELD_SET(v, 3, 1, 0); // field is 2 bits from bit 0 to bit 1, set value 3

u8 field = FIELD_GET(v, 1, 0); // get value in field at bit 0 to 1

// declare a bitfield array // the array has 256 elements and each element is a 2 bit integer BITFIELD_VAR(bitfields, 256, 2) = init0Var;

// set value for element at index 255 BITFIELD_SET(bitfields, 255, 3, 2); // get value for element at index 255 v = BITFIELD_GET(bitfields, 255, 2); set bitfield value in destination (opposite of EXTRACT macro)

only bits between msb and lsb are set in dst

Parameters
dstdestination, unsigned integer (u8, u16, u32, u64)
valvalue to set, the value is shifted to lsb
msbmost significant bit in dst to be set
lsbleast significant bit in dst to be set

Definition at line 8034 of file libsheepy.h.

◆ FIELD_GET

#define FIELD_GET   EXTRACT

Definition at line 8036 of file libsheepy.h.

◆ FIELD_SETL

#define FIELD_SETL (   dst,
  index,
  val,
  len 
)    FIELD_SET(dst, val, ((index)+1)*(len)-1, (index)*(len))

set bitfield value in destination, given bitfield index and length

(index+1)*len-1 must be lower or equal to 8*sizeof(dst), otherwise val will be truncated

Parameters
dstdestination, unsigned integer (u8, u16, u32, u64)
indexindex of the bitfield in dst (bit index*len is lsb)
valvalue to set, the value is shifted to lsb
lenbitfield length in dst

Definition at line 8053 of file libsheepy.h.

◆ BITFIELD_SET

#define BITFIELD_SET (   array,
  index,
  val,
  len 
)    FIELD_SET((array)[((index)*(len))/64], val, ((index)*(len))%64+(len)-1, ((index)*(len))%64)

set bitfield value in array of bitfields the boundaries are not checked

Parameters
arrayarray of u64
indexindex of the bitfield in array (bit index*len is lsb)
valvalue to set, the value is shifted to the correct position
lenbitfield length in array, must divide 64 (2, 4, 8, 16, 32)

Definition at line 8068 of file libsheepy.h.

◆ BITFIELD_GET

#define BITFIELD_GET (   array,
  index,
  len 
)    EXTRACT((array)[((index)*(len))/64], ((index)*(len))%64+(len)-1, ((index)*(len))%64)

get bitfield value in array of bitfields the boundaries are not checked

Parameters
arrayarray of u64
indexindex of the bitfield in array (bit index*len is lsb)
lenbitfield length in array, must divide 64 (2, 4, 8, 16, 32)

Definition at line 8081 of file libsheepy.h.

◆ BITFIELD_SIZE

#define BITFIELD_SIZE (   count,
  len,
  containerType 
)    BUCKETS((count)*(len), 8 * sizeof(containerType))

return number of u64 necessary to hold count bitfields of length len

Definition at line 8086 of file libsheepy.h.

◆ BITFIELD_VAR

#define BITFIELD_VAR (   array,
  count,
  len 
)    u64 array[BITFIELD_SIZE(count, len, u64)]

declare an array to hold count bitfields of length len

Definition at line 8091 of file libsheepy.h.

◆ nanoSleep [1/2]

#define nanoSleep (   time)    pError0(nanoSleepF(time))

sleep nanoseconds

Definition at line 8105 of file libsheepy.h.

◆ nanoSleep [2/2]

#define nanoSleep (   time)    pError0(nanoSleepF(time))

sleep nanoseconds

Definition at line 8105 of file libsheepy.h.

◆ nanoSleepE

#define nanoSleepE (   time,
  cmd 
)    pErrorCmd(nanoSleepF(time), == 0, cmd)

nanoSleep and error code

Definition at line 8108 of file libsheepy.h.

◆ usSleep

#define usSleep (   time)    pError0(nanoSleepF(1000 * (uint64_t)time))

sleep microseconds

Definition at line 8111 of file libsheepy.h.

◆ msSleep

#define msSleep (   time)    pError0(nanoSleepF(1000000 * (uint64_t)time))

sleep miliseconds

Definition at line 8114 of file libsheepy.h.

◆ UNUSED

#define UNUSED

Definition at line 8195 of file libsheepy.h.

◆ DEPRECATED

#define DEPRECATED

Definition at line 8196 of file libsheepy.h.

◆ PACKED

#define PACKED

Definition at line 8197 of file libsheepy.h.

◆ CLEANUP

#define CLEANUP

Definition at line 8198 of file libsheepy.h.

◆ FALLTHRU

#define FALLTHRU

Definition at line 8199 of file libsheepy.h.

◆ AINLINE

#define AINLINE

Definition at line 8200 of file libsheepy.h.

◆ NOINLINE

#define NOINLINE

Definition at line 8201 of file libsheepy.h.

◆ PURE

#define PURE

Definition at line 8202 of file libsheepy.h.

◆ CONST

#define CONST

Definition at line 8203 of file libsheepy.h.

◆ NORETURN

#define NORETURN

Definition at line 8204 of file libsheepy.h.

◆ AMALLOC

#define AMALLOC

Definition at line 8205 of file libsheepy.h.

◆ MUST_CHECK [2/2]

#define MUST_CHECK

Definition at line 8206 of file libsheepy.h.

◆ USED

#define USED

Definition at line 8207 of file libsheepy.h.

◆ ALIGN

#define ALIGN (   X)

Definition at line 8208 of file libsheepy.h.

◆ ALIGN_MAX

#define ALIGN_MAX

Definition at line 8209 of file libsheepy.h.

◆ likely

#define likely (   x)    (x)

Definition at line 8210 of file libsheepy.h.

◆ unlikely

#define unlikely (   x)    (x)

Definition at line 8211 of file libsheepy.h.

Typedef Documentation

◆ initLibsheepyObjectP

typedef void(* initLibsheepyObjectP) (void)

Definition at line 1597 of file libsheepy.h.

◆ rune

typedef int rune

Definition at line 2312 of file libsheepy.h.

◆ shCmpt

typedef int(* shCmpt) (const void *a, const void *b)

Definition at line 3085 of file libsheepy.h.

◆ fiberFT

typedef void(* fiberFT) (int)

fiber function type

Definition at line 6874 of file libsheepy.h.

Function Documentation

◆ cleanUpCharFree()

void cleanUpCharFree ( char **  val)

Definition at line 919 of file libsheepy.c.

Here is the call graph for this function:

◆ cleanUpListFree()

void cleanUpListFree ( char ***  val)

Definition at line 925 of file libsheepy.c.

Here is the call graph for this function:

◆ cleanUpFileFree()

void cleanUpFileFree ( FILE **  val)

Definition at line 931 of file libsheepy.c.

Here is the call graph for this function:

◆ cleanUpFd()

void cleanUpFd ( int *  val)

Definition at line 939 of file libsheepy.c.

◆ shStopwatch()

uint64_t shStopwatch ( uint8_t  op)

nanosecond stopwatch

Parameters
opoperation: 0 start, 1 get stopwatch value
Returns
0 when op is 0 time since last start in ns when op is 1

Definition at line 955 of file libsheepy.c.

Here is the call graph for this function:

◆ setLogFile()

FILE* SH_PREFIX() setLogFile ( char *  filename)

set log file the logs are appended to all log files set with this function

there is a maximum of 15 log files

Returns
log file handle NULL when filename is NULL or more than 15 log files are set

Definition at line 1058 of file libsheepy.c.

◆ getLogSymbols()

int getLogSymbols ( void  )

get current log symbols

Definition at line 996 of file libsheepy.c.

◆ setLogSymbols()

void setLogSymbols ( int  mode)

set log symbols

LOG_VERBOSE for words LOG_UTF8 for emojis LOG_VOID for no symbols LOG_INVALID_MODE (reset log symbols) for default log mode symbols anything else (LOG_CONCISE,...) for symbols (!*+->~)

default is default log mode symbols

Definition at line 1012 of file libsheepy.c.

◆ getMaxLogLevel()

int getMaxLogLevel ( void  )

get current max log level

default is LOG_INVALID, to show all log levels -1 hides all logs

Definition at line 1028 of file libsheepy.c.

◆ setMaxLogLevel()

void setMaxLogLevel ( int  logLevel)

set max log level logs above logMaxLevel are skipped

default is LOG_INVALID, to show all log levels LOG_DISABLE hides all logs

Parameters
logLevelfrom LOG_DISABLE to LOG_INVALID

Definition at line 1043 of file libsheepy.c.

◆ closeLogFiles()

void closeLogFiles ( void  )

close logfiles opened with setLogFile

Definition at line 1081 of file libsheepy.c.

◆ getLogMode()

int getLogMode ( void  )

get current log mode (verbose, concise)

Returns
current mode LOG_VERBOSE, LOG_CONCISE, ...

Definition at line 1097 of file libsheepy.c.

◆ setLogMode()

void setLogMode ( int  mode)

set log mode LOG_VERBOSE, LOG_CONCISE, .

the default log mode is LOG_DATE

Definition at line 1107 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLogShortPath()

bool getLogShortPath ( void  )

get current log long/short path value

The default value is TRUE (short paths) TRUE shows short file paths in logs FALSE shows long file paths in logs

Returns
current long/short file path configuration value for VERBOSE mode

Definition at line 1128 of file libsheepy.c.

◆ setLogShortPath()

void setLogShortPath ( bool  shortPath)

set log long/short file path value for VERBOSE mode

TRUE shows short file paths in logs FALSE shows long file paths in logs

the default long/short path value is TRUE

Definition at line 1141 of file libsheepy.c.

◆ getLogStdout()

bool getLogStdout ( void  )

get stdout state, when TRUE (default) all logs are printed to stdout

Definition at line 1149 of file libsheepy.c.

◆ setLogStdout()

void setLogStdout ( bool  state)

enable/disable printing logs to stdout

TRUE: print logs to stdout FALSE: print logs to files only

Definition at line 1160 of file libsheepy.c.

◆ openProgLogFile()

bool openProgLogFile ( void  )

log to a file named progName.log Use closeLogFiles when finished logging

Definition at line 1169 of file libsheepy.c.

◆ keepAnsiColorsInLog()

void keepAnsiColorsInLog ( bool  state)

enable/disable ansi color codes in logs

TRUE: print colors FALSE: strip colors

Definition at line 1194 of file libsheepy.c.

◆ _pLog()

void _pLog ( int  ,
const char *  ,
const char *  ,
int  ,
const char *  ,
  ... 
)

Definition at line 1210 of file libsheepy.c.

◆ initLibsheepyF()

void initLibsheepyF ( const char *  progPath,
initLibsheepyObjectP  initF 
)

initialize libsheepy (optional, for debug)

initialize segfault handler for crash debug the segfault handler prints the line and file where the segfault occured

initialize the fibers initialize libsheepyObject

Definition at line 1579 of file libsheepy.c.

◆ finalizeLibsheepyCharAtExit()

void finalizeLibsheepyCharAtExit ( void  )

finalize libsheepy char at exit

free internal buffers in this file:

realprogpath urandomFp software random file

Definition at line 1652 of file libsheepy.c.

Here is the call graph for this function:

◆ getStackLimit()

int64_t getStackLimit ( void  )

get current stack limit

Returns
current stack limit -1 unlimited 0 when error

Definition at line 1667 of file libsheepy.c.

◆ setStackLimit()

int setStackLimit ( int64_t  stackSize)

set stack limit

Parameters
stackSizestack size in bytes, set -1 for unlimited size
Returns
!0 when ok 0 when it failed

Definition at line 1686 of file libsheepy.c.

◆ enableCoreDump()

int enableCoreDump ( void  )

enable core dump

change core dump size to infinity to enable core dump. After the program receives a signal generating core dump, a core file is written to disk and can be open with gdb

Returns
!0 when ok 0 when it failed

Definition at line 1720 of file libsheepy.c.

◆ getProgName()

const char* getProgName ( void  )

get program name

this program name showing in the logs

Definition at line 1745 of file libsheepy.c.

◆ setProgName()

bool setProgName ( const char *  name)

set program name

this program name showing in the logs

Definition at line 1755 of file libsheepy.c.

Here is the call graph for this function:

◆ setDefaultProgName()

void setDefaultProgName ( void  )

set default program name

this program name showing in the logs

Definition at line 1773 of file libsheepy.c.

◆ freeProgName()

void freeProgName ( void  )

free ProgName if set with setProgName

Definition at line 1782 of file libsheepy.c.

◆ getProgPath()

const char* getProgPath ( void  )

get program path When initLibsheepy is called before this function, it returns the given program path.

When initLibsheepy has not been called before this function, it returns the real program path.

Returns
program path or real program path (do not free this pointer)

Definition at line 1795 of file libsheepy.c.

Here is the caller graph for this function:

◆ getRealProgPath()

const char* getRealProgPath ( void  )

get real program path The first call allocates libSheepyRealProgPath, it is freed with freeRealProgPath

Returns
real program path (do not free this pointer)

Definition at line 1812 of file libsheepy.c.

Here is the caller graph for this function:

◆ freeRealProgPath()

void freeRealProgPath ( void  )

free real program path finalizeLibsheepy calls this function

Definition at line 1826 of file libsheepy.c.

Here is the call graph for this function:

◆ systemNFreeF()

int systemNFreeF ( char *  command,
int  line,
const char *  thisFunc,
const char *  thisFileName 
)

run system command and free command buffer a message is printed when an error occurs

this function is called from the systemNFree macro

Parameters
commandcommand to run in the shell
Returns
0 success command error code

Definition at line 1844 of file libsheepy.c.

Here is the call graph for this function:

◆ getModificationTime()

time_t getModificationTime ( const char *  path)

get modification time for path

Parameters
path
Returns
modification time 0 when an error occured

Definition at line 1864 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setModificationTime()

int setModificationTime ( const char *  path,
time_t  mtime 
)

set modification time for path

Parameters
path
mtime(for example, from the getModificationTime function)
Returns
1 ok 0 when an error occured

Definition at line 1890 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isReadable()

bool isReadable ( const char *  path)

is path readable

Returns
true when path is readable

Definition at line 1914 of file libsheepy.c.

◆ isWritable()

bool isWritable ( const char *  path)

is path writable

Returns
true when path is writable

Definition at line 1934 of file libsheepy.c.

◆ isExecutable()

bool isExecutable ( const char *  path)

is path executable

Returns
true when path is executable

Definition at line 1954 of file libsheepy.c.

◆ equalModificationTimes()

bool equalModificationTimes ( const char *  path1,
const char *  path2 
)

compare modification times for path1 and path2

Parameters
path1
path2
Returns
true when mtime is equal for path1 and path2 false when mtime is different for path1 and path2 or when there is an error

Definition at line 1979 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCurrentUnixTime()

time_t getCurrentUnixTime ( void  )

get current unix time in seconds

time_t is either int32_t or int64_t

Definition at line 2001 of file libsheepy.c.

◆ strToUnixTime()

time_t strToUnixTime ( const char *  date,
const char *  format 
)

convert date string to unix time

Parameters
datestring
formatfor strptime
Returns
time -1 error

Definition at line 2018 of file libsheepy.c.

Here is the call graph for this function:

◆ timeToS()

char* timeToS ( const time_t  t)

time To String convert unix time to string (ctime is not used here because it adds
at the end of the string)

Parameters
unixtime to convert
Returns
string representing the unix time in ctime format (Wed Dec 12 11:44:08 2018), you must free the pointer

Definition at line 2048 of file libsheepy.c.

Here is the caller graph for this function:

◆ bTimeToS()

char* bTimeToS ( char *  dst,
const time_t  t 
)

Definition at line 2057 of file libsheepy.c.

◆ bLTimeToS()

char* bLTimeToS ( char *  dst,
size_t  dstSize,
const time_t  t 
)

Definition at line 2065 of file libsheepy.c.

◆ timeToYMDS()

char* timeToYMDS ( const time_t  t)

time To Year-Month-Day Hour:Minute:Second String convert unix time to string

Parameters
unixtime to convert
Returns
string representing the unix time, you must free the pointer

Definition at line 2082 of file libsheepy.c.

◆ bTimeToYMDS()

char* bTimeToYMDS ( char *  dst,
const time_t  t 
)

Definition at line 2091 of file libsheepy.c.

◆ bLTimeToYMDS()

char* bLTimeToYMDS ( char *  dst,
size_t  dstSize,
const time_t  t 
)

Definition at line 2099 of file libsheepy.c.

◆ getCurrentDate()

char* getCurrentDate ( void  )

get current date in ctime format (Wed Dec 12 11:44:08 2018)

you must free the pointer

Definition at line 2112 of file libsheepy.c.

◆ bGetCurrentDate()

char* bGetCurrentDate ( char *  dst)

Definition at line 2121 of file libsheepy.c.

◆ bLGetCurrentDate()

char* bLGetCurrentDate ( char *  dst,
size_t  dstSize 
)

Definition at line 2132 of file libsheepy.c.

◆ getCurrentDateYMD()

char* getCurrentDateYMD ( void  )

get current date in Y-m-d H:M:S format

you must free the pointer

Definition at line 2148 of file libsheepy.c.

◆ bGetCurrentDateYMD()

char* bGetCurrentDateYMD ( char *  dst)

Definition at line 2157 of file libsheepy.c.

◆ bLGetCurrentDateYMD()

char* bLGetCurrentDateYMD ( char *  dst,
size_t  dstSize 
)

Definition at line 2168 of file libsheepy.c.

◆ shDirname()

char* shDirname ( const char *  path)

sheepy dirname

the returned string has to be freed

Parameters
path
Returns
path without basename (last item in the path, you must free the pointer) "./" when path is blank or when there is only one item in the path NULL when path is NULL

Definition at line 2191 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bDirname()

char* bDirname ( char *  path)

buffer dirname

the buffer size (path) must be at least 3 chars

Parameters
path
Returns
path without basename (last item in the path) "./" when path is blank or when there is only one item in the path NULL when path is NULL

Definition at line 2252 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLDirname()

char* bLDirname ( char *  path,
size_t  pathSize 
)

buffer size dirname

the buffer size (path) must be at least 3 chars

Parameters
path
pathSizepath buffer size, the path strlen will be at most pathSize-1
Returns
path without basename (last item in the path) "./" when path is blank or when there is only one item in the path NULL when path is NULL

Definition at line 2306 of file libsheepy.c.

Here is the call graph for this function:

◆ expandHome()

char* expandHome ( const char *  path)

expands ~/ ($HOME) or ~USER
duplicate and expand path.

The original remains unchanged.

Parameters
pathstring
Returns
new string path or NULL (you must free the pointer)

Definition at line 2443 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iExpandHome()

char* iExpandHome ( char **  path)

expands ~/ ($HOME) or ~USER

duplicate and expand path.

Parameters
pathstring (this parameter is reallocated)
Returns
path modified path
NULL error

Definition at line 2638 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bExpandHome()

char* bExpandHome ( char *  path)

buffer expands ~/ ($HOME) or ~USER

expand path

Parameters
pathstring
Returns
path modified path
NULL error

Definition at line 2821 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLExpandHome()

char* bLExpandHome ( char *  path,
size_t  pathSize 
)

buffer size expands ~/ ($HOME) or ~USER

expand path

Parameters
pathstring
pathSizepath buffer size, the path strlen will be at most pathSize-1
Returns
path modified path
NULL error

Definition at line 3001 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalizePath()

char* normalizePath ( const char *  path)

normalize path

remove unecessary /, .. and . leading / is kept leading .. is kept leading . is removed

'/../' becomes '/'

Parameters
path
Returns
new normalized path (you must free the pointer) NULL when path is NULL

Definition at line 3057 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iNormalizePath()

char* iNormalizePath ( char **  path)

normalize path

remove unecessary /, .. and . leading / is kept leading .. is kept leading . is removed

'/../' becomes '/'

Parameters
path(this parameter is reallocated)
Returns
path modified path NULL when path is NULL

Definition at line 3155 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bNormalizePath()

char* bNormalizePath ( char *  path)

buffer normalize path

remove unecessary /, .. and . leading / is kept leading .. is kept leading . is removed

'/../' becomes '/'

Parameters
path
Returns
path modified path NULL when path is NULL

Definition at line 3260 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLNormalizePath()

char* bLNormalizePath ( char *  path,
size_t  pathSize 
)

buffer size normalize path

path must be at least 2 chars

remove unecessary /, .. and . leading / is kept leading .. is kept leading . is removed

'/../' becomes '/'

Parameters
path
pathSizepath buffer size, the path strlen will be at most pathSize-1
Returns
path modified path NULL when path is NULL

Definition at line 3367 of file libsheepy.c.

Here is the call graph for this function:

◆ relPath()

char* relPath ( const char *  path,
const char *  start 
)

relative path

Return a relative filepath to path either from the current directory or from an optional start directory

Parameters
pathpath to convert
startreference path, cwd when NULL
Returns
new relative path (you must free the pointer) NULL when path is NULL

Definition at line 3472 of file libsheepy.c.

Here is the call graph for this function:

◆ iRelPath()

char* iRelPath ( char **  path,
const char *  start 
)

relative path

Return a relative filepath to path either from the current directory or from an optional start directory

Parameters
pathpath to convert (this parameter is reallocated)
startreference path, cwd when NULL
Returns
updated relative path (you must free the pointer) NULL when path is NULL

Definition at line 3599 of file libsheepy.c.

Here is the call graph for this function:

◆ bRelPath()

char* bRelPath ( char *  dest,
const char *  path,
const char *  start 
)

relative path

Return a relative filepath to path either from the current directory or from an optional start directory

Parameters
pathpath to convert
startreference path, cwd when NULL
Returns
relative path in dest NULL when path or dest are NULL

Definition at line 3730 of file libsheepy.c.

Here is the call graph for this function:

◆ bLRelPath()

char* bLRelPath ( char *  dest,
size_t  destSize,
char *  path,
const char *  start 
)

relative path

Return a relative filepath to path either from the current directory or from an optional start directory

Parameters
pathpath to convert
startreference path, cwd when NULL
Returns
relative path in dest NULL when path or dest are NULL

Definition at line 3860 of file libsheepy.c.

Here is the call graph for this function:

◆ getHomePath()

char* getHomePath ( void  )

get home path

Returns
home path (you must free the pointer)

Definition at line 3983 of file libsheepy.c.

◆ bGetHomePath()

char* bGetHomePath ( char *  path)

copy home path to path

Parameters
pathbuffer large enough for home path
Returns
path pointer

Definition at line 4000 of file libsheepy.c.

◆ bLGetHomePath()

char* bLGetHomePath ( char *  path,
size_t  pathSize 
)

copy home path to path maximum pathSize

Parameters
pathbuffer large enough for home path
pathSizesize of path
Returns
path pointer

Definition at line 4020 of file libsheepy.c.

Here is the call graph for this function:

◆ getCHomePath()

const char* getCHomePath ( void  )

get home path as a const char*

Returns
home path

Definition at line 4039 of file libsheepy.c.

◆ getCwd()

char* getCwd ( void  )

get current working directory

Returns
current path (you must free the pointer)

Definition at line 4054 of file libsheepy.c.

Here is the caller graph for this function:

◆ bLGetCwd()

char* bLGetCwd ( char *  path,
size_t  pathSize 
)

Definition at line 4070 of file libsheepy.c.

◆ chDir()

int chDir ( const char *  path)

change directory

Parameters
path
Returns
1 success 0 error

Definition at line 4092 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isDir()

bool isDir ( const char *  path)

is directory

Parameters
path
Returns
true when path is a directory false path is not a directory, filePath is NULL or empty string

Definition at line 4119 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shReadlink()

char* shReadlink ( const char *  path)

sheepy read link

read the first target in the link chain

the returned string has to be freed

Parameters
pathsymbolic link path
Returns
path to linked file or directory (you must free the pointer) NULL failed: path is blank or NULL path is not a symlink malloc failed to allocate the result buffer readlink failed

Definition at line 4153 of file libsheepy.c.

Here is the call graph for this function:

◆ endlink()

char* endlink ( const char *  path)

end link

read the link chain of a symbolic link to the end the returned string has to be freed

Parameters
pathsymbolic link path
Returns
path to linked file or directory (you must free the pointer) NULL failed: path is blank or NULL path is not a symlink malloc failed to allocate the result buffer readlink failed

Definition at line 4215 of file libsheepy.c.

Here is the call graph for this function:

◆ isLink()

bool isLink ( const char *  path)

is symbolic link

Parameters
path
Returns
true when path is a symbolic link false path is not a symbolic link, filePath is NULL or empty string

Definition at line 4293 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileExists()

bool fileExists ( const char *  filePath)

detect files and directories

Parameters
filePathpath to file or directory
Returns
true exists false non existant false filePath is NULL or empty string

Definition at line 4321 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileChmod()

bool fileChmod ( const char *  filePath,
mode_t  mode 
)

like chmod in stdlibc but return true/false

Parameters
filePathpath to file or directory mode: permissions
Returns
true success false filePath doesnt exist, not enough permissions... false filePath is NULL or empty string

Definition at line 4345 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileSize()

ssize_t fileSize ( const char *  filePath)

get file size

Parameters
filePathpath to file
Returns
ssize_t >= 0 size -1 an error occured or filePath is NULL or empty string

Definition at line 4369 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileSizeFP()

ssize_t fileSizeFP ( FILE *  fp)

get file size from file pointer

Parameters
fpfile pointer
Returns
ssize_t >= 0 size -1 an error occured or file pointer is NULL

Definition at line 4401 of file libsheepy.c.

Here is the caller graph for this function:

◆ readFileToS()

void* readFileToS ( const char *  filePath)

read file to string

0 is added at the end to terminate the string

Parameters
filePathpath to file
Returns
data in file (you must free the pointer) NULL an error occured

Definition at line 4427 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bReadFileToS()

void* bReadFileToS ( const char *  filePath,
void *  dst 
)

buffer read file to string

0 is added at the end to terminate the string

Parameters
dstdestination buffer
filePathpath to file
Returns
data in file NULL an error occured

Definition at line 4530 of file libsheepy.c.

Here is the call graph for this function:

◆ bLReadFileToS()

void* bLReadFileToS ( const char *  filePath,
void *  dst,
size_t  dstSize 
)

buffer size read file to string

0 is added at the end to terminate the string

Parameters
filePathpath to file
dstdestination buffer
dstSizepath buffer size, the path strlen will be at most dstSize-1
Returns
data in file NULL an error occured

Definition at line 4621 of file libsheepy.c.

Here is the call graph for this function:

◆ readFile()

ssize_t readFile ( const char *  filePath,
void **  buffer 
)

read file to buffer

The function allocates the buffer

Parameters
filePathpath to file
bufferunallocated buffer
Returns
data from file in buffer (you must free the pointer) buffer size -1 error

Definition at line 4726 of file libsheepy.c.

Here is the call graph for this function:

◆ bReadFile()

ssize_t bReadFile ( const char *  filePath,
void *  buffer 
)

buffer read file to buffer

The function allocates the buffer

Parameters
filePathpath to file
bufferalready allocated buffer
Returns
data from file in buffer buffer size -1 error

Definition at line 4782 of file libsheepy.c.

Here is the call graph for this function:

◆ bLReadFile()

ssize_t bLReadFile ( const char *  filePath,
void *  buffer,
size_t  dstSize 
)

buffer size read file to buffer

The function allocates the buffer

Parameters
filePathpath to file
bufferalready allocated buffer
dstSizepath buffer size
Returns
data from file in buffer buffer size -1 error

Definition at line 4832 of file libsheepy.c.

Here is the call graph for this function:

◆ readStreamToS()

void* readStreamToS ( FILE *  fp)

read file to string

0 is added at the end to terminate the string

Parameters
fpfile pointer
Returns
data in file (you must free the pointer) NULL an error occured

Definition at line 4482 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bReadStreamToS()

void* bReadStreamToS ( FILE *  fp,
void *  dst 
)

buffer read file to string

0 is added at the end to terminate the string

Parameters
dstdestination buffer
fpfile pointer
Returns
data in file NULL an error occured

Definition at line 4579 of file libsheepy.c.

Here is the call graph for this function:

◆ bLReadStreamToS()

void* bLReadStreamToS ( FILE *  fp,
void *  dst,
size_t  dstSize 
)

buffer size read file to string

0 is added at the end to terminate the string

Parameters
dstdestination buffer
fpfile pointer
Returns
data in file NULL an error occured

Definition at line 4678 of file libsheepy.c.

Here is the call graph for this function:

◆ writeFileS()

int writeFileS ( const char *  filePath,
const char *  string 
)

write string to file

Parameters
filePathpath to file string
Returns
1 success 0 error

Definition at line 4883 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeFile()

int writeFile ( const char *  filePath,
void *  buffer,
size_t  len 
)

write buffer to file

Parameters
filePathpath to file buffer len buffer size in bytes
Returns
1 success 0 error

Definition at line 4925 of file libsheepy.c.

Here is the call graph for this function:

◆ writeStreamS()

int writeStreamS ( FILE *  fp,
const char *  string 
)

write string to file

Parameters
fpfile pointer string
Returns
1 success 0 error

Definition at line 4963 of file libsheepy.c.

Here is the caller graph for this function:

◆ writeLStream()

int writeLStream ( FILE *  fp,
void *  buffer,
size_t  len 
)

write buffer to file

Parameters
fpfile pointer buffer len buffer size in bytes
Returns
1 success 0 error

Definition at line 4995 of file libsheepy.c.

◆ appendFileS()

bool appendFileS ( const char *  filePath,
const char *  string 
)

append string to filePath

Parameters
filePathpath to file string
Returns
true success false failed, filePath or list are NULL

Definition at line 5023 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendFile()

bool appendFile ( const char *  filePath,
void *  buffer,
size_t  len 
)

append buffer to file

Parameters
filePathpath to file buffer len buffer size in bytes
Returns
true success false error

Definition at line 5064 of file libsheepy.c.

Here is the call graph for this function:

◆ walkDir()

char** walkDir ( const char *  dirPath)

list all files in a directory recursively and sort the list

directories are not listed

Parameters
dirPathpath to directory
Returns
list of files (you must free the pointer with listFreeS) empty list when the directory is not found

Definition at line 5103 of file libsheepy.c.

Here is the call graph for this function:

◆ walkDirDir()

char** walkDirDir ( const char *  dirPath)

list all directories in a directory recursively and sort the list

files are not listed

Parameters
dirPathpath to directory
Returns
list of directories (you must free the pointer with listFreeS) empty list when the directory is not found

Definition at line 5166 of file libsheepy.c.

Here is the call graph for this function:

◆ readDir()

char** readDir ( const char *  dirPath)

list files in a directory and sort the list

directories are not listed

Parameters
dirPathpath to directory
Returns
list of files, dirPath is not prepended to the file names (you must free the pointer with listFreeS) empty list when the directory is not found

Definition at line 5227 of file libsheepy.c.

Here is the call graph for this function:

◆ readDirDir()

char** readDirDir ( const char *  dirPath)

list directories in a directory and sort the list

files are not listed

Parameters
dirPathpath to directory
Returns
list of directories, dirPath is not prepended to the names (you must free the pointer with listFreeS) empty list when the directory is not found

Definition at line 5279 of file libsheepy.c.

Here is the call graph for this function:

◆ walkDirAll()

char** walkDirAll ( const char *  dirPath)

list all files and directories in a directory recursively and sort the list

directories are listed

Parameters
dirPathpath to directory
Returns
list of files (you must free the pointer with listFreeS) empty list when the directory is not found

Definition at line 5331 of file libsheepy.c.

Here is the call graph for this function:

◆ readDirAll()

char** readDirAll ( const char *  dirPath)

list files in a directory and sort the list

directories are listed

Parameters
dirPathpath to directory
Returns
list of files, dirPath is not prepended to the file names (you must free the pointer with listFreeS) empty list when the directory is not found

Definition at line 5392 of file libsheepy.c.

Here is the call graph for this function:

◆ getUmask()

mode_t getUmask ( void  )

get umask

Definition at line 5433 of file libsheepy.c.

Here is the caller graph for this function:

◆ getCurrentPermissions()

mode_t getCurrentPermissions ( void  )

get current permissions for creating directories

Definition at line 5443 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mkdirParents()

int mkdirParents ( const char *  path)

recursive mkdir

Parameters
path
Returns
1 success 0 when path is NULL or empty

Definition at line 5457 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rmAll()

int rmAll ( const char *  path)

remove all delete recursively files and directories

Parameters
path
Returns
1 success 0 when path is NULL or empty

Definition at line 5510 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy()

int copy ( const char *  src,
const char *  dst 
)

copy files recursively This function is equivalent to 'cp -Ra' without wildcards and circular link detection

when src ends with /, the files in src are copied to dst when src does't end with /, the last directory name in src is copied to dst The permissions are copied to the destination

Parameters
srcsource path dst destination path
Returns
1 success 0 when src or dst are NULL or empty

Definition at line 5590 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shRename()

int shRename ( const char *  src,
const char *  dst 
)

rename file

Parameters
srcsource path dst destination path
Returns
1 success 0 when src or dst are NULL or empty

Definition at line 5808 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shMove()

int shMove ( const char *  src,
const char *  dst 
)

move files recursively

copy and then delete source

called shMove because it conflicts with move in ncurses

Parameters
srcsource path
dstdestination path
Returns
1 success 0 when src or dst are NULL or empty

Definition at line 5845 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSoftwareRandom()

void setSoftwareRandom ( void  )

use software random numbers works on all cpu architectures the default random function is software

Definition at line 5869 of file libsheepy.c.

◆ setHardwareRandom()

void setHardwareRandom ( void  )

use cpu hardware random number generator

Definition at line 5878 of file libsheepy.c.

◆ randomUrandomOpen()

int randomUrandomOpen ( void  )

open /dev/urandom in libsheepy

call this function before calling randomWord and randomChoice when random are not needed anymore call randomUrandomClose

Returns
1 success 0 error

Definition at line 5895 of file libsheepy.c.

◆ randomUrandomClose()

void randomUrandomClose ( void  )

close /dev/urandom in libsheepy call this function when random are not needed anymore

Definition at line 5916 of file libsheepy.c.

◆ randomWord()

uint64_t randomWord ( void  )

return random 64 bit unsigned integer call randomUrandomOpen before this calling function

Returns
random uint64 integer 0 error urandomFp file is NULL or fread failed

Definition at line 5933 of file libsheepy.c.

◆ randomWordFromHW()

uint64_t randomWordFromHW ( void  )

return random 64 bit unsigned integer from the cpu when the cpu doesn't have the random generator instruction, the program stops with 'Illegal instruction'

Definition at line 5959 of file libsheepy.c.

◆ randomChoice()

uint64_t randomChoice ( uint64_t  range)

return a random value between 0 and range 0<=value<range call randomUrandomOpen before this calling function

Parameters
range- must be > 0
Returns
random uint64 0<=value<range range error

Definition at line 5991 of file libsheepy.c.

◆ randomS()

char* randomS ( uint64_t  length)

random string

allocate and generate a random string in charset "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-,"

Parameters
stringlength
Returns
random string (you must free the pointer) NULL error opening /dev/urandom, malloc failed, fread /dev/urandom failed, length is 0

Definition at line 6020 of file libsheepy.c.

Here is the caller graph for this function:

◆ bRandomS()

char* bRandomS ( char *  dst,
size_t  dstSize 
)

buffer random string

allocate and generate a random string in charset "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-,"

Parameters
dstdestination buffer
dstSizedestination buffer size, must be at least 2, to have at least 1 random char in the string
Returns
random string NULL error opening /dev/urandom, malloc failed, fread /dev/urandom failed, length is 0

Definition at line 6080 of file libsheepy.c.

◆ randomAlphaNumS()

char* randomAlphaNumS ( uint64_t  length)

random alpha numerical string

allocate and generate a random string in charset "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

Parameters
stringlength
Returns
random string (you must free the pointer) NULL error opening /dev/urandom, malloc failed, fread /dev/urandom failed, length is 0

Definition at line 6132 of file libsheepy.c.

Here is the caller graph for this function:

◆ bRandomAlphaNumS()

char* bRandomAlphaNumS ( char *  dst,
size_t  dstSize 
)

buffer random alpha numerical string

allocate and generate a random string in charset "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

Parameters
dstdestination buffer
dstSizedestination buffer size, must be at least 2, to have at least 1 random char in the string
Returns
random string NULL error opening /dev/urandom, malloc failed, fread /dev/urandom failed, length is 0

Definition at line 6192 of file libsheepy.c.

◆ readS()

char* readS ( void  )

read String read user input (one line) as a string

there is no size limit and the buffer expands as needed

Returns
line from the user (you must free the pointer) NULL when buffer allocation failed

Definition at line 6244 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLReadS()

char* bLReadS ( char *  dst,
size_t  dstSize 
)

buffer read String read user input (one line) as a string

Parameters
dstdestination buffer
dstSizedestination buffer size, must be at least 2, to have at least 1 char from the user in the string
Returns
line from the user NULL when buffer allocation failed

Definition at line 6297 of file libsheepy.c.

◆ readPasswordS()

char* readPasswordS ( void  )

read hidden password string

Returns
newly allocated password string (you must free the pointer)

Definition at line 6377 of file libsheepy.c.

Here is the call graph for this function:

◆ zeroS()

bool zeroS ( char *  string)

write zero to all bytes in string with memset, for clearing password buffers

Parameters
string
Returns
true 0s are written false error string is NULL

Definition at line 6403 of file libsheepy.c.

◆ zeroBuf()

bool zeroBuf ( void *  buf,
size_t  len 
)

write zero to all bytes in buffer with memset

Parameters
bufbuffer
lenlength
Returns
true 0s are written false error string is NULL

Definition at line 6425 of file libsheepy.c.

◆ memdup()

void* memdup ( const void *  buf,
size_t  size 
)

memory duplicate allocate and copy buffer

Parameters
bufbuffer to duplicate
sizebuffer size
Returns
duplicated buffer (you must free the pointer) NULL when there is an error

Definition at line 6448 of file libsheepy.c.

◆ readEnter()

void readEnter ( void  )

read Enter key wait until press the enter key

Definition at line 6468 of file libsheepy.c.

◆ readLine()

char* readLine ( FILE *  fp)

readLine from file stream the fist new line is converted to 0

Parameters
fpfile stream
Returns
one line in a string (you must free the pointer) empty string when stream is empty or when there is an error reading the stream NULL when the stream is NULL

Definition at line 6493 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freeManySF()

void freeManySF ( char *  paramType,
  ... 
)

free Many String

free variable list of pointers freeManyS(s1, s2, ...);

Definition at line 6526 of file libsheepy.c.

Here is the call graph for this function:

◆ dupS()

char* dupS ( const char *  string)

duplicate string

Parameters
string
Returns
new identical string (you must free the pointer) NULL when string is NULL

Definition at line 6548 of file libsheepy.c.

Here is the caller graph for this function:

◆ shPrintfS()

void shPrintfS ( const char *  fmt,
  ... 
)

sheepy Print String

same as printf when the formating string is NULL, "(null)" is printed

Parameters
formatstring - can be NULL data

Definition at line 6566 of file libsheepy.c.

◆ shEPrintfS()

void shEPrintfS ( const char *  fmt,
  ... 
)

sheepy Error printf String print with logE

when the formating string is NULL, "(null)" is printed

Parameters
formatstring like printf
Returns
print with logE

Definition at line 6589 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logNFree()

void logNFree ( char *  s)

log and free

Parameters
stringto print, can be NULL

Definition at line 6613 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loghex()

void loghex ( const void *  buf,
size_t  len 
)

print buffer as hexadecimal string

Definition at line 6624 of file libsheepy.c.

◆ toHexS()

char* toHexS ( const void *  buf,
size_t  len 
)

create a string with bytes in buf converted to hex strings

Parameters
bufbuffer to convert to hexstring
lenbuffer size in bytes
Returns
string representing the buffer in hexadecimal "0x01, 0x02,..." (you must free the pointer)

Definition at line 6648 of file libsheepy.c.

◆ toHexSepS()

char* toHexSepS ( const void *  buf,
size_t  len,
const char *  separator 
)

create a string with bytes in buf converted to hex strings separated by separator

Parameters
bufbuffer to convert to hexstring
lenbuffer size in bytes
separatorseparator between the hexadecimal numbers
Returns
string representing the buffer in hexadecimal "0x01SEP0x02SEP..." (you must free the pointer)

Definition at line 6686 of file libsheepy.c.

Here is the caller graph for this function:

◆ toHexHeadSepS()

char* toHexHeadSepS ( const void *  buf,
size_t  len,
const char *  head,
const char *  separator 
)

create a string with bytes in buf converted to hex strings separated by separator and with head string in front of earch byte: HEADffSEP

Parameters
bufbuffer to convert to hexstring
lenbuffer size in bytes
headseparator before each hexadecimal numbers
separatorseparator after each hexadecimal numbers
Returns
string representing the buffer in hexadecimal "HEAD0x01SEPHEAD0x02SEP..." (you must free the pointer)

Definition at line 6728 of file libsheepy.c.

◆ strCpy()

char* strCpy ( char *restrict  dst,
const char *restrict  src 
)

strCpy - copy src to dst

like strcpy with sanity checks

Parameters
dstdestination buffer
srcsource string
Returns
dst string NULL error

Definition at line 6771 of file libsheepy.c.

◆ strNCpy()

char* strNCpy ( char *restrict  dst,
const char *restrict  src,
size_t  srcSize 
)

strNCpy - copy src to dst

null safe version of strncpy

Parameters
dstdestination buffer
srcsource string
srcSizesource buffer size
Returns
dst string NULL error

Definition at line 6796 of file libsheepy.c.

◆ strLCpy()

char* strLCpy ( char *restrict  dst,
size_t  dstSize,
const char *restrict  src 
)

strLCpy - copy src to dst

like strncpy and the NUL char is always added at the end of the string

Parameters
dstdestination buffer
dstSizedestination buffer size, result string will be no longer than dstSize-1
srcsource string
Returns
dst string NULL error

Definition at line 6822 of file libsheepy.c.

Here is the caller graph for this function:

◆ strCat()

char* strCat ( char *restrict  dst,
const char *restrict  src 
)

strCat - concatenate two strings

like strcat with sanity checks

Parameters
dstdestination buffer
srcsource string
Returns
string with input strings concatenated NULL error

Definition at line 6848 of file libsheepy.c.

◆ strNCat()

char* strNCat ( char *restrict  dst,
const char *restrict  src,
size_t  srcLen 
)

strNCat - concatenate two strings

like strncat with sanity checks

Parameters
dstdestination buffer
srcsource string
srcLenmax source len
Returns
string with input strings concatenated NULL error

Definition at line 6872 of file libsheepy.c.

◆ strLCat()

char* strLCat ( char *restrict  dst,
size_t  dstSize,
const char *restrict  src 
)

strLCat - concatenate two strings

like strlcat with sanity checks

Parameters
dstdestination buffer
srcsource string
dstSizedestination buffer size, result string will be no longer than dstSize-1
Returns
string with input strings concatenated NULL error

Definition at line 6897 of file libsheepy.c.

Here is the caller graph for this function:

◆ strLNCat()

char* strLNCat ( char *restrict  dst,
size_t  dstSize,
const char *restrict  src,
size_t  srcLen 
)

strLNCat - concatenate two strings

like strlcat with sanity checks

Parameters
dstdestination buffer
srcsource string
dstSizedestination buffer size, result string will be no longer than dstSize-1
srcLenmax source len
Returns
string with input strings concatenated NULL error

Definition at line 6966 of file libsheepy.c.

Here is the caller graph for this function:

◆ catSF()

char* catSF ( const char *  paramType,
  ... 
)

cat String Function

Parameters
arbitrarylist of strings seperated by commas
Returns
string with input strings concatenated (you must free the pointer)

Definition at line 6998 of file libsheepy.c.

Here is the call graph for this function:

◆ iCatSF()

char* iCatSF ( char *  dst,
const char *  paramType,
  ... 
)

cat and copy String Function dst has to be big enough to hold the result

Parameters
dstresult destination buffer arbitrary list of strings seperated by commas
Returns
dst string with input strings concatenated

Definition at line 7027 of file libsheepy.c.

◆ bLCatSF()

char* bLCatSF ( char *  dst,
size_t  dstSize,
const char *  paramType,
  ... 
)

cat and copy String Function

Parameters
dstresult destination buffer arbitrary list of strings seperated by commas
Returns
dst string with input strings concatenated

Definition at line 7057 of file libsheepy.c.

Here is the call graph for this function:

◆ formatS()

char* formatS ( const char *  fmt,
  ... 
)

format string allocate and format string using asprintf

Parameters
formatstring and other parameters
Returns
allocated and formated string (you must free the pointer) NULL when fmt is NULL or asprintf fails

Definition at line 7092 of file libsheepy.c.

Here is the caller graph for this function:

◆ bFormatS()

char* bFormatS ( char *  string,
const char *  fmt,
  ... 
)

format and store in string: bFormatS(string, "Value %d", i);

format and store in string: bFormatS(string, "Value %d", i);

Parameters
formatstring and other parameters
Returns
formated string NULL when string, fmt are NULL or sprintf fails

Definition at line 7117 of file libsheepy.c.

◆ bLFormatS()

char* bLFormatS ( char *  string,
size_t  stringSize,
const char *  fmt,
  ... 
)

format and store in string: bLFormatS(string, sizeof(string), "Value %d", i);

format and store in string: bLFormatS(string, sizeof(string), "Value %d", i);

Parameters
formatstring and other parameters
Returns
formated string NULL when string, fmt is NULL or snprintf fails

Definition at line 7140 of file libsheepy.c.

◆ appendS()

char* appendS ( const char *  string1,
const char *  string2 
)

append strings

Parameters
string1string string2 string to append at the end of string1
Returns
new string string1+string2 (you must free the pointer) dup string1 when string2 is NULL (you must free the pointer) NULL when string1 is NULL

Definition at line 7166 of file libsheepy.c.

Here is the caller graph for this function:

◆ appendCharS()

char* appendCharS ( const char *  string1,
char  c 
)

append char to string when c is 0 the result is string1

Parameters
string1string c char to append
Returns
new string string1+c (you must free the pointer) NULL when string1 is NULL

Definition at line 7209 of file libsheepy.c.

Here is the caller graph for this function:

◆ appendSChar()

char* appendSChar ( char  c,
const char *  string2 
)

append string to char

Parameters
string1string c char to append
Returns
new string string1+c (you must free the pointer) NULL when string1 is NULL

Definition at line 7245 of file libsheepy.c.

Here is the caller graph for this function:

◆ iAppendS()

char* iAppendS ( char **  string1,
const char *  string2 
)

append strings

Parameters
string1string, which is reallocated. string2 string to append at the end of string1
Returns
string1 modified string1 (realloc), string1+string2 (you must free the pointer) string1 no change when string2 is NULL (you must free the pointer) NULL no change when string1 is NULL

Definition at line 7285 of file libsheepy.c.

Here is the caller graph for this function:

◆ iAppendCharS()

char* iAppendCharS ( char **  string1,
char  c 
)

append char to string

Parameters
string1string, which is reallocated. c char to append at the end of string1
Returns
string1 modified string1 (realloc), string1+c (you must free the pointer) NULL no change when string1 is NULL

Definition at line 7329 of file libsheepy.c.

Here is the caller graph for this function:

◆ iAppendNFreeS()

char* iAppendNFreeS ( char **  string1,
char *  string2 
)

append and free strings

string2 is freed (except when there is an error)

Parameters
string1string, which is reallocated. string2 string to append at the end of string1
Returns
string1 modified string1 (realloc), string1+string2 (you must free the pointer) NULL no change when string1 or string2 are NULL

Definition at line 7368 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iAppendManySF()

char* iAppendManySF ( char **  string,
const char *  paramType,
  ... 
)

append many strings

Parameters
string1string, which is reallocated. string2 string to append at the end of string1
Returns
string1 modified string1, string1+string2 (you must free the pointer) NULL no change when string1 or string2 are NULL

Definition at line 7388 of file libsheepy.c.

Here is the call graph for this function:

◆ bAppendManySF()

char* bAppendManySF ( char *  string,
const char *  paramType,
  ... 
)

buffer append many strings

Parameters
string1string string2 string to append at the end of string1
Returns
string1 modified string1, string1+string2 NULL no change when string1 or string2 are NULL

Definition at line 7427 of file libsheepy.c.

Here is the call graph for this function:

◆ bLAppendManySF()

char* bLAppendManySF ( char *  string,
size_t  stringSize,
const char *  paramType,
  ... 
)

buffer size append many strings

Parameters
string1string string2 string to append at the end of string1
Returns
string1 modified string1, string1+string2 NULL no change when string1 or string2 are NULL

Definition at line 7466 of file libsheepy.c.

Here is the call graph for this function:

◆ prependS()

char* prependS ( const char *  string1,
const char *  string2 
)

prepend strings

Parameters
string1string string2 string to prepend at the beginning of string1
Returns
new string string2+string1 (you must free the pointer) dup string2 when string1 is NULL (you must free the pointer) NULL when string2 is NULL

Definition at line 7511 of file libsheepy.c.

Here is the call graph for this function:

◆ prependCharS()

char* prependCharS ( const char *  string1,
char  c 
)

prepend char to string

Parameters
string1string c char to prepend at the beginning of string1
Returns
new string c+string1 (you must free the pointer) NULL when string1 is NULL

Definition at line 7526 of file libsheepy.c.

Here is the call graph for this function:

◆ prependSChar()

char* prependSChar ( char  c,
const char *  string2 
)

prepend string to char

Parameters
cchar string2 string to prepend at the beginning of c
Returns
new string string2+c (you must free the pointer) NULL when string2 is NULL

Definition at line 7541 of file libsheepy.c.

Here is the call graph for this function:

◆ iPrependS()

char* iPrependS ( char **  string1,
const char *  string2 
)

prepend strings

Parameters
string1string, which is reallocated. string2 string to prepend at the beginning of string1
Returns
string1 modified string1, string2+string1 (you must free the pointer) string1 when string2 is NULL (you must free the pointer) NULL no change when string1 is NULL

Definition at line 7557 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iPrependCharS()

char* iPrependCharS ( char **  string1,
char  c 
)

prepend char to string

Parameters
string1string, which is reallocated. c char to prepend at the beginning of string1
Returns
string1 modified string1, c+string1 (you must free the pointer) NULL no change when string1 is NULL

Definition at line 7591 of file libsheepy.c.

◆ iPrependNFreeS()

char* iPrependNFreeS ( char **  string1,
char *  string2 
)

prepend and free strings

string2 is freed

Parameters
string1string, which is reallocated. string2 string to prepend at the beginning of string1
Returns
string1 modified string1, string2+string1 (you must free the pointer) NULL no change when string1 or string2 are NULL

Definition at line 7634 of file libsheepy.c.

Here is the call graph for this function:

◆ bPrependS()

char* bPrependS ( char *  string1,
const char *  string2 
)

buffer prepend strings

Parameters
string1string string2 string to prepend at the beginning of string1
Returns
string1 modified string1, string2+string1 NULL no change when string1 or string2 are NULL

Definition at line 7655 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLPrependS()

char* bLPrependS ( char *  string1,
size_t  string1Size,
const char *  string2 
)

buffer prepend strings

Parameters
string1string string2 string to prepend at the beginning of string1
Returns
string1 modified string1, string2+string1 NULL no change when string1 or string2 are NULL

Definition at line 7687 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replaceS()

char* replaceS ( const char *  s,
const char *  olds,
const char *  news,
size_t  max 
)

replace String the original remains unchanged duplicate s the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings

Parameters
sstring olds: old string to be replaced in s news: new string replacing olds in s max: number of times to replace olds, 0 to replace all found olds
Returns
new string (you must free the pointer) "" when s is empty NULL when s is NULL NULL when olds is empty

Definition at line 7731 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replaceCharSS()

char* replaceCharSS ( const char *  s,
char  olds,
const char *  news,
size_t  max 
)

Definition at line 7805 of file libsheepy.c.

Here is the call graph for this function:

◆ replaceSCharS()

char* replaceSCharS ( const char *  s,
const char *  olds,
char  news,
size_t  max 
)

Definition at line 7811 of file libsheepy.c.

Here is the call graph for this function:

◆ replaceCharCharS()

char* replaceCharCharS ( const char *  s,
char  olds,
char  news,
size_t  max 
)

Definition at line 7817 of file libsheepy.c.

Here is the call graph for this function:

◆ replaceSLen()

size_t replaceSLen ( const char *  s,
const char *  olds,
const char *  news,
size_t  max 
)

replaceSLen returns the length of the resulting string

Definition at line 7827 of file libsheepy.c.

Here is the call graph for this function:

◆ iReplaceS()

char* iReplaceS ( char **  s,
const char *  olds,
const char *  news,
size_t  max 
)

replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings

Parameters
sstring (that is allocated with malloc) olds: old string to be replaced in s news: new string replacing olds in s max: number of times to replace olds, 0 to replace all found olds
Returns
modified s string (you must free the pointer) NULL s not modified when s is NULL or empty and when olds is empty

Definition at line 7892 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iReplaceCharSS()

char* iReplaceCharSS ( char **  s,
char  olds,
const char *  news,
size_t  max 
)

Definition at line 7971 of file libsheepy.c.

Here is the call graph for this function:

◆ iReplaceSCharS()

char* iReplaceSCharS ( char **  s,
const char *  olds,
char  news,
size_t  max 
)

Definition at line 7977 of file libsheepy.c.

Here is the call graph for this function:

◆ iReplaceCharCharS()

char* iReplaceCharCharS ( char **  s,
char  olds,
char  news,
size_t  max 
)

Definition at line 7983 of file libsheepy.c.

Here is the call graph for this function:

◆ bReplaceS()

char* bReplaceS ( char *  s,
const char *  olds,
const char *  news,
size_t  max 
)

buffer replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings

Parameters
sstring olds: old string to be replaced in s news: new string replacing olds in s max: number of times to replace olds, 0 to replace all found olds
Returns
modified s string NULL s not modified when s is NULL or empty and when olds is empty

Definition at line 8004 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLReplaceS()

char* bLReplaceS ( char *  s,
size_t  sSize,
const char *  olds,
const char *  news,
size_t  max 
)

buffer size replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings

Parameters
sstring olds: old string to be replaced in s news: new string replacing olds in s max: number of times to replace olds, 0 to replace all found olds
Returns
modified s string NULL s not modified when s is NULL or empty and when olds is empty

Definition at line 8097 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replaceManySF()

char* replaceManySF ( const char *  paramType,
  ... 
)

replace Many Strings the original remains unchanged duplicate s the olds string is replaced with the news string max times in the result

Example: r = replaceManyS("asd", "s", "BNM", "a", "AAA") ^olds ^news ^olds ^news

Parameters
sstring olds: old string to be replaced in s news: new string replacing olds in s ...
Returns
new string (you must free the pointer) "" when s is empty NULL when s is NULL NULL when only 2 parameters are given NULL when any olds is empty

Definition at line 8202 of file libsheepy.c.

Here is the call graph for this function:

◆ iReplaceManySF()

char* iReplaceManySF ( char **  s,
char *  paramType,
  ... 
)

replace Many Strings the olds string is replaced with the news string max times in the result

Example: iReplaceManyS(s, "s", "BNM", "a", "AAA") ^olds ^news ^olds ^news

Parameters
string(this parameter is reallocated) olds: old string to be replaced in s news: new string replacing olds in s ...
Returns
modified string (you must free the pointer) NULL not modified when s is empty, when s is NULL, when only 2 parameters are given, when any olds is empty

Definition at line 8263 of file libsheepy.c.

Here is the call graph for this function:

◆ bReplaceManySF()

char* bReplaceManySF ( char *  s,
char *  paramType,
  ... 
)

buffer replace Many Strings the olds string is replaced with the news string max times in the result

Example: bReplaceManyS(s, "s", "BNM", "a", "AAA") ^olds ^news ^olds ^news

Parameters
stringolds: old string to be replaced in s news: new string replacing olds in s ...
Returns
modified string NULL not modified when s is empty, when s is NULL, when only 2 parameters are given, when any olds is empty

Definition at line 8317 of file libsheepy.c.

Here is the call graph for this function:

◆ bLReplaceManySF()

char* bLReplaceManySF ( char *  s,
size_t  sSize,
char *  paramType,
  ... 
)

buffer size replace Many Strings the olds string is replaced with the news string max times in the result

Example: bReplaceManyS(s, "s", "BNM", "a", "AAA") ^olds ^news ^olds ^news

Parameters
stringolds: old string to be replaced in s news: new string replacing olds in s ...
Returns
modified string NULL not modified when s is empty, when s is NULL, when only 2 parameters are given, when any olds is empty

Definition at line 8371 of file libsheepy.c.

Here is the call graph for this function:

◆ icReplaceS()

char* icReplaceS ( const char *  s,
const char *  olds,
const char *  news,
size_t  max 
)

ignore case Replace String the original remains unchanged duplicate s the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings

Parameters
sstring olds: old string to be replaced in s news: new string replacing olds in s max: number of times to replace olds, 0 to replace all found olds
Returns
new string (you must free the pointer) "" when s is empty NULL when s is NULL NULL when olds is empty

Definition at line 8429 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icReplaceCharSS()

char* icReplaceCharSS ( const char *  s,
char  olds,
const char *  news,
size_t  max 
)

Definition at line 8503 of file libsheepy.c.

Here is the call graph for this function:

◆ icReplaceSCharS()

char* icReplaceSCharS ( const char *  s,
const char *  olds,
char  news,
size_t  max 
)

Definition at line 8509 of file libsheepy.c.

Here is the call graph for this function:

◆ icReplaceCharCharS()

char* icReplaceCharCharS ( const char *  s,
char  olds,
char  news,
size_t  max 
)

Definition at line 8515 of file libsheepy.c.

Here is the call graph for this function:

◆ iicReplaceS()

char* iicReplaceS ( char **  s,
const char *  olds,
const char *  news,
size_t  max 
)

in place ignore case replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings

Parameters
sstring (this parameter is reallocated) olds: old string to be replaced in s news: new string replacing olds in s max: number of times to replace olds, 0 to replace all found olds
Returns
modified s string (you must free the pointer) NULL s not modified when s is NULL or empty and when olds is empty

Definition at line 8537 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iicReplaceCharSS()

char* iicReplaceCharSS ( char **  s,
char  olds,
const char *  news,
size_t  max 
)

Definition at line 8616 of file libsheepy.c.

Here is the call graph for this function:

◆ iicReplaceSCharS()

char* iicReplaceSCharS ( char **  s,
const char *  olds,
char  news,
size_t  max 
)

Definition at line 8622 of file libsheepy.c.

Here is the call graph for this function:

◆ iicReplaceCharCharS()

char* iicReplaceCharCharS ( char **  s,
char  olds,
char  news,
size_t  max 
)

Definition at line 8628 of file libsheepy.c.

Here is the call graph for this function:

◆ bicReplaceS()

char* bicReplaceS ( char *  s,
const char *  olds,
const char *  news,
size_t  max 
)

buffer ignore case replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings

Parameters
sstring olds: old string to be replaced in s news: new string replacing olds in s max: number of times to replace olds, 0 to replace all found olds
Returns
modified s string NULL s not modified when s is NULL or empty and when olds is empty

Definition at line 8649 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLicReplaceS()

char* bLicReplaceS ( char *  s,
size_t  sSize,
const char *  olds,
const char *  news,
size_t  max 
)

buffer size ignore case replace String the olds string is replaced with the news string max times in the result 0 for max means replace all olds strings

Parameters
sstring olds: old string to be replaced in s news: new string replacing olds in s max: number of times to replace olds, 0 to replace all found olds
Returns
modified s string NULL s not modified when s is NULL or empty and when olds is empty

Definition at line 8742 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icReplaceManySF()

char* icReplaceManySF ( const char *  paramType,
  ... 
)

ignore case replace Many Strings the original remains unchanged duplicate s the olds string is replaced with the news string max times in the result

Example: r = icReplaceManyS("asd", "s", "BNM", "a", "AAA") ^olds ^news ^olds ^news

Parameters
sstring olds: old string to be replaced in s news: new string replacing olds in s ...
Returns
new string (you must free the pointer) "" when s is empty NULL when s is NULL NULL when only 2 parameters are given NULL when any olds is empty

Definition at line 8847 of file libsheepy.c.

Here is the call graph for this function:

◆ iicReplaceManySF()

char* iicReplaceManySF ( char **  s,
char *  paramType,
  ... 
)

in place ignore case replace Many Strings the olds string is replaced with the news string max times in the result

Example: iicReplaceManyS(s, "s", "BNM", "a", "AAA") ^olds ^news ^olds ^news

Parameters
string(this parameter is reallocated) olds: old string to be replaced in s news: new string replacing olds in s ...
Returns
modified string (you must free the pointer) NULL not modified when s is empty, when s is NULL, when only 2 parameters are given, when any olds is empty

Definition at line 8908 of file libsheepy.c.

Here is the call graph for this function:

◆ bicReplaceManySF()

char* bicReplaceManySF ( char *  s,
char *  paramType,
  ... 
)

buffer ignore case replace Many Strings the olds string is replaced with the news string max times in the result

Example: bReplaceManyS(s, "s", "BNM", "a", "AAA") ^olds ^news ^olds ^news

Parameters
stringolds: old string to be replaced in s news: new string replacing olds in s ...
Returns
modified string NULL not modified when s is empty, when s is NULL, when only 2 parameters are given, when any olds is empty

Definition at line 8962 of file libsheepy.c.

Here is the call graph for this function:

◆ bLicReplaceManySF()

char* bLicReplaceManySF ( char *  s,
size_t  sSize,
char *  paramType,
  ... 
)

buffer size ignore case replace Many Strings the olds string is replaced with the news string max times in the result

Example: bReplaceManyS(s, "s", "BNM", "a", "AAA") ^olds ^news ^olds ^news

Parameters
stringolds: old string to be replaced in s news: new string replacing olds in s ...
Returns
modified string NULL not modified when s is empty, when s is NULL, when only 2 parameters are given, when any olds is empty

Definition at line 9016 of file libsheepy.c.

Here is the call graph for this function:

◆ eqS()

bool eqS ( const char *  string1,
const char *  string2 
)

string Equal compare string1 to string2

Parameters
2strings
Returns
true the strings have identical content false they differ

Definition at line 9067 of file libsheepy.c.

Here is the caller graph for this function:

◆ eqCharS()

bool eqCharS ( char  c,
const char *  string2 
)

Definition at line 9076 of file libsheepy.c.

◆ eqSChar()

bool eqSChar ( const char *  string1,
char  c 
)

Definition at line 9086 of file libsheepy.c.

◆ eqIS()

bool eqIS ( const char *  string1,
const char *  string2,
int64_t  index 
)

string Index Equal compare string1 at index to string2 when string2 is empty, the result is false

Parameters
2strings
Returns
true string1 at index is equal to string2 false they differ

Definition at line 9107 of file libsheepy.c.

Here is the caller graph for this function:

◆ eqICharS()

bool eqICharS ( const char *  string1,
char  c,
int64_t  index 
)

Definition at line 9142 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startsWithS()

bool startsWithS ( const char *  string1,
const char *  string2 
)

starts With String compare start of string1 with string2

Parameters
2strings
Returns
true when string1 starts with string2 false for other cases

Definition at line 9158 of file libsheepy.c.

Here is the caller graph for this function:

◆ startsWithCharS()

bool startsWithCharS ( const char *  string1,
char  c 
)

Definition at line 9167 of file libsheepy.c.

◆ endsWithS()

bool endsWithS ( const char *  string1,
const char *  string2 
)

ends With String compare end of string1 with string2

Parameters
2strings
Returns
true when string1 ends with string2 false for other cases

Definition at line 9185 of file libsheepy.c.

Here is the caller graph for this function:

◆ endsWithCharS()

bool endsWithCharS ( const char *  string1,
char  c 
)

Definition at line 9198 of file libsheepy.c.

◆ countS()

ssize_t countS ( const char *  s,
const char *  needle 
)

count String count number of (non-overlapping) occurrences of a substring

Example: assert(countS("aaa aaa", "a") == 6); assert(countS("aaa aaa", "ab") == 0); assert(countS("aaa aaa", "aa") == 2);

Parameters
2strings
Returns
string count -1 when there is an error

Definition at line 9230 of file libsheepy.c.

◆ countCharS()

ssize_t countCharS ( const char *  s,
char  c 
)

Definition at line 9254 of file libsheepy.c.

◆ icEqS()

bool icEqS ( const char *  string1,
const char *  string2 
)

ignore case string Equal compare string1 to string2

Parameters
2strings
Returns
true the strings have identical content false they differ

Definition at line 9283 of file libsheepy.c.

Here is the caller graph for this function:

◆ icEqCharS()

bool icEqCharS ( char  c,
const char *  string2 
)

Definition at line 9292 of file libsheepy.c.

◆ icEqSChar()

bool icEqSChar ( const char *  string1,
char  c 
)

Definition at line 9302 of file libsheepy.c.

◆ icEqIS()

bool icEqIS ( const char *  string1,
const char *  string2,
int64_t  index 
)

ignore case string Index Equal compare string1 at index to string2 when string2 is empty, the result is false

Parameters
2strings
Returns
true string1 at index is equal to string2 false they differ

Definition at line 9323 of file libsheepy.c.

Here is the caller graph for this function:

◆ icEqICharS()

bool icEqICharS ( const char *  string1,
char  c,
int64_t  index 
)

Definition at line 9358 of file libsheepy.c.

Here is the call graph for this function:

◆ icStartsWithS()

bool icStartsWithS ( const char *  string1,
const char *  string2 
)

ignore case starts With String compare start of string1 with string2

Parameters
2strings
Returns
true when string1 starts with string2 false for other cases

Definition at line 9374 of file libsheepy.c.

◆ icStartsWithCharS()

bool icStartsWithCharS ( const char *  string1,
char  c 
)

Definition at line 9383 of file libsheepy.c.

◆ icEndsWithS()

bool icEndsWithS ( const char *  string1,
const char *  string2 
)

ignore case ends With String compare end of string1 with string2

Parameters
2strings
Returns
true when string1 ends with string2 false for other cases

Definition at line 9401 of file libsheepy.c.

◆ icEndsWithCharS()

bool icEndsWithCharS ( const char *  string1,
char  c 
)

Definition at line 9414 of file libsheepy.c.

◆ icCountS()

ssize_t icCountS ( const char *  s,
const char *  needle 
)

ignore case count String count number of (non-overlapping) occurrences of a substring

Example: assert(countS("aaa aaa", "a") == 6); assert(countS("aaa aaa", "ab") == 0); assert(countS("aaa aaa", "aa") == 2);

Parameters
2strings
Returns
string count -1 when there is an error

Definition at line 9446 of file libsheepy.c.

◆ icCountCharS()

ssize_t icCountCharS ( const char *  s,
char  c 
)

Definition at line 9470 of file libsheepy.c.

◆ hasCtrlChar()

bool hasCtrlChar ( const char *  string)

has control char

Returns
true when there is a terminal control in string

Definition at line 9497 of file libsheepy.c.

◆ stripCtrlS()

char* stripCtrlS ( const char *  string)

remove terminal control char from string

Parameters
string
Returns
new string without the control chars NULL when string is NULL

Definition at line 9521 of file libsheepy.c.

◆ iStripCtrlS()

char* iStripCtrlS ( char **  string)

remove terminal control char from string

Parameters
stringpointer to a string
Returns
string without the control chars NULL when string is NULL

Definition at line 9553 of file libsheepy.c.

◆ bStripCtrlS()

char* bStripCtrlS ( char *  string)

remove terminal control char from string

Parameters
string
Returns
string without the control chars NULL when string is NULL

Definition at line 9581 of file libsheepy.c.

◆ stripColorsS()

char* stripColorsS ( const char *  string)

remove ansi colors from string

Parameters
string
Returns
new string without colors NULL when string is NULL

Definition at line 9609 of file libsheepy.c.

◆ iStripColorsS()

char* iStripColorsS ( char **  string)

remove ansi colors from string

Parameters
stringpointer to a string
Returns
string without the control chars NULL when string is NULL

Definition at line 9690 of file libsheepy.c.

◆ bStripColorsS()

char* bStripColorsS ( char *  string)

remove terminal control char from string

Parameters
string
Returns
string without the control chars NULL when string is NULL

Definition at line 9768 of file libsheepy.c.

◆ quoteS()

char* quoteS ( const char *  s,
char  delim 
)

add backslash '\' before delim('\'' or '"') and backslash the backslashes in the result avoid splitting the string when it is in a source file or a json string

Parameters
sstring to escape
delimstring delimiter ' or "
Returns
new string with escape backslash (free this buffer) null when s is null

Definition at line 9850 of file libsheepy.c.

◆ bQuoteS()

char* bQuoteS ( char *  dest,
const char *  s,
char  delim 
)

add backslash '\' before delim('\'' or '"') and backslash the backslashes in the result avoid splitting the string when it is in a source file or a json string

Parameters
destdestination buffer, it should be big enough
sstring to escape
delimstring delimiter ' or "
Returns
new string with escape backslash (free this buffer) null when s is null

Definition at line 9914 of file libsheepy.c.

◆ bLQuoteS()

char* bLQuoteS ( char *  dest,
size_t  destSize,
const char *  s,
char  delim 
)

add backslash '\' before delim('\'' or '"') and backslash the backslashes in the result avoid splitting the string when it is in a source file or a json string

Parameters
destdestination buffer
destSizedestination buffer size
sstring to escape
delimstring delimiter ' or "
Returns
new string with escape backslash (free this buffer) null when s is null

Definition at line 9959 of file libsheepy.c.

◆ quoteLenS()

size_t quoteLenS ( const char *  s,
char  delim 
)

return the length of the escaped string (without the terminating \0)

Definition at line 10007 of file libsheepy.c.

◆ escapeS()

char* escapeS ( const char *  s,
char  delim 
)

escape string according the json specification (RFC 8259) if there is in the string, the backslash is escaped and it will be parsed as the string '' be the json parsers the unicode characters should be converted to UTF8 codepoints instead of using the result can be included in a json string and the parsing will be correct

Parameters
sstring to escape
delimstring delimiter ' or "
Returns
new string with escape backslash (free this buffer) null when s is null

Definition at line 10045 of file libsheepy.c.

Here is the caller graph for this function:

◆ bEscapeS()

char* bEscapeS ( char *  dest,
const char *  s,
char  delim 
)

escape string according the json specification (RFC 8259) if there is in the string, the backslash is escaped and it will be parsed as the string '' be the json parsers the unicode characters should be converted to UTF8 codepoints instead of using the result can be included in a json string and the parsing will be correct

Parameters
destdestination buffer
sstring to escape
delimstring delimiter ' or "
Returns
new string with escape backslash (free this buffer) null when s is null

Definition at line 10134 of file libsheepy.c.

◆ bLEscapeS()

char* bLEscapeS ( char *  dest,
size_t  destSize,
const char *  s,
char  delim 
)

escape string according the json specification (RFC 8259) if there is in the string, the backslash is escaped and it will be parsed as the string '' be the json parsers the unicode characters should be converted to UTF8 codepoints instead of using the result can be included in a json string and the parsing will be correct

Parameters
destdestination buffer
destSizedestination buffer size
sstring to escape
delimstring delimiter ' or "
Returns
new string with escape backslash (free this buffer) null when s is null

Definition at line 10205 of file libsheepy.c.

◆ escapeLenS()

size_t escapeLenS ( const char *  s,
char  delim 
)

return the length of the escaped string (without the terminating \0)

Definition at line 10276 of file libsheepy.c.

◆ nibbleToHex()

char nibbleToHex ( u8  n)

convert number between 0 and 15 to hexadecimal character '0' to 'F'

Definition at line 10301 of file libsheepy.c.

Here is the caller graph for this function:

◆ cEscapeS()

char* cEscapeS ( const char *  S)

escape string to become a valid C source string control characters, backslash and double quotes are escaped.

control characters without an escaped representation () are represented as hexidecimal literal '' the result can be included in C source code and the parsing will be correct

Parameters
Sstring to escape
Returns
new escaped string (free this buffer) null when S is null

Definition at line 10328 of file libsheepy.c.

Here is the call graph for this function:

◆ bCEscapeS()

char* bCEscapeS ( char *  dest,
const char *  S 
)

escape string to become a valid C source string control characters, backslash and double quotes are escaped.

control characters without an escaped representation () are represented as hexidecimal literal '' the result can be included in C source code and the parsing will be correct

Parameters
destdestination buffer
Sstring to escape
Returns
new escaped string (free this buffer) null when S is null

Definition at line 10459 of file libsheepy.c.

Here is the call graph for this function:

◆ bLCEscapeS()

char* bLCEscapeS ( char *  dest,
size_t  destSize,
const char *  S 
)

escape string to become a valid C source string control characters, backslash and double quotes are escaped.

control characters without an escaped representation () are represented as hexidecimal literal '' the result can be included in C source code and the parsing will be correct

Parameters
destdestination buffer
destSizedestination buffer size
Sstring to escape
Returns
new escaped string (free this buffer) null when S is null

Definition at line 10549 of file libsheepy.c.

Here is the call graph for this function:

◆ cEscapeLenS()

size_t cEscapeLenS ( const char *  s)

return the length of the escaped string (without the terminating \0)

Definition at line 10693 of file libsheepy.c.

◆ isNumber()

bool isNumber ( const char *  string)

is Number (integer or float) String

1, -12 1e+4, -1.44E-1

Parameters
string
Returns
true when string is a number false when string is not a number or string is empty or NULL

Definition at line 10749 of file libsheepy.c.

Here is the caller graph for this function:

◆ isInt()

bool isInt ( const char *  string)

is Integer String

Parameters
string
Returns
true when string is an integer false when string is not an integer or string is empty or NULL

Definition at line 10811 of file libsheepy.c.

Here is the caller graph for this function:

◆ parseInt()

int64_t parseInt ( const char *  string)

convert string to decimal integer

Parameters
string
Returns
int64_t 0 when string represents 0 or doesnt represent a number or the input is NULL

Definition at line 10846 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseIntChar()

int64_t parseIntChar ( char  c)

Definition at line 10863 of file libsheepy.c.

◆ parseI64()

int64_t parseI64 ( const char *  string)

convert string to decimal integer

Parameters
string
Returns
int64_t 0 when string represents 0 or doesnt represent a number or the input is NULL

Definition at line 10880 of file libsheepy.c.

Here is the call graph for this function:

◆ parseI64Char()

int64_t parseI64Char ( char  c)

Definition at line 10897 of file libsheepy.c.

◆ parseDouble()

double parseDouble ( const char *  string)

convert string to double

Parameters
string
Returns
double 0 when string represents 0 or doesnt represent a number or the input is NULL

Definition at line 10914 of file libsheepy.c.

Here is the caller graph for this function:

◆ parseDoubleChar()

double parseDoubleChar ( char  c)

Definition at line 10927 of file libsheepy.c.

◆ parseHex()

uint64_t parseHex ( const char *  string)

parse hexadecimal number in a string

Parameters
stringhexadecimal string starting with 0x
Returns
integer value 0 failed or the value is 0

Definition at line 10944 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intToS()

char* intToS ( int64_t  n)

int To String

convert int to string

Parameters
int64number
Returns
string representing the number (you must free the pointer)

Definition at line 10970 of file libsheepy.c.

Here is the caller graph for this function:

◆ bIntToS()

char* bIntToS ( char *  s,
int64_t  n 
)

buffer int To String

convert int to string

Parameters
int64number
Returns
string representing the number

Definition at line 10989 of file libsheepy.c.

◆ doubleToS()

char* doubleToS ( double  n)

double To String

convert int to string

Parameters
doublenumber
Returns
string representing the number (you must free the pointer)

Definition at line 11008 of file libsheepy.c.

Here is the caller graph for this function:

◆ bDoubleToS()

char* bDoubleToS ( char *  s,
double  n 
)

buffer double To String

convert int to string

Parameters
doublenumber
Returns
string representing the number

Definition at line 11027 of file libsheepy.c.

◆ lenS()

size_t lenS ( const char *  string)

length string

return strlen when possible

Parameters
string
Returns
strlen value 0 when string is NULL

Definition at line 11047 of file libsheepy.c.

Here is the caller graph for this function:

◆ sizeS()

size_t sizeS ( const char *  string)

string buffer size

return strlen+1 when possible

Parameters
string
Returns
strlen+1 value 0 when string is NULL

Definition at line 11066 of file libsheepy.c.

◆ upperS()

char* upperS ( const char *  string)

upper case String duplicate string

Parameters
string
Returns
new upper case string (you must free the pointer)

Definition at line 11083 of file libsheepy.c.

◆ iUpperS()

char* iUpperS ( char **  string)

upper case String

Parameters
string
Returns
upper case string NULL error

Definition at line 11114 of file libsheepy.c.

◆ bUpperS()

char* bUpperS ( char *  string)

buffer upper case String

Parameters
string
Returns
upper case string NULL error

Definition at line 11139 of file libsheepy.c.

◆ lowerS()

char* lowerS ( const char *  string)

lower case String duplicate string

Parameters
string
Returns
new lower case string (you must free the pointer)

Definition at line 11164 of file libsheepy.c.

◆ iLowerS()

char* iLowerS ( char **  string)

lower case String

Parameters
string
Returns
lower case string NULL error

Definition at line 11195 of file libsheepy.c.

Here is the caller graph for this function:

◆ bLowerS()

char* bLowerS ( char *  string)

buffer lower case String

Parameters
string
Returns
lower case string NULL error

Definition at line 11220 of file libsheepy.c.

◆ trimS()

char* trimS ( const char *  string)

trim String duplicate string

Parameters
string
Returns
new string without leading or trailing spaces (you must free the pointer)

Definition at line 11245 of file libsheepy.c.

Here is the caller graph for this function:

◆ iTrimS()

char* iTrimS ( char **  string)

trim String

Parameters
string(this parameter is reallocated)
Returns
string without leading or trailing spaces NULL error

Definition at line 11292 of file libsheepy.c.

Here is the call graph for this function:

◆ bTrimS()

char* bTrimS ( char *  string)

buffer trim String

Parameters
string
Returns
string without leading or trailing spaces NULL error

Definition at line 11345 of file libsheepy.c.

Here is the call graph for this function:

◆ lTrimS()

char* lTrimS ( const char *  string)

left trim String duplicate string

Parameters
string
Returns
new string without leading spaces (you must free the pointer)

Definition at line 11397 of file libsheepy.c.

◆ iLTrimS()

char* iLTrimS ( char **  string)

left trim String

Parameters
string(this parameter is reallocated)
Returns
string without leading spaces (you must free the pointer) NULL error

Definition at line 11430 of file libsheepy.c.

Here is the call graph for this function:

◆ bLTrimS()

char* bLTrimS ( char *  string)

buffer left trim String

Parameters
string
Returns
string without leading spaces NULL error

Definition at line 11464 of file libsheepy.c.

◆ rTrimS()

char* rTrimS ( const char *  string)

right trim String duplicate string

Parameters
string
Returns
new string without trailing spaces (you must free the pointer)

Definition at line 11492 of file libsheepy.c.

◆ iRTrimS()

char* iRTrimS ( char **  string)

right trim String

Parameters
string
Returns
string without trailing spaces NULL error

Definition at line 11529 of file libsheepy.c.

◆ bRTrimS()

char* bRTrimS ( char *  string)

buffer right trim String

Parameters
string
Returns
string without trailing spaces NULL error

Definition at line 11559 of file libsheepy.c.

◆ uniqS()

char* uniqS ( const char *  string,
char  c 
)

uniq String duplicate string

remove successive repetitions of char c

Parameters
stringc character to remove
Returns
new string without successive repetitions of char c (you must free the pointer)

Definition at line 11592 of file libsheepy.c.

◆ iUniqS()

char* iUniqS ( char **  string,
char  c 
)

uniq String

remove successive repetitions of char c

Parameters
stringc character to remove
Returns
string without successive repetitions of char c NULL error

Definition at line 11638 of file libsheepy.c.

Here is the caller graph for this function:

◆ bUniqS()

char* bUniqS ( char *  string,
char  c 
)

buffer uniq String

remove successive repetitions of char c

Parameters
stringc character to remove
Returns
string without successive repetitions of char c NULL error

Definition at line 11682 of file libsheepy.c.

◆ icUniqS()

char* icUniqS ( const char *  string,
char  c 
)

ignore case uniq String duplicate string

remove successive repetitions of char c

Parameters
stringc character to remove
Returns
new string without successive repetitions of char c (you must free the pointer)

Definition at line 11726 of file libsheepy.c.

◆ iicUniqS()

char* iicUniqS ( char **  string,
char  c 
)

in place ignore case uniq String

remove successive repetitions of char c

Parameters
stringc character to remove
Returns
string without successive repetitions of char c NULL error

Definition at line 11774 of file libsheepy.c.

◆ bicUniqS()

char* bicUniqS ( char *  string,
char  c 
)

ignore case buffer uniq String

remove successive repetitions of char c

Parameters
stringc character to remove
Returns
string without successive repetitions of char c NULL error

Definition at line 11820 of file libsheepy.c.

◆ repeatS()

char* repeatS ( const char *  string,
size_t  count 
)

repeat string count times

Parameters
string
countnumber of times string is repeated
Returns
new string with string repeated count times (you must free the pointer) NULL when string is NULL

Definition at line 11865 of file libsheepy.c.

Here is the caller graph for this function:

◆ iRepeatS()

char* iRepeatS ( char **  string,
size_t  count 
)

repeat string count times

Parameters
string(this parameter is reallocated)
countnumber of times string is repeated
Returns
string with string repeated count times NULL when string is NULL

Definition at line 11908 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bRepeatS()

char* bRepeatS ( char *  dest,
const char *  string,
size_t  count 
)

repeat string count times

Parameters
destbuffer big enough to hold count times string
string
countnumber of times string is repeated
Returns
dest with string repeated count times NULL when dest or string are NULL

Definition at line 11956 of file libsheepy.c.

Here is the caller graph for this function:

◆ bLRepeatS()

char* bLRepeatS ( char *  dest,
size_t  destSize,
const char *  string,
size_t  count 
)

repeat string count times

Parameters
destbuffer big enough to hold count times string
destSizedest buffer size (sizeof(dest))
string
countnumber of times string is repeated
Returns
dest with string repeated count times NULL when dest or string are NULL

Definition at line 11996 of file libsheepy.c.

Here is the caller graph for this function:

◆ repeatCharS()

char* repeatCharS ( char  c,
size_t  count 
)

repeat char count times

Parameters
cchar to repeat
countnumber of times c is repeated
Returns
new string with c repeated count times (you must free the pointer)

Definition at line 12036 of file libsheepy.c.

Here is the call graph for this function:

◆ bRepeatCharS()

char* bRepeatCharS ( char *  dest,
char  c,
size_t  count 
)

repeat char count times

Parameters
destbuffer big enough to hold count times c
cchar to repeat
countnumber of times c is repeated
Returns
dest with c repeated count times NULL when dest is NULL

Definition at line 12055 of file libsheepy.c.

Here is the call graph for this function:

◆ bLRepeatCharS()

char* bLRepeatCharS ( char *  dest,
size_t  destSize,
char  c,
size_t  count 
)

repeat char count times

Parameters
destbuffer big enough to hold count times c
destSizedest buffer size (sizeof(dest))
cchar to repeat
countnumber of times c is repeated
Returns
dest with c repeated count times NULL when dest is NULL

Definition at line 12076 of file libsheepy.c.

Here is the call graph for this function:

◆ repeatLenS()

ssize_t repeatLenS ( const char *  string,
size_t  count 
)

length of string repeated count times

Parameters
string
countnumber of times string is repeated
Returns
length of string repeated count times -1 when string is NULL

Definition at line 12093 of file libsheepy.c.

◆ ellipsisStartS()

char* ellipsisStartS ( const char *  string,
size_t  targetLength,
const char *  ellipsisString 
)

ellipsis start string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the right and the pad is applied once
ellipsisStringThe string to pad the current string with.
Returns
new string of the specified length with the pad string applied from the start (you must free the pointer) NULL when string or ellipsisString are NULL

Definition at line 12126 of file libsheepy.c.

Here is the call graph for this function:

◆ iEllipsisStartS()

char* iEllipsisStartS ( char **  string,
size_t  targetLength,
const char *  ellipsisString 
)

ellipsis start string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string(this parameter is reallocated)
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the right and the pad is applied once
ellipsisStringThe string to pad the current string with.
Returns
updated string of the specified length with the pad string applied from the start NULL when string or ellipsisString are NULL

Definition at line 12172 of file libsheepy.c.

Here is the call graph for this function:

◆ bEllipsisStartS()

char* bEllipsisStartS ( char *  dest,
const char *  string,
size_t  targetLength,
const char *  ellipsisString 
)

ellipsis start string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the right and the pad is applied once
ellipsisStringThe string to pad the current string with.
Returns
string in dest of the specified length with the pad string applied from the start NULL when dest, string or ellipsisString are NULL

Definition at line 12217 of file libsheepy.c.

Here is the call graph for this function:

◆ bLEllipsisStartS()

char* bLEllipsisStartS ( char *  dest,
size_t  destSize,
const char *  string,
size_t  targetLength,
const char *  ellipsisString 
)

ellipsis start string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the right and the pad is applied once
ellipsisStringThe string to pad the current string with.
Returns
string in dest of the specified length with the pad string applied from the start NULL when dest, string or ellipsisString are NULL

Definition at line 12265 of file libsheepy.c.

Here is the call graph for this function:

◆ ellipsisStartCharS()

char* ellipsisStartCharS ( const char *  string,
size_t  targetLength,
char  ellipsisChar 
)

ellipsis start string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the right and the pad is applied once
ellipsisCharThe char to pad the current string with.
Returns
new string of the specified length with the pad string applied from the start (you must free the pointer) NULL when string or ellipsisString are NULL

Definition at line 12319 of file libsheepy.c.

Here is the call graph for this function:

◆ iEllipsisStartCharS()

char* iEllipsisStartCharS ( char **  string,
size_t  targetLength,
char  ellipsisChar 
)

ellipsis start string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string(this parameter is reallocated)
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the right and the pad is applied once
ellipsisCharThe char to pad the current string with.
Returns
updated string of the specified length with the pad string applied from the start NULL when string or ellipsisString are NULL

Definition at line 12366 of file libsheepy.c.

Here is the call graph for this function:

◆ bEllipsisStartCharS()

char* bEllipsisStartCharS ( char *  dest,
const char *  string,
size_t  targetLength,
char  ellipsisChar 
)

ellipsis start string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the right and the pad is applied once
ellipsisCharThe char to pad the current string with.
Returns
string in dest of the specified length with the pad string applied from the start NULL when dest, string or ellipsisString are NULL

Definition at line 12413 of file libsheepy.c.

Here is the call graph for this function:

◆ bLEllipsisStartCharS()

char* bLEllipsisStartCharS ( char *  dest,
size_t  destSize,
const char *  string,
size_t  targetLength,
char  ellipsisChar 
)

ellipsis start string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the right and the pad is applied once
ellipsisCharThe char to pad the current string with.
Returns
string in dest of the specified length with the pad string applied from the start NULL when dest, string or ellipsisString are NULL

Definition at line 12463 of file libsheepy.c.

Here is the call graph for this function:

◆ ellipsisLenS()

ssize_t ellipsisLenS ( const char *  string,
size_t  targetLength,
const char *  ellipsisString 
)

length of string after ellipsis

Parameters
string
Returns
length of string after ellipsis -1 when string is NULL

Definition at line 12511 of file libsheepy.c.

◆ ellipsisEndS()

char* ellipsisEndS ( const char *  string,
size_t  targetLength,
const char *  ellipsisString 
)

ellipsis end string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the left and the pad is applied once
ellipsisStringThe string to pad the current string with.
Returns
new string of the specified length with the pad string applied from the end (you must free the pointer) NULL when string or ellipsisString are NULL

Definition at line 12546 of file libsheepy.c.

Here is the call graph for this function:

◆ iEllipsisEndS()

char* iEllipsisEndS ( char **  string,
size_t  targetLength,
const char *  ellipsisString 
)

ellipsis end string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string(this parameter is reallocated)
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the left and the pad is applied once
ellipsisStringThe string to pad the current string with.
Returns
updated string of the specified length with the pad string applied from the end NULL when string or ellipsisString are NULL

Definition at line 12595 of file libsheepy.c.

Here is the call graph for this function:

◆ bEllipsisEndS()

char* bEllipsisEndS ( char *  dest,
const char *  string,
size_t  targetLength,
const char *  ellipsisString 
)

ellipsis end string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the left and the pad is applied once
ellipsisStringThe string to pad the current string with.
Returns
string in dest of the specified length with the pad string applied from the end NULL when dest, string or ellipsisString are NULL

Definition at line 12644 of file libsheepy.c.

Here is the call graph for this function:

◆ bLEllipsisEndS()

char* bLEllipsisEndS ( char *  dest,
size_t  destSize,
const char *  string,
size_t  targetLength,
const char *  ellipsisString 
)

ellipsis end string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the left and the pad is applied once
ellipsisStringThe string to pad the current string with.
Returns
string in dest of the specified length with the pad string applied from the end NULL when dest, string or ellipsisString are NULL

Definition at line 12699 of file libsheepy.c.

Here is the call graph for this function:

◆ ellipsisEndCharS()

char* ellipsisEndCharS ( const char *  string,
size_t  targetLength,
char  ellipsisChar 
)

ellipsis end string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the left and the pad is applied once
ellipsisCharThe char to pad the current string with.
Returns
new string of the specified length with the pad string applied from the end (you must free the pointer) NULL when string or ellipsisString are NULL

Definition at line 12757 of file libsheepy.c.

Here is the call graph for this function:

◆ iEllipsisEndCharS()

char* iEllipsisEndCharS ( char **  string,
size_t  targetLength,
char  ellipsisChar 
)

ellipsis end string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string(this parameter is reallocated)
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the left and the pad is applied once
ellipsisCharThe char to pad the current string with.
Returns
updated string of the specified length with the pad string applied from the end NULL when string or ellipsisString are NULL

Definition at line 12802 of file libsheepy.c.

Here is the call graph for this function:

◆ bEllipsisEndCharS()

char* bEllipsisEndCharS ( char *  dest,
const char *  string,
size_t  targetLength,
char  ellipsisChar 
)

ellipsis end string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the left and the pad is applied once
ellipsisCharThe char to pad the current string with.
Returns
string in dest of the specified length with the pad string applied from the end NULL when dest, string or ellipsisString are NULL

Definition at line 12847 of file libsheepy.c.

Here is the call graph for this function:

◆ bLEllipsisEndCharS()

char* bLEllipsisEndCharS ( char *  dest,
size_t  destSize,
const char *  string,
size_t  targetLength,
char  ellipsisChar 
)

ellipsis end string

This function pads the current string with a given string if current string is longer than target length If target length is more than current string's length, the current string is returned as is

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is truncated from the left and the pad is applied once
ellipsisStringThe string to pad the current string with.
Returns
string in dest of the specified length with the pad string applied from the end NULL when dest, string or ellipsisString are NULL

Definition at line 12898 of file libsheepy.c.

Here is the call graph for this function:

◆ padStartS()

char* padStartS ( const char *  string,
size_t  targetLength,
const char *  padString 
)

pad start string

This function pads the current string with a given string (repeated, if needed) until the resulting string reaches a given length. The padding is applied from the start (left) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is returned as is
padStringThe string to pad the current string with. If this string is too long to stay within the target length, it will be truncated from the right. The current string is returned as is when an empty string is supplied
Returns
new string of the specified length with the pad string applied from the start (you must free the pointer) NULL when string or padString are NULL

Definition at line 12955 of file libsheepy.c.

Here is the call graph for this function:

◆ iPadStartS()

char* iPadStartS ( char **  string,
size_t  targetLength,
const char *  padString 
)

pad start string

This function pads the current string with a given string (repeated, if needed) until the resulting string reaches a given length. The padding is applied from the start (left) of the current string

Parameters
string(this parameter is reallocated)
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is returned as is
padStringThe string to pad the current string with. If this string is too long to stay within the target length, it will be truncated from the right. The current string is returned as is when an empty string is supplied
Returns
updated string of the specified length with the pad string applied from the start NULL when string or padString are NULL

Definition at line 13009 of file libsheepy.c.

Here is the call graph for this function:

◆ bPadStartS()

char* bPadStartS ( char *  dest,
const char *  string,
size_t  targetLength,
const char *  padString 
)

pad start string

This function pads the current string with a given string (repeated, if needed) until the resulting string reaches a given length. The padding is applied from the start (left) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is returned as is
padStringThe string to pad the current string with. If this string is too long to stay within the target length, it will be truncated from the right. The current string is returned as is when an empty string is supplied
Returns
new string of the specified length with the pad string applied from the start NULL when dest, string or padString are NULL

Definition at line 13061 of file libsheepy.c.

Here is the call graph for this function:

◆ bLPadStartS()

char* bLPadStartS ( char *  dest,
size_t  destSize,
const char *  string,
size_t  targetLength,
const char *  padString 
)

pad start string

This function pads the current string with a given string (repeated, if needed) until the resulting string reaches a given length. The padding is applied from the start (left) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is returned as is
padStringThe string to pad the current string with. If this string is too long to stay within the target length, it will be truncated from the right. The current string is returned as is when an empty string is supplied
Returns
new string of the specified length with the pad string applied from the start NULL when dest, string or padString are NULL

Definition at line 13123 of file libsheepy.c.

Here is the call graph for this function:

◆ padStartCharS()

char* padStartCharS ( const char *  string,
size_t  targetLength,
char  padChar 
)

pad start string

This function pads the current string with a given character (repeated, if needed) until the resulting string reaches a given length. The padding is applied from the start (left) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is returned as is
padCharThe character to pad the current string with
Returns
new string of the specified length with the pad character applied from the start (you must free the pointer) NULL when string is NULL

Definition at line 13183 of file libsheepy.c.

Here is the call graph for this function:

◆ iPadStartCharS()

char* iPadStartCharS ( char **  string,
size_t  targetLength,
char  padChar 
)

pad start string

This function pads the current string with a given character (repeated, if needed) until the resulting string reaches a given length. The padding is applied from the start (left) of the current string

Parameters
string(this parameter is reallocated)
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is returned as is
padCharThe character to pad the current string with
Returns
new string of the specified length with the pad character applied from the start NULL when string is NULL

Definition at line 13231 of file libsheepy.c.

Here is the call graph for this function:

◆ bPadStartCharS()

char* bPadStartCharS ( char *  dest,
const char *  string,
size_t  targetLength,
char  padChar 
)

pad start string

This function pads the current string with a given character (repeated, if needed) until the resulting string reaches a given length. The padding is applied from the start (left) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is returned as is
padCharThe character to pad the current string with
Returns
new string of the specified length with the pad character applied from the start NULL when dest or string are NULL

Definition at line 13277 of file libsheepy.c.

Here is the call graph for this function:

◆ bLPadStartCharS()

char* bLPadStartCharS ( char *  dest,
size_t  destSize,
const char *  string,
size_t  targetLength,
char  padChar 
)

pad start string

This function pads the current string with a given character (repeated, if needed) until the resulting string reaches a given length. The padding is applied from the start (left) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is returned as is
padCharThe character to pad the current string with
Returns
new string of the specified length with the pad character applied from the start NULL when dest or string are NULL

Definition at line 13332 of file libsheepy.c.

Here is the call graph for this function:

◆ padStartLenS()

ssize_t padStartLenS ( const char *  string,
size_t  targetLength,
const char *  padString 
)

length of string after padStart

Parameters
string
Returns
length of string after padStart -1 when string is NULL

Definition at line 13378 of file libsheepy.c.

◆ padEndS()

char* padEndS ( const char *  string,
size_t  targetLength,
const char *  padString 
)

pad end string

This function pads the current string with a given string (repeated, if needed) until the resulting string reaches a given length. The padding is applied from the end (right) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string is returned as is
padStringThe string to pad the current string with. If this string is too long to stay within the target length, it will be truncated and the left-most part will be applied. The current string is returned as is when an empty string is supplied
Returns
new string of the specified length with the pad string applied at the end of the current string (you must free the pointer) NULL when string or padString are NULL

Definition at line 13417 of file libsheepy.c.

Here is the call graph for this function:

◆ iPadEndS()

char* iPadEndS ( char **  string,
size_t  targetLength,
const char *  padString 
)

pad end string

This function pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string

Parameters
string(this parameter is reallocated)
targetLengthThe length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string will be returned as is
padStringThe string to pad the current string with. If this string is too long to stay within the target length, it will be truncated and the left-most part will be applied. The current string is returned as is when an empty string is supplied
Returns
updated string of the specified length with the pad string applied at the end of the current string NULL when string or padString are NULL

Definition at line 13473 of file libsheepy.c.

Here is the call graph for this function:

◆ bPadEndS()

char* bPadEndS ( char *  dest,
const char *  string,
size_t  targetLength,
const char *  padString 
)

pad end string

This function pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string will be returned as is
padStringThe string to pad the current string with. If this string is too long to stay within the target length, it will be truncated and the left-most part will be applied. The current string is returned as is when an empty string is supplied
Returns
new string of the specified length with the pad string applied at the end of the current string NULL when dest, string or padString are NULL

Definition at line 13527 of file libsheepy.c.

Here is the call graph for this function:

◆ bLPadEndS()

char* bLPadEndS ( char *  dest,
size_t  destSize,
const char *  string,
size_t  targetLength,
const char *  padString 
)

pad end string

This function pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string will be returned as is
padStringThe string to pad the current string with. If this string is too long to stay within the target length, it will be truncated and the left-most part will be applied. The current string is returned as is when an empty string is supplied
Returns
new string of the specified length with the pad string applied at the end of the current string NULL when dest, string or padString are NULL

Definition at line 13589 of file libsheepy.c.

Here is the call graph for this function:

◆ padEndCharS()

char* padEndCharS ( const char *  string,
size_t  targetLength,
char  padChar 
)

pad end string

This function pads the current string with a given character (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string will be returned as is
padCharThe character to pad the current string with
Returns
new string of the specified length with the pad character applied at the end of the current string (you must free the pointer) NULL when string is NULL

Definition at line 13649 of file libsheepy.c.

Here is the call graph for this function:

◆ iPadEndCharS()

char* iPadEndCharS ( char **  string,
size_t  targetLength,
char  padChar 
)

pad end string

This function pads the current string with a given character (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string

Parameters
string(this parameter is reallocated)
targetLengthThe length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string will be returned as is
padCharThe character to pad the current string with
Returns
updated string of the specified length with the pad character applied at the end of the current string NULL when string is NULL

Definition at line 13697 of file libsheepy.c.

Here is the call graph for this function:

◆ bPadEndCharS()

char* bPadEndCharS ( char *  dest,
const char *  string,
size_t  targetLength,
char  padChar 
)

pad end string

This function pads the current string with a given character (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string will be returned as is
padCharThe character to pad the current string with
Returns
new string of the specified length with the pad character applied at the end of the current string NULL when dest or string are NULL

Definition at line 13745 of file libsheepy.c.

Here is the call graph for this function:

◆ bLPadEndCharS()

char* bLPadEndCharS ( char *  dest,
size_t  destSize,
const char *  string,
size_t  targetLength,
char  padChar 
)

pad end string

This function pads the current string with a given character (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string

Parameters
string
targetLengthThe length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string will be returned as is
padCharThe string to pad the current string with
Returns
new string of the specified length with the pad character applied at the end of the current string NULL when dest, string or padString are NULL

Definition at line 13800 of file libsheepy.c.

Here is the call graph for this function:

◆ padEndLenS()

ssize_t padEndLenS ( const char *  string,
size_t  targetLength,
const char *  padString 
)

length of string after padEnd

Parameters
string
Returns
length of string after padEnd -1 when string is NULL

Definition at line 13847 of file libsheepy.c.

◆ getS()

char getS ( const char *  string,
int64_t  index 
)

get string

get char at python index

Definition at line 13872 of file libsheepy.c.

Here is the caller graph for this function:

◆ setS()

char* setS ( char *  string,
int64_t  index,
char  c 
)

set string

set char at python index

Definition at line 13898 of file libsheepy.c.

Here is the caller graph for this function:

◆ swapS()

char* swapS ( char *  string,
int64_t  index1,
int64_t  index2 
)

swap characters in string

Parameters
string
index1index of character to swap
index2index of second character to swap
Returns
new string with characters swapped at index1 and index2 (you must free this pointer) NULL when string is NULL or when index1 or index2 are outside the string

Definition at line 13933 of file libsheepy.c.

◆ iSwapS()

char* iSwapS ( char **  string,
int64_t  index1,
int64_t  index2 
)

swap characters in string

Parameters
string
index1index of character to swap
index2index of second character to swap
Returns
updated string with characters swapped at index1 and index2 (you must free this pointer) NULL when string is NULL or when index1 or index2 are outside the string

Definition at line 13986 of file libsheepy.c.

◆ bSwapS()

char* bSwapS ( char *  string,
int64_t  index1,
int64_t  index2 
)

swap characters in string

Parameters
string
index1index of character to swap
index2index of second character to swap
Returns
string with characters swapped at index1 and index2 NULL when string is NULL or when index1 or index2 are outside the string

Definition at line 14034 of file libsheepy.c.

◆ bLSwapS()

char* bLSwapS ( char *  string,
size_t  size,
int64_t  index1,
int64_t  index2 
)

swap characters in string

if string's length is more than size then size is the end of string and the indexes are computed relative to size

Parameters
string
sizestring buffer size
index1index of character to swap
index2index of second character to swap
Returns
string with characters swapped at index1 and index2 NULL when string is NULL or when index1 or index2 are outside the string

Definition at line 14087 of file libsheepy.c.

◆ sliceS()

char* sliceS ( const char *  string,
int64_t  start,
int64_t  end 
)

slice String return new string which is the string between start and end negative indexes are allowed

(copy substring from start to end)

Parameters
stringto slice start: start index, must be in the string end: end index, must be in the string after start
Returns
new sliced string (you must free the pointer) "" when start=end NULL when start and end are not set correctly

Definition at line 14148 of file libsheepy.c.

Here is the caller graph for this function:

◆ iSliceS()

char* iSliceS ( char **  string,
int64_t  start,
int64_t  end 
)

slice String return string which is the string between start and end negative indexes are allowed

Parameters
stringto slice (this parameter is reallocated) start: start index, must be in the string end: end index, must be in the string after start
Returns
sliced string (you must free the pointer) "" when start=end NULL unchanged string when start and end are not set correctly

Definition at line 14213 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bSliceS()

char* bSliceS ( char *  string,
int64_t  start,
int64_t  end 
)

buffer slice String return string which is the string between start and end negative indexes are allowed

Parameters
stringto slice start: start index, must be in the string end: end index, must be in the string after start
Returns
sliced string "" when start=end NULL unchanged string when start and end are not set correctly

Definition at line 14286 of file libsheepy.c.

◆ bLSliceS()

char* bLSliceS ( char *  string,
size_t  stringSize,
int64_t  start,
int64_t  end 
)

buffer size slice String return string which is the string between start and end negative indexes are allowed

Parameters
stringto slice
stringSizestring buffer size
startstart index, must be in the string
endend index, must be in the string after start
Returns
sliced string "" when start=end NULL unchanged string when start and end are not set correctly

Definition at line 14355 of file libsheepy.c.

◆ cropS()

char* cropS ( char *  string,
int64_t  start,
int64_t  end 
)

Crop String return a new string with characters from start and end in string and delete characters from start to end in the original string negative indexes are allowed.

Parameters
string
startindex, must be in the list
endindex, must be in the list
Returns
new sliced string (you must free the pointer with free) empty list when start=end unchanged when list is empty unchanged when list is NULL or when start and end are not set correctly NULL error

Definition at line 14430 of file libsheepy.c.

Here is the call graph for this function:

◆ iCropS()

char* iCropS ( char **  string,
int64_t  start,
int64_t  end 
)

Crop String return a new string with characters from start and end in string and delete characters from start to end in the original string negative indexes are allowed.

Parameters
string
startindex, must be in the list
endindex, must be in the list
Returns
new sliced string (you must free the pointer with free) empty list when start=end unchanged when list is empty unchanged when list is NULL or when start and end are not set correctly NULL error

Definition at line 14501 of file libsheepy.c.

Here is the call graph for this function:

◆ cropElemS()

char cropElemS ( char *  string,
int64_t  index 
)

Definition at line 14553 of file libsheepy.c.

Here is the caller graph for this function:

◆ iCropElemS()

char iCropElemS ( char **  string,
int64_t  index 
)

Definition at line 14583 of file libsheepy.c.

Here is the call graph for this function:

◆ insertS()

char* insertS ( const char *  string,
int64_t  index,
const char *  toInsert 
)

insert string in string at index

return new string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string
indexin string
toInsertstring
Returns
new string (you must free the pointer) NULL when string is NULL or invalid index

Definition at line 14609 of file libsheepy.c.

Here is the call graph for this function:

◆ insertNFreeS()

char* insertNFreeS ( const char *  string,
int64_t  index,
char *  toInsert 
)

insert string in string at index and free toInsert when successful

return new string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string
indexin string
toInsertstring
Returns
new string (you must free the pointer) NULL when string is NULL or invalid index

Definition at line 14678 of file libsheepy.c.

Here is the call graph for this function:

◆ iInsertS()

char* iInsertS ( char **  string,
int64_t  index,
const char *  toInsert 
)

insert string in string at index

return string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string(this parameter is reallocated)
indexin string
toInsertstring
Returns
modified string (you must free the pointer) NULL unchanged string when string is NULL or invalid index

Definition at line 14756 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iInsertNFreeS()

char* iInsertNFreeS ( char **  string,
int64_t  index,
char *  toInsert 
)

insert string in string at index and free toInsert

return string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string(this parameter is reallocated)
indexin string
toInsertstring
Returns
modified string (you must free the pointer) NULL unchanged string when string is NULL or invalid index

Definition at line 14835 of file libsheepy.c.

Here is the call graph for this function:

◆ bInsertS()

char* bInsertS ( char *  string,
int64_t  index,
const char *  toInsert 
)

buffer insert string in string at index

return string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string
indexin string
toInsertstring
Returns
modified string NULL unchanged string when string is NULL or invalid index

Definition at line 14917 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLInsertS()

char* bLInsertS ( char *  string,
size_t  stringSize,
int64_t  index,
const char *  toInsert 
)

buffer size insert string in string at index

return string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string
indexin string
toInsertstring
Returns
modified string NULL unchanged string when string is NULL or invalid index

Definition at line 14986 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ injectS()

char* injectS ( const char *  string,
int64_t  index,
char  toInject 
)

inject a char in string at index

return new string with toInject at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string
indexin string
toInjectchar
Returns
new string (you must free the pointer) NULL when string is NULL or invalid index

Definition at line 15061 of file libsheepy.c.

Here is the call graph for this function:

◆ iInjectS()

char* iInjectS ( char **  string,
int64_t  index,
char  toInject 
)

inject a char in string at index

return string with toInject at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string(this parameter is reallocated)
indexin string
toInjectchar
Returns
modified string (you must free the pointer) NULL unchanged string when string is NULL or invalid index

Definition at line 15131 of file libsheepy.c.

Here is the call graph for this function:

◆ bInjectS()

char* bInjectS ( char *  string,
int64_t  index,
char  toInject 
)

buffer inject a char in string at index

return string with toInject at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string
indexin string
toInjectchar
Returns
modified string NULL unchanged string when string is NULL or invalid index

Definition at line 15208 of file libsheepy.c.

Here is the call graph for this function:

◆ bLInjectS()

char* bLInjectS ( char *  string,
size_t  stringSize,
int64_t  index,
char  toInject 
)

buffer size inject a char in string at index

return string with toInject at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
string
indexin string
toInjectchar
Returns
modified string NULL unchanged string when string is NULL or invalid index

Definition at line 15274 of file libsheepy.c.

Here is the call graph for this function:

◆ delS()

char* delS ( const char *  string,
int64_t  start,
int64_t  end 
)

delete string

return new string without the string between start and end negative indexes are allowed

Parameters
stringto delete
startstart index, must be in the string
endend index, must be in the string after start
Returns
new sliced string (you must free the pointer) new identical string when start=end or when start and end are not set correctly NULL when input string is NULL or when malloc failed or when end is under start

Definition at line 15345 of file libsheepy.c.

◆ iDelS()

char* iDelS ( char **  string,
int64_t  start,
int64_t  end 
)

delete string

return string without the string between start and end negative indexes are allowed

Parameters
stringto delete (this parameter is reallocated)
startstart index, must be in the string
endend index, must be in the string after start
Returns
sliced string (you must free the pointer) unchanged string when start=end NULL when start and end are not set correctly or when input string is NULL or when malloc failed or when end is under start

Definition at line 15415 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bDelS()

char* bDelS ( char *  string,
int64_t  start,
int64_t  end 
)

buffer delete string

return string without the string between start and end negative indexes are allowed

Parameters
stringto delete
startstart index, must be in the string
endend index, must be in the string after start
Returns
sliced string unchanged string when start=end NULL when start and end are not set correctly or when input string is NULL or when malloc failed or when end is under start

Definition at line 15487 of file libsheepy.c.

◆ bLDelS()

char* bLDelS ( char *  string,
size_t  stringSize,
int64_t  start,
int64_t  end 
)

buffer size delete string

return string without the string between start and end negative indexes are allowed

Parameters
stringto delete
stringSizestring buffer size
startstart index, must be in the string
endend index, must be in the string after start
Returns
sliced string unchanged string when start=end NULL when start and end are not set correctly or when input string is NULL or when malloc failed or when end is under start

Definition at line 15553 of file libsheepy.c.

◆ delElemS()

char* delElemS ( const char *  string,
int64_t  index 
)

delete element/character string

return new string without the character at given index negative indexes are allowed

Parameters
stringto delete
indexmust be in the string, -1 is the last character in the string
Returns
new string (you must free the pointer) NULL when input string is NULL or when malloc failed

Definition at line 15617 of file libsheepy.c.

◆ iDelElemS()

char* iDelElemS ( char **  string,
int64_t  index 
)

delete element/character string

return string without the character at given index negative indexes are allowed

Parameters
stringto delete (this parameter is reallocated)
indexmust be in the string, -1 is the last character in the string
Returns
new string (you must free the pointer) NULL when input string is NULL or when malloc failed

Definition at line 15660 of file libsheepy.c.

Here is the call graph for this function:

◆ bDelElemS()

char* bDelElemS ( char *  string,
int64_t  index 
)

buffer delete element/character string

return string without the character at given index negative indexes are allowed

Parameters
stringto delete
indexmust be in the string, -1 is the last character in the string
Returns
string with one less character NULL when input string is NULL or when malloc failed

Definition at line 15707 of file libsheepy.c.

◆ bLDelElemS()

char* bLDelElemS ( char *  string,
size_t  stringSize,
int64_t  index 
)

buffer size delete element/character string

return string without the character at given index negative indexes are allowed

Parameters
stringto delete
stringSizestring buffer size
indexmust be in the string, -1 is the last character in the string
Returns
string with one less character NULL when input string is NULL or when malloc failed

Definition at line 15748 of file libsheepy.c.

◆ findS()

char* findS ( const char *  string,
const char *  needle 
)

find String

Parameters
string
needlestring to find
Returns
pointer to first occurence of needle in string NULL when needle is not found NULL when string or needle are NULL

Definition at line 15790 of file libsheepy.c.

Here is the caller graph for this function:

◆ findCharS()

char* findCharS ( const char *  string,
char  c 
)

Definition at line 15799 of file libsheepy.c.

Here is the caller graph for this function:

◆ indexOfS()

ssize_t indexOfS ( const char *  string,
const char *  needle 
)

indexOf String relative to start

Parameters
string
needlestring to find
Returns
index of first occurence of needle in string -1 when needle is not found -1 when string or needle are NULL

Definition at line 15821 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexOfCharS()

ssize_t indexOfCharS ( const char *  string,
char  c 
)

Definition at line 15830 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasS()

bool hasS ( const char *  string,
const char *  needle 
)

has String

Parameters
string
needlestring to find
Returns
true when needle is in string false when needle is not found false when string or needle are NULL

Definition at line 15851 of file libsheepy.c.

Here is the caller graph for this function:

◆ hasCharS()

bool hasCharS ( const char *  string,
char  c 
)

Definition at line 15864 of file libsheepy.c.

◆ icFindS()

char* icFindS ( const char *  string,
const char *  needle 
)

ignore case Find String

Parameters
string
needlestring to find
Returns
pointer to first occurence of needle in string NULL when needle is not found NULL when string or needle are NULL

Definition at line 15888 of file libsheepy.c.

Here is the caller graph for this function:

◆ icFindCharS()

char* icFindCharS ( const char *  string,
char  c 
)

Definition at line 15897 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icIndexOfS()

ssize_t icIndexOfS ( const char *  string,
const char *  needle 
)

ignore case indexOf String relative to start

Parameters
string
needlestring to find
Returns
index of first occurence of needle in string -1 when needle is not found -1 when string or needle are NULL

Definition at line 15925 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icIndexOfCharS()

ssize_t icIndexOfCharS ( const char *  string,
char  c 
)

Definition at line 15934 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icHasS()

bool icHasS ( const char *  string,
const char *  needle 
)

ignore case has String

Parameters
string
needlestring to find
Returns
true when needle is in string false when needle is not found false when string or needle are NULL

Definition at line 15955 of file libsheepy.c.

Here is the caller graph for this function:

◆ icHasCharS()

bool icHasCharS ( const char *  string,
char  c 
)

Definition at line 15968 of file libsheepy.c.

Here is the call graph for this function:

◆ tokS()

char* tokS ( char *  s,
const char *  delim,
char **  saveptr 
)

token in String

parse string into a sequence of tokens delimited by the ENTIRE DELIM string work like strtok_r from c stdlib (for strtok_r, when delim has multiple characters, each character is a delimiter)

on first call s is the string to parse, optionally initialize *saveptr to NULL on next calls, s should be NULL

Parameters
sstring to parse, the s string is modified
delimstring
Returns
token *saveptr is set to NULL when the last token is found

Definition at line 15996 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icTokS()

char* icTokS ( char *  s,
const char *  delim,
char **  saveptr 
)

ignore case token in String

parse string into a sequence of tokens delimited by the ENTIRE DELIM string work like strtok_r from c stdlib (for strtok_r, when delim has multiple characters, each character is a delimiter)

on first call s is the string to parse, optionally initialize *saveptr to NULL on next calls, s should be NULL

Parameters
sstring to parse, the s string is modified
delimstring
Returns
token *saveptr is set to NULL when the last token is found

Definition at line 16038 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lenUTF8()

size_t lenUTF8 ( const char *  s)

character length of UTF-8 string

string is not checked for validity

Definition at line 16076 of file libsheepy.c.

Here is the caller graph for this function:

◆ bLLenUTF8()

size_t bLLenUTF8 ( const char *  s,
size_t  maxSize 
)

buffer character length of UTF-8 string

string is not checked for validity

bLLenUTF8 checks at most maxSize bytes

Definition at line 16095 of file libsheepy.c.

Here is the caller graph for this function:

◆ isUTF8()

bool isUTF8 ( const char *  string)

is UTF-8 string

check if string is a valid UTF-8 string

Parameters
stringUTF-8 encoded string
Returns
true string is valid UTF-8 false string is invalid UTF-8

Definition at line 16124 of file libsheepy.c.

◆ bLIsUTF8()

bool bLIsUTF8 ( const char *  string,
size_t  stringSize 
)

buffer length is UTF-8 string

check if string is a valid UTF-8 string

Parameters
stringUTF-8 encoded string
Returns
true string is valid UTF-8 false string is invalid UTF-8

Definition at line 16178 of file libsheepy.c.

◆ isCodeUTF8()

bool isCodeUTF8 ( const char *  code)

is code point UTF8 encoded string

Check if a UTF8 code point is valid

This function checks only the first code point

Parameters
bytesstring, NUL-terminated or not, bytes can be a pointer inside a UTF8 encoded string
Returns
true bytes is a valid UTF-8 code point false bytes is invalid code point

Definition at line 16247 of file libsheepy.c.

Here is the caller graph for this function:

◆ nextUTF8()

const char* nextUTF8 ( const char *  utf8)

next UTF-8 code point

find the next UTF-8 code point in the string

the validity of the found UTF-8 code point is not checked

nextUTF8 gives wrong result when utf8 is not on the first byte of a code point use findNextUTF8 to find next code point when utf8 is not at the start of a code point

Parameters
utf8UTF-8 encoded string
Returns
pointer to next UTF-8 code point NULL when the end string is reached or utf8 is NULL

Definition at line 46037 of file libsheepy.c.

◆ bLNextUTF8()

const char* bLNextUTF8 ( const char *  string,
size_t  utf8Size,
const char *  utf8 
)

buffer length next UTF-8 code point

find the next UTF-8 code point in the string

the validity of the found UTF-8 code point is not checked

bLNextUTF8 gives wrong result when utf8 is not on the first byte of a code point use findNextUTF8 to find next code point when utf8 is not at the start of a code point

Parameters
stringstart of the UTF-8 encoded string
utf8pointer to a code point in string
utf8Sizestring buffer size (including NUL, strlen(string) +1 when the buffer is full)
Returns
pointer to next UTF-8 code point NULL when the end string is reached or utf8 is NULL or the start of the next code point is outside the string

Definition at line 46067 of file libsheepy.c.

◆ findNextUTF8()

const char* findNextUTF8 ( const char *  string,
size_t  utf8Size,
const char *  utf8 
)

find next UTF-8 code point even not at the start of a code point

find the next UTF-8 code point in the string

the validity of the found UTF-8 code point is not checked

Parameters
stringstart of the UTF-8 encoded string
utf8pointer in string
ut8Sizestring buffer size (including NUL, strlen(string) +1 when the buffer is full)
Returns
pointer to next UTF-8 code point NULL when the end string is reached or utf8 is NULL or the start of the next code point is outside the string

Definition at line 46099 of file libsheepy.c.

◆ prevUTF8()

const char* prevUTF8 ( const char *  utf8)

previous UTF-8 code point

find the previous UTF-8 code point in the string

the validity of the found UTF-8 code point is not checked

the behavior is undefined when utf8 is the start of the string, use instead findPrevUTF8 for safe handling

Parameters
utf8UTF-8 encoded string
Returns
pointer to previous UTF-8 code point NULL when utf8 is NULL

Definition at line 46132 of file libsheepy.c.

◆ bPrevUTF8()

const char* bPrevUTF8 ( const char *  string,
const char *  utf8 
)

buffer previous UTF-8 code point

find the previous UTF-8 code point in the string

the validity of the found UTF-8 code point is not checked

Parameters
stringUTF-8 encoded string
utf8pointer in UTF-8 encoded string
Returns
pointer to previous UTF-8 code point NULL when utf8 is NULL

Definition at line 46161 of file libsheepy.c.

Here is the call graph for this function:

◆ idx2PtrUTF8()

const char* idx2PtrUTF8 ( const char *  utf8,
int64_t  index 
)

index to pointer UTF8 encoded string

Converts character index to pointer in utf8

Parameters
utf8UTF8 encoded string
indexcharacter index in utf8, positive or negative. -1 is the last character in the string
Returns
pointer to character at index NULL when index is outside the string

Definition at line 46207 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLIdx2PtrUTF8()

const char* bLIdx2PtrUTF8 ( const char *  utf8,
size_t  utf8Size,
int64_t  index 
)

Definition at line 46306 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ptr2IdxUTF8()

int64_t ptr2IdxUTF8 ( const char *  utf8,
const char *  pos 
)

pointer to code point index UTF8 encoded string

Converts pointer to character index

This function works when utf8 and pos point inside code points

Parameters
utf8pointer to a code point in a UTF8 encoded string
pospointer to a code point in a UTF8 encoded string
Returns
Number of code points from utf8 to pos, positive or negative When utf8 < pos, the result is positive When pos < utf8, the result is negative 0 failed or index 0

Definition at line 46371 of file libsheepy.c.

Here is the caller graph for this function:

◆ bPtr2IdxUTF8()

int64_t bPtr2IdxUTF8 ( const char *  start,
const char *  utf8,
const char *  pos 
)

buffer pointer to code point index UTF8 encoded string

Converts pointer to character index

Safe function for negative index

This function works when utf8 and pos point inside code points

Parameters
startstart of the UTF8 encoded string
utf8pointer to a code point in a UTF8 encoded string
pospointer to a code point in a UTF8 encoded string
Returns
Number of code points from utf8 to pos, positive or negative When utf8 < pos, the result is positive When pos < utf8, the result is negative 0 failed or index 0

Definition at line 46444 of file libsheepy.c.

◆ bLPtr2IdxUTF8()

int64_t bLPtr2IdxUTF8 ( const char *  utf8,
size_t  utf8Size,
const char *  pos 
)

buffer size pointer to code point index UTF8 encoded string

Converts pointer to character index

This function works when utf8 and pos point inside code points

Parameters
utf8pointer to a code point in a UTF8 encoded string
utf8Sizeutf8 buffer size including NUL
pospointer to a code point in a UTF8 encoded string
Returns
Number of code points from utf8 to pos, positive -1 failed

Definition at line 46505 of file libsheepy.c.

◆ bLPtr2NegIdxUTF8()

int64_t bLPtr2NegIdxUTF8 ( const char *  utf8,
size_t  utf8Size,
const char *  pos 
)

buffer size pointer to negative code point index UTF8 encoded string

Converts pointer to negative character index (from the end of the string)

This function works when utf8 and pos point inside code points

Parameters
utf8pointer to a code point in a UTF8 encoded string
utf8Sizeutf8 buffer size including NUL
pospointer to a code point in a UTF8 encoded string
Returns
Number of code points from utf8 end to pos, negative 0 failed

Definition at line 46556 of file libsheepy.c.

◆ makeValidUTF8()

char* makeValidUTF8 ( const char *  utf8)

make valid UTF-8 encoded string

copy utf8 to newly allocated buffer, the invalid code points are replaced with '?'

The result buffer size is the same as utf8 size

Parameters
utf8valid or invalid UTF-8 encoded string
Returns
new valid UTF-8 encoded string (you must free the pointer) NULL failed

Definition at line 46593 of file libsheepy.c.

Here is the call graph for this function:

◆ bMakeValidUTF8()

char* bMakeValidUTF8 ( char *  utf8)

buffer make valid UTF-8 encoded string

replace the invalid code points with '?' in utf8

Parameters
utf8valid or invalid UTF-8 encoded string
Returns
valid UTF-8 encoded string in utf8 buffer NULL failed

Definition at line 46635 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nMakeValidUTF8()

char* nMakeValidUTF8 ( const char *  utf8,
size_t  utf8Len 
)

length make valid UTF-8 encoded string

copy utf8 to newly allocated buffer, the invalid code points are replaced with '?'

The result buffer size is utf8Len+1

Parameters
utf8valid or invalid UTF-8 encoded string
utf8Lenutf8 length
Returns
new valid UTF-8 encoded string (you must free the pointer) NULL failed

Definition at line 46672 of file libsheepy.c.

Here is the call graph for this function:

◆ bNMakeValidUTF8()

char* bNMakeValidUTF8 ( char *  dst,
const char *  utf8,
size_t  utf8Len 
)

buffer length make valid UTF-8 encoded string

copy utf8 to the dst buffer, the invalid code points are replaced with '?'

The result buffer size is utf8Len+1

Parameters
utf8valid or invalid UTF-8 encoded string
utf8Lenutf8 length
Returns
new valid UTF-8 encoded string NULL failed

Definition at line 46724 of file libsheepy.c.

Here is the call graph for this function:

◆ bLMakeValidUTF8()

char* bLMakeValidUTF8 ( char *  dst,
size_t  dstSize,
const char *  utf8 
)

buffer destination size make valid UTF-8 encoded string

copy utf8 to the dst buffer, the invalid code points are replaced with '?'

The result buffer size is dstSize

Parameters
dstdestination buffer
dstSizesize of dst
utf8valid or invalid UTF-8 encoded string
Returns
new valid UTF-8 encoded string NULL failed

Definition at line 46773 of file libsheepy.c.

Here is the call graph for this function:

◆ bLNMakeValidUTF8()

char* bLNMakeValidUTF8 ( char *  dst,
size_t  dstSize,
const char *  utf8,
size_t  utf8Len 
)

buffer destination size source length make valid UTF-8 encoded string

copy utf8 to the dst buffer, the invalid code points are replaced with '?'

This function always reads less than utf8Len+1 bytes in utf8 buffer The result buffer size is dstSize

Parameters
dstdestination buffer
dstSizesize of dst
utf8valid or invalid UTF-8 encoded string
utf8Lenutf8 length
Returns
new valid UTF-8 encoded string NULL failed

Definition at line 46825 of file libsheepy.c.

Here is the call graph for this function:

◆ strNCpyUTF8()

char* strNCpyUTF8 ( char *  dst,
const char *  src,
size_t  srcLen 
)

strNCpyUTF8 - copy src to dst with srcLen in code points

copy srcLen code points from src (UTF-8 encoded string) to dst and add one NUL character when src end is not reached (unlike strncpy).

Parameters
dstdestination buffer
srcsource string
srcLensource buffer size in code points
Returns
dst string NULL error

Definition at line 46875 of file libsheepy.c.

◆ strLCpyUTF8()

char* strLCpyUTF8 ( char *  dst,
size_t  dstSize,
const char *  src 
)

strLCpyUTF8 - copy src to dst

like strncpy and the NUL char is always added at the end of the string and the result string is always a valid UTF-8 encoded string

Parameters
dstdestination buffer
dstSizedestination buffer size, result string will be no longer than dstSize-1
srcsource string
Returns
dst string NULL error

Definition at line 46912 of file libsheepy.c.

Here is the call graph for this function:

◆ strNCatUTF8()

char* strNCatUTF8 ( char *  dst,
const char *  src,
size_t  srcLen 
)

strNCatUTF8 - concatenate two UTF-8 encoded strings

like strncat with sanity checks and srcLen is the number of code points

Parameters
dstdestination buffer
srcsource string
srcLenmax source len in code points
Returns
string with input strings concatenated NULL error

Definition at line 46941 of file libsheepy.c.

◆ strLCatUTF8()

char* strLCatUTF8 ( char *  dst,
size_t  dstSize,
const char *  src 
)

strLCatUTF8 - concatenate two UTF-8 encoded strings

like strlcat with sanity checks the result string is always a valid UTF-8 encoded string

Parameters
dstdestination buffer
srcsource string
dstSizedestination buffer size, result string will be no longer than dstSize-1
Returns
string with input strings concatenated NULL error

Definition at line 46978 of file libsheepy.c.

Here is the call graph for this function:

◆ strLNCatUTF8()

char* strLNCatUTF8 ( char *  dst,
size_t  dstSize,
const char *  src,
size_t  srcLen 
)

strLNCatUTF8 - concatenate two UTF-8 encoded strings

like strlcat with sanity checks and srcLen is the number of code points the result string is always a valid UTF-8 encoded string

Parameters
dstdestination buffer
srcsource string
dstSizedestination buffer size, result string will be no longer than dstSize-1
srcLenmax source len in code points
Returns
string with input strings concatenated NULL error

Definition at line 47023 of file libsheepy.c.

Here is the call graph for this function:

◆ icReplaceUTF8()

char* icReplaceUTF8 ( const char *  s,
const char *  olds,
const char *  news,
size_t  max 
)

◆ icReplaceCharSUTF8()

char* icReplaceCharSUTF8 ( const char *  s,
char  olds,
const char *  news,
size_t  max 
)

◆ icReplaceSCharUTF8()

char* icReplaceSCharUTF8 ( const char *  s,
const char *  olds,
char  news,
size_t  max 
)

◆ iicReplaceUTF8()

char* iicReplaceUTF8 ( char **  s,
const char *  olds,
const char *  news,
size_t  max 
)

◆ iicReplaceCharSUTF8()

char* iicReplaceCharSUTF8 ( char **  s,
char  olds,
const char *  news,
size_t  max 
)

◆ iicReplaceSCharUTF8()

char* iicReplaceSCharUTF8 ( char **  s,
const char *  olds,
char  news,
size_t  max 
)

◆ bicReplaceUTF8()

char* bicReplaceUTF8 ( char *  s,
const char *  olds,
const char *  news,
size_t  max 
)

◆ bLicReplaceUTF8()

char* bLicReplaceUTF8 ( char *  s,
size_t  sSize,
const char *  olds,
const char *  news,
size_t  max 
)

◆ icReplaceManyUTF8F()

char* icReplaceManyUTF8F ( const char *  paramType,
  ... 
)

◆ iicReplaceManyUTF8F()

char* iicReplaceManyUTF8F ( char **  s,
char *  paramType,
  ... 
)

◆ bicReplaceManyUTF8F()

char* bicReplaceManyUTF8F ( char *  s,
char *  paramType,
  ... 
)

◆ bLicReplaceManyUTF8F()

char* bLicReplaceManyUTF8F ( char *  s,
size_t  sSize,
char *  paramType,
  ... 
)

◆ eqIUTF8()

bool eqIUTF8 ( const char *  string1,
const char *  string2,
int64_t  index 
)

UTF8 encoded string Index Equal compare string1 at character index to string2 when string2 is empty, the result is false.

Parameters
2strings
Returns
true string1 at index is equal to string2 false they differ

Definition at line 47312 of file libsheepy.c.

Here is the call graph for this function:

◆ eqICharUTF8()

bool eqICharUTF8 ( const char *  string1,
char  c,
int64_t  index 
)

Definition at line 47322 of file libsheepy.c.

Here is the call graph for this function:

◆ icEqUTF8()

bool icEqUTF8 ( const char *  string1,
const char *  string2 
)

ignore case UTF8 encoded string Equal compare string1 to string2

Parameters
2strings
Returns
true the strings have identical content false they differ

Definition at line 47343 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icEqCharUTF8()

bool icEqCharUTF8 ( char  c,
const char *  string2 
)

Definition at line 47357 of file libsheepy.c.

Here is the call graph for this function:

◆ icEqUTF8Char()

bool icEqUTF8Char ( const char *  string1,
char  c 
)

Definition at line 47371 of file libsheepy.c.

Here is the call graph for this function:

◆ icEqIUTF8()

bool icEqIUTF8 ( const char *  string1,
const char *  string2,
int64_t  index 
)

◆ icEqICharUTF8()

bool icEqICharUTF8 ( const char *  string1,
char  c,
int64_t  index 
)

◆ icStartsWithUTF8()

bool icStartsWithUTF8 ( const char *  string1,
const char *  string2 
)

ignore case starts With UTF8 encoded String compare start of string1 with string2

Parameters
2strings
Returns
true when string1 starts with string2 false for other cases

Definition at line 47419 of file libsheepy.c.

Here is the call graph for this function:

◆ icEndsWithUTF8()

bool icEndsWithUTF8 ( const char *  string1,
const char *  string2 
)

ignore case ends With UTF8 encoded String compare end of string1 with string2

Parameters
2strings
Returns
true when string1 ends with string2 false for other cases

Definition at line 47444 of file libsheepy.c.

Here is the call graph for this function:

◆ icCountUTF8()

ssize_t icCountUTF8 ( const char *  s,
const char *  needle 
)

ignore case count UTF8 encoded String count number of (non-overlapping) occurrences of a substring

Example: assert(countUTF8("aaa aaa", "a") == 6); assert(countUTF8("aaa aaa", "ab") == 0); assert(countUTF8("aaa aaa", "aa") == 2);

Parameters
2strings
Returns
string count -1 when there is an error

Definition at line 47480 of file libsheepy.c.

Here is the call graph for this function:

◆ code2RuneUTF8()

rune code2RuneUTF8 ( const char *  code)

UTF-8 code point to rune.

Parameters
codeUTF-8 code point
Returns
Rune 0 failed

Definition at line 47550 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ code2RuneLUTF8()

rune code2RuneLUTF8 ( const char *  code,
uint8_t *  n 
)

UTF-8 code point to rune and length.

the code point length is returned in *n

Parameters
codeUTF-8 code point
npointer to returned code point length
Returns
Rune 0 failed

Definition at line 47569 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bRune2CodeUTF8()

size_t bRune2CodeUTF8 ( char *  dst,
rune  c 
)

rune to UTF-8 code point

Parameters
dstdestination buffer at least 6 bytes or if NULL, the code point length is computed
cUNICODE rune
Returns
code point length and code point in dst when dst is NULL, return code point length only 0 bad rune, dst becomes an empty string

Definition at line 47635 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runeLenUTF8()

uint8_t runeLenUTF8 ( rune  r)

rune length as UTF-8 code point

Parameters
rUNICODE rune
Returns
code point length 0 bad rune

Definition at line 47670 of file libsheepy.c.

Here is the caller graph for this function:

◆ toupperUTF8()

rune toupperUTF8 ( rune  c)

rune toupper UTF8

Converts a character to uppercase.

Parameters
crune
Returns
c converted to uppercase c unchanged if c has no upper case or is not lowercase or titlecase

Definition at line 47854 of file libsheepy.c.

Here is the caller graph for this function:

◆ upperUTF8()

char* upperUTF8 ( const char *  utf8)

upper case UTF-8 encoded string duplicate string

Parameters
stringUTF-8 encoded string
Returns
new upper case string (you must free the pointer)

Definition at line 47975 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iUpperUTF8()

char* iUpperUTF8 ( char **  utf8)

upper case UTF-8 encoded string

Parameters
string(this parameter is reallocated)
Returns
upper case string (you must free the pointer) NULL error

Definition at line 48003 of file libsheepy.c.

Here is the call graph for this function:

◆ bUpperUTF8()

char* bUpperUTF8 ( char *  string)

◆ tolowerUTF8()

rune tolowerUTF8 ( rune  c)

rune tolower UTF8

Converts a character to lower case.

Parameters
cUNICODE rune
Returns
lowercase c c unchanged if c has lowercase or is not an uppercase or titlecase character

Definition at line 48078 of file libsheepy.c.

Here is the caller graph for this function:

◆ lowerUTF8()

char* lowerUTF8 ( const char *  utf8)

lower case UTF-8 String duplicate string

Parameters
string
Returns
new lower case string (you must free the pointer)

Definition at line 48228 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iLowerUTF8()

char* iLowerUTF8 ( char **  utf8)

lower case String

Parameters
string(this parameter is reallocated)
Returns
lower case string (you must free the pointer) NULL error

Definition at line 48256 of file libsheepy.c.

Here is the call graph for this function:

◆ bLowerUTF8()

char* bLowerUTF8 ( char *  string)

◆ casefoldUTF8()

char* casefoldUTF8 ( const char *  utf8)

casefold UTF-8 encoded string

Parameters
utf8UTF-8 encoded string
Returns
new string (you must free the pointer) NULL when utf8 is NULL

Definition at line 48294 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uniqUTF8()

char* uniqUTF8 ( const char *  string,
const char *  code 
)

uniq UTF-8 String duplicate string

remove successive repetitions of UTF-8 code point code

Parameters
string
ccharacter to remove
Returns
new string without successive repetitions of char c (you must free the pointer)

Definition at line 48352 of file libsheepy.c.

Here is the call graph for this function:

◆ iUniqUTF8()

char* iUniqUTF8 ( char **  string,
const char *  code 
)

uniq UTF-8 String

remove successive repetitions of char c

Parameters
string
ccharacter to remove
Returns
string without successive repetitions of char c NULL error

Definition at line 48409 of file libsheepy.c.

Here is the call graph for this function:

◆ bUniqUTF8()

char* bUniqUTF8 ( char *  string,
const char *  code 
)

buffer uniq String

remove successive repetitions of char c

Parameters
string
ccharacter to remove
Returns
string without successive repetitions of char c NULL error

Definition at line 48463 of file libsheepy.c.

Here is the call graph for this function:

◆ icUniqUTF8()

char* icUniqUTF8 ( const char *  string,
const char *  code 
)

◆ iicUniqUTF8()

char* iicUniqUTF8 ( char **  string,
const char *  code 
)

◆ bicUniqUTF8()

char* bicUniqUTF8 ( char *  string,
char  c 
)

◆ getUTF8()

rune getUTF8 ( const char *  string,
int64_t  index 
)

get UTF8 encoded string

get char at python index

Definition at line 48567 of file libsheepy.c.

Here is the call graph for this function:

◆ setUTF8()

char* setUTF8 ( char *  string,
int64_t  index,
rune  c 
)

set UTF8 encoded string

set char at python index

TODO this function might make the string invalid UTF8 check codeSizeUTF8 and adjust the buffer

Definition at line 48598 of file libsheepy.c.

Here is the call graph for this function:

◆ sliceUTF8()

char* sliceUTF8 ( const char *  string,
int64_t  start,
int64_t  end 
)

slice UTF8 encoded String return new string which is the string between start and end negative indexes are allowed

(copy substring from start to end)

Parameters
stringto slice
startstart character index, must be in the string
endend character index, must be in the string after start
Returns
new sliced string (you must free the pointer) "" when start=end NULL when start and end are not set correctly

Definition at line 48641 of file libsheepy.c.

Here is the call graph for this function:

◆ iSliceUTF8()

char* iSliceUTF8 ( char **  string,
int64_t  start,
int64_t  end 
)

slice UTF8 encoded String return string which is the string between start and end negative indexes are allowed

Parameters
stringto slice (this parameter is reallocated)
startstart character index, must be in the string
endend character index, must be in the string after start
Returns
sliced string (you must free the pointer) "" when start=end NULL unchanged string when start and end are not set correctly

Definition at line 48712 of file libsheepy.c.

Here is the call graph for this function:

◆ bSliceUTF8()

char* bSliceUTF8 ( char *  string,
int64_t  start,
int64_t  end 
)

buffer slice UTF8 encoded String return string which is the string between start and end negative indexes are allowed

Parameters
stringto slice
startstart index, must be in the string
endend index, must be in the string after start
Returns
sliced string "" when start=end NULL unchanged string when start and end are not set correctly

Definition at line 48791 of file libsheepy.c.

Here is the call graph for this function:

◆ bLSliceUTF8()

char* bLSliceUTF8 ( char *  string,
size_t  stringSize,
int64_t  start,
int64_t  end 
)

buffer size slice UTF8 encoded String return string which is the string between start and end negative indexes are allowed

Parameters
stringto slice
stringSizestring buffer size
startstart character index, must be in the string
endend character index, must be in the string after start
Returns
sliced string "" when start=end NULL unchanged string when start and end are not set correctly

Definition at line 48862 of file libsheepy.c.

Here is the call graph for this function:

◆ insertUTF8()

char* insertUTF8 ( const char *  string,
int64_t  index,
const char *  toInsert 
)

insert string in UTF8 encoded string at index

return new string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
stringUTF8 encoded string
indexcharacter index in string
toInsertUTF8 encoded string
Returns
new string (you must free the pointer) NULL when string is NULL or invalid index

Definition at line 48956 of file libsheepy.c.

Here is the call graph for this function:

◆ insertNFreeUTF8()

char* insertNFreeUTF8 ( const char *  string,
int64_t  index,
char *  toInsert 
)

insert string in UTF8 encoded string at index and free toInsert

return new string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
stringUTF8 encoded string
indexcharacter index in string
toInsertUTF8 encoded string
Returns
new string (you must free the pointer) NULL when string is NULL or invalid index

Definition at line 49029 of file libsheepy.c.

Here is the call graph for this function:

◆ iInsertUTF8()

char* iInsertUTF8 ( char **  string,
int64_t  index,
const char *  toInsert 
)

insert string in UTF8 encoded string at index

return string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
stringUTF8 encoded string (this parameter is reallocated)
indexcharacter index in string
toInsertUTF8 encoded string
Returns
modified string (you must free the pointer) NULL unchanged string when string is NULL or invalid index

Definition at line 49110 of file libsheepy.c.

Here is the call graph for this function:

◆ iInsertNFreeUTF8()

char* iInsertNFreeUTF8 ( char **  string,
int64_t  index,
char *  toInsert 
)

insert string in UTF8 encoded string at index and free toInsert

return string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
stringUTF8 encoded string (this parameter is reallocated)
indexcharacter index in string
toInsertUTF8 encoded string
Returns
modified string (you must free the pointer) NULL unchanged string when string is NULL or invalid index

Definition at line 49191 of file libsheepy.c.

Here is the call graph for this function:

◆ bInsertUTF8()

char* bInsertUTF8 ( char *  string,
int64_t  index,
const char *  toInsert 
)

buffer insert string in UTF8 encoded string at index

return string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
stringUTF8 encoded string
indexcharacter index in string
toInsertUTF8 encoded string
Returns
modified string NULL unchanged string when string is NULL or invalid index

Definition at line 49275 of file libsheepy.c.

Here is the call graph for this function:

◆ bLInsertUTF8()

char* bLInsertUTF8 ( char *  string,
size_t  stringSize,
int64_t  index,
const char *  toInsert 
)

buffer size insert string in UTF8 encoded string at index

return string with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
stringUTF8 encoded string
indexcharacter index in string
toInsertUTF8 encoded string
Returns
modified string NULL unchanged string when string is NULL or invalid index

Definition at line 49347 of file libsheepy.c.

Here is the call graph for this function:

◆ delUTF8()

char* delUTF8 ( const char *  string,
int64_t  start,
int64_t  end 
)

delete UTF8 encoded string

return new string without the string between start and end negative indexes are allowed

Parameters
stringto delete
startstart character index, must be in the string
endend character index, must be in the string after start
Returns
new sliced string (you must free the pointer) new identical string when start=end or when start and end are not set correctly NULL when input string is NULL or when malloc failed or when end is under start

Definition at line 49424 of file libsheepy.c.

Here is the call graph for this function:

◆ iDelUTF8()

char* iDelUTF8 ( char **  string,
int64_t  start,
int64_t  end 
)

delete UTF8 encoded string

return string without the string between start and end negative indexes are allowed

Parameters
stringto delete (this parameter is reallocated)
startstart character index, must be in the string
endend character index, must be in the string after start
Returns
sliced string (you must free the pointer) unchanged string when start=end NULL when start and end are not set correctly or when input string is NULL or when malloc failed or when end is under start

Definition at line 49499 of file libsheepy.c.

Here is the call graph for this function:

◆ bDelUTF8()

char* bDelUTF8 ( char *  string,
int64_t  start,
int64_t  end 
)

buffer delete UTF8 encoded string

return string without the string between start and end negative indexes are allowed

Parameters
stringto delete
startstart character index, must be in the string
endend character index, must be in the string after start
Returns
sliced string unchanged string when start=end NULL when start and end are not set correctly or when input string is NULL or when malloc failed or when end is under start

Definition at line 49576 of file libsheepy.c.

Here is the call graph for this function:

◆ bLDelUTF8()

char* bLDelUTF8 ( char *  string,
size_t  stringSize,
int64_t  start,
int64_t  end 
)

buffer size delete UTF8 encoded string

return string without the string between start and end negative indexes are allowed

Parameters
stringto delete
stringSizestring buffer size
startstart character index, must be in the string
endend character index, must be in the string after start
Returns
sliced string unchanged string when start=end NULL when start and end are not set correctly or when input string is NULL or when malloc failed or when end is under start

Definition at line 49647 of file libsheepy.c.

Here is the call graph for this function:

◆ indexOfUTF8()

ssize_t indexOfUTF8 ( const char *  string,
const char *  needle 
)

indexOf UTF8 encoded String relative to start

Parameters
string
needlestring to find
Returns
character index of first occurence of needle in string -1 when needle is not found -1 when string or needle are NULL

Definition at line 49726 of file libsheepy.c.

Here is the call graph for this function:

◆ icIndexOfUTF8()

ssize_t icIndexOfUTF8 ( const char *  string,
const char *  needle 
)

◆ icHasUTF8()

bool icHasUTF8 ( const char *  string,
const char *  needle 
)

ignore case has UTF8 encoded String

Parameters
string
needlestring to find
Returns
true when needle is in string false when needle is not found false when string or needle are NULL

Definition at line 49768 of file libsheepy.c.

Here is the call graph for this function:

◆ icTokUTF8()

char* icTokUTF8 ( const char *  s,
const char *  delim,
char **  saveptr 
)

◆ icExtractUTF8()

char** icExtractUTF8 ( const char *  string,
const char *  delim1,
const char *  delim2 
)

◆ icExtractCharSUTF8()

char** icExtractCharSUTF8 ( const char *  string,
char  delim1,
const char *  delim2 
)

◆ icExtractSCharUTF8()

char** icExtractSCharUTF8 ( const char *  string,
const char *  delim1,
char  delim2 
)

◆ icListSortUTF8()

char** icListSortUTF8 ( char **  list)

ignore case list Sort UTF8 encoded String duplicate list and sort

Parameters
list
Returns
new sorted list (you must free the pointer with listFreeS) empty list when list is empty NULL when list is NULL

Definition at line 49903 of file libsheepy.c.

Here is the call graph for this function:

◆ iicListSortUTF8()

char** iicListSortUTF8 ( char ***  list)

ignore case list Sort UTF8 encoded String

Parameters
list
Returns
sorted list empty list when list is empty unchanged list when list is NULL NULL error

Definition at line 49934 of file libsheepy.c.

Here is the call graph for this function:

◆ icListEqUTF8()

bool icListEqUTF8 ( char **  list1,
char **  list2 
)

ignore case list Equal UTF8 encoded String compare each element of list1 and list2

Parameters
2lists
Returns
true the lists have identical elements false they differ

Definition at line 49961 of file libsheepy.c.

Here is the call graph for this function:

◆ icListHasUTF8()

bool icListHasUTF8 ( char **  list,
const char *  string 
)

ignore case and return true when list has UTF8 encoded string

Parameters
list
string
Returns
true when list has string false when the string is not found false when list or string are NULL

Definition at line 49994 of file libsheepy.c.

Here is the call graph for this function:

◆ icListIndexOfUTF8()

ssize_t icListIndexOfUTF8 ( char **  list,
const char *  string 
)

ignore case and return index of UTF8 encoded string in list

Parameters
list
string
Returns
index -1 when the string is not found -1 when list or string are NULL

Definition at line 50018 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListBinarySearchUTF8()

ssize_t icListBinarySearchUTF8 ( char **  list,
const char *  string 
)

ignore case list binary search UTF8 encoded string

efficiently finds the index of string in list the list has be sorted with for example listSortS

Parameters
list
stringto search
Returns
index of string -1 string not found or NULL input pointers

Definition at line 50055 of file libsheepy.c.

Here is the call graph for this function:

◆ icListUniqUTF8()

char** icListUniqUTF8 ( char **  list)

ignore case and uniquify UTF8 encoded elements of list duplicate list each elements are unique in the new list

Parameters
list
Returns
new list with unique elements (you must free the pointer with listFreeS) empty list when list is empty NULL when list is NULL

Definition at line 50098 of file libsheepy.c.

Here is the call graph for this function:

◆ iicListUniqUTF8()

char** iicListUniqUTF8 ( char ***  list)

ignore case and uniquify UTF8 encoded elements of list each elements are unique in the list

Parameters
list
Returns
list with unique elements empty list when list is empty unchanged list when list is NULL NULL error

Definition at line 50139 of file libsheepy.c.

Here is the call graph for this function:

◆ emptySF()

char* emptySF ( void  )

empty String Function

Returns
new empty string (you must free the pointer)

Definition at line 50188 of file libsheepy.c.

Here is the caller graph for this function:

◆ iEmptySF()

char* iEmptySF ( char **  string)

empty String Function

when *string is NULL, it is freed

Returns
empty string (you must free the pointer) NULL nothing when string is NULL

Definition at line 50202 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEmptyS()

bool isEmptyS ( const char *  string)

is Empty String

Parameters
string
Returns
false when there are characters in the string true when string is empty true when string is NULL

Definition at line 50226 of file libsheepy.c.

Here is the caller graph for this function:

◆ isBlankS()

bool isBlankS ( const char *  string)

is Blank String

Parameters
string
Returns
false when there are non white space characters in the string true when there are only white spaces in the string true when string is empty true when string is NULL

Definition at line 50246 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intIndex()

ssize_t intIndex ( int64_t  index,
int64_t  length 
)

int to positive index index can be negative

Parameters
indexindex in list, must be inside the list
lengthlist length
Returns
positive index -1 when length is 0 or index is not set correctly

Definition at line 50275 of file libsheepy.c.

◆ listEmptySF()

char** listEmptySF ( void  )

list Empty String Function

Returns
new empty list (you must free the pointer with listFreeS)

Definition at line 50305 of file libsheepy.c.

◆ iListEmptySF()

char** iListEmptySF ( char ***  list)

list Empty String Function

Returns
empty list (you must free the pointer with listFreeS) NULL error

Definition at line 50322 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listIsEmptyS()

bool listIsEmptyS ( char **  list)

list Is Empty String

Parameters
list
Returns
false when there are elements in the list true when list is empty true when list is NULL

Definition at line 50351 of file libsheepy.c.

Here is the caller graph for this function:

◆ listIsBlankS()

bool listIsBlankS ( char **  list)

list Is Empty String

Parameters
list
Returns
false when there are non blank elements in the list true when all elements are blank true when list is NULL

Definition at line 50370 of file libsheepy.c.

Here is the call graph for this function:

◆ listCreateSF()

char** listCreateSF ( const char *  paramType,
  ... 
)

list Create String Function create a list from the list of parameters used from the listCreateS(...) macro

Parameters
listof strings seperated with commas
Returns
list NULL when first element if NULL

Definition at line 50395 of file libsheepy.c.

Here is the call graph for this function:

◆ listFromArrayS()

char** listFromArrayS ( char **  array,
size_t  size 
)

list From Array String

copy array of 'size' strings to a new list NULL strings are not copied to the list

Parameters
arrayof strings
size- number of strings in the array
Returns
list empty list when size is 0 NULL when array is NULL

Definition at line 50427 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listFromCArrayS()

char** listFromCArrayS ( const char **  array,
size_t  size 
)

list From Const Array String

copy array of 'size' strings to a new list NULL strings are not copied to the list

Parameters
arrayof strings
size- number of strings in the array
Returns
list empty list when size is 0 NULL when array is NULL

Definition at line 50465 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listPushS()

char** listPushS ( char ***  list,
const char *  s 
)

list Push String append s at the end of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, NULL is pushed at the end of the list

the list is reallocated to add extra space

Parameters
pointerto list - becomes NULL when realloc fails (this parameter is reallocated)
sstring to push
Returns
list success (you must free the pointer with listFreeS) NULL error

Definition at line 50504 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listPushCharS()

char** listPushCharS ( char ***  list,
char  c 
)

Definition at line 50536 of file libsheepy.c.

Here is the call graph for this function:

◆ iListPushS()

char** iListPushS ( char ***  list,
char *  s 
)

list Push String append s pointer at the end of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, NULL is pushed at the end of the list

the list is reallocated to add extra space

Parameters
pointerto list - becomes NULL when realloc fails (this parameter is reallocated)
sstring to push
Returns
list success NULL error

Definition at line 50559 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listPopS()

char* listPopS ( char ***  list)

list Pop String return last string from list and remove last element from the list

Parameters
pointerto list
Returns
duplicated last string (you must free the pointer) NULL when the list is NULL or empty (first element is NULL)

Definition at line 50602 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listPrependS()

char** listPrependS ( char ***  list,
const char *  s 
)

list Prepend String append s at the beginning of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, the operation is canceled

the list is reallocated to add extra space

Parameters
pointerto list - becomes NULL when realloc fails (this parameter is reallocated)
sstring to prepend
Returns
list success (you must free the pointer with listFreeS) NULL error

Definition at line 50641 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listPrependCharS()

char** listPrependCharS ( char ***  list,
char  c 
)

Definition at line 50677 of file libsheepy.c.

Here is the call graph for this function:

◆ iListPrependS()

char** iListPrependS ( char ***  list,
char *  s 
)

list Prepend String append s pointer at the beginning of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, the operation is canceled

the list is reallocated to add extra space

Parameters
pointerto list - becomes NULL when realloc fails (this parameter is reallocated)
sstring to prepend
Returns
list success NULL error

Definition at line 50700 of file libsheepy.c.

Here is the call graph for this function:

◆ listDequeueS()

char* listDequeueS ( char ***  list)

list Dequeue String return first string from list and remove it from the list

Parameters
pointerto list
Returns
first string (you must free the pointer) NULL when the list is NULL or empty (first element is NULL)

Definition at line 50746 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listFreeS()

void listFreeS ( char **  list)

list Free String

Parameters
list
Returns
nothing

Definition at line 50780 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listFreeManySF()

void listFreeManySF ( char **  paramType,
  ... 
)

list free many String

free variable list of pointers listFreeManyS(l1, l2, ...);

Definition at line 50797 of file libsheepy.c.

Here is the call graph for this function:

◆ listLengthS()

size_t listLengthS ( char **  list)

list Length String return number of elements until the first NULL element

Parameters
list
Returns
number of element until first NULL element 0 when list is NULL

Definition at line 50820 of file libsheepy.c.

Here is the caller graph for this function:

◆ listLengthCS()

size_t listLengthCS ( const char **  list)

const list Length String return number of elements until the first NULL element

Parameters
list
Returns
number of element until first NULL element 0 when list is NULL

Definition at line 50843 of file libsheepy.c.

Here is the caller graph for this function:

◆ listStrLengthS()

ssize_t listStrLengthS ( char **  list)

list String Length String

Parameters
list
Returns
list length as a single string -1 when list is NULL

Definition at line 50865 of file libsheepy.c.

◆ listIntIndexS()

ssize_t listIntIndexS ( char **  list,
int64_t  index 
)

list int to index String index can be negative

Parameters
list
indexindex in list, must be inside the list
Returns
positive index -1 when list is NULL or index is not set correctly

Definition at line 50892 of file libsheepy.c.

Here is the call graph for this function:

◆ listAddrS()

char** listAddrS ( char **  list,
int64_t  index 
)

list address String index can be negative

Parameters
list
indexindex in list, must be inside the list
Returns
pointer to char* at index NULL when list is NULL or index is not set correctly

Definition at line 50929 of file libsheepy.c.

Here is the call graph for this function:

◆ listGetS()

char* listGetS ( char **  list,
int64_t  index 
)

list Get String duplicate string at given index index can be negative

Parameters
list
indexindex in list, must be inside the list
Returns
duplicated string (you must free the pointer) NULL when list is NULL or index is not set correctly

Definition at line 50967 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListGetS()

char* iListGetS ( char **  list,
int64_t  index 
)

list Get String index can be negative

Parameters
list
indexindex in list, must be inside the list
Returns
string NULL when list is NULL or index is not set correctly

Definition at line 51001 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listGetCS()

char* listGetCS ( const char **  list,
int64_t  index 
)

const list Get String duplicate string at given index index can be negative

Parameters
list
indexindex in list, must be inside the list
Returns
duplicated string (you must free the pointer) NULL when list is NULL or index is not set correctly

Definition at line 51036 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListGetCS()

const char* iListGetCS ( const char **  list,
int64_t  index 
)

const list Get String index can be negative

Parameters
list
indexindex in list, must be inside the list
Returns
string NULL when list is NULL or index is not set correctly

Definition at line 51070 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listSetS()

char** listSetS ( char **  list,
int64_t  index,
const char *  s 
)

list Set String duplicate string and store at given index, the existing element is freed index can be negative

Parameters
list
indexindex in list, must be inside the list
string
Returns
list success (you must free the pointer with listFreeS) NULL error

Does nothing when: when list is NULL, index is not set correctly or s is NULL

Definition at line 51110 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listSetCharS()

char** listSetCharS ( char **  list,
int64_t  index,
char  c 
)

Definition at line 51134 of file libsheepy.c.

Here is the call graph for this function:

◆ iListSetS()

char** iListSetS ( char **  list,
int64_t  index,
char *  s 
)

list Set String store string at given index index can be negative

Parameters
list
indexindex in list, must be inside the list
string
Returns
list success NULL error

Does nothing when: when list is NULL, index is not set correctly or s is NULL

Definition at line 51158 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listSwapS()

char** listSwapS ( char **  list,
int64_t  index1,
int64_t  index2 
)

swap elements in list

Parameters
list
index1index of character to swap
index2index of second character to swap
Returns
new list with elements swapped at index1 and index2 (you must free this pointer) NULL when list is NULL or when index1 or index2 are outside the list

Definition at line 51195 of file libsheepy.c.

Here is the call graph for this function:

◆ iListSwapS()

char** iListSwapS ( char **  list,
int64_t  index1,
int64_t  index2 
)

swap elements in list

Parameters
list
index1index of character to swap
index2index of second character to swap
Returns
updated list with characters swapped at index1 and index2 (you must free this pointer) NULL when list is NULL or when index1 or index2 are outside the list

Definition at line 51245 of file libsheepy.c.

Here is the call graph for this function:

◆ split()

char** split ( const char *  string,
const char *  delim 
)

split string with delim string when updating this function, also update splitS (identical to split) return list

Parameters
stringto split
delimdelimiter
Returns
list of tokens (you must free the pointer with listFreeS) NULL when list or delim are NULL

Definition at line 51294 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ splitS()

char** splitS ( const char *  string,
const char *  delim 
)

Definition at line 51342 of file libsheepy.c.

Here is the call graph for this function:

◆ splitChar()

char** splitChar ( const char *  string,
char  delim 
)

Definition at line 51388 of file libsheepy.c.

Here is the call graph for this function:

◆ icSplit()

char** icSplit ( const char *  string,
const char *  delim 
)

ignore case split string with delim string when updating this function, also update icSplitS (identical to icSplit) return list

Parameters
stringto split
delimdelimiter
Returns
list of tokens (you must free the pointer with listFreeS) NULL when list or delim are NULL

Definition at line 51407 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icSplitS()

char** icSplitS ( const char *  string,
const char *  delim 
)

Definition at line 51455 of file libsheepy.c.

Here is the call graph for this function:

◆ icSplitChar()

char** icSplitChar ( const char *  string,
char  delim 
)

Definition at line 51501 of file libsheepy.c.

Here is the call graph for this function:

◆ joinLength()

ssize_t joinLength ( char **  list,
const char *  delim 
)

join Length list length after joined with delimiter

Parameters
list
delimstring seperator
Returns
list length as a single string -1 when list is NULL

Definition at line 51519 of file libsheepy.c.

◆ join()

char* join ( char **  list,
const char *  delim 
)

join list, the elements are seperated with delim in the resulting string when updating this function, also update joinS (identical to join)

Parameters
list
delimstring seperator
Returns
joined string (you must free the pointer) NULL when list or delim are NULL

Definition at line 51554 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ joinS()

char* joinS ( char **  list,
const char *  delim 
)

Definition at line 51589 of file libsheepy.c.

Here is the call graph for this function:

◆ joinCS()

char* joinCS ( const char **  list,
const char *  delim 
)

join list, the elements are seperated with delim in the resulting string

Parameters
list
delimstring seperator
Returns
joined string (you must free the pointer) NULL when list or delim are NULL

Definition at line 51633 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ joinChar()

char* joinChar ( char **  list,
char  delim 
)

Definition at line 51666 of file libsheepy.c.

Here is the call graph for this function:

◆ bJoin()

char* bJoin ( char *  string,
char **  list,
const char *  delim 
)

buffer join list, the elements are seperated with delim in the resulting string

Parameters
list
delimstring seperator
Returns
joined string NULL when list or delim are NULL

Definition at line 51683 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bJoinChar()

char* bJoinChar ( char *  string,
char **  list,
char  delim 
)

Definition at line 51703 of file libsheepy.c.

Here is the call graph for this function:

◆ bLJoin()

char* bLJoin ( char *  string,
size_t  stringSize,
char **  list,
const char *  delim 
)

buffer size join list, the elements are seperated with delim in the resulting string

Parameters
list
delimstring seperator
Returns
joined string NULL when list or delim are NULL

Definition at line 51720 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bLJoinChar()

char* bLJoinChar ( char *  string,
size_t  stringSize,
char **  list,
char  delim 
)

Definition at line 51745 of file libsheepy.c.

Here is the call graph for this function:

◆ extractS()

char** extractS ( const char *  string,
const char *  delim1,
const char *  delim2 
)

extract string between delim1 and delim2 strings return list

Parameters
stringto split
delim1first delimiter
delim2second delimiter, has to be different from delim1
Returns
list of tokens (you must free the pointer with listFreeS) NULL when list or delim are NULL

Definition at line 51765 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extractCharSS()

char** extractCharSS ( const char *  string,
char  delim1,
const char *  delim2 
)

Definition at line 51805 of file libsheepy.c.

Here is the call graph for this function:

◆ extractSCharS()

char** extractSCharS ( const char *  string,
const char *  delim1,
char  delim2 
)

Definition at line 51811 of file libsheepy.c.

Here is the call graph for this function:

◆ extractCharCharS()

char** extractCharCharS ( const char *  string,
char  delim1,
char  delim2 
)

Definition at line 51817 of file libsheepy.c.

Here is the call graph for this function:

◆ icExtractS()

char** icExtractS ( const char *  string,
const char *  delim1,
const char *  delim2 
)

ignore case extract string between delim1 and delim2 strings return list

Parameters
stringto split
delim1first delimiter
delim2second delimiter, has to different from delim1
Returns
list of tokens (you must free the pointer with listFreeS) NULL when list or delim are NULL

Definition at line 51838 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icExtractCharSS()

char** icExtractCharSS ( const char *  string,
char  delim1,
const char *  delim2 
)

Definition at line 51878 of file libsheepy.c.

Here is the call graph for this function:

◆ icExtractSCharS()

char** icExtractSCharS ( const char *  string,
const char *  delim1,
char  delim2 
)

Definition at line 51884 of file libsheepy.c.

Here is the call graph for this function:

◆ icExtractCharCharS()

char** icExtractCharCharS ( const char *  string,
char  delim1,
char  delim2 
)

Definition at line 51890 of file libsheepy.c.

Here is the call graph for this function:

◆ listDupS()

char** listDupS ( char **  list)

list Duplicate String

Parameters
list
Returns
duplicated list (you must free the pointer with listFreeS) NULL when list is NULL

Definition at line 51906 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listDupCS()

char** listDupCS ( const char **  list)

const list Duplicate String

Parameters
list
Returns
duplicated list (you must free the pointer with listFreeS) NULL when list is NULL

Definition at line 51940 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListDupS()

char** iListDupS ( char **  list)

list Duplicate String

copy pointers to new list After this function, free list with free instead of listFreeS

Note: this function creates a new list, so char *** is not needed. Unlike iList functions.

Parameters
list
Returns
new list pointing to the same string as list (you should free the pointer with free) NULL when list is NULL

Definition at line 51980 of file libsheepy.c.

Here is the call graph for this function:

◆ listReverseS()

char** listReverseS ( char **  list)

list Reverse String duplicate and reverse list, the last element is the first element of the new list

Parameters
list
Returns
reversed list (you must free the pointer with listFreeS) NULL when list is NULL

Definition at line 52015 of file libsheepy.c.

Here is the call graph for this function:

◆ iListReverseS()

char** iListReverseS ( char ***  list)

list Reverse String reverse list, the last element is the first element of the list

Parameters
list(this parameter is reallocated)
Returns
reversed list (you must free the pointer with listFreeS or free) nothing when list is NULL NULL error

Definition at line 52051 of file libsheepy.c.

Here is the call graph for this function:

◆ listCatSF()

char** listCatSF ( char **  paramType,
  ... 
)

list Cat String

Parameters
arbitrarylist of lists seperated by commas
Returns
new list with input lists concatenated (you must free the pointer with listFreeS)

Definition at line 52086 of file libsheepy.c.

Here is the call graph for this function:

◆ listAppendS()

char** listAppendS ( char ***  list1,
char **  list2 
)

list Append String Append list2 at the end of list1

list1 is reallocated to add extra space

Parameters
list1(this parameter is reallocated)
list2
Returns
list1 and list2 (you must free the pointer with listFreeS) list1 not modified when list1 and list2 are NULL NULL error

Definition at line 52116 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListAppendS()

char** iListAppendS ( char ***  list1,
char **  list2 
)

in place list Append String Append list2 at the end of list1 by copying the pointers from list2 to list1.

After this function, free list2 with free instead of listFreeS

list1 is reallocated to add extra space

Parameters
list1(this parameter is reallocated)
list2
Returns
list1 and list2 (you must free the pointer with listFreeS or free) list1 not modified when list1 and list2 are NULL or when list1 is identical to list2 (same pointers) NULL error

Definition at line 52199 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListAppendNSmashS()

char** iListAppendNSmashS ( char ***  list1,
char **  list2 
)

list Append and smash list2 Append list2 at the end of list1 by copying the pointers from list2 to list1.

list2 is freed (except when there is an error)

list1 is reallocated to add extra space

Parameters
list1(this parameter is reallocated)
list2
Returns
list1 and list2 (you must free the pointer with listFreeS or free) list1 not modified when list1 and list2 are NULL or when list1 is identical to list2 (same pointers) NULL error

Definition at line 52273 of file libsheepy.c.

Here is the call graph for this function:

◆ listShiftS()

char** listShiftS ( char ***  list1,
char **  list2 
)

list Shift String Append list2 at the start of list1

list1 is reallocated to add extra space

Parameters
list1(this parameter is reallocated)
list2
Returns
list1 and list2 (you must free the pointer with listFreeS) list1 not modified when list1 and list2 are NULL NULL error

Definition at line 52298 of file libsheepy.c.

Here is the call graph for this function:

◆ iListShiftS()

char** iListShiftS ( char ***  list1,
char **  list2 
)

in place list Shift String Append list2 at the start of list1 by copying the pointers from list2 to list1.

After this function, free list2 with free instead of listFreeS

list1 is reallocated to add extra space

Parameters
list1(this parameter is reallocated)
list2
Returns
list1 and list2 (you must free the pointer with listFreeS or free) list1 not modified when list1 and list2 are NULL or when list1 is identical to list2 (same pointers) NULL error

Definition at line 52330 of file libsheepy.c.

Here is the call graph for this function:

◆ iListShiftNSmashS()

char** iListShiftNSmashS ( char ***  list1,
char **  list2 
)

list Append and smash list2 Append list2 at the start of list1 by copying the pointers from list2 to list1.

list2 is freed (except when there is an error)

list1 is reallocated to add extra space

Parameters
list1(this parameter is reallocated)
list2
Returns
list1 and list2 (you must free the pointer with listFreeS or free) list1 not modified when list1 and list2 are NULL or when list1 is identical to list2 (same pointers) NULL error

Definition at line 52354 of file libsheepy.c.

Here is the call graph for this function:

◆ listAddS()

char** listAddS ( char **  list1,
char **  list2 
)

list Add String add list1 and list2 in a new list

Parameters
list1
list2
Returns
new list with list1 and list2 (you must free the pointer with listFreeS) NULL when list1 and list2 are NULL

Definition at line 52372 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listAddCS()

char** listAddCS ( char **  list1,
const char **  list2 
)

const list Add String add list1 and list2 in a new list

Parameters
list1
list2
Returns
new list with list1 and list2 (you must free the pointer with listFreeS) NULL when list1 and list2 are NULL

Definition at line 52423 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listSliceS()

char** listSliceS ( char **  list,
int64_t  start,
int64_t  end 
)

list Slice String return new list with elements from start and end in list negative indexes are allowed

Parameters
list
startindex, must be in the list
endindex, must be in the list
Returns
sliced list (you must free the pointer with listFreeS) empty list when start=end NULL when list is empty NULL when list is NULL or when start and end are not set correctly

Definition at line 52479 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListCopyS()

char** iListCopyS ( char **  list,
int64_t  start,
int64_t  end 
)

list Copy String return new list with element pointers from start and end in list negative indexes are allowed

Note: this function creates a new list, so char *** is not needed. Unlike iList functions.

Parameters
list
startindex, must be in the list
endindex, must be in the list
Returns
new list pointing to the same string as list (you must free the pointer with free) empty list when start=end NULL when list is empty NULL when list is NULL or when start and end are not set correctly

Definition at line 52552 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListSliceS()

char** iListSliceS ( char ***  list,
int64_t  start,
int64_t  end 
)

list Slice String return list with elements from start and end in list negative indexes are allowed

Parameters
list(this parameter is reallocated)
startindex, must be in the list
endindex, must be in the list
Returns
sliced list (you must free the pointer with listFreeS or free) empty list when start=end unchanged when list is empty unchanged when list is NULL or when start and end are not set correctly NULL error

Definition at line 52623 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listCropS()

char** listCropS ( char **  list,
int64_t  start,
int64_t  end 
)

list Crop String return a new list with elements from start and end in list and delete elements from start to end in the original list negative indexes are allowed

iListCropS is faster than listSliceS+iListDelS because only the string pointers are copied to the sliced list

Parameters
list
startindex, must be in the list
endindex, must be in the list
Returns
new sliced list (you must free the pointer with listFreeS or free) empty list when start=end unchanged when list is empty unchanged when list is NULL or when start and end are not set correctly NULL error

Definition at line 52717 of file libsheepy.c.

Here is the call graph for this function:

◆ iListCropS()

char** iListCropS ( char ***  list,
int64_t  start,
int64_t  end 
)

list Crop String return a new list with elements from start and end in list and delete elements from start to end in the original list negative indexes are allowed

iListCropS is faster than listSliceS+iListDelS because only the string pointers are copied to the sliced list

Parameters
list
startindex, must be in the list
endindex, must be in the list
Returns
new sliced list (you must free the pointer with listFreeS or free) empty list when start=end unchanged when list is empty unchanged when list is NULL or when start and end are not set correctly NULL error

Definition at line 52799 of file libsheepy.c.

Here is the call graph for this function:

◆ listCropElemS()

char* listCropElemS ( char **  list,
int64_t  index 
)

list Crop Element String return element at index and delete element at index in the original list negative indexes are allowed

iListCropS is faster than listSliceS+iListDelElemS because only the string pointer is returned directly

Parameters
list
indexmust be in the list
Returns
element at index (you must free the pointer with free) empty list when start=end unchanged when list is empty unchanged when list is NULL or when start and end are not set correctly NULL error

Definition at line 52879 of file libsheepy.c.

Here is the call graph for this function:

◆ iListCropElemS()

char* iListCropElemS ( char ***  list,
int64_t  index 
)

list Crop Element String return element at index and delete element at index in the original list negative indexes are allowed

iListCropS is faster than listSliceS+iListDelElemS because only the string pointer is returned directly

Parameters
list
indexmust be in the list
Returns
element at index (you must free the pointer with free) empty list when start=end unchanged when list is empty unchanged when list is NULL or when start and end are not set correctly NULL error

Definition at line 52933 of file libsheepy.c.

Here is the call graph for this function:

◆ listInsertS()

char** listInsertS ( char **  list,
int64_t  index,
char **  toInsert 
)

list Insert string

insert list in list at index

return new list with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
list
indexin list
toInsertlist
Returns
new list (you must free the pointer with listFreeS) NULL when list is NULL or invalid index

Definition at line 52986 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListInsertS()

char** iListInsertS ( char ***  list,
int64_t  index,
char **  toInsert 
)

list Insert string

insert list in list at index After this function, free toInsert with free instead of listFreeS

return list with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
list(this parameter is reallocated)
indexin list
toInsertlist
Returns
list (you must free the pointer with listFreeS or free) unchanged list when list is NULL or invalid index NULL error

Definition at line 53060 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListInsertNFreeS()

char** iListInsertNFreeS ( char ***  list,
int64_t  index,
char **  toInsert 
)

list Insert string and free toInsert

insert list in list at index

return list with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
list(this parameter is reallocated)
indexin list
toInsertlist
Returns
list (you must free the pointer with listFreeS or free) unchanged list when list is NULL or invalid index NULL error

Definition at line 53161 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listInjectS()

char** listInjectS ( char **  list,
int64_t  index,
char *  toInject 
)

list Inject string

Inject string in list at index

return new list with toInject at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
list
indexin list
toInjectstring
Returns
new list (you must free the pointer with listFreeS) NULL when list is NULL or invalid index

Definition at line 53254 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listInjectCharS()

char** listInjectCharS ( char **  list,
int64_t  index,
char  toInject 
)

Definition at line 53313 of file libsheepy.c.

Here is the call graph for this function:

◆ iListInjectS()

char** iListInjectS ( char ***  list,
int64_t  index,
char *  toInject 
)

list Inject string

Inject string pointer in list at index

return list with toInject at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
list(this parameter is reallocated)
indexin list
toInjectstring
Returns
list (you must free the pointer with listFreeS or free) unchanged list when list is NULL or invalid index NULL error

Definition at line 53339 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListInjectCharS()

char** iListInjectCharS ( char ***  list,
int64_t  index,
char  toInject 
)

Definition at line 53403 of file libsheepy.c.

Here is the call graph for this function:

◆ listDelS()

char** listDelS ( char **  list,
int64_t  start,
int64_t  end 
)

list Delete String return new list without elements from start and end in list negative indexes are allowed

Parameters
list
startindex, must be in the list
endindex, must be in the list
Returns
sliced list (you must free the pointer with listFreeS) list copy when start=end or when start and end are not set correctly NULL when list is empty NULL when list is NULL or when end is under start

Definition at line 53435 of file libsheepy.c.

Here is the call graph for this function:

◆ iListDelS()

char** iListDelS ( char ***  list,
int64_t  start,
int64_t  end 
)

list Delete String return list without elements from start and end in list negative indexes are allowed

Parameters
list(this parameter is reallocated)
startindex, must be in the list
endindex, must be in the list
Returns
sliced list (you must free the pointer with listFreeS or free) list copy when start=end or when start and end are not set correctly NULL when list is empty NULL when list is NULL or when end is under start NULL error

Definition at line 53512 of file libsheepy.c.

Here is the call graph for this function:

◆ iListRemoveS()

char** iListRemoveS ( char ***  list,
int64_t  start,
int64_t  end 
)

list Remove String return list without elements from start and end in list the elements are removed without being freed negative indexes are allowed

Parameters
list(this parameter is reallocated)
startindex, must be in the list
endindex, must be in the list
Returns
sliced list (you must free the pointer with listFreeS or free) list copy when start=end or when start and end are not set correctly NULL when list is empty NULL when list is NULL or when end is under start NULL error

Definition at line 53595 of file libsheepy.c.

Here is the call graph for this function:

◆ listDelElemS()

char** listDelElemS ( char **  list,
int64_t  index 
)

list Delete Element String return new list without the element at index negative indexes are allowed

Parameters
list
indexmust be in the list
Returns
new list without the element at index (you must free the pointer with listFreeS) NULL when list is empty NULL when list is NULL

Definition at line 53670 of file libsheepy.c.

Here is the call graph for this function:

◆ iListDelElemS()

char** iListDelElemS ( char ***  list,
int64_t  index 
)

list Delete Element String return list without the element at index negative indexes are allowed

Parameters
list(this parameter is reallocated)
indexmust be in the list
Returns
new list without the element at index (you must free the pointer with listFreeS) NULL when list is empty NULL when list is NULL NULL error

Definition at line 53725 of file libsheepy.c.

Here is the call graph for this function:

◆ iListRemoveElemS()

char** iListRemoveElemS ( char ***  list,
int64_t  index 
)

list Remove Element String return list without the element at index the element is removed without being freed negative indexes are allowed

Parameters
list(this parameter is reallocated)
indexmust be in the list
Returns
new list without the element at index (you must free the pointer with listFreeS) NULL when list is empty NULL when list is NULL NULL error

Definition at line 53785 of file libsheepy.c.

Here is the call graph for this function:

◆ listPrintS()

int listPrintS ( char **  list)

print list elements to stdout

when list is NULL, returns directly without doing anything

Parameters
list
Returns
nothing 1 success 0 error

Definition at line 53841 of file libsheepy.c.

Here is the caller graph for this function:

◆ listPrintCS()

int listPrintCS ( const char **  list)

Definition at line 53852 of file libsheepy.c.

Here is the caller graph for this function:

◆ listSortS()

char** listSortS ( char **  list)

list Sort String duplicate list and sort

Parameters
list
Returns
new sorted list (you must free the pointer with listFreeS) empty list when list is empty NULL when list is NULL

Definition at line 53898 of file libsheepy.c.

Here is the call graph for this function:

◆ iListSortS()

char** iListSortS ( char ***  list)

list Sort String

Parameters
list
Returns
sorted list empty list when list is empty unchanged list when list is NULL NULL error

Definition at line 53928 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listSortFS()

char** listSortFS ( char **  list,
shCmpt  compareFunction 
)

list Sort String duplicate list and sort

Parameters
listcompareFunction
Returns
new sorted list (you must free the pointer with listFreeS) empty list when list is empty NULL when list is NULL

Definition at line 53956 of file libsheepy.c.

Here is the call graph for this function:

◆ iListSortFS()

char** iListSortFS ( char ***  list,
shCmpt  compareFunction 
)

list Sort String

Parameters
listcompareFunction
Returns
sorted list empty list when list is empty unchanged list when list is NULL NULL error

Definition at line 53987 of file libsheepy.c.

Here is the call graph for this function:

◆ icListSortS()

char** icListSortS ( char **  list)

ignore case list Sort String duplicate list and sort

Parameters
list
Returns
new sorted list (you must free the pointer with listFreeS) empty list when list is empty NULL when list is NULL

Definition at line 54039 of file libsheepy.c.

Here is the call graph for this function:

◆ iicListSortS()

char** iicListSortS ( char ***  list)

ignore case list Sort String

Parameters
list
Returns
sorted list empty list when list is empty unchanged list when list is NULL NULL error

Definition at line 54069 of file libsheepy.c.

Here is the call graph for this function:

◆ readText()

char** readText ( const char *  filePath)

return text from filePath in a list new line characters are removed

Parameters
filePathfile path
Returns
lines in list (you must free the pointer with listFreeS) empty list when the file is empty NULL on failure

Definition at line 54122 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readStream()

char** readStream ( FILE *  fp)

return text from stream fp in a list new line characters are removed

Parameters
fpfile stream
Returns
lines in list (you must free the pointer with listFreeS) empty list when there is no data in the stream NULL on failure

Definition at line 54187 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeText()

bool writeText ( const char *  filePath,
char **  list 
)

write list to filePath

Parameters
filePath
list
Returns
true success false failed, filePath or list are NULL

Definition at line 54230 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeCText()

bool writeCText ( const char *  filePath,
const char **  list 
)

write const list to filePath

Parameters
filePath
list
Returns
true success false failed, filePath or list are NULL

Definition at line 54267 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeStream()

bool writeStream ( FILE *  fp,
char **  list 
)

write list to stream

Parameters
fpfile stream
list
Returns
true success false failed, fp or list are NULL

Definition at line 54304 of file libsheepy.c.

Here is the caller graph for this function:

◆ writeCStream()

bool writeCStream ( FILE *  fp,
const char **  list 
)

write const list to stream

Parameters
fpfile stream
list
Returns
true success false failed, fp or list are NULL

Definition at line 54328 of file libsheepy.c.

Here is the caller graph for this function:

◆ appendText()

bool appendText ( const char *  filePath,
char **  list 
)

append list to filePath

Parameters
filePath
list
Returns
true success false failed, filePath or list are NULL

Definition at line 54352 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendCText()

bool appendCText ( const char *  filePath,
const char **  list 
)

append const list to filePath

Parameters
filePath
list
Returns
true success false failed, filePath or list are NULL

Definition at line 54389 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execOut()

char** execOut ( const char *  cmd)

execute command return stdout from cmd

Parameters
cmdcommand
Returns
stdout from command in a list (you must free the pointer with listFreeS) empty list when command didnt produce any output NULL when cmd is NULL

Definition at line 54426 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ systemOutf()

char** systemOutf ( const char *  fmt,
  ... 
)

execute system command with formatting

Parameters
formatting
Returns
stdout from command in a list (you must free the pointer with listFreeS) empty list when command didnt produce any output NULL when cmd is NULL

Definition at line 54458 of file libsheepy.c.

Here is the call graph for this function:

◆ systemf()

int systemf ( const char *  fmt,
  ... 
)

execute system command with formatting

Parameters
formatting
Returns
system return code

Definition at line 54484 of file libsheepy.c.

◆ commandF()

int commandF ( const char *  cmd,
int  line,
const char *  thisFunc,
const char *  thisFileName 
)

run command in default shell

Exit value equals to 127 is considered an error because if a shell could not be executed in the child process, then the return value from system() is 127 (man 3 system).

Parameters
cmdcommand string
Returns
command exit code -1 when cmd is NULL or system exited with errors

Definition at line 54514 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ commandfF()

int commandfF ( int  line,
const char *  thisFunc,
const char *  thisFileName,
const char *  fmt,
  ... 
)

run command with formatting in default shell

Exit value equals to 127 is considered an error because if a shell could not be executed in the child process, then the return value from system() is 127 (man 3 system).

Parameters
formatting
Returns
command exit code -1 when cmd is NULL or system exited with errors

Definition at line 54551 of file libsheepy.c.

Here is the call graph for this function:

◆ commandNFreeF()

int commandNFreeF ( char *  cmd,
int  line,
const char *  thisFunc,
const char *  thisFileName 
)

run command in default shell and free the cmd parameter

Exit value equals to 127 is considered an error because if a shell could not be executed in the child process, then the return value from system() is 127 (man 3 system).

Parameters
cmdcommand string
Returns
command exit code -1 when cmd is NULL or system exited with errors

Definition at line 54581 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listEqS()

bool listEqS ( char **  list1,
char **  list2 
)

list Equal String compare each element of list1 and list2

Parameters
2lists
Returns
true the lists have identical elements false they differ

Definition at line 54599 of file libsheepy.c.

Here is the call graph for this function:

◆ listEqCS()

bool listEqCS ( char **  list1,
const char **  list2 
)

const(list2) list Equal String compare each element of list1 and list2

Parameters
2lists
Returns
true the lists have identical elements false they differ

Definition at line 54629 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listEqC1S()

bool listEqC1S ( const char **  list1,
char **  list2 
)

const(list1) list Equal String compare each element of list1 and list2

Parameters
2lists
Returns
true the lists have identical elements false they differ

Definition at line 54659 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listEqCCS()

bool listEqCCS ( const char **  list1,
const char **  list2 
)

const(list1 and 2) list Equal String compare each element of list1 and list2

Parameters
2lists
Returns
true the lists have identical elements false they differ

Definition at line 54689 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listHasS()

bool listHasS ( char **  list,
const char *  string 
)

return true when list has string

Parameters
list
string
Returns
true when list has string false when the string is not found false when list or string are NULL

Definition at line 54721 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listHasCS()

bool listHasCS ( const char **  list,
const char *  string 
)

return true when const list has string

Parameters
list
string
Returns
true when list has string false when the string is not found false when list or string are NULL

Definition at line 54744 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listHasCharS()

bool listHasCharS ( char **  list,
char  c 
)

Definition at line 54755 of file libsheepy.c.

Here is the call graph for this function:

◆ listHasCharCS()

bool listHasCharCS ( const char **  list,
char  c 
)

Definition at line 54761 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listIndexOfS()

ssize_t listIndexOfS ( char **  list,
const char *  string 
)

return index of string in list

Parameters
list
string
Returns
index -1 when the string is not found -1 when list or string are NULL

Definition at line 54779 of file libsheepy.c.

Here is the caller graph for this function:

◆ listIndexOfCS()

ssize_t listIndexOfCS ( const char **  list,
const char *  string 
)

return index of string in const list

Parameters
list
string
Returns
index -1 when the string is not found -1 when list or string are NULL

Definition at line 54813 of file libsheepy.c.

Here is the caller graph for this function:

◆ listIndexOfCharS()

ssize_t listIndexOfCharS ( char **  list,
char  c 
)

Definition at line 54835 of file libsheepy.c.

Here is the call graph for this function:

◆ listIndexOfCharCS()

ssize_t listIndexOfCharCS ( const char **  list,
char  c 
)

Definition at line 54841 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listBinarySearchS()

ssize_t listBinarySearchS ( char **  list,
const char *  string 
)

list binary search string

efficiently finds the index of string in list the list has to be sorted with for example listSortS

Parameters
list
stringto search
Returns
index of string -1 string not found or NULL input pointers

Definition at line 54861 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listBinarySearchCharS()

ssize_t listBinarySearchCharS ( char **  list,
char  c 
)

Definition at line 54884 of file libsheepy.c.

Here is the call graph for this function:

◆ listUniqS()

char** listUniqS ( char **  list)

Uniquify elements of list duplicate list each elements are unique in the new list.

Parameters
list
Returns
new list with unique elements (you must free the pointer with listFreeS) empty list when list is empty NULL when list is NULL

Definition at line 54902 of file libsheepy.c.

Here is the call graph for this function:

◆ iListUniqS()

char** iListUniqS ( char ***  list)

Uniquify elements of list each elements are unique in the list.

Parameters
list(this parameter is reallocated)
Returns
list with unique elements (you must free the pointer with listFreeS) empty list when list is empty unchanged list when list is NULL NULL error

Definition at line 54942 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListEqS()

bool icListEqS ( char **  list1,
char **  list2 
)

ignore case list Equal String compare each element of list1 and list2

Parameters
2lists
Returns
true the lists have identical elements false they differ

Definition at line 54986 of file libsheepy.c.

Here is the call graph for this function:

◆ icListEqCS()

bool icListEqCS ( char **  list1,
const char **  list2 
)

ignore case const(list2) list Equal String compare each element of list1 and list2

Parameters
2lists
Returns
true the lists have identical elements false they differ

Definition at line 55016 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListEqC1S()

bool icListEqC1S ( const char **  list1,
char **  list2 
)

ignore case const(list1) list Equal String compare each element of list1 and list2

Parameters
2lists
Returns
true the lists have identical elements false they differ

Definition at line 55046 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListEqCCS()

bool icListEqCCS ( const char **  list1,
const char **  list2 
)

ignore case const(list1 and 2) list Equal String compare each element of list1 and list2

Parameters
2lists
Returns
true the lists have identical elements false they differ

Definition at line 55076 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListHasS()

bool icListHasS ( char **  list,
const char *  string 
)

ignore case and return true when list has string

Parameters
list
string
Returns
true when list has string false when the string is not found false when list or string are NULL

Definition at line 55108 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListHasCharS()

bool icListHasCharS ( char **  list,
char  c 
)

Definition at line 55119 of file libsheepy.c.

Here is the call graph for this function:

◆ icListHasCS()

bool icListHasCS ( const char **  list,
const char *  string 
)

ignore case and return true when const list has string

Parameters
list
string
Returns
true when list has string false when the string is not found false when list or string are NULL

Definition at line 55137 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListHasCharCS()

bool icListHasCharCS ( const char **  list,
char  c 
)

Definition at line 55148 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListIndexOfS()

ssize_t icListIndexOfS ( char **  list,
const char *  string 
)

ignore case and return index of string in list

Parameters
list
string
Returns
index -1 when the string is not found -1 when list or string are NULL

Definition at line 55166 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListIndexOfCS()

ssize_t icListIndexOfCS ( const char **  list,
const char *  string 
)

ignore case and return index of string in const list

Parameters
list
string
Returns
index -1 when the string is not found -1 when list or string are NULL

Definition at line 55200 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListIndexOfCharS()

ssize_t icListIndexOfCharS ( char **  list,
char  c 
)

Definition at line 55222 of file libsheepy.c.

Here is the call graph for this function:

◆ icListIndexOfCharCS()

ssize_t icListIndexOfCharCS ( const char **  list,
char  c 
)

Definition at line 55228 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListBinarySearchS()

ssize_t icListBinarySearchS ( char **  list,
const char *  string 
)

ignore case list binary search string

efficiently finds the index of string in list the list has be sorted with for example listSortS

Parameters
list
stringto search
Returns
index of string -1 string not found or NULL input pointers

Definition at line 55248 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icListBinarySearchCharS()

ssize_t icListBinarySearchCharS ( char **  list,
char  c 
)

Definition at line 55271 of file libsheepy.c.

Here is the call graph for this function:

◆ icListUniqS()

char** icListUniqS ( char **  list)

ignore case and uniquify elements of list duplicate list each elements are unique in the new list

Parameters
list
Returns
new list with unique elements (you must free the pointer with listFreeS) empty list when list is empty NULL when list is NULL

Definition at line 55289 of file libsheepy.c.

Here is the call graph for this function:

◆ iicListUniqS()

char** iicListUniqS ( char ***  list)

ignore case and uniquify elements of list each elements are unique in the list

Parameters
list(this parameter is reallocated)
Returns
list with unique elements (you must free the pointer with listFreeS) empty list when list is empty unchanged list when list is NULL NULL error

Definition at line 55329 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listCompactS()

char** listCompactS ( char **  list)

remove empty strings from list

Parameters
list
Returns
list without empty strings (you must free the pointer with listFreeS) empty list when list is empty NULL when list is NULL

Definition at line 55373 of file libsheepy.c.

Here is the call graph for this function:

◆ iListCompactS()

char** iListCompactS ( char ***  list)

remove empty strings from list

Parameters
list(this parameter is reallocated)
Returns
list without empty strings (you must free the pointer with listFreeS) empty list when list is empty unchanged list when list is NULL NULL error

Definition at line 55407 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ btraceEnable()

void btraceEnable ( void  )

Definition at line 55441 of file libsheepy.c.

◆ btraceDisable()

void btraceDisable ( void  )

Definition at line 55446 of file libsheepy.c.

Here is the caller graph for this function:

◆ btraceConfig()

bool btraceConfig ( void  )

Definition at line 55451 of file libsheepy.c.

Here is the call graph for this function:

◆ btrace()

char** btrace ( void  )

generate backtrace the program has to be linked the -rdynamic option for btrace to work btrace can backtrace 50 functions at most.

Returns
list of functions in the backtrace, the line format is: function name: source path:line number (you must free the pointer with listFreeS)

Definition at line 55472 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listEmptyF()

void** listEmptyF ( void  )

list Empty Function

Returns
new empty list (you must free the pointer with listFreeS)

Definition at line 55649 of file libsheepy.c.

◆ iListEmptyF()

void** iListEmptyF ( void ***  list)

list Empty Function

Parameters
listlist to empty (this parameter is reallocated)
Returns
empty list (you must free the pointer with listFreeS) NULL error

Definition at line 55668 of file libsheepy.c.

Here is the call graph for this function:

◆ listIsEmpty()

bool listIsEmpty ( void **  list)

list Is Empty

Parameters
list
Returns
false when there are elements in the list true when list is empty true when list is NULL

Definition at line 55696 of file libsheepy.c.

Here is the caller graph for this function:

◆ listCreateF()

void** listCreateF ( void *  paramType,
  ... 
)

list Create Function create a list from the list of parameters used from the listCreate(...) macro

Parameters
listof elements seperated with commas
Returns
list (you must free the pointer with listFreeS) NULL when first element if NULL

Definition at line 55716 of file libsheepy.c.

Here is the call graph for this function:

◆ listFromArray()

void** listFromArray ( void **  array,
size_t  size 
)

list From Array

copy array of 'size' to a new list NULL elements are not copied to the list

Parameters
array
size- number of elements in the array
Returns
list (you must free the pointer with listFreeS) empty list when size is 0 NULL when array is NULL

Definition at line 55748 of file libsheepy.c.

Here is the call graph for this function:

◆ listPush()

void** listPush ( void ***  list,
void *  s 
)

list Push

(like iListPushS)

append s pointer at the end of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, NULL is pushed at the end of the list

the list is reallocated to add extra space

Parameters
pointerto list - becomes NULL when realloc fails (this parameter is reallocated)
selement to push
Returns
list success (you must free the pointer) NULL error

Definition at line 55790 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listPop()

void* listPop ( void ***  list)

list Pop return last element from list and remove last element from the list

Parameters
pointerto list (this parameter is reallocated)
Returns
last element NULL when the list is NULL or empty (first element is NULL)

Definition at line 55832 of file libsheepy.c.

Here is the call graph for this function:

◆ listPrepend()

void** listPrepend ( void ***  list,
void *  s 
)

list Prepend

(like iListPrependS)

append s pointer at the beginning of the list when list is NULL, a new list with one element is returned when list and s are NULL return list with 2 NULL elements when s is NULL, NULL is pushed at the end of the list

the list is reallocated to add extra space

Parameters
pointerto list - becomes NULL when realloc fails (this parameter is reallocated)
selement to prepend
Returns
list success (you must free the pointer) NULL error

Definition at line 55874 of file libsheepy.c.

Here is the call graph for this function:

◆ listDequeue()

void* listDequeue ( void ***  list)

list Dequeue return first element from list and remove last element from the list

Parameters
pointerto list
Returns
first element NULL when the list is NULL or empty (first element is NULL)

Definition at line 55920 of file libsheepy.c.

Here is the call graph for this function:

◆ listFree()

void listFree ( void **  list)

list Free

Parameters
list
Returns
nothing

Definition at line 55954 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listFreeManyF()

void listFreeManyF ( void **  paramType,
  ... 
)

list free many

free variable list of pointers listFreeManyS(l1, l2, ...);

Definition at line 55971 of file libsheepy.c.

Here is the call graph for this function:

◆ listLength()

size_t listLength ( void **  list)

list Length return number of elements until the first NULL element

Parameters
list
Returns
number of element until first NULL element 0 when list is NULL

Definition at line 55994 of file libsheepy.c.

Here is the caller graph for this function:

◆ listGet()

void* listGet ( void **  list,
int64_t  index 
)

list Get

(like iListGetS)

index can be negative

Parameters
list
indexindex in list, must be inside the list
Returns
element NULL when list is NULL or index is not set correctly

Definition at line 56022 of file libsheepy.c.

Here is the call graph for this function:

◆ listSet()

void** listSet ( void **  list,
int64_t  index,
void *  s 
)

list Set

(like iListSetS)

store element at given index previous element at index has to be freed before hand index can be negative

Parameters
list
indexindex in list, must be inside the list
element
Returns
list success NULL error

Does nothing when: when list is NULL, index is not set correctly or s is NULL

Definition at line 56066 of file libsheepy.c.

Here is the call graph for this function:

◆ listDup()

void** listDup ( void **  list)

list Duplicate

(like iListDupS)

copy pointers to new list After this function, free list with free instead of listFreeS

Note: this function creates a new list, so void *** is not needed. Unlike iList functions.

Parameters
list
Returns
new list pointing to the same elements as list (you must free the pointer) NULL when list is NULL

Definition at line 56110 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listReverse()

void** listReverse ( void **  list)

list Reverse create index list and reverse list, the last element is the first element of the new list

Parameters
list
Returns
reversed list (you must free the pointer) NULL when list is NULL

Definition at line 56145 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListReverse()

void** iListReverse ( void ***  list)

list Reverse reverse list, the last element is the first element of the list

Parameters
list(this parameter is reallocated)
Returns
reversed list (you must free the pointer) nothing when list is NULL NULL error

Definition at line 56182 of file libsheepy.c.

Here is the call graph for this function:

◆ listCatF()

void** listCatF ( void **  paramType,
  ... 
)

list Cat

Parameters
arbitrarylist of lists seperated by commas
Returns
new list with input lists concatenated (you must free the pointer)

Definition at line 56203 of file libsheepy.c.

Here is the call graph for this function:

◆ listAppend()

void** listAppend ( void ***  list1,
void **  list2 
)

list Append

(like iListAppendS)

Append list2 at the end of list1 by copying the pointers from list2 to list1. After this function, free list2 with free instead of listFreeS

list1 is reallocated to add extra space

Parameters
list1(this parameter is reallocated)
list2
Returns
list1 and list2 (you must free the pointer) list1 not modified when list1 and list2 are NULL or when list1 is identical to list2 (same pointers) NULL error

Definition at line 56240 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listAdd()

void** listAdd ( void **  list1,
void **  list2 
)

list Add add list1 and list2 in a new list

Parameters
list1
list2
Returns
new list with list1 and list2 (you must free the pointer) NULL when list1 and list2 are NULL

Definition at line 56308 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listSlice()

void** listSlice ( void **  list,
int64_t  start,
int64_t  end 
)

list Slice

(like iListCopyS)

return new list with element pointers from start and end in list negative indexes are allowed

Note: this function creates a new list, so void *** is not needed. Unlike iList functions.

Parameters
list
startindex, must be in the list
endindex, must be in the list
Returns
new list pointing to the same elements as list (you must free the pointer) empty list when start=end NULL when list is empty NULL when list is NULL or when start and end are not set correctly

Definition at line 56370 of file libsheepy.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iListSlice()

void** iListSlice ( void ***  list,
int64_t  start,
int64_t  end 
)

list Slice return list with elements from start and end in list negative indexes are allowed

Parameters
list(this parameter is reallocated)
startindex, must be in the list
endindex, must be in the list
Returns
sliced list (you must free the pointer) empty list when start=end unchanged when list is empty unchanged when list is NULL or when start and end are not set correctly NULL error

Definition at line 56441 of file libsheepy.c.

Here is the call graph for this function:

◆ listInsert()

void** listInsert ( void **  list,
int64_t  index,
void **  toInsert 
)

list Insert

insert list in list at index

return new list with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
list
indexin list
toInsertlist
Returns
new list (you must free the pointer) NULL when list is NULL or invalid index

Definition at line 56522 of file libsheepy.c.

Here is the call graph for this function:

◆ iListInsert()

void** iListInsert ( void ***  list,
int64_t  index,
void **  toInsert 
)

list Insert

insert list in list at index After this function, free toInsert with free instead of listFreeS

return list with toInsert at index negative indexes are allowed index -1 is the end of the array and is equivalent to index len

Parameters
list(this parameter is reallocated)
indexin list
toInsertlist
Returns
list (you must free the pointer) unchanged list when list is NULL or invalid index NULL error

Definition at line 56602 of file libsheepy.c.

Here is the call graph for this function:

◆ listDel()

void** listDel ( void **  list,
int64_t  start,
int64_t  end 
)

list Delete return new list without elements from start and end in list negative indexes are allowed

Parameters
list
startindex, must be in the list
endindex, must be in the list
Returns
sliced list (you must free the pointer) list copy when start=end or when start and end are not set correctly NULL when list is empty NULL when list is NULL or when end is under start

Definition at line 56684 of file libsheepy.c.

Here is the call graph for this function:

◆ iListDel()

void** iListDel ( void ***  list,
int64_t  start,
int64_t  end 
)

list Delete return list without elements from start and end in list negative indexes are allowed

Parameters
list(this parameter is reallocated)
startindex, must be in the list
endindex, must be in the list
Returns
sliced list (you must free the pointer) list copy when start=end or when start and end are not set correctly NULL when list is empty NULL when list is NULL or when end is under start NULL error

Definition at line 56761 of file libsheepy.c.

Here is the call graph for this function:

◆ ringInit()

int ringInit ( void *  ring,
int  maxCount 
)

list Sort duplicate list and sort

Parameters
list
Returns
new sorted list empty list when list is empty NULL when list is NULL list Sort
Parameters
list
Returns
sorted list empty list when list is empty unchanged list when list is NULL list Equal compare each element of list1 and list2
Parameters
2lists
Returns
true the lists have identical elements false they differ return index of element in list
Parameters
listelement
Returns
index -1 when the element is not found -1 when list or element are NULL list binary search

efficiently finds the index of element in list the list has be sorted with for example listSortS

Parameters
listelement to search
Returns
index of element -1 element not found or NULL input pointers Uniquify elements of list duplicate list each elements are unique in the new list
Parameters
list
Returns
new list with unique elements empty list when list is empty NULL when list is NULL Uniquify elements of list each elements are unique in the list
Parameters
list
Returns
list with unique elements empty list when list is empty unchanged list when list is NULL remove empty element from list
Parameters
list
Returns
list without empty element empty list when list is empty NULL when list is NULL remove empty elements from list
Parameters
list
Returns
list without empty elements empty list when list is empty unchanged list when list is NULL initialize ring/pointer to staticArray sets count and head to 0 sets maxCount

the ring is empty after this function

a pointer to staticArray is also valid the array is empty after this function

Parameters
ringpointer to initialize
maxCountfor this ring type
Returns
1 success 0 error

Definition at line 57082 of file libsheepy.c.

◆ ringEmpty()

int ringEmpty ( void *  ring)

empty ring Allocated buffers in the list must be freed before running staticArrayEmpty

Returns
1 success 0 error

Definition at line 57104 of file libsheepy.c.

◆ ringIsEmpty()

int ringIsEmpty ( void *  ring)

1 when empty 0 not empty -1 error

Definition at line 57121 of file libsheepy.c.

Here is the caller graph for this function:

◆ ringIsFull()

int ringIsFull ( void *  ring)

1 when full 0 not full -1 error

Definition at line 57137 of file libsheepy.c.

Here is the caller graph for this function:

◆ ringCount()

ssize_t ringCount ( void *  ring)

return elements count

Returns
message count -1 error

Definition at line 57159 of file libsheepy.c.

◆ ringPush()

i64 ringPush ( void *  ring)

push element to ring (only increases last, use ringSend) use ringLast to access the element

Returns
position of the element -1 ring is full -2 error

Definition at line 57186 of file libsheepy.c.

Here is the call graph for this function:

◆ ringPop()

int ringPop ( void *  ring)

pop element from ring (only decreases last)

Returns
1 element is removed 0 ring is empty -1 error

Definition at line 57215 of file libsheepy.c.

Here is the call graph for this function:

◆ ringPrepend()

i64 ringPrepend ( void *  ring)

prepend element to ring (only decreases head) use ringFirst to access the element

Returns
position of the element -1 ring is full -2 error

Definition at line 57249 of file libsheepy.c.

Here is the call graph for this function:

◆ ringDequeue()

int ringDequeue ( void *  ring)

dequeue element from ring (only increases head, use ringRecv)

Returns
1 element is removed 0 ring is empty -1 error

Definition at line 57282 of file libsheepy.c.

Here is the call graph for this function:

◆ scheduler()

void scheduler ( void  )

fiber usage

The stack is not restored, so all local variables should be stored in the context struct.

Declare a context type for the fiber:

typedef struct {int slot; int a; chanT *c;} AArgs;

the context type must start with int slot; in this example, the fiber has a ring c of type chanT

Declare a function of type:

void fiberA(int thisSlot) { static AArgs *ctx; int slot; ctx = fiberCtx(thisSlot); ... }

several fibers can have the function fiberA with different slots

To yield, add:

yield(slot, ctx->slot); // switch to scheduler ctx = fiberCtx(slot); // restore the context for this fiber

The next steps show how to start the fibers

Declare a variable for the context and create the ring chanT:

AArgs Aa; chanT c; ringInit(&c, chanMax);

Initialize the fiber:

Aa.a = 0; Aa.c = fiberAdd(&Aa, 1, fiberA);

this can also be done from a running fiber

Finally, start the scheduler:

scheduler();

fiber usage

Definition at line 57358 of file libsheepy.c.

Here is the call graph for this function:

◆ staticArrayT()

staticArrayT ( fiberLT  ,
int  ,
tCount   
)

staticArray to hold the fiber slots

◆ fiberAdd()

bool fiberAdd ( void *  ctx,
int  thisSlot,
fiberFT  func 
)

add new fiber

Parameters
ctxcontext for the fiber at thisSlot
thisSlotreserved slot for this fiber
funcfiber function
Returns
true

Definition at line 57321 of file libsheepy.c.

◆ fiberPrepend()

bool fiberPrepend ( void *  ctx,
int  thisSlot,
fiberFT  func 
)

add new fiber and start immediately after next yield

Parameters
ctxcontext for the fiber at thisSlot
thisSlotreserved slot for this fiber
funcfiber function
Returns
true

Definition at line 57344 of file libsheepy.c.

◆ getMonotonicTime()

uint64_t getMonotonicTime ( void  )

end bitfield

Definition at line 57411 of file libsheepy.c.

Here is the caller graph for this function:

◆ nanoSleepF()

int nanoSleepF ( uint64_t  time)

nanosleep

sleep nanoseconds

Parameters
timein nanosceonds
Returns
1 ok 0 error

Definition at line 57427 of file libsheepy.c.

Variable Documentation

◆ TRUE

const bool TRUE

type bool true (glibc true is not bool), for use in generics

Definition at line 862 of file libsheepy.c.

◆ FALSE

const bool FALSE

type bool false (glibc true is not bool), for use in generics

Definition at line 864 of file libsheepy.c.

◆ tryJumpBuffers

jmp_buf tryJumpBuffers[maxTryThrowCount]

setjmp buffers for try/throw,throwV macros

Definition at line 872 of file libsheepy.c.

◆ logMask

uint64_t logMask

variable to control which group logs to show, all logs are enabled by default (0xFFFFFFFFFFFFFFFF)

Definition at line 974 of file libsheepy.c.

◆ codeSzUTF8

const uint8_t codeSzUTF8[256]

Definition at line 31675 of file libsheepy.c.

◆ btraceCfg

bool btraceCfg

backtrace in error messages is enabled by default

Definition at line 867 of file libsheepy.c.

◆ fibers

fibersT fibers

data for fiber system

data for fiber system

Definition at line 57307 of file libsheepy.c.