aboutsummaryrefslogtreecommitdiff
path: root/src/extlib.c
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2024-07-16 02:28:06 +0200
committeraxtloss <axtlos@getcryst.al>2024-07-16 02:28:06 +0200
commit8a1c3461bb820bf875a50be56c7652177cf50645 (patch)
treeb79b103693dc01f0f5b0b993e9f9fcf972d67977 /src/extlib.c
parent0366952bae967a1b69c510f8e633c0567ccab4a9 (diff)
downloadextlib-8a1c3461bb820bf875a50be56c7652177cf50645.tar.gz
extlib-8a1c3461bb820bf875a50be56c7652177cf50645.tar.bz2
fix formatting
Diffstat (limited to 'src/extlib.c')
-rw-r--r--src/extlib.c90
1 files changed, 44 insertions, 46 deletions
diff --git a/src/extlib.c b/src/extlib.c
index 2ee4225..e1fdb14 100644
--- a/src/extlib.c
+++ b/src/extlib.c
@@ -1,15 +1,16 @@
-/* extlib.c
+/*
+ * extlib.c
*
* 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
+ * 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.
+ * 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/>.
@@ -32,69 +33,66 @@
#undef malloc
void
-free_secure(void **__ptr, size_t ptrlen)
+free_secure (void **__ptr, size_t ptrlen)
{
- memset_s (*__ptr, ptrlen+1, 0, ptrlen);
- free (*__ptr);
- *__ptr = NULL;
- return;
+ memset_s (*__ptr, ptrlen + 1, 0, ptrlen);
+ free (*__ptr);
+ *__ptr = NULL;
+ return;
}
void *
malloc_secure (size_t len)
{
- void *mem = calloc (1, len);
- return mem;
+ void *mem = calloc (1, len);
+ return mem;
}
int
-memvcmp (void *str,
- char val,
- size_t n)
+memvcmp (void *str, char val, size_t n)
{
- char str2[n];
- memset (str2, val, n);
- return memcmp (str, str2, n);
+ char str2[n];
+ memset (str2, val, n);
+ return memcmp (str, str2, n);
}
size_t
fcopy (FILE *src, FILE *dst)
{
- char buffer[BUFSIZ];
- size_t n, copied = 0;
+ char buffer[BUFSIZ];
+ size_t n, copied = 0;
- if (src == NULL || dst == NULL)
- return -1;
+ if (src == NULL || dst == NULL)
+ return -1;
- while ((n = fread (buffer, sizeof (char), sizeof (buffer), src)) > 0)
- {
- if (fwrite (buffer, sizeof (char), n, dst) != n) {
- fprintf (stderr, "Failed to copy data");
- return -1;
+ while ((n = fread (buffer, sizeof (char), sizeof (buffer), src)) > 0)
+ {
+ if (fwrite (buffer, sizeof (char), n, dst) != n)
+ {
+ fprintf (stderr, "Failed to copy data");
+ return -1;
+ }
+ fflush (dst);
+ copied += n;
}
- fflush (dst);
- copied += n;
- }
- return copied;
+ return copied;
}
int
-rmfile(const char *fpath,
- const struct stat *sb,
- int typeflag,
- struct FTW *ftwbuf)
+rmfile (const char *fpath,
+ const struct stat *sb, int typeflag, struct FTW *ftwbuf)
{
- int err = remove (fpath);
- if (err < 0)
- return err;
- return 0;
+ int err = remove (fpath);
+ if (err < 0)
+ return err;
+ return 0;
}
int
-rrmdir(char *pathname)
+rrmdir (char *pathname)
{
- int err = nftw (pathname, rmfile, 10, FTW_DEPTH|FTW_MOUNT|FTW_PHYS);
- if (err < 0)
- return err;
- return 0;
+ int err = nftw (pathname, rmfile, 10, FTW_DEPTH | FTW_MOUNT | FTW_PHYS);
+ if (err < 0)
+ return err;
+ return 0;
}