aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--doc/fcopy.375
-rw-r--r--doc/memset_s.351
-rw-r--r--doc/memvcmp.332
-rw-r--r--doc/replace_str.334
-rw-r--r--doc/rrmdir.333
-rw-r--r--doc/set_constraint_handler_s.3147
-rw-r--r--doc/strlwr.341
-rw-r--r--doc/strupr.341
-rw-r--r--doc/trim.340
9 files changed, 494 insertions, 0 deletions
diff --git a/doc/fcopy.3 b/doc/fcopy.3
new file mode 100644
index 0000000..5096fe4
--- /dev/null
+++ b/doc/fcopy.3
@@ -0,0 +1,75 @@
+'\" t
+.\" Copyright 2024 axtlos (axtlos@disroot.org)
+.\"
+.\" SPDX-License-Identifier: BSD-3-Clause
+
+.TH fcopy 3 2024-07-13 "extlib"
+.SH NAME
+fcopy \- copy a file
+.SH LIBRARY
+extlib extended standard library
+.RI ( libextlib ", " \-lextlib )
+.SH SYNOPSIS
+.nf
+.B #include <extlib.h>
+.P
+.BI "size_t fcopy(FILE *src, FILE *dst);"
+.fi
+.SH DESCRIPTION
+If
+.I *src
+or
+.I *dst
+is NULL, the
+.BR fcopy ()
+function will return -1 and do nothing else.
+Otherwise, this function copies the contents
+of
+.I *src
+to
+.IR *dst .
+.fi
+.SH RETURN VALUE
+The
+.BR fcopy ()
+function returns the amount of bytes copied from
+.I *src
+to
+.IR *dst .
+.SH EXAMPLES
+The following code will write the text "hello" into
+a memstream, and then copy the contents of that
+file into a second memstream buffer.
+.fi
+\&
+.\" SRC BEGIN (fcopy.c)
+.EX
+#include <stdio.h>
+#include <stdlib.h>
+#include <extlib.h>
+\&
+int
+main(void)
+{
+ char *buf_a, *buf_b;
+ size_t len_a, len_b;
+ FILE *file_buf_a = open_memstream (&buf_a, &len_a);
+ FILE *file_buf_b = open_memstream (&buf_b, &len_b);
+\&
+ fprintf (file_test_a, "hello");
+ fflush (file_test_a);
+ fclose (file_test_a);
+ file_test_a = fmemopen(buf_a, len_a, "r");
+\&
+ fcopy (file_test_a, file_test_b);
+ fclose (file_test_b);
+\&
+ puts (buf_a);
+ puts (buf_b);
+ free (buf_a);
+ free (buf_b);
+\&
+ exit(EXIT_SUCCESS);
+}
+.EE
+.\" SRC END
diff --git a/doc/memset_s.3 b/doc/memset_s.3
new file mode 100644
index 0000000..57956d0
--- /dev/null
+++ b/doc/memset_s.3
@@ -0,0 +1,51 @@
+'\" t
+.\" Copyright 2024 axtlos (axtlos@disroot.org)
+.\"
+.\" SPDX-License-Identifier: BSD-3-Clause
+
+.TH memset_s 3 2024-07-14 "extlib"
+.SH NAME
+fcopy \- copy a file
+.SH LIBRARY
+extlib extended standard library
+.RI ( libextlib ", " \-lextlib )
+.SH SYNOPSIS
+.nf
+.B #define __STDC_WANT_LIB_EXT1__ 1
+.P
+.B #include <extlib.h>
+.P
+.BI "errno_t memset_s (void *s, rsize_t max, int c, rsize_t n);"
+.fi
+.SH DESCRIPTION
+The
+.BR memset_s()
+function behaves the same way as
+.BR memset ()
+except that it will not be removed through Dead Store Elimination,
+which makes it useful when sensitive data needs to be cleared.
+Unlike
+.BR memset()
+,
+.BR memset_s()
+will also return an error and call the currently registered constraint handler
+if
+.I *s
+is a null pointer,
+.I max
+or
+.I n
+is greater than RSIZE_MAX, or
+.I n
+is greater than max.
+.fi
+.SH RETURN VALUE
+The
+.BR memset_s ()
+returns zero on success, non-zero on error.
+.I *src
+to
+.IR *dst .
+.SH STANDARDS
+.BR memset_s ()
+conforms to ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1.
diff --git a/doc/memvcmp.3 b/doc/memvcmp.3
new file mode 100644
index 0000000..952c0cf
--- /dev/null
+++ b/doc/memvcmp.3
@@ -0,0 +1,32 @@
+'\" t
+.\" Copyright 2024 axtlos (axtlos@disroot.org)
+.\"
+.\" SPDX-License-Identifier: BSD-3-Clause
+
+.TH memvcmp 3 2024-07-14 "extlib"
+.SH NAME
+memvcmp \- compare a memory area to a value
+.SH LIBRARY
+extlib extended standard library
+.RI ( libextlib ", " \-lextlib )
+.SH SYNOPSIS
+.nf
+.B #include <extlib.h>
+.P
+.BI "int memvcmp (void *str, char val, size_t n);"
+.fi
+.SH DESCRIPTION
+The
+.BR memcvmp ()
+function compares
+.I n
+bytes of
+.I *str
+to the value
+.I val
+.
+.fi
+.SH RETURN VALUE
+.BR memvcmp ()
+returns zero if the area matches, non-zero if it does not.
+.\" SRC END
diff --git a/doc/replace_str.3 b/doc/replace_str.3
new file mode 100644
index 0000000..230f6d1
--- /dev/null
+++ b/doc/replace_str.3
@@ -0,0 +1,34 @@
+'\" t
+.\" Copyright 2024 axtlos (axtlos@disroot.org)
+.\"
+.\" SPDX-License-Identifier: BSD-3-Clause
+
+.TH replace_str 3 2024-07-14 "extlib"
+.SH NAME
+replace_str \- replace a substring in a string
+.SH LIBRARY
+extlib extended standard library
+.RI ( libextlib ", " \-lextlib )
+.SH SYNOPSIS
+.nf
+.B #include <extlib.h>
+.P
+.BI "char *replace_str (char *s, char *old, char *replace);"
+.P
+.fi
+.SH DESCRIPTION
+The
+.BR replace_str ()
+function replaces any matches of
+.I *old
+in the string
+.I *s
+with the string
+.IR *replace .
+.fi
+.SH RETURN VALUE
+.BR replace_str ()
+returns a copy of
+.I *s
+with all the substrings replaced.
+.\" SRC END
diff --git a/doc/rrmdir.3 b/doc/rrmdir.3
new file mode 100644
index 0000000..bb4be4e
--- /dev/null
+++ b/doc/rrmdir.3
@@ -0,0 +1,33 @@
+'\" t
+.\" Copyright 2024 axtlos (axtlos@disroot.org)
+.\"
+.\" SPDX-License-Identifier: BSD-3-Clause
+
+.TH rrmdir 3 2024-07-14 "extlib"
+.SH NAME
+rrmdir \- recursively remove a directory
+.SH LIBRARY
+extlib extended standard library
+.RI ( libextlib ", " \-lextlib )
+.SH SYNOPSIS
+.nf
+.B #define _XOPEN_SOURCE 500
+.P
+.B #include <extlib.h>
+.P
+.BI "int rrmdir(char *pathname);"
+.fi
+.SH DESCRIPTION
+.BR rrmdir ()
+loops over
+.I *pathname
+using
+.BR nftw ()
+and removes every file and directory found in
+.I *pathname
+.
+.fi
+.SH RETURN VALUE
+.BR rrmdir ()
+return zero on sucess, non-zero on error.
+.\" SRC END
diff --git a/doc/set_constraint_handler_s.3 b/doc/set_constraint_handler_s.3
new file mode 100644
index 0000000..0860465
--- /dev/null
+++ b/doc/set_constraint_handler_s.3
@@ -0,0 +1,147 @@
+.\" Copyright 2018 Yuri Pankov <yuripv@yuripv.net>
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd August 18, 2018
+.Dt SET_CONSTRAINT_HANDLER_S 3
+.Os
+.Sh NAME
+.Nm set_constraint_handler_s ,
+.Nm abort_handler_s ,
+.Nm ignore_handler_s
+.Nd runtime-constraint violation handling
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.Fd #define __STDC_WANT_LIB_EXT1__ 1
+.In stdlib.h
+.Ft constraint_handler_t
+.Fo set_constraint_handler_s
+.Fa "constraint_handler_t handler"
+.Fc
+.Ss Handler Prototype
+.Ft typedef void
+.Fo (*constraint_handler_t)
+.Fa "const char * restrict msg"
+.Fa "void * restrict ptr"
+.Fa "errno_t error"
+.Fc
+.Ss Predefined Handlers
+.Ft void
+.Fo abort_handler_s
+.Fa "const char * restrict msg"
+.Fa "void * restrict ptr"
+.Fa "errno_t error"
+.Fc
+.Ft void
+.Fo ignore_handler_s
+.Fa "const char * restrict msg"
+.Fa "void * restrict ptr"
+.Fa "errno_t error"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn set_constraint_handler_s
+function sets the runtime-constraint violation handler to be
+.Fa handler .
+.Pp
+The runtime-constraint handler is the callback function invoked when a library
+function detects a runtime-constraint violation.
+.Pp
+The arguments are as follows:
+.Bl -tag -width "error"
+.It Fa msg
+A pointer to a character string describing the runtime-constraint violation.
+.It Fa ptr
+A
+.Dv NULL
+pointer.
+.It Fa error
+If the function calling the handler has a return type declared as
+.Vt errno_t ,
+the return value of the function is passed.
+Otherwise, a positive value of type
+.Vt errno_t
+is passed.
+.El
+.Pp
+Only the most recent handler registered with
+.Fn set_constraint_handler_s
+is called when a runtime-constraint violation occurs.
+.Pp
+The implementation has a default constraint handler that is used if no calls to
+the
+.Fn set_constraint_handler_s
+function have been made.
+If the
+.Fa handler
+argument to
+.Fn set_constraint_handler_s
+is a
+.Dv NULL
+pointer, the default handler becomes the current constraint handler.
+.Pp
+The
+.Fn abort_handler_s
+and
+.Fn ignore_handler_s
+are the standard-defined runtime-constraint handlers provided by the C library.
+.Pp
+The
+.Fn abort_handler_s
+function writes the error message including the
+.Fa msg
+to
+.Dv stderr
+and calls the
+.Xr abort 3
+function.
+The
+.Fn abort_handler_s
+is currently the default runtime-constraint handler.
+.Pp
+The
+.Fn ignore_handler_s
+simply returns to its caller.
+.Sh RETURN VALUES
+The
+.Fn set_constraint_handler_s
+function returns a pointer to the previously registered handler, or
+.Dv NULL
+if none was previously registered.
+.Pp
+The
+.Fn abort_handler_s
+function does not return to its caller.
+.Pp
+The
+.Fn ignore_handler_s
+function returns no value.
+.Sh STANDARDS
+The
+.Fn set_constraint_handler_s
+function conforms to
+.St -isoC-2011
+K.3.6.1.1.
+.Sh AUTHORS
+This manual page was written by
+.An Yuri Pankov Aq Mt yuripv@yuripv.net .
diff --git a/doc/strlwr.3 b/doc/strlwr.3
new file mode 100644
index 0000000..ca2e971
--- /dev/null
+++ b/doc/strlwr.3
@@ -0,0 +1,41 @@
+'\" t
+.\" Copyright 2024 axtlos (axtlos@disroot.org)
+.\"
+.\" SPDX-License-Identifier: BSD-3-Clause
+
+.TH strlwr 3 2024-07-14 "extlib"
+.SH NAME
+strlwr, strupr \- convert a string to upper/lowercase
+.SH LIBRARY
+extlib extended standard library
+.RI ( libextlib ", " \-lextlib )
+.SH SYNOPSIS
+.nf
+.B #include <extlib.h>
+.P
+.BI "char *strlwr (char *s);"
+.P
+.BI "char *strupr (char *s);"
+.P
+.fi
+.SH DESCRIPTION
+The
+.BR strlwr ()
+function converts
+.I *s
+to a lowercase version of itself.
+The
+.BR strupr ()
+function converts
+.I *s
+to an uppercase version of itself.
+In both functions
+.I *s
+will be consumed and cannot be used after the function completes.
+.fi
+.SH RETURN VALUE
+.BR strlwr ()
+and
+.BR strupr ()
+return the string in the appropriate case, the resulting string will have to be manually free'd.
+.\" SRC END
diff --git a/doc/strupr.3 b/doc/strupr.3
new file mode 100644
index 0000000..ca2e971
--- /dev/null
+++ b/doc/strupr.3
@@ -0,0 +1,41 @@
+'\" t
+.\" Copyright 2024 axtlos (axtlos@disroot.org)
+.\"
+.\" SPDX-License-Identifier: BSD-3-Clause
+
+.TH strlwr 3 2024-07-14 "extlib"
+.SH NAME
+strlwr, strupr \- convert a string to upper/lowercase
+.SH LIBRARY
+extlib extended standard library
+.RI ( libextlib ", " \-lextlib )
+.SH SYNOPSIS
+.nf
+.B #include <extlib.h>
+.P
+.BI "char *strlwr (char *s);"
+.P
+.BI "char *strupr (char *s);"
+.P
+.fi
+.SH DESCRIPTION
+The
+.BR strlwr ()
+function converts
+.I *s
+to a lowercase version of itself.
+The
+.BR strupr ()
+function converts
+.I *s
+to an uppercase version of itself.
+In both functions
+.I *s
+will be consumed and cannot be used after the function completes.
+.fi
+.SH RETURN VALUE
+.BR strlwr ()
+and
+.BR strupr ()
+return the string in the appropriate case, the resulting string will have to be manually free'd.
+.\" SRC END
diff --git a/doc/trim.3 b/doc/trim.3
new file mode 100644
index 0000000..fe2f7ab
--- /dev/null
+++ b/doc/trim.3
@@ -0,0 +1,40 @@
+'\" t
+.\" Copyright 2024 axtlos (axtlos@disroot.org)
+.\"
+.\" SPDX-License-Identifier: BSD-3-Clause
+
+.TH trim 3 2024-07-14 "extlib"
+.SH NAME
+trim \- trim leading/trailing whitespace from a string
+.SH LIBRARY
+extlib extended standard library
+.RI ( libextlib ", " \-lextlib )
+.SH SYNOPSIS
+.nf
+.B #include <extlib.h>
+.P
+.BI "char *trim (char *s, int *rem_front, int *rem_back);"
+.P
+.fi
+.SH DESCRIPTION
+The
+.BR trim ()
+function removes leading/trailing newspace from
+.IR *s .
+If
+.I *rem_front
+is not NULL, it is set to the amount of leading whitespace removed from
+.IR *s .
+If
+.I *rem_back
+is not NULL, it is set to the amount of trailing whitespace removed from string
+.IR *s .
+.BR trim ()
+does not consume
+.Ir *s ,
+it needs to be free'd manually.
+.fi
+.SH RETURN VALUE
+.BR trim ()
+returns the trimmed string.
+.\" SRC END