.TH LIBSIMPLE.H 0 2018-11-16 libsimple .SH NAME libsimple.h \- main header for libsimple .SH SYNOPSIS .nf #include .fi .SH DESCRIPTION The header .I includes the following header files: .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , .IR , and .IR . .PP The header .I defines the following symbols if at least one them are defined: .BR AF_LOCAL , .BR AF_UNIX , and .BR AF_FILE ; the following symbols if at least one them are defined: .B AF_NETLINK and .BR AF_ROUTE ; the following symbols if at least one them are defined, or if their .B AF_ counterpart is defined: .BR PF_LOCAL , .BR PF_UNIX , and .BR PF_FILE ; the following symbols if at least one them are defined, or if their .B AF_ counterpart is defined: .B PF_NETLINK and .BR PF_ROUTE . Additionally, unless .B DONT_DEFINE_CLOCK_MONOTONIC_RAW is defined, .B CLOCK_MONOTONIC_RAW is defined to .BR CLOCK_MONOTONIC , unless the system defines .BR CLOCK_MONOTONIC_RAW . .PP The header .I also defines, without a value, .B TWOS_COMPLEMENT if two's complement is used to represent signed integers, .B ONES_COMPLEMENT if ones' complement is used to represent signed integers, or .B SIGN_MAGNITUDE if sign\-magnitude is used to represent signed integers. Since no other representation is permitted in C, the header .I will define exactly one of these macros. .PP The header .I defines a number of functions, macros, and variables. The following macros are defined only without namespacing: .TP .BR ELEMSOF (3libsimple) Size of array in number of elements. .TP .BR INTSTRLEN (3libsimple) Maximum length of a string representing an integer. .TP .BR MAX (3libsimple) Maximum of 2 values. .TP .BR MAX3 (3libsimple) Maximum of 3 values. .TP .BR MIN (3libsimple) Minimum of 2 values. .TP .BR MIN3 (3libsimple) Minimum of 3 values. .TP .BR STRLEN (3libsimple) Length of string literal. .TP .BR TYPE_MAX (3libsimple) Largest integer. .TP .BR TYPE_MIN (3libsimple) Smallest integer. .PP The following functions, macros, and variables are defined only with namespacing: .TP .BR libsimple_arrayalloc (3), .RS 0 .BR libsimple_earrayalloc (3), .br .BR libsimple_enarrayalloc (3), .br .BR libsimple_varrayalloc (3), .br .BR libsimple_evarrayalloc (3), .br .BR libsimple_envarrayalloc (3) .RE .RS Flexible allocation of memory suitable for allocating arrays. .RE .TP .BR libsimple_close (3) Close a file and set to stored file descriptor number to mark it file as closed. .TP .BR libsimple_default_failure_exit (3) Default exit value on failure. .TP .BR libsimple_eprintf_postprint (3) Function called after printing error messages. .TP .BR libsimple_eprintf_preprint (3) Function called before printing error messages. .TP .BR libsimple_memalloc (3), .RS 0 .BR libsimple_ememalloc (3), .br .BR libsimple_enmemalloc (3), .br .BR libsimple_vmemalloc (3), .br .BR libsimple_evmemalloc (3), .br .BR libsimple_envmemalloc (3) .RE .RS Flexible allocation of memory. .RE .PP The following functions and macros are defined both with and without namespacing: .TP .BR libsimple_ealigned_alloc (3), .RS 0 .BR libsimple_enaligned_alloc (3) .RE .RS Wrappers for .BR aligned_alloc (3) that terminate the process on failure. .RE .TP .BR libsimple_aligned_allocn (3), .RS 0 .BR libsimple_ealigned_allocn (3), .br .BR libsimple_enaligned_allocn (3), .br .BR libsimple_valigned_allocn (3), .br .BR libsimple_evaligned_allocn (3), .br .BR libsimple_envaligned_allocn (3) .RE .RS Wrappers for .BR aligned_alloc (3) that take the product of multiple arguments as the allocation size. .RE .TP .BR libsimple_aligned_allocz (3), .RS 0 .BR libsimple_ealigned_allocz (3), .br .BR libsimple_enaligned_allocz (3) .RE .RS Wrappers for .BR aligned_alloc (3) that conditionally initialises the memory. .RE .TP .BR libsimple_aligned_alloczn (3), .RS 0 .BR libsimple_ealigned_alloczn (3), .br .BR libsimple_enaligned_alloczn (3), .br .BR libsimple_valigned_alloczn (3), .br .BR libsimple_evaligned_alloczn (3), .br .BR libsimple_envaligned_alloczn (3) .RE .RS Wrappers for .BR aligned_alloc (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. .RE .TP .BR libsimple_aligned_memdup (3), .RS 0 .BR libsimple_ealigned_memdup (3), .br .BR libsimple_enaligned_memdup (3) .RE .RS Duplicate an array of bytes into a new pointer with a custom alignment. .RE .TP .BR libsimple_aligned_memdupa (3) Duplicate an array of bytes onto the stack. .TP .BR libsimple_asprintf (3), .RS 0 .BR libsimple_vasprintf (3) .RE .RS Format a string and allocate a sufficient large string. .RE .TP .BR libsimple_asprintfa (3), .RS 0 .BR libsimple_vasprintfa (3) .RE .RS Format a string and allocate a sufficient large string onto the stack. .RE .TP .BR libsimple_ecalloc (3), .RS 0 .BR libsimple_encalloc (3) .RE .RS Wrappers for .BR calloc (3) that terminate the process on failure. .RE .TP .BR libsimple_callocn (3), .RS 0 .BR libsimple_ecallocn (3), .br .BR libsimple_encallocn (3), .br .BR libsimple_vcallocn (3), .br .BR libsimple_evcallocn (3), .br .BR libsimple_envcallocn (3) .RE .RS Wrappers for .BR calloc (3) that take the product of multiple arguments as the allocation size. .RE .TP .BR libsimple_cmptimespec (3), .RS 0 .BR libsimple_cmptimeval (3) .RE .RS Compare two durations. .RE .TP .BR libsimple_difftimespec (3), .RS 0 .BR libsimple_difftimeval (3) .RE .RS Calculate the difference of two durations. .RE .TP .BR libsimple_doubletotimespec (3), .RS 0 .BR libsimple_doubletotimeval (3) .RE .RS Convert a real value to a duration data structure. .RE .TP .BR libsimple_eprintf (3), .RS 0 .BR libsimple_enprintf (3), .br .BR libsimple_veprintf (3), .br .BR libsimple_venprintf (3), .br .BR libsimple_weprintf (3), .br .BR libsimple_vweprintf (3) .RE .RS Print an error message and (except for the two last functions) terminate the process. .RE .TP .BR libsimple_getenv_e (3) Get the value of an environment value or the empty string. .TP .BR libsimple_getenv_ne (3) Get the value of a non-empty environment value or .BR NULL . .TP .BR libsimple_inchrset (3) .RS 0 .BR libsimple_inchrcaseset (3) .RE .RS Test if a byte belongs to set of byte. .RE .TP .BR libsimple_emalloc (3), .RS 0 .BR libsimple_enmalloc (3) .RE .RS Wrappers for .BR malloc (3) that terminate the process on failure. .RE .TP .BR libsimple_mallocn (3), .RS 0 .BR libsimple_emallocn (3), .br .BR libsimple_enmallocn (3), .br .BR libsimple_vmallocn (3), .br .BR libsimple_evmallocn (3), .br .BR libsimple_envmallocn (3) .RE .RS Wrappers for .BR malloc (3) that take the product of multiple arguments as the allocation size. .RE .TP .BR libsimple_mallocz (3), .RS 0 .BR libsimple_emallocz (3), .br .BR libsimple_enmallocz (3) .RE .RS Wrappers for .BR aligned_alloc (3) that conditionally initialises the memory. .RE .TP .BR libsimple_malloczn (3), .RS 0 .BR libsimple_emalloczn (3), .br .BR libsimple_enmalloczn (3), .br .BR libsimple_vmalloczn (3), .br .BR libsimple_evmalloczn (3), .br .BR libsimple_envmalloczn (3) .RE .RS Wrappers for .BR malloc (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. .RE .TP .BR libsimple_memalign (3), .RS 0 .BR libsimple_ememalign (3), .br .BR libsimple_enmemalign (3) .RE .RS Implementation of the nonstandard .BR memalign (3) function. .RE .TP .BR libsimple_memalignn (3), .RS 0 .BR libsimple_ememalignn (3), .br .BR libsimple_enmemalignn (3), .br .BR libsimple_vmemalignn (3), .br .BR libsimple_evmemalignn (3), .br .BR libsimple_envmemalignn (3) .RE .RS Versions of .BR libsimple_memalign (3) that take the product of multiple arguments as the allocation size. .RE .TP .BR libsimple_memalignz (3), .RS 0 .BR libsimple_ememalignz (3), .br .BR libsimple_enmemalignz (3) .RE .RS Versions of .BR libsimple_memalign (3) that conditionally initialises the memory. .RE .TP .BR libsimple_memalignzn (3), .RS 0 .BR libsimple_ememalignzn (3), .br .BR libsimple_enmemalignzn (3), .br .BR libsimple_vmemalignzn (3), .br .BR libsimple_evmemalignzn (3), .br .BR libsimple_envmemalignzn (3) .RE .RS Versions of .BR libsimple_memalign (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. .RE .TP .BR libsimple_memcasechr (3) Case-insensitive version of .BR memchr (3). .TP .BR libsimple_memcasecmp (3) Case-insensitive version of .BR memcmp (3). .TP .BR libsimple_memdup (3), .RS 0 .BR libsimple_ememdup (3), .br .BR libsimple_enmemdup (3) .RE .RS Duplicate an array of bytes into a new pointer. .RE .TP .BR libsimple_memdupa (3) Duplicate an array of bytes onto the stack. .TP .BR libsimple_memelem (3) Version of .BR memchr (3) that operate on multibyte units rather than simple bytes. .TP .BR libsimple_memends (3), .RS 0 .BR libsimple_memcaseends (3) .RE .RS Check the end if an array of bytes. .RE .TP .BR libsimple_memeq (3), .RS 0 .BR libsimple_memcaseeq (3) .RE .RS Compare two arrays of bytes for equality. .RE .TP .BR libsimple_memeqlen (3), .RS 0 .BR libsimple_memcaseeqlen (3) .RE .RS Get the number if bytes two arrays of bytes have in common at their beginning. .RE .TP .BR libsimple_memmem (3), .RS 0 .BR libsimple_memcasemem (3) .RE .RS Find a substring of bytes in an array of bytes. .RE .TP .BR libsimple_mempcpy (3) Version of .BR memcpy that returns the end of the written array. .TP .BR libsimple_mempmove (3) Version of .BR memmove that returns the end of the written array. .TP .BR libsimple_mempset (3) Version of .BR memset that returns the end of the written array. .TP .BR libsimple_mempsetelem (3) Version of .BR libsimple_memsetelem that returns the end of the written array. .TP .BR libsimple_memrchr (3), .RS 0 .BR libsimple_memrcasechr (3) .RE .RS Find the last occurrence of a specific byte in an array of bytes. .RE .TP .BR libsimple_memrelem (3) Find the last occurrence of a specific element in an array. .TP .BR libsimple_memreqlen (3), .RS 0 .BR libsimple_memrcaseeqlen (3) .RE .RS Get the number if bytes two arrays of bytes have in common at their end. .RE .TP .BR libsimple_memrmem (3), .RS 0 .BR libsimple_memrcasemem (3) .RE .RS Find the last occurrence of string of byte in an array of bytes. .RE .TP .BR libsimple_memsetelem (3) Fill en array. .TP .BR libsimple_memstarts (3), .RS 0 .BR libsimple_memcasestarts (3) .RE .RS Check the beginning if an array of bytes. .RE .TP .BR libsimple_multimespec (3), .RS 0 .BR libsimple_multimeval (3) .RE .RS Multiple a duration with an integer. .RE .TP .BR libsimple_eposix_memalign (3), .RS 0 .BR libsimple_enposix_memalign (3) .RE .RS Wrappers for .BR posix_memalign (3) that terminate the process on failure. .RE .TP .BR libsimple_posix_memalignn (3), .RS 0 .BR libsimple_eposix_memalignn (3), .br .BR libsimple_enposix_memalignn (3), .br .BR libsimple_vposix_memalignn (3), .br .BR libsimple_evposix_memalignn (3), .br .BR libsimple_envposix_memalignn (3) .RE .RS Wrappers for .BR posix_memalign (3) that take the product of multiple arguments as the allocation size. .RE .TP .BR libsimple_posix_memalignz (3), .RS 0 .BR libsimple_eposix_memalignz (3), .br .BR libsimple_enposix_memalignz (3) .RE .RS Wrappers for .BR posix_memalign (3) that conditionally initialises the memory. .RE .TP .BR libsimple_posix_memalignzn (3), .RS 0 .BR libsimple_eposix_memalignzn (3), .br .BR libsimple_enposix_memalignzn (3), .br .BR libsimple_vposix_memalignzn (3), .br .BR libsimple_evposix_memalignzn (3), .br .BR libsimple_envposix_memalignzn (3) .RE .RS Wrappers for .BR posix_memalign (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. .RE .TP .BR libsimple_putenvf (3), .RS 0 .BR libsimple_eputenvf (3), .br .BR libsimple_enputenvf (3), .br .BR libsimple_vputenvf (3), .br .BR libsimple_evputenvf (3), .br .BR libsimple_envputenvf (3) .RE .RS Verion of .BR putenv (3) that formats the string. .RE .TP .BR libsimple_pvalloc (3), .RS 0 .BR libsimple_epvalloc (3), .br .BR libsimple_enpvalloc (3) .RE .RS Implementation of the nonstandard .BR pvalloc (3) function. .RE .TP .BR libsimple_pvallocn (3), .RS 0 .BR libsimple_epvallocn (3), .br .BR libsimple_enpvallocn (3), .br .BR libsimple_vpvallocn (3), .br .BR libsimple_evpvallocn (3), .br .BR libsimple_envpvallocn (3) .RE .RS Versions of .BR libsimple_pvalloc (3) that take the product of multiple arguments as the allocation size. .RE .TP .BR libsimple_pvallocz (3), .RS 0 .BR libsimple_epvallocz (3), .br .BR libsimple_enpvallocz (3) .RE .RS Versions of .BR libsimple_pvalloc (3) that conditionally initialises the memory. .RE .TP .BR libsimple_pvalloczn (3), .RS 0 .BR libsimple_epvalloczn (3), .br .BR libsimple_enpvalloczn (3), .br .BR libsimple_vpvalloczn (3), .br .BR libsimple_evpvalloczn (3), .br .BR libsimple_envpvalloczn (3) .RE .RS Versions of .BR libsimple_pvalloc (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. .RE .TP .BR libsimple_rawmemchr (3) .RS 0 .BR libsimple_rawmemcasechr (3) .RE .RS Find the first occurrence of a specific byte in an array of bytes, with the optimising assumption that is actually exists in the array. .RE .TP .BR libsimple_rawmemrchr (3) .RS 0 .BR libsimple_rawmemrcasechr (3) .RE .RS Find the last occurrence of a specific byte in an array of bytes, with the optimising assumption that is actually exists in the array. .RE .TP .BR libsimple_erealloc (3), .RS 0 .BR libsimple_enrealloc (3) .RE .RS Wrappers for .BR realloc (3) that terminate the process on failure. .RE .TP .BR libsimple_reallocn (3), .RS 0 .BR libsimple_ereallocn (3), .br .BR libsimple_enreallocn (3), .br .BR libsimple_vreallocn (3), .br .BR libsimple_evreallocn (3), .br .BR libsimple_envreallocn (3) .RE .RS Wrappers for .BR realloc (3) that take the product of multiple arguments as the allocation size. .RE .TP .BR libsimple_strcasechr (3) Case-insensitive version of .BR strchr (3). .TP .BR libsimple_strcasestr (3) Case-insensitive version of .BR strstr (3). .TP .BR libsimple_strchrnul (3), .RS 0 .BR libsimple_strcasechrnul (3), .br .BR libsimple_strnchrnul (3), .br .BR libsimple_strncasechrnul (3) .RE .RS Versions of .BR strchr (3), .BR libsimple_strcasechr (3), .BR libsimple_strnchr (3), and .BR libsimple_strncasechr (3) that return the end of the string if the byte is not found. .RE .TP .BR libsimple_strcmpnul (3), .RS 0 .BR libsimple_strcasecmpnul (3), .br .BR libsimple_strncmpnul (3), .br .BR libsimple_strncasecmpnul (3) .RE .RS Versions of .BR strcmp (3), .BR strcasecmp (3), .BR strncmp (3), and .BR strncasecmp (3) that support .BR NULL . .RE .TP .BR libsimple_estrdup (3), .RS 0 .BR libsimple_enstrdup (3), .br .BR libsimple_estrndup (3), .br .BR libsimple_enstrndup (3) .RE .RS Wrappers of .BR strdup (3) and .BR strndup (3) that terminate the process on failure. .RE .TP .BR libsimple_strdupa (3), .RS 0 .BR libsimple_strndupa (3) .RE .RS Versions of .BR strdup (3), and .BR strndup (3) that allocate the string on the stack. .RE .TP .BR libsimple_strend (3), .RS 0 .BR libsimple_strnend (3) .RE .RS Locate end of string. .RE .TP .BR libsimple_strends (3), .RS 0 .BR libsimple_strcaseends (3), .br .BR libsimple_strnends (3), .br .BR libsimple_strncaseends (3) .RE .RS Check the end if a string. .RE .TP .BR libsimple_streq (3), .RS 0 .BR libsimple_strcaseeq (3), .br .BR libsimple_strneq (3), .br .BR libsimple_strncaseeq (3) .RE .RS Compare two strings for equality. .RE .TP .BR libsimple_streqlen (3), .RS 0 .BR libsimple_strcaseeqlen (3), .br .BR libsimple_strneqlen (3), .br .BR libsimple_strncaseeqlen (3) .RE .RS Get the number if bytes two strings have in common at their beginning. .RE .TP .BR libsimple_streqnul (3), .RS 0 .BR libsimple_strcaseeqnul (3), .br .BR libsimple_strneqnul (3), .br .BR libsimple_strncaseeqnul (3) .RE .RS Verions of .BR libsimple_streq (3) and .BR libsimple_strcaseeq (3) that support .BR NULL . .RE .TP .BR libsimple_strisutf8 (3), .RS 0 .BR libsimple_strnisutf8 (3), .br .BR libsimple_memisutf8 (3) .RE .RS Check if a string is valid UTF-8. .RE .TP .BR libsimple_strnchr (3), .RS 0 .BR libsimple_strncasechr (3) .RE .RS Versions of .BR strchr (3) and .BR libsimple_strcasechr (3) that support strings without NUL-termination. .RE .TP .BR libsimple_strnstr (3), .RS 0 .BR libsimple_strncasestr (3) .RE .RS Versions of .BR strstr (3) and .BR libsimple_strcasestr (3) that support strings without NUL-termination. .RE .TP .BR libsimple_strrcasechr (3) Case-insensitive version of the .BR strrchr (3). .TP .BR libsimple_strreqlen (3), .RS 0 .BR libsimple_strrcaseeqlen (3), .br .BR libsimple_strrneqlen (3), .br .BR libsimple_strrncaseeqlen (3) .RE .RS Get the number if bytes two strings have in common at their end. .RE .TP .BR libsimple_strrnchr (3), .RS 0 .BR libsimple_strrncasechr (3) .RE .RS Versions of .BR strrchr (3) and .BR libsimple_strrcasechr (3) that support strings without NUL-termination. .RE .TP .BR libsimple_strrstr (3), .RS 0 .BR libsimple_strrcasestr (3), .br .BR libsimple_strrnstr (3), .br .BR libsimple_strrncasestr (3) .RE .RS Find the last occurrence of a substring. .RE .TP .BR libsimple_strstarts (3), .RS 0 .BR libsimple_strcasestarts (3), .br .BR libsimple_strnstarts (3), .br .BR libsimple_strncasestarts (3) .RE .RS Check the beginning if a string. .RE .TP .BR libsimple_strtotimespec (3), .RS 0 .BR libsimple_strtotimeval (3) .RE .RS Convert a string, with a real value representing a number of seconds, to a duration. .RE .TP .BR libsimple_sumtimespec (3), .RS 0 .BR libsimple_sumtimeval (3) .RE .RS Calculate the sum of two durations. .RE .TP .BR libsimple_timespec2timeval (3), .RS 0 .BR libsimple_timeval2timespec (3) .RE .RS Convert a duration between to storage formats. .RE .TP .BR libsimple_timespectodouble (3), .RS 0 .BR libsimple_timevaltodouble (3) .RE .RS Convert a duration stored in a duration specific format to a double. .RE .TP .BR libsimple_timespectostr (3), .RS 0 .BR libsimple_timevaltostr (3), .br .BR libsimple_minimise_number_string (3) .RE .RS Convert a duration stored in a duration specific format to a string. .RE .TP .BR libsimple_unlist (3), .RS 0 .BR LIBSIMPLE_UNLIST (3) .RE .RS Remove an item from an array without changing the order of the items in the array. .RE .TP .BR libsimple_valloc (3), .RS 0 .BR libsimple_evalloc (3), .br .BR libsimple_envalloc (3) .RE .RS Implementation of the nonstandard .BR valloc (3) function. .RE .TP .BR libsimple_vallocn (3), .RS 0 .BR libsimple_evallocn (3), .br .BR libsimple_envallocn (3), .br .BR libsimple_vvallocn (3), .br .BR libsimple_evvallocn (3), .br .BR libsimple_envvallocn (3) .RE .RS Versions of .BR libsimple_valloc (3) that take the product of multiple arguments as the allocation size. .RE .TP .BR libsimple_vallocz (3), .RS 0 .BR libsimple_evallocz (3), .br .BR libsimple_envallocz (3) .RE .RS Versions of .BR libsimple_valloc (3) that conditionally initialises the memory. .RE .TP .BR libsimple_valloczn (3), .RS 0 .BR libsimple_evalloczn (3), .br .BR libsimple_envalloczn (3), .br .BR libsimple_vvalloczn (3), .br .BR libsimple_evvalloczn (3), .br .BR libsimple_envvalloczn (3) .RE .RS Versions of .BR libsimple_valloc (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. .RE .SH APPLICATION USAGE None. .SH RATIONALE None. .SH FUTURE DIRECTIONS None. .SH NOTES None. .SH SEE ALSO .BR libsimple-arg.h (0)