aboutsummaryrefslogtreecommitdiff
path: root/src/extlib.h
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2024-06-23 03:39:42 +0200
committeraxtloss <axtlos@getcryst.al>2024-06-23 03:39:42 +0200
commitfa4666ae07fb7525aa8e84aacf906bc8cb398a6a (patch)
treee5d1f8b8f3da397c1be313119bb1061bdcadd2d7 /src/extlib.h
downloadextlib-fa4666ae07fb7525aa8e84aacf906bc8cb398a6a.tar.gz
extlib-fa4666ae07fb7525aa8e84aacf906bc8cb398a6a.tar.bz2
Add base extlib
Diffstat (limited to 'src/extlib.h')
-rw-r--r--src/extlib.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/extlib.h b/src/extlib.h
new file mode 100644
index 0000000..1948352
--- /dev/null
+++ b/src/extlib.h
@@ -0,0 +1,46 @@
+/* extlib.h
+ *
+ * Copyright 2024 axtlos <axtlos@disroot.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-3.0-only
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#define free(x) error - use free_secure
+#define malloc(x) error - use malloc_secure
+
+/// Automatically zero out a pointer before freeing it
+void free_secure (void *__ptr, size_t ptrlen);
+
+/// Automatically initialise the allocated memory with zeros
+void *malloc_secure (size_t len);
+
+/// Copy the data of one filestream to another
+void fcopy(FILE *f1, FILE *f2);
+
+/// Convert a string to lowercase
+char *strlwr(char *s);
+
+/// Convert a string to uppercase
+char *strupr(char *s);
+
+/// Trim spaces from a string
+char *trim (char *s);
+
+/// Match string old and replace it with string replace
+char *replace_str (char *s, char *old, char *replace);